Sfoglia il codice sorgente

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

LAPTOP-KB9HII50\70708 1 anno fa
parent
commit
08ade9b5ba
39 ha cambiato i file con 7601 aggiunte e 3400 eliminazioni
  1. 20 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/FrequencyDao.java
  2. 4 4
      business/base-service/src/main/java/com/yihu/jw/hospital/HospitalDao.java
  3. 20 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/MessageNoticeSettingDao.java
  4. 18 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SpecialistDynamicMessagesDao.java
  5. 175 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/SystemMessageService.java
  6. 87 0
      business/base-service/src/main/java/com/yihu/jw/hospital/team/dao/SignPatientLabelInfoDao.java
  7. 29 6
      business/base-service/src/main/java/com/yihu/jw/hospital/team/dao/WlyyAdminTeamDao.java
  8. 232 227
      business/base-service/src/main/java/com/yihu/jw/hospital/team/dao/WlyySignFamilyDao.java
  9. 962 0
      business/base-service/src/main/java/com/yihu/jw/jw/service/JwArchivesService.java
  10. 1370 0
      business/base-service/src/main/java/com/yihu/jw/jw/service/JwSmjkService.java
  11. 18 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/PatientEventDao.java
  12. 256 189
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  13. 40 0
      business/base-service/src/main/java/com/yihu/jw/system/dao/SystemDictDao.java
  14. 148 0
      business/base-service/src/main/java/com/yihu/jw/system/service/SystemDictService.java
  15. 2 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseFrequencyDictDO.java
  16. 22 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictDO.java
  17. 91 0
      common/common-entity/src/main/java/com/yihu/jw/entity/door/SignPatientLabelInfo.java
  18. 178 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/MessageNoticeSetting.java
  19. 191 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SpecialistDynamicMessages.java
  20. 107 78
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/team/WlyyAdminTeamDO.java
  21. 56 0
      common/common-util/src/main/java/com/yihu/jw/util/DoctorAssistantUtil.java
  22. 14 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  23. 38 0
      common/common-util/src/main/java/com/yihu/jw/util/encrypt/MD5.java
  24. 2 0
      common/common-util/src/main/java/com/yihu/jw/util/html/HtmlUtil.java
  25. 1 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/async/AsynService.java
  26. 39 13
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/dao/FollowUpDao.java
  27. 2322 2237
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java
  28. 149 145
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/RehabilitationManageController.java
  29. 9 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/dao/PatientDischargeDao.java
  30. 26 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/dao/RehabilitationPatientInfoDao.java
  31. 304 311
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/PatientRecordService.java
  32. 148 147
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationInfoService.java
  33. 6 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java
  34. 242 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationPlanService.java
  35. 66 41
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/SynchronizePatientService.java
  36. 159 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/ZsRehabilitationInfoService.java
  37. 29 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/specialist/dao/PatientDiseaseServerDao.java
  38. 19 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/specialist/dao/PatientMedicalRecordsRehabilitationDao.java
  39. 2 0
      svr/svr-visit-behind/src/main/resources/application.yml

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/FrequencyDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.hospital.doctor.Frequency;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by wzn54 on 2019/1/17.
 */
public interface FrequencyDao extends PagingAndSortingRepository<Frequency, Long>, JpaSpecificationExecutor<Frequency> {
    @Query("select f from Frequency f where  f.del=1 and f.code <> 'bid_2-14' ")
    List<Frequency> findByDel();
    @Query("select f from Frequency  f where f.del=1 and f.code=?1 ")
    Frequency findByCode(String code);
}

+ 4 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/HospitalDao.java

@ -2,14 +2,14 @@ package com.yihu.jw.hospital;
import com.yihu.jw.entity.hospital.DmHospitalDO;
import com.yihu.jw.entity.hospital.team.WlyyAdminTeamDO;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/MessageNoticeSettingDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.hospital.message.dao;
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2017/11/27.
 */
public interface MessageNoticeSettingDao extends PagingAndSortingRepository<MessageNoticeSetting, Long>, JpaSpecificationExecutor<MessageNoticeSetting> {
    @Query("from MessageNoticeSetting a where a.user = ?1 and a.type=?2")
    MessageNoticeSetting findByUserAndType(String user, String type);
//    @Query("from MessageNoticeSetting a where a.id = ?1")
//    MessageNoticeSetting findById(Long id);
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SpecialistDynamicMessagesDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.hospital.message.dao;
import com.yihu.jw.entity.hospital.message.SpecialistDynamicMessages;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2023/5/23.
 */
public interface SpecialistDynamicMessagesDao extends PagingAndSortingRepository<SpecialistDynamicMessages, Long>,
        JpaSpecificationExecutor<SpecialistDynamicMessages> {
    @Query("select m from SpecialistDynamicMessages m where m.createTime>?1 and m.createTime<?2 and m.diseaseType=?3 group by m.name,m.code,m.createTime order by m.createTime desc ")
    Page<SpecialistDynamicMessages> findByTime(String createTime, String endTime, String diseaseType, Pageable pageRequest);
}

+ 175 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/SystemMessageService.java

@ -5,10 +5,18 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
import com.yihu.jw.entity.hospital.message.SpecialistDynamicMessages;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.message.dao.MessageNoticeSettingDao;
import com.yihu.jw.hospital.message.dao.SpecialistDynamicMessagesDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.system.service.SystemDictService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.YkyySMSService;
import com.yihu.jw.utils.hibernate.HibenateUtils;
@ -16,10 +24,12 @@ import com.yihu.jw.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.Map;
/**
 * @author zmk
@ -45,6 +55,15 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
    @Autowired
    private HibenateUtils hibenateUtils;
    private final String MESSAGE_NOTICESETTING = "wlyy:message:setting:";
    @Autowired
    private MessageNoticeSettingDao messageNoticeSettingDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    SystemDictService systemDictService;
    @Autowired
    SpecialistDynamicMessagesDao specialistDynamicMessagesDao;
    /**
     * 新增线上就诊消息
@ -183,4 +202,160 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
    }*/
    /**
     * 获取消息提示开关
     * @param user
     * @param type
     * @param messageType
     * @return (1开,0关)
     */
    public Boolean getMessageNoticeSettingByMessageType(String user,String type,String messageType){
        Integer re = 0;
        com.alibaba.fastjson.JSONObject setting = getMessageNoticSetting(user,type);
        Integer masterSwitch = setting.getInteger("masterSwitch");
        if(masterSwitch==0){
            return false;
        }
        switch (messageType){
            case "masterSwitch":
                //总开关
                re = masterSwitch;
                break;
            case "imSwitch":
                //im消息开关
                re = setting.getInteger("imSwitch");
                break;
            case "familyTopicSwitch":
                //健管师邀请后推送开关
                Integer imSwitch = setting.getInteger("imSwitch");
                if(imSwitch==1){
                    re = setting.getInteger("familyTopicSwitch");
                }
                break;
            case "signSwitch":
                //签约消息开关
                re = setting.getInteger("signSwitch");
                break;
            case "healthSignSwitch":
                //体征消息开关
                re = setting.getInteger("healthSignSwitch");
                break;
            case "systemSwitch":
                //系统消息开关
                re = setting.getInteger("systemSwitch");
                break;
            case "prescriptionSwitch":
                //续方消息开关
                re = setting.getInteger("prescriptionSwitch");
                break;
            case "soundSwitch":
                //铃声提醒开关
                re = setting.getInteger("soundSwitch");
                break;
            case "vibrationSwitch":
                //振动提醒开关
                re = setting.getInteger("vibrationSwitch");
                break;
            case "coordinationSwitch":
                //协同消息开关
                re = setting.getInteger("coordinationSwitch");
                break;
            default:
                break;
        }
        return re==1;
    }
    /**
     * 获取消息提醒设置
     * @param user
     * @param type
     * @return
     */
    public com.alibaba.fastjson.JSONObject getMessageNoticSetting(String user, String type){
        com.alibaba.fastjson.JSONObject re = null;
        String key = MESSAGE_NOTICESETTING+user+":"+type;
        String response = redisTemplate.opsForValue().get(key);
        if(StringUtils.isBlank(response)){
            MessageNoticeSetting messageNoticeSetting = messageNoticeSettingDao.findByUserAndType(user,type);
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(0);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);
                messageNoticeSetting.setMasterSwitch(1);
                messageNoticeSetting.setPrescriptionSwitch(1);
                messageNoticeSetting.setSignSwitch(1);
                messageNoticeSetting.setSoundSwitch(1);
                messageNoticeSetting.setSystemSwitch(1);
                messageNoticeSetting.setType(type);
                messageNoticeSetting.setUser(user);
                messageNoticeSetting.setVibrationSwitch(1);
                messageNoticeSettingDao.save(messageNoticeSetting);
            }
            response = com.alibaba.fastjson.JSONObject.toJSONString(messageNoticeSetting);
            redisTemplate.opsForValue().set(key,response);
        }
        re = com.alibaba.fastjson.JSONObject.parseObject(response);
        return re;
    }
    //添加专科动态消息
    public void addSpecialistDynamicMessages(BasePatientDO patient, BaseDoctorDO specialist, BaseDoctorDO doctor, String result, String disease, String type, SignFamily signFamily){
        try {
            String patientName = patient.getName();
            String doctorName = "";
            String specialistName = specialist.getName();
            SpecialistDynamicMessages specialistDynamicMessages = new SpecialistDynamicMessages();
            specialistDynamicMessages.setAddress(patient.getAddress());
            specialistDynamicMessages.setResult(result);
            specialistDynamicMessages.setName(patientName);
            specialistDynamicMessages.setCode(patient.getId());
            if(doctor!=null){
//                specialistDynamicMessages.setDoctor(doctor.getCode());
//                specialistDynamicMessages.setHospital(doctor.getHospital());
                doctorName = doctor.getName();
            }else if(signFamily!=null){
                specialistDynamicMessages.setDoctor(signFamily.getDoctor());
                specialistDynamicMessages.setHospital(signFamily.getHospital());
                doctorName = signFamily.getDoctorName();
            }
//            specialistDynamicMessages.setSpecialist(specialist.getCode());
//            specialistDynamicMessages.setSpecialistHospital(specialist.getHospital());
            specialistDynamicMessages.setDiseaseType(disease);
            specialistDynamicMessages.setCodeType("2");
            specialistDynamicMessages.setCreateTime(DateUtil.getStringDate());
            specialistDynamicMessages.setType(type);
            Map<String,String> copywritingMap = systemDictService.getDictMap("DynamicMessages"+type);
            //获取文案模板
            String content = copywritingMap.get("doctor");
            content = content.replace("【医生】",specialistName).replace("【居民】",patientName);
            //【医生】专科医生给您下转了居民【居民】
            //您代居民【居民】预约了【医生】专科医生的门诊
            //您向【医生】专科医生的发起了专科协同,居民【居民】
            //您向【医生】专科医生的发起了咨询求助,居民【居民】
            String specialistContent = copywritingMap.get("specialist");
            specialistContent = specialistContent.replace("【医生】",doctorName).replace("【居民】",patientName);
            //您给社区医生【医生】下转了居民【居民】
            //【医生】社区医生代居民【居民】预约了您的门诊
            //【医生】社区医生向您发起了专科协同,居民【居民】
            //【医生】社区医生向您发起了咨询求组,居民【居民】
            specialistDynamicMessages.setContent(content);
            specialistDynamicMessages.setSpecialistContent(specialistContent);
            specialistDynamicMessagesDao.save(specialistDynamicMessages);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 87 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/team/dao/SignPatientLabelInfoDao.java

@ -0,0 +1,87 @@
package com.yihu.jw.hospital.team.dao;
import com.yihu.jw.entity.door.SignPatientLabelInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/10/9.
 */
public interface SignPatientLabelInfoDao extends
        PagingAndSortingRepository<SignPatientLabelInfo, Long>,
        JpaSpecificationExecutor<SignPatientLabelInfo> {
//    /**
//     * 查询某个患者的标签
//     *
//     * @param patient 患者
//     * @param status  状态
//     * @return
//     */
//    List<SignPatientLabelInfo> findByPatientAndStatus(String patient, Integer status);
//
//    /**
//     * 查询某个患者的标签
//     *
//     * @param patient 患者
//     * @param status  状态
//     * @return
//     */
//    @Query("select f from SignPatientLabelInfo f,SignPatientLabel l where f.patient = ?1 and f.status = ?2 and f.label = l.labelCode and f.labelType =l.labelType" +
//            " and l.status = ?2 and (l.labelType <> '4' or l.teamCode = ?3 or ( l.labelType = '4' and l.labelCode in (1,2)) )")
//    List<SignPatientLabelInfo> findByPatientAndStatusByTeam(String patient, Integer status, Long teamCode);
    /**
     * 查询某个患者的某个类型标签
     *
     * @param patient   患者
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
//    /**
//     * 查询某个患者的某个类型的某个标签
//     *
//     * @param patient   患者
//     * @param labelCode  标签代码
//     * @param labelType 标签类型
//     * @param status    状态
//     * @return
//     */
//    SignPatientLabelInfo findByPatientAndLabelAndLabelTypeAndStatus(String patient, String labelCode, String labelType, Integer status);
    /**
     * 删除患者的某个标签类型的所有指定状态标签
     *
     * @param patient
     * @param labelType
     * @param status
     * @return
     */
    @Modifying
    @Query("update SignPatientLabelInfo set status = 0 where patient = ?1 and labelType = ?2 and status = ?3")
    int deleteByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
//    @Modifying
//    @Query("update SignPatientLabelInfo set status = 0 where label = ?1 and status = 1")
//    int deleteByLabel(String labelCode);
    /**
     * 更新某个标签名称
     *
     * @param labelName
     * @param labelCode
     * @return
     */
//    @Modifying
//    @Query("update SignPatientLabelInfo a set a.labelName = ?1 where a.label= ?2 and a.labelType = '4' ")
//    int updateLabelName(String labelName, String labelCode);
}

+ 29 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/team/dao/WlyyAdminTeamDao.java

@ -1,20 +1,43 @@
package com.yihu.jw.hospital.team.dao;
import com.yihu.jw.entity.hospital.team.WlyyAdminTeamDO;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.hospital.team.*;
import java.util.List;
public interface WlyyAdminTeamDao extends JpaRepository<WlyyAdminTeamDO, Integer>, JpaSpecificationExecutor<WlyyAdminTeamDO> {
    @Query("from WlyyAdminTeamDO  t where t.orgCode=?1 and t.available=1")
    List<WlyyAdminTeamDO> findTeamByOrgCode(String orgCode, Pageable pageRequest);
    @Query("from WlyyAdminTeamDO  t where t.available=1")
////    @Query("from WlyyAdminTeamDO  t where t.orgCode=?1 and t.available=1")
//    @Query("from WlyyAdminTeamDO  t where t.orgCode=?1 ")
//    List<WlyyAdminTeamDO> findTeamByOrgCode(String orgCode, Pageable pageRequest);
//    @Query("from WlyyAdminTeamDO  t where 1=1 and t.available='1' ")
    @Query("from WlyyAdminTeamDO  t where 1=1  ")
    List<WlyyAdminTeamDO> findTeamAndAvailable();
    @Query(value = "select t.id from WlyyAdminTeamDO t " +
            "where t.specialCode=?1 and t.acceptType=?2 and t.orgCode=?3 and t.available=true")
    Long findTeamID(String specialCode, Integer acceptType, String orgCode);
    @Query(value = "select t.leaderCode from WlyyAdminTeamDO t " +
            "where t.specialCode=?1 and t.acceptType=?2 and t.orgCode=?3 and t.available=true")
    String findTeamLeader(String specialCode, Integer acceptType, String orgCode);
    @Query(value = "select count(1) from WlyyAdminTeamDO t " +
            "where t.specialCode=?1 and t.acceptType=?2 and t.orgCode=?3 and t.available=true ")
    Integer findAcceptTeamCount(String specialCode, Integer acceptType, String orgCode);
//    @Query(value = "select t from WlyyAdminTeamDO t where t.id=?1")
//    WlyyAdminTeamDO findAdminTeamById(Long teamId);
//
//    @Query(value = "select t from WlyyAdminTeamDO t where t.orgCode=?1 and t.leaderCode=?2 and t.available=true ")
//    List<WlyyAdminTeamDO> findAdminTeamByLeaderCode(String hospital,String doctor);
}

+ 232 - 227
business/base-service/src/main/java/com/yihu/jw/hospital/team/dao/WlyySignFamilyDao.java

@ -1,69 +1,74 @@
package com.yihu.jw.hospital.team.dao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.hospital.team.WlyyAdminTeamDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface WlyySignFamilyDao extends JpaRepository<SignFamily, Integer>, JpaSpecificationExecutor<SignFamily> {
    @Query("select count(*) from SignFamily  t where t.doctor=?1 and t.status=1")
    Integer getCountByDoctorCode(String doctor);
    @Query("select count(1) from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
    int hasSingStatus(String idcard);
    @Modifying
    @Query("update SignFamily a set a.mobile = ?2 where a.patient = ?1")
    int updatePatientMobile(String patient, String mobile);
    @Query("select a from SignFamily a where a.idcard = ?1 and status = ?2 and a.type = 2")
    SignFamily findByPatientStatus(String idcard, int status);
    @Query("select a from SignFamily a where a.patient = ?1 and status = ?2 and a.type = 2")
    SignFamily findByPatientCodeStatus(String patient, int status);
    @Query("select a from SignFamily a where a.patient = ?1 and status >= ?2 and a.type = 2")
    SignFamily findByPatientCodeStatus2(String patient, int status);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status >= 1")
    SignFamily findByPatientAndType(String patient, int type);
    SignFamily findByCodeAndType(String code, Integer type);
    SignFamily findByTeamCode(String TeamCode);
    @Query("select a from SignFamily a where a.teamCode = ?1 and a.type = 2 and a.code=?2")
    List<SignFamily> findByTeamCodeIsValid(String teamCode, String code);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    SignFamily findByDoctorPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and (a.type = 2 or a.type=1) and a.status >= 0")
    List<SignFamily> findSSandFamilyByDoctorPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctorHealth = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0 ")
    SignFamily findByDoctorHealthPatient(String doctor, String patient);
    @Query("select p from Patient p,SignFamily a where a.doctorHealth = ?1  and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
    List<Patient> findByDoctorHealthPatient(String doctor, Long team);
    @Query("select p from Patient p,SignFamily a where a.doctor = ?1 and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
    List<Patient> findByDoctorPatient(String doctor, Long team);
    @Query("select a from SignFamily a,DoctorTeamMember w where a.teamCode = w.team and w.del = '1' and w.memberCode = ?1 and a.patient = ?2 and a.status > 0")
    List<SignFamily> findByDoctorAndPatient(String doctor, String patient);
    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamily> findByDoctorAndPatientIsValid(String doctor, String patient, String signYear);
    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamily> findByDoctorHealthAndPatientIsValid(String doctorHealth, String patient, String signYear);
//    @Query("select count(*) from SignFamily  t where t.doctor=?1 and t.status=1")
//    Integer getCountByDoctorCode(String doctor);
//    @Query("select count(1) from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
//    int hasSingStatus(String idcard);
//    @Modifying
//    @Query("update SignFamily a set a.mobile = ?2 where a.patient = ?1")
//    int updatePatientMobile(String patient, String mobile);
//    @Query("select a from SignFamily a where a.idcard = ?1 and status = ?2 and a.type = 2")
//    SignFamily findByPatientStatus(String idcard, int status);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and status = ?2 and a.type = 2")
//    SignFamily findByPatientCodeStatus(String patient, int status);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and status >= ?2 and a.type = 2")
//    SignFamily findByPatientCodeStatus2(String patient, int status);
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status >= 1")
//    SignFamily findByPatientAndType(String patient, int type);
//
//    SignFamily findByCodeAndType(String code, Integer type);
//
//    SignFamily findByTeamCode(String TeamCode);
//
//    @Query("select a from SignFamily a where a.teamCode = ?1 and a.type = 2 and a.code=?2")
//    List<SignFamily> findByTeamCodeIsValid(String teamCode, String code);
//
//    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
//    SignFamily findByDoctorPatient(String doctor, String patient);
//
//    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and (a.type = 2 or a.type=1) and a.status >= 0")
//    List<SignFamily> findSSandFamilyByDoctorPatient(String doctor, String patient);
//
//    @Query("select a from SignFamily a where a.doctorHealth = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0 ")
//    SignFamily findByDoctorHealthPatient(String doctor, String patient);
//    @Query("select p from BasePatientDO p,SignFamily a where a.doctorHealth = ?1  and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
//    List<BasePatientDO> findByDoctorHealthPatient(String doctor, Long team);
//
//    @Query("select p from BasePatientDO p,SignFamily a where a.doctor = ?1 and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
//    List<BasePatientDO> findByDoctorPatient(String doctor, Long team);
//    @Query("select a from SignFamily a,DoctorTeamMember w " +
//            "where a.teamCode = w.team and w.del = '1' and w.memberCode = ?1 and a.patient = ?2 and a.status > 0 ")
//    List<SignFamily> findByDoctorAndPatient(String doctor, String patient);
//    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
//    List<SignFamily> findByDoctorAndPatientIsValid(String doctor, String patient, String signYear);
//
//    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
//    List<SignFamily> findByDoctorHealthAndPatientIsValid(String doctorHealth, String patient, String signYear);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 2")
    SignFamily findByFamilyDoctorAndPatient(String doctor, String patient);
@ -77,114 +82,114 @@ public interface WlyySignFamilyDao extends JpaRepository<SignFamily, Integer>, J
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status > 0 and a.expensesStatus ='1'")
    SignFamily getExpensesSignByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type =1 and a.status >= 0")
    SignFamily findSSByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 ")
    List<SignFamily> findAllByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.status >= 0")
    List<SignFamily> findSSandJTByIdcard(String idcard);
    // 拒绝解约
    @Modifying
    @Query("update SignFamily a set a.status = 1 where a.patient = ?1 and a.status = 2 and a.type = 2")
    int refuseSurrender(String patient);
    // 查询患者已生效的家庭签约
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status > 0")
    SignFamily findSignByPatient(String patient);
    @Modifying
    @Query("update SignFamily a set a.openid = ?1 where a.patient = ?2")
    int updateOpenidByPatient(String openid, String patient);
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.type =1 and a.status >= 0")
//    SignFamily findSSByIdcard(String idcard);
//
//    @Query("select a from SignFamily a where a.idcard = ?1 ")
//    List<SignFamily> findAllByIdcard(String idcard);
//
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.status >= 0")
//    List<SignFamily> findSSandJTByIdcard(String idcard);
//    // 拒绝解约
//    @Modifying
//    @Query("update SignFamily a set a.status = 1 where a.patient = ?1 and a.status = 2 and a.type = 2")
//    int refuseSurrender(String patient);
//
//    // 查询患者已生效的家庭签约
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status > 0")
//    SignFamily findSignByPatient(String patient);
//
//    @Modifying
//    @Query("update SignFamily a set a.openid = ?1 where a.patient = ?2")
//    int updateOpenidByPatient(String openid, String patient);
    // 查询已签约的总数
    @Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and (a.status = 1 or a.status = 2) and a.type = 2")
    int countAmountSignedByDoctor(String doctor);
//    @Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and (a.status = 1 or a.status = 2) and a.type = 2")
//    int countAmountSignedByDoctor(String doctor);
    // 查询待签约总数
    @Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and a.status = 0 and a.type = 2")
    int countAmountUnsignByDoctor(String doctor);
//    @Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and a.status = 0 and a.type = 2")
//    int countAmountUnsignByDoctor(String doctor);
    @Query("select a from SignFamily a where a.mobile = ?1 and a.type = 2 and a.status >= 0")
    SignFamily findByMobile(String mobile);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 1")
    SignFamily findBySanshiPatient(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 0")
    SignFamily findBySsPatient(String code);
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 1")
//    SignFamily findBySanshiPatient(String code);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 0")
//    SignFamily findBySsPatient(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 1")
    SignFamily findByjiatingPatient(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status = 1")
    SignFamily findByjiatingPatientYes(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status = 1")
    SignFamily findBySanshiPatientYes(String id);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status in (0,1,2,3)")
    SignFamily findByPatientSanshiSignInfo(String idCard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status in (0,1,2,3)")
    SignFamily findByPatientFamilySignInfo(String idCard);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >=0")
    SignFamily findByjiatingPatientStatus0(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 1 and a.status in (0,1,2)")
    SignFamily findSanshiSignByPatient(String patientCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status in (0,1,2)")
    SignFamily findFamilySignByPatient(String patientCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status =-4 and a.signYear =?2")
    SignFamily findFamilySignByPatientOverDue(String patientCode, String signYear);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatients(String doctor);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and p.name like ?2 and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatientsLikeName(String doctor, String name);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatientsBySignType(String doctor, int type);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and p.name like ?3 and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatientsByTypeName(String doctor, int type, String name);
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status = 1")
//    SignFamily findByjiatingPatientYes(String code);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status = 1")
//    SignFamily findBySanshiPatientYes(String id);
//
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status in (0,1,2,3)")
//    SignFamily findByPatientSanshiSignInfo(String idCard);
//
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status in (0,1,2,3)")
//    SignFamily findByPatientFamilySignInfo(String idCard);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >=0")
//    SignFamily findByjiatingPatientStatus0(String patient);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 1 and a.status in (0,1,2)")
//    SignFamily findSanshiSignByPatient(String patientCode);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status in (0,1,2)")
//    SignFamily findFamilySignByPatient(String patientCode);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status =-4 and a.signYear =?2")
//    SignFamily findFamilySignByPatientOverDue(String patientCode, String signYear);
//    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.patient = p.code and a.status in (1,2,3)")
//    List<Object> findDoctorSignPatients(String doctor);
//
//    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and p.name like ?2 and a.patient = p.code and a.status in (1,2,3)")
//    List<Object> findDoctorSignPatientsLikeName(String doctor, String name);
//    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and a.patient = p.code and a.status in (1,2,3)")
//    List<Object> findDoctorSignPatientsBySignType(String doctor, int type);
//
//    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and p.name like ?3 and a.patient = p.code and a.status in (1,2,3)")
//    List<Object> findDoctorSignPatientsByTypeName(String doctor, int type, String name);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
    SignFamily findByPatient(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.signYear =?2 and a.status in (-4,1,2,3) order by a.id desc ")
    List<SignFamily> findByPatientsLastYear(String patient, String signYear);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status >= 0")
    SignFamily findBySanshiIdcard(String idcard);
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.signYear =?2 and a.status in (-4,1,2,3) order by a.id desc ")
//    List<SignFamily> findByPatientsLastYear(String patient, String signYear);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status > 0")
    SignFamily findSignByPatient(String patient, int type);
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status >= 0")
//    SignFamily findBySanshiIdcard(String idcard);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status > 0")
//    SignFamily findSignByPatient(String patient, int type);
    SignFamily findByCode(String code);
    @Query(" from SignFamily a where a.patient = ?1 and a.type = ?2 and (a.status=-3 or a.status=-4)  order by a.id desc")
    List<SignFamily> findLastJySignByPatient(String patient, int type);
//    @Query(" from SignFamily a where a.patient = ?1 and a.type = ?2 and (a.status=-3 or a.status=-4)  order by a.id desc")
//    List<SignFamily> findLastJySignByPatient(String patient, int type);
    @Query(" from SignFamily a where  a.type =1 and unix_timestamp(a.czrq)=unix_timestamp( ?1 )  ")
    List<SignFamily> findByDate(String s);
//    @Query(" from SignFamily a where  a.type =1 and unix_timestamp(a.czrq)=unix_timestamp( ?1 )  ")
//    List<SignFamily> findByDate(String s);
    @Modifying
    @Query("update SignFamily set expenses_type = ?1 where patient = ?2 and status > 0 and type = 2")
    int updateExpensesType(String expensesType, String patient);
    @Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 1")
    int countPatientSsSign(String patient);
    @Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 2")
    int countPatientJtSign(String patient);
//    @Modifying
//    @Query("update SignFamily set expenses_type = ?1 where patient = ?2 and status > 0 and type = 2")
//    int updateExpensesType(String expensesType, String patient);
//
//    @Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 1")
//    int countPatientSsSign(String patient);
//
//    @Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 2")
//    int countPatientJtSign(String patient);
    // 查询患者已生效的家庭签约
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status = 0")
@ -197,15 +202,15 @@ public interface WlyySignFamilyDao extends JpaRepository<SignFamily, Integer>, J
    //找出没有健康管理师的签约数据
    @Query("select a from SignFamily a where a.type = 2 and a.status >= 1 and a.doctorHealth is null and a.adminTeamId = ?1 order by a.czrq desc")
    List<SignFamily> findNoHealthSignFamilyNum(Long teamCode);
    @Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 order by a.id")
    Page<SignFamily> findByTypeAndSignSource(Integer type, String signSource, Pageable pageable);
    @Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
    Page<SignFamily> findByTypeAndSignSourceAndId(Integer type, String signSource, Long start, Long end, Pageable pageable);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
    List<SignFamily> findAllSignByPatient(String patient);
//
//    @Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 order by a.id")
//    Page<SignFamily> findByTypeAndSignSource(Integer type, String signSource, Pageable pageable);
//
//    @Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
//    Page<SignFamily> findByTypeAndSignSourceAndId(Integer type, String signSource, Long start, Long end, Pageable pageable);
//
//    @Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
//    List<SignFamily> findAllSignByPatient(String patient);
    /**
     * 获取所有有效的签约信息(不包含-1 -2)
@ -213,11 +218,11 @@ public interface WlyySignFamilyDao extends JpaRepository<SignFamily, Integer>, J
     * @param patient
     * @return
     */
    @Query("select a from SignFamily a where a.patient = ?1 and a.status <> -1 and a.status <> -2 order by a.czrq")
    List<SignFamily> findAllActiveSignByPatient(String patient);
    @Query("select a.patient from SignFamily a where a.doctor = ?1 and a.type = 2 and a.status > 0 and a.doctorHealth is null")
    List<String> findNohealthByDoctor(String doctor);
//    @Query("select a from SignFamily a where a.patient = ?1 and a.status <> -1 and a.status <> -2 order by a.czrq")
//    List<SignFamily> findAllActiveSignByPatient(String patient);
//
//    @Query("select a.patient from SignFamily a where a.doctor = ?1 and a.type = 2 and a.status > 0 and a.doctorHealth is null")
//    List<String> findNohealthByDoctor(String doctor);
    /**
     * 获取团队中有效的患者
@ -226,79 +231,79 @@ public interface WlyySignFamilyDao extends JpaRepository<SignFamily, Integer>, J
     * @param status
     * @return
     */
    @Query("select count(f) from SignFamily f where f.adminTeamId = ?1 and f.status >= ?2 ")
    int findByAdminTeamIdAndStatus(long teamCode, int status);
    @Query("select f from SignFamily f where f.patient = ?1 and f.adminTeamId = ?2 and f.status > 0 and f.type = ?3")
    SignFamily findByPatientAndAdminTeamId(String patient, Long teamCode, Integer type);
    @Query(value = " select a.*  from wlyy_sign_family a where a.patient = ?1  and a.status = -4 order by a.apply_date desc limit 0,1", nativeQuery = true)
    SignFamily findOutTimeSigningByPatient(String patient);
//    @Query("select count(f) from SignFamily f where f.adminTeamId = ?1 and f.status >= ?2 ")
//    int findByAdminTeamIdAndStatus(long teamCode, int status);
//
//    @Query("select f from SignFamily f where f.patient = ?1 and f.adminTeamId = ?2 and f.status > 0 and f.type = ?3")
//    SignFamily findByPatientAndAdminTeamId(String patient, Long teamCode, Integer type);
//
//    @Query(value = " select a.*  from wlyy_sign_family a where a.patient = ?1  and a.status = -4 order by a.apply_date desc limit 0,1", nativeQuery = true)
//    SignFamily findOutTimeSigningByPatient(String patient);
    //      完成缴费后更新签约开始时间begin 缴费状态expensesStatus 医保流水号medical_insurance_num  扣费时间expenses_time
    @Modifying
    @Query("update SignFamily a set a.begin = ?2 ,a.medicalInsuranceNum=?3,a.expensesStatus = ?4,a.expensesTime = ?2,a.signPaySource = ?5 where a.code = ?1 ")
    int updatePatientBegin(String code, Date begin, String medicalInsuranceNum, String expensesStatus, int signPaySource );
    //查询65岁以上一年内未体检且未系统提醒的签约居民
    @Query(value = "SELECT DISTINCT t1.* FROM wlyy_sign_family t1 LEFT JOIN wlyy_physical_examination_records r ON r.patient_code=t1.patient WHERE r.patient_code IS NULL " +
            " AND t1.STATUS>0 AND t1.hospital=?1 AND(YEAR(curdate())-IF(length(idcard)=18,substring(idcard,7,4),IF(length(idcard)=15,concat('19',substring(idcard,7,2)),NULL)))>=65 " +
            " AND t1.idcard NOT IN(SELECT DISTINCT s.idcard FROM wlyy_sign_family s,wlyy_old_people_physical_examination o WHERE s.hospital=?1 AND s.`status`>0 AND s.idcard=o.id_card " +
            " AND o.medical_time>?2 )ORDER BY t1.openid DESC,CONVERT(t1.NAME USING gbk) ",nativeQuery = true)
    List<SignFamily> findExaminationByHospital(String hospital,Date examinationTime);
    //查询wlyy_sign_family有续签却未同步到wlyy_sign_family_renew_log数据
    @Query(value = "SELECT f.* FROM wlyy_sign_family f LEFT JOIN wlyy_sign_family_renew_log r ON f.`code` = r.sign_code WHERE r.sign_code IS NULL  " +
            " AND f.renew_flag IN (1, 2) AND f.`status` IN (1, 2)  ",nativeQuery = true)
    List<SignFamily> findRenew();
    //根据身份证号查询最近的已到期签约数据
    @Query(value = "SELECT f.* FROM wlyy_sign_family f WHERE f.idcard = ?1 and f.`status` = -4 ORDER BY sign_year desc LIMIT 0,1 ",nativeQuery = true)
    SignFamily findLatelyRenew(String idcard);
    //查询wlyy_sign_family有效签约且居民的医疗保险号为空的数据
    @Query(value = "select a.idcard from wlyy_sign_family a left join wlyy_patient b on a.idcard = b.idcard where a.hospital = ?1 and (a.type = 2 or a.type = 1) " +
            "and a.status = 1 and a.expenses_status = 1 and (b.medicare_number is null or b.medicare_number = '')", nativeQuery = true)
    List<String> findIdcardByStatus(String hospital);
    /**
     * 判断是否已存在待处理签约
     */
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status = 0")
    SignFamily findByIdcardPre(String idcard);
    /**
     * 判断是否存在去年签约
     */
    @Query("select a from SignFamily a where a.idcard = ?1 and a.signYear=?2 and a.type = 2 and (a.status= -4 or a.status>0) and a.expensesStatus = '1'")
    SignFamily findOldSign(String idcard,String signYear);
    /**
     * 【临时】清洗
     */
    List<SignFamily> findByRenewFlag(String renewflag);
    /**
     * 【临时】清洗未扣费
     */
    @Query("select a from SignFamily a where a.status>0 and a.expensesStatus='0' and a.signYear='2017'")
    List<SignFamily> findNoExpenses(Pageable pageable);
    /**
     * 【临时】退费
     */
    @Query("select a from SignFamily a where a.status>0 and a.expensesStatus='3' and a.signYear='2017'")
    List<SignFamily> findReCharge();
    /**
     * 通过医生原有团队是否有签约
     */
    @Query("select a from SignFamily a where a.doctor = ?1 and a.adminTeamId =?2 and a.status > 0")
    List<SignFamily> findByDoctorAndAdminTeamCode(String doctor,Long adminTeamCode);
    /**
     * 判断是否三师签约
     */
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status > 0")
    SignFamily findSanshiByIdcard(String idcard);
//    @Modifying
//    @Query("update SignFamily a set a.begin = ?2 ,a.medicalInsuranceNum=?3,a.expensesStatus = ?4,a.expensesTime = ?2,a.signPaySource = ?5 where a.code = ?1 ")
//    int updatePatientBegin(String code, Date begin, String medicalInsuranceNum, String expensesStatus, int signPaySource );
//
//    //查询65岁以上一年内未体检且未系统提醒的签约居民
//    @Query(value = "SELECT DISTINCT t1.* FROM wlyy_sign_family t1 LEFT JOIN wlyy_physical_examination_records r ON r.patient_code=t1.patient WHERE r.patient_code IS NULL " +
//            " AND t1.STATUS>0 AND t1.hospital=?1 AND(YEAR(curdate())-IF(length(idcard)=18,substring(idcard,7,4),IF(length(idcard)=15,concat('19',substring(idcard,7,2)),NULL)))>=65 " +
//            " AND t1.idcard NOT IN(SELECT DISTINCT s.idcard FROM wlyy_sign_family s,wlyy_old_people_physical_examination o WHERE s.hospital=?1 AND s.`status`>0 AND s.idcard=o.id_card " +
//            " AND o.medical_time>?2 )ORDER BY t1.openid DESC,CONVERT(t1.NAME USING gbk) ",nativeQuery = true)
//    List<SignFamily> findExaminationByHospital(String hospital,Date examinationTime);
//
//    //查询wlyy_sign_family有续签却未同步到wlyy_sign_family_renew_log数据
//    @Query(value = "SELECT f.* FROM wlyy_sign_family f LEFT JOIN wlyy_sign_family_renew_log r ON f.`code` = r.sign_code WHERE r.sign_code IS NULL  " +
//            " AND f.renew_flag IN (1, 2) AND f.`status` IN (1, 2)  ",nativeQuery = true)
//    List<SignFamily> findRenew();
//
//    //根据身份证号查询最近的已到期签约数据
//    @Query(value = "SELECT f.* FROM wlyy_sign_family f WHERE f.idcard = ?1 and f.`status` = -4 ORDER BY sign_year desc LIMIT 0,1 ",nativeQuery = true)
//    SignFamily findLatelyRenew(String idcard);
//
//    //查询wlyy_sign_family有效签约且居民的医疗保险号为空的数据
//    @Query(value = "select a.idcard from wlyy_sign_family a left join wlyy_patient b on a.idcard = b.idcard where a.hospital = ?1 and (a.type = 2 or a.type = 1) " +
//            "and a.status = 1 and a.expenses_status = 1 and (b.medicare_number is null or b.medicare_number = '')", nativeQuery = true)
//    List<String> findIdcardByStatus(String hospital);
//
//    /**
//     * 判断是否已存在待处理签约
//     */
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status = 0")
//    SignFamily findByIdcardPre(String idcard);
//
//    /**
//     * 判断是否存在去年签约
//     */
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.signYear=?2 and a.type = 2 and (a.status= -4 or a.status>0) and a.expensesStatus = '1'")
//    SignFamily findOldSign(String idcard,String signYear);
//
//    /**
//     * 【临时】清洗
//     */
//    List<SignFamily> findByRenewFlag(String renewflag);
//
//    /**
//     * 【临时】清洗未扣费
//     */
//    @Query("select a from SignFamily a where a.status>0 and a.expensesStatus='0' and a.signYear='2017'")
//    List<SignFamily> findNoExpenses(Pageable pageable);
//
//    /**
//     * 【临时】退费
//     */
//    @Query("select a from SignFamily a where a.status>0 and a.expensesStatus='3' and a.signYear='2017'")
//    List<SignFamily> findReCharge();
//
//    /**
//     * 通过医生原有团队是否有签约
//     */
//    @Query("select a from SignFamily a where a.doctor = ?1 and a.adminTeamId =?2 and a.status > 0")
//    List<SignFamily> findByDoctorAndAdminTeamCode(String doctor,Long adminTeamCode);
//
//    /**
//     * 判断是否三师签约
//     */
//    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status > 0")
//    SignFamily findSanshiByIdcard(String idcard);
}

File diff suppressed because it is too large
+ 962 - 0
business/base-service/src/main/java/com/yihu/jw/jw/service/JwArchivesService.java


File diff suppressed because it is too large
+ 1370 - 0
business/base-service/src/main/java/com/yihu/jw/jw/service/JwSmjkService.java


+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/PatientEventDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.PatientEvent;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientEventDao extends PagingAndSortingRepository<PatientEvent, Long>, JpaSpecificationExecutor<PatientEvent> {
      @Query("select a from PatientEvent a where a.patient = ?1 order by a.eventDate desc")
      List<PatientEvent> findByPatient(String patient) throws Exception;
      @Query("select a from PatientEvent a where a.patient = ?1 and a.eventType = ?2 order by a.eventDate desc")
      List<PatientEvent> findByPatientAndEventType(String patient, String type) throws Exception;
}

+ 256 - 189
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -14,6 +14,7 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.dao.WlyyInspectionDao;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.jw.service.JwArchivesService;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientGroupDao;
@ -45,11 +46,9 @@ import java.io.IOException;
import java.util.*;
/**
 * 
 * 居民基础信息服务service
 * 
 * @version 
 * <pre>
 *
 * @version <pre>
 * Author	Version		Date		Changes
 * litaohong    1.0  2018年08月31日 Created
 *
@ -62,67 +61,79 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BasePatientMedicardCardService basePatientMedicardCardService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private YkyyService ykyyService;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private OutpatientDao outpatientDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.flag}")
    private boolean flag;
    @Autowired
    private WlyyInspectionDao wlyyInspectionDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private BasePatientGroupDao basePatientGroupDao;
    @Autowired
    private BasePatientGroupDictDao basePatientGroupDictDao;
    @Autowired
    private HospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private HealthCareService healthCareService;
    JwArchivesService jwArchivesService;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.flag}")
    private boolean flag;
    /**
     * 居民id
     *
     * @param patientId
     * @return
     */
    public BasePatientDO findPatientById(String patientId) throws Exception{
    public BasePatientDO findPatientById(String patientId) throws Exception {
        return basePatientDao.findById(patientId).orElse(null);
    }
    public boolean findByIdCard(String idcard){
        BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idcard,"1");
    public boolean findByIdCard(String idcard) {
        BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idcard, "1");
        if (patientDO != null) {
            return true;
        }
        return false;
    }
    public BasePatientDO findInfoByIdCard(String idcard) {
        BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idcard, "1");
        return patientDO;
    }
    /**
     * 居民id
     *
     * @param patientId
     * @return
     */
    public Map getPatientById(String patientId) throws Exception{
    public Map getPatientById(String patientId) throws Exception {
        Map result = new HashMap();
        if(StringUtils.isEmpty(patientId)){
            result.put("result","parameter patientId is null");
        if (StringUtils.isEmpty(patientId)) {
            result.put("result", "parameter patientId is null");
            return result;
        }
        BasePatientDO basePatientDO = basePatientDao.findById(patientId).orElse(null);
@ -134,27 +145,28 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        result.put("patient", basePatientDO);
        List<PatientMedicareCardDO> cards = basePatientMedicardCardService.findPatientCardByCode(patientId);
        if (cards==null||cards.size()==0){
        if (cards == null || cards.size() == 0) {
            System.out.println("new一个list");
            PatientMedicareCardDO patientMedicareCardDO = new PatientMedicareCardDO();
            cards.add(patientMedicareCardDO);
        }
        result.put("medicareCard",cards);
        result.put("medicareCard", cards);
        return result;
    }
    /**
     * 获取用户基础信息,参数为空查全部
     *
     * @param nameOrIdcard
     * @param page
     * @param size
     * @param sorts
     * @return
     */
    public MixEnvelop queryPatientBaseInfo(String nameOrIdcard, int page, int size, String sorts)throws Exception{
    public MixEnvelop queryPatientBaseInfo(String nameOrIdcard, int page, int size, String sorts) throws Exception {
        List<Map<String, Object>> result = new ArrayList<>();
        String param = null == nameOrIdcard ? "": nameOrIdcard;
        String param = null == nameOrIdcard ? "" : nameOrIdcard;
        String sql = "SELECT\n" +
                "\tID AS \"id\",\n" +
                "\tidcard AS \"idcard\",\n" +
@ -177,24 +189,24 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                " address AS \"address\"\n" +
                "FROM\n" +
                "\tbase_patient\n";
        if (StringUtils.isNotEmpty(nameOrIdcard)){
            sql+="WHERE\n" +
                    "\tNAME LIKE '%"+nameOrIdcard+"%'\n" +
                    "OR idcard LIKE '%"+nameOrIdcard+"%'\n";
        if (StringUtils.isNotEmpty(nameOrIdcard)) {
            sql += "WHERE\n" +
                    "\tNAME LIKE '%" + nameOrIdcard + "%'\n" +
                    "OR idcard LIKE '%" + nameOrIdcard + "%'\n";
        }
        sql+="ORDER BY\n" +
        sql += "ORDER BY\n" +
                "\tcreate_time DESC";
        String condition ="";
        if (StringUtils.isNoneBlank(param)){
        String condition = "";
        if (StringUtils.isNoneBlank(param)) {
            condition = "where name like '%" + param + "%' or idcard like '%" + param + "%'";
        }
        String countSql = "select count(id) from base_patient "+condition;
        Long count  = jdbcTemplate.queryForObject(countSql,Long.class);
        if(count <= 0){
        String countSql = "select count(id) from base_patient " + condition;
        Long count = jdbcTemplate.queryForObject(countSql, Long.class);
        if (count <= 0) {
            return null;
        }
        MixEnvelop envelop = new MixEnvelop();
        result = hibenateUtils.createSQLQuery(sql,page,size);
        result = hibenateUtils.createSQLQuery(sql, page, size);
        envelop.setDetailModelList(result);
        envelop.setTotalCount(count.intValue());
        envelop.setCurrPage(page);
@ -204,6 +216,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    /**
     * 新增居民
     *
     * @param jsonData
     * @return
     */
@ -212,14 +225,14 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        JSONObject jsonObject = JSONObject.parseObject(jsonData);
        JSONObject patient = jsonObject.getJSONObject("patient");
        JSONArray patientMedicareCards = jsonObject.getJSONArray("medicareCard");
        if(null == patient || CollectionUtils.isEmpty(patientMedicareCards)){
        if (null == patient || CollectionUtils.isEmpty(patientMedicareCards)) {
            return ConstantUtils.FAIL;
        }
        BasePatientDO basePatientDO = objectMapper.readValue(patient.toJSONString(),BasePatientDO.class);
        BasePatientDO basePatientDO = objectMapper.readValue(patient.toJSONString(), BasePatientDO.class);
        List<PatientMedicareCardDO> list = new ArrayList<>();
        patientMedicareCards.forEach((card)->{
        patientMedicareCards.forEach((card) -> {
            try {
                list.add(objectMapper.readValue(card.toString(),PatientMedicareCardDO.class));
                list.add(objectMapper.readValue(card.toString(), PatientMedicareCardDO.class));
            } catch (IOException e) {
                e.printStackTrace();
            }
@ -231,6 +244,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    /**
     * 新增档案
     *
     * @param jsonData
     * @return
     */
@ -238,27 +252,28 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    public String createArchive(String jsonData) throws Exception {
        JSONObject jsonObject = JSONObject.parseObject(jsonData);
        JSONObject patient = jsonObject.getJSONObject("patient");
        if(null == patient){
        if (null == patient) {
            return ConstantUtils.FAIL;
        }
        BasePatientDO patientDO = objectMapper.readValue(patient.toJSONString(),BasePatientDO.class);
        BasePatientDO patientDO = objectMapper.readValue(patient.toJSONString(), BasePatientDO.class);
        this.save(patientDO);
        return ConstantUtils.SUCCESS;
    }
    /**
     * 修改档案
     *
     * @param jsonData
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String updateArchive(String jsonData) throws Exception {
        BasePatientDO basePatientDO = objectMapper.readValue(jsonData,BasePatientDO.class);
        if(StringUtils.isEmpty(basePatientDO.getId())){
        BasePatientDO basePatientDO = objectMapper.readValue(jsonData, BasePatientDO.class);
        if (StringUtils.isEmpty(basePatientDO.getId())) {
            return ConstantUtils.FAIL;
        }
        BasePatientDO basePatientDO1 = basePatientDao.findById(basePatientDO.getId()).orElse(null);
        if (null!=basePatientDO1){
        if (null != basePatientDO1) {
            basePatientDO1.setName(basePatientDO.getName());
            basePatientDO1.setMobile(basePatientDO.getMobile());
@ -284,15 +299,15 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            basePatientDO1.setAddress(basePatientDO.getAddress());
            basePatientDO1.setPhoto(basePatientDO.getPhoto());
            basePatientDO1.setArchiveStatus(basePatientDO.getArchiveStatus());
            if("hz_yyyzh_wx".equalsIgnoreCase(wxId)){//杭州医养头像初始化
                if (org.apache.commons.lang3.StringUtils.isBlank(basePatientDO1.getPhoto())){
                    String hzPhoto= getHzAvatar(1,null,basePatientDO1.getArchiveType()+"",null==basePatientDO1.getSex()?"":basePatientDO1.getSex()+"",basePatientDO1.getIdcard());
            if ("hz_yyyzh_wx".equalsIgnoreCase(wxId)) {//杭州医养头像初始化
                if (org.apache.commons.lang3.StringUtils.isBlank(basePatientDO1.getPhoto())) {
                    String hzPhoto = getHzAvatar(1, null, basePatientDO1.getArchiveType() + "", null == basePatientDO1.getSex() ? "" : basePatientDO1.getSex() + "", basePatientDO1.getIdcard());
                    basePatientDO1.setPhoto(hzPhoto);
                }else{
                    String sql = " select count(id) from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_value='"+basePatientDO1.getPhoto()+"' ";
                    Integer defaultAvatar =  jdbcTemplate.queryForObject(sql,Integer.class);
                    if (defaultAvatar>0){
                        String hzPhoto= getHzAvatar(1,null,basePatientDO1.getArchiveType()+"",null==basePatientDO1.getSex()?"":basePatientDO1.getSex()+"",basePatientDO1.getIdcard());
                } else {
                    String sql = " select count(id) from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_value='" + basePatientDO1.getPhoto() + "' ";
                    Integer defaultAvatar = jdbcTemplate.queryForObject(sql, Integer.class);
                    if (defaultAvatar > 0) {
                        String hzPhoto = getHzAvatar(1, null, basePatientDO1.getArchiveType() + "", null == basePatientDO1.getSex() ? "" : basePatientDO1.getSex() + "", basePatientDO1.getIdcard());
                        basePatientDO1.setPhoto(hzPhoto);
                    }
                }
@ -305,6 +320,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    /**
     * 修改居民
     *
     * @param jsonData
     * @return
     */
@ -313,15 +329,15 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        JSONObject jsonObject = JSONObject.parseObject(jsonData);
        JSONObject patient = jsonObject.getJSONObject("patient");
        JSONArray patientMedicareCards = jsonObject.getJSONArray("medicareCard");
        if(null == patient || CollectionUtils.isEmpty(patientMedicareCards)){
        if (null == patient || CollectionUtils.isEmpty(patientMedicareCards)) {
            return ConstantUtils.FAIL;
        }
        BasePatientDO basePatientDO = objectMapper.readValue(patient.toJSONString(),BasePatientDO.class);
        if(StringUtils.isEmpty(basePatientDO.getId())){
        BasePatientDO basePatientDO = objectMapper.readValue(patient.toJSONString(), BasePatientDO.class);
        if (StringUtils.isEmpty(basePatientDO.getId())) {
            return ConstantUtils.FAIL;
        }
        BasePatientDO basePatientDO1 = basePatientDao.findById(basePatientDO.getId()).orElse(null);
        if (null!=basePatientDO1){
        if (null != basePatientDO1) {
            basePatientDO1.setName(basePatientDO.getName());
            basePatientDO1.setSex(basePatientDO.getSex());
            basePatientDO1.setIdcard(basePatientDO.getIdcard());
@ -346,18 +362,18 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            basePatientDO1.setResidentialArea(basePatientDO.getResidentialArea());
            basePatientDO1.setCommitteeCode(basePatientDO.getCommitteeCode());
            basePatientDO1.setCommitteeName(basePatientDO.getCommitteeName());
            if(StringUtils.isNotBlank(basePatientDO.getYktId())){
            if (StringUtils.isNotBlank(basePatientDO.getYktId())) {
                basePatientDO1.setYktId(basePatientDO.getYktId());
            }
            if("hz_yyyzh_wx".equalsIgnoreCase(wxId)){//杭州医养头像初始化
                if (org.apache.commons.lang3.StringUtils.isBlank(basePatientDO1.getPhoto())){
                    String hzPhoto= getHzAvatar(1,null,basePatientDO1.getArchiveType()+"",null==basePatientDO1.getSex()?"":basePatientDO1.getSex()+"",basePatientDO1.getIdcard());
            if ("hz_yyyzh_wx".equalsIgnoreCase(wxId)) {//杭州医养头像初始化
                if (org.apache.commons.lang3.StringUtils.isBlank(basePatientDO1.getPhoto())) {
                    String hzPhoto = getHzAvatar(1, null, basePatientDO1.getArchiveType() + "", null == basePatientDO1.getSex() ? "" : basePatientDO1.getSex() + "", basePatientDO1.getIdcard());
                    basePatientDO1.setPhoto(hzPhoto);
                }else{
                    String sql = " select count(id) from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_value='"+basePatientDO1.getPhoto()+"' ";
                    Integer defaultAvatar =  jdbcTemplate.queryForObject(sql,Integer.class);
                    if (defaultAvatar>0){
                        String hzPhoto= getHzAvatar(1,null,basePatientDO1.getArchiveType()+"",null==basePatientDO1.getSex()?"":basePatientDO1.getSex()+"",basePatientDO1.getIdcard());
                } else {
                    String sql = " select count(id) from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_value='" + basePatientDO1.getPhoto() + "' ";
                    Integer defaultAvatar = jdbcTemplate.queryForObject(sql, Integer.class);
                    if (defaultAvatar > 0) {
                        String hzPhoto = getHzAvatar(1, null, basePatientDO1.getArchiveType() + "", null == basePatientDO1.getSex() ? "" : basePatientDO1.getSex() + "", basePatientDO1.getIdcard());
                        basePatientDO1.setPhoto(hzPhoto);
                    }
                }
@ -373,13 +389,13 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            PatientMedicareCardDO card = objectMapper.readValue(obj.toString(), PatientMedicareCardDO.class);
            card.setPatientCode(basePatientDO.getId());
            card.setDel("1");
            if(cardIdList.contains(card.getId())){
            if (cardIdList.contains(card.getId())) {
                cardIdList.remove(card.getId());
            }
            basePatientMedicardCardService.save(card);
        }
        // 有些卡可能是删除的
        if(cardIdList.size() > 0){
        if (cardIdList.size() > 0) {
            basePatientMedicardCardService.delete(cardIdList.toArray());
        }
        return ConstantUtils.SUCCESS;
@ -387,30 +403,31 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    /**
     * 根据patient的id获取居民信息
     *
     * @param patient
     * @return
     */
    public BasePatientDO findByIdAndDel(String patient) throws Exception{
    public BasePatientDO findByIdAndDel(String patient) throws Exception {
        BasePatientDO basePatientDO = basePatientDao.findById(patient).orElse(null);
        if(basePatientDO==null){
        if (basePatientDO == null) {
            throw new Exception("用户不存在");
        }
        Boolean flag = healthCareService.isHospitalFlag();
        if (flag){
            if(wxId.equalsIgnoreCase("xm_xzzx_wx")){
        if (flag) {
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
                String result = healthCareService.authorizedToEntrace(basePatientDO.getId());
                JSONObject object = JSONObject.parseObject(result);
                if (object.getString("flag").equalsIgnoreCase("1")){
                if (object.getString("flag").equalsIgnoreCase("1")) {
                    JSONObject encryptData = object.getJSONObject("encrypt_data");
                    String state = encryptData.getString("state");
                    String auth_date = encryptData.getString("auth_date");
                    basePatientDO.setMedicalState(state);
                    basePatientDO = basePatientDao.save(basePatientDO);
                }
            }else {
            } else {
                String result = healthCareService.authorized(basePatientDO.getId());
                JSONObject object = JSONObject.parseObject(result);
                if (object.getString("flag").equalsIgnoreCase("1")){
                if (object.getString("flag").equalsIgnoreCase("1")) {
                    JSONObject encryptData = object.getJSONObject("encrypt_data");
                    String state = encryptData.getString("state");
                    String auth_date = encryptData.getString("auth_date");
@ -424,29 +441,30 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    /**
     * 根据patient的id获取居民信息
     *
     * @param mobile
     * @return
     */
    public BasePatientDO findByMobileAndDel(String mobile) throws Exception{
        List<BasePatientDO> list = basePatientDao.findByMobileAndDel(mobile,"1");
        if(list.size()<=0){
    public BasePatientDO findByMobileAndDel(String mobile) throws Exception {
        List<BasePatientDO> list = basePatientDao.findByMobileAndDel(mobile, "1");
        if (list.size() <= 0) {
            return null;
        }
        return list.get(0);
    }
    public Boolean updatePatientPw(String id,String pw,String orgPw){
    public Boolean updatePatientPw(String id, String pw, String orgPw) {
        BasePatientDO patientDO = basePatientDao.findById(id).orElse(null);
        if (!"xm_ykyy_wx".equalsIgnoreCase(wxId)){
        if (!"xm_ykyy_wx".equalsIgnoreCase(wxId)) {
            String orgPwMd5 = MD5.md5Hex(orgPw + "{" + patientDO.getSalt() + "}");
            if(!orgPwMd5.equals(patientDO.getPassword())){
            if (!orgPwMd5.equals(patientDO.getPassword())) {
                return false;
            }
        }
        //认证信息设置
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            String response =ykyyService.updatePatientPassword(patientDO.getMobile(),pw,"");
            if (StringUtils.isNoneBlank(response)&&response.contains("10000")){
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
            String response = ykyyService.updatePatientPassword(patientDO.getMobile(), pw, "");
            if (StringUtils.isNoneBlank(response) && response.contains("10000")) {
                String salt = randomString(5);
                patientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patientDO.setSalt(salt);
@ -468,19 +486,21 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        saveDoctorPwlimitDate(id);*/
        return true;
    }
    public Map<String,Object> getPatientCountByDoctor(String doctor,String patient) throws  Exception{
        List<WlyyOutpatientDO> fzList = outpatientDao.findByDoctorAndOutpatientType(doctor,"1",patient);
        List<WlyyOutpatientDO> xtList = outpatientDao.findByDoctorAndOutpatientType(doctor,"2",patient);
        List<WlyyOutpatientDO> zxList = outpatientDao.findByDoctorAndOutpatientType(doctor,"3",patient);
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("fzNum",fzList==null?0:fzList.size());
        resultMap.put("xtNum",xtList==null?0:xtList.size());
        resultMap.put("zxNum",zxList==null?0:zxList.size());
    public Map<String, Object> getPatientCountByDoctor(String doctor, String patient) throws Exception {
        List<WlyyOutpatientDO> fzList = outpatientDao.findByDoctorAndOutpatientType(doctor, "1", patient);
        List<WlyyOutpatientDO> xtList = outpatientDao.findByDoctorAndOutpatientType(doctor, "2", patient);
        List<WlyyOutpatientDO> zxList = outpatientDao.findByDoctorAndOutpatientType(doctor, "3", patient);
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("fzNum", fzList == null ? 0 : fzList.size());
        resultMap.put("xtNum", xtList == null ? 0 : xtList.size());
        resultMap.put("zxNum", zxList == null ? 0 : zxList.size());
        return resultMap;
    }
    //查询电子病历
        public MixEnvelop findEmrByPatientId(String patient,String doctor,Integer page ,Integer pageSize){
        String sql ="select e.id as \"id\"," +
    public MixEnvelop findEmrByPatientId(String patient, String doctor, Integer page, Integer pageSize) {
        String sql = "select e.id as \"id\"," +
                " e.prescription_id as \"prescriptionId\"," +
                " e.complaint as \"complaint\"," +
                " e.medical_history as \"medicalHistory\"," +
@ -496,15 +516,15 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                " from wlyy_prescription_emr e " +
                " left join  wlyy_prescription p on e.prescription_id = p.id" +
                " where p.status >= 20";
        if (StringUtils.isNoneBlank(patient)){
            sql+=" and p.patient_code ='"+patient+"'";
        if (StringUtils.isNoneBlank(patient)) {
            sql += " and p.patient_code ='" + patient + "'";
        }
        if (StringUtils.isNoneBlank(doctor)){
            sql+=" and p.doctor ='"+doctor+"'";
        if (StringUtils.isNoneBlank(doctor)) {
            sql += " and p.doctor ='" + doctor + "'";
        }
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setTotalCount(list==null?0:list.size());
        mixEnvelop.setTotalCount(list == null ? 0 : list.size());
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
@ -552,6 +572,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }*/
    /**
     * 查询患者所有处方信息
     *
@ -559,36 +580,36 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
     * @param size
     * @return
     */
    public PageEnvelop findPatientAllPrescription(String doctor,String keyName, String status, Integer page, Integer size,String patient,String isSelectDrug) {
    public PageEnvelop findPatientAllPrescription(String doctor, String keyName, String status, Integer page, Integer size, String patient, String isSelectDrug) {
        BasePatientDO patientDO = basePatientDao.findById(patient).orElse(null);
        if (patientDO==null){
            return PageEnvelop.getError("找不到该患者",-1);
        if (patientDO == null) {
            return PageEnvelop.getError("找不到该患者", -1);
        }
        StringBuffer sql = new StringBuffer(" SELECT DISTINCT b.*, c.oneself_pickup_flg,f.job_title_code,f.job_title_name  FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
        StringBuffer countSql = new StringBuffer("select COUNT(DISTINCT b.id) count FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
        sql.append(patient).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        countSql.append(patient).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        if (StringUtils.isNoneBlank(isSelectDrug)){
            if("0".equalsIgnoreCase(isSelectDrug)){
        if (StringUtils.isNoneBlank(isSelectDrug)) {
            if ("0".equalsIgnoreCase(isSelectDrug)) {
                sql.append(" left join wlyy_inspection m on b.outpatient_id =m.outpatient_id");
                countSql.append(" left join wlyy_inspection m on b.outpatient_id =m.outpatient_id");
            }
            if ("1".equalsIgnoreCase(isSelectDrug)){
            if ("1".equalsIgnoreCase(isSelectDrug)) {
                sql.append(" left join wlyy_prescription_info m on b.id =m.prescription_id");
                countSql.append(" left join wlyy_prescription_info m on b.id =m.prescription_id");
            }
        }
        if (StringUtils.isNotEmpty(status)) {
            status = status.substring(1, status.length() - 1);
            if (StringUtils.isNoneBlank(isSelectDrug)){
                if("0".equalsIgnoreCase(isSelectDrug)){
            if (StringUtils.isNoneBlank(isSelectDrug)) {
                if ("0".equalsIgnoreCase(isSelectDrug)) {
                    sql.append(" where b.status IN( 9,").append(status).append(")");
                    countSql.append(" where b.status IN( 9,").append(status).append(")");
                }else {
                } else {
                    sql.append(" where b.status IN(").append(status).append(")");
                    countSql.append(" where b.status IN(").append(status).append(")");
                }
            }else{
            } else {
                sql.append(" where b.status IN(").append(status).append(")");
                countSql.append(" where b.status IN(").append(status).append(")");
            }
@ -596,12 +617,12 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            sql.append("  where b.status IN(20,21,30,31,32,100,101)");
            countSql.append(" where b.status IN(20,21,30,31,32,100,101) ");
        }
        if (StringUtils.isNoneBlank(isSelectDrug)){
            if("0".equalsIgnoreCase(isSelectDrug)){
        if (StringUtils.isNoneBlank(isSelectDrug)) {
            if ("0".equalsIgnoreCase(isSelectDrug)) {
                sql.append(" and m.del =1 ");
                countSql.append(" and m.del =1 ");
            }
            if ("1".equalsIgnoreCase(isSelectDrug)){
            if ("1".equalsIgnoreCase(isSelectDrug)) {
                sql.append(" and m.del =1");
                countSql.append(" and m.del =1");
            }
@ -624,8 +645,8 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                    ")");
        }
        if (StringUtils.isNotEmpty(doctor)) {
            sql.append(" and  b.doctor ='" +doctor+"'");
            countSql.append(" and  b.doctor ='" +doctor+"'");
            sql.append(" and  b.doctor ='" + doctor + "'");
            countSql.append(" and  b.doctor ='" + doctor + "'");
        }
        sql.append(" order by b.prescribe_time DESC ");
@ -649,11 +670,11 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= " + (page - 1) * size;
            if (flag){
            if (flag) {
                sql.append("  limit ").append((page - 1) * size).append(",").append(size);
                logger.info("MySql=" + sql.toString());
                list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
            }else {
            } else {
                logger.info("oracleSql=" + oracleSql);
                list = jdbcTemplate.query(oracleSql, new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
            }
@ -663,15 +684,15 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            logger.info("MySql=" + sql.toString());
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
        }
        for (WlyyPrescriptionVO singlePre:list){
            List<WlyyPrescriptionInfoDO> infoDOs = prescriptionInfoDao.findByPrescriptionId(singlePre.getId(),1);
            logger.info("singlePreId===="+singlePre.getId());
            logger.info("infoDOs"+infoDOs);
        for (WlyyPrescriptionVO singlePre : list) {
            List<WlyyPrescriptionInfoDO> infoDOs = prescriptionInfoDao.findByPrescriptionId(singlePre.getId(), 1);
            logger.info("singlePreId====" + singlePre.getId());
            logger.info("infoDOs" + infoDOs);
            List<WlyyPrescriptionInfoVO> infoVOS = new ArrayList<>();
            convertToModels(infoDOs, infoVOS, WlyyPrescriptionInfoVO.class);
            logger.info("infoVOS"+infoVOS);
            logger.info("infoVOS" + infoVOS);
            singlePre.setInfoVOs(infoVOS);
            List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(singlePre.getId(),1);
            List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(singlePre.getId(), 1);
            List<WlyyInspectionVO> inspectionVOS = new ArrayList<>();
            convertToModels(inspectionDOS, inspectionVOS, WlyyInspectionVO.class);
            //BeanUtils.copyProperties(inspectionDOS,inspectionVOS);
@ -683,148 +704,194 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        long count = Long.parseLong(mapList.get(0).get("count").toString());
        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, list, page, size, count);
    }
    public Map<String,Object>  findPatientInfoById(String patientId,String doctor){
    public Map<String, Object> findPatientInfoById(String patientId, String doctor) {
        String sql = "select b.id as \"id\"," +
                "  b.group_code as \"groupCode\"," +
                "  b.group_name as \"groupName\"" +
                "  from base_patient_group t " +
                " left join base_patient_group_dict b on t.group_id = b.id" +
                " where b.del = '1' and t.patient ='"+patientId+"' and t.doctor ='"+doctor+"'";
        sql+=" group by b.id,b.group_code,b.group_name";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        String patientSql= "select t.id as \"id\"," +
                " where b.del = '1' and t.patient ='" + patientId + "' and t.doctor ='" + doctor + "'";
        sql += " group by b.id,b.group_code,b.group_name";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
        String patientSql = "select t.id as \"id\"," +
                " t.name as \"name\"," +
                " t.idcard as \"idcard\"," +
                " t.disease as \"disease\"" +
                "  from base_patient t where t.del = '1' and t.id='"+patientId+"'";
        List<Map<String,Object>> patientInfo = hibenateUtils.createSQLQuery(patientSql);
        if (patientInfo!=null&&patientInfo.size()>0){
            Map<String,Object> patient = patientInfo.get(0);
                "  from base_patient t where t.del = '1' and t.id='" + patientId + "'";
        List<Map<String, Object>> patientInfo = hibenateUtils.createSQLQuery(patientSql);
        if (patientInfo != null && patientInfo.size() > 0) {
            Map<String, Object> patient = patientInfo.get(0);
            String sex = IdCardUtil.getSexForIdcard_new(patient.get("idcard").toString());
            Integer age = IdCardUtil.getAgeForIdcard(patient.get("idcard").toString());
            patient.put("sex",sex);
            patient.put("age",age);
            patient.put("groupList",list);
            patient.put("sex", sex);
            patient.put("age", age);
            patient.put("groupList", list);
            return patient;
        }
        return null;
    }
    public PageEnvelop pageByCondition(String name, Integer archiveType, Integer archiveStatus,int page,int size){
        List<Map<String ,Object>> list;
        if (page>0){
    public PageEnvelop pageByCondition(String name, Integer archiveType, Integer archiveStatus, int page, int size) {
        List<Map<String, Object>> list;
        if (page > 0) {
//            page--;
        }else{
            page=0;
        } else {
            page = 0;
        }
        String sqlCount = "select count(*) as \"total\" from base_patient where 1=1 ";
        String sql = "select * from base_patient where 1=1 ";
        String sqlCondition = "";
        if (StringUtils.isNotBlank(name)){
            sqlCondition += " and (name like '%"+name+"%' or idcard like '%"+name+"%' or mobile like '%"+name+"%') ";
        if (StringUtils.isNotBlank(name)) {
            sqlCondition += " and (name like '%" + name + "%' or idcard like '%" + name + "%' or mobile like '%" + name + "%') ";
        }
        if (archiveType!=null){
            sqlCondition += " and archive_type ="+archiveType;
        if (archiveType != null) {
            sqlCondition += " and archive_type =" + archiveType;
        }
        if (archiveStatus!=null){
            sqlCondition += " and archive_status ="+archiveStatus;
        if (archiveStatus != null) {
            sqlCondition += " and archive_status =" + archiveStatus;
        }
        List<Map<String ,Object>> count = hibenateUtils.createSQLQuery(sqlCount+sqlCondition);
        Long cou=0l;
        if (count!=null&&count.size()>0){
            cou= Long.valueOf(count.get(0).get("total").toString());
        List<Map<String, Object>> count = hibenateUtils.createSQLQuery(sqlCount + sqlCondition);
        Long cou = 0l;
        if (count != null && count.size() > 0) {
            cou = Long.valueOf(count.get(0).get("total").toString());
        }
        list = hibenateUtils.createSQLQuery(sql+sqlCondition,page,size);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,cou);
        list = hibenateUtils.createSQLQuery(sql + sqlCondition, page, size);
        return PageEnvelop.getSuccessListWithPage("success", list, page, size, cou);
    }
    /**
     *
     * 获取医养默认头像
     * @param user 1居民2员工(医生、助老员等)
     *
     * @param user        1居民2员工(医生、助老员等)
     * @param doctorLevel
     * @param archiveType
     * @param sex
     * @param idcard
     * @return
     */
    public String getHzAvatar(Integer user,String doctorLevel,String archiveType,String sex,String idcard){
    public String getHzAvatar(Integer user, String doctorLevel, String archiveType, String sex, String idcard) {
        String avatar = null;
        String flag = "";
        if (org.apache.commons.lang3.StringUtils.isBlank(sex)&& org.apache.commons.lang3.StringUtils.isNotBlank(idcard)){
        if (org.apache.commons.lang3.StringUtils.isBlank(sex) && org.apache.commons.lang3.StringUtils.isNotBlank(idcard)) {
            sex = IdCardUtil.getSexForIdcard_new(idcard);
        }
        if (1==user){
            if (org.apache.commons.lang3.StringUtils.isNotBlank(archiveType)){
                flag = "1"+"-"+archiveType;
        if (1 == user) {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(archiveType)) {
                flag = "1" + "-" + archiveType;
            }
            if (org.apache.commons.lang3.StringUtils.isNotBlank(sex)&&!"3".equals(sex)){
                flag += "-"+sex;
            }else {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(sex) && !"3".equals(sex)) {
                flag += "-" + sex;
            } else {
                flag += "-1";
            }
        }
        else if (2==user){
            if (org.apache.commons.lang3.StringUtils.isNotBlank(doctorLevel)){
                flag = "2"+"-"+doctorLevel;
        } else if (2 == user) {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(doctorLevel)) {
                flag = "2" + "-" + doctorLevel;
            }
            if (org.apache.commons.lang3.StringUtils.isNotBlank(sex)&&!"3".equals(sex)){
                flag += "-"+sex;
            }else {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(sex) && !"3".equals(sex)) {
                flag += "-" + sex;
            } else {
                flag += "-1";
            }
        }
        String dictName="";
        switch (flag){
        String dictName = "";
        switch (flag) {
            case "1-1-1"://老人男
                dictName="laorennan";
                dictName = "laorennan";
                break;
            case "1-1-2"://老人女
                dictName="laorennv";
                dictName = "laorennv";
                break;
            case "1-2-1"://新生儿男
                dictName="xinshengernan";
                dictName = "xinshengernan";
                break;
            case "1-2-2"://新生儿女
                dictName="xinshengernv";
                dictName = "xinshengernv";
                break;
            case "1-3-1"://家属男
                dictName="jiashunan";
                dictName = "jiashunan";
                break;
            case "1-3-2"://家属女
                dictName="jiashunv";
                dictName = "jiashunv";
                break;
            case "2-1-1"://医生男
                dictName="yishengnan";
                dictName = "yishengnan";
                break;
            case "2-1-2"://医生女
                dictName="yishengnv";
                dictName = "yishengnv";
                break;
            case "2-2-1"://社工男
                dictName="shegongnan";
                dictName = "shegongnan";
                break;
            case "2-2-2"://社工女
                dictName="shegongnv";
                dictName = "shegongnv";
                break;
            case "2-3-1"://教师男
                dictName="jiaoshinan";
                dictName = "jiaoshinan";
                break;
            case "2-3-2"://教师女
                dictName="jiaoshinv";
                dictName = "jiaoshinv";
                break;
            case "2-4-1"://助老员男
                dictName="zhulaoyuannan";
                dictName = "zhulaoyuannan";
                break;
            case "2-4-2"://助老员女
                dictName="zhulaoyuannv";
                dictName = "zhulaoyuannv";
                break;
            default:
                dictName="zhulaoyuannan";
                dictName = "zhulaoyuannan";
                break;
        }
        String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_code='"+dictName+"' ";
        avatar = jdbcTemplate.queryForObject(sql,String.class);
        String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_code='" + dictName + "' ";
        avatar = jdbcTemplate.queryForObject(sql, String.class);
        return avatar;
    }
    /**
     * 根据身份证添加居民
     *
     * @param idcard
     * @return
     */
    public BasePatientDO addPaitentByIdcard(String idcard) {
        try {
            org.json.JSONArray jsonArray = jwArchivesService.getSickArchiveRecord(idcard);
            if (jsonArray.length() > 0) {
                org.json.JSONObject json = jsonArray.getJSONObject(0);
                BasePatientDO patient = new BasePatientDO();
//                patient.setCode(getCode());
                patient.setName(json.getString("sickName"));
                patient.setIdcard(idcard);
                patient.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
                patient.setSsc(json.getString("ssc"));
                String salt = UUID.randomUUID().toString().replace("-", "");
                String password = idcard.substring(idcard.length() - 6, idcard.length());
                password = MD5.GetMD5Code("a" + password + "*" + salt);
                patient.setSalt(salt);
                patient.setPassword(password);
                //统一身份认证状态
//                patient.setIsCertified(0);
//                patient.setStatus(1);
//                patient.setCzrq(new Date());
//                patient.setSicardStatus(0);
                patientDao.save(patient);
                //同步居民签约记录
//                try {
//                    jwSignService.LoadSignFamilyByIdcard(idcard);
//                } catch (ServiceException se){
//                    se.printStackTrace();
//                } catch (Exception e){
//                    e.printStackTrace();
//                }
                return patient;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

+ 40 - 0
business/base-service/src/main/java/com/yihu/jw/system/dao/SystemDictDao.java

@ -0,0 +1,40 @@
package com.yihu.jw.system.dao;
import com.yihu.jw.entity.base.system.SystemDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2016/8/13.
 */
public interface SystemDictDao extends PagingAndSortingRepository<SystemDictDO, Long>, JpaSpecificationExecutor<SystemDictDO> {
    @Query("from SystemDictDO s where s.dictName=?1 order by s.sort asc ")
    List<SystemDictDO> findByDictName(String name);
    @Query("select s.name from SystemDictDO s where s.dictName=?1 and s.code =?2")
    String findByDictNameAndCode(String dictName, String code);
    @Query(" from SystemDictDO s where s.dictName=?1 and s.name =?2")
    SystemDictDO findByDictNameAndValue(String dictName, String value);
    @Query(" from SystemDictDO s where s.pyCode=?1 ")
    SystemDictDO findByPyCode(String pyCode);
    @Query("select s from SystemDictDO s where s.name like ?1 ")
    List<SystemDictDO> findByLikeName(String name);
    @Query("select s from SystemDictDO s where s.dictName like ?1 ")
    List<SystemDictDO> findByLikeDictName(String name);
    @Modifying
    @Query("delete SystemDictDO s where s.dictName = ?1")
    int delete(String dictName);
    @Query(" from SystemDictDO s where s.code=?1 and s.dictName=?2 ")
    SystemDictDO findByCodeAndName(String code, String dictName);
}

+ 148 - 0
business/base-service/src/main/java/com/yihu/jw/system/service/SystemDictService.java

@ -0,0 +1,148 @@
package com.yihu.jw.system.service;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.system.dao.SystemDictDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by Administrator on 2016/8/13.
 */
@Service
@Transactional
public class SystemDictService {
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    public Map<String,String> getDictMap(String dictName){
        List<SystemDictDO> dictList = systemDictDao.findByDictName(dictName);
//        Map<String,String> map = dictList.stream().collect(Collectors.toMap(SystemDictDO::getCode,SystemDict::getValue));
        Map<String,String> map = dictList.stream().collect(Collectors.toMap(SystemDictDO::getCode,SystemDictDO::getName));
        return map;
    }
    public List<SystemDictDO> getDictByDictName(String name) {
        return systemDictDao.findByDictName(name);
    }
    private String dictName = "SYSTEM_PARAMS";
    public String getDictValueNoRedis(String dictName, String code) {
        String re = systemDictDao.findByDictNameAndCode(dictName, code);
        return re;
    }
    /**
     * 字典转译
     *
     * @param dictName
     * @param code
     * @return
     */
    public String getDictValue(String dictName, String code) {
        String re = "";
        try {
            if (!StringUtils.isEmpty(code)) {
                //判断该字典redis是否存在
                String exit = redisTemplate.opsForValue().get("systemDict:" + dictName);
                if (!StringUtils.isEmpty(exit)) {
                    re = redisTemplate.opsForValue().get("systemDict:" + dictName + ":" + code);
                    if(StringUtils.isEmpty(re)){
                        re = systemDictDao.findByDictNameAndCode(dictName,code);
//                        if (!StringUtils.isEmpty(re)) {
//                            redisTemplate.opsForValue().set("systemDict:" + dictName + ":" + code, re);
//                        }
                    }
                } else {
                    List<SystemDictDO> list = systemDictDao.findByDictName(dictName);
                    if (list != null && list.size() > 0) {
                        redisTemplate.opsForValue().set("systemDict:" + dictName, "1");
                        for (SystemDictDO item : list) {
//                            redisTemplate.opsForValue().set("systemDict:" + dictName + ":" + item.getCode(), item.getValue());
                            redisTemplate.opsForValue().set("systemDict:" + dictName + ":" + item.getCode(), item.getName());
                            if (code.equals(item.getCode())) {
//                                re = item.getValue();
                                re = item.getName();
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            re = systemDictDao.findByDictNameAndCode(dictName, code);
        }
        return re;
    }
    /************************************** 其他参数 ****************************************/
    /**
     * http_log是否记录成功消息
     *
     * @return
     */
    public Boolean getSaveSuccessLog() {
        try {
            String re = systemDictDao.findByDictNameAndCode(dictName, "SAVE_SUCCESS_LOG");
            if ("1".equals(re)) {
                return true;
            } else {
                return false;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
    public int delete(String dictName) {
        return systemDictDao.delete(dictName);
    }
    /**
     * 保存健康教育设置字典
     * @param dictName
     * @param isComment
     */
//    public void save(String dictName, String isComment) {
//        SystemDict systemDict = new SystemDict();
//        systemDict.setDictName(dictName);
//        systemDict.setCode(isComment);
//        if (isComment.equals("0")) {
//            systemDict.setValue("不允许");
//        } else if (isComment.equals("1")) {
//            systemDict.setValue("允许");
//        }
//        systemDict.setSort(1);
//        systemDictDao.save(systemDict);
//    }
//    public void saveJkeduNotDisturb(String dictName, String json) {
//        JSONArray jsonArray = new JSONArray(json);
//        List<SystemDict> list = new ArrayList<>();
//        int code = 1;
//        for (Object object : jsonArray){
//            SystemDict systemDict = new SystemDict();
//            systemDict.setDictName(dictName);
//            systemDict.setCode(code + "");
//            systemDict.setValue(((JSONObject)object).toString());
//            systemDict.setSort(code);
//            list.add(systemDict);
//            code ++;
//        }
//        systemDictDao.save(list);
//    }
}

+ 2 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseFrequencyDictDO.java

@ -18,6 +18,8 @@ public class BaseFrequencyDictDO extends UuidIdentityEntityWithCreateTime {
    private String is_op_ip;
    private String is_del;
    private String status;
    @Column(name = "freq_code")
    public String getFreq_code() {
        return freq_code;

+ 22 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictDO.java

@ -31,6 +31,28 @@ public class SystemDictDO implements Serializable {
	//类型
	private Type type;
	@Column(name = "dict_name")
	private String dictName;
	@Column(name = "sort")
	private String sort;
	public String getDictName() {
		return dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	public String getSort() {
		return sort;
	}
	public void setSort(String sort) {
		this.sort = sort;
	}
	@Id
	@GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "assigned")

+ 91 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/door/SignPatientLabelInfo.java

@ -0,0 +1,91 @@
package com.yihu.jw.entity.door;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr on 2016/10/9.
 */
@Entity
@Table(name = "wlyy_sign_patient_label_info")
public class SignPatientLabelInfo extends IdEntity {
    // 患者code
    private String patient;
    // 患者姓名
    private String pname;
    // 标签code
    private String label;
    // 标签名称
    private String labelName;
    // 标签类型
    private String labelType;
    //标签状态
    private Integer labelStatus;
    // 状态 0:无效 1:有效
    private Integer status;
    // 操作日期
    private Date czrq;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPname() {
        return pname;
    }
    public void setPname(String pname) {
        this.pname = pname;
    }
    public String getLabel() {
        return label;
    }
    public void setLabel(String label) {
        this.label = label;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    public Integer getLabelStatus() {
        return labelStatus;
    }
    public void setLabelStatus(Integer labelStatus) {
        this.labelStatus = labelStatus;
    }
}

+ 178 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/MessageNoticeSetting.java

@ -0,0 +1,178 @@
package com.yihu.jw.entity.hospital.message;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 消息提醒设置
 * @author yeshijie on 2017/11/27.
 *
 */
@Entity
@Table(name = "wlyy_message_notice_setting")
public class MessageNoticeSetting extends IdEntity {
    private String user;//'用户code'
    private String type;// '类型(1医生,2居民)'
    private Integer masterSwitch;// '总开关' (1开,0关)
    private Integer imSwitch;//'im消息开关'(1开,0关)
    private Integer familyTopicSwitch;// '健管师邀请后推送开关'(1开,0关)
    private Integer signSwitch;// '签约消息开关'(1开,0关)
    private Integer healthSignSwitch;// '体征消息开关'(1开,0关)
    private Integer systemSwitch;// '系统消息开关'(1开,0关)
    private Integer prescriptionSwitch;// '续方消息开关'(1开,0关)
    private Integer soundSwitch;// '铃声提醒开关'(1开,0关)
    private Integer vibrationSwitch;// '振动提醒开关'(1开,0关)
    private Integer coordinationSwitch;// '协同消息开关'(1开,0关)
    private Date createTime;// '创建时间'
    //状态枚举
    public enum MessageTypeEnum {
        masterSwitch("总开关","masterSwitch"),
        imSwitch("im消息开关","imSwitch"),
        familyTopicSwitch("健管师邀请后推送开关","familyTopicSwitch"),
        signSwitch("签约消息开关","signSwitch"),
        healthSignSwitch("体征消息开关","healthSignSwitch"),
        systemSwitch("系统消息开关","systemSwitch"),
        prescriptionSwitch("续方消息开关","prescriptionSwitch"),
        soundSwitch("铃声提醒开关","soundSwitch"),
        vibrationSwitch("振动提醒开关","vibrationSwitch"),
        coordinationSwitch("协同消息开关","coordinationSwitch");
        private String name;
        private String value;
        MessageTypeEnum(String name, String value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getValue() {
            return value;
        }
        public void setValue(String value) {
            this.value = value;
        }
    }
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Integer getMasterSwitch() {
        return masterSwitch;
    }
    public void setMasterSwitch(Integer masterSwitch) {
        this.masterSwitch = masterSwitch;
    }
    public Integer getImSwitch() {
        return imSwitch;
    }
    public void setImSwitch(Integer imSwitch) {
        this.imSwitch = imSwitch;
    }
    public Integer getFamilyTopicSwitch() {
        return familyTopicSwitch;
    }
    public void setFamilyTopicSwitch(Integer familyTopicSwitch) {
        this.familyTopicSwitch = familyTopicSwitch;
    }
    public Integer getSignSwitch() {
        return signSwitch;
    }
    public void setSignSwitch(Integer signSwitch) {
        this.signSwitch = signSwitch;
    }
    public Integer getHealthSignSwitch() {
        return healthSignSwitch;
    }
    public void setHealthSignSwitch(Integer healthSignSwitch) {
        this.healthSignSwitch = healthSignSwitch;
    }
    public Integer getSystemSwitch() {
        return systemSwitch;
    }
    public void setSystemSwitch(Integer systemSwitch) {
        this.systemSwitch = systemSwitch;
    }
    public Integer getPrescriptionSwitch() {
        return prescriptionSwitch;
    }
    public void setPrescriptionSwitch(Integer prescriptionSwitch) {
        this.prescriptionSwitch = prescriptionSwitch;
    }
    public Integer getSoundSwitch() {
        return soundSwitch;
    }
    public void setSoundSwitch(Integer soundSwitch) {
        this.soundSwitch = soundSwitch;
    }
    public Integer getVibrationSwitch() {
        return vibrationSwitch;
    }
    public void setVibrationSwitch(Integer vibrationSwitch) {
        this.vibrationSwitch = vibrationSwitch;
    }
    public Integer getCoordinationSwitch() {
        return coordinationSwitch;
    }
    public void setCoordinationSwitch(Integer coordinationSwitch) {
        this.coordinationSwitch = coordinationSwitch;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 191 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SpecialistDynamicMessages.java

@ -0,0 +1,191 @@
package com.yihu.jw.entity.hospital.message;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/***
 * @Description: 专病分级诊疗实时动态
 * @Auther: yeshijie
 * @Date: 2023-05-23
 */
@Entity
@Table(name = "wlyy_specialist_dynamic_messages")
public class SpecialistDynamicMessages extends IdEntity {
    private String name;//居民姓名
    private String address;//居民地址
    private String result;//执行结果
    private String createTime;//创建时间yyyy-MM-dd HH:mm:ss
    private String code;//居民code
    private String codeType;//用户code类型 2居民
    private String hospital;//社区医院
    private String doctor;//全科
    private String diseaseType;//专病类型
    private String specialist;//专科
    private String specialistHospital;//专科医院
    private String content;//全科文案
    private String specialistContent;//专科文案
    private String type;//类型1康复计划 2代预约 3咨询求助 4专科协同
    private String photo;//头像
    private String doctorName;//全科医生姓名
    private String specialistName;//专科医生姓名
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "result")
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    @Column(name = "createTime")
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "code_type")
    public String getCodeType() {
        return codeType;
    }
    public void setCodeType(String codeType) {
        this.codeType = codeType;
    }
    @Column(name = "disease_type")
    public String getDiseaseType() {
        return diseaseType;
    }
    public void setDiseaseType(String diseaseType) {
        this.diseaseType = diseaseType;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "specialist")
    public String getSpecialist() {
        return specialist;
    }
    public void setSpecialist(String specialist) {
        this.specialist = specialist;
    }
    @Column(name = "specialist_hospital")
    public String getSpecialistHospital() {
        return specialistHospital;
    }
    public void setSpecialistHospital(String specialistHospital) {
        this.specialistHospital = specialistHospital;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "specialist_content")
    public String getSpecialistContent() {
        return specialistContent;
    }
    public void setSpecialistContent(String specialistContent) {
        this.specialistContent = specialistContent;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Transient
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    @Transient
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Transient
    public String getSpecialistName() {
        return specialistName;
    }
    public void setSpecialistName(String specialistName) {
        this.specialistName = specialistName;
    }
}

+ 107 - 78
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/team/WlyyAdminTeamDO.java

@ -1,115 +1,93 @@
package com.yihu.jw.entity.hospital.team;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.persistence.criteria.CriteriaBuilder;
import java.io.Serializable;
import java.util.ArrayList;
import com.yihu.jw.entity.IdEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.stereotype.Component;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * Created by yww on 2016/11/15.
 * 医生行政团队。
 *
 * @author Sand
 */
@Component
@Entity
@Table(name = "wlyy_admin_team")
@EntityListeners(AuditingEntityListener.class)
public class WlyyAdminTeamDO implements Serializable {
    private Integer id;
    private static final long serialVersionUID = 1L;
    private String name;            //团队名称
    private Date createTime;              //创建时间
    private Integer available;
public class WlyyAdminTeamDO extends IdEntity {
    private String name;
    private Date createTime;
    private String leaderCode;
    private boolean available;
    private String orgCode;
    private String orgName;
    private String leaderCode;
    private String leaderName;
    private String townCode;
    private String townName;
    private String mappingCode;
    private String mappingName;
    private Date lastModified;
    private String memberCount;
    @Id
    @Column(name = "id")
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getMemberCount() {
        return memberCount;
    }
    public void setMemberCount(String memberCount) {
        this.memberCount = memberCount;
    }
    //不对应表中字段
    private List<WlyyAdminTeamMemberDO> memberList = new ArrayList<>();
    private String specialCode;
    private String specialName;
    private String phone;//团队电话
    private String phoneStatus;//是否对外开放电话 1是0否
    private Integer acceptType;//是否接受下转 0接受 1拒绝
    private String signLimit;//签约上限
    public String getName() {
        return name;
    }
    @Column(name = "name")
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    @Column(name = "create_time")
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getAvailable() {
        return available;
    }
    public void setAvailable(Integer available) {
        this.available = available;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    @Column(name = "org_code")
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    @Transient
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
    @Column(name = "leader_code")
    public String getLeaderCode() {
        return leaderCode;
    }
    @Column(name = "leader_id")
    public void setLeaderCode(String leaderCode) {
        this.leaderCode = leaderCode;
    }
    @Column(name = "leader_name")
    public String getLeaderName() {
        return leaderName;
    public boolean isAvailable() {
        return available;
    }
    public void setLeaderName(String leaderName) {
        this.leaderName = leaderName;
    @Column(name = "available")
    public void setAvailable(boolean available) {
        this.available = available;
    }
    @Column(name = "mapping_code")
    public String getMappingCode() {
        return mappingCode;
@ -118,30 +96,81 @@ public class WlyyAdminTeamDO implements Serializable {
    public void setMappingCode(String mappingCode) {
        this.mappingCode = mappingCode;
    }
    @Transient
    public String getMappingName() {
        return mappingName;
    public String getOrgName() {
        return orgName;
    }
    public void setMappingName(String mappingName) {
        this.mappingName = mappingName;
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name = "last_modified")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getLastModified() {
        return lastModified;
    @Transient
    public String getTownCode() {
        return townCode;
    }
    public void setLastModified(Date lastModified) {
        this.lastModified = lastModified;
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    @Transient
    public List<WlyyAdminTeamMemberDO> getMemberList() {
        return memberList;
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getSpecialCode() {
        return specialCode;
    }
    public void setSpecialCode(String specialCode) {
        this.specialCode = specialCode;
    }
    public String getSpecialName() {
        return specialName;
    }
    public void setSpecialName(String specialName) {
        this.specialName = specialName;
    }
    @Column(name = "accept_type")
    public Integer getAcceptType() {
        return acceptType;
    }
    public void setAcceptType(Integer acceptType) {
        this.acceptType = acceptType;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Column(name = "phone_status")
    public String getPhoneStatus() {
        return phoneStatus;
    }
    public void setPhoneStatus(String phoneStatus) {
        this.phoneStatus = phoneStatus;
    }
    @Column(name = "sign_limit")
    public String getSignLimit() {
        return signLimit;
    }
    public void setMemberList(List<WlyyAdminTeamMemberDO> memberList) {
        this.memberList = memberList;
    public void setSignLimit(String signLimit) {
        this.signLimit = signLimit;
    }
}

+ 56 - 0
common/common-util/src/main/java/com/yihu/jw/util/DoctorAssistantUtil.java

@ -0,0 +1,56 @@
package com.yihu.jw.util;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
 * 医生助手工具类
 * Created by yeshijie on 2021/7/9.
 */
@Component
public class DoctorAssistantUtil {
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 发送医生助手通用方法
     * @param type
     * @param openId
     * @param first
     * @param remark
     * @param keywords
     */
    public void sendWXTemplate(int type,String openId,String cid,String first,String remark,String ... keywords){
        try{
            String doctorAssistantUrl = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("type", type+""));
            params.add(new BasicNameValuePair("openId", openId));
            params.add(new BasicNameValuePair("cid", cid));
            params.add(new BasicNameValuePair("url", targetUrl));
            params.add(new BasicNameValuePair("first", first));
            params.add(new BasicNameValuePair("remark", remark));
            params.add(new BasicNameValuePair("keywords", String.join(",",keywords)));
            httpClientUtil.post(doctorAssistantUrl, params, "UTF-8");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 14 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1632,4 +1632,18 @@ public class DateUtil {
        int monthsDiff = Math.abs(yearInterval * 12 + monthInterval);
        return monthsDiff;
    }
    /**
     * 根据数组返回若干天后的时间
     * @return 返回yyyy-MM-dd格式集合
     */
    public static List<String> getDaysByNow(int[] dayArray){
        List<String> list = new ArrayList<>();
        Date date = new Date();
        for (int i : dayArray) {
            Date preDays = DateUtil.getPreDays(date, i);
            list.add(DateUtil.dateToStrShort(preDays));
        }
        return list;
    }
}

+ 38 - 0
common/common-util/src/main/java/com/yihu/jw/util/encrypt/MD5.java

@ -16,6 +16,10 @@ import java.security.PrivilegedAction;
 */
public class MD5 {
    // 全局数组
    private final static String[] strDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
    public static String md5Hex(String data) {
        return DigestUtils.md5Hex(data);
    }
@ -178,4 +182,38 @@ public class MD5 {
    public static boolean md5CheckSum(String path, String toBeCheckSum) throws NoSuchAlgorithmException, IOException {
        return getMD5(path).equals(toBeCheckSum);
    }
    public static String GetMD5Code(String strObj) {
        String resultString = null;
        try {
            resultString = new String(strObj);
            MessageDigest md = MessageDigest.getInstance("MD5");
            // md.digest() 该函数返回值为存放哈希值结果的byte数组
            resultString = byteToString(md.digest(strObj.getBytes()));
        } catch (NoSuchAlgorithmException ex) {
            ex.printStackTrace();
        }
        return resultString;
    }
    // 转换字节数组为16进制字串
    private static String byteToString(byte[] bByte) {
        StringBuffer sBuffer = new StringBuffer();
        for (int i = 0; i < bByte.length; i++) {
            sBuffer.append(byteToArrayString(bByte[i]));
        }
        return sBuffer.toString();
    }
    // 返回形式为数字跟字符串
    private static String byteToArrayString(byte bByte) {
        int iRet = bByte;
        // System.out.println("iRet="+iRet);
        if (iRet < 0) {
            iRet += 256;
        }
        int iD1 = iRet / 16;
        int iD2 = iRet % 16;
        return strDigits[iD1] + strDigits[iD2];
    }
}

+ 2 - 0
common/common-util/src/main/java/com/yihu/jw/util/html/HtmlUtil.java

@ -1,6 +1,7 @@
package com.yihu.jw.util.html;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@ -12,6 +13,7 @@ import java.util.regex.Pattern;
/**
 * Created by liub on 2020/12/10.
 */
@Component
public class HtmlUtil {
    public static List<String> getTagContent(String source, String regString) {
        List<String> result = new ArrayList<String>();

+ 1 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/async/AsynService.java

@ -2,7 +2,6 @@ package com.yihu.jw.hospital.async;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.dict.service.FollowUpDictService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -139,7 +138,7 @@ public class AsynService {
                    messageJson.put("patientName",patient.getName());
                    messageJson.put("medicalRecordDo", JSON.toJSONString(patientMedicalRecordsDO1));
                    imUtill.sendImMsg(doctor.getId(),doctor.getName(),sessionId,"3101",messageJson.toString(),"1");
                    ImUtil.sendImMsg(doctor.getId(),doctor.getName(),sessionId,"3101",messageJson.toString(),"1");
                }
            }
        } catch (RuntimeException se) {

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

@ -7,6 +7,7 @@ package com.yihu.jw.hospital.module.followup.dao;
import com.yihu.jw.entity.followup.Followup;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
@ -51,7 +52,8 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupPlanDate between ?2 and ?3 and a.status <> '0' and a.patientCode = ?4 and a.followupClass = ?5 and a.patientName like ?6 and a.followupClass in(5,6,7,8,9) order by a.followupPlanDate DESC")
    List<Followup> findAllDoorDoctorPlan(String doctor, Date begin, Date end, String patientCode, String followupClass, String patientName) throws Exception;
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupPlanDate between ?2 and ?3 and a.status <> '0' and a.followupClass=?4 and a.patientName like ?5 and a.followupClass in(5,6,7,8,9) order by a.followupPlanDate DESC")
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupPlanDate between ?2 and ?3 and a.status <> '0' " +
            "and a.followupClass=?4 and a.patientName like ?5 and a.followupClass in('5','6','7','8','9') order by a.followupPlanDate DESC")
    List<Followup> findAllDoorDoctorPlan(String doctor, Date begin, Date end, String followupClass, String patientName) throws Exception;
    @Query("select a from Followup a where a.patientCode = ?1 and a.status <> '0' and a.doctorCode = ?2 order by a.followupPlanDate DESC")
@ -70,8 +72,13 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
     * @param pageable
     * @return
     */
    @Query("select distinct d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode,a.type from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and (a.adminTeamCode = ?2 or a.doctorCode=?3) and a.status > '0' order by a.followupPlanDate")
    Page<Object> findByPatientAndTeam(String patient, Long teamCode, String doctor, Pageable pageable);
    @Query("select distinct d.id,d.name,d.photo,a.followupType,a.followupClass," +
            "a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.id,c.name,c.photo" +
            ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode,a.type from Followup a, " +
            "BaseDoctorDO d, BaseDoctorDO c " +
            "where a.doctorCode = d.id and a.creater = c.id and a.patientCode = ?1 " +
            "and (a.adminTeamCode = ?2 or a.doctorCode=?3) and a.status > '0' order by a.followupPlanDate")
    Page<Object> findByPatientAndTeam(String patient, Long teamCode, String doctor, PageRequest pageable);
    /**
     * 查找所有的随访数据
@ -79,8 +86,11 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
     * @param pageable
     * @return
     */
    @Query("select d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1  and a.status > '0'")
    Page<Object> findByPatient(String patient, Pageable pageable);
    @Query("select d.id,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus," +
            "c.id,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode " +
            "from Followup a, BaseDoctorDO d, BaseDoctorDO c " +
            "where a.doctorCode = d.id and a.creater = c.id and a.patientCode = ?1  and a.status > '0'")
    Page<Object> findByPatient(String patient, PageRequest pageable);
    /**
     * 查找所有的随访计划(未开始的归类为计划)
@ -88,8 +98,11 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
     * @param pageable
     * @return
     */
    @Query("select d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and a.status = '2'")
    Page<Object> findPlanByPatient(String patient, Pageable pageable);
    @Query("select d.id,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus," +
            "c.id,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode " +
            "from Followup a, BaseDoctorDO d, BaseDoctorDO c " +
            "where a.doctorCode = d.id and a.creater = c.id and a.patientCode = ?1 and a.status = '2'")
    Page<Object> findPlanByPatient(String patient, PageRequest pageable);
    /**
     * 查找所有的随访记录(进行中的,已完整的的归类为计划)
@ -97,8 +110,11 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
     * @param pageable
     * @return
     */
    @Query("select d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and (a.status = '1' or a.status = '3')")
    Page<Object> findRecordByPatient(String patient, Pageable pageable);
    @Query("select d.id,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus," +
            "c.id,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode " +
            "from Followup a, BaseDoctorDO d, BaseDoctorDO c" +
            " where a.doctorCode = d.id and a.creater = c.id and a.patientCode = ?1 and (a.status = '1' or a.status = '3')")
    Page<Object> findRecordByPatient(String patient, PageRequest pageable);
    /**
     * 查找所有的随访计划(未开始的归类为计划)
@ -107,8 +123,13 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
     * @param pageable
     * @return
     */
    @Query("select distinct d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode,a.type from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and (a.adminTeamCode = ?2 or a.doctorCode=?3) and a.status = '2' order by a.followupPlanDate")
    Page<Object> findPlanByPatientAndTeam(String patient, Long teamCode, String doctor, Pageable pageable);
    @Query("select distinct d.id,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime," +
            "a.followupManagerStatus,c.id,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate," +
            "a.id,a.followupNo,a.prescriptionCode,a.type " +
            "from Followup a, BaseDoctorDO d, BaseDoctorDO c where a.doctorCode = d.id and a.creater = c.id and a.patientCode = ?1 " +
            "and (a.adminTeamCode = ?2 or a.doctorCode=?3) and a.status = '2' " +
            "order by a.followupPlanDate")
    Page<Object> findPlanByPatientAndTeam(String patient, Long teamCode, String doctor, PageRequest pageable);
    /**
@ -118,8 +139,13 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
     * @param pageable
     * @return
     */
    @Query("select distinct d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" + ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode,a.type from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and (a.adminTeamCode = ?2 or a.doctorCode=?3) and (a.status = '1' or a.status = '3')  order by a.followupPlanDate")
    Page<Object> findRecordByPatientAndTeam(String patient, Long teamCode, String doctor, Pageable pageable);
    @Query("select distinct d.id,d.name,d.photo,a.followupType,a.followupClass,a.status," +
            "a.createTime,a.updateTime,a.followupManagerStatus,c.id,c.name,c.photo" +
            ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo,a.prescriptionCode,a.type " +
            "from Followup a, BaseDoctorDO d, BaseDoctorDO c " +
            "where a.doctorCode = d.id and a.creater = c.id and a.patientCode = ?1 " +
            "and (a.adminTeamCode = ?2 or a.doctorCode=?3) and (a.status = '1' or a.status = '3')  order by a.followupPlanDate")
    Page<Object> findRecordByPatientAndTeam(String patient, Long teamCode, String doctor, PageRequest pageable);
    /**
     * 根据续方CODE获取随访记录

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

@ -3,34 +3,39 @@ package com.yihu.jw.hospital.module.followup.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.entity.followup.FollowupContent;
import com.yihu.jw.entity.followup.FollowupMapping;
import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.hospital.module.followup.dao.FollowUpDao;
import com.yihu.jw.hospital.module.followup.dao.FollowupContentDao;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.followup.*;
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.module.followup.dao.*;
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.team.dao.WlyySignFamilyDao;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.system.service.SystemDictService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.hibernate.sql.Delete;
import org.json.JSONArray;
import org.json.JSONObject;
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.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
@ -41,11 +46,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -58,14 +59,14 @@ import java.util.stream.Collectors;
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowUpService  {
public class FollowUpService {
    private static Logger logger = LoggerFactory.getLogger(FollowUpService.class);
    //统计随访类型
    public static String[] FOLLOWUP_TYPE = {"1","2","3","10","22"};
    public static String[] FOLLOWUP_TYPE = {"1", "2", "3", "10", "22"};
    //随访类别,多类别“,”分割【1.高血压 2.糖尿病 3.肿瘤 4.精神分裂症 5.产后 6.新生儿 7.严重精神病 8.80岁以上老人 9.肺结核】
    public static String[] FOLLOWUP_CLASS = {"1","2","1,2","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};
    public static String[] FOLLOWUP_CLASS = {"1", "2", "1,2", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"};
    @Autowired
    private BaseDoctorDao doctorDao;
@ -80,16 +81,16 @@ public class FollowUpService  {
    private FollowupContentDao followupContentDao;
    @Autowired
    private SystemDictDO systemDictService;
    private SystemDictService systemDictService;
    @Autowired
    private SignFamilyDao signFamilyDao;
    private WlyySignFamilyDao signFamilyDao;
    @Autowired
    private DrHealthTeamService drHealthTeamService;
//    @Autowired
//    private DrHealthTeamService drHealthTeamService;
    @Autowired
    private MessageDao messageDao;
    private SystemMessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
@ -98,48 +99,57 @@ public class FollowUpService  {
    SystemDictService dictService;
    @Autowired
    private PatientService patientService;
    private BasePatientService patientService;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private FollowUpMappingDao followUpMappingDao;
    @Autowired
    private FollowupDrugsDao followupDrugsDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
//
//    @Value("${es.type.FollowUpContent}")
//    private String esType;
//    @Value("${es.index.FollowUp}")
//    private String esIndex;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${es.type.FollowUpContent}")
    private String esType;
    @Value("${es.index.FollowUp}")
    private String esIndex;
    @Autowired
    private ElasticFactory elasticFactory;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Autowired
    private MessageService messageService;
    private SystemMessageService messageService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private FollowupSignDao followupSignDao;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private BusinessMappingDao businessMappingDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private VisitDetailService visitDetailService;
    @Value("${fastDFS.fastdfs_file_url}")
    private String imgUrlDomain;
    @Autowired
    private RehabilitationManageService rehabilitationManageService;
//    @Autowired
//    private VisitDetailService visitDetailService;
//    @Autowired
//    private ElasticFactory elasticFactory;
//    @Autowired
//    private ElastricSearchSave elastricSearchSave;
//    @Autowired
//    private ElasticsearchUtil elasticsearchUtil;
//    @Autowired
//    private BusinessMappingDao businessMappingDao;
    /**
     * 转译随访信息
     */
@ -147,7 +157,7 @@ public class FollowUpService  {
        Map<String, String> re = new HashMap<>();
        //患者信息
        String patientCode = followup.getPatientCode();
        Patient patient = patientDao.findByCode(patientCode);
        BasePatientDO patient = patientDao.findById(patientCode).orElse(null);
        if (patient != null) {
            re.put("patientCode", patientCode);
            re.put("patientName", patient.getName());
@ -161,7 +171,7 @@ public class FollowUpService  {
            re.put("birthday", DateUtil.dateToStrLong(patient.getBirthday()));
            re.put("photo", patient.getPhoto());
        } else {
            throw new ServiceException("查找不到用户信息!");
            throw new RuntimeException("查找不到用户信息!");
        }
        re.put("id", String.valueOf(followup.getId()));
@ -207,7 +217,7 @@ public class FollowUpService  {
        re.put("followupContentPhone", followup.getFollowupContentPhone());
        re.put("createTime", DateUtil.dateToStrLong(followup.getCreateTime()));
        re.put("creater", followup.getCreater());
        re.put("prescriptionCode",followup.getPrescriptionCode());
        re.put("prescriptionCode", followup.getPrescriptionCode());
        return re;
    }
@ -259,18 +269,18 @@ public class FollowUpService  {
     * @return
     */
    public JSONArray getListByPatientAndTeam(String patient, String doctor, Long teamCode, int page, int pageSize, String type) {
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize, sort);
        Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest =  PageRequest.of(page, pageSize, sort);
        Page<Object> result = null;
        if (StringUtils.isBlank(type)) {
            result = followupDao.findByPatientAndTeam(patient, teamCode, doctor, pageRequest);
        } else if ("1".equals(type)) {
            //已经开始的就是记录
            result = followupDao.findPlanByPatientAndTeam(patient,teamCode, doctor, pageRequest);
            result = followupDao.findPlanByPatientAndTeam(patient, teamCode, doctor, pageRequest);
        } else if ("2".equals(type)) {
            //未开始的就是计划
            result = followupDao.findRecordByPatientAndTeam(patient, teamCode,doctor, pageRequest);
            result = followupDao.findRecordByPatientAndTeam(patient, teamCode, doctor, pageRequest);
        } else {
        }
@ -281,16 +291,18 @@ public class FollowUpService  {
            Map<String, String> dictMap = new HashMap<>();
            Map<String, String> statusMap = new HashMap<>();
            Map<String, String> mngStatusMap = new HashMap<>();
            List<SystemDict> dicts = dictService.getDictByDictName("FOLLOWUP_WAY_DICT");
            List<SystemDict> mngDicts = dictService.getDictByDictName("FOLLOWUP_MANAGER_STATUS");
            List<SystemDictDO> dicts = dictService.getDictByDictName("FOLLOWUP_WAY_DICT");
            List<SystemDictDO> mngDicts = dictService.getDictByDictName("FOLLOWUP_MANAGER_STATUS");
            if (dicts != null) {
                for (SystemDict dict : dicts) {
                    dictMap.put(dict.getCode(), dict.getValue());
                for (SystemDictDO dict : dicts) {
//                    dictMap.put(dict.getCode(), dict.getValue());
                    dictMap.put(dict.getCode(), dict.getName());
                }
            }
            if (mngDicts != null) {
                for (SystemDict dict : mngDicts) {
                    mngStatusMap.put(dict.getCode(), dict.getValue());
                for (SystemDictDO dict : mngDicts) {
//                    mngStatusMap.put(dict.getCode(), dict.getValue());
                    mngStatusMap.put(dict.getCode(), dict.getName());
                }
            }
@ -303,7 +315,7 @@ public class FollowUpService  {
                JSONObject followup = new JSONObject();
                Object[] objArr = (Object[]) obj;
//              返回值增加居民信息
                Patient patientDetail = patientDao.findByCode(patient);
                BasePatientDO patientDetail = patientDao.findById(patient).orElse(null);
                followup.put("patientName", patientDetail.getName() != null ? patientDetail.getName() : "");
                followup.put("photo", patientDetail.getPhoto() != null ? patientDetail.getPhoto() : "");
                followup.put("sex", patientDetail.getSex() != null ? patientDetail.getSex() : "");
@ -367,8 +379,9 @@ public class FollowUpService  {
     * @return
     */
    public JSONArray getListByPatient(String patient, int page, int pageSize, String type) {
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize, sort);
//        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = PageRequest.of(page, pageSize);
        Page<Object> result = null;
        if (StringUtils.isBlank(type)) {
@ -389,16 +402,18 @@ public class FollowUpService  {
            Map<String, String> dictMap = new HashMap<>();
            Map<String, String> statusMap = new HashMap<>();
            Map<String, String> mngStatusMap = new HashMap<>();
            List<SystemDict> dicts = dictService.getDictByDictName("FOLLOWUP_WAY_DICT");
            List<SystemDict> mngDicts = dictService.getDictByDictName("FOLLOWUP_MANAGER_STATUS");
            List<SystemDictDO> dicts = dictService.getDictByDictName("FOLLOWUP_WAY_DICT");
            List<SystemDictDO> mngDicts = dictService.getDictByDictName("FOLLOWUP_MANAGER_STATUS");
            if (dicts != null) {
                for (SystemDict dict : dicts) {
                    dictMap.put(dict.getCode(), dict.getValue());
                for (SystemDictDO dict : dicts) {
//                    dictMap.put(dict.getCode(), dict.getValue());
                    dictMap.put(dict.getCode(), dict.getName());
                }
            }
            if (mngDicts != null) {
                for (SystemDict dict : mngDicts) {
                    mngStatusMap.put(dict.getCode(), dict.getValue());
                for (SystemDictDO dict : mngDicts) {
//                    mngStatusMap.put(dict.getCode(), dict.getValue());
                    mngStatusMap.put(dict.getCode(), dict.getName());
                }
            }
@ -411,7 +426,7 @@ public class FollowUpService  {
                JSONObject followup = new JSONObject();
                Object[] objArr = (Object[]) obj;
//              返回值增加居民信息
                Patient patientDetail = patientDao.findByCode(patient);
                BasePatientDO patientDetail = patientDao.findById(patient).orElse(null);
                followup.put("patientName", patientDetail.getName() != null ? patientDetail.getName() : "");
                followup.put("photo", patientDetail.getPhoto() != null ? patientDetail.getPhoto() : "");
                followup.put("sex", patientDetail.getSex() != null ? patientDetail.getSex() : "");
@ -462,17 +477,19 @@ public class FollowUpService  {
        return array;
    }
    /**
     * 获取医生随访列表(创建者)
     */
    public List<Map<String, String>> getListByCreater(String doctorCode, String startTime, String endTime, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
//        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
        // 分页信息
        int pageInt = Integer.valueOf(page) - 1;
        int pageSizeInt = Integer.valueOf(pageSize);
        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
//        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
        PageRequest pageRequest = PageRequest.of(pageInt, pageSizeInt);
        List<Followup> list = followupDao.findByCreater(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime), pageRequest);
        if (list != null && list.size() > 0) {
@ -495,19 +512,19 @@ public class FollowUpService  {
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
        if (list != null && list.size() > 0) {
            //获取患者信息
            Patient patient = patientDao.findByCode(patientCode);
            BasePatientDO patient = patientDao.findById(patientCode).orElse(null);
            if (patient == null) {
                throw new ServiceException("获取不到用户信息!");
                throw new RuntimeException("获取不到用户信息!");
            }
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
            Long adminCodeId=0L;
            Long adminCodeId = 0L;
            List<Followup> followupPlan = new ArrayList<>();
            for (Map<String, String> map : list) {
                //获取医生信息
                Doctor doctor = doctorDao.findByCode(map.get("doctor"));
                BaseDoctorDO doctor = doctorDao.findById(map.get("doctor")).orElse(null);
                if (doctor == null) {
                    throw new ServiceException("获取不到医生信息!");
                    throw new RuntimeException("获取不到医生信息!");
                }
                Followup followup = new Followup();
@ -515,10 +532,10 @@ public class FollowUpService  {
                Date date = DateUtil.strToDate(map.get("date"));
                followup.setFollowupDate(date);
                followup.setFollowupPlanDate(date);
                followup.setDoctorCode(doctor.getCode());
                followup.setDoctorCode(doctor.getId());
                followup.setDoctorName(doctor.getName());
                followup.setOrgCode(doctor.getHospital());
                followup.setOrgName(doctor.getHospitalName());
//                followup.setOrgCode(doctor.getHospital());
//                followup.setOrgName(doctor.getHospitalName());
                followup.setPatientCode(patientCode);
                followup.setPatientName(patient.getName());
                followup.setIdcard(patient.getIdcard());
@ -526,10 +543,10 @@ public class FollowUpService  {
                followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
                followup.setCreateTime(new Date());
                followup.setCreater(doctorCode);
                if (!map.get("followupClass").toString().equalsIgnoreCase("10")){
                if (!map.get("followupClass").toString().equalsIgnoreCase("10")) {
                    if (signFamily == null) {
                        throw new ServiceException("非家签居民仅支持创建体温异常随访");
                    }else{
                        throw new RuntimeException("非家签居民仅支持创建体温异常随访");
                    } else {
                        adminCodeId = signFamily.getAdminTeamId();
                    }
                }
@ -540,16 +557,16 @@ public class FollowUpService  {
                followup.setSignType(2);
                //获取随访医生角色类型
                List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(doctorCode);
                if(doctorMapping.size() ==1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())){
                    followup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
                }
//                List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(doctorCode);
//                if(doctorMapping.size() ==1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())){
//                    followup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
//                }
                //新增签约保存CODE
                followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
//                followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
                followupPlan.add(followup);
            }
            return followupDao.save(followupPlan);
            return followupDao.saveAll(followupPlan);
        }
        return null;
@ -560,17 +577,17 @@ public class FollowUpService  {
     */
    public Followup addFollowupPlanNew(String doctorCode, String patientCode, JSONObject data, String dataJson) throws Exception {
        //获取患者信息
        Patient patient = patientDao.findByCode(patientCode);
        BasePatientDO patient = patientDao.findById(patientCode).orElse(null);
        if (patient == null) {
            throw new ServiceException("获取不到用户信息!");
            throw new RuntimeException("获取不到用户信息!");
        }
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        Long adminCodeId=0L;
        Long adminCodeId = 0L;
        //获取医生信息
        Doctor doctor = doctorDao.findByCode(data.getString("doctor"));
        BaseDoctorDO doctor = doctorDao.findById(data.getString("doctor")).orElse(null);
        if (doctor == null) {
            throw new ServiceException("获取不到医生信息!");
            throw new RuntimeException("获取不到医生信息!");
        }
        Followup followup = new Followup();
@ -578,10 +595,10 @@ public class FollowUpService  {
        Date date = DateUtil.strToDate(data.getString("date"));
        followup.setFollowupDate(date);
        followup.setFollowupPlanDate(date);
        followup.setDoctorCode(doctor.getCode());
//        followup.setDoctorCode(doctor.getCode());
        followup.setDoctorName(doctor.getName());
        followup.setOrgCode(doctor.getHospital());
        followup.setOrgName(doctor.getHospitalName());
//        followup.setOrgCode(doctor.getHospital());
//        followup.setOrgName(doctor.getHospitalName());
        followup.setPatientCode(patientCode);
        followup.setPatientName(patient.getName());
        followup.setIdcard(patient.getIdcard());
@ -589,10 +606,10 @@ public class FollowUpService  {
        followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
        followup.setCreateTime(new Date());
        followup.setCreater(doctorCode);
        if (!data.getString("followupClass").toString().equalsIgnoreCase("10")){
        if (!data.getString("followupClass").toString().equalsIgnoreCase("10")) {
            if (signFamily == null) {
                throw new ServiceException("非家签居民仅支持创建体温异常随访");
            }else{
                throw new RuntimeException("非家签居民仅支持创建体温异常随访");
            } else {
                adminCodeId = signFamily.getAdminTeamId();
            }
        }
@ -603,16 +620,17 @@ public class FollowUpService  {
        followup.setSignType(2);
        //获取随访医生角色类型
        List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(doctorCode);
        if(doctorMapping.size() ==1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())){
            followup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
        }
//        List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(doctorCode);
//        if(doctorMapping.size() ==1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())){
//            followup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
//        }
        //新增签约保存CODE
        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
//        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        followup = followupDao.save(followup);
        rehabilitationManageService.updateRelationCodeByDetailId(data.getString("id"),followup.getId()+"");
        rehabilitationManageService.saveRehabilitationOperateRecord(dataJson);
//        远程2.0接口,参数在改改
//        rehabilitationManageService.updateRelationCodeByDetailId(data.getString("id"),followup.getId()+"");
//        rehabilitationManageService.saveRehabilitationOperateRecord(dataJson);
        return followup;
    }
@ -621,7 +639,7 @@ public class FollowUpService  {
     * 编辑随访计划
     */
    public void editFollowupPlan(String doctorCode, String id, String date, String followupType) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            Date followupDate = DateUtil.strToDate(date);
            followup.setFollowupDate(followupDate);
@ -631,7 +649,7 @@ public class FollowUpService  {
            followupDao.save(followup);
        } else {
            throw new ServiceException("查找不到该随访!");
            throw new RuntimeException("查找不到该随访!");
        }
    }
@ -639,9 +657,9 @@ public class FollowUpService  {
     * 开始随访记录
     */
    public Followup startFollowup(String id, String followupNo, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            if(followup.getStatus().compareTo("2") == 0) {
            if (followup.getStatus().compareTo("2") == 0) {
                followup.setFollowupNo(followupNo);
                followup.setFollowupDate(DateUtil.strToDate(date));
                //计划下次随访时间--huangwenjie.2017.10.19
@ -673,10 +691,10 @@ public class FollowUpService  {
                    nextFollowup.setSignType(followup.getSignType());
                    nextFollowup.setType(1);
                    //获取随访医生角色类型
                    List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(followup.getDoctorCode());
                    if(doctorMapping.size() ==1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())){
                        nextFollowup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
                    }
//                    List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(followup.getDoctorCode());
//                    if (doctorMapping.size() == 1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())) {
//                        nextFollowup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
//                    }
                    followupDao.save(nextFollowup);
                }
@ -685,16 +703,16 @@ public class FollowUpService  {
                followup.setFollowupManagerStatus(followupManagerStatus);
                followup.setStatus("3");  //状态 0取消 1已完成 2未开始 3进行中
                followup.setPrescriptionCode(prescriptioncode);
                
                if(StringUtils.isNoneBlank(prescriptioncode)){
                    try {
                        Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
//                        prescription.setViewSuifang(1);
                        prescriptionDao.save(prescription);
                    }catch (Exception e){
                        logger.info(e.getMessage());
                    }
                }
//                if (StringUtils.isNoneBlank(prescriptioncode)) {
//                    try {
//                        Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
////                        prescription.setViewSuifang(1);
//                        prescriptionDao.save(prescription);
//                    } catch (Exception e) {
//                        logger.info(e.getMessage());
//                    }
//                }
                Followup f = followupDao.save(followup);
                System.out.println("随访状态status" + f.getStatus());
@ -702,12 +720,13 @@ public class FollowUpService  {
            }
            return followup;
        } else {
            throw new ServiceException("查找不到该随访!");
            throw new RuntimeException("查找不到该随访!");
        }
    }
    /**
     * 如果今日没有计划中的随访计划,则将随访消息设成已操作
     *
     * @param doctor
     */
    public void getNotStartFollowup(String doctor, Date followupPlanDate) {
@ -717,11 +736,11 @@ public class FollowUpService  {
        String end = now + " 23:59:59";
        String sql = "select count(1) count from wlyy_followup where status = 2 and (followup_class is null or followup_class in (1,2)) " +
                "and followup_plan_date>='" + start + "' and followup_plan_date<='" + end + "'and  doctor_code = '" +doctor +"'";
                "and followup_plan_date>='" + start + "' and followup_plan_date<='" + end + "'and  doctor_code = '" + doctor + "'";
        //获取所有未执行随访计划
        Long followupToday = jdbcTemplate.queryForObject(sql, Long.class);
        System.out.println("计划中随访:" + followupToday);
        if(followupToday == 0){
        if (followupToday == 0) {
            messageDao.setMessageOverByType(doctor, 4, DateUtil.strToDateLong(start), DateUtil.strToDateLong(end));
        }
    }
@ -730,27 +749,27 @@ public class FollowUpService  {
    /**
     * 新增临时随访记录(返回ID)
     */
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode,Integer type) throws Exception {
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus, String plandate, String prescriptioncode, Integer type) throws Exception {
        String re = "";
        //获取医生信息
        Doctor doctor = doctorDao.findByCode(doctorCode);
        BaseDoctorDO doctor = doctorDao.findById(doctorCode).orElse(null);
        if (doctor == null) {
            throw new ServiceException("查找不到医生信息!");
            throw new RuntimeException("查找不到医生信息!");
        }
        //获取患者信息
        Patient patient = patientDao.findByCode(patientCode);
        BasePatientDO patient = patientDao.findById(patientCode).orElse(null);
        if (patient == null) {
            throw new ServiceException("查找不到居民信息!");
            throw new RuntimeException("查找不到居民信息!");
        }
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        Long adminId = 0L;
        if (!followupClass.equalsIgnoreCase("10")){
        if (!followupClass.equalsIgnoreCase("10")) {
            if (signFamily == null) {
                throw new ServiceException("非家签居民仅支持创建体温异常随访");
            }else {
                adminId=signFamily.getAdminTeamId();
                throw new RuntimeException("非家签居民仅支持创建体温异常随访");
            } else {
                adminId = signFamily.getAdminTeamId();
            }
        }
@ -761,8 +780,8 @@ public class FollowUpService  {
        followup.setFollowupPlanDate(followDate);
        followup.setDoctorCode(doctorCode);
        followup.setDoctorName(doctor.getName());
        followup.setOrgCode(doctor.getHospital());
        followup.setOrgName(doctor.getHospitalName());
//        followup.setOrgCode(doctor.getHospital());
//        followup.setOrgName(doctor.getHospitalName());
        followup.setPatientCode(patientCode);
        followup.setPatientName(patient.getName());
        followup.setIdcard(patient.getIdcard());
@ -775,11 +794,11 @@ public class FollowUpService  {
        followup.setCreater(doctorCode);
        followup.setAdminTeamCode(signFamily.getAdminTeamId());
        followup.setSignType(2);
        if (type!=null&&type!=0){
        if (type != null && type != 0) {
            followup.setType(type);
        }
        //保存质询code
        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
//        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        //如果有填入续方CODE,则添加续方关联--huangwenjie.2017.11.02
        if (StringUtils.isNotBlank(prescriptioncode)) {
@ -826,12 +845,12 @@ public class FollowUpService  {
     * 取消随访计划
     */
    public void cancelFollowupPlan(String id) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            followup.setStatus("0");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
        } else {
            throw new ServiceException("查找不到该随访计划!");
            throw new RuntimeException("查找不到该随访计划!");
        }
    }
@ -839,7 +858,7 @@ public class FollowUpService  {
     * 完成随访记录,并上传随访记录
     */
    public void finishFollowup(String id) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followup = followupDao.save(followup);
@ -858,17 +877,17 @@ public class FollowUpService  {
            followupMapping.setNeedUpload(1);
            followUpMappingDao.save(followupMapping);
    
            //随访完成,增加随访状态完成的标记
            Prescription prescription = prescriptionDao.findByCode(followup.getPrescriptionCode());
            if(prescription  != null){
                prescription.setViewSuifang(1);
                prescriptionDao.save(prescription);
            }
//            Prescription prescription = prescriptionDao.findByCode(followup.getPrescriptionCode());
//            if (prescription != null) {
//                prescription.setViewSuifang(1);
//                prescriptionDao.save(prescription);
//            }
//            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
        } else {
            throw new ServiceException("查找不到该随访计划!");
            throw new RuntimeException("查找不到该随访计划!");
        }
    }
@ -878,11 +897,11 @@ public class FollowUpService  {
     */
    public Map<String, String> getFollowup(String id) throws Exception {
        Map<String, String> re = new HashMap<>();
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            re = getFollowupDetail(followup);
        } else {
            throw new ServiceException("查找不到该随访信息");
            throw new RuntimeException("查找不到该随访信息");
        }
        return re;
    }
@ -895,15 +914,16 @@ public class FollowUpService  {
        //获取已填写的面访项目
//        List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
        //修改为通过ES查询---2017.11.01--huangwenjie
        List<String> project = esfindProjectByFollowupId(id);
//        List<String> project = esfindProjectByFollowupId(id);
        List<String> project = null;
        //获取所有面访项目
        List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
        List<SystemDictDO> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
        if (dictList != null && dictList.size() > 0) {
            for (SystemDict dict : dictList) {
            for (SystemDictDO dict : dictList) {
                Map<String, String> map = new HashMap<>();
                String code = dict.getCode();
                map.put("projectCode", code);
                map.put("projectName", dict.getValue());
                map.put("projectName", dict.getName());
                if (project != null && project.contains(code)) {
                    map.put("status", "1"); //已填写
                } else {
@ -936,7 +956,7 @@ public class FollowUpService  {
        List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
        //删除原有记录
        followupContentDao.delete(dataList);
        followupContentDao.deleteAll(dataList);
        Map<String, String> data = objectMapper.readValue(followupProjectData, Map.class);
@ -951,11 +971,11 @@ public class FollowUpService  {
                item.setCreateTime(new Date());
                newList.add(item);
            }
            followupContentDao.save(newList);
            followupContentDao.saveAll(newList);
        }
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        if ("1".equals(followup.getStatus())) {
@ -979,11 +999,11 @@ public class FollowUpService  {
     */
    public String getFollowupPhone(String id) throws Exception {
        String re = "";
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            re = followup.getFollowupContentPhone();
        } else {
            throw new ServiceException("查找不到该随访计划!");
            throw new RuntimeException("查找不到该随访计划!");
        }
        return re;
    }
@ -992,12 +1012,12 @@ public class FollowUpService  {
     * 记录电话随访内容
     */
    public void saveFollowupPhone(String id, String content) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
        if (followup != null) {
            followup.setFollowupContentPhone(content);
            followupDao.save(followup);
        } else {
            throw new ServiceException("查找不到该随访计划!");
            throw new RuntimeException("查找不到该随访计划!");
        }
    }
@ -1007,14 +1027,14 @@ public class FollowUpService  {
    /**
     * 获取团队医生
     */
    private List<Doctor> getTeamDoctors(String doctor, String patient) throws Exception {
        List<Doctor> doctors = new ArrayList<>();
    private List<BaseDoctorDO> getTeamDoctors(String doctor, String patient) throws Exception {
        List<BaseDoctorDO> doctors = new ArrayList<>();
        //获取医生团队成员
        SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
        // 查询家庭医生团队
        if (signFamily != null) {
            doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
        }
//        if (signFamily != null) {
//            doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
//        }
        return doctors;
    }
@ -1027,11 +1047,12 @@ public class FollowUpService  {
        //获取医生团队成员
        String[] doctors = new String[]{doctor};
        List<Doctor> doctorList = getTeamDoctors(doctor, patient);
        List<BaseDoctorDO> doctorList = getTeamDoctors(doctor, patient);
        if (doctorList != null && doctorList.size() > 1) {
            doctors = new String[doctorList.size()];
            for (int i = 0; i < doctorList.size(); i++) {
                doctors[i] = doctorList.get(i).getCode();
//                doctors[i] = doctorList.get(i).getCode();
                doctors[i] = doctorList.get(i).getId();
            }
        }
@ -1051,40 +1072,40 @@ public class FollowUpService  {
    /**
     * 获取上次随访
     */
    public void copyFollowup(Long id, Long fromId) throws Exception {
//        List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
        JestClient jestClient = null;
        jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", fromId))
        );
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        List<FollowupContentESDO> list = result.getSourceAsObjectList(FollowupContentESDO.class);
        if (list != null && list.size() > 0) {
            List<FollowupContentESDO> copyList = new ArrayList<>();
            for (FollowupContentESDO item : list) {
                FollowupContentESDO copyItem = new FollowupContentESDO();
                BeanUtils.copyProperties(item, copyItem);
                copyItem.setId(null);
                copyItem.setFollowup_id(id + "");
                copyItem.setCreate_time(new Date());
//                copyItem.setFollowupId(id);
//                copyItem.setFollowupKey(item.getFollowupKey());
//                copyItem.setFollowupValue(item.getFollowupValue());
//                copyItem.setFollowupProject(item.getFollowupProject());
                copyList.add(copyItem);
            }
            elastricSearchSave.save(copyList, esIndex, esType);
        }
    }
//    public void copyFollowup(Long id, Long fromId) throws Exception {
////        List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
//        JestClient jestClient = null;
//        jestClient = elasticFactory.getJestClient();
//        //先根据条件查找出来
//        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//        searchSourceBuilder.query(
//                new BoolQueryBuilder()
//                        .must(QueryBuilders.matchQuery("followup_id", fromId))
//        );
//
//        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                .build();
//        SearchResult result = jestClient.execute(search);
//        List<FollowupContentESDO> list = result.getSourceAsObjectList(FollowupContentESDO.class);
//
//        if (list != null && list.size() > 0) {
//            List<FollowupContentESDO> copyList = new ArrayList<>();
//            for (FollowupContentESDO item : list) {
//                FollowupContentESDO copyItem = new FollowupContentESDO();
//                BeanUtils.copyProperties(item, copyItem);
//                copyItem.setId(null);
//                copyItem.setFollowup_id(id + "");
//                copyItem.setCreate_time(new Date());
////                copyItem.setFollowupId(id);
////                copyItem.setFollowupKey(item.getFollowupKey());
////                copyItem.setFollowupValue(item.getFollowupValue());
////                copyItem.setFollowupProject(item.getFollowupProject());
//                copyList.add(copyItem);
//            }
//
//            elastricSearchSave.save(copyList, esIndex, esType);
//        }
//    }
    /**************************************** 随访计划消息 ******************************************/
    /**
@ -1101,7 +1122,7 @@ public class FollowUpService  {
            List<Map<String, Object>> followupToday = jdbcTemplate.queryForList(sql);
            if (followupToday != null) {
                List<Message> list = new ArrayList<>();
                List<SystemMessageDO> list = new ArrayList<>();
                for (Map<String, Object> map : followupToday) {
                    String doctor = String.valueOf(map.get("doctor_code"));
                    String count = String.valueOf(map.get("count"));
@ -1109,28 +1130,28 @@ public class FollowUpService  {
                    // 添加签约消息
                    String title = "随访计划提醒";
                    String content = "您今日有" + count + "个随访计划待处理";
                    Message message = new Message();
                    message.setCode(getCode());
                    message.setCzrq(new Date());
                    SystemMessageDO message = new SystemMessageDO();
                    message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
                    message.setCreateTime(new Date());
                    message.setCreateTime(new Date());
                    message.setContent(content);
                    message.setRead(1);//设置未读
                    message.setIsRead("1");//设置未读
                    message.setReceiver(doctor);//设置接受医生的code
                    message.setSender("system");//设置发送的用户
                    message.setTitle(title);
                    message.setType(4);//随访计划提醒
                    message.setType("4");//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    if(messageService.getMessageNoticeSettingByMessageType(doctor,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())){
                    if (messageService.getMessageNoticeSettingByMessageType(doctor, "1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())) {
                        // 推送消息给医生
                        pushMsgTask.put(doctor, "4", title, content, "");
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            List<Followup> followups = followupDao.getByDoctorPlan(doctor,format.parse(start),format.parse(end));
                            for (Followup followup:followups) {
                            List<Followup> followups = followupDao.getByDoctorPlan(doctor, format.parse(start), format.parse(end));
                            for (Followup followup : followups) {
                                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                                Doctor doctor1 = doctorDao.findByCode(doctor);
                                BaseDoctorDO doctor1 = doctorDao.findById(doctor).orElse(null);
                                String doctorOpenID = doctor1.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
@ -1138,7 +1159,7 @@ public class FollowUpService  {
                                    params.add(new BasicNameValuePair("type", "6"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first", "您今日有"+count+"个随访计划待处理"));
                                    params.add(new BasicNameValuePair("first", "您今日有" + count + "个随访计划待处理"));
                                    params.add(new BasicNameValuePair("remark", ""));
                                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                                    String newDate = formatDate.format(new Date());
@ -1153,8 +1174,7 @@ public class FollowUpService  {
                        }
                    }
                }
                messageDao.save(list);
                messageDao.saveAll(list);
            }
@ -1169,100 +1189,100 @@ public class FollowUpService  {
     * @author huangwenjie
     * @date 2017/11/1 14:57
     */
    @Transactional
    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
            List<FollowupContentESDO> dataList = new ArrayList<>();
            if(followupContentESDO != null){
                dataList.add(followupContentESDO);
                //删除原有记录
                this.esDeleteFollowUpContent(dataList);
            }
            //保存新的随访详情信息
            List<FollowupContentESDO> newdatalist = new ArrayList<>();
            followupContentESDO = new FollowupContentESDO();
            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
            followupContentESDO.setFollowup_id(id);
            followupContentESDO.setFollowup_project(followupProject);
            followupContentESDO.setCreate_time(new Date());
            newdatalist.add(followupContentESDO);
            elastricSearchSave.save(newdatalist, esIndex, esType);
            //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
            Followup followup = followupDao.findOne(Long.valueOf(id));
            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);
                //随访完成,增加随访状态完成的标记
                Prescription prescription = prescriptionDao.findByCode(followup.getPrescriptionCode());
                if(prescription  != null){
                    prescription.setViewSuifang(1);
                    prescriptionDao.save(prescription);
                }
            }
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
//    @Transactional
//    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
//        JestClient jestClient = null;
//        try {
//
//
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
//
//            List<FollowupContentESDO> dataList = new ArrayList<>();
//            if(followupContentESDO != null){
//                dataList.add(followupContentESDO);
//                //删除原有记录
//                this.esDeleteFollowUpContent(dataList);
//            }
//
//            //保存新的随访详情信息
//            List<FollowupContentESDO> newdatalist = new ArrayList<>();
//            followupContentESDO = new FollowupContentESDO();
//            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
//            followupContentESDO.setFollowup_id(id);
//            followupContentESDO.setFollowup_project(followupProject);
//            followupContentESDO.setCreate_time(new Date());
//            newdatalist.add(followupContentESDO);
//            elastricSearchSave.save(newdatalist, esIndex, esType);
//
//
//            //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
//            Followup followup = followupDao.findOne(Long.valueOf(id));
//            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);
//                //随访完成,增加随访状态完成的标记
//                Prescription prescription = prescriptionDao.findByCode(followup.getPrescriptionCode());
//                if(prescription  != null){
//                    prescription.setViewSuifang(1);
//                    prescriptionDao.save(prescription);
//                }
//            }
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//    }
    /**
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        JestClient jestClient = null;
        FollowupContentESDO followupContentESDO = null;
        try {
            //根据随访ID、分类ID获取随访记录详情
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDO;
    }
//    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
//        JestClient jestClient = null;
//        FollowupContentESDO followupContentESDO = null;
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return followupContentESDO;
//    }
    /**
     * ES 删除随访详情信息
@ -1270,28 +1290,28 @@ public class FollowUpService  {
     * @author huangwenjie
     * @date 2017/11/1 15:17
     */
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (FollowupContentESDO obj : datalist) {
                Delete index = new Delete.Builder(obj.getId()).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("delete data count:" + datalist.size());
            logger.info("delete flag:" + br.isSucceeded());
            jestClient.shutdownClient();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
//    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
//        JestClient jestClient = null;
//        try {
//            jestClient = elasticFactory.getJestClient();
//            //根据id批量删除
//            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
//            for (FollowupContentESDO obj : datalist) {
//                Delete index = new Delete.Builder(obj.getId()).build();
//                bulk.addAction(index);
//            }
//            BulkResult br = jestClient.execute(bulk.build());
//
//            logger.info("delete data count:" + datalist.size());
//            logger.info("delete flag:" + br.isSucceeded());
//            jestClient.shutdownClient();
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//
//    }
    /**
     * ES获取面访项目数据列表
@ -1299,66 +1319,66 @@ public class FollowUpService  {
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
    public List<String> esfindProjectByFollowupId(String id) throws Exception {
        JestClient jestClient = null;
        List<String> resultList = new ArrayList<>();
        try {
            //根据随访ID、分类ID获取随访记录详情
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.from(0).size(100);
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
            followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
            if (!followupContentESDOList.isEmpty()) {
                for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
                   
                    if("2".equals(followupContentESDO.getFollowup_project())){
//                        //判断血压必填
//                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())
//                        &&StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR()) && StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR_TYPE())){
//    public List<String> esfindProjectByFollowupId(String id) throws Exception {
//        JestClient jestClient = null;
//        List<String> resultList = new ArrayList<>();
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.from(0).size(100);
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//
//            List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
//
//            followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
//            if (!followupContentESDOList.isEmpty()) {
//                for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
//
//                    if("2".equals(followupContentESDO.getFollowup_project())){
////                        //判断血压必填
////                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())
////                        &&StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR()) && StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR_TYPE())){
////                            resultList.add(followupContentESDO.getFollowup_project());
////                        } else if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
////                            resultList.add(followupContentESDO.getFollowup_project());
////                        }
//                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
//                            resultList.add(followupContentESDO.getFollowup_project());
//                        } else if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
//                        }
//                        if(StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR()) && StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR_TYPE())){
//                            resultList.add(followupContentESDO.getFollowup_project());
//                        }
                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
                            resultList.add(followupContentESDO.getFollowup_project());
                        }
                        if(StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR()) && StringUtils.isNotBlank(followupContentESDO.getBLOOD_SUGAR_TYPE())){
                            resultList.add(followupContentESDO.getFollowup_project());
                        }
                    }else if("3".equals(followupContentESDO.getFollowup_project())){
                        //判断血糖必填
                        if(StringUtils.isNotBlank(followupContentESDO.getBS_FPG()) ||
                                StringUtils.isNotBlank(followupContentESDO.getNO_BS_FPG())||
                                    StringUtils.isNotBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
                            resultList.add(followupContentESDO.getFollowup_project());
                        }
                    }else{
                        resultList.add(followupContentESDO.getFollowup_project());
                    }
                    
                }
            }
            jestClient.shutdownClient();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return resultList;
    }
//                    }else if("3".equals(followupContentESDO.getFollowup_project())){
//                        //判断血糖必填
//                        if(StringUtils.isNotBlank(followupContentESDO.getBS_FPG()) ||
//                                StringUtils.isNotBlank(followupContentESDO.getNO_BS_FPG())||
//                                    StringUtils.isNotBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
//                            resultList.add(followupContentESDO.getFollowup_project());
//                        }
//                    }else{
//                        resultList.add(followupContentESDO.getFollowup_project());
//                    }
//
//                }
//            }
//
//            jestClient.shutdownClient();
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return resultList;
//    }
    /**
     * ES获取面访项目数据详情
@ -1366,33 +1386,33 @@ public class FollowUpService  {
     * @author huangwenjie
     * @date 2017/11/1 19:41
     */
    public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
        JestClient jestClient = null;
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        try {
            //根据随访ID、分类ID获取随访记录详情
            List<String> resultList = new ArrayList<>();
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDOList;
    }
//    public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
//        JestClient jestClient = null;
//        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//
//            List<String> resultList = new ArrayList<>();
//
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return followupContentESDOList;
//    }
    /**
     * 根据续方CODE获取随访记录信息
@ -1416,105 +1436,104 @@ public class FollowUpService  {
     * @param type
     * @return
     */
    public int getfollowupcontent(String followupid, String type) throws Exception {
        int count = 0;
        String[] typelist = null;
        if (type.contains(",")) {
            typelist = type.split(",");
        } else {
            typelist = new String[]{type};
        }
        for (String typekey : typelist) {
            if (!"drug".equals(type)) {
//    public int getfollowupcontent(String followupid, String type) throws Exception {
//
//        int count = 0;
//        String[] typelist = null;
//        if (type.contains(",")) {
//            typelist = type.split(",");
//        } else {
//            typelist = new String[]{type};
//        }
//
//        for (String typekey : typelist) {
//            if (!"drug".equals(type)) {
//
//                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid, typekey);
//                if (followupContentESDO != null) {
//                    count++;
//                }
//
//            } else {
//                //获取用药记录
//                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
//                if (!drugsList.isEmpty()) {
//                    count = count + drugsList.size();
//                }
//            }
//        }
//
//        return count;
//
//    }
                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid, typekey);
                if (followupContentESDO != null) {
                    count++;
                }
            } else {
                //获取用药记录
                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
                if (!drugsList.isEmpty()) {
                    count = count + drugsList.size();
                }
            }
        }
        return count;
    }
    
    /**
     * 检查随访记录是否可完成
     * @param followupid
     * @return
     */
    public boolean checkfollowupcompleted(String followupid)  throws Exception {
        boolean result = true;
    
        List<FollowupContentESDO> eslist = this.esfindFollowUpContestsByFollowupId(followupid);
    
        if (!eslist.isEmpty()) {
            for (FollowupContentESDO followupContentESDO : eslist) {
            
                if("2".equals(followupContentESDO.getFollowup_project())){
                    //判断血压必填
                    if(StringUtils.isBlank(followupContentESDO.getBP_D()) || StringUtils.isBlank(followupContentESDO.getBP_U())){
                        return false;
                    }
                }else if("3".equals(followupContentESDO.getFollowup_project())){
                    //判断血糖必填
                    if(StringUtils.isBlank(followupContentESDO.getBS_FPG()) &&
                            StringUtils.isBlank(followupContentESDO.getNO_BS_FPG()) &&
                            StringUtils.isBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
                        return false;
                    }
                }else if("5".equals(followupContentESDO.getFollowup_project())){
                    //判断评价
                    if(StringUtils.isBlank(followupContentESDO.getDIA_FOLLOWUP_TYPE_CODE()) &&
                            StringUtils.isBlank(followupContentESDO.getHYP_FOLLOWUP_TYPE_CODE())){
                        return false;
                    }
                }else{}
            
            }
        }
        
        return result;
    }
    
//    public boolean checkfollowupcompleted(String followupid)  throws Exception {
//        boolean result = true;
//
//        List<FollowupContentESDO> eslist = this.esfindFollowUpContestsByFollowupId(followupid);
//
//        if (!eslist.isEmpty()) {
//            for (FollowupContentESDO followupContentESDO : eslist) {
//
//                if("2".equals(followupContentESDO.getFollowup_project())){
//                    //判断血压必填
//                    if(StringUtils.isBlank(followupContentESDO.getBP_D()) || StringUtils.isBlank(followupContentESDO.getBP_U())){
//                        return false;
//                    }
//                }else if("3".equals(followupContentESDO.getFollowup_project())){
//                    //判断血糖必填
//                    if(StringUtils.isBlank(followupContentESDO.getBS_FPG()) &&
//                            StringUtils.isBlank(followupContentESDO.getNO_BS_FPG()) &&
//                            StringUtils.isBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
//                        return false;
//                    }
//                }else if("5".equals(followupContentESDO.getFollowup_project())){
//                    //判断评价
//                    if(StringUtils.isBlank(followupContentESDO.getDIA_FOLLOWUP_TYPE_CODE()) &&
//                            StringUtils.isBlank(followupContentESDO.getHYP_FOLLOWUP_TYPE_CODE())){
//                        return false;
//                    }
//                }else{}
//
//            }
//        }
//
//        return result;
//    }
//
    /**
     * 保存随访详情
     * @param followupContentESDO
     * @throws Exception
     * followupContentESDO
     */
    public void esSaveFollowupContentESDAO(FollowupContentESDO followupContentESDO)throws Exception{
        JestClient jestClient = null;
        try {
        
        
            jestClient = elasticFactory.getJestClient();
        
            List<FollowupContentESDO> dataList = new ArrayList<>();
            if(followupContentESDO != null){
                dataList.add(followupContentESDO);
                //删除原有记录
                this.esDeleteFollowUpContent(dataList);
            }
            elastricSearchSave.save(dataList, esIndex, esType);
        
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
    public void updateFollowup(Long id){
        Followup followup = followupDao.findOne(id);
//    public void esSaveFollowupContentESDAO(FollowupContentESDO followupContentESDO)throws Exception{
//        JestClient jestClient = null;
//        try {
//
//
//            jestClient = elasticFactory.getJestClient();
//
//            List<FollowupContentESDO> dataList = new ArrayList<>();
//            if(followupContentESDO != null){
//                dataList.add(followupContentESDO);
//                //删除原有记录
//                this.esDeleteFollowUpContent(dataList);
//            }
//            elastricSearchSave.save(dataList, esIndex, esType);
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//    }
    public void updateFollowup(Long id) {
        Followup followup = followupDao.findById(id).orElse(null);
        followup.setStatus("1");
        followupDao.save(followup);
    }
@ -1522,127 +1541,127 @@ public class FollowUpService  {
    //============================上门访视相关接口================================================
    public Map<String,Object> findFollowupByMonth(String doctor,String patient,String followupClass,String patientName,String startTime,String endTime,String flag,Integer type1,String status)throws Exception{
    public Map<String, Object> findFollowupByMonth(String doctor, String patient, String followupClass, String patientName, String startTime, String endTime, String flag, Integer type1, String status) throws Exception {
        String sqlList = "select  wf.id as id,wf.followup_no as followupNo,wf.followup_date as followupDate,wf.followup_plan_date as followupPlanDate,wf.followup_next_date as followupNextDate," +
                " wf.followup_type as followupType,wf.followup_class as followupClass,wf.followup_manager_status as followupManagerStatus,wf.doctor_code as doctorCode,wf.doctor_name as doctorName," +
                "wf.jwdoctor_code as jwdoctorCode,wf.org_code as orgCode,wf.org_name as orgName,wf.jworg_code as jworgCode,wf.patient_code as patientCode,wf.patient_name as patientName,wf.idcard," +
                "wf.data_from as dataFrom,wf.status,wf.followup_content_phone as followupContentPhone,wf.creater,wf.sign_type as signType,wf.admin_team_code as adminTeamCode,wf.sign_code as signCode," +
                "wf.prescription_code as prescriptionCode,wf.type";
        String sql = " from wlyy_followup wf ";
        sql+= " where 1=1 and wf.status !=0";
        if(!org.apache.commons.lang.StringUtils.isEmpty(doctor)){
            sql+=" and wf.doctor_code = '"+doctor+"'";
        sql += " where 1=1 and wf.status !=0";
        if (!org.apache.commons.lang.StringUtils.isEmpty(doctor)) {
            sql += " and wf.doctor_code = '" + doctor + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(patient)){
            sql+=" and wf.patient_code = '"+patient+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(patient)) {
            sql += " and wf.patient_code = '" + patient + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(followupClass)){
            sql+=" and wf.followup_class = '"+followupClass+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(followupClass)) {
            sql += " and wf.followup_class = '" + followupClass + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(patientName)){
            sql+=" and wf.patient_name like '%"+patientName+"%'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(patientName)) {
            sql += " and wf.patient_name like '%" + patientName + "%'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(startTime)){
            sql+=" and wf.followup_plan_date >='"+startTime+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(startTime)) {
            sql += " and wf.followup_plan_date >='" + startTime + "'";
        }
        if (StringUtils.isNotBlank(status)){
            sql+=" and wf.status ='"+status+"' ";
        if (StringUtils.isNotBlank(status)) {
            sql += " and wf.status ='" + status + "' ";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(endTime)){
        if (!org.apache.commons.lang.StringUtils.isEmpty(endTime)) {
            Date currentTime = DateUtil.strToDate(endTime + " 23:59:59");
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = formatter.format(currentTime);
            sql+=" and wf.followup_plan_date <='"+dateString+"'";
            sql += " and wf.followup_plan_date <='" + dateString + "'";
        }
        if (type1!=null&&type1!=0){
            sql+=" and wf.type ="+type1;
        if (type1 != null && type1 != 0) {
            sql += " and wf.type =" + type1;
        }
        if(flag==null){
            flag="0";
        if (flag == null) {
            flag = "0";
        }
        if(flag.equals("1")&&flag!=null){
            sql+=" and wf.followup_class in(5,6,7,8,9)";
        if (flag.equals("1") && flag != null) {
            sql += " and wf.followup_class in(5,6,7,8,9)";
        }
        if(flag.equals("2")&&flag!=null){
            sql+=" and (wf.followup_class in(1,2,3,4,11,12,13,14,15,16,17,18) or wf.followup_class IS NULL)";
        if (flag.equals("2") && flag != null) {
            sql += " and (wf.followup_class in(1,2,3,4,11,12,13,14,15,16,17,18) or wf.followup_class IS NULL)";
        }
        sql+=" order by wf.followup_plan_date desc";
        List<Followup> followups = jdbcTemplate.query(sqlList+sql,new BeanPropertyRowMapper(Followup.class));
        sql += " order by wf.followup_plan_date desc";
        List<Followup> followups = jdbcTemplate.query(sqlList + sql, new BeanPropertyRowMapper(Followup.class));
        //按时间分组
        Map<String,Object> date = sortFollowupByDate(followups);
        Map<String, Object> date = sortFollowupByDate(followups);
        //统计每一天完成数与计划数目
        if(date!=null&&date.size()>0){
            for(String key : date.keySet()){
        if (date != null && date.size() > 0) {
            for (String key : date.keySet()) {
                //获取一天的数据
                Map<String,Object> d = (Map<String,Object>)date.get(key);
                Map<String, Object> d = (Map<String, Object>) date.get(key);
                // 获取一天随访数据
                List<Followup> dateFollowups = (List<Followup>)d.get("followups");
                List<Followup> dateFollowups = (List<Followup>) d.get("followups");
                //统计一天各项纬度指标
                List<Map<String,Object>> statistics = new ArrayList<>();
                for(String type : FOLLOWUP_TYPE){
                    for(String cls:FOLLOWUP_CLASS ){
                List<Map<String, Object>> statistics = new ArrayList<>();
                for (String type : FOLLOWUP_TYPE) {
                    for (String cls : FOLLOWUP_CLASS) {
                        //统计单条
                        Map<String,Object> fs = sortFollowupList(type,cls,dateFollowups);
                        Integer count = (Integer)fs.get("count");
                        if(count!=0){
                        Map<String, Object> fs = sortFollowupList(type, cls, dateFollowups);
                        Integer count = (Integer) fs.get("count");
                        if (count != 0) {
                            statistics.add(fs);
                        }
                    }
                }
                d.put("statistics",statistics);
                d.put("statistics", statistics);
            }
        }
        return date;
    }
    public Map<String,Object> sortFollowupByDate(List<Followup> followups){
    public Map<String, Object> sortFollowupByDate(List<Followup> followups) {
        //按时间分组
        Map<String,Object> date = new HashedMap();
        if(followups!=null&&followups.size()>0){
        Map<String, Object> date = new HashedMap();
        if (followups != null && followups.size() > 0) {
            Iterator it = followups.iterator();
            while (it.hasNext()){
                Followup followup = (Followup)it.next();
            while (it.hasNext()) {
                Followup followup = (Followup) it.next();
                //1.获取日期分组
                Map<String,Object> dateFollows = (Map<String,Object>)date.get(DateUtil.dateToStr(followup.getFollowupPlanDate(),"yyyy-MM-dd"));
                Map<String, Object> dateFollows = (Map<String, Object>) date.get(DateUtil.dateToStr(followup.getFollowupPlanDate(), "yyyy-MM-dd"));
                //判断随访时间是否已经创建分组
                if(dateFollows!=null&&dateFollows.size()>0){
                if (dateFollows != null && dateFollows.size() > 0) {
                    //同一天时间已经有分组则加入list
                    List<Followup> list = (List<Followup>)dateFollows.get("followups");
                    List<Followup> list = (List<Followup>) dateFollows.get("followups");
                    list.add(followup);
                }else{
                } else {
                    //同一天的时间没有该分组则创建这天的随访计划List
                    Map<String,Object> newdateFollow = new HashedMap();
                    Map<String, Object> newdateFollow = new HashedMap();
                    List<Followup> dateFollowups = new ArrayList<>();
                    dateFollowups.add(followup);
                    newdateFollow.put("followups",dateFollowups);
                    newdateFollow.put("followups", dateFollowups);
                    date.put(DateUtil.dateToStr(followup.getFollowupPlanDate(),"yyyy-MM-dd"),newdateFollow);
                    date.put(DateUtil.dateToStr(followup.getFollowupPlanDate(), "yyyy-MM-dd"), newdateFollow);
                }
            }
        }
        return date;
    }
    public Map<String,Object> sortFollowupList(String followupType,String followupClass,List<Followup> followups){
    public Map<String, Object> sortFollowupList(String followupType, String followupClass, List<Followup> followups) {
        //统计完成数
        Integer compeleCount = 0;
        //总数
        Integer count = 0;
        //迭代数组
        List<Followup> rs = new ArrayList<>();
        if(followups!=null&&followups.size()>0){
        if (followups != null && followups.size() > 0) {
            Iterator it = followups.iterator();
            while (it.hasNext()){
                Followup followup = (Followup)it.next();
            while (it.hasNext()) {
                Followup followup = (Followup) it.next();
                //判断随访类型与类别
                if(followupClass.equals(followup.getFollowupClass())&& followupType.equals(followup.getFollowupType())){
                if (followupClass.equals(followup.getFollowupClass()) && followupType.equals(followup.getFollowupType())) {
                    rs.add(followup);
                    if("1".equals(followup.getStatus())){
                    if ("1".equals(followup.getStatus())) {
                        compeleCount++;
                    }
                    //删除迭代器中元素
@ -1653,23 +1672,24 @@ public class FollowUpService  {
            count = rs.size();
        }
        Map<String,Object> mapFollow =new HashedMap();
        mapFollow.put("followupType",followupType);
        mapFollow.put("followupClass",followupClass);
        mapFollow.put("compeleCount",compeleCount);
        mapFollow.put("count",count);
        Map<String, Object> mapFollow = new HashedMap();
        mapFollow.put("followupType", followupType);
        mapFollow.put("followupClass", followupClass);
        mapFollow.put("compeleCount", compeleCount);
        mapFollow.put("count", count);
        return mapFollow;
    }
    /**
     * 获取随访计划
     *
     * @param doctor
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public List<Followup> findFollowupList(String followIds,String doctor,String patient,String followupClass,String patientName,String startTime,String endTime,String flag,Integer type,String status)throws Exception {
    public List<Followup> findFollowupList(String followIds, String doctor, String patient, String followupClass, String patientName, String startTime, String endTime, String flag, Integer type, String status) throws Exception {
        //1.查找时间段中所有计划中的随访
        String sqlList = "select  wf.id as id,wf.followup_no as followupNo,wf.followup_date as followupDate,wf.followup_plan_date as followupPlanDate,wf.followup_next_date as followupNextDate," +
@ -1679,56 +1699,56 @@ public class FollowUpService  {
                "wf.prescription_code as prescriptionCode,wf.age,wf.sex,wf.mobile,wf.idcard_encrypt AS idcardEncrypt,wf.type" +
                "";
        String sql = " from wlyy_followup wf ";
        sql+= " where 1=1 and wf.status !=0";
        if (StringUtils.isNotBlank(followIds)){
        sql += " where 1=1 and wf.status !=0";
        if (StringUtils.isNotBlank(followIds)) {
            List<String> followId = Arrays.asList(followIds.split(","));
            String wfIds = followId.stream().map(String::valueOf).collect(Collectors.joining("','"));
            sql+=" and wf.id in ('"+wfIds+"') ";
            sql += " and wf.id in ('" + wfIds + "') ";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(doctor)){
            sql+=" and wf.doctor_code = '"+doctor+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(doctor)) {
            sql += " and wf.doctor_code = '" + doctor + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(patient)){
            sql+=" and wf.patient_code = '"+patient+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(patient)) {
            sql += " and wf.patient_code = '" + patient + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(followupClass)){
            sql+=" and wf.followup_class = '"+followupClass+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(followupClass)) {
            sql += " and wf.followup_class = '" + followupClass + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(patientName)){
            sql+=" and wf.patient_name like '%"+patientName+"%'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(patientName)) {
            sql += " and wf.patient_name like '%" + patientName + "%'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(startTime)){
            sql+=" and wf.followup_plan_date >='"+startTime+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(startTime)) {
            sql += " and wf.followup_plan_date >='" + startTime + "'";
        }
        if (StringUtils.isNotBlank(status)){
            sql+=" and wf.status ='"+status+"' ";
        if (StringUtils.isNotBlank(status)) {
            sql += " and wf.status ='" + status + "' ";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(endTime)){
        if (!org.apache.commons.lang.StringUtils.isEmpty(endTime)) {
            Date currentTime = DateUtil.strToDate(endTime + " 23:59:59");
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = formatter.format(currentTime);
            sql+=" and wf.followup_plan_date <='"+dateString+"'";
            sql += " and wf.followup_plan_date <='" + dateString + "'";
        }
        if(flag==null){
            flag="0";
        if (flag == null) {
            flag = "0";
        }
        if (type!=null&&type!=0){
            sql+=" AND  wf.type ="+type;
        if (type != null && type != 0) {
            sql += " AND  wf.type =" + type;
        }
        if(flag.equals("1")&&flag!=null){
            sql+=" and wf.followup_class in(5,6,7,8,9)";
        if (flag.equals("1") && flag != null) {
            sql += " and wf.followup_class in(5,6,7,8,9)";
        }
        if(flag.equals("2")&&flag!=null){
            sql+=" and (wf.followup_class in(1,2,3,4,11,12,13,14,15,16,17,18) or wf.followup_class IS NULL)";
        if (flag.equals("2") && flag != null) {
            sql += " and (wf.followup_class in(1,2,3,4,11,12,13,14,15,16,17,18) or wf.followup_class IS NULL)";
        }
        sql+=" order by wf.followup_plan_date desc";
        List<Followup> followupAll = jdbcTemplate.query(sqlList+sql,new BeanPropertyRowMapper(Followup.class));
        sql += " order by wf.followup_plan_date desc";
        List<Followup> followupAll = jdbcTemplate.query(sqlList + sql, new BeanPropertyRowMapper(Followup.class));
        List<Followup> followups = new ArrayList<>();
        for(Followup followup:followupAll){
            Patient patient1 = patientDao.findByCode(followup.getPatientCode());
        for (Followup followup : followupAll) {
            BasePatientDO patient1 = patientDao.findById(followup.getPatientCode()).orElse(null);
            int age = IdCardUtil.getAgeForIdcard(followup.getIdcard());
            patient1.setAge(age);
            List<Map<String,Object>> map = findPatientLabel(followup.getPatientCode());
            List<Map<String, Object>> map = findPatientLabel(followup.getPatientCode());
            followup.setPatient(patient1);
            followup.setFollowupLabelPatient(map);
            followups.add(followup);
@ -1738,14 +1758,15 @@ public class FollowUpService  {
    /**
     * 获取随访标签列表带居民数
     *
     * @return
     */
    public List<Map<String,Object>> findLabelListWithCount(){
        List<Map<String,Object>> rs = findFollowupLabel();
        if(rs!=null&& rs.size()>0){
            for(Map<String,Object> map:rs){
                String labelCode = (String)map.get("LableCode");
                map.put("count",findPatientFollowLabelCount(labelCode));
    public List<Map<String, Object>> findLabelListWithCount() {
        List<Map<String, Object>> rs = findFollowupLabel();
        if (rs != null && rs.size() > 0) {
            for (Map<String, Object> map : rs) {
                String labelCode = (String) map.get("LableCode");
                map.put("count", findPatientFollowLabelCount(labelCode));
            }
        }
        return rs;
@ -1753,10 +1774,11 @@ public class FollowUpService  {
    /**
     * 获取随访标签列表
     *
     * @return
     */
    public List<Map<String,Object>> findFollowupLabel(){
        String sql=" SELECT " +
    public List<Map<String, Object>> findFollowupLabel() {
        String sql = " SELECT " +
                " l.label_code AS LableCode, " +
                " l.label_name AS labelName " +
                " FROM " +
@ -1770,17 +1792,18 @@ public class FollowUpService  {
    /**
     * 计算随访标签人数
     *
     * @param labelCode
     * @return
     */
    public Long findPatientFollowLabelCount(String labelCode){
        String sql =" SELECT " +
    public Long findPatientFollowLabelCount(String labelCode) {
        String sql = " SELECT " +
                " COUNT(1) AS total " +
                " FROM " +
                " wlyy_followup_label l " +
                " JOIN wlyy_followup_label_patient p ON l.label_code = p.label_code " +
                " WHERE " +
                " l.label_code ='"+labelCode+"'";
                " l.label_code ='" + labelCode + "'";
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
@ -1791,6 +1814,7 @@ public class FollowUpService  {
    /**
     * 获取随访居民
     *
     * @param namekey
     * @param labelCode
     * @param page
@ -1798,7 +1822,7 @@ public class FollowUpService  {
     * @return
     * @throws Exception
     */
    public Map<String,Object> findFollowUpPatient(String namekey,String doctor,String labelCode,Integer page,Integer size)throws Exception{
    public Map<String, Object> findFollowUpPatient(String namekey, String doctor, String labelCode, Integer page, Integer size) throws Exception {
        String totalSql = " SELECT " +
                " DISTINCT p.code " +
                " FROM " +
@ -1807,11 +1831,11 @@ public class FollowUpService  {
                " JOIN wlyy_patient p ON lp.patient = p.code " +
                " WHERE " +
                " 1=1 ";
        if(StringUtils.isNotBlank(namekey)){
            totalSql +=" AND p.name LIKE '%"+namekey+"%'";
        if (StringUtils.isNotBlank(namekey)) {
            totalSql += " AND p.name LIKE '%" + namekey + "%'";
        }
        if(StringUtils.isNotBlank(labelCode)){
            totalSql +=" AND lp.label_code ='"+labelCode+"' ";
        if (StringUtils.isNotBlank(labelCode)) {
            totalSql += " AND lp.label_code ='" + labelCode + "' ";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Integer count = 0;
@ -1832,63 +1856,64 @@ public class FollowUpService  {
                " JOIN wlyy_patient p ON lp.patient = p.code " +
                " WHERE " +
                " 1=1 ";
        if(StringUtils.isNotBlank(namekey)){
            sql +=" AND p.name LIKE '%"+namekey+"%'";
        if (StringUtils.isNotBlank(namekey)) {
            sql += " AND p.name LIKE '%" + namekey + "%'";
        }
        if(StringUtils.isNotBlank(labelCode)){
            sql +=" AND lp.label_code ='"+labelCode+"' ";
        if (StringUtils.isNotBlank(labelCode)) {
            sql += " AND lp.label_code ='" + labelCode + "' ";
        }
        sql +=" limit " + (page-1)*size +"," + size;
        sql += " limit " + (page - 1) * size + "," + size;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        //设置标签
        if(list!=null&&list.size()>0){
            for(Map<String,Object> map:list){
                String patient = (String)map.get("code");
                map.put("labels",findPatientLabel(patient));
        if (list != null && list.size() > 0) {
            for (Map<String, Object> map : list) {
                String patient = (String) map.get("code");
                map.put("labels", findPatientLabel(patient));
            }
        }
        Map<String,Object> rs = new HashedMap();
        rs.put("total",count);
        Map<String, Object> rs = new HashedMap();
        rs.put("total", count);
        //统计随访数目
        rs.put("list",findPatientFollowCount(list,doctor));
        rs.put("list", findPatientFollowCount(list, doctor));
        return rs;
    }
    /**
     * 统计当前医生的居民计划数与完成数
     *
     * @param list
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> findPatientFollowCount(List<Map<String,Object>> list,String doctor)throws Exception{
        if(list!=null&&list.size()>0){
            for(Map<String,Object> map:list){
                String patient = (String)map.get("code");
                List<Followup> followups = followupDao.findAllPatientPlan(patient,doctor);
    public List<Map<String, Object>> findPatientFollowCount(List<Map<String, Object>> list, String doctor) throws Exception {
        if (list != null && list.size() > 0) {
            for (Map<String, Object> map : list) {
                String patient = (String) map.get("code");
                List<Followup> followups = followupDao.findAllPatientPlan(patient, doctor);
                //统计数目
                Integer count = 0;
                Integer compeleCount =0;
                Integer compeleCount = 0;
                if(followups!=null&&followups.size()>0){
                if (followups != null && followups.size() > 0) {
                    count = followups.size();
                    for(Followup followup:followups){
                        if("1".equals(followup.getStatus())){
                    for (Followup followup : followups) {
                        if ("1".equals(followup.getStatus())) {
                            compeleCount++;
                        }
                    }
                    map.put("count",count);
                    map.put("compeleCount",compeleCount);
                    map.put("followups",followups);
                }else{
                    map.put("count",count);
                    map.put("compeleCount",compeleCount);
                    map.put("followups",followups);
                    map.put("count", count);
                    map.put("compeleCount", compeleCount);
                    map.put("followups", followups);
                } else {
                    map.put("count", count);
                    map.put("compeleCount", compeleCount);
                    map.put("followups", followups);
                }
            }
@ -1898,10 +1923,11 @@ public class FollowUpService  {
    /**
     * 获取居民详情
     *
     * @param patient
     * @return
     */
    public Map<String,Object> findPatientInfo(String patient){
    public Map<String, Object> findPatientInfo(String patient) {
        String sql = " SELECT " +
                " p.`name`, " +
                " p.code, " +
@ -1918,9 +1944,9 @@ public class FollowUpService  {
                " JOIN wlyy_followup_label_patient lp ON l.label_code = lp.label_code " +
                " JOIN wlyy_patient p ON lp.patient = p.code " +
                " WHERE " +
                " p.code = '"+patient+ "'";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        if(rs!=null&&rs.size()>0){
                " p.code = '" + patient + "'";
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
        if (rs != null && rs.size() > 0) {
            return rs.get(0);
        }
        return null;
@ -1928,64 +1954,66 @@ public class FollowUpService  {
    /**
     * 获取居民随访列表
     *
     * @param patient
     * @param doctor
     * @return
     * @throws Exception
     */
    public List<Followup> findPatientFollowList(String patient,String doctor)throws Exception{
        List<Followup> followups = followupDao.findAllPatientPlan(patient,doctor);
    public List<Followup> findPatientFollowList(String patient, String doctor) throws Exception {
        List<Followup> followups = followupDao.findAllPatientPlan(patient, doctor);
        return followups;
    }
    /**
     * 获取居民随访列表
     *
     * @param patient
     * @param doctor
     * @return
     * @throws Exception
     */
    public List<Followup> findPatientFollowListByCondition(String patient,String doctor,String followupType,String followupClass,String type,
                                                           String status,String startDate,String endDate)throws Exception{
    public List<Followup> findPatientFollowListByCondition(String patient, String doctor, String followupType, String followupClass, String type,
                                                           String status, String startDate, String endDate) throws Exception {
        StringBuilder sql = new StringBuilder("select * from wlyy_followup a where 1=1 ");
        if (StringUtils.isNotBlank(patient)){
            sql.append(" and a.patient_code ='"+patient+"' ");
        if (StringUtils.isNotBlank(patient)) {
            sql.append(" and a.patient_code ='" + patient + "' ");
        }
        if (StringUtils.isNotBlank(doctor)){
            sql.append(" and a.doctor_code ='"+doctor+"' ");
        if (StringUtils.isNotBlank(doctor)) {
            sql.append(" and a.doctor_code ='" + doctor + "' ");
        }
        if (StringUtils.isNotBlank(followupType)){
            sql.append(" and a.followup_type ='"+followupType+"' ");
        if (StringUtils.isNotBlank(followupType)) {
            sql.append(" and a.followup_type ='" + followupType + "' ");
        }
        if (StringUtils.isNotBlank(followupClass)){
            sql.append(" and a.followup_class in("+followupClass+") ");
        if (StringUtils.isNotBlank(followupClass)) {
            sql.append(" and a.followup_class in(" + followupClass + ") ");
        }
        if (StringUtils.isNotBlank(type)){
            sql.append(" and a.type ='"+type+"' ");
        if (StringUtils.isNotBlank(type)) {
            sql.append(" and a.type ='" + type + "' ");
        }
        if (StringUtils.isNotBlank(status)){
            sql.append(" and a.status ='"+status+"' ");
        if (StringUtils.isNotBlank(status)) {
            sql.append(" and a.status ='" + status + "' ");
        }
        if (StringUtils.isNotBlank(startDate)){
            sql.append(" and a.followup_date >='"+startDate+"' ");
        if (StringUtils.isNotBlank(startDate)) {
            sql.append(" and a.followup_date >='" + startDate + "' ");
        }
        if (StringUtils.isNotBlank(endDate)){
            sql.append(" and a.followup_date <='"+endDate+"' ");
        if (StringUtils.isNotBlank(endDate)) {
            sql.append(" and a.followup_date <='" + endDate + "' ");
        }
        sql.append("order by a.followup_date desc");
        List<Followup> followups = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper<>(Followup.class));
        List<Followup> followups = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(Followup.class));
        for (Followup tmp:followups){
        for (Followup tmp : followups) {
            //随访方式
            sql = new StringBuilder("select `value` from system_dict where dict_name='FOLLOWUP_WAY_DICT'  and `code` ='"+tmp.getFollowupType()+"'");
            tmp.setFollowupTypeName(jdbcTemplate.queryForObject(sql.toString(),String.class));
            sql = new StringBuilder("select `value` from system_dict where dict_name='FOLLOWUP_WAY_DICT'  and `code` ='" + tmp.getFollowupType() + "'");
            tmp.setFollowupTypeName(jdbcTemplate.queryForObject(sql.toString(), String.class));
            //随访类别
            String followupClassTmp = tmp.getFollowupClass();
            sql =new StringBuilder("select GROUP_CONCAT(\n" +
            sql = new StringBuilder("select GROUP_CONCAT(\n" +
                    "  `value` SEPARATOR ','\n" +
                    " ) AS followupClassName from system_dict where dict_name='FOLLOWUP_CLASS_DICT' ");
            sql.append(" and  `code` in ('").append(followupClassTmp.replace(",","','")).append("')");
            tmp.setFollowupClassName(jdbcTemplate.queryForObject(sql.toString(),String.class));
            sql.append(" and  `code` in ('").append(followupClassTmp.replace(",", "','")).append("')");
            tmp.setFollowupClassName(jdbcTemplate.queryForObject(sql.toString(), String.class));
        }
        return followups;
@ -1994,15 +2022,16 @@ public class FollowUpService  {
    /**
     * 创建随访
     *
     * @param jsonFollowup
     * @return
     * @throws Exception
     */
    public Followup saveFollowup(String jsonFollowup)throws Exception{
        Followup followup =  objectMapper.readValue(jsonFollowup,Followup.class);
    public Followup saveFollowup(String jsonFollowup) throws Exception {
        Followup followup = objectMapper.readValue(jsonFollowup, Followup.class);
        //访视添加居民信息
        if(StringUtils.isBlank(followup.getPatientName()) && StringUtils.isBlank(followup.getIdcard())) {
            Patient p = patientDao.findByCode(followup.getPatientCode());
        if (StringUtils.isBlank(followup.getPatientName()) && StringUtils.isBlank(followup.getIdcard())) {
            BasePatientDO p = patientDao.findById(followup.getPatientCode()).orElse(null);
            followup.setPatientName(p.getName());
            followup.setIdcard(p.getIdcard());
@ -2012,14 +2041,14 @@ public class FollowUpService  {
                followup.setAdminTeamCode(signFamily.getAdminTeamId());
            }
        }
        List<Date> dateList = followupDao.findFollowupDateList(followup.getDoctorCode(),followup.getPatientCode());
        List<Date> dateList = followupDao.findFollowupDateList(followup.getDoctorCode(), followup.getPatientCode());
        Date prior = null;
        for (Date date : dateList) {
            try {
                if (prior == null) {
                    prior = date;
                } else {
                    if(prior.after(date)) {
                    if (prior.after(date)) {
                        prior = date;
                    }
                }
@ -2046,16 +2075,16 @@ public class FollowUpService  {
                    String two = sdf.format(followupList.get(1).getFollowupDate());
                    Date twoDate = df.parse(two);
                    if (followupDate.getTime() >= twoDate.getTime()) {
                        throw new ServiceException("第一次访视时间不能晚于第二次访视时间!");
                        throw new RuntimeException("第一次访视时间不能晚于第二次访视时间!");
                    }
                } else if (priorDate.getTime() >= followupDate.getTime()) {
                    throw new ServiceException("随访时间不能早于第一次随访时间!");
                    throw new RuntimeException("随访时间不能早于第一次随访时间!");
                } else {
                    return followupDao.save(followup);
                }
            } else if (priorDate.getTime() >= followupDate.getTime()) {
                throw new ServiceException("随访时间不能早于第一次随访时间!");
                throw new RuntimeException("随访时间不能早于第一次随访时间!");
            } else {
                return followupDao.save(followup);
            }
@ -2063,27 +2092,28 @@ public class FollowUpService  {
        return followupDao.save(followup);
    }
    public Followup delFollowup(Long followupId)throws Exception{
        Followup followup = followupDao.findOne(followupId);
        List<Followup> followupList = followupDao.findFollowupList(followup.getDoctorCode(),followup.getPatientCode());
        if(followupList.size()>=2){
            if(followupList.get(1)!=null&&followupList.get(1).getStatus().equals("1")){
                throw new ServiceException("当前状态不可删除!");
    public Followup delFollowup(Long followupId) throws Exception {
        Followup followup = followupDao.findById(followupId).orElse(null);
        List<Followup> followupList = followupDao.findFollowupList(followup.getDoctorCode(), followup.getPatientCode());
        if (followupList.size() >= 2) {
            if (followupList.get(1) != null && followupList.get(1).getStatus().equals("1")) {
                throw new RuntimeException("当前状态不可删除!");
            }
        }
        followupDao.delete(followupId);
        followupDao.deleteById(followupId);
        return followup;
//        return true;
    }
    /**
     * 获取随访详情
     *
     * @param followupId
     * @return
     */
    public Followup findFollowupInfo(Long followupId){
        Followup followup = followupDao.findOne(followupId);
        Patient patient = patientDao.findByCode(followup.getPatientCode());
    public Followup findFollowupInfo(Long followupId) {
        Followup followup = followupDao.findById(followupId).orElse(null);
        BasePatientDO patient = patientDao.findById(followup.getPatientCode()).orElse(null);
        followup.setPhoto(patient.getPhoto());
        followup.setPatient(patient);
        return followup;
@ -2091,27 +2121,28 @@ public class FollowUpService  {
    /**
     * 随访签到
     *
     * @param jsonSign
     * @return
     * @throws Exception
     */
    public Boolean saveFollowupSign(String jsonSign)throws Exception{
        FollowupSign followupSign = objectMapper.readValue(jsonSign,FollowupSign.class);
        List<FollowupSign> sign = followupSignDao.findByFollowupIdAndDel(followupSign.getFollowupId(),0);
        if(sign!=null&&sign.size()>0){
    public Boolean saveFollowupSign(String jsonSign) throws Exception {
        FollowupSign followupSign = objectMapper.readValue(jsonSign, FollowupSign.class);
        List<FollowupSign> sign = followupSignDao.findByFollowupIdAndDel(followupSign.getFollowupId(), 0);
        if (sign != null && sign.size() > 0) {
            //做更新操作
            for(FollowupSign s:sign){
            for (FollowupSign s : sign) {
                s.setDel(1);
            }
            followupSignDao.save(sign);
        }else{
            followupSignDao.saveAll(sign);
        } else {
            //修改随访状态为进行中
            Followup followup = followupDao.findOne(followupSign.getFollowupId());
            Followup followup = followupDao.findById(followupSign.getFollowupId()).orElse(null);
            followup.setStatus("3");
        }
        //新增更新随访状态
        followupSign.setCode(getCode());
        followupSign.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
        followupSign.setCreateTime(new Date());
        followupSign.setDel(0);
        followupSignDao.save(followupSign);
@ -2121,20 +2152,21 @@ public class FollowUpService  {
    /**
     * 修改签到记录
     *
     * @param jsonSign
     * @return
     * @throws Exception
     */
    public Boolean updateFollowupSign(String jsonSign)throws Exception{
    public Boolean updateFollowupSign(String jsonSign) throws Exception {
        //重新签到
        FollowupSign followupSign = objectMapper.readValue(jsonSign,FollowupSign.class);
        FollowupSign sign = followupSignDao.findOne(followupSign.getId());
        FollowupSign followupSign = objectMapper.readValue(jsonSign, FollowupSign.class);
        FollowupSign sign = followupSignDao.findById(followupSign.getId()).orElse(null);
        sign.setDel(1);
        followupSignDao.save(sign);
        FollowupSign newSign = new FollowupSign();
        newSign.setCode(getCode());
        newSign.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
        newSign.setFollowupId(sign.getFollowupId());
        newSign.setAddress(sign.getAddress());
        newSign.setType(sign.getType());
@ -2152,25 +2184,26 @@ public class FollowUpService  {
    /**
     * 门牌地址解析
     *
     * @param url
     * @return
     * @throws Exception
     */
    public String urlAnalysis(String url)throws Exception{
        url.replace("http://www.fjadd.com/addr?","http://www.fjadd.com/shhyy/addr_list.jsp?showtp=1&system");
    public String urlAnalysis(String url) throws Exception {
        url.replace("http://www.fjadd.com/addr?", "http://www.fjadd.com/shhyy/addr_list.jsp?showtp=1&system");
        Document doc = Jsoup.connect(url).get();
        String html = doc.toString();
        int start = html.indexOf("href=\"");
        int end = html.indexOf("\"}");
        int ed = url.indexOf("com");
        String ym = url.substring(0,ed+3);
        String path = html.substring(start+6,end);
        String ym = url.substring(0, ed + 3);
        String path = html.substring(start + 6, end);
        Document d = Jsoup.connect(ym+path).get();
        String address = d.select("div.dzksfd1_lz2").eq(0).text()+d.select("div.dzksfd1_lz2").eq(1).text();
        Document d = Jsoup.connect(ym + path).get();
        String address = d.select("div.dzksfd1_lz2").eq(0).text() + d.select("div.dzksfd1_lz2").eq(1).text();
        logger.info("url:"+url+" path:"+ym+path+" adress:"+address);
        logger.info("url:" + url + " path:" + ym + path + " adress:" + address);
        return address;
    }
@ -2179,88 +2212,89 @@ public class FollowUpService  {
     * @param followupId
     * @return
     */
    public Boolean updateFollowStatus(Long followupId,Integer isFlag)throws Exception{
        Followup followup = followupDao.findOne(followupId);
        followup.setStatus("1");
        followupDao.save(followup);
        BusinessMapping businessMapping = new BusinessMapping();
        if (followup.getFollowupClass().equalsIgnoreCase("6")){
            businessMapping.setBusinessType(1);
        }else if (followup.getFollowupClass().equalsIgnoreCase("5")){
            businessMapping.setBusinessType(2);
        }else if (followup.getFollowupClass().equalsIgnoreCase("9")){
            if (isFlag!=null){
                if (isFlag==0){
                    businessMapping.setBusinessType(5);
                }else if (isFlag==1){
                    businessMapping.setBusinessType(6);
                }
            }
        }else if (followup.getFollowupClass().equalsIgnoreCase("8")){
            businessMapping.setBusinessType(3);
            businessMapping.setBusinessId(followupId);
            businessMapping.setNeedUpload(1);
            businessMapping.setCode(getCode());
            businessMapping.setCreateTime(new Date());
            businessMappingDao.save(businessMapping);
        }else if (followup.getFollowupClass().equalsIgnoreCase("8")){
            businessMapping.setBusinessType(4);
        }
        businessMapping.setBusinessId(followupId);
        businessMapping.setNeedUpload(1);
        businessMapping.setCode(getCode());
        businessMapping.setCreateTime(new Date());
        businessMappingDao.save(businessMapping);
        return true;
    }
//    public Boolean updateFollowStatus(Long followupId,Integer isFlag)throws Exception{
//        Followup followup = followupDao.findOne(followupId);
//        followup.setStatus("1");
//        followupDao.save(followup);
//        BusinessMapping businessMapping = new BusinessMapping();
//        if (followup.getFollowupClass().equalsIgnoreCase("6")){
//            businessMapping.setBusinessType(1);
//        }else if (followup.getFollowupClass().equalsIgnoreCase("5")){
//            businessMapping.setBusinessType(2);
//        }else if (followup.getFollowupClass().equalsIgnoreCase("9")){
//            if (isFlag!=null){
//                if (isFlag==0){
//                    businessMapping.setBusinessType(5);
//                }else if (isFlag==1){
//                    businessMapping.setBusinessType(6);
//                }
//            }
//        }else if (followup.getFollowupClass().equalsIgnoreCase("8")){
//            businessMapping.setBusinessType(3);
//            businessMapping.setBusinessId(followupId);
//            businessMapping.setNeedUpload(1);
//            businessMapping.setCode(getCode());
//            businessMapping.setCreateTime(new Date());
//            businessMappingDao.save(businessMapping);
//        }else if (followup.getFollowupClass().equalsIgnoreCase("8")){
//            businessMapping.setBusinessType(4);
//        }
//        businessMapping.setBusinessId(followupId);
//        businessMapping.setNeedUpload(1);
//        businessMapping.setCode(getCode());
//        businessMapping.setCreateTime(new Date());
//        businessMappingDao.save(businessMapping);
//        return true;
//    }
    /**
     * 签到详细
     *
     * @param followupId
     * @return
     */
    public FollowupSign findByFollowupId(Long followupId){
        List<FollowupSign> sign = followupSignDao.findByFollowupIdAndDel(followupId,0);
        if(sign!=null&&sign.size()>0){
    public FollowupSign findByFollowupId(Long followupId) {
        List<FollowupSign> sign = followupSignDao.findByFollowupIdAndDel(followupId, 0);
        if (sign != null && sign.size() > 0) {
            return sign.get(0);
        }
        return null;
    }
    public List<Map<String,Object>> findPatientLabel(String patient){
        String sql ="SELECT " +
    public List<Map<String, Object>> findPatientLabel(String patient) {
        String sql = "SELECT " +
                " pl.label_code AS labelCode, " +
                " pl.label_name AS labelName " +
                " FROM " +
                " wlyy_followup_label_patient pl " +
                " WHERE " +
                " pl.patient = '"+patient+"'";
        List<Map<String,Object>> label = jdbcTemplate.queryForList(sql);
                " pl.patient = '" + patient + "'";
        List<Map<String, Object>> label = jdbcTemplate.queryForList(sql);
        return label;
    }
    public Boolean isFirstTimeFollowup(String doctor,String patient,String followupClass,Integer followupId){
    public Boolean isFirstTimeFollowup(String doctor, String patient, String followupClass, Integer followupId) {
        //按时间升序取第一条
        String sql =" SELECT " +
        String sql = " SELECT " +
                " f.id, " +
                " f.create_time " +
                " FROM " +
                " wlyy_followup f " +
                " WHERE " +
//                " f.doctor_code = '"+doctor+"' AND " +
                "  f.patient_code = '"+patient+"' " +
                " AND f.followup_class = '"+followupClass+"' and f.status != 0 " +
                "  f.patient_code = '" + patient + "' " +
                " AND f.followup_class = '" + followupClass + "' and f.status != 0 " +
                " ORDER BY " +
                " f.followup_date " +
                " ASC " +
                " LIMIT 0,1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            int id = (Integer)list.get(0).get("id");
        if (list != null && list.size() > 0) {
            int id = (Integer) list.get(0).get("id");
            //如果与第一条的id不等,则非第一次
            if(!(id==followupId)){
            if (!(id == followupId)) {
                return false;
            }
        }
@ -2276,81 +2310,81 @@ public class FollowUpService  {
    /**
     * ES获取表单项目数据
     */
    public FollowupContentESDO esGetFollowupProjectDataList(String id, String followupProject) throws Exception {
        JestClient jestClient = null;
        FollowupContentESDO followupContentESDO = null;
        try {
            //根据随访ID、分类ID获取随访记录详情
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            if(StringUtils.isNotBlank(followupProject)) {
                searchSourceBuilder.query(
                        new BoolQueryBuilder()
                                .must(QueryBuilders.matchQuery("followup_id", id))
                                .must(QueryBuilders.matchQuery("followup_project", followupProject))
                );
            }else {
                searchSourceBuilder.query(
                        new BoolQueryBuilder()
                                .must(QueryBuilders.matchQuery("followup_id", id))
                                .mustNot(QueryBuilders.existsQuery("followup_project"))
                );
            }
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDO;
    }
    public void delFollowupProjectData(String followuoId,String followupProject,String all){
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", followuoId))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            if("1".equals(all)){
                List<FollowupContentESDO> followupContentESDOS = result.getSourceAsObjectList(FollowupContentESDO.class);
                List<FollowupContentESDO> dataList = new ArrayList<>();
                if(followupContentESDOS != null){
                    dataList.addAll(followupContentESDOS);
                    //删除原有记录
                    this.esDeleteFollowUpContent(dataList);
                }
            }else {
                FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
                List<FollowupContentESDO> dataList = new ArrayList<>();
                if(followupContentESDO != null){
                    dataList.add(followupContentESDO);
                    //删除原有记录
                    this.esDeleteFollowUpContent(dataList);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
//    public FollowupContentESDO esGetFollowupProjectDataList(String id, String followupProject) throws Exception {
//        JestClient jestClient = null;
//        FollowupContentESDO followupContentESDO = null;
//        try {
//            //根据随访ID、分类ID获取随访记录详情
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            if(StringUtils.isNotBlank(followupProject)) {
//                searchSourceBuilder.query(
//                        new BoolQueryBuilder()
//                                .must(QueryBuilders.matchQuery("followup_id", id))
//                                .must(QueryBuilders.matchQuery("followup_project", followupProject))
//                );
//            }else {
//                searchSourceBuilder.query(
//                        new BoolQueryBuilder()
//                                .must(QueryBuilders.matchQuery("followup_id", id))
//                                .mustNot(QueryBuilders.existsQuery("followup_project"))
//                );
//            }
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//        return followupContentESDO;
//    }
//    public void delFollowupProjectData(String followuoId,String followupProject,String all){
//        JestClient jestClient = null;
//        try {
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", followuoId))
//                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
//
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            if("1".equals(all)){
//                List<FollowupContentESDO> followupContentESDOS = result.getSourceAsObjectList(FollowupContentESDO.class);
//                List<FollowupContentESDO> dataList = new ArrayList<>();
//                if(followupContentESDOS != null){
//                    dataList.addAll(followupContentESDOS);
//                    //删除原有记录
//                    this.esDeleteFollowUpContent(dataList);
//                }
//            }else {
//                FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
//                List<FollowupContentESDO> dataList = new ArrayList<>();
//                if(followupContentESDO != null){
//                    dataList.add(followupContentESDO);
//                    //删除原有记录
//                    this.esDeleteFollowUpContent(dataList);
//                }
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//    }
    /**
     * ES 保存随访记录详情
@ -2358,1413 +2392,1464 @@ public class FollowUpService  {
     * @author huangwenjie
     * @date 2017/11/1 14:57
     */
    @Transactional
    public void saveAllFollowupProjectData(String id, String followupProjectData) throws Exception {
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<FollowupContentESDO> followupContentESDOS = result.getSourceAsObjectList(FollowupContentESDO.class);
            List<FollowupContentESDO> dataList = new ArrayList<>();
            if(followupContentESDOS != null){
                dataList.addAll(followupContentESDOS);
                //删除原有记录
                this.esDeleteFollowUpContent(dataList);
            }
            //保存新的随访详情信息
            List<FollowupContentESDO> newdatalist = new ArrayList<>();
            FollowupContentESDO followupContentESDO = new FollowupContentESDO();
            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
            followupContentESDO.setFollowup_id(id);
            followupContentESDO.setCreate_time(new Date());
            newdatalist.add(followupContentESDO);
            elastricSearchSave.save(newdatalist, esIndex, esType);
            //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
            Followup followup = followupDao.findOne(Long.valueOf(id));
            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);
            }
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
    public File writeWordFile(List<Long> orderId, HttpServletResponse response) throws Exception {
        String zipFileName = "入户访视详情";
        long time = System.currentTimeMillis();
        String exportConclusionList = time+"exportList";
        String path = this.getClass().getResource("/").getPath() + exportConclusionList;
        File file = new File(path);
        // 删除文件夹、文件
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        System.out.println("创建文件夹时间:"+sdf.format(new Date()));
        if (file.exists()) {
            if (file != null){
                DoorOrderService.deleteFolder(file);
                file.mkdir();
            }else {
                file.delete();
                file.mkdir();
            }
        }else {
            file.mkdir();
        }
        int j =1;
        long doorStart = System.currentTimeMillis();
        long feeDetailStart = System.currentTimeMillis();
        long feeDetailEnd = System.currentTimeMillis();
        System.out.println("feeDetail用时:"+(feeDetailEnd-feeDetailStart)/1000);
        System.out.println("开始生成Word:"+sdf.format(new Date()));
        for (int i = 0; i < orderId.size(); i++) {
            try {
                Long followId = orderId.get(i);
                Followup followup = followupDao.findOne(followId);
                if (null==followup){
                    continue;
                }
                if (!"8".equals(followup.getFollowupClass())){
                    continue;
                }
                String fileName = "入户访视详情_"+followup.getPatientName()+"_"+followId+".doc";;
                j = j + 1;
//            fileName = URLEncoder.encode(fileName, "utf-8");
                fileName = java.net.URLEncoder.encode(fileName,"UTF-8");
                fileName = java.net.URLDecoder.decode(fileName,"UTF-8");
//            response.setHeader("Content-Disposition", "attachment;filename=" + new String( fileName.getBytes(), "iso-8859-1"));
                response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
                String pathName = this.getClass().getResource("/").getPath() + "health_examination.mht";
                Document doc = Jsoup.parse(new File(pathName), "UTF-8");
                String html = this.handleHealthExamData(doc, orderId.get(i),followup);
                if (StringUtils.isNotBlank(html)){
                    BufferedWriter bw = new BufferedWriter(new FileWriter(path+"/"+fileName));//创建的文件
                    bw.write(html);
                    bw.close();
                    File zipFile = new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
                    if (zipFile.exists()) {
                        zipFile.delete();
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
                continue;
            }
        }
        System.out.println("Word生成结束:"+sdf.format(new Date()));
        // 打包文件夹
        if (FileUtil.fileToZip(path, path.replace(exportConclusionList, ""), zipFileName)) {
            return new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
        } else {
            return null;
        }
    }
    public String handleHealthExamData(Document doc, Long orderId, Followup followup) throws Exception {
        String html = doc.toString();
        //根据随访ID获取随访记录详情
        OlderPeopleHealthCheckRecordES olderPeopleHealthCheckRecord = visitDetailService.getOlderPeopleHealthCheckRecord(orderId+"",null);
        if (null==olderPeopleHealthCheckRecord){
            return null;
        }
        html = html.replace("${patientName}", null==olderPeopleHealthCheckRecord.getName()?"":olderPeopleHealthCheckRecord.getName());
        html = html.replace("${idcard}", null==olderPeopleHealthCheckRecord.getIdcard()?"":olderPeopleHealthCheckRecord.getIdcard());
        html = html.replace("${number}", null==olderPeopleHealthCheckRecord.getNumber()?"":olderPeopleHealthCheckRecord.getNumber());
        html = html.replace("${duty}", null==olderPeopleHealthCheckRecord.getDuty()?" ":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getDuty()));
        html = html.replace("${responsibility_doctor_name}",olderPeopleHealthCheckRecord.getResponsibility_doctor_name());
        if (null==olderPeopleHealthCheckRecord.getSymptom()){
            html = html.replace("${symptom}"," ");
        }else {
            StringBuilder symptomName = new StringBuilder();
            String symptom =  olderPeopleHealthCheckRecord.getSymptom();
            String[] symptoms = symptom.split(",");
            for (String tmp:symptoms){
                symptomName.append(getSymptomName(tmp));
            }
            html = html.replace("${symptom}",symptomName.toString());
        }
        html = html.replace("${symptom_other}",olderPeopleHealthCheckRecord.getSymptom_other());
        /**一般状况**/
        html = html.replace("${temperature}",null==olderPeopleHealthCheckRecord.getTemperature()?" ":olderPeopleHealthCheckRecord.getTemperature()+"");
        html = html.replace("${pulse_frequency}",olderPeopleHealthCheckRecord.getPulse_frequency());
        html = html.replace("${breath_frequency}",olderPeopleHealthCheckRecord.getBreath_frequency());
        html = html.replace("${blood_pressure_left_low}",null==olderPeopleHealthCheckRecord.getBlood_pressure_left_low()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_left_low()+"");
        html = html.replace("${blood_pressure_left_high}",null==olderPeopleHealthCheckRecord.getBlood_pressure_left_high()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_left_high()+"");
        html = html.replace("${blood_pressure_right_low}",null==olderPeopleHealthCheckRecord.getBlood_pressure_right_low()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_right_low()+"");
        html = html.replace("${blood_pressure_right_high}",null==olderPeopleHealthCheckRecord.getBlood_pressure_right_high()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_right_high()+"");
        html = html.replace("${height}",null==olderPeopleHealthCheckRecord.getHeight()?" ":olderPeopleHealthCheckRecord.getHeight()+"");
        html = html.replace("${weight}",null==olderPeopleHealthCheckRecord.getWeight()?" ":olderPeopleHealthCheckRecord.getWeight()+"");
        html = html.replace("${waistline}",null==olderPeopleHealthCheckRecord.getWaistline()?" ":olderPeopleHealthCheckRecord.getWaistline()+"");
        html = html.replace("${BMI}",null==olderPeopleHealthCheckRecord.getBMI()?" ":olderPeopleHealthCheckRecord.getBMI()+"");
        if (null==olderPeopleHealthCheckRecord.getHealth_status()){
            html = html.replace("${health_status}"," ");
        }else {
            Integer health_status = olderPeopleHealthCheckRecord.getHealth_status();
            switch (health_status){
                case 1:html = html.replace("${health_status}","满意");break;
                case 2:html = html.replace("${health_status}","基本满意");break;
                case 3:html = html.replace("${health_status}","说不清");break;
                case 4:html = html.replace("${health_status}","不太满意");break;
                case 5:html = html.replace("${health_status}","不满意");break;
                default:html = html.replace("${health_status}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getSelfcare_ability()){
            html = html.replace("${selfcare_ability}"," ");
        }else {
            Integer selfcare_ability = olderPeopleHealthCheckRecord.getSelfcare_ability();
            switch (selfcare_ability){
                case 1:html = html.replace("${selfcare_ability}","可自理(0~3)分");break;
                case 2:html = html.replace("${selfcare_ability}","轻度依赖(4~8)分");break;
                case 3:html = html.replace("${selfcare_ability}","中度依赖(9~18)分");break;
                case 4:html = html.replace("${selfcare_ability}","不能自理(≥19)分");break;
                default:html = html.replace("${selfcare_ability}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getCognitive_function()){
            html = html.replace("${cognitive_function}"," ");
        }else {
            Integer cognitiveFunction = olderPeopleHealthCheckRecord.getCognitive_function();
            switch (cognitiveFunction){
                case 1:html = html.replace("${cognitive_function}","粗筛阴性");break;
                case 2:html = html.replace("${cognitive_function}","粗筛阳性");break;
                default:html = html.replace("${cognitive_function}"," ");break;
            }
        }
        html = html.replace("${cognitive_function_score}",null==olderPeopleHealthCheckRecord.getCognitive_function_score()?" ":olderPeopleHealthCheckRecord.getCognitive_function_score()+"");
        if (null==olderPeopleHealthCheckRecord.getEmotional_state()){
            html = html.replace("${emotional_state}"," ");
        }else {
            Integer emotionalState = olderPeopleHealthCheckRecord.getEmotional_state();
            switch (emotionalState){
                case 1:html = html.replace("${emotional_state}","粗筛阴性");break;
                case 2:html = html.replace("${emotional_state}","粗筛阳性");break;
                default:html = html.replace("${emotional_state}"," ");break;
            }
        }
        html = html.replace("${emotional_state_score}",null==olderPeopleHealthCheckRecord.getEmotional_state_score()?" ":olderPeopleHealthCheckRecord.getEmotional_state_score()+"");
        /**体育锻炼**/
        if (null==olderPeopleHealthCheckRecord.getExercise_frequency()){
            html = html.replace("${exercise_frequency}"," ");
        }else {
            Integer exerciseFrequency = olderPeopleHealthCheckRecord.getExercise_frequency();
            switch (exerciseFrequency){
                case 1:html = html.replace("${exercise_frequency}","每天");break;
                case 2:html = html.replace("${exercise_frequency}","每周一次以上");break;
                case 3:html = html.replace("${exercise_frequency}","偶尔");break;
                case 4:html = html.replace("${exercise_frequency}","不锻炼");break;
                default:html = html.replace("${exercise_frequency}"," ");break;
            }
        }
        html = html.replace("${exercise_time}",null==olderPeopleHealthCheckRecord.getExercise_time()?" ":olderPeopleHealthCheckRecord.getExercise_time()+"");
        html = html.replace("${sustain_exercise_time}",null==olderPeopleHealthCheckRecord.getSustain_exercise_time()?" ":olderPeopleHealthCheckRecord.getSustain_exercise_time()+"");
        html = html.replace("${exercise_type}",null==olderPeopleHealthCheckRecord.getExercise_type()?" ":olderPeopleHealthCheckRecord.getExercise_type()+"");
        /**饮食习惯**/
        if (null==olderPeopleHealthCheckRecord.getDietary_habit()){
            html = html.replace("${dietary_habit}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getDietary_habit();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="荤素均衡 ";break;
                    case "2":valueStrTmp+="荤食为主 ";break;
                    case "3":valueStrTmp+="素食为主 ";break;
                    case "4":valueStrTmp+="嗜盐 ";break;
                    case "5":valueStrTmp+="嗜油 ";break;
                    case "6":valueStrTmp+="嗜糖 ";break;
                }
            }
            html = html.replace("${dietary_habit}",valueStrTmp);
        }
        /**吸烟情况**/
        if (null==olderPeopleHealthCheckRecord.getSmoking_state()){
            html = html.replace("${smoking_state}"," ");
        }else {
            Integer smokingState = olderPeopleHealthCheckRecord.getSmoking_state();
            switch (smokingState){
                case 1:html = html.replace("${smoking_state}","从不吸烟");break;
                case 2:html = html.replace("${smoking_state}","已戒烟");break;
                case 3:html = html.replace("${smoking_state}","吸烟");break;
                default:html = html.replace("${smoking_state}"," ");break;
            }
        }
        html = html.replace("${smoking_daily}",null==olderPeopleHealthCheckRecord.getSmoking_daily()?" ":olderPeopleHealthCheckRecord.getSmoking_daily()+"");
        html = html.replace("${start_smoking_age}",null==olderPeopleHealthCheckRecord.getStart_smoking_age()?" ":olderPeopleHealthCheckRecord.getStart_smoking_age()+"");
        html = html.replace("${stop_smoking_age}",null==olderPeopleHealthCheckRecord.getStop_smoking_age()?" ":olderPeopleHealthCheckRecord.getStop_smoking_age()+"");
        /**饮酒情况**/
        if (null==olderPeopleHealthCheckRecord.getDrinking_frequency()){
            html = html.replace("${drinking_frequency}"," ");
        }else {
            Integer drinkingFrequency = olderPeopleHealthCheckRecord.getDrinking_frequency();
            switch (drinkingFrequency){
                case 1:html = html.replace("${drinking_frequency}","从不");break;
                case 2:html = html.replace("${drinking_frequency}","偶尔");break;
                case 3:html = html.replace("${drinking_frequency}","经常");break;
                case 4:html = html.replace("${drinking_frequency}","每天");break;
                default:html = html.replace("${drinking_frequency}"," ");break;
            }
        }
        html = html.replace("${drinking_daily}",null==olderPeopleHealthCheckRecord.getDrinking_daily()?" ":olderPeopleHealthCheckRecord.getDrinking_daily()+"");
        if (null==olderPeopleHealthCheckRecord.getIs_stop_drinking()){
            html = html.replace("${is_stop_drinking}"," ");
        }else {
            Integer isStopDrinking = olderPeopleHealthCheckRecord.getIs_stop_drinking();
            switch (isStopDrinking){
                case 1:html = html.replace("${is_stop_drinking}","否");break;
                case 2:html = html.replace("${is_stop_drinking}","是");break;
                default:html = html.replace("${is_stop_drinking}"," ");break;
            }
        }
        html = html.replace("${stop_drinking_age}",null==olderPeopleHealthCheckRecord.getStop_drinking_age()?" ":olderPeopleHealthCheckRecord.getStop_drinking_age()+"");
        html = html.replace("${start_drinking_age}",null==olderPeopleHealthCheckRecord.getStart_drinking_age()?" ":olderPeopleHealthCheckRecord.getStart_drinking_age()+"");
        if (null==olderPeopleHealthCheckRecord.getDrunkenness()){
            html = html.replace("${drunkenness}"," ");
        }else {
            Integer drunkenness = olderPeopleHealthCheckRecord.getDrunkenness();
            switch (drunkenness){
                case 1:html = html.replace("${drunkenness}","是");break;
                case 2:html = html.replace("${drunkenness}","否");break;
                default:html = html.replace("${drunkenness}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getDrinking_type()){
            html = html.replace("${drinking_type}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getDrinking_type();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="白酒 ";break;
                    case "2":valueStrTmp+="啤酒 ";break;
                    case "3":valueStrTmp+="红酒 ";break;
                    case "4":valueStrTmp+="黄酒 ";break;
                    case "5":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${drinking_type}",valueStrTmp);
        }
        html = html.replace("${other_drinking_type}",null==olderPeopleHealthCheckRecord.getOther_drinking_type()?" ":olderPeopleHealthCheckRecord.getOther_drinking_type());
        /**职业病危害因素接触史**/
        html = html.replace("${dust}",null==olderPeopleHealthCheckRecord.getDust()?" ":olderPeopleHealthCheckRecord.getDust());
        if (null==olderPeopleHealthCheckRecord.getDust_protective_measures()){
            html = html.replace("${dust_protective_measures}"," ");
        }else {
            Integer dustProtectiveMeasures = olderPeopleHealthCheckRecord.getDust_protective_measures();
            switch (dustProtectiveMeasures){
                case 1:html = html.replace("${dust_protective_measures}","无");break;
                case 2:html = html.replace("${dust_protective_measures}","有");break;
                default:html = html.replace("${dust_protective_measures}"," ");break;
            }
        }
        html = html.replace("${dust_protective_measures_has}",null==olderPeopleHealthCheckRecord.getDust_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getDust_protective_measures_has());
        html = html.replace("${radiogen}",null==olderPeopleHealthCheckRecord.getRadiogen()?" ":olderPeopleHealthCheckRecord.getRadiogen());
        if (null==olderPeopleHealthCheckRecord.getRadiogen_protective_measures()){
            html = html.replace("${radiogen_protective_measures}"," ");
        }else {
            Integer radiogenProtectiveMeasures = olderPeopleHealthCheckRecord.getRadiogen_protective_measures();
            switch (radiogenProtectiveMeasures){
                case 1:html = html.replace("${radiogen_protective_measures}","无");break;
                case 2:html = html.replace("${radiogen_protective_measures}","有");break;
                default:html = html.replace("${radiogen_protective_measures}"," ");break;
            }
        }
        html = html.replace("${radiogen_protective_measures_has}",null==olderPeopleHealthCheckRecord.getRadiogen_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getRadiogen_protective_measures_has());
        html = html.replace("${physical_factor}",null==olderPeopleHealthCheckRecord.getPhysical_factor()?" ":olderPeopleHealthCheckRecord.getPhysical_factor());
        if (null==olderPeopleHealthCheckRecord.getPhysical_protective_measures()){
            html = html.replace("${physical_protective_measures}"," ");
        }else {
            Integer physicalProtectiveMeasures   = olderPeopleHealthCheckRecord.getPhysical_protective_measures();
            switch (physicalProtectiveMeasures){
                case 1:html = html.replace("${physical_protective_measures}","无");break;
                case 2:html = html.replace("${physical_protective_measures}","有");break;
                default:html = html.replace("${physical_protective_measures}"," ");break;
            }
        }
        html = html.replace("${physical_protective_measures_has}",null==olderPeopleHealthCheckRecord.getPhysical_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getPhysical_protective_measures_has());
        html = html.replace("${chemical_factor}",null==olderPeopleHealthCheckRecord.getChemical_factor()?" ":olderPeopleHealthCheckRecord.getChemical_factor());
        if (null==olderPeopleHealthCheckRecord.getChemical_protective_measures()){
            html = html.replace("${chemical_protective_measures}"," ");
        }else {
            Integer chemicalProtectiveMeasures   = olderPeopleHealthCheckRecord.getChemical_protective_measures();
            switch (chemicalProtectiveMeasures){
                case 1:html = html.replace("${chemical_protective_measures}","无");break;
                case 2:html = html.replace("${chemical_protective_measures}","有");break;
                default:html = html.replace("${chemical_protective_measures}"," ");break;
            }
        }
        html = html.replace("${chemical_protective_measures_has}",null==olderPeopleHealthCheckRecord.getChemical_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getChemical_protective_measures_has());
        html = html.replace("${physical_protective_measures_has}",null==olderPeopleHealthCheckRecord.getPhysical_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getPhysical_protective_measures_has());
        html = html.replace("${other_hazard_factors}",null==olderPeopleHealthCheckRecord.getOther_hazard_factors()?" ":olderPeopleHealthCheckRecord.getOther_hazard_factors());
        if (null==olderPeopleHealthCheckRecord.getOther_hazard_protective_measures()){
            html = html.replace("${other_hazard_protective_measures}"," ");
        }else {
            Integer other_hazard_protective_measures   = olderPeopleHealthCheckRecord.getOther_hazard_protective_measures();
            switch (other_hazard_protective_measures){
                case 1:html = html.replace("${other_hazard_protective_measures}","无");break;
                case 2:html = html.replace("${other_hazard_protective_measures}","有");break;
                default:html = html.replace("${other_hazard_protective_measures}"," ");break;
            }
        }
        html = html.replace("${other_hazard_protective_measures_has}",null==olderPeopleHealthCheckRecord.getOther_hazard_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getOther_hazard_protective_measures_has());
        if (null==olderPeopleHealthCheckRecord.getLip()){
            html = html.replace("${lip}"," ");
        }else {
            Integer lip = olderPeopleHealthCheckRecord.getLip();
            switch (lip){
                case 1:html = html.replace("${lip}","红润");break;
                case 2:html = html.replace("${lip}","苍白");break;
                case 3:html = html.replace("${lip}","发钳");break;
                case 4:html = html.replace("${lip}","皲裂");break;
                case 5:html = html.replace("${lip}","疱疹");break;
                default:html = html.replace("${lip}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getDentition()){
            html = html.replace("${dentition}"," ");
        }else {
            Integer dentition = olderPeopleHealthCheckRecord.getDentition();
            switch (dentition){
                case 1:html = html.replace("${dentition}","正常");break;
                case 2:html = html.replace("${dentition}","缺齿");break;
                case 3:html = html.replace("${dentition}","龋齿");break;
                case 4:html = html.replace("${dentition}","义齿,假牙");break;
                default:html = html.replace("${dentition}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getOropharynx()){
            html = html.replace("${oropharynx}"," ");
        }else {
            Integer oropharynx = olderPeopleHealthCheckRecord.getOropharynx();
            switch (oropharynx){
                case 1:html = html.replace("${oropharynx}","无充血");break;
                case 2:html = html.replace("${oropharynx}","充血");break;
                case 3:html = html.replace("${oropharynx}","淋巴滤泡增生");break;
                default:html = html.replace("${oropharynx}"," ");break;
            }
        }
        html = html.replace("${left_eyesight}",null==olderPeopleHealthCheckRecord.getLeft_eyesight()?"":olderPeopleHealthCheckRecord.getLeft_eyesight()+"");
        html = html.replace("${right_eyesight}",null==olderPeopleHealthCheckRecord.getRight_eyesight()?"":olderPeopleHealthCheckRecord.getRight_eyesight()+"");
        html = html.replace("${left_correctional_eyesight}",null==olderPeopleHealthCheckRecord.getLeft_correctional_eyesight()?"":olderPeopleHealthCheckRecord.getLeft_correctional_eyesight()+"");
        html = html.replace("${right_correctional_eyesight}",null==olderPeopleHealthCheckRecord.getRight_correctional_eyesight()?"":olderPeopleHealthCheckRecord.getRight_correctional_eyesight()+"");
        if (null==olderPeopleHealthCheckRecord.getHearing()){
            html = html.replace("${hearing}"," ");
        }else {
            Integer hearing = olderPeopleHealthCheckRecord.getHearing();
            switch (hearing){
                case 1:html = html.replace("${hearing}","听见");break;
                case 2:html = html.replace("${hearing}","听不清或无法听见");break;
                default:html = html.replace("${hearing}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getMotor_function()){
            html = html.replace("${motor_function}"," ");
        }else {
            Integer motor_function = olderPeopleHealthCheckRecord.getMotor_function();
            switch (motor_function){
                case 1:html = html.replace("${motor_function}","可顺利完成");break;
                case 2:html = html.replace("${motor_function}","无法独立完成任何一个动作");break;
                default:html = html.replace("${motor_function}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getFundus()){
            html = html.replace("${fundus}"," ");
        }else {
            Integer function = olderPeopleHealthCheckRecord.getFundus();
            switch (function){
                case 1:html = html.replace("${fundus}","正常");break;
                case 2:html = html.replace("${fundus}","异常");break;
                default:html = html.replace("${fundus}"," ");break;
            }
        }
        html = html.replace("${fundus_abnormal}",null==olderPeopleHealthCheckRecord.getFundus_abnormal()?"":olderPeopleHealthCheckRecord.getFundus_abnormal());
        if (null==olderPeopleHealthCheckRecord.getSkin()){
            html = html.replace("${skin}"," ");
        }else {
            Integer skin = olderPeopleHealthCheckRecord.getSkin();
            switch (skin){
                case 1:html = html.replace("${skin}","正常");break;
                case 2:html = html.replace("${skin}","潮红");break;
                case 3:html = html.replace("${skin}","苍白");break;
                case 4:html = html.replace("${skin}","发钳");break;
                case 5:html = html.replace("${skin}","黄染");break;
                case 6:html = html.replace("${skin}","色素沉着");break;
                case 7:html = html.replace("${skin}","其他");break;
                default:html = html.replace("${skin}"," ");break;
            }
        }
        html = html.replace("${skin_other}",null==olderPeopleHealthCheckRecord.getSkin_other()?"":olderPeopleHealthCheckRecord.getSkin_other());
        if (null==olderPeopleHealthCheckRecord.getSclera()){
            html = html.replace("${sclera}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getSclera();
            switch (sclera){
                case 1:html = html.replace("${sclera}","正常");break;
                case 2:html = html.replace("${sclera}","黄染");break;
                case 3:html = html.replace("${sclera}","充血");break;
                case 4:html = html.replace("${sclera}","其他");break;
                default:html = html.replace("${sclera}"," ");break;
            }
        }
        html = html.replace("${sclera_other}",null==olderPeopleHealthCheckRecord.getSclera_other()?"":olderPeopleHealthCheckRecord.getSclera_other());
        if (null==olderPeopleHealthCheckRecord.getLymphaden()){
            html = html.replace("${lymphaden}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getLymphaden();
            switch (sclera){
                case 1:html = html.replace("${lymphaden}","未触及");break;
                case 2:html = html.replace("${lymphaden}","锁骨上");break;
                case 3:html = html.replace("${lymphaden}","腋窝");break;
                case 4:html = html.replace("${lymphaden}","其他");break;
                default:html = html.replace("${lymphaden}"," ");break;
            }
        }
        html = html.replace("${lymphaden_other}",null==olderPeopleHealthCheckRecord.getLymphaden_other()?"":olderPeopleHealthCheckRecord.getLymphaden_other());
        if (null==olderPeopleHealthCheckRecord.getBarrel_chest()){
            html = html.replace("${barrel_chest}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getBarrel_chest();
            switch (sclera){
                case 1:html = html.replace("${barrel_chest}","否");break;
                case 2:html = html.replace("${barrel_chest}","是");break;
                default:html = html.replace("${barrel_chest}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getBreath_sounds()){
            html = html.replace("${breath_sounds}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getBreath_sounds();
            switch (sclera){
                case 1:html = html.replace("${breath_sounds}","正常");break;
                case 2:html = html.replace("${breath_sounds}","异常");break;
                default:html = html.replace("${breath_sounds}"," ");break;
            }
        }
        html = html.replace("${breath_sounds_abnormal}",null==olderPeopleHealthCheckRecord.getBreath_sounds_abnormal()?"":olderPeopleHealthCheckRecord.getBreath_sounds_abnormal());
        if (null==olderPeopleHealthCheckRecord.getRale()){
            html = html.replace("${rale}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getRale();
            switch (sclera){
                case 1:html = html.replace("${rale}","无");break;
                case 2:html = html.replace("${rale}","干罗音");break;
                case 3:html = html.replace("${rale}","湿罗音");break;
                case 4:html = html.replace("${rale}","其他");break;
                default:html = html.replace("${rale}"," ");break;
            }
        }
        html = html.replace("${rale_abnormal}",null==olderPeopleHealthCheckRecord.getRale_abnormal()?"":olderPeopleHealthCheckRecord.getRale_abnormal());
        html = html.replace("${heart_rate}",null==olderPeopleHealthCheckRecord.getHeart_rate()?"":olderPeopleHealthCheckRecord.getHeart_rate()+"");
        if (null==olderPeopleHealthCheckRecord.getHeart_rhythm()){
            html = html.replace("${heart_rhythm}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getHeart_rhythm();
            switch (sclera){
                case 1:html = html.replace("${heart_rhythm}","齐");break;
                case 2:html = html.replace("${heart_rhythm}","不齐");break;
                case 3:html = html.replace("${heart_rhythm}","绝对不齐");break;
                default:html = html.replace("${heart_rhythm}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getHeart_noise()){
            html = html.replace("${heart_noise}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getHeart_noise();
            switch (sclera){
                case 1:html = html.replace("${heart_noise}","无");break;
                case 2:html = html.replace("${heart_noise}","有");break;
                default:html = html.replace("${heart_noise}"," ");break;
            }
        }
        html = html.replace("${heart_noise_has}",null==olderPeopleHealthCheckRecord.getHeart_noise_has()?"":olderPeopleHealthCheckRecord.getHeart_noise_has());
        if (null==olderPeopleHealthCheckRecord.getAbdominal_tenderness()){
            html = html.replace("${abdominal_tenderness}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_tenderness();
            switch (sclera){
                case 1:html = html.replace("${abdominal_tenderness}","无");break;
                case 2:html = html.replace("${abdominal_tenderness}","有");break;
                default:html = html.replace("${abdominal_tenderness}"," ");break;
            }
        }
        html = html.replace("${tenderness_has}",null==olderPeopleHealthCheckRecord.getTenderness_has()?"":olderPeopleHealthCheckRecord.getTenderness_has());
        if (null==olderPeopleHealthCheckRecord.getAbdominal_mass()){
            html = html.replace("${abdominal_mass}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_mass();
            switch (sclera){
                case 1:html = html.replace("${abdominal_mass}","无");break;
                case 2:html = html.replace("${abdominal_mass}","有");break;
                default:html = html.replace("${abdominal_mass}"," ");break;
            }
        }
        html = html.replace("${mass_has}",null==olderPeopleHealthCheckRecord.getMass_has()?"":olderPeopleHealthCheckRecord.getMass_has());
        if (null==olderPeopleHealthCheckRecord.getAbdominal_hepatomegaly()){
            html = html.replace("${abdominal_hepatomegaly}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_hepatomegaly();
            switch (sclera){
                case 1:html = html.replace("${abdominal_hepatomegaly}","无");break;
                case 2:html = html.replace("${abdominal_hepatomegaly}","有");break;
                default:html = html.replace("${abdominal_hepatomegaly}"," ");break;
            }
        }
        html = html.replace("${hepatomegaly_has}",null==olderPeopleHealthCheckRecord.getHepatomegaly_has()?"":olderPeopleHealthCheckRecord.getHepatomegaly_has());
        if (null==olderPeopleHealthCheckRecord.getAbdominal_spleen_big()){
            html = html.replace("${abdominal_spleen_big}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_spleen_big();
            switch (sclera){
                case 1:html = html.replace("${abdominal_spleen_big}","无");break;
                case 2:html = html.replace("${abdominal_spleen_big}","有");break;
                default:html = html.replace("${abdominal_spleen_big}"," ");break;
            }
        }
        html = html.replace("${spleen_big_has}",null==olderPeopleHealthCheckRecord.getSpleen_big_has()?"":olderPeopleHealthCheckRecord.getSpleen_big_has());
        if (null==olderPeopleHealthCheckRecord.getAbdominal_shifting_dullness()){
            html = html.replace("${abdominal_shifting_dullness}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_shifting_dullness();
            switch (sclera){
                case 1:html = html.replace("${abdominal_shifting_dullness}","无");break;
                case 2:html = html.replace("${abdominal_shifting_dullness}","有");break;
                default:html = html.replace("${abdominal_shifting_dullness}"," ");break;
            }
        }
        html = html.replace("${shifting_dullness_has}",null==olderPeopleHealthCheckRecord.getShifting_dullness_has()?"":olderPeopleHealthCheckRecord.getShifting_dullness_has());
        if (null==olderPeopleHealthCheckRecord.getCrura_edema()){
            html = html.replace("${crura_edema}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getCrura_edema();
            switch (sclera){
                case 1:html = html.replace("${crura_edema}","无");break;
                case 2:html = html.replace("${crura_edema}","单侧");break;
                case 3:html = html.replace("${crura_edema}","双侧不对称");break;
                case 4:html = html.replace("${crura_edema}","双侧对称");break;
                default:html = html.replace("${crura_edema}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getDorsal_foot_pulse()){
            html = html.replace("${dorsal_foot_pulse}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getDorsal_foot_pulse();
            switch (sclera){
                case 1:html = html.replace("${dorsal_foot_pulse}","未接触");break;
                case 2:html = html.replace("${dorsal_foot_pulse}","触及双侧对称");break;
                case 3:html = html.replace("${dorsal_foot_pulse}","触及左侧弱或消失");break;
                case 4:html = html.replace("${dorsal_foot_pulse}","触及右侧弱或消失");break;
                default:html = html.replace("${dorsal_foot_pulse}"," ");break;
            }
        }
        if (null==olderPeopleHealthCheckRecord.getAnus_dre()){
            html = html.replace("${anus_dre}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAnus_dre();
            switch (sclera){
                case 1:html = html.replace("${anus_dre}","未见异常");break;
                case 2:html = html.replace("${anus_dre}","触痛");break;
                case 3:html = html.replace("${anus_dre}","包块");break;
                case 4:html = html.replace("${anus_dre}","前列腺异常");break;
                case 5:html = html.replace("${anus_dre}","其他");break;
                default:html = html.replace("${anus_dre}"," ");break;
            }
        }
        html = html.replace("${anus_dre_other}",null==olderPeopleHealthCheckRecord.getAnus_dre_other()?"":olderPeopleHealthCheckRecord.getAnus_dre_other());
        if (null==olderPeopleHealthCheckRecord.getBreast()){
            html = html.replace("${breast}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getBreast();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="未见异常 ";break;
                    case "2":valueStrTmp+="乳房切除 ";break;
                    case "3":valueStrTmp+="异常泌乳 ";break;
                    case "4":valueStrTmp+="乳腺包块 ";break;
                    case "5":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${breast}",valueStrTmp);
        }
        html = html.replace("${breast_other}",null==olderPeopleHealthCheckRecord.getBreast_other()?"":olderPeopleHealthCheckRecord.getBreast_other());
        if (null==olderPeopleHealthCheckRecord.getVulva()){
            html = html.replace("${vulva}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getVulva();
            switch (sclera){
                case 1:html = html.replace("${vulva}","未见异常");break;
                case 2:html = html.replace("${vulva}","异常");break;
                default:html = html.replace("${vulva}"," ");break;
            }
        }
        html = html.replace("${vulva_abnormal}",null==olderPeopleHealthCheckRecord.getVulva_abnormal()?"":olderPeopleHealthCheckRecord.getVulva_abnormal());
        if (null==olderPeopleHealthCheckRecord.getVagina()){
            html = html.replace("${vagina}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getVagina();
            switch (sclera){
                case 1:html = html.replace("${vagina}","未见异常");break;
                case 2:html = html.replace("${vagina}","异常");break;
                default:html = html.replace("${vagina}"," ");break;
            }
        }
        html = html.replace("${vagina_abnormal}",null==olderPeopleHealthCheckRecord.getVagina_abnormal()?"":olderPeopleHealthCheckRecord.getVagina_abnormal());
        if (null==olderPeopleHealthCheckRecord.getCervical()){
            html = html.replace("${cervical}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getCervical();
            switch (sclera){
                case 1:html = html.replace("${cervical}","未见异常");break;
                case 2:html = html.replace("${cervical}","异常");break;
                default:html = html.replace("${cervical}"," ");break;
            }
        }
        html = html.replace("${cervical_abnormal}",null==olderPeopleHealthCheckRecord.getCervical_abnormal()?"":olderPeopleHealthCheckRecord.getCervical_abnormal());
        if (null==olderPeopleHealthCheckRecord.getCorpus()){
            html = html.replace("${corpus}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getCorpus();
            switch (sclera){
                case 1:html = html.replace("${corpus}","未见异常");break;
                case 2:html = html.replace("${corpus}","异常");break;
                default:html = html.replace("${corpus}"," ");break;
            }
        }
        html = html.replace("${corpus_abnormal}",null==olderPeopleHealthCheckRecord.getCorpus_abnormal()?"":olderPeopleHealthCheckRecord.getCorpus_abnormal());
        if (null==olderPeopleHealthCheckRecord.getGynecologic_appendix()){
            html = html.replace("${gynecologic_appendix}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getGynecologic_appendix();
            switch (sclera){
                case 1:html = html.replace("${gynecologic_appendix}","未见异常");break;
                case 2:html = html.replace("${gynecologic_appendix}","异常");break;
                default:html = html.replace("${gynecologic_appendix}"," ");break;
            }
        }
        html = html.replace("${appendix_abnormal}",null==olderPeopleHealthCheckRecord.getAppendix_abnormal()?"":olderPeopleHealthCheckRecord.getAppendix_abnormal());
        html = html.replace("${physical_examination_other}",null==olderPeopleHealthCheckRecord.getPhysical_examination_other()?"":olderPeopleHealthCheckRecord.getPhysical_examination_other());
        html = html.replace("${hemoglobin}",null==olderPeopleHealthCheckRecord.getHemoglobin()?"":olderPeopleHealthCheckRecord.getHemoglobin()+"");
        html = html.replace("${leukocyte}",null==olderPeopleHealthCheckRecord.getLeukocyte()?"":olderPeopleHealthCheckRecord.getLeukocyte()+"");
        html = html.replace("${thrombocyte}",null==olderPeopleHealthCheckRecord.getThrombocyte()?"":olderPeopleHealthCheckRecord.getThrombocyte()+"");
        html = html.replace("${blood_routine_other}",null==olderPeopleHealthCheckRecord.getBlood_routine_other()?"":olderPeopleHealthCheckRecord.getBlood_routine_other()+"");
        html = html.replace("${urine_protein}",null==olderPeopleHealthCheckRecord.getUrine_protein()?"":olderPeopleHealthCheckRecord.getUrine_protein()+"");
        html = html.replace("${urine_sugar}",null==olderPeopleHealthCheckRecord.getUrine_sugar()?"":olderPeopleHealthCheckRecord.getUrine_sugar()+"");
        html = html.replace("${urine_acetone_bodies}",null==olderPeopleHealthCheckRecord.getUrine_acetone_bodies()?"":olderPeopleHealthCheckRecord.getUrine_acetone_bodies()+"");
        html = html.replace("${urine_occult_blood}",null==olderPeopleHealthCheckRecord.getUrine_occult_blood()?"":olderPeopleHealthCheckRecord.getUrine_occult_blood()+"");
        html = html.replace("${urine_routine_other}",null==olderPeopleHealthCheckRecord.getUrine_routine_other()?"":olderPeopleHealthCheckRecord.getUrine_routine_other()+"");
        html = html.replace("${fasting_blood_glucose_L}",null==olderPeopleHealthCheckRecord.getFasting_blood_glucose_L()?"":olderPeopleHealthCheckRecord.getFasting_blood_glucose_L()+"");
        html = html.replace("${fasting_blood_glucose_dL}",null==olderPeopleHealthCheckRecord.getFasting_blood_glucose_dL()?"":olderPeopleHealthCheckRecord.getFasting_blood_glucose_dL()+"");
        if (null==olderPeopleHealthCheckRecord.getElectrocardiogram()){
            html = html.replace("${electrocardiogram}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getElectrocardiogram();
            switch (sclera){
                case 1:html = html.replace("${electrocardiogram}","正常");break;
                case 2:html = html.replace("${electrocardiogram}","异常");break;
                default:html = html.replace("${electrocardiogram}"," ");break;
            }
        }
        html = html.replace("${electrocardiogram_abnormal}",null==olderPeopleHealthCheckRecord.getElectrocardiogram_abnormal()?"":olderPeopleHealthCheckRecord.getElectrocardiogram_abnormal()+"");
        html = html.replace("${microalbuminuria}",null==olderPeopleHealthCheckRecord.getMicroalbuminuria()?"":olderPeopleHealthCheckRecord.getMicroalbuminuria()+"");
        if(null==olderPeopleHealthCheckRecord.getOccult_blood_in_stool()){
            html = html.replace("${occult_blood_in_stool}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getOccult_blood_in_stool();
            switch (sclera){
                case 1:html = html.replace("${occult_blood_in_stool}","阴性");break;
                case 2:html = html.replace("${occult_blood_in_stool}","阳性");break;
                default:html = html.replace("${occult_blood_in_stool}"," ");break;
            }
        }
        html = html.replace("${glycated_hemoglobin}",null==olderPeopleHealthCheckRecord.getGlycated_hemoglobin()?"":olderPeopleHealthCheckRecord.getGlycated_hemoglobin()+"");
        if(null==olderPeopleHealthCheckRecord.getHBsAg()){
            html = html.replace("${HBsAg}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getHBsAg();
            switch (sclera){
                case 1:html = html.replace("${HBsAg}","阴性");break;
                case 2:html = html.replace("${HBsAg}","阳性");break;
                default:html = html.replace("${HBsAg}"," ");break;
            }
        }
        html = html.replace("${ALT}",null==olderPeopleHealthCheckRecord.getALT()?"":olderPeopleHealthCheckRecord.getALT()+"");
        html = html.replace("${SGOT}",null==olderPeopleHealthCheckRecord.getSGOT()?"":olderPeopleHealthCheckRecord.getSGOT()+"");
        html = html.replace("${albumin}",null==olderPeopleHealthCheckRecord.getAlbumin()?"":olderPeopleHealthCheckRecord.getAlbumin()+"");
        html = html.replace("${total_bilirubin}",null==olderPeopleHealthCheckRecord.getTotal_bilirubin()?"":olderPeopleHealthCheckRecord.getTotal_bilirubin()+"");
        html = html.replace("${conjugated_bilirubin}",null==olderPeopleHealthCheckRecord.getConjugated_bilirubin()?"":olderPeopleHealthCheckRecord.getConjugated_bilirubin()+"");
        html = html.replace("${serum_creatinine}",null==olderPeopleHealthCheckRecord.getConjugated_bilirubin()?"":olderPeopleHealthCheckRecord.getConjugated_bilirubin()+"");
        html = html.replace("${blood_urea_nitrogen}",null==olderPeopleHealthCheckRecord.getBlood_urea_nitrogen()?"":olderPeopleHealthCheckRecord.getBlood_urea_nitrogen()+"");
        html = html.replace("${blood_potassium_concentration}",null==olderPeopleHealthCheckRecord.getBlood_potassium_concentration()?"":olderPeopleHealthCheckRecord.getBlood_potassium_concentration()+"");
        html = html.replace("${blood_Na_concentration}",null==olderPeopleHealthCheckRecord.getBlood_Na_concentration()?"":olderPeopleHealthCheckRecord.getBlood_Na_concentration()+"");
        html = html.replace("${uric_acid}",null==olderPeopleHealthCheckRecord.getUric_acid()?"":olderPeopleHealthCheckRecord.getUric_acid()+"");
        html = html.replace("${total_cholesterol}",null==olderPeopleHealthCheckRecord.getTotal_cholesterol()?"":olderPeopleHealthCheckRecord.getTotal_cholesterol()+"");
        html = html.replace("${triglyceride}",null==olderPeopleHealthCheckRecord.getTriglyceride()?"":olderPeopleHealthCheckRecord.getTriglyceride()+"");
        html = html.replace("${LDL_cholesterol}",null==olderPeopleHealthCheckRecord.getLDL_cholesterol()?"":olderPeopleHealthCheckRecord.getLDL_cholesterol()+"");
        html = html.replace("${HDL_cholesterol}",null==olderPeopleHealthCheckRecord.getHDL_cholesterol()?"":olderPeopleHealthCheckRecord.getHDL_cholesterol()+"");
        html = html.replace("${alpha_fetal_protein}",null==olderPeopleHealthCheckRecord.getAlpha_fetal_protein()?"":olderPeopleHealthCheckRecord.getAlpha_fetal_protein()+"");
        if(null==olderPeopleHealthCheckRecord.getChest_Xray()){
            html = html.replace("${chest_Xray}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getChest_Xray();
            switch (sclera){
                case 1:html = html.replace("${chest_Xray}","正常");break;
                case 2:html = html.replace("${chest_Xray}","异常");break;
                default:html = html.replace("${chest_Xray}"," ");break;
            }
        }
        html = html.replace("${chest_Xray_abnormal}",null==olderPeopleHealthCheckRecord.getChest_Xray_abnormal()?"":olderPeopleHealthCheckRecord.getChest_Xray_abnormal());
        if(null==olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic()){
            html = html.replace("${abdomen_B_ultrasonic}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic();
            switch (sclera){
                case 1:html = html.replace("${abdomen_B_ultrasonic}","正常");break;
                case 2:html = html.replace("${abdomen_B_ultrasonic}","异常");break;
                default:html = html.replace("${abdomen_B_ultrasonic}"," ");break;
            }
        }
        html = html.replace("${abdomen_B_ultrasonic_abnormal}",null==olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic_abnormal()?"":olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic_abnormal());
        if(null==olderPeopleHealthCheckRecord.getB_ultrasonic_other()){
            html = html.replace("${B_ultrasonic_other}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getB_ultrasonic_other();
            switch (sclera){
                case 1:html = html.replace("${B_ultrasonic_other}","正常");break;
                case 2:html = html.replace("${B_ultrasonic_other}","异常");break;
                default:html = html.replace("${B_ultrasonic_other}"," ");break;
            }
        }
        html = html.replace("${B_ultrasonic_other_abnormal}",null==olderPeopleHealthCheckRecord.getB_ultrasonic_other_abnormal()?"":olderPeopleHealthCheckRecord.getB_ultrasonic_other_abnormal());
        if(null==olderPeopleHealthCheckRecord.getCervical_smear()){
            html = html.replace("${cervical_smear}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getCervical_smear();
            switch (sclera){
                case 1:html = html.replace("${cervical_smear}","正常");break;
                case 2:html = html.replace("${cervical_smear}","异常");break;
                default:html = html.replace("${cervical_smear}"," ");break;
            }
        }
        html = html.replace("${cervical_smear_abnormal}",null==olderPeopleHealthCheckRecord.getCervical_smear_abnormal()?"":olderPeopleHealthCheckRecord.getCervical_smear_abnormal());
        html = html.replace("${auxiliary_examination_other}",null==olderPeopleHealthCheckRecord.getAuxiliary_examination_other()?"":olderPeopleHealthCheckRecord.getAuxiliary_examination_other());
        if(null==olderPeopleHealthCheckRecord.getMild_physical()){
            html = html.replace("${mild_physical}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMild_physical();
            switch (sclera){
                case 1:html = html.replace("${mild_physical}","是");break;
                case 2:html = html.replace("${mild_physical}","倾向是");break;
                default:html = html.replace("${mild_physical}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getQi_deficiency()){
            html = html.replace("${qi_deficiency}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getQi_deficiency();
            switch (sclera){
                case 1:html = html.replace("${qi_deficiency}","是");break;
                case 2:html = html.replace("${qi_deficiency}","基本是");break;
                default:html = html.replace("${qi_deficiency}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getYang_deficiency()){
            html = html.replace("${yang_deficiency}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getYang_deficiency();
            switch (sclera){
                case 1:html = html.replace("${yang_deficiency}","是");break;
                case 2:html = html.replace("${yang_deficiency}","基本是");break;
                default:html = html.replace("${yang_deficiency}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getYin_deficiency()){
            html = html.replace("${yin_deficiency}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getYin_deficiency();
            switch (sclera){
                case 1:html = html.replace("${yin_deficiency}","是");break;
                case 2:html = html.replace("${yin_deficiency}","基本是");break;
                default:html = html.replace("${yin_deficiency}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getPhlegm_dampness()){
            html = html.replace("${phlegm_dampness}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getPhlegm_dampness();
            switch (sclera){
                case 1:html = html.replace("${phlegm_dampness}","是");break;
                case 2:html = html.replace("${phlegm_dampness}","基本是");break;
                default:html = html.replace("${phlegm_dampness}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getDampness_heat()){
            html = html.replace("${dampness_heat}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getDampness_heat();
            switch (sclera){
                case 1:html = html.replace("${dampness_heat}","是");break;
                case 2:html = html.replace("${dampness_heat}","基本是");break;
                default:html = html.replace("${dampness_heat}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getBlood_stasis()){
            html = html.replace("${blood_stasis}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getBlood_stasis();
            switch (sclera){
                case 1:html = html.replace("${blood_stasis}","是");break;
                case 2:html = html.replace("${blood_stasis}","基本是");break;
                default:html = html.replace("${blood_stasis}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getLogistic_regression()){
            html = html.replace("${logistic_regression}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getLogistic_regression();
            switch (sclera){
                case 1:html = html.replace("${logistic_regression}","是");break;
                case 2:html = html.replace("${logistic_regression}","基本是");break;
                default:html = html.replace("${logistic_regression}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getGrasp_quality()){
            html = html.replace("${grasp_quality}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getGrasp_quality();
            switch (sclera){
                case 1:html = html.replace("${grasp_quality}","是");break;
                case 2:html = html.replace("${grasp_quality}","基本是");break;
                default:html = html.replace("${grasp_quality}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getCerebrovascular_disease()){
            html = html.replace("${cerebrovascular_disease}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getCerebrovascular_disease();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="未发现 ";break;
                    case "2":valueStrTmp+="缺血性卒中 ";break;
                    case "3":valueStrTmp+="脑出血 ";break;
                    case "4":valueStrTmp+="蛛网膜下腔出血 ";break;
                    case "5":valueStrTmp+="短暂性脑缺血发作 ";break;
                    case "6":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${cerebrovascular_disease}",valueStrTmp);
        }
        html = html.replace("${cerebrovascular_disease_other}",null==olderPeopleHealthCheckRecord.getCerebrovascular_disease_other()?"":olderPeopleHealthCheckRecord.getCerebrovascular_disease_other());
        if(null==olderPeopleHealthCheckRecord.getNephropathy()){
            html = html.replace("${nephropathy}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getNephropathy();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="未发现 ";break;
                    case "2":valueStrTmp+="糖尿病肾病 ";break;
                    case "3":valueStrTmp+="肾功能衰竭 ";break;
                    case "4":valueStrTmp+="急性肾炎 ";break;
                    case "5":valueStrTmp+="慢性肾炎 ";break;
                    case "6":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${nephropathy}",valueStrTmp);
        }
        html = html.replace("${nephropathy_other}",null==olderPeopleHealthCheckRecord.getNephropathy_other()?"":olderPeopleHealthCheckRecord.getNephropathy_other());
        if(null==olderPeopleHealthCheckRecord.getHeart_disease()){
                    html = html.replace("${heart_disease}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getHeart_disease();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="未发现 ";break;
                    case "2":valueStrTmp+="心肌梗死 ";break;
                    case "3":valueStrTmp+="心绞痛 ";break;
                    case "4":valueStrTmp+="冠状动脉血运重建 ";break;
                    case "5":valueStrTmp+="充血性心力衰竭 ";break;
                    case "6":valueStrTmp+="心前区疼痛 ";break;
                    case "7":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${heart_disease}",valueStrTmp);
        }
        html = html.replace("${heart_disease_other}",null==olderPeopleHealthCheckRecord.getHeart_disease_other()?"":olderPeopleHealthCheckRecord.getHeart_disease_other());
        if(null==olderPeopleHealthCheckRecord.getVascular_disease()){
                    html = html.replace("${vascular_disease}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getVascular_disease();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="未发现 ";break;
                    case "2":valueStrTmp+="夹层动脉瘤 ";break;
                    case "3":valueStrTmp+="动脉闭塞性疾病 ";break;
                    case "4":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${vascular_disease}",valueStrTmp);
        }
        html = html.replace("${vascular_disease_other}",null==olderPeopleHealthCheckRecord.getVascular_disease_other()?"":olderPeopleHealthCheckRecord.getVascular_disease_other());
        if(null==olderPeopleHealthCheckRecord.getEye_disease()){
            html = html.replace("${eye_disease}"," ");
        }else {
            String smokingState = olderPeopleHealthCheckRecord.getEye_disease();
            String[] smokingStates = smokingState.split(",");
            String valueStrTmp = " ";
            for (String tmp:smokingStates){
                switch (tmp){
                    case "1":valueStrTmp+="未发现 ";break;
                    case "2":valueStrTmp+="视网膜出血或渗出 ";break;
                    case "3":valueStrTmp+="视乳头水肿 ";break;
                    case "4":valueStrTmp+="白内障 ";break;
                    case "5":valueStrTmp+="其他 ";break;
                }
            }
            html = html.replace("${eye_disease}",valueStrTmp);
        }
        html = html.replace("${eye_disease_other}",null==olderPeopleHealthCheckRecord.getEye_disease_other()?"":olderPeopleHealthCheckRecord.getEye_disease_other());
        if(null==olderPeopleHealthCheckRecord.getNervous_system_disease()){
            html = html.replace("${nervous_system_disease}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getNervous_system_disease();
            switch (sclera){
                case 1:html = html.replace("${nervous_system_disease}","未发现");break;
                case 2:html = html.replace("${nervous_system_disease}","有");break;
                default:html = html.replace("${nervous_system_disease}"," ");break;
            }
        }
        html = html.replace("${nervous_system_disease_has}",null==olderPeopleHealthCheckRecord.getNervous_system_disease_has()?"":olderPeopleHealthCheckRecord.getNervous_system_disease_has());
        if(null==olderPeopleHealthCheckRecord.getOther_system_disease()){
            html = html.replace("${other_system_disease}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getOther_system_disease();
            switch (sclera){
                case 1:html = html.replace("${other_system_disease}","未发现");break;
                case 2:html = html.replace("${other_system_disease}","有");break;
                default:html = html.replace("${other_system_disease}"," ");break;
            }
        }
        html = html.replace("${other_system_disease_has}",null==olderPeopleHealthCheckRecord.getOther_system_disease_has()?"":olderPeopleHealthCheckRecord.getOther_system_disease_has());
        html = html.replace("${admission_date1}",null==olderPeopleHealthCheckRecord.getAdmission_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getAdmission_date1()));
        html = html.replace("${admission_date2}",null==olderPeopleHealthCheckRecord.getAdmission_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getAdmission_date2()));
        html = html.replace("${discharge_date1}",null==olderPeopleHealthCheckRecord.getDischarge_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getDischarge_date1()));
        html = html.replace("${discharge_date2}",null==olderPeopleHealthCheckRecord.getDischarge_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getDischarge_date2()));
        html = html.replace("${admission_reason1}",null==olderPeopleHealthCheckRecord.getAdmission_reason1()?"":olderPeopleHealthCheckRecord.getAdmission_reason1());
        html = html.replace("${admission_reason2}",null==olderPeopleHealthCheckRecord.getAdmission_reason2()?"":olderPeopleHealthCheckRecord.getAdmission_reason2());
        html = html.replace("${admission_hospital_name1}",null==olderPeopleHealthCheckRecord.getAdmission_hospital_name1()?"":olderPeopleHealthCheckRecord.getAdmission_hospital_name1());
        html = html.replace("${admission_hospital_name2}",null==olderPeopleHealthCheckRecord.getAdmission_hospital_name2()?"":olderPeopleHealthCheckRecord.getAdmission_hospital_name2());
        html = html.replace("${admission_number1}",null==olderPeopleHealthCheckRecord.getAdmission_number1()?"":olderPeopleHealthCheckRecord.getAdmission_number1());
        html = html.replace("${admission_number2}",null==olderPeopleHealthCheckRecord.getAdmission_number2()?"":olderPeopleHealthCheckRecord.getAdmission_number2());
        html = html.replace("${building_bed_date1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getBuilding_bed_date1()));
        html = html.replace("${building_bed_date2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getBuilding_bed_date2()));
        html = html.replace("${cancel_bed_date1}",null==olderPeopleHealthCheckRecord.getCancel_bed_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getCancel_bed_date1()));
        html = html.replace("${cancel_bed_date2}",null==olderPeopleHealthCheckRecord.getCancel_bed_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getCancel_bed_date2()));
        html = html.replace("${building_bed_reason1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_reason1()?"":olderPeopleHealthCheckRecord.getBuilding_bed_reason1());
        html = html.replace("${building_bed_reason2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_reason2()?"":olderPeopleHealthCheckRecord.getBuilding_bed_reason2());
        html = html.replace("${building_bed_hospiatl_name1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name1()?"":olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name1());
        html = html.replace("${building_bed_hospiatl_name2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name2()?"":olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name2());
        html = html.replace("${building_bed_number1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_number1()?"":olderPeopleHealthCheckRecord.getBuilding_bed_number1());
        html = html.replace("${building_bed_number2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_number2()?"":olderPeopleHealthCheckRecord.getBuilding_bed_number2());
        html = html.replace("${medicine1}",null==olderPeopleHealthCheckRecord.getMedicine1()?"":olderPeopleHealthCheckRecord.getMedicine1());
        html = html.replace("${medicine2}",null==olderPeopleHealthCheckRecord.getMedicine2()?"":olderPeopleHealthCheckRecord.getMedicine2());
        html = html.replace("${medicine3}",null==olderPeopleHealthCheckRecord.getMedicine3()?"":olderPeopleHealthCheckRecord.getMedicine3());
        html = html.replace("${medicine4}",null==olderPeopleHealthCheckRecord.getMedicine4()?"":olderPeopleHealthCheckRecord.getMedicine4());
        html = html.replace("${medicine5}",null==olderPeopleHealthCheckRecord.getMedicine5()?"":olderPeopleHealthCheckRecord.getMedicine5());
        html = html.replace("${medicine6}",null==olderPeopleHealthCheckRecord.getMedicine6()?"":olderPeopleHealthCheckRecord.getMedicine6());
        html = html.replace("${medicine1_use}",null==olderPeopleHealthCheckRecord.getMedicine1_use()?"":olderPeopleHealthCheckRecord.getMedicine1_use());
        html = html.replace("${medicine2_use}",null==olderPeopleHealthCheckRecord.getMedicine2_use()?"":olderPeopleHealthCheckRecord.getMedicine2_use());
        html = html.replace("${medicine3_use}",null==olderPeopleHealthCheckRecord.getMedicine3_use()?"":olderPeopleHealthCheckRecord.getMedicine3_use());
        html = html.replace("${medicine4_use}",null==olderPeopleHealthCheckRecord.getMedicine4_use()?"":olderPeopleHealthCheckRecord.getMedicine4_use());
        html = html.replace("${medicine5_use}",null==olderPeopleHealthCheckRecord.getMedicine5_use()?"":olderPeopleHealthCheckRecord.getMedicine5_use());
        html = html.replace("${medicine6_use}",null==olderPeopleHealthCheckRecord.getMedicine6_use()?"":olderPeopleHealthCheckRecord.getMedicine6_use());
        html = html.replace("${medicine1_dosage}",null==olderPeopleHealthCheckRecord.getMedicine1_dosage()?"":olderPeopleHealthCheckRecord.getMedicine1_dosage());
        html = html.replace("${medicine2_dosage}",null==olderPeopleHealthCheckRecord.getMedicine2_dosage()?"":olderPeopleHealthCheckRecord.getMedicine2_dosage());
        html = html.replace("${medicine3_dosage}",null==olderPeopleHealthCheckRecord.getMedicine3_dosage()?"":olderPeopleHealthCheckRecord.getMedicine3_dosage());
        html = html.replace("${medicine4_dosage}",null==olderPeopleHealthCheckRecord.getMedicine4_dosage()?"":olderPeopleHealthCheckRecord.getMedicine4_dosage());
        html = html.replace("${medicine5_dosage}",null==olderPeopleHealthCheckRecord.getMedicine5_dosage()?"":olderPeopleHealthCheckRecord.getMedicine5_dosage());
        html = html.replace("${medicine6_dosage}",null==olderPeopleHealthCheckRecord.getMedicine6_dosage()?"":olderPeopleHealthCheckRecord.getMedicine6_dosage());
        html = html.replace("${medication1_time}",null==olderPeopleHealthCheckRecord.getMedication1_time()?"":olderPeopleHealthCheckRecord.getMedication1_time());
        html = html.replace("${medication2_time}",null==olderPeopleHealthCheckRecord.getMedication2_time()?"":olderPeopleHealthCheckRecord.getMedication2_time());
        html = html.replace("${medication3_time}",null==olderPeopleHealthCheckRecord.getMedication3_time()?"":olderPeopleHealthCheckRecord.getMedication3_time());
        html = html.replace("${medication4_time}",null==olderPeopleHealthCheckRecord.getMedication4_time()?"":olderPeopleHealthCheckRecord.getMedication4_time());
        html = html.replace("${medication5_time}",null==olderPeopleHealthCheckRecord.getMedication5_time()?"":olderPeopleHealthCheckRecord.getMedication5_time());
        html = html.replace("${medication6_time}",null==olderPeopleHealthCheckRecord.getMedication6_time()?"":olderPeopleHealthCheckRecord.getMedication6_time());
        if(null==olderPeopleHealthCheckRecord.getMedication1_compliance()){
            html = html.replace("${medication1_compliance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMedication1_compliance();
            switch (sclera){
                case 1:html = html.replace("${medication1_compliance}","规律");break;
                case 2:html = html.replace("${medication1_compliance}","间断");break;
                case 3:html = html.replace("${medication1_compliance}","不服药");break;
                default:html = html.replace("${medication1_compliance}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getMedication2_compliance()){
            html = html.replace("${medication2_compliance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMedication2_compliance();
            switch (sclera){
                case 1:html = html.replace("${medication2_compliance}","规律");break;
                case 2:html = html.replace("${medication2_compliance}","间断");break;
                case 3:html = html.replace("${medication2_compliance}","不服药");break;
                default:html = html.replace("${medication2_compliance}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getMedication3_compliance()){
            html = html.replace("${medication3_compliance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMedication3_compliance();
            switch (sclera){
                case 1:html = html.replace("${medication3_compliance}","规律");break;
                case 2:html = html.replace("${medication3_compliance}","间断");break;
                case 3:html = html.replace("${medication3_compliance}","不服药");break;
                default:html = html.replace("${medication3_compliance}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getMedication4_compliance()){
            html = html.replace("${medication4_compliance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMedication4_compliance();
            switch (sclera){
                case 1:html = html.replace("${medication4_compliance}","规律");break;
                case 2:html = html.replace("${medication4_compliance}","间断");break;
                case 3:html = html.replace("${medication4_compliance}","不服药");break;
                default:html = html.replace("${medication4_compliance}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getMedication5_compliance()){
            html = html.replace("${medication5_compliance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMedication5_compliance();
            switch (sclera){
                case 1:html = html.replace("${medication5_compliance}","规律");break;
                case 2:html = html.replace("${medication5_compliance}","间断");break;
                case 3:html = html.replace("${medication5_compliance}","不服药");break;
                default:html = html.replace("${medication5_compliance}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getMedication6_compliance()){
            html = html.replace("${medication6_compliance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getMedication6_compliance();
            switch (sclera){
                case 1:html = html.replace("${medication6_compliance}","规律");break;
                case 2:html = html.replace("${medication6_compliance}","间断");break;
                case 3:html = html.replace("${medication6_compliance}","不服药");break;
                default:html = html.replace("${medication6_compliance}"," ");break;
            }
        }
        html = html.replace("${vaccination_name1}",null==olderPeopleHealthCheckRecord.getVaccination_name1()?"":olderPeopleHealthCheckRecord.getVaccination_name1());
        html = html.replace("${vaccination_name2}",null==olderPeopleHealthCheckRecord.getVaccination_name2()?"":olderPeopleHealthCheckRecord.getVaccination_name2());
        html = html.replace("${vaccination_name3}",null==olderPeopleHealthCheckRecord.getVaccination_name3()?"":olderPeopleHealthCheckRecord.getVaccination_name3());
        html = html.replace("${vaccination_date1}",null==olderPeopleHealthCheckRecord.getVaccination_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getVaccination_date1()));
        html = html.replace("${vaccination_date2}",null==olderPeopleHealthCheckRecord.getVaccination_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getVaccination_date2()));
        html = html.replace("${vaccination_date3}",null==olderPeopleHealthCheckRecord.getVaccination_date3()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getVaccination_date3()));
        html = html.replace("${vaccination_hospital_name1}",null==olderPeopleHealthCheckRecord.getVaccination_hospital_name1()?"":olderPeopleHealthCheckRecord.getVaccination_hospital_name1());
        html = html.replace("${vaccination_hospital_name2}",null==olderPeopleHealthCheckRecord.getVaccination_hospital_name2()?"":olderPeopleHealthCheckRecord.getVaccination_hospital_name2());
        html = html.replace("${vaccination_hospital_name3}",null==olderPeopleHealthCheckRecord.getVaccination_hospital_name3()?"":olderPeopleHealthCheckRecord.getVaccination_hospital_name3());
        if(null==olderPeopleHealthCheckRecord.getHealth_examination()){
            html = html.replace("${health_examination}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getHealth_examination();
            switch (sclera){
                case 1:html = html.replace("${health_examination}","无");break;
                case 2:html = html.replace("${health_examination}","有异常");break;
                default:html = html.replace("${health_examination}"," ");break;
            }
        }
        html = html.replace("${health_examination_abnormal1}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal1()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal1());
        html = html.replace("${health_examination_abnormal2}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal2()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal2());
        html = html.replace("${health_examination_abnormal3}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal3()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal3());
        html = html.replace("${health_examination_abnormal4}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal4()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal4());
        if(null==olderPeopleHealthCheckRecord.getRegular_followup()){
            html = html.replace("${regular_followup}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getRegular_followup();
            switch (sclera){
                case 2:html = html.replace("${regular_followup}","定期随访:是");break;
                default:html = html.replace("${regular_followup}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getChronic_health_management()){
            html = html.replace("${chronic_health_management}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getChronic_health_management();
            switch (sclera){
                case 2:html = html.replace("${chronic_health_management}","纳入慢性病患者健康管理:是");break;
                default:html = html.replace("${chronic_health_management}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getSuggest_recheck()){
            html = html.replace("${suggest_recheck}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getSuggest_recheck();
            switch (sclera){
                case 2:html = html.replace("${suggest_recheck}","建议复查:是");break;
                default:html = html.replace("${suggest_recheck}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getSuggest_referral()){
            html = html.replace("${suggest_referral}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getSuggest_referral();
            switch (sclera){
                case 2:html = html.replace("${suggest_referral}","建议转诊:是");break;
                default:html = html.replace("${suggest_referral}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getOther_health_guidance()){
            html = html.replace("${other_health_guidance}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getOther_health_guidance();
            switch (sclera){
                case 2:html = html.replace("${other_health_guidance}","其他");break;
                default:html = html.replace("${other_health_guidance}"," ");break;
            }
        }
        html = html.replace("${other_health_guidance_description}",null==olderPeopleHealthCheckRecord.getOther_health_guidance_description()?"":olderPeopleHealthCheckRecord.getOther_health_guidance_description());
        if(null==olderPeopleHealthCheckRecord.getStop_smoking()){
            html = html.replace("${stop_smoking}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getStop_smoking();
            switch (sclera){
                case 2:html = html.replace("${stop_smoking}","戒烟:是");break;
                default:html = html.replace("${stop_smoking}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getHealthy_drinking()){
            html = html.replace("${healthy_drinking}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getHealthy_drinking();
            switch (sclera){
                case 2:html = html.replace("${healthy_drinking}","健康饮酒:是");break;
                default:html = html.replace("${healthy_drinking}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getDiet()){
            html = html.replace("${diet}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getDiet();
            switch (sclera){
                case 2:html = html.replace("${diet}","饮食:是");break;
                default:html = html.replace("${diet}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getExercise()){
            html = html.replace("${exercise}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getExercise();
            switch (sclera){
                case 2:html = html.replace("${exercise}","锻炼:是");break;
                default:html = html.replace("${exercise}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getLose_weight()){
            html = html.replace("${lose_weight}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getLose_weight();
            switch (sclera){
                case 2:html = html.replace("${lose_weight}","减肥:是");break;
                default:html = html.replace("${lose_weight}"," ");break;
            }
        }
        html = html.replace("${goal_weight}",null==olderPeopleHealthCheckRecord.getGoal_weight()?"":"目标:"+olderPeopleHealthCheckRecord.getGoal_weight()+"Kg");
        if(null==olderPeopleHealthCheckRecord.getRecommended_vaccination()){
            html = html.replace("${recommended_vaccination}"," ");
        }else {
            String sclera = olderPeopleHealthCheckRecord.getRecommended_vaccination();
            switch (sclera){
                case "2":html = html.replace("${recommended_vaccination}","建议接种疫苗:是");break;
                default:html = html.replace("${recommended_vaccination}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getOther_advice()){
            html = html.replace("${other_advice}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getOther_advice();
            switch (sclera){
                case 2:html = html.replace("${other_advice}","其他建议:是");break;
                default:html = html.replace("${other_advice}"," ");break;
            }
        }
        html = html.replace("${other_advice_description}",null==olderPeopleHealthCheckRecord.getOther_advice_description()?"":olderPeopleHealthCheckRecord.getOther_advice_description());
        if(null==olderPeopleHealthCheckRecord.getEat()){
            html = html.replace("${eat}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getEat();
            switch (sclera){
                case 1:html = html.replace("${eat}","    独立完成0-3分");break;
                case 2:html = html.replace("${eat}","    轻度依赖4-8分");break;
                case 3:html = html.replace("${eat}","    中度依赖9-18分");break;
                case 4:html = html.replace("${eat}","    不能自理≥19分");break;
                default:html = html.replace("${eat}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getWash()){
            html = html.replace("${wash}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getWash();
            switch (sclera){
                case 1:html = html.replace("${wash}","    独立完成0-3分");break;
                case 2:html = html.replace("${wash}","    轻度依赖4-8分");break;
                case 3:html = html.replace("${wash}","    中度依赖9-18分");break;
                case 4:html = html.replace("${wash}","    不能自理≥19分");break;
                default:html = html.replace("${wash}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getDress()){
            html = html.replace("${dress}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getDress();
            switch (sclera){
                case 1:html = html.replace("${dress}","    独立完成0-3分");break;
                case 2:html = html.replace("${dress}","    轻度依赖4-8分");break;
                case 3:html = html.replace("${dress}","    中度依赖9-18分");break;
                case 4:html = html.replace("${dress}","    不能自理≥19分");break;
                default:html = html.replace("${dress}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getToilet()){
            html = html.replace("${toilet}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getToilet();
            switch (sclera){
                case 1:html = html.replace("${toilet}","    独立完成0-3分");break;
                case 2:html = html.replace("${toilet}","    轻度依赖4-8分");break;
                case 3:html = html.replace("${toilet}","    中度依赖9-18分");break;
                case 4:html = html.replace("${toilet}","    不能自理≥19分");break;
                default:html = html.replace("${toilet}"," ");break;
            }
        }
        if(null==olderPeopleHealthCheckRecord.getActivity()){
            html = html.replace("${activity}"," ");
        }else {
            Integer sclera = olderPeopleHealthCheckRecord.getActivity();
            switch (sclera){
                case 1:html = html.replace("${activity}","    独立完成0-3分");break;
                case 2:html = html.replace("${activity}","    轻度依赖4-8分");break;
                case 3:html = html.replace("${activity}","    中度依赖9-18分");break;
                case 4:html = html.replace("${activity}","    能自理≥19分");break;
                default:html = html.replace("${activity}"," ");break;
            }
        }
        html = html.replace("${score}",null==olderPeopleHealthCheckRecord.getScore()?"":olderPeopleHealthCheckRecord.getScore()+"");
        String sign_wayStr="";
        String sign_time="";
        String sign_address="";
        String sign_imgs="";
        List<FollowupSign> followupSignDOs = followupSignDao.findByFollowupIdAndDel(Long.valueOf(olderPeopleHealthCheckRecord.getFollowup_id()),0);
        if (followupSignDOs.size()>0){
            FollowupSign followupSignDO = followupSignDOs.get(0);
            if (null!=followupSignDO){
                try {
                    switch (followupSignDO.getType()){
                        case "1":sign_wayStr="定位"; break;
                        case "2":sign_wayStr="拍照";break;
                        case "3":sign_wayStr="门牌";break;
                        default:sign_wayStr=" ";break;
                    }
                    sign_address = null==followupSignDO.getAddress()?" ":followupSignDO.getAddress();
                    if(StringUtils.isNotBlank(followupSignDO.getImg())) {
                        String imgs = followupSignDO.getImg();
                        String[] imgsArray;
                        if (imgs.contains(",")) {
                            imgsArray = imgs.split(",");
                        } else {
                            imgsArray = new String[]{imgs};
                        }
                        for (String img : imgsArray) {
                            sign_imgs += "<img width='80' height='100' src='" + imgUrlDomain + img + "' />&nbsp;";
                        }
                    }
                    sign_time = DateUtil.dateToStrLong(followupSignDO.getCreateTime());
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
        html = html.replace("${sign_way}",sign_wayStr);
        html = html.replace("${sign_time}",sign_time);
        html = html.replace("${sign_address}",sign_address);
        html = html.replace("${sigm_imgs}",sign_imgs);
        return html;
    }
    public String getSymptomName(String symptom){
        String symptomName="";
        switch (symptom){
            case "1": symptomName =  " 无症状 ";break;
            case "2": symptomName =  " 头痛 ";break;
            case "3": symptomName =  " 头晕 ";break;
            case "4": symptomName =  " 心悸 ";break;
            case "5": symptomName =  " 胸闷 ";break;
            case "6": symptomName =  " 胸痛 ";break;
            case "7": symptomName =  " 慢性咳嗽 ";break;
            case "8": symptomName =  " 咳痰 ";break;
            case "9": symptomName =  " 呼吸困难 ";break;
            case "10": symptomName =  "多饮 ";break;
            case "11": symptomName =  "多尿 ";break;
            case "12": symptomName =  "体重下降 ";break;
            case "13": symptomName =  "乏力 ";break;
            case "14": symptomName =  "关节肿痛 ";break;
            case "15": symptomName =  "视力模糊 ";break;
            case "16": symptomName =  "手脚麻木 ";break;
            case "17": symptomName =  "尿急 ";break;
            case "18": symptomName =  "尿痛 ";break;
            case "19": symptomName =  "便秘 ";break;
            case "20": symptomName =  "腹泻 ";break;
            case "21": symptomName =  "恶心呕吐 ";break;
            case "22": symptomName =  "眼花 ";break;
            case "23": symptomName =  "耳鸣 ";break;
            case "24": symptomName =  "乳房胀痛 ";break;
            case "25": symptomName =  "其他 ";break;
            default:symptomName=" ";break;
//    @Transactional
//    public void saveAllFollowupProjectData(String id, String followupProjectData) throws Exception {
//        JestClient jestClient = null;
//        try {
//
//
//            jestClient = elasticFactory.getJestClient();
//            //先根据条件查找出来
//            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//            searchSourceBuilder.query(
//                    new BoolQueryBuilder()
//                            .must(QueryBuilders.matchQuery("followup_id", id))
//            );
//
//            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
//                    .build();
//            SearchResult result = jestClient.execute(search);
//            List<FollowupContentESDO> followupContentESDOS = result.getSourceAsObjectList(FollowupContentESDO.class);
//
//            List<FollowupContentESDO> dataList = new ArrayList<>();
//            if(followupContentESDOS != null){
//                dataList.addAll(followupContentESDOS);
//                //删除原有记录
//                this.esDeleteFollowUpContent(dataList);
//            }
//
//            //保存新的随访详情信息
//            List<FollowupContentESDO> newdatalist = new ArrayList<>();
//            FollowupContentESDO followupContentESDO = new FollowupContentESDO();
//            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
//            followupContentESDO.setFollowup_id(id);
//            followupContentESDO.setCreate_time(new Date());
//            newdatalist.add(followupContentESDO);
//            elastricSearchSave.save(newdatalist, esIndex, esType);
//
//
//            //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
//            Followup followup = followupDao.findOne(Long.valueOf(id));
//            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);
//            }
//
//        } finally {
//            if (jestClient != null) {
//                jestClient.shutdownClient();
//            }
//        }
//    }
//    public File writeWordFile(List<Long> orderId, HttpServletResponse response) throws Exception {
//        String zipFileName = "入户访视详情";
//        long time = System.currentTimeMillis();
//        String exportConclusionList = time+"exportList";
//        String path = this.getClass().getResource("/").getPath() + exportConclusionList;
//        File file = new File(path);
//        // 删除文件夹、文件
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
//        System.out.println("创建文件夹时间:"+sdf.format(new Date()));
//        if (file.exists()) {
//            if (file != null){
//                DoorOrderService.deleteFolder(file);
//                file.mkdir();
//            }else {
//                file.delete();
//                file.mkdir();
//            }
//        }else {
//            file.mkdir();
//        }
//        int j =1;
//        long doorStart = System.currentTimeMillis();
//        long feeDetailStart = System.currentTimeMillis();
//        long feeDetailEnd = System.currentTimeMillis();
//
//        System.out.println("feeDetail用时:"+(feeDetailEnd-feeDetailStart)/1000);
//        System.out.println("开始生成Word:"+sdf.format(new Date()));
//        for (int i = 0; i < orderId.size(); i++) {
//            try {
//                Long followId = orderId.get(i);
//                Followup followup = followupDao.findOne(followId);
//                if (null==followup){
//                    continue;
//                }
//                if (!"8".equals(followup.getFollowupClass())){
//                    continue;
//                }
//
//                String fileName = "入户访视详情_"+followup.getPatientName()+"_"+followId+".doc";;
//                j = j + 1;
////            fileName = URLEncoder.encode(fileName, "utf-8");
//                fileName = java.net.URLEncoder.encode(fileName,"UTF-8");
//                fileName = java.net.URLDecoder.decode(fileName,"UTF-8");
////            response.setHeader("Content-Disposition", "attachment;filename=" + new String( fileName.getBytes(), "iso-8859-1"));
//                response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
//                String pathName = this.getClass().getResource("/").getPath() + "health_examination.mht";
//                Document doc = Jsoup.parse(new File(pathName), "UTF-8");
//                String html = this.handleHealthExamData(doc, orderId.get(i),followup);
//                if (StringUtils.isNotBlank(html)){
//                    BufferedWriter bw = new BufferedWriter(new FileWriter(path+"/"+fileName));//创建的文件
//                    bw.write(html);
//                    bw.close();
//                    File zipFile = new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
//                    if (zipFile.exists()) {
//                        zipFile.delete();
//                    }
//                }
//            }catch (Exception e){
//                e.printStackTrace();
//                continue;
//            }
//        }
//        System.out.println("Word生成结束:"+sdf.format(new Date()));
//        // 打包文件夹
//        if (FileUtil.fileToZip(path, path.replace(exportConclusionList, ""), zipFileName)) {
//            return new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
//        } else {
//            return null;
//        }
//    }
//    public String handleHealthExamData(Document doc, Long orderId, Followup followup) throws Exception {
//        String html = doc.toString();
//        //根据随访ID获取随访记录详情
//        OlderPeopleHealthCheckRecordES olderPeopleHealthCheckRecord = visitDetailService.getOlderPeopleHealthCheckRecord(orderId+"",null);
//        if (null==olderPeopleHealthCheckRecord){
//            return null;
//        }
//        html = html.replace("${patientName}", null==olderPeopleHealthCheckRecord.getName()?"":olderPeopleHealthCheckRecord.getName());
//        html = html.replace("${idcard}", null==olderPeopleHealthCheckRecord.getIdcard()?"":olderPeopleHealthCheckRecord.getIdcard());
//        html = html.replace("${number}", null==olderPeopleHealthCheckRecord.getNumber()?"":olderPeopleHealthCheckRecord.getNumber());
//        html = html.replace("${duty}", null==olderPeopleHealthCheckRecord.getDuty()?" ":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getDuty()));
//        html = html.replace("${responsibility_doctor_name}",olderPeopleHealthCheckRecord.getResponsibility_doctor_name());
//        if (null==olderPeopleHealthCheckRecord.getSymptom()){
//            html = html.replace("${symptom}"," ");
//        }else {
//            StringBuilder symptomName = new StringBuilder();
//            String symptom =  olderPeopleHealthCheckRecord.getSymptom();
//            String[] symptoms = symptom.split(",");
//            for (String tmp:symptoms){
//                symptomName.append(getSymptomName(tmp));
//            }
//            html = html.replace("${symptom}",symptomName.toString());
//        }
//        html = html.replace("${symptom_other}",olderPeopleHealthCheckRecord.getSymptom_other());
//        /**一般状况**/
//        html = html.replace("${temperature}",null==olderPeopleHealthCheckRecord.getTemperature()?" ":olderPeopleHealthCheckRecord.getTemperature()+"");
//        html = html.replace("${pulse_frequency}",olderPeopleHealthCheckRecord.getPulse_frequency());
//        html = html.replace("${breath_frequency}",olderPeopleHealthCheckRecord.getBreath_frequency());
//        html = html.replace("${blood_pressure_left_low}",null==olderPeopleHealthCheckRecord.getBlood_pressure_left_low()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_left_low()+"");
//        html = html.replace("${blood_pressure_left_high}",null==olderPeopleHealthCheckRecord.getBlood_pressure_left_high()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_left_high()+"");
//        html = html.replace("${blood_pressure_right_low}",null==olderPeopleHealthCheckRecord.getBlood_pressure_right_low()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_right_low()+"");
//        html = html.replace("${blood_pressure_right_high}",null==olderPeopleHealthCheckRecord.getBlood_pressure_right_high()?" ":olderPeopleHealthCheckRecord.getBlood_pressure_right_high()+"");
//        html = html.replace("${height}",null==olderPeopleHealthCheckRecord.getHeight()?" ":olderPeopleHealthCheckRecord.getHeight()+"");
//        html = html.replace("${weight}",null==olderPeopleHealthCheckRecord.getWeight()?" ":olderPeopleHealthCheckRecord.getWeight()+"");
//        html = html.replace("${waistline}",null==olderPeopleHealthCheckRecord.getWaistline()?" ":olderPeopleHealthCheckRecord.getWaistline()+"");
//        html = html.replace("${BMI}",null==olderPeopleHealthCheckRecord.getBMI()?" ":olderPeopleHealthCheckRecord.getBMI()+"");
//        if (null==olderPeopleHealthCheckRecord.getHealth_status()){
//            html = html.replace("${health_status}"," ");
//        }else {
//            Integer health_status = olderPeopleHealthCheckRecord.getHealth_status();
//            switch (health_status){
//                case 1:html = html.replace("${health_status}","满意");break;
//                case 2:html = html.replace("${health_status}","基本满意");break;
//                case 3:html = html.replace("${health_status}","说不清");break;
//                case 4:html = html.replace("${health_status}","不太满意");break;
//                case 5:html = html.replace("${health_status}","不满意");break;
//                default:html = html.replace("${health_status}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getSelfcare_ability()){
//            html = html.replace("${selfcare_ability}"," ");
//        }else {
//            Integer selfcare_ability = olderPeopleHealthCheckRecord.getSelfcare_ability();
//            switch (selfcare_ability){
//                case 1:html = html.replace("${selfcare_ability}","可自理(0~3)分");break;
//                case 2:html = html.replace("${selfcare_ability}","轻度依赖(4~8)分");break;
//                case 3:html = html.replace("${selfcare_ability}","中度依赖(9~18)分");break;
//                case 4:html = html.replace("${selfcare_ability}","不能自理(≥19)分");break;
//                default:html = html.replace("${selfcare_ability}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getCognitive_function()){
//            html = html.replace("${cognitive_function}"," ");
//        }else {
//            Integer cognitiveFunction = olderPeopleHealthCheckRecord.getCognitive_function();
//            switch (cognitiveFunction){
//                case 1:html = html.replace("${cognitive_function}","粗筛阴性");break;
//                case 2:html = html.replace("${cognitive_function}","粗筛阳性");break;
//                default:html = html.replace("${cognitive_function}"," ");break;
//            }
//        }
//        html = html.replace("${cognitive_function_score}",null==olderPeopleHealthCheckRecord.getCognitive_function_score()?" ":olderPeopleHealthCheckRecord.getCognitive_function_score()+"");
//        if (null==olderPeopleHealthCheckRecord.getEmotional_state()){
//            html = html.replace("${emotional_state}"," ");
//        }else {
//            Integer emotionalState = olderPeopleHealthCheckRecord.getEmotional_state();
//            switch (emotionalState){
//                case 1:html = html.replace("${emotional_state}","粗筛阴性");break;
//                case 2:html = html.replace("${emotional_state}","粗筛阳性");break;
//                default:html = html.replace("${emotional_state}"," ");break;
//            }
//        }
//        html = html.replace("${emotional_state_score}",null==olderPeopleHealthCheckRecord.getEmotional_state_score()?" ":olderPeopleHealthCheckRecord.getEmotional_state_score()+"");
//        /**体育锻炼**/
//        if (null==olderPeopleHealthCheckRecord.getExercise_frequency()){
//            html = html.replace("${exercise_frequency}"," ");
//        }else {
//            Integer exerciseFrequency = olderPeopleHealthCheckRecord.getExercise_frequency();
//            switch (exerciseFrequency){
//                case 1:html = html.replace("${exercise_frequency}","每天");break;
//                case 2:html = html.replace("${exercise_frequency}","每周一次以上");break;
//                case 3:html = html.replace("${exercise_frequency}","偶尔");break;
//                case 4:html = html.replace("${exercise_frequency}","不锻炼");break;
//                default:html = html.replace("${exercise_frequency}"," ");break;
//            }
//        }
//        html = html.replace("${exercise_time}",null==olderPeopleHealthCheckRecord.getExercise_time()?" ":olderPeopleHealthCheckRecord.getExercise_time()+"");
//        html = html.replace("${sustain_exercise_time}",null==olderPeopleHealthCheckRecord.getSustain_exercise_time()?" ":olderPeopleHealthCheckRecord.getSustain_exercise_time()+"");
//        html = html.replace("${exercise_type}",null==olderPeopleHealthCheckRecord.getExercise_type()?" ":olderPeopleHealthCheckRecord.getExercise_type()+"");
//        /**饮食习惯**/
//        if (null==olderPeopleHealthCheckRecord.getDietary_habit()){
//            html = html.replace("${dietary_habit}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getDietary_habit();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="荤素均衡 ";break;
//                    case "2":valueStrTmp+="荤食为主 ";break;
//                    case "3":valueStrTmp+="素食为主 ";break;
//                    case "4":valueStrTmp+="嗜盐 ";break;
//                    case "5":valueStrTmp+="嗜油 ";break;
//                    case "6":valueStrTmp+="嗜糖 ";break;
//                }
//            }
//            html = html.replace("${dietary_habit}",valueStrTmp);
//        }
//
//        /**吸烟情况**/
//        if (null==olderPeopleHealthCheckRecord.getSmoking_state()){
//            html = html.replace("${smoking_state}"," ");
//        }else {
//            Integer smokingState = olderPeopleHealthCheckRecord.getSmoking_state();
//            switch (smokingState){
//                case 1:html = html.replace("${smoking_state}","从不吸烟");break;
//                case 2:html = html.replace("${smoking_state}","已戒烟");break;
//                case 3:html = html.replace("${smoking_state}","吸烟");break;
//                default:html = html.replace("${smoking_state}"," ");break;
//            }
//        }
//        html = html.replace("${smoking_daily}",null==olderPeopleHealthCheckRecord.getSmoking_daily()?" ":olderPeopleHealthCheckRecord.getSmoking_daily()+"");
//        html = html.replace("${start_smoking_age}",null==olderPeopleHealthCheckRecord.getStart_smoking_age()?" ":olderPeopleHealthCheckRecord.getStart_smoking_age()+"");
//        html = html.replace("${stop_smoking_age}",null==olderPeopleHealthCheckRecord.getStop_smoking_age()?" ":olderPeopleHealthCheckRecord.getStop_smoking_age()+"");
//        /**饮酒情况**/
//        if (null==olderPeopleHealthCheckRecord.getDrinking_frequency()){
//            html = html.replace("${drinking_frequency}"," ");
//        }else {
//            Integer drinkingFrequency = olderPeopleHealthCheckRecord.getDrinking_frequency();
//            switch (drinkingFrequency){
//                case 1:html = html.replace("${drinking_frequency}","从不");break;
//                case 2:html = html.replace("${drinking_frequency}","偶尔");break;
//                case 3:html = html.replace("${drinking_frequency}","经常");break;
//                case 4:html = html.replace("${drinking_frequency}","每天");break;
//                default:html = html.replace("${drinking_frequency}"," ");break;
//            }
//        }
//        html = html.replace("${drinking_daily}",null==olderPeopleHealthCheckRecord.getDrinking_daily()?" ":olderPeopleHealthCheckRecord.getDrinking_daily()+"");
//
//        if (null==olderPeopleHealthCheckRecord.getIs_stop_drinking()){
//            html = html.replace("${is_stop_drinking}"," ");
//        }else {
//            Integer isStopDrinking = olderPeopleHealthCheckRecord.getIs_stop_drinking();
//            switch (isStopDrinking){
//                case 1:html = html.replace("${is_stop_drinking}","否");break;
//                case 2:html = html.replace("${is_stop_drinking}","是");break;
//                default:html = html.replace("${is_stop_drinking}"," ");break;
//            }
//        }
//        html = html.replace("${stop_drinking_age}",null==olderPeopleHealthCheckRecord.getStop_drinking_age()?" ":olderPeopleHealthCheckRecord.getStop_drinking_age()+"");
//        html = html.replace("${start_drinking_age}",null==olderPeopleHealthCheckRecord.getStart_drinking_age()?" ":olderPeopleHealthCheckRecord.getStart_drinking_age()+"");
//        if (null==olderPeopleHealthCheckRecord.getDrunkenness()){
//            html = html.replace("${drunkenness}"," ");
//        }else {
//            Integer drunkenness = olderPeopleHealthCheckRecord.getDrunkenness();
//            switch (drunkenness){
//                case 1:html = html.replace("${drunkenness}","是");break;
//                case 2:html = html.replace("${drunkenness}","否");break;
//                default:html = html.replace("${drunkenness}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getDrinking_type()){
//            html = html.replace("${drinking_type}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getDrinking_type();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="白酒 ";break;
//                    case "2":valueStrTmp+="啤酒 ";break;
//                    case "3":valueStrTmp+="红酒 ";break;
//                    case "4":valueStrTmp+="黄酒 ";break;
//                    case "5":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${drinking_type}",valueStrTmp);
//        }
//        html = html.replace("${other_drinking_type}",null==olderPeopleHealthCheckRecord.getOther_drinking_type()?" ":olderPeopleHealthCheckRecord.getOther_drinking_type());
//        /**职业病危害因素接触史**/
//        html = html.replace("${dust}",null==olderPeopleHealthCheckRecord.getDust()?" ":olderPeopleHealthCheckRecord.getDust());
//        if (null==olderPeopleHealthCheckRecord.getDust_protective_measures()){
//            html = html.replace("${dust_protective_measures}"," ");
//        }else {
//            Integer dustProtectiveMeasures = olderPeopleHealthCheckRecord.getDust_protective_measures();
//            switch (dustProtectiveMeasures){
//                case 1:html = html.replace("${dust_protective_measures}","无");break;
//                case 2:html = html.replace("${dust_protective_measures}","有");break;
//                default:html = html.replace("${dust_protective_measures}"," ");break;
//            }
//        }
//        html = html.replace("${dust_protective_measures_has}",null==olderPeopleHealthCheckRecord.getDust_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getDust_protective_measures_has());
//        html = html.replace("${radiogen}",null==olderPeopleHealthCheckRecord.getRadiogen()?" ":olderPeopleHealthCheckRecord.getRadiogen());
//        if (null==olderPeopleHealthCheckRecord.getRadiogen_protective_measures()){
//            html = html.replace("${radiogen_protective_measures}"," ");
//        }else {
//            Integer radiogenProtectiveMeasures = olderPeopleHealthCheckRecord.getRadiogen_protective_measures();
//            switch (radiogenProtectiveMeasures){
//                case 1:html = html.replace("${radiogen_protective_measures}","无");break;
//                case 2:html = html.replace("${radiogen_protective_measures}","有");break;
//                default:html = html.replace("${radiogen_protective_measures}"," ");break;
//            }
//        }
//        html = html.replace("${radiogen_protective_measures_has}",null==olderPeopleHealthCheckRecord.getRadiogen_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getRadiogen_protective_measures_has());
//        html = html.replace("${physical_factor}",null==olderPeopleHealthCheckRecord.getPhysical_factor()?" ":olderPeopleHealthCheckRecord.getPhysical_factor());
//        if (null==olderPeopleHealthCheckRecord.getPhysical_protective_measures()){
//            html = html.replace("${physical_protective_measures}"," ");
//        }else {
//            Integer physicalProtectiveMeasures   = olderPeopleHealthCheckRecord.getPhysical_protective_measures();
//            switch (physicalProtectiveMeasures){
//                case 1:html = html.replace("${physical_protective_measures}","无");break;
//                case 2:html = html.replace("${physical_protective_measures}","有");break;
//                default:html = html.replace("${physical_protective_measures}"," ");break;
//            }
//        }
//        html = html.replace("${physical_protective_measures_has}",null==olderPeopleHealthCheckRecord.getPhysical_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getPhysical_protective_measures_has());
//        html = html.replace("${chemical_factor}",null==olderPeopleHealthCheckRecord.getChemical_factor()?" ":olderPeopleHealthCheckRecord.getChemical_factor());
//        if (null==olderPeopleHealthCheckRecord.getChemical_protective_measures()){
//            html = html.replace("${chemical_protective_measures}"," ");
//        }else {
//            Integer chemicalProtectiveMeasures   = olderPeopleHealthCheckRecord.getChemical_protective_measures();
//            switch (chemicalProtectiveMeasures){
//                case 1:html = html.replace("${chemical_protective_measures}","无");break;
//                case 2:html = html.replace("${chemical_protective_measures}","有");break;
//                default:html = html.replace("${chemical_protective_measures}"," ");break;
//            }
//        }
//        html = html.replace("${chemical_protective_measures_has}",null==olderPeopleHealthCheckRecord.getChemical_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getChemical_protective_measures_has());
//        html = html.replace("${physical_protective_measures_has}",null==olderPeopleHealthCheckRecord.getPhysical_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getPhysical_protective_measures_has());
//        html = html.replace("${other_hazard_factors}",null==olderPeopleHealthCheckRecord.getOther_hazard_factors()?" ":olderPeopleHealthCheckRecord.getOther_hazard_factors());
//        if (null==olderPeopleHealthCheckRecord.getOther_hazard_protective_measures()){
//            html = html.replace("${other_hazard_protective_measures}"," ");
//        }else {
//            Integer other_hazard_protective_measures   = olderPeopleHealthCheckRecord.getOther_hazard_protective_measures();
//            switch (other_hazard_protective_measures){
//                case 1:html = html.replace("${other_hazard_protective_measures}","无");break;
//                case 2:html = html.replace("${other_hazard_protective_measures}","有");break;
//                default:html = html.replace("${other_hazard_protective_measures}"," ");break;
//            }
//        }
//        html = html.replace("${other_hazard_protective_measures_has}",null==olderPeopleHealthCheckRecord.getOther_hazard_protective_measures_has()?" ":olderPeopleHealthCheckRecord.getOther_hazard_protective_measures_has());
//        if (null==olderPeopleHealthCheckRecord.getLip()){
//            html = html.replace("${lip}"," ");
//        }else {
//            Integer lip = olderPeopleHealthCheckRecord.getLip();
//            switch (lip){
//                case 1:html = html.replace("${lip}","红润");break;
//                case 2:html = html.replace("${lip}","苍白");break;
//                case 3:html = html.replace("${lip}","发钳");break;
//                case 4:html = html.replace("${lip}","皲裂");break;
//                case 5:html = html.replace("${lip}","疱疹");break;
//                default:html = html.replace("${lip}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getDentition()){
//            html = html.replace("${dentition}"," ");
//        }else {
//            Integer dentition = olderPeopleHealthCheckRecord.getDentition();
//            switch (dentition){
//                case 1:html = html.replace("${dentition}","正常");break;
//                case 2:html = html.replace("${dentition}","缺齿");break;
//                case 3:html = html.replace("${dentition}","龋齿");break;
//                case 4:html = html.replace("${dentition}","义齿,假牙");break;
//                default:html = html.replace("${dentition}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getOropharynx()){
//            html = html.replace("${oropharynx}"," ");
//        }else {
//            Integer oropharynx = olderPeopleHealthCheckRecord.getOropharynx();
//            switch (oropharynx){
//                case 1:html = html.replace("${oropharynx}","无充血");break;
//                case 2:html = html.replace("${oropharynx}","充血");break;
//                case 3:html = html.replace("${oropharynx}","淋巴滤泡增生");break;
//                default:html = html.replace("${oropharynx}"," ");break;
//            }
//        }
//        html = html.replace("${left_eyesight}",null==olderPeopleHealthCheckRecord.getLeft_eyesight()?"":olderPeopleHealthCheckRecord.getLeft_eyesight()+"");
//        html = html.replace("${right_eyesight}",null==olderPeopleHealthCheckRecord.getRight_eyesight()?"":olderPeopleHealthCheckRecord.getRight_eyesight()+"");
//        html = html.replace("${left_correctional_eyesight}",null==olderPeopleHealthCheckRecord.getLeft_correctional_eyesight()?"":olderPeopleHealthCheckRecord.getLeft_correctional_eyesight()+"");
//        html = html.replace("${right_correctional_eyesight}",null==olderPeopleHealthCheckRecord.getRight_correctional_eyesight()?"":olderPeopleHealthCheckRecord.getRight_correctional_eyesight()+"");
//        if (null==olderPeopleHealthCheckRecord.getHearing()){
//            html = html.replace("${hearing}"," ");
//        }else {
//            Integer hearing = olderPeopleHealthCheckRecord.getHearing();
//            switch (hearing){
//                case 1:html = html.replace("${hearing}","听见");break;
//                case 2:html = html.replace("${hearing}","听不清或无法听见");break;
//                default:html = html.replace("${hearing}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getMotor_function()){
//            html = html.replace("${motor_function}"," ");
//        }else {
//            Integer motor_function = olderPeopleHealthCheckRecord.getMotor_function();
//            switch (motor_function){
//                case 1:html = html.replace("${motor_function}","可顺利完成");break;
//                case 2:html = html.replace("${motor_function}","无法独立完成任何一个动作");break;
//                default:html = html.replace("${motor_function}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getFundus()){
//            html = html.replace("${fundus}"," ");
//        }else {
//            Integer function = olderPeopleHealthCheckRecord.getFundus();
//            switch (function){
//                case 1:html = html.replace("${fundus}","正常");break;
//                case 2:html = html.replace("${fundus}","异常");break;
//                default:html = html.replace("${fundus}"," ");break;
//            }
//        }
//        html = html.replace("${fundus_abnormal}",null==olderPeopleHealthCheckRecord.getFundus_abnormal()?"":olderPeopleHealthCheckRecord.getFundus_abnormal());
//        if (null==olderPeopleHealthCheckRecord.getSkin()){
//            html = html.replace("${skin}"," ");
//        }else {
//            Integer skin = olderPeopleHealthCheckRecord.getSkin();
//            switch (skin){
//                case 1:html = html.replace("${skin}","正常");break;
//                case 2:html = html.replace("${skin}","潮红");break;
//                case 3:html = html.replace("${skin}","苍白");break;
//                case 4:html = html.replace("${skin}","发钳");break;
//                case 5:html = html.replace("${skin}","黄染");break;
//                case 6:html = html.replace("${skin}","色素沉着");break;
//                case 7:html = html.replace("${skin}","其他");break;
//                default:html = html.replace("${skin}"," ");break;
//            }
//        }
//        html = html.replace("${skin_other}",null==olderPeopleHealthCheckRecord.getSkin_other()?"":olderPeopleHealthCheckRecord.getSkin_other());
//        if (null==olderPeopleHealthCheckRecord.getSclera()){
//            html = html.replace("${sclera}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getSclera();
//            switch (sclera){
//                case 1:html = html.replace("${sclera}","正常");break;
//                case 2:html = html.replace("${sclera}","黄染");break;
//                case 3:html = html.replace("${sclera}","充血");break;
//                case 4:html = html.replace("${sclera}","其他");break;
//                default:html = html.replace("${sclera}"," ");break;
//            }
//        }
//        html = html.replace("${sclera_other}",null==olderPeopleHealthCheckRecord.getSclera_other()?"":olderPeopleHealthCheckRecord.getSclera_other());
//        if (null==olderPeopleHealthCheckRecord.getLymphaden()){
//            html = html.replace("${lymphaden}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getLymphaden();
//            switch (sclera){
//                case 1:html = html.replace("${lymphaden}","未触及");break;
//                case 2:html = html.replace("${lymphaden}","锁骨上");break;
//                case 3:html = html.replace("${lymphaden}","腋窝");break;
//                case 4:html = html.replace("${lymphaden}","其他");break;
//                default:html = html.replace("${lymphaden}"," ");break;
//            }
//        }
//        html = html.replace("${lymphaden_other}",null==olderPeopleHealthCheckRecord.getLymphaden_other()?"":olderPeopleHealthCheckRecord.getLymphaden_other());
//        if (null==olderPeopleHealthCheckRecord.getBarrel_chest()){
//            html = html.replace("${barrel_chest}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getBarrel_chest();
//            switch (sclera){
//                case 1:html = html.replace("${barrel_chest}","否");break;
//                case 2:html = html.replace("${barrel_chest}","是");break;
//                default:html = html.replace("${barrel_chest}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getBreath_sounds()){
//            html = html.replace("${breath_sounds}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getBreath_sounds();
//            switch (sclera){
//                case 1:html = html.replace("${breath_sounds}","正常");break;
//                case 2:html = html.replace("${breath_sounds}","异常");break;
//                default:html = html.replace("${breath_sounds}"," ");break;
//            }
//        }
//        html = html.replace("${breath_sounds_abnormal}",null==olderPeopleHealthCheckRecord.getBreath_sounds_abnormal()?"":olderPeopleHealthCheckRecord.getBreath_sounds_abnormal());
//        if (null==olderPeopleHealthCheckRecord.getRale()){
//            html = html.replace("${rale}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getRale();
//            switch (sclera){
//                case 1:html = html.replace("${rale}","无");break;
//                case 2:html = html.replace("${rale}","干罗音");break;
//                case 3:html = html.replace("${rale}","湿罗音");break;
//                case 4:html = html.replace("${rale}","其他");break;
//                default:html = html.replace("${rale}"," ");break;
//            }
//        }
//        html = html.replace("${rale_abnormal}",null==olderPeopleHealthCheckRecord.getRale_abnormal()?"":olderPeopleHealthCheckRecord.getRale_abnormal());
//        html = html.replace("${heart_rate}",null==olderPeopleHealthCheckRecord.getHeart_rate()?"":olderPeopleHealthCheckRecord.getHeart_rate()+"");
//        if (null==olderPeopleHealthCheckRecord.getHeart_rhythm()){
//            html = html.replace("${heart_rhythm}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getHeart_rhythm();
//            switch (sclera){
//                case 1:html = html.replace("${heart_rhythm}","齐");break;
//                case 2:html = html.replace("${heart_rhythm}","不齐");break;
//                case 3:html = html.replace("${heart_rhythm}","绝对不齐");break;
//                default:html = html.replace("${heart_rhythm}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getHeart_noise()){
//            html = html.replace("${heart_noise}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getHeart_noise();
//            switch (sclera){
//                case 1:html = html.replace("${heart_noise}","无");break;
//                case 2:html = html.replace("${heart_noise}","有");break;
//                default:html = html.replace("${heart_noise}"," ");break;
//            }
//        }
//        html = html.replace("${heart_noise_has}",null==olderPeopleHealthCheckRecord.getHeart_noise_has()?"":olderPeopleHealthCheckRecord.getHeart_noise_has());
//        if (null==olderPeopleHealthCheckRecord.getAbdominal_tenderness()){
//            html = html.replace("${abdominal_tenderness}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_tenderness();
//            switch (sclera){
//                case 1:html = html.replace("${abdominal_tenderness}","无");break;
//                case 2:html = html.replace("${abdominal_tenderness}","有");break;
//                default:html = html.replace("${abdominal_tenderness}"," ");break;
//            }
//        }
//        html = html.replace("${tenderness_has}",null==olderPeopleHealthCheckRecord.getTenderness_has()?"":olderPeopleHealthCheckRecord.getTenderness_has());
//        if (null==olderPeopleHealthCheckRecord.getAbdominal_mass()){
//            html = html.replace("${abdominal_mass}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_mass();
//            switch (sclera){
//                case 1:html = html.replace("${abdominal_mass}","无");break;
//                case 2:html = html.replace("${abdominal_mass}","有");break;
//                default:html = html.replace("${abdominal_mass}"," ");break;
//            }
//        }
//        html = html.replace("${mass_has}",null==olderPeopleHealthCheckRecord.getMass_has()?"":olderPeopleHealthCheckRecord.getMass_has());
//        if (null==olderPeopleHealthCheckRecord.getAbdominal_hepatomegaly()){
//            html = html.replace("${abdominal_hepatomegaly}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_hepatomegaly();
//            switch (sclera){
//                case 1:html = html.replace("${abdominal_hepatomegaly}","无");break;
//                case 2:html = html.replace("${abdominal_hepatomegaly}","有");break;
//                default:html = html.replace("${abdominal_hepatomegaly}"," ");break;
//            }
//        }
//        html = html.replace("${hepatomegaly_has}",null==olderPeopleHealthCheckRecord.getHepatomegaly_has()?"":olderPeopleHealthCheckRecord.getHepatomegaly_has());
//        if (null==olderPeopleHealthCheckRecord.getAbdominal_spleen_big()){
//            html = html.replace("${abdominal_spleen_big}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_spleen_big();
//            switch (sclera){
//                case 1:html = html.replace("${abdominal_spleen_big}","无");break;
//                case 2:html = html.replace("${abdominal_spleen_big}","有");break;
//                default:html = html.replace("${abdominal_spleen_big}"," ");break;
//            }
//        }
//        html = html.replace("${spleen_big_has}",null==olderPeopleHealthCheckRecord.getSpleen_big_has()?"":olderPeopleHealthCheckRecord.getSpleen_big_has());
//        if (null==olderPeopleHealthCheckRecord.getAbdominal_shifting_dullness()){
//            html = html.replace("${abdominal_shifting_dullness}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAbdominal_shifting_dullness();
//            switch (sclera){
//                case 1:html = html.replace("${abdominal_shifting_dullness}","无");break;
//                case 2:html = html.replace("${abdominal_shifting_dullness}","有");break;
//                default:html = html.replace("${abdominal_shifting_dullness}"," ");break;
//            }
//        }
//        html = html.replace("${shifting_dullness_has}",null==olderPeopleHealthCheckRecord.getShifting_dullness_has()?"":olderPeopleHealthCheckRecord.getShifting_dullness_has());
//        if (null==olderPeopleHealthCheckRecord.getCrura_edema()){
//            html = html.replace("${crura_edema}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getCrura_edema();
//            switch (sclera){
//                case 1:html = html.replace("${crura_edema}","无");break;
//                case 2:html = html.replace("${crura_edema}","单侧");break;
//                case 3:html = html.replace("${crura_edema}","双侧不对称");break;
//                case 4:html = html.replace("${crura_edema}","双侧对称");break;
//                default:html = html.replace("${crura_edema}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getDorsal_foot_pulse()){
//            html = html.replace("${dorsal_foot_pulse}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getDorsal_foot_pulse();
//            switch (sclera){
//                case 1:html = html.replace("${dorsal_foot_pulse}","未接触");break;
//                case 2:html = html.replace("${dorsal_foot_pulse}","触及双侧对称");break;
//                case 3:html = html.replace("${dorsal_foot_pulse}","触及左侧弱或消失");break;
//                case 4:html = html.replace("${dorsal_foot_pulse}","触及右侧弱或消失");break;
//                default:html = html.replace("${dorsal_foot_pulse}"," ");break;
//            }
//        }
//        if (null==olderPeopleHealthCheckRecord.getAnus_dre()){
//            html = html.replace("${anus_dre}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAnus_dre();
//            switch (sclera){
//                case 1:html = html.replace("${anus_dre}","未见异常");break;
//                case 2:html = html.replace("${anus_dre}","触痛");break;
//                case 3:html = html.replace("${anus_dre}","包块");break;
//                case 4:html = html.replace("${anus_dre}","前列腺异常");break;
//                case 5:html = html.replace("${anus_dre}","其他");break;
//                default:html = html.replace("${anus_dre}"," ");break;
//            }
//        }
//        html = html.replace("${anus_dre_other}",null==olderPeopleHealthCheckRecord.getAnus_dre_other()?"":olderPeopleHealthCheckRecord.getAnus_dre_other());
//        if (null==olderPeopleHealthCheckRecord.getBreast()){
//            html = html.replace("${breast}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getBreast();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="未见异常 ";break;
//                    case "2":valueStrTmp+="乳房切除 ";break;
//                    case "3":valueStrTmp+="异常泌乳 ";break;
//                    case "4":valueStrTmp+="乳腺包块 ";break;
//                    case "5":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${breast}",valueStrTmp);
//        }
//        html = html.replace("${breast_other}",null==olderPeopleHealthCheckRecord.getBreast_other()?"":olderPeopleHealthCheckRecord.getBreast_other());
//        if (null==olderPeopleHealthCheckRecord.getVulva()){
//            html = html.replace("${vulva}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getVulva();
//            switch (sclera){
//                case 1:html = html.replace("${vulva}","未见异常");break;
//                case 2:html = html.replace("${vulva}","异常");break;
//                default:html = html.replace("${vulva}"," ");break;
//            }
//        }
//        html = html.replace("${vulva_abnormal}",null==olderPeopleHealthCheckRecord.getVulva_abnormal()?"":olderPeopleHealthCheckRecord.getVulva_abnormal());
//        if (null==olderPeopleHealthCheckRecord.getVagina()){
//            html = html.replace("${vagina}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getVagina();
//            switch (sclera){
//                case 1:html = html.replace("${vagina}","未见异常");break;
//                case 2:html = html.replace("${vagina}","异常");break;
//                default:html = html.replace("${vagina}"," ");break;
//            }
//        }
//        html = html.replace("${vagina_abnormal}",null==olderPeopleHealthCheckRecord.getVagina_abnormal()?"":olderPeopleHealthCheckRecord.getVagina_abnormal());
//        if (null==olderPeopleHealthCheckRecord.getCervical()){
//            html = html.replace("${cervical}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getCervical();
//            switch (sclera){
//                case 1:html = html.replace("${cervical}","未见异常");break;
//                case 2:html = html.replace("${cervical}","异常");break;
//                default:html = html.replace("${cervical}"," ");break;
//            }
//        }
//        html = html.replace("${cervical_abnormal}",null==olderPeopleHealthCheckRecord.getCervical_abnormal()?"":olderPeopleHealthCheckRecord.getCervical_abnormal());
//        if (null==olderPeopleHealthCheckRecord.getCorpus()){
//            html = html.replace("${corpus}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getCorpus();
//            switch (sclera){
//                case 1:html = html.replace("${corpus}","未见异常");break;
//                case 2:html = html.replace("${corpus}","异常");break;
//                default:html = html.replace("${corpus}"," ");break;
//            }
//        }
//        html = html.replace("${corpus_abnormal}",null==olderPeopleHealthCheckRecord.getCorpus_abnormal()?"":olderPeopleHealthCheckRecord.getCorpus_abnormal());
//        if (null==olderPeopleHealthCheckRecord.getGynecologic_appendix()){
//            html = html.replace("${gynecologic_appendix}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getGynecologic_appendix();
//            switch (sclera){
//                case 1:html = html.replace("${gynecologic_appendix}","未见异常");break;
//                case 2:html = html.replace("${gynecologic_appendix}","异常");break;
//                default:html = html.replace("${gynecologic_appendix}"," ");break;
//            }
//        }
//        html = html.replace("${appendix_abnormal}",null==olderPeopleHealthCheckRecord.getAppendix_abnormal()?"":olderPeopleHealthCheckRecord.getAppendix_abnormal());
//        html = html.replace("${physical_examination_other}",null==olderPeopleHealthCheckRecord.getPhysical_examination_other()?"":olderPeopleHealthCheckRecord.getPhysical_examination_other());
//        html = html.replace("${hemoglobin}",null==olderPeopleHealthCheckRecord.getHemoglobin()?"":olderPeopleHealthCheckRecord.getHemoglobin()+"");
//        html = html.replace("${leukocyte}",null==olderPeopleHealthCheckRecord.getLeukocyte()?"":olderPeopleHealthCheckRecord.getLeukocyte()+"");
//        html = html.replace("${thrombocyte}",null==olderPeopleHealthCheckRecord.getThrombocyte()?"":olderPeopleHealthCheckRecord.getThrombocyte()+"");
//        html = html.replace("${blood_routine_other}",null==olderPeopleHealthCheckRecord.getBlood_routine_other()?"":olderPeopleHealthCheckRecord.getBlood_routine_other()+"");
//        html = html.replace("${urine_protein}",null==olderPeopleHealthCheckRecord.getUrine_protein()?"":olderPeopleHealthCheckRecord.getUrine_protein()+"");
//        html = html.replace("${urine_sugar}",null==olderPeopleHealthCheckRecord.getUrine_sugar()?"":olderPeopleHealthCheckRecord.getUrine_sugar()+"");
//        html = html.replace("${urine_acetone_bodies}",null==olderPeopleHealthCheckRecord.getUrine_acetone_bodies()?"":olderPeopleHealthCheckRecord.getUrine_acetone_bodies()+"");
//        html = html.replace("${urine_occult_blood}",null==olderPeopleHealthCheckRecord.getUrine_occult_blood()?"":olderPeopleHealthCheckRecord.getUrine_occult_blood()+"");
//        html = html.replace("${urine_routine_other}",null==olderPeopleHealthCheckRecord.getUrine_routine_other()?"":olderPeopleHealthCheckRecord.getUrine_routine_other()+"");
//        html = html.replace("${fasting_blood_glucose_L}",null==olderPeopleHealthCheckRecord.getFasting_blood_glucose_L()?"":olderPeopleHealthCheckRecord.getFasting_blood_glucose_L()+"");
//        html = html.replace("${fasting_blood_glucose_dL}",null==olderPeopleHealthCheckRecord.getFasting_blood_glucose_dL()?"":olderPeopleHealthCheckRecord.getFasting_blood_glucose_dL()+"");
//        if (null==olderPeopleHealthCheckRecord.getElectrocardiogram()){
//            html = html.replace("${electrocardiogram}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getElectrocardiogram();
//            switch (sclera){
//                case 1:html = html.replace("${electrocardiogram}","正常");break;
//                case 2:html = html.replace("${electrocardiogram}","异常");break;
//                default:html = html.replace("${electrocardiogram}"," ");break;
//            }
//        }
//        html = html.replace("${electrocardiogram_abnormal}",null==olderPeopleHealthCheckRecord.getElectrocardiogram_abnormal()?"":olderPeopleHealthCheckRecord.getElectrocardiogram_abnormal()+"");
//        html = html.replace("${microalbuminuria}",null==olderPeopleHealthCheckRecord.getMicroalbuminuria()?"":olderPeopleHealthCheckRecord.getMicroalbuminuria()+"");
//        if(null==olderPeopleHealthCheckRecord.getOccult_blood_in_stool()){
//            html = html.replace("${occult_blood_in_stool}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getOccult_blood_in_stool();
//            switch (sclera){
//                case 1:html = html.replace("${occult_blood_in_stool}","阴性");break;
//                case 2:html = html.replace("${occult_blood_in_stool}","阳性");break;
//                default:html = html.replace("${occult_blood_in_stool}"," ");break;
//            }
//        }
//        html = html.replace("${glycated_hemoglobin}",null==olderPeopleHealthCheckRecord.getGlycated_hemoglobin()?"":olderPeopleHealthCheckRecord.getGlycated_hemoglobin()+"");
//        if(null==olderPeopleHealthCheckRecord.getHBsAg()){
//            html = html.replace("${HBsAg}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getHBsAg();
//            switch (sclera){
//                case 1:html = html.replace("${HBsAg}","阴性");break;
//                case 2:html = html.replace("${HBsAg}","阳性");break;
//                default:html = html.replace("${HBsAg}"," ");break;
//            }
//        }
//        html = html.replace("${ALT}",null==olderPeopleHealthCheckRecord.getALT()?"":olderPeopleHealthCheckRecord.getALT()+"");
//        html = html.replace("${SGOT}",null==olderPeopleHealthCheckRecord.getSGOT()?"":olderPeopleHealthCheckRecord.getSGOT()+"");
//        html = html.replace("${albumin}",null==olderPeopleHealthCheckRecord.getAlbumin()?"":olderPeopleHealthCheckRecord.getAlbumin()+"");
//        html = html.replace("${total_bilirubin}",null==olderPeopleHealthCheckRecord.getTotal_bilirubin()?"":olderPeopleHealthCheckRecord.getTotal_bilirubin()+"");
//        html = html.replace("${conjugated_bilirubin}",null==olderPeopleHealthCheckRecord.getConjugated_bilirubin()?"":olderPeopleHealthCheckRecord.getConjugated_bilirubin()+"");
//        html = html.replace("${serum_creatinine}",null==olderPeopleHealthCheckRecord.getConjugated_bilirubin()?"":olderPeopleHealthCheckRecord.getConjugated_bilirubin()+"");
//        html = html.replace("${blood_urea_nitrogen}",null==olderPeopleHealthCheckRecord.getBlood_urea_nitrogen()?"":olderPeopleHealthCheckRecord.getBlood_urea_nitrogen()+"");
//        html = html.replace("${blood_potassium_concentration}",null==olderPeopleHealthCheckRecord.getBlood_potassium_concentration()?"":olderPeopleHealthCheckRecord.getBlood_potassium_concentration()+"");
//        html = html.replace("${blood_Na_concentration}",null==olderPeopleHealthCheckRecord.getBlood_Na_concentration()?"":olderPeopleHealthCheckRecord.getBlood_Na_concentration()+"");
//        html = html.replace("${uric_acid}",null==olderPeopleHealthCheckRecord.getUric_acid()?"":olderPeopleHealthCheckRecord.getUric_acid()+"");
//        html = html.replace("${total_cholesterol}",null==olderPeopleHealthCheckRecord.getTotal_cholesterol()?"":olderPeopleHealthCheckRecord.getTotal_cholesterol()+"");
//        html = html.replace("${triglyceride}",null==olderPeopleHealthCheckRecord.getTriglyceride()?"":olderPeopleHealthCheckRecord.getTriglyceride()+"");
//        html = html.replace("${LDL_cholesterol}",null==olderPeopleHealthCheckRecord.getLDL_cholesterol()?"":olderPeopleHealthCheckRecord.getLDL_cholesterol()+"");
//        html = html.replace("${HDL_cholesterol}",null==olderPeopleHealthCheckRecord.getHDL_cholesterol()?"":olderPeopleHealthCheckRecord.getHDL_cholesterol()+"");
//        html = html.replace("${alpha_fetal_protein}",null==olderPeopleHealthCheckRecord.getAlpha_fetal_protein()?"":olderPeopleHealthCheckRecord.getAlpha_fetal_protein()+"");
//        if(null==olderPeopleHealthCheckRecord.getChest_Xray()){
//            html = html.replace("${chest_Xray}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getChest_Xray();
//            switch (sclera){
//                case 1:html = html.replace("${chest_Xray}","正常");break;
//                case 2:html = html.replace("${chest_Xray}","异常");break;
//                default:html = html.replace("${chest_Xray}"," ");break;
//            }
//        }
//        html = html.replace("${chest_Xray_abnormal}",null==olderPeopleHealthCheckRecord.getChest_Xray_abnormal()?"":olderPeopleHealthCheckRecord.getChest_Xray_abnormal());
//        if(null==olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic()){
//            html = html.replace("${abdomen_B_ultrasonic}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic();
//            switch (sclera){
//                case 1:html = html.replace("${abdomen_B_ultrasonic}","正常");break;
//                case 2:html = html.replace("${abdomen_B_ultrasonic}","异常");break;
//                default:html = html.replace("${abdomen_B_ultrasonic}"," ");break;
//            }
//        }
//        html = html.replace("${abdomen_B_ultrasonic_abnormal}",null==olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic_abnormal()?"":olderPeopleHealthCheckRecord.getAbdomen_B_ultrasonic_abnormal());
//        if(null==olderPeopleHealthCheckRecord.getB_ultrasonic_other()){
//            html = html.replace("${B_ultrasonic_other}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getB_ultrasonic_other();
//            switch (sclera){
//                case 1:html = html.replace("${B_ultrasonic_other}","正常");break;
//                case 2:html = html.replace("${B_ultrasonic_other}","异常");break;
//                default:html = html.replace("${B_ultrasonic_other}"," ");break;
//            }
//        }
//        html = html.replace("${B_ultrasonic_other_abnormal}",null==olderPeopleHealthCheckRecord.getB_ultrasonic_other_abnormal()?"":olderPeopleHealthCheckRecord.getB_ultrasonic_other_abnormal());
//        if(null==olderPeopleHealthCheckRecord.getCervical_smear()){
//            html = html.replace("${cervical_smear}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getCervical_smear();
//            switch (sclera){
//                case 1:html = html.replace("${cervical_smear}","正常");break;
//                case 2:html = html.replace("${cervical_smear}","异常");break;
//                default:html = html.replace("${cervical_smear}"," ");break;
//            }
//        }
//        html = html.replace("${cervical_smear_abnormal}",null==olderPeopleHealthCheckRecord.getCervical_smear_abnormal()?"":olderPeopleHealthCheckRecord.getCervical_smear_abnormal());
//        html = html.replace("${auxiliary_examination_other}",null==olderPeopleHealthCheckRecord.getAuxiliary_examination_other()?"":olderPeopleHealthCheckRecord.getAuxiliary_examination_other());
//        if(null==olderPeopleHealthCheckRecord.getMild_physical()){
//            html = html.replace("${mild_physical}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMild_physical();
//            switch (sclera){
//                case 1:html = html.replace("${mild_physical}","是");break;
//                case 2:html = html.replace("${mild_physical}","倾向是");break;
//                default:html = html.replace("${mild_physical}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getQi_deficiency()){
//            html = html.replace("${qi_deficiency}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getQi_deficiency();
//            switch (sclera){
//                case 1:html = html.replace("${qi_deficiency}","是");break;
//                case 2:html = html.replace("${qi_deficiency}","基本是");break;
//                default:html = html.replace("${qi_deficiency}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getYang_deficiency()){
//            html = html.replace("${yang_deficiency}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getYang_deficiency();
//            switch (sclera){
//                case 1:html = html.replace("${yang_deficiency}","是");break;
//                case 2:html = html.replace("${yang_deficiency}","基本是");break;
//                default:html = html.replace("${yang_deficiency}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getYin_deficiency()){
//            html = html.replace("${yin_deficiency}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getYin_deficiency();
//            switch (sclera){
//                case 1:html = html.replace("${yin_deficiency}","是");break;
//                case 2:html = html.replace("${yin_deficiency}","基本是");break;
//                default:html = html.replace("${yin_deficiency}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getPhlegm_dampness()){
//            html = html.replace("${phlegm_dampness}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getPhlegm_dampness();
//            switch (sclera){
//                case 1:html = html.replace("${phlegm_dampness}","是");break;
//                case 2:html = html.replace("${phlegm_dampness}","基本是");break;
//                default:html = html.replace("${phlegm_dampness}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getDampness_heat()){
//            html = html.replace("${dampness_heat}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getDampness_heat();
//            switch (sclera){
//                case 1:html = html.replace("${dampness_heat}","是");break;
//                case 2:html = html.replace("${dampness_heat}","基本是");break;
//                default:html = html.replace("${dampness_heat}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getBlood_stasis()){
//            html = html.replace("${blood_stasis}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getBlood_stasis();
//            switch (sclera){
//                case 1:html = html.replace("${blood_stasis}","是");break;
//                case 2:html = html.replace("${blood_stasis}","基本是");break;
//                default:html = html.replace("${blood_stasis}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getLogistic_regression()){
//            html = html.replace("${logistic_regression}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getLogistic_regression();
//            switch (sclera){
//                case 1:html = html.replace("${logistic_regression}","是");break;
//                case 2:html = html.replace("${logistic_regression}","基本是");break;
//                default:html = html.replace("${logistic_regression}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getGrasp_quality()){
//            html = html.replace("${grasp_quality}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getGrasp_quality();
//            switch (sclera){
//                case 1:html = html.replace("${grasp_quality}","是");break;
//                case 2:html = html.replace("${grasp_quality}","基本是");break;
//                default:html = html.replace("${grasp_quality}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getCerebrovascular_disease()){
//            html = html.replace("${cerebrovascular_disease}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getCerebrovascular_disease();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="未发现 ";break;
//                    case "2":valueStrTmp+="缺血性卒中 ";break;
//                    case "3":valueStrTmp+="脑出血 ";break;
//                    case "4":valueStrTmp+="蛛网膜下腔出血 ";break;
//                    case "5":valueStrTmp+="短暂性脑缺血发作 ";break;
//                    case "6":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${cerebrovascular_disease}",valueStrTmp);
//        }
//        html = html.replace("${cerebrovascular_disease_other}",null==olderPeopleHealthCheckRecord.getCerebrovascular_disease_other()?"":olderPeopleHealthCheckRecord.getCerebrovascular_disease_other());
//        if(null==olderPeopleHealthCheckRecord.getNephropathy()){
//            html = html.replace("${nephropathy}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getNephropathy();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="未发现 ";break;
//                    case "2":valueStrTmp+="糖尿病肾病 ";break;
//                    case "3":valueStrTmp+="肾功能衰竭 ";break;
//                    case "4":valueStrTmp+="急性肾炎 ";break;
//                    case "5":valueStrTmp+="慢性肾炎 ";break;
//                    case "6":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${nephropathy}",valueStrTmp);
//
//        }
//        html = html.replace("${nephropathy_other}",null==olderPeopleHealthCheckRecord.getNephropathy_other()?"":olderPeopleHealthCheckRecord.getNephropathy_other());
//        if(null==olderPeopleHealthCheckRecord.getHeart_disease()){
//                    html = html.replace("${heart_disease}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getHeart_disease();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="未发现 ";break;
//                    case "2":valueStrTmp+="心肌梗死 ";break;
//                    case "3":valueStrTmp+="心绞痛 ";break;
//                    case "4":valueStrTmp+="冠状动脉血运重建 ";break;
//                    case "5":valueStrTmp+="充血性心力衰竭 ";break;
//                    case "6":valueStrTmp+="心前区疼痛 ";break;
//                    case "7":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${heart_disease}",valueStrTmp);
//        }
//        html = html.replace("${heart_disease_other}",null==olderPeopleHealthCheckRecord.getHeart_disease_other()?"":olderPeopleHealthCheckRecord.getHeart_disease_other());
//        if(null==olderPeopleHealthCheckRecord.getVascular_disease()){
//                    html = html.replace("${vascular_disease}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getVascular_disease();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="未发现 ";break;
//                    case "2":valueStrTmp+="夹层动脉瘤 ";break;
//                    case "3":valueStrTmp+="动脉闭塞性疾病 ";break;
//                    case "4":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${vascular_disease}",valueStrTmp);
//
//        }
//        html = html.replace("${vascular_disease_other}",null==olderPeopleHealthCheckRecord.getVascular_disease_other()?"":olderPeopleHealthCheckRecord.getVascular_disease_other());
//        if(null==olderPeopleHealthCheckRecord.getEye_disease()){
//            html = html.replace("${eye_disease}"," ");
//        }else {
//            String smokingState = olderPeopleHealthCheckRecord.getEye_disease();
//            String[] smokingStates = smokingState.split(",");
//            String valueStrTmp = " ";
//            for (String tmp:smokingStates){
//                switch (tmp){
//                    case "1":valueStrTmp+="未发现 ";break;
//                    case "2":valueStrTmp+="视网膜出血或渗出 ";break;
//                    case "3":valueStrTmp+="视乳头水肿 ";break;
//                    case "4":valueStrTmp+="白内障 ";break;
//                    case "5":valueStrTmp+="其他 ";break;
//                }
//            }
//            html = html.replace("${eye_disease}",valueStrTmp);
//
//        }
//        html = html.replace("${eye_disease_other}",null==olderPeopleHealthCheckRecord.getEye_disease_other()?"":olderPeopleHealthCheckRecord.getEye_disease_other());
//        if(null==olderPeopleHealthCheckRecord.getNervous_system_disease()){
//            html = html.replace("${nervous_system_disease}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getNervous_system_disease();
//            switch (sclera){
//                case 1:html = html.replace("${nervous_system_disease}","未发现");break;
//                case 2:html = html.replace("${nervous_system_disease}","有");break;
//                default:html = html.replace("${nervous_system_disease}"," ");break;
//            }
//        }
//        html = html.replace("${nervous_system_disease_has}",null==olderPeopleHealthCheckRecord.getNervous_system_disease_has()?"":olderPeopleHealthCheckRecord.getNervous_system_disease_has());
//        if(null==olderPeopleHealthCheckRecord.getOther_system_disease()){
//            html = html.replace("${other_system_disease}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getOther_system_disease();
//            switch (sclera){
//                case 1:html = html.replace("${other_system_disease}","未发现");break;
//                case 2:html = html.replace("${other_system_disease}","有");break;
//                default:html = html.replace("${other_system_disease}"," ");break;
//            }
//        }
//        html = html.replace("${other_system_disease_has}",null==olderPeopleHealthCheckRecord.getOther_system_disease_has()?"":olderPeopleHealthCheckRecord.getOther_system_disease_has());
//        html = html.replace("${admission_date1}",null==olderPeopleHealthCheckRecord.getAdmission_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getAdmission_date1()));
//        html = html.replace("${admission_date2}",null==olderPeopleHealthCheckRecord.getAdmission_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getAdmission_date2()));
//        html = html.replace("${discharge_date1}",null==olderPeopleHealthCheckRecord.getDischarge_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getDischarge_date1()));
//        html = html.replace("${discharge_date2}",null==olderPeopleHealthCheckRecord.getDischarge_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getDischarge_date2()));
//        html = html.replace("${admission_reason1}",null==olderPeopleHealthCheckRecord.getAdmission_reason1()?"":olderPeopleHealthCheckRecord.getAdmission_reason1());
//        html = html.replace("${admission_reason2}",null==olderPeopleHealthCheckRecord.getAdmission_reason2()?"":olderPeopleHealthCheckRecord.getAdmission_reason2());
//        html = html.replace("${admission_hospital_name1}",null==olderPeopleHealthCheckRecord.getAdmission_hospital_name1()?"":olderPeopleHealthCheckRecord.getAdmission_hospital_name1());
//        html = html.replace("${admission_hospital_name2}",null==olderPeopleHealthCheckRecord.getAdmission_hospital_name2()?"":olderPeopleHealthCheckRecord.getAdmission_hospital_name2());
//        html = html.replace("${admission_number1}",null==olderPeopleHealthCheckRecord.getAdmission_number1()?"":olderPeopleHealthCheckRecord.getAdmission_number1());
//        html = html.replace("${admission_number2}",null==olderPeopleHealthCheckRecord.getAdmission_number2()?"":olderPeopleHealthCheckRecord.getAdmission_number2());
//        html = html.replace("${building_bed_date1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getBuilding_bed_date1()));
//        html = html.replace("${building_bed_date2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getBuilding_bed_date2()));
//        html = html.replace("${cancel_bed_date1}",null==olderPeopleHealthCheckRecord.getCancel_bed_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getCancel_bed_date1()));
//        html = html.replace("${cancel_bed_date2}",null==olderPeopleHealthCheckRecord.getCancel_bed_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getCancel_bed_date2()));
//        html = html.replace("${building_bed_reason1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_reason1()?"":olderPeopleHealthCheckRecord.getBuilding_bed_reason1());
//        html = html.replace("${building_bed_reason2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_reason2()?"":olderPeopleHealthCheckRecord.getBuilding_bed_reason2());
//        html = html.replace("${building_bed_hospiatl_name1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name1()?"":olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name1());
//        html = html.replace("${building_bed_hospiatl_name2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name2()?"":olderPeopleHealthCheckRecord.getBuilding_bed_hospiatl_name2());
//        html = html.replace("${building_bed_number1}",null==olderPeopleHealthCheckRecord.getBuilding_bed_number1()?"":olderPeopleHealthCheckRecord.getBuilding_bed_number1());
//        html = html.replace("${building_bed_number2}",null==olderPeopleHealthCheckRecord.getBuilding_bed_number2()?"":olderPeopleHealthCheckRecord.getBuilding_bed_number2());
//        html = html.replace("${medicine1}",null==olderPeopleHealthCheckRecord.getMedicine1()?"":olderPeopleHealthCheckRecord.getMedicine1());
//        html = html.replace("${medicine2}",null==olderPeopleHealthCheckRecord.getMedicine2()?"":olderPeopleHealthCheckRecord.getMedicine2());
//        html = html.replace("${medicine3}",null==olderPeopleHealthCheckRecord.getMedicine3()?"":olderPeopleHealthCheckRecord.getMedicine3());
//        html = html.replace("${medicine4}",null==olderPeopleHealthCheckRecord.getMedicine4()?"":olderPeopleHealthCheckRecord.getMedicine4());
//        html = html.replace("${medicine5}",null==olderPeopleHealthCheckRecord.getMedicine5()?"":olderPeopleHealthCheckRecord.getMedicine5());
//        html = html.replace("${medicine6}",null==olderPeopleHealthCheckRecord.getMedicine6()?"":olderPeopleHealthCheckRecord.getMedicine6());
//        html = html.replace("${medicine1_use}",null==olderPeopleHealthCheckRecord.getMedicine1_use()?"":olderPeopleHealthCheckRecord.getMedicine1_use());
//        html = html.replace("${medicine2_use}",null==olderPeopleHealthCheckRecord.getMedicine2_use()?"":olderPeopleHealthCheckRecord.getMedicine2_use());
//        html = html.replace("${medicine3_use}",null==olderPeopleHealthCheckRecord.getMedicine3_use()?"":olderPeopleHealthCheckRecord.getMedicine3_use());
//        html = html.replace("${medicine4_use}",null==olderPeopleHealthCheckRecord.getMedicine4_use()?"":olderPeopleHealthCheckRecord.getMedicine4_use());
//        html = html.replace("${medicine5_use}",null==olderPeopleHealthCheckRecord.getMedicine5_use()?"":olderPeopleHealthCheckRecord.getMedicine5_use());
//        html = html.replace("${medicine6_use}",null==olderPeopleHealthCheckRecord.getMedicine6_use()?"":olderPeopleHealthCheckRecord.getMedicine6_use());
//        html = html.replace("${medicine1_dosage}",null==olderPeopleHealthCheckRecord.getMedicine1_dosage()?"":olderPeopleHealthCheckRecord.getMedicine1_dosage());
//        html = html.replace("${medicine2_dosage}",null==olderPeopleHealthCheckRecord.getMedicine2_dosage()?"":olderPeopleHealthCheckRecord.getMedicine2_dosage());
//        html = html.replace("${medicine3_dosage}",null==olderPeopleHealthCheckRecord.getMedicine3_dosage()?"":olderPeopleHealthCheckRecord.getMedicine3_dosage());
//        html = html.replace("${medicine4_dosage}",null==olderPeopleHealthCheckRecord.getMedicine4_dosage()?"":olderPeopleHealthCheckRecord.getMedicine4_dosage());
//        html = html.replace("${medicine5_dosage}",null==olderPeopleHealthCheckRecord.getMedicine5_dosage()?"":olderPeopleHealthCheckRecord.getMedicine5_dosage());
//        html = html.replace("${medicine6_dosage}",null==olderPeopleHealthCheckRecord.getMedicine6_dosage()?"":olderPeopleHealthCheckRecord.getMedicine6_dosage());
//        html = html.replace("${medication1_time}",null==olderPeopleHealthCheckRecord.getMedication1_time()?"":olderPeopleHealthCheckRecord.getMedication1_time());
//        html = html.replace("${medication2_time}",null==olderPeopleHealthCheckRecord.getMedication2_time()?"":olderPeopleHealthCheckRecord.getMedication2_time());
//        html = html.replace("${medication3_time}",null==olderPeopleHealthCheckRecord.getMedication3_time()?"":olderPeopleHealthCheckRecord.getMedication3_time());
//        html = html.replace("${medication4_time}",null==olderPeopleHealthCheckRecord.getMedication4_time()?"":olderPeopleHealthCheckRecord.getMedication4_time());
//        html = html.replace("${medication5_time}",null==olderPeopleHealthCheckRecord.getMedication5_time()?"":olderPeopleHealthCheckRecord.getMedication5_time());
//        html = html.replace("${medication6_time}",null==olderPeopleHealthCheckRecord.getMedication6_time()?"":olderPeopleHealthCheckRecord.getMedication6_time());
//        if(null==olderPeopleHealthCheckRecord.getMedication1_compliance()){
//            html = html.replace("${medication1_compliance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMedication1_compliance();
//            switch (sclera){
//                case 1:html = html.replace("${medication1_compliance}","规律");break;
//                case 2:html = html.replace("${medication1_compliance}","间断");break;
//                case 3:html = html.replace("${medication1_compliance}","不服药");break;
//                default:html = html.replace("${medication1_compliance}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getMedication2_compliance()){
//            html = html.replace("${medication2_compliance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMedication2_compliance();
//            switch (sclera){
//                case 1:html = html.replace("${medication2_compliance}","规律");break;
//                case 2:html = html.replace("${medication2_compliance}","间断");break;
//                case 3:html = html.replace("${medication2_compliance}","不服药");break;
//                default:html = html.replace("${medication2_compliance}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getMedication3_compliance()){
//            html = html.replace("${medication3_compliance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMedication3_compliance();
//            switch (sclera){
//                case 1:html = html.replace("${medication3_compliance}","规律");break;
//                case 2:html = html.replace("${medication3_compliance}","间断");break;
//                case 3:html = html.replace("${medication3_compliance}","不服药");break;
//                default:html = html.replace("${medication3_compliance}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getMedication4_compliance()){
//            html = html.replace("${medication4_compliance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMedication4_compliance();
//            switch (sclera){
//                case 1:html = html.replace("${medication4_compliance}","规律");break;
//                case 2:html = html.replace("${medication4_compliance}","间断");break;
//                case 3:html = html.replace("${medication4_compliance}","不服药");break;
//                default:html = html.replace("${medication4_compliance}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getMedication5_compliance()){
//            html = html.replace("${medication5_compliance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMedication5_compliance();
//            switch (sclera){
//                case 1:html = html.replace("${medication5_compliance}","规律");break;
//                case 2:html = html.replace("${medication5_compliance}","间断");break;
//                case 3:html = html.replace("${medication5_compliance}","不服药");break;
//                default:html = html.replace("${medication5_compliance}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getMedication6_compliance()){
//            html = html.replace("${medication6_compliance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getMedication6_compliance();
//            switch (sclera){
//                case 1:html = html.replace("${medication6_compliance}","规律");break;
//                case 2:html = html.replace("${medication6_compliance}","间断");break;
//                case 3:html = html.replace("${medication6_compliance}","不服药");break;
//                default:html = html.replace("${medication6_compliance}"," ");break;
//            }
//        }
//        html = html.replace("${vaccination_name1}",null==olderPeopleHealthCheckRecord.getVaccination_name1()?"":olderPeopleHealthCheckRecord.getVaccination_name1());
//        html = html.replace("${vaccination_name2}",null==olderPeopleHealthCheckRecord.getVaccination_name2()?"":olderPeopleHealthCheckRecord.getVaccination_name2());
//        html = html.replace("${vaccination_name3}",null==olderPeopleHealthCheckRecord.getVaccination_name3()?"":olderPeopleHealthCheckRecord.getVaccination_name3());
//        html = html.replace("${vaccination_date1}",null==olderPeopleHealthCheckRecord.getVaccination_date1()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getVaccination_date1()));
//        html = html.replace("${vaccination_date2}",null==olderPeopleHealthCheckRecord.getVaccination_date2()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getVaccination_date2()));
//        html = html.replace("${vaccination_date3}",null==olderPeopleHealthCheckRecord.getVaccination_date3()?"":DateUtil.dateToStrShort(olderPeopleHealthCheckRecord.getVaccination_date3()));
//        html = html.replace("${vaccination_hospital_name1}",null==olderPeopleHealthCheckRecord.getVaccination_hospital_name1()?"":olderPeopleHealthCheckRecord.getVaccination_hospital_name1());
//        html = html.replace("${vaccination_hospital_name2}",null==olderPeopleHealthCheckRecord.getVaccination_hospital_name2()?"":olderPeopleHealthCheckRecord.getVaccination_hospital_name2());
//        html = html.replace("${vaccination_hospital_name3}",null==olderPeopleHealthCheckRecord.getVaccination_hospital_name3()?"":olderPeopleHealthCheckRecord.getVaccination_hospital_name3());
//        if(null==olderPeopleHealthCheckRecord.getHealth_examination()){
//            html = html.replace("${health_examination}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getHealth_examination();
//            switch (sclera){
//                case 1:html = html.replace("${health_examination}","无");break;
//                case 2:html = html.replace("${health_examination}","有异常");break;
//                default:html = html.replace("${health_examination}"," ");break;
//            }
//        }
//        html = html.replace("${health_examination_abnormal1}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal1()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal1());
//        html = html.replace("${health_examination_abnormal2}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal2()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal2());
//        html = html.replace("${health_examination_abnormal3}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal3()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal3());
//        html = html.replace("${health_examination_abnormal4}",null==olderPeopleHealthCheckRecord.getHealth_examination_abnormal4()?"":olderPeopleHealthCheckRecord.getHealth_examination_abnormal4());
//        if(null==olderPeopleHealthCheckRecord.getRegular_followup()){
//            html = html.replace("${regular_followup}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getRegular_followup();
//            switch (sclera){
//                case 2:html = html.replace("${regular_followup}","定期随访:是");break;
//                default:html = html.replace("${regular_followup}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getChronic_health_management()){
//            html = html.replace("${chronic_health_management}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getChronic_health_management();
//            switch (sclera){
//                case 2:html = html.replace("${chronic_health_management}","纳入慢性病患者健康管理:是");break;
//                default:html = html.replace("${chronic_health_management}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getSuggest_recheck()){
//            html = html.replace("${suggest_recheck}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getSuggest_recheck();
//            switch (sclera){
//                case 2:html = html.replace("${suggest_recheck}","建议复查:是");break;
//                default:html = html.replace("${suggest_recheck}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getSuggest_referral()){
//            html = html.replace("${suggest_referral}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getSuggest_referral();
//            switch (sclera){
//                case 2:html = html.replace("${suggest_referral}","建议转诊:是");break;
//                default:html = html.replace("${suggest_referral}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getOther_health_guidance()){
//            html = html.replace("${other_health_guidance}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getOther_health_guidance();
//            switch (sclera){
//                case 2:html = html.replace("${other_health_guidance}","其他");break;
//                default:html = html.replace("${other_health_guidance}"," ");break;
//            }
//        }
//        html = html.replace("${other_health_guidance_description}",null==olderPeopleHealthCheckRecord.getOther_health_guidance_description()?"":olderPeopleHealthCheckRecord.getOther_health_guidance_description());
//        if(null==olderPeopleHealthCheckRecord.getStop_smoking()){
//            html = html.replace("${stop_smoking}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getStop_smoking();
//            switch (sclera){
//                case 2:html = html.replace("${stop_smoking}","戒烟:是");break;
//                default:html = html.replace("${stop_smoking}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getHealthy_drinking()){
//            html = html.replace("${healthy_drinking}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getHealthy_drinking();
//            switch (sclera){
//                case 2:html = html.replace("${healthy_drinking}","健康饮酒:是");break;
//                default:html = html.replace("${healthy_drinking}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getDiet()){
//            html = html.replace("${diet}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getDiet();
//            switch (sclera){
//                case 2:html = html.replace("${diet}","饮食:是");break;
//                default:html = html.replace("${diet}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getExercise()){
//            html = html.replace("${exercise}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getExercise();
//            switch (sclera){
//                case 2:html = html.replace("${exercise}","锻炼:是");break;
//                default:html = html.replace("${exercise}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getLose_weight()){
//            html = html.replace("${lose_weight}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getLose_weight();
//            switch (sclera){
//                case 2:html = html.replace("${lose_weight}","减肥:是");break;
//                default:html = html.replace("${lose_weight}"," ");break;
//            }
//        }
//        html = html.replace("${goal_weight}",null==olderPeopleHealthCheckRecord.getGoal_weight()?"":"目标:"+olderPeopleHealthCheckRecord.getGoal_weight()+"Kg");
//        if(null==olderPeopleHealthCheckRecord.getRecommended_vaccination()){
//            html = html.replace("${recommended_vaccination}"," ");
//        }else {
//            String sclera = olderPeopleHealthCheckRecord.getRecommended_vaccination();
//            switch (sclera){
//                case "2":html = html.replace("${recommended_vaccination}","建议接种疫苗:是");break;
//                default:html = html.replace("${recommended_vaccination}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getOther_advice()){
//            html = html.replace("${other_advice}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getOther_advice();
//            switch (sclera){
//                case 2:html = html.replace("${other_advice}","其他建议:是");break;
//                default:html = html.replace("${other_advice}"," ");break;
//            }
//        }
//        html = html.replace("${other_advice_description}",null==olderPeopleHealthCheckRecord.getOther_advice_description()?"":olderPeopleHealthCheckRecord.getOther_advice_description());
//        if(null==olderPeopleHealthCheckRecord.getEat()){
//            html = html.replace("${eat}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getEat();
//            switch (sclera){
//                case 1:html = html.replace("${eat}","    独立完成0-3分");break;
//                case 2:html = html.replace("${eat}","    轻度依赖4-8分");break;
//                case 3:html = html.replace("${eat}","    中度依赖9-18分");break;
//                case 4:html = html.replace("${eat}","    不能自理≥19分");break;
//                default:html = html.replace("${eat}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getWash()){
//            html = html.replace("${wash}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getWash();
//            switch (sclera){
//                case 1:html = html.replace("${wash}","    独立完成0-3分");break;
//                case 2:html = html.replace("${wash}","    轻度依赖4-8分");break;
//                case 3:html = html.replace("${wash}","    中度依赖9-18分");break;
//                case 4:html = html.replace("${wash}","    不能自理≥19分");break;
//                default:html = html.replace("${wash}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getDress()){
//            html = html.replace("${dress}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getDress();
//            switch (sclera){
//                case 1:html = html.replace("${dress}","    独立完成0-3分");break;
//                case 2:html = html.replace("${dress}","    轻度依赖4-8分");break;
//                case 3:html = html.replace("${dress}","    中度依赖9-18分");break;
//                case 4:html = html.replace("${dress}","    不能自理≥19分");break;
//                default:html = html.replace("${dress}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getToilet()){
//            html = html.replace("${toilet}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getToilet();
//            switch (sclera){
//                case 1:html = html.replace("${toilet}","    独立完成0-3分");break;
//                case 2:html = html.replace("${toilet}","    轻度依赖4-8分");break;
//                case 3:html = html.replace("${toilet}","    中度依赖9-18分");break;
//                case 4:html = html.replace("${toilet}","    不能自理≥19分");break;
//                default:html = html.replace("${toilet}"," ");break;
//            }
//        }
//        if(null==olderPeopleHealthCheckRecord.getActivity()){
//            html = html.replace("${activity}"," ");
//        }else {
//            Integer sclera = olderPeopleHealthCheckRecord.getActivity();
//            switch (sclera){
//                case 1:html = html.replace("${activity}","    独立完成0-3分");break;
//                case 2:html = html.replace("${activity}","    轻度依赖4-8分");break;
//                case 3:html = html.replace("${activity}","    中度依赖9-18分");break;
//                case 4:html = html.replace("${activity}","    能自理≥19分");break;
//                default:html = html.replace("${activity}"," ");break;
//            }
//        }
//        html = html.replace("${score}",null==olderPeopleHealthCheckRecord.getScore()?"":olderPeopleHealthCheckRecord.getScore()+"");
//
//        String sign_wayStr="";
//        String sign_time="";
//        String sign_address="";
//        String sign_imgs="";
//
//        List<FollowupSign> followupSignDOs = followupSignDao.findByFollowupIdAndDel(Long.valueOf(olderPeopleHealthCheckRecord.getFollowup_id()),0);
//        if (followupSignDOs.size()>0){
//            FollowupSign followupSignDO = followupSignDOs.get(0);
//            if (null!=followupSignDO){
//                try {
//                    switch (followupSignDO.getType()){
//                        case "1":sign_wayStr="定位"; break;
//                        case "2":sign_wayStr="拍照";break;
//                        case "3":sign_wayStr="门牌";break;
//                        default:sign_wayStr=" ";break;
//                    }
//                    sign_address = null==followupSignDO.getAddress()?" ":followupSignDO.getAddress();
//                    if(StringUtils.isNotBlank(followupSignDO.getImg())) {
//                        String imgs = followupSignDO.getImg();
//                        String[] imgsArray;
//                        if (imgs.contains(",")) {
//                            imgsArray = imgs.split(",");
//                        } else {
//                            imgsArray = new String[]{imgs};
//                        }
//                        for (String img : imgsArray) {
//                            sign_imgs += "<img width='80' height='100' src='" + imgUrlDomain + img + "' />&nbsp;";
//                        }
//                    }
//                    sign_time = DateUtil.dateToStrLong(followupSignDO.getCreateTime());
//
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }
//        }
//        html = html.replace("${sign_way}",sign_wayStr);
//        html = html.replace("${sign_time}",sign_time);
//        html = html.replace("${sign_address}",sign_address);
//        html = html.replace("${sigm_imgs}",sign_imgs);
//        return html;
//    }
    public String getSymptomName(String symptom) {
        String symptomName = "";
        switch (symptom) {
            case "1":
                symptomName = " 无症状 ";
                break;
            case "2":
                symptomName = " 头痛 ";
                break;
            case "3":
                symptomName = " 头晕 ";
                break;
            case "4":
                symptomName = " 心悸 ";
                break;
            case "5":
                symptomName = " 胸闷 ";
                break;
            case "6":
                symptomName = " 胸痛 ";
                break;
            case "7":
                symptomName = " 慢性咳嗽 ";
                break;
            case "8":
                symptomName = " 咳痰 ";
                break;
            case "9":
                symptomName = " 呼吸困难 ";
                break;
            case "10":
                symptomName = "多饮 ";
                break;
            case "11":
                symptomName = "多尿 ";
                break;
            case "12":
                symptomName = "体重下降 ";
                break;
            case "13":
                symptomName = "乏力 ";
                break;
            case "14":
                symptomName = "关节肿痛 ";
                break;
            case "15":
                symptomName = "视力模糊 ";
                break;
            case "16":
                symptomName = "手脚麻木 ";
                break;
            case "17":
                symptomName = "尿急 ";
                break;
            case "18":
                symptomName = "尿痛 ";
                break;
            case "19":
                symptomName = "便秘 ";
                break;
            case "20":
                symptomName = "腹泻 ";
                break;
            case "21":
                symptomName = "恶心呕吐 ";
                break;
            case "22":
                symptomName = "眼花 ";
                break;
            case "23":
                symptomName = "耳鸣 ";
                break;
            case "24":
                symptomName = "乳房胀痛 ";
                break;
            case "25":
                symptomName = "其他 ";
                break;
            default:
                symptomName = " ";
                break;
        }
        return symptomName;
    }

+ 149 - 145
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/RehabilitationManageController.java

@ -1,10 +1,10 @@
package com.yihu.jw.hospital.module.rehabilitation.controller;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationOperateRecordsDao;
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
import com.yihu.jw.hospital.module.rehabilitation.service.SynchronizePatientService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -32,25 +32,28 @@ public class RehabilitationManageController {
    @Autowired
    private RehabilitationManageService rehabilitationManageService;
//    @Autowired
    //    @Autowired
//    private Tracer tracer;
    @Autowired
    private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao;
    @Autowired
    SynchronizePatientService synchronizePatientService;
    @PostMapping(value = "synchronizePationSingle")
    @ApiOperation("手动重新下转")
    public String synchronizePationSingle(@ApiParam(name = "id", value = "id", required = true)
                                          @RequestParam(value = "id", required = true)Long id) {
    public MixEnvelop synchronizePationSingle(@ApiParam(name = "id", value = "id", required = true)
                                              @RequestParam(value = "id", required = true) Long id) {
        try {
            String res = synchronizePatientService.synchronizePationSingle(id);
            if(StringUtils.isBlank(res)){
                return success("操作成功,康复计划生成");
            }else {
                return error(-1,res);
            if (StringUtils.isBlank(res)) {
                return MixEnvelop.getSuccess("操作成功,康复计划生成");
            } else {
                return MixEnvelop.getError(res);
            }
        } catch (Exception e) {
            return errorResult(e);
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
@ -58,24 +61,24 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.findRehabilitationPlanList)
    @ApiOperation(value = "康复管理-康复计划列表")
    public MixEnvelop findRehabilitationPlan(@ApiParam(name = "doctorType", value = "医生类型(1、专科医生,2、家庭医生)", required = true)
                                             @RequestParam(value = "doctorType", required = true)Integer doctorType,
                                             @RequestParam(value = "doctorType", required = true) Integer doctorType,
                                             @ApiParam(name = "doctorCode", value = "医生code", required = true)
                                             @RequestParam(value = "doctorCode", required = true)String doctorCode,
                                             @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                             @ApiParam(name = "patientCondition", value = "居民条件,可以按身份证或者居民名称模糊匹配", required = false)
                                             @RequestParam(value = "patientCondition", required = false)String patientCondition,
                                             @RequestParam(value = "patientCondition", required = false) String patientCondition,
                                             @ApiParam(name = "diseaseCode", value = "疾病类型code", required = false)
                                             @RequestParam(value = "diseaseCode", required = false)String diseaseCode,
                                             @RequestParam(value = "diseaseCode", required = false) String diseaseCode,
                                             @ApiParam(name = "planType", value = "安排类型(1康复计划,2转社区医院,3转家庭病床)", required = false)
                                             @RequestParam(value = "planType", required = false)Integer planType,
                                             @RequestParam(value = "planType", required = false) Integer planType,
                                             @ApiParam(name = "todaybacklog", value = "今日待办(1、今日待办,2、全部)", required = false)
                                             @RequestParam(value = "todaybacklog", required = false,defaultValue = "1")Integer todaybacklog,
                                             @RequestParam(value = "todaybacklog", required = false, defaultValue = "1") Integer todaybacklog,
                                             @ApiParam(name = "page", value = "第几页,从1开始", required = false)
                                             @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
                                             @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                             @ApiParam(name = "pageSize", value = "每页分页大小", required = false)
                                             @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize){
                                             @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        try {
            return rehabilitationManageService.findRehabilitationPlan(doctorType,doctorCode,diseaseCode,planType,todaybacklog,patientCondition,page,pageSize);
        }catch (Exception e){
            return rehabilitationManageService.findRehabilitationPlan(doctorType, doctorCode, diseaseCode, planType, todaybacklog, patientCondition, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
@ -85,12 +88,12 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.findRehabilitationPlanDetailList)
    @ApiOperation(value = "康复管理-康复计划详情列表")
    public ObjEnvelop findRehabilitationPlanDetailList(@ApiParam(name = "doctorCode", value = "医生code", required = true)
                                                       @RequestParam(value = "doctorCode", required = true)String doctorCode,
                                                       @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                                       @ApiParam(name = "patientCode", value = "居民code", required = true)
                                                       @RequestParam(value = "patientCode", required = true)String patientCode){
                                                       @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            return rehabilitationManageService.findRehabilitationPlanDetailList(doctorCode,patientCode);
        }catch (Exception e){
            return rehabilitationManageService.findRehabilitationPlanDetailList(doctorCode, patientCode);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -100,22 +103,22 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.calendarPlanDetail)
    @ApiOperation(value = "康复管理-康复计划按日历展示")
    public ObjEnvelop calendarPlanDetail(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)")
                                          @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                         @RequestParam(value = "executeStartTime", required = false) String executeStartTime,
                                         @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)")
                                          @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                         @RequestParam(value = "executeEndTime", required = false) String executeEndTime,
                                         @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true)
                                          @RequestParam(value = "planId", required = true)String planId,
                                         @RequestParam(value = "planId", required = true) String planId,
                                         @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)", required = false)
                                          @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                         @RequestParam(value = "searchTask", required = false) Integer searchTask,
                                         @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                          @RequestParam(value = "status", required = false)Integer status,
                                         @RequestParam(value = "status", required = false) Integer status,
                                         @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                          @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                         @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
                                          @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor){
                                         @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                         @ApiParam(name = "taskExecutor", value = "任务执行人:0全部;1我的任务:2他人任务", required = false)
                                         @RequestParam(value = "taskExecutor", required = false, defaultValue = "0") String taskExecutor) {
        try {
            return rehabilitationManageService.calendarPlanDetail(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode,taskExecutor);
        }catch (Exception e){
            return rehabilitationManageService.calendarPlanDetail(executeStartTime, executeEndTime, planId, searchTask, status, doctorCode, taskExecutor);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -125,22 +128,22 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.calendarPlanDetailList)
    @ApiOperation(value = "康复管理-康复计划按列表展示")
    public ObjEnvelop calendarPlanDetailList(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)")
                                         @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                             @RequestParam(value = "executeStartTime", required = false) String executeStartTime,
                                             @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)")
                                         @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                             @RequestParam(value = "executeEndTime", required = false) String executeEndTime,
                                             @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true)
                                         @RequestParam(value = "planId", required = true)String planId,
                                             @RequestParam(value = "planId", required = true) String planId,
                                             @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)")
                                         @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                             @RequestParam(value = "searchTask", required = false) Integer searchTask,
                                             @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)")
                                         @RequestParam(value = "status", required = false)Integer status,
                                             @RequestParam(value = "status", required = false) Integer status,
                                             @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)")
                                         @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                             @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
                                         @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor){
                                             @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                             @ApiParam(name = "taskExecutor", value = "任务执行人:0全部;1我的任务:2他人任务", required = false)
                                             @RequestParam(value = "taskExecutor", required = false, defaultValue = "0") String taskExecutor) {
        try {
            return rehabilitationManageService.calendarPlanDetailList(planId,searchTask,status,doctorCode,executeStartTime,executeEndTime,taskExecutor);
        }catch (Exception e){
            return rehabilitationManageService.calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -150,12 +153,12 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.serviceItemList)
    @ApiOperation(value = "康复管理-多个康复计划服务项目内容信息列表")
    public ObjEnvelop serviceItemList(@ApiParam(name = "planDetailIds", value = "多个服务项目id用‘,’分隔", required = true)
                                             @RequestParam(value = "planDetailIds", required = true)String planDetailIds,
                                      @RequestParam(value = "planDetailIds", required = true) String planDetailIds,
                                      @ApiParam(name = "doctorCode", value = "医生code", required = false)
                                      @RequestParam(value = "doctorCode", required = false)String doctorCode){
                                      @RequestParam(value = "doctorCode", required = false) String doctorCode) {
        try {
            return rehabilitationManageService.serviceItemList(planDetailIds,doctorCode);
        }catch (Exception e){
            return rehabilitationManageService.serviceItemList(planDetailIds, doctorCode);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -165,14 +168,14 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.serviceItem)
    @ApiOperation(value = "康复管理-康复计划服务项目确认详情页")
    public ObjEnvelop serviceItem(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                  @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                  @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                  @ApiParam(name = "doctorCode", value = "医生code", required = false)
                                  @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                  @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                  @ApiParam(name = "recordId", value = "记录id", required = false)
                                      @RequestParam(value = "recordId", required = false)String recordId){
                                  @RequestParam(value = "recordId", required = false) String recordId) {
        try {
            return rehabilitationManageService.serviceItem(planDetailId,doctorCode,recordId);
        }catch (Exception e){
            return rehabilitationManageService.serviceItem(planDetailId, doctorCode, recordId);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -192,13 +195,13 @@ public class RehabilitationManageController {
            @RequestParam(value = "appointmentDoctor", required = true) String appointmentDoctor,
            @ApiParam(name = "appointmentDoctorName", value = "医生姓名", required = true)
            @RequestParam(value = "appointmentDoctorName", required = true) String appointmentDoctorName,
                                              @ApiParam(name = "sendTime", value = "发送时间", required = true)
                                              @RequestParam(value = "sendTime", required = true) String sendTime,
                                              @ApiParam(name = "planDetailId", value = "计划明细id", required = true)
                                              @RequestParam(value = "planDetailId", required = true) String planDetailId){
            @ApiParam(name = "sendTime", value = "发送时间", required = true)
            @RequestParam(value = "sendTime", required = true) String sendTime,
            @ApiParam(name = "planDetailId", value = "计划明细id", required = true)
            @RequestParam(value = "planDetailId", required = true) String planDetailId) {
        try {
            return rehabilitationManageService.appointmentConsultation(patient,doctor, doctorName,appointmentDoctor,appointmentDoctorName, sendTime, planDetailId);
        }catch (Exception e){
            return rehabilitationManageService.appointmentConsultation(patient, doctor, doctorName, appointmentDoctor, appointmentDoctorName, sendTime, planDetailId);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -208,22 +211,22 @@ public class RehabilitationManageController {
    @PostMapping(value = SpecialistMapping.rehabilitation.saveGuidanceMessage)
    @ApiOperation(value = "康复管理-保存指导留言")
    public Envelop saveGuidanceMessage(@ApiParam(name = "messageId", value = "消息id", required = true)
                                       @RequestParam(value = "messageId", required = true)String messageId,
                                       @RequestParam(value = "messageId", required = true) String messageId,
//                                       @ApiParam(name = "patientCode", value = "居民code", required = true)
//                                       @RequestParam(value = "patientCode", required = true)String patientCode,
                                       @ApiParam(name = "doctorCode", value = "医生code", required = true)
                                       @RequestParam(value = "doctorCode", required = true)String doctorCode,
                                       @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                       @ApiParam(name = "doctorType", value = "医生类型(1、专科医生,2、家庭医生)", required = true)
                                       @RequestParam(value = "doctorType", required = true)Integer doctorType,
                                       @RequestParam(value = "doctorType", required = true) Integer doctorType,
                                       @ApiParam(name = "content", value = "聊天内容", required = true)
                                       @RequestParam(value = "content", required = true)String content,
                                       @RequestParam(value = "content", required = true) String content,
                                       @ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                       @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                       @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                       @ApiParam(name = "contentType", value = "内容类型(1,6,8 - 文本, 2,9- 图片, 3 - 语音, 4-文章, 5,7系统消息。12-语音 18-居民名片, 19-聊天记录)", required = true)
                                       @RequestParam(value = "contentType", required = true)Integer contentType){
                                       @RequestParam(value = "contentType", required = true) Integer contentType) {
        try {
            return rehabilitationManageService.saveGuidanceMessage(messageId,doctorCode,doctorType,content,planDetailId,contentType);
        }catch (Exception e){
            return rehabilitationManageService.saveGuidanceMessage(messageId, doctorCode, doctorType, content, planDetailId, contentType);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -233,12 +236,12 @@ public class RehabilitationManageController {
    @PostMapping(value = SpecialistMapping.rehabilitation.updateStatusRehabilitationOperate)
    @ApiOperation(value = "康复管理-更新康复计划操作完成日志状态")
    public Envelop updateStatusRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                                        @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                     @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                                     @ApiParam(name = "status", value = "状态", required = true)
                                                        @RequestParam(value = "status", required = true)Integer status){
                                                     @RequestParam(value = "status", required = true) Integer status) {
        try {
            return rehabilitationManageService.updateStatusRehabilitationOperate(status,planDetailId);
        }catch (Exception e){
            return rehabilitationManageService.updateStatusRehabilitationOperate(status, planDetailId);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -249,18 +252,18 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.patientRehabilitationDetail)
    @ApiOperation(value = "康复管理-居民详情页")
    public Envelop patientRehabilitationDetail(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                       @RequestParam(value = "patientCode", required = true)String patientCode,
                                               @RequestParam(value = "patientCode", required = true) String patientCode,
                                               @ApiParam(name = "healthDoctor", value = "健管师医生code", required = false)
                                       @RequestParam(value = "healthDoctor", required = false)String healthDoctor,
                                               @RequestParam(value = "healthDoctor", required = false) String healthDoctor,
                                               @ApiParam(name = "healthDoctorName", value = "健管师医生名称", required = false)
                                       @RequestParam(value = "healthDoctorName", required = false)String healthDoctorName,
                                               @RequestParam(value = "healthDoctorName", required = false) String healthDoctorName,
                                               @ApiParam(name = "generalDoctor", value = "全科医生code", required = false)
                                       @RequestParam(value = "generalDoctor", required = false)String generalDoctor,
                                               @RequestParam(value = "generalDoctor", required = false) String generalDoctor,
                                               @ApiParam(name = "generalDoctorName", value = "全科医生名称", required = false)
                                       @RequestParam(value = "generalDoctorName", required = false)String generalDoctorName){
                                               @RequestParam(value = "generalDoctorName", required = false) String generalDoctorName) {
        try {
            return rehabilitationManageService.patientRehabilitationDetail(patientCode,healthDoctor, healthDoctorName,generalDoctor,generalDoctorName);
        }catch (Exception e){
            return rehabilitationManageService.patientRehabilitationDetail(patientCode, healthDoctor, healthDoctorName, generalDoctor, generalDoctorName);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -271,18 +274,18 @@ public class RehabilitationManageController {
    @ApiOperation(value = "居民康复计划详情页-近期康复相关记录")
    public Envelop recentPlanDetailRecord(
            @ApiParam(name = "patientCode", value = "居民code", required = true)
            @RequestParam(value = "patientCode", required = true)String patientCode,
            @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
            @RequestParam(value = "startTime", required = false)String startTime,
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
            @RequestParam(value = "endTime", required = false)String endTime,
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true)
            @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
            @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize){
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        try {
            return rehabilitationManageService.recentPlanDetailRecord(patientCode,startTime,endTime,page,pageSize);
        }catch (Exception e){
            return rehabilitationManageService.recentPlanDetailRecord(patientCode, startTime, endTime, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -292,18 +295,18 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.serviceDoctorList)
    @ApiOperation(value = "康复管理-医生端居民详情服务医生列表")
    public Envelop serviceDoctorList(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                               @RequestParam(value = "patientCode", required = true)String patientCode,
                                     @RequestParam(value = "patientCode", required = true) String patientCode,
                                     @ApiParam(name = "healthDoctor", value = "健管师医生code", required = false)
                                               @RequestParam(value = "healthDoctor", required = false)String healthDoctor,
                                     @RequestParam(value = "healthDoctor", required = false) String healthDoctor,
                                     @ApiParam(name = "healthDoctorName", value = "健管师医生名称", required = false)
                                               @RequestParam(value = "healthDoctorName", required = false)String healthDoctorName,
                                     @RequestParam(value = "healthDoctorName", required = false) String healthDoctorName,
                                     @ApiParam(name = "generalDoctor", value = "全科医生code", required = false)
                                               @RequestParam(value = "generalDoctor", required = false)String generalDoctor,
                                     @RequestParam(value = "generalDoctor", required = false) String generalDoctor,
                                     @ApiParam(name = "generalDoctorName", value = "全科医生名称", required = false)
                                               @RequestParam(value = "generalDoctorName", required = false)String generalDoctorName){
                                     @RequestParam(value = "generalDoctorName", required = false) String generalDoctorName) {
        try {
            return rehabilitationManageService.serviceDoctorList(patientCode,healthDoctor, healthDoctorName,generalDoctor,generalDoctorName);
        }catch (Exception e){
            return rehabilitationManageService.serviceDoctorList(patientCode, healthDoctor, healthDoctorName, generalDoctor, generalDoctorName);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -313,18 +316,18 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.appCalendarPlanDetailList)
    @ApiOperation(value = "康复管理-app端、微信端计划的服务项目列表")
    public ObjEnvelop appCalendarPlanDetailList(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                             @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                                @RequestParam(value = "executeStartTime", required = false) String executeStartTime,
                                                @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                             @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                                @RequestParam(value = "executeEndTime", required = false) String executeEndTime,
                                                @ApiParam(name = "planId", value = "计划id", required = true)
                                             @RequestParam(value = "planId", required = true)String planId,
                                                @RequestParam(value = "planId", required = true) String planId,
                                                @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)", required = false)
                                             @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                                @RequestParam(value = "searchTask", required = false) Integer searchTask,
                                                @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                             @RequestParam(value = "status", required = false)Integer status){
                                                @RequestParam(value = "status", required = false) Integer status) {
        try {
            return rehabilitationManageService.appCalendarPlanDetailList(planId,searchTask,status,executeStartTime,executeEndTime);
        }catch (Exception e){
            return rehabilitationManageService.appCalendarPlanDetailList(planId, searchTask, status, executeStartTime, executeEndTime);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -334,12 +337,12 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.dailyJob)
    @ApiOperation(value = "每日康复服务通知")
    public ObjEnvelop dailyJob(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                @RequestParam(value = "startTime", required = true)String startTime,
                               @RequestParam(value = "startTime", required = true) String startTime,
                               @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                @RequestParam(value = "endTime", required = true)String endTime){
                               @RequestParam(value = "endTime", required = true) String endTime) {
        try {
            return rehabilitationManageService.dailyJob(startTime,endTime);
        }catch (Exception e){
            return rehabilitationManageService.dailyJob(startTime, endTime);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -349,12 +352,12 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.tomorrowJob)
    @ApiOperation(value = "明日康复服务通知")
    public ObjEnvelop tomorrowJob(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "startTime", required = true)String startTime,
                                  @RequestParam(value = "startTime", required = true) String startTime,
                                  @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "endTime", required = true)String endTime){
                                  @RequestParam(value = "endTime", required = true) String endTime) {
        try {
            return rehabilitationManageService.tomorrowJob(startTime,endTime);
        }catch (Exception e){
            return rehabilitationManageService.tomorrowJob(startTime, endTime);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -365,12 +368,12 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.dailyByJob)
    @ApiOperation(value = "每日康复计划提醒")
    public ObjEnvelop dailyByJob(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "startTime", required = true)String startTime,
                                 @RequestParam(value = "startTime", required = true) String startTime,
                                 @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "endTime", required = true)String endTime){
                                 @RequestParam(value = "endTime", required = true) String endTime) {
        try {
            return rehabilitationManageService.dailyByJob(startTime,endTime);
        }catch (Exception e){
            return rehabilitationManageService.dailyByJob(startTime, endTime);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -379,16 +382,16 @@ public class RehabilitationManageController {
    @PostMapping(value = SpecialistMapping.rehabilitation.updateNoteAndImageRehabilitationOperate)
    @ApiOperation(value = "康复计划完成时更新服务完成笔记和图片接口并且确认完成")
    public ObjEnvelop updateNoteAndImageRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                              @ApiParam(name = "node", value = "服务完成笔记", required = true)@RequestParam(value = "node", required = false)String node,
                                                              @ApiParam(name = "image", value = "相关记录图片,json格式", required = true)@RequestParam(value = "image", required = false)String image,
                                                              @ApiParam(name = "relationCode", value = "业务code", required = true)@RequestParam(value = "relationCode", required = false)String relationCode,
                                                              @ApiParam(name = "status", value = "是否确认完成 0未确认 1确认", required = true)@RequestParam(value = "status", required = false)String status){
    public ObjEnvelop updateNoteAndImageRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true) @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                                              @ApiParam(name = "node", value = "服务完成笔记", required = true) @RequestParam(value = "node", required = false) String node,
                                                              @ApiParam(name = "image", value = "相关记录图片,json格式", required = true) @RequestParam(value = "image", required = false) String image,
                                                              @ApiParam(name = "relationCode", value = "业务code", required = true) @RequestParam(value = "relationCode", required = false) String relationCode,
                                                              @ApiParam(name = "status", value = "是否确认完成 0未确认 1确认", required = true) @RequestParam(value = "status", required = false) String status) {
        try {
            Map<String,Object> map = rehabilitationManageService.updateNodeAndRelationRecordImg(node,image,status,planDetailId,relationCode);
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
            Map<String, Object> map = rehabilitationManageService.updateNodeAndRelationRecordImg(node, image, status, planDetailId, relationCode);
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success, map);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -399,11 +402,11 @@ public class RehabilitationManageController {
    @PostMapping(value = "planDetailAfterCall")
    @ApiOperation(value = "康复管理-电话关怀拨打后生成记录对应怪坏记录")
    public MixEnvelop<RehabilitationOperateRecordsDO, RehabilitationOperateRecordsDO> planDetailAfterCall(
            @ApiParam(name = "dataJson", value = "实体json",defaultValue = "{\"rehabilitationDetailId\":\"808080eb764ba46b017669712c640012\",\"doctorCode\":\"7e06886207e843948ae65d8f91d6ca97\",\"doctorName\":\"兰冠勇\"}")
            @RequestParam(value = "dataJson", required = true)String dataJson){
            @ApiParam(name = "dataJson", value = "实体json", defaultValue = "{\"rehabilitationDetailId\":\"808080eb764ba46b017669712c640012\",\"doctorCode\":\"7e06886207e843948ae65d8f91d6ca97\",\"doctorName\":\"兰冠勇\"}")
            @RequestParam(value = "dataJson", required = true) String dataJson) {
        try {
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationManageService.planDetailAfterCall(dataJson));
        }catch (Exception e){
            return MixEnvelop.getSuccess(SpecialistMapping.api_success, rehabilitationManageService.planDetailAfterCall(dataJson));
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
@ -413,12 +416,12 @@ public class RehabilitationManageController {
    @PostMapping(value = SpecialistMapping.rehabilitation.updatePlanDetailStatusById)
    @ApiOperation(value = "康复管理-更新康复计划项目状态")
    public Envelop updatePlanDetailStatusById(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                                     @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                              @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                              @ApiParam(name = "status", value = "状态", required = true)
                                                     @RequestParam(value = "status", required = true)Integer status){
                                              @RequestParam(value = "status", required = true) Integer status) {
        try {
            return rehabilitationManageService.updatePlanDetailStatusById(status,planDetailId);
        }catch (Exception e){
            return rehabilitationManageService.updatePlanDetailStatusById(status, planDetailId);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -429,13 +432,13 @@ public class RehabilitationManageController {
    @PostMapping(value = SpecialistMapping.rehabilitation.updatePlanDetailExecuteTimeById)
    @ApiOperation(value = "康复管理-修改康复计划项目执行时间")
    public Envelop updatePlanDetailExecuteTimeById(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                              @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                   @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                                   @ApiParam(name = "executeTime", value = "状态", required = true)
                                              @RequestParam(value = "executeTime", required = true)String executeTime){
                                                   @RequestParam(value = "executeTime", required = true) String executeTime) {
        try {
            Date date = DateUtil.strToDateLong(executeTime);
            return rehabilitationManageService.updatePlanDetailExecuteTimeById(date,planDetailId);
        }catch (Exception e){
            return rehabilitationManageService.updatePlanDetailExecuteTimeById(date, planDetailId);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
@ -446,10 +449,10 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.planSchedule)
    @ApiOperation(value = "康复管理-计划总进度")
    public ObjEnvelop planSchedule(@ApiParam(name = "planId", value = "计划id", required = true)
                                                       @RequestParam(value = "planId", required = true)String planId){
                                   @RequestParam(value = "planId", required = true) String planId) {
        try {
            return rehabilitationManageService.planSchedule(planId);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -459,10 +462,10 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.planListByPatient)
    @ApiOperation(value = "康复管理-根据居民获取康复计划")
    public ObjEnvelop planListByPatient(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                   @RequestParam(value = "patientCode", required = true)String patientCode){
                                        @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            return rehabilitationManageService.planListByPatient(patientCode);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -472,10 +475,10 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.patientCount)
    @ApiOperation(value = "医生已计划数,已完成计划数(居民数)")
    public ObjEnvelop patientCount(@ApiParam(name = "doctorCode", value = "医生code", required = true)
                               @RequestParam(value = "doctorCode", required = true)String doctorCode){
                                   @RequestParam(value = "doctorCode", required = true) String doctorCode) {
        try {
            return rehabilitationManageService.patientCount(doctorCode);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -485,12 +488,12 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.dailyJobReserve)
    @ApiOperation(value = "10天、7天、5天、当天康复服务预约复诊通知")
    public ObjEnvelop dailyJobReserve(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "startTime", required = true)String startTime,
                                      @RequestParam(value = "startTime", required = true) String startTime,
                                      @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "endTime", required = true)String endTime){
                                      @RequestParam(value = "endTime", required = true) String endTime) {
        try {
            return rehabilitationManageService.dailyJobReserve(startTime,endTime);
        }catch (Exception e){
            return rehabilitationManageService.dailyJobReserve(startTime, endTime);
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -500,16 +503,17 @@ public class RehabilitationManageController {
    /**
     * 查询康复服务项目
     *
     * @param ids
     * @return
     */
    @PostMapping(value = SpecialistMapping.rehabilitation.selectByIds)
    @ApiOperation(value = "查询康复服务项目")
    public ObjEnvelop selectByIds(@ApiParam(name = "ids",value = "康复服务套餐明细表ids")
            @RequestParam(value = "ids",required = true)String ids){
    public ObjEnvelop selectByIds(@ApiParam(name = "ids", value = "康复服务套餐明细表ids")
                                  @RequestParam(value = "ids", required = true) String ids) {
        try {
            return rehabilitationManageService.selectByIds(ids);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -519,10 +523,10 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.serviceItem.getServiceItemsAfterStop)
    @ApiOperation(value = "康复管理-中止康复计划结算项目清单")
    public ObjEnvelop getServiceItemsAfterStop(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                  @RequestParam(value = "planId", required = true)String planId){
                                               @RequestParam(value = "planId", required = true) String planId) {
        try {
            return rehabilitationManageService.getServiceItemsAfterStop(planId);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            //tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());

+ 9 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/dao/PatientDischargeDao.java

@ -3,11 +3,20 @@ package com.yihu.jw.hospital.module.rehabilitation.dao;
import com.yihu.jw.entity.rehabilitation.PatientDischargeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by liub on 2020/9/16.
 */
public interface PatientDischargeDao extends PagingAndSortingRepository<PatientDischargeDO, Long>, JpaSpecificationExecutor<PatientDischargeDO> {
    List<PatientDischargeDO> findAllByCreateUser(String createUser);
    List<PatientDischargeDO> queryByCreateUserAndPatientIn(String createUser,String[] patient);
    // //查询下转是否存在该患者 :sign_status=1(包括type==null,type==2) 1.6.8后新增未家签的也能添加患者判断条件(d.type=2 and sign_status=0)
    @Query(value = "select count(1) from PatientDischargeDO p where p.idcard = ?1 and p.createUser=?2 and (p.signStatus=1 and ( p.type is null or p.type=2) or (p.type=2 and p.signStatus=0))")
    int isPatientExist(String idcard, String createUser);
}

+ 26 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/dao/RehabilitationPatientInfoDao.java

@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -24,5 +25,30 @@ public interface RehabilitationPatientInfoDao extends PagingAndSortingRepository
    @Query(value = "update RehabilitationPatientInfoDO r set r.status=?1 where r.code = ?2")
    int updateState(Integer state, String code);
    @Query(value="select r.* from wlyy_rehabilitation_patient_info r where (r.status =0 or r.status is null ) " +
            " and r.create_time>=?1 group by r.idcard,DATE_FORMAT(r.create_time,'%Y-%m-%d')  ",nativeQuery = true)
    List<RehabilitationPatientInfoDO> findUnDispation(Date preTime);
    @Query(value="select r.* from wlyy_rehabilitation_patient_info r where (r.status =0 or r.status is null ) " +
            " and r.hospital_code=?2 and r.create_time>=?1 group by r.idcard,DATE_FORMAT(r.create_time,'%Y-%m-%d')  ",nativeQuery = true)
    List<RehabilitationPatientInfoDO> findUnDispation(Date preTime,String hospital);
    @Query(value="select r.* from wlyy_rehabilitation_patient_info r where r.status =?1 " +
            " and r.create_time>=?2 group by r.idcard,DATE_FORMAT(r.create_time,'%Y-%m-%d') ",nativeQuery = true)
    List<RehabilitationPatientInfoDO> findUnDispationByStatus(Integer status,Date preTime);
    @Query(value="select r.* from wlyy_rehabilitation_patient_info r where r.status =?1 " +
            " and r.hospital_code=?3 and r.create_time>=?2 group by r.idcard,DATE_FORMAT(r.create_time,'%Y-%m-%d') ",nativeQuery = true)
    List<RehabilitationPatientInfoDO> findUnDispationByStatus(Integer status,Date preTime,String hospital);
    @Query(value="select r from RehabilitationPatientInfoDO r where r.idcard=?1 and r.createTime>=?2 and r.createTime<=?3 ")
    List<RehabilitationPatientInfoDO> findByIdcardAndCreateTime(String status,Date preTimeStart,Date preTimeEnd);
//    @Modifying
//    @Query(value="update RehabilitationPatientInfoDO r set r.status=?1 where r.code = ?2")
//    int updateState(Integer state, String code);
}

File diff suppressed because it is too large
+ 304 - 311
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/PatientRecordService.java


+ 148 - 147
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationInfoService.java

@ -2,35 +2,31 @@ package com.yihu.jw.hospital.module.rehabilitation.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.util.TransforSqlUtl;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDischargeDO;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.specialist.PatientMedicalRecordsDO;
import com.yihu.wlyy.entity.specialist.RehabilitationAdviceDO;
import com.yihu.wlyy.entity.specialist.XxzxMedicalHistory;
import com.yihu.wlyy.entity.specialist.XxzxMedicalHistoryDispose;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorMappingDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDischargeDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientMedicalRecordsRehabilitationDao;
import com.yihu.wlyy.repository.specialist.RehabilitationAdviceDao;
import com.yihu.wlyy.repository.specialist.XxzxMedicalHistoryDao;
import com.yihu.wlyy.repository.specialist.XxzxMedicalHistoryDisposeDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.hospital.DmHospitalDO;
import com.yihu.jw.entity.rehabilitation.PatientDischargeDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationAdviceDO;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.hospital.HospitalDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientDischargeDao;
import com.yihu.jw.hospital.module.specialist.dao.PatientMedicalRecordsRehabilitationDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.team.dao.WlyySignFamilyDao;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.hospital.utils.WeiXinOpenIdUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.system.dao.SystemDictDao;
import com.yihu.jw.util.DoctorAssistantUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -46,18 +42,9 @@ import java.util.*;
 */
@Service
@Transactional
public class RehabilitationInfoService extends BaseService {
    @Autowired
    private RehabilitationAdviceDao adviceDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientMedicalRecordsRehabilitationDao patientMedicalRecordsDao;
    @Autowired
    private PatientDao patientDao;
public class RehabilitationInfoService  {
    @Autowired
    private SignFamilyDao signFamilyDao;
    private HospitalDao hospitalDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
@ -71,24 +58,37 @@ public class RehabilitationInfoService extends BaseService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    private HttpClientUtil httpClientUtil;
    @Autowired
    private HospitalDao hospitalDao;
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    private BasePatientService patientService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private SystemDictDao systemDictDao;
    @Autowired
    private PatientService patientService;
    private BaseDoctorDao doctorDao;
    @Autowired
    private DoctorAssistantUtil doctorAssistantUtil;
    private BasePatientDao patientDao;
    @Autowired
    private SystemDictDao systemDictDao;
    private WlyySignFamilyDao signFamilyDao;
    
    
 
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private XxzxMedicalHistoryDisposeDao medicalHistoryDisposeDao;
    private DoctorAssistantUtil doctorAssistantUtil;
//    @Autowired
//    private XxzxMedicalHistoryDisposeDao medicalHistoryDisposeDao;
//    @Autowired
//    private XxzxMedicalHistoryDa medicalHistoryDao;
//
    @Autowired
    private XxzxMedicalHistoryDao medicalHistoryDao;
    private PatientMedicalRecordsRehabilitationDao patientMedicalRecordsDao;
//    @Autowired
//    private HospitalMappingDao hospitalMappingDao;
//    @Autowired
//    private RehabilitationAdviceDao adviceDao;
    public PatientMedicalRecordsDO findByCode(String code) {
@ -99,12 +99,13 @@ public class RehabilitationInfoService extends BaseService {
     * 提醒家医接收
     */
    public void remindDoctorReceive(String diseaseName,String specialistCode,String doctorCode){
        Doctor doctor = doctorDao.findByCode(doctorCode);
        BaseDoctorDO doctor = doctorDao.findById(doctorCode).orElse(null);
        if(StringUtils.isNoneBlank(doctor.getOpenid())){
            Doctor specialist = doctorDao.findByCode(specialistCode);
            BaseDoctorDO specialist = doctorDao.findById(specialistCode).orElse(null);
            //这边先注释掉
            //[医生姓名]医生您好,您收到来自[医院名称]的[医生名称]下转转的[疾病名称]疑似病历患病居民,请访问厦门i健康APP疾病筛查菜单查看。
            String first = doctor.getName()+"医生您好,您收到来自"+specialist.getHospitalName()+"的"+specialist.getName()+"下转的"+diseaseName.replace(","," ")+"疑似病历患病居民,请访问厦门i健康APP疾病筛查菜单查看。";
            doctorAssistantUtil.sendWXTemplate(9,specialist.getOpenid(),specialist.getCid(),first,"请及时处理","筛查转诊",specialist.getHospitalName(),specialist.getName());
//            String first = doctor.getName()+"医生您好,您收到来自"+specialist.getHospitalName()+"的"+specialist.getName()+"下转的"+diseaseName.replace(","," ")+"疑似病历患病居民,请访问厦门i健康APP疾病筛查菜单查看。";
//            doctorAssistantUtil.sendWXTemplate(9,specialist.getOpenid(),specialist.getCid(),first,"请及时处理","筛查转诊",specialist.getHospitalName(),specialist.getName());
        }
    }
@ -179,27 +180,27 @@ public class RehabilitationInfoService extends BaseService {
     * 获取厦心随访门诊病例相关信息
     * @param idCard
     */
    public List<XxzxMedicalHistory> getMedicalHistory(String idCard){
        List<XxzxMedicalHistory> historyList = medicalHistoryDao.findByIdCardNo(idCard);
        for (XxzxMedicalHistory history:historyList){
            List<XxzxMedicalHistoryDispose> disposeList = medicalHistoryDisposeDao.findByHistoryCode(history.getCode());
            history.setDispose(disposeList);
        }
        return historyList;
    }
//    public List<XxzxMedicalHistory> getMedicalHistory(String idCard){
//        List<XxzxMedicalHistory> historyList = medicalHistoryDao.findByIdCardNo(idCard);
//        for (XxzxMedicalHistory history:historyList){
//            List<XxzxMedicalHistoryDispose> disposeList = medicalHistoryDisposeDao.findByHistoryCode(history.getCode());
//            history.setDispose(disposeList);
//        }
//        return historyList;
//    }
    /**
     * 出院就诊详情-厦心出院小结
     * @param code
     * @return
     */
    public XxzxMedicalHistory getMedicalHistoryDetail(String code){
        XxzxMedicalHistory history = medicalHistoryDao.findByCode(code);
        history.setHospitalName(Constant.xmxzzxName);
        List<XxzxMedicalHistoryDispose> disposeList = medicalHistoryDisposeDao.findByHistoryCode(history.getCode());
        history.setDispose(disposeList);
        return history;
    }
//    public XxzxMedicalHistory getMedicalHistoryDetail(String code){
//        XxzxMedicalHistory history = medicalHistoryDao.findByCode(code);
//        history.setHospitalName(Constant.xmxzzxName);
//        List<XxzxMedicalHistoryDispose> disposeList = medicalHistoryDisposeDao.findByHistoryCode(history.getCode());
//        history.setDispose(disposeList);
//        return history;
//    }
    /**
@ -207,7 +208,7 @@ public class RehabilitationInfoService extends BaseService {
     * @param patientCode
     */
    public List<Map<String,Object>> getMedicalHistoryList(String patientCode,Integer page,Integer size){
        Patient patient = patientDao.findByCode(patientCode);
        BasePatientDO patient = patientDao.findById(patientCode).orElse(null);
        if(page<=0){
            page = 1;
        }
@ -225,7 +226,7 @@ public class RehabilitationInfoService extends BaseService {
                "where id_card_no = '"+patient.getIdcard()+"' order by visit_time desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            map.put("hospitalName", Constant.xmxzzxName);
            map.put("hospitalName", "厦心");
            map.put("sex",sexName);
            map.put("age",age);
        }
@ -236,42 +237,42 @@ public class RehabilitationInfoService extends BaseService {
    /**
     * 新增或编辑康复建议模板
     * @param doctorCode
     * @param code 模板code
     * @param name
     * @param content
     * doctorCode
     * code 模板code
     * name
     * content
     */
    public void createAdvice(String doctorCode, String code, String name, String content) {
        RehabilitationAdviceDO adviceDO = null;
        //判断是新增还是编辑
        if (StringUtils.isNotBlank(code)) {
            adviceDO = adviceDao.findByCode(code);
        } else {
            adviceDO = new RehabilitationAdviceDO();
            adviceDO.setCode(getCode());
            Doctor doctor = doctorDao.findByCode(doctorCode);
            adviceDO.setCreateUser(doctorCode);
            adviceDO.setCreateUserName(doctor.getName());
        }
        adviceDO.setName(name);
        adviceDO.setContent(content);
        adviceDO.setCreateTime(new Date());
        adviceDao.save(adviceDO);
    }
    public void deleteAdvice(Long id) {
        adviceDao.delete(id);
    }
//    public void createAdvice(String doctorCode, String code, String name, String content) {
//        RehabilitationAdviceDO adviceDO = null;
//        //判断是新增还是编辑
//        if (StringUtils.isNotBlank(code)) {
//            adviceDO = adviceDao.findByCode(code);
//        } else {
//            adviceDO = new RehabilitationAdviceDO();
//            adviceDO.setCode(getCode());
//            BaseDoctorDO doctor = doctorDao.findByCode(doctorCode);
//            adviceDO.setCreateUser(doctorCode);
//            adviceDO.setCreateUserName(doctor.getName());
//        }
//        adviceDO.setName(name);
//        adviceDO.setContent(content);
//        adviceDO.setCreateTime(new Date());
//        adviceDao.save(adviceDO);
//    }
//    public void deleteAdvice(Long id) {
//        adviceDao.delete(id);
//    }
    /**
     * 获取医生创建康复建议模板及系统模板
     * @param doctorCode
     * @return
     */
    public List<RehabilitationAdviceDO> getAdviceListByDoctor(String doctorCode) {
        List<RehabilitationAdviceDO> list = adviceDao.findByDoctor(doctorCode);
        return list;
    }
//    public List<RehabilitationAdviceDO> getAdviceListByDoctor(String doctorCode) {
//        List<RehabilitationAdviceDO> list = adviceDao.findByDoctor(doctorCode);
//        return list;
//    }
    /**
     * 新增住院病历
@ -283,31 +284,31 @@ public class RehabilitationInfoService extends BaseService {
     * @return
     */
    public PatientMedicalRecordsDO createMedicalRecords(String doctorCode, String patient, String patientName, PatientMedicalRecordsDO patientMedicalRecordsDO, Long id) {
        Doctor doctor = doctorDao.findByCode(doctorCode);
        BaseDoctorDO doctor = doctorDao.findById(doctorCode).orElse(null);
        if(id != null){
            PatientMedicalRecordsDO oldRecord  = patientMedicalRecordsDao.findOne(id);
            patientMedicalRecordsDO.setId(id);
            PatientMedicalRecordsDO oldRecord  = patientMedicalRecordsDao.findById(id).orElse(null);
            patientMedicalRecordsDO.setId(id.toString());
            patientMedicalRecordsDO.setCode(oldRecord.getCode());
        }else {
            patientMedicalRecordsDO.setCode(getCode());
            patientMedicalRecordsDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
        }
        patientMedicalRecordsDO.setPatient(patient);
        patientMedicalRecordsDO.setPatientName(patientName);
        if(StringUtils.isBlank(patientMedicalRecordsDO.getHospital())){
            patientMedicalRecordsDO.setHospital(doctor.getHospital());
            patientMedicalRecordsDO.setHospitalName(doctor.getHospitalName());
//            patientMedicalRecordsDO.setHospital(doctor.getHospital());
//            patientMedicalRecordsDO.setHospitalName(doctor.getHospitalName());
        }else{
            //如果有传 hospital根据传过来的hospital来定义
            if("3".equals(patientMedicalRecordsDO.getDataFrom())||"1".equals(patientMedicalRecordsDO.getDataFrom())){
                //hospital为自己的code
                Hospital hospital = hospitalDao.findByCode(patientMedicalRecordsDO.getHospital());
                DmHospitalDO hospital = hospitalDao.findByCode(patientMedicalRecordsDO.getHospital());
                patientMedicalRecordsDO.setHospital(hospital.getCode());
                patientMedicalRecordsDO.setHospitalName(hospital.getName());
            }else{
                //hospital为基位的code
                HospitalMapping hospitalMapping = hospitalMappingDao.findByMappingCode(patientMedicalRecordsDO.getHospital());
//                patientMedicalRecordsDO.setHospital(hospitalMapping.getCode());
                patientMedicalRecordsDO.setHospitalName(hospitalMapping.getName());
//                HospitalMapping hospitalMapping = hospitalMappingDao.findByMappingCode(patientMedicalRecordsDO.getHospital());
////                patientMedicalRecordsDO.setHospital(hospitalMapping.getCode());
//                patientMedicalRecordsDO.setHospitalName(hospitalMapping.getName());
            }
        }
@ -768,37 +769,37 @@ public class RehabilitationInfoService extends BaseService {
     * 提醒居民家签
     * @param patient
     */
    public void sendWxMsgRemindSign(String patient) throws Exception {
        org.json.JSONObject json = new org.json.JSONObject();
        if(StringUtils.isNotBlank(patient)) {
            Patient p = patientDao.findByCode(patient);
            json.put("first", p.getName() + "您好!为方便为您提供康复管理服务,请先选择合适的社区和家庭医生进行签约。");
            json.put("toUser", patient);
            json.put("represented", patient);//被代理人
            json.put("keyword1", "家庭医生签约");
            json.put("keyword2", DateUtil.dateToStrShort(new Date()));
            json.put("remark", "");
            if (StringUtils.isNotBlank(p.getOpenid())) {
                json.put("url",  "/qygl/html/signing-welcome.html?openid=" + p.getOpenid() + "&toUser=" + patient + "&toName=" + p.getName());
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 35, p.getOpenid(), p.getName(), json);
            }else {
                //发送代理人
                org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
                if (jsonArray != null && jsonArray.length() > 0) {
                    for (int i = 0; i < jsonArray.length(); i++) {
                        org.json.JSONObject j = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        org.json.JSONObject data = json;
                        data.remove("toUser");
                        data.put("toUser", member.getCode());
                        data.remove("first");
                        data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()));
                        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 35, member.getOpenid(), p.getName(), data);
                    }
                }
            }
        }
    }
//    public void sendWxMsgRemindSign(String patient) throws Exception {
//        org.json.JSONObject json = new org.json.JSONObject();
//        if(StringUtils.isNotBlank(patient)) {
//            Patient p = patientDao.findByCode(patient);
//            json.put("first", p.getName() + "您好!为方便为您提供康复管理服务,请先选择合适的社区和家庭医生进行签约。");
//            json.put("toUser", patient);
//            json.put("represented", patient);//被代理人
//            json.put("keyword1", "家庭医生签约");
//            json.put("keyword2", DateUtil.dateToStrShort(new Date()));
//            json.put("remark", "");
//            if (StringUtils.isNotBlank(p.getOpenid())) {
//                json.put("url",  "/qygl/html/signing-welcome.html?openid=" + p.getOpenid() + "&toUser=" + patient + "&toName=" + p.getName());
//                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 35, p.getOpenid(), p.getName(), json);
//            }else {
//                //发送代理人
//                org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
//                if (jsonArray != null && jsonArray.length() > 0) {
//                    for (int i = 0; i < jsonArray.length(); i++) {
//                        org.json.JSONObject j = jsonArray.getJSONObject(i);
//                        Patient member = (Patient) j.get("member");
//                        org.json.JSONObject data = json;
//                        data.remove("toUser");
//                        data.put("toUser", member.getCode());
//                        data.remove("first");
//                        data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()));
//                        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 35, member.getOpenid(), p.getName(), data);
//                    }
//                }
//            }
//        }
//    }
    /**
     *
@ -810,8 +811,8 @@ public class RehabilitationInfoService extends BaseService {
    public JSONObject getPatientByIdcardOrSsc(String patientInfo, Integer type, String doctorCode) {
        //加签列表查询wlyy_patient_discharge表,与type无关。当家签处添加时(即type=1),统一保存type=2的记录
        JSONObject data = new JSONObject();
        List<Patient> patientList = patientDao.getPatientByIdcardOrSsc(patientInfo);
        Patient patient = null;
        List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(patientInfo);
        BasePatientDO patient = null;
        if(patientList.size() == 0){
            //未找到居民,从健康档案添加居民
            if(type==2){
@ -827,7 +828,7 @@ public class RehabilitationInfoService extends BaseService {
            return data;
        }
        Doctor doctor = doctorDao.findByCode(doctorCode);
        BaseDoctorDO doctor = doctorDao.findById(doctorCode).orElse(null);
        //判断是否添加过该居民
        Integer patientDischargeDOS =0;
        if (type==2){//查询下转是否存在该患者:sign_status=1(包括type==null,type==2) 1.6.8后新增未家签的也能添加患者 判断条件(d.type=2 and sign_status=0)
@ -845,9 +846,9 @@ public class RehabilitationInfoService extends BaseService {
        }
        PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
        patientDischargeDO.setCode(getCode());
        patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
        patientDischargeDO.setType(2);//统一保存为2
        patientDischargeDO.setPatient(patient.getCode());
        patientDischargeDO.setPatient(patient.getId());
        patientDischargeDO.setName(patient.getName());
        patientDischargeDO.setIdcard(patient.getIdcard());
        patientDischargeDO.setSsc(patient.getSsc());

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

@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -1715,4 +1716,9 @@ public class RehabilitationManageService {
        return array;
    }
}

+ 242 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationPlanService.java

@ -33,6 +33,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -589,7 +591,247 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
        String sql = " SELECT * FROM `base`.`wlyy_frequency` WHERE del='1' ";
        List<Frequency> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(Frequency.class));
        return ListEnvelop.getSuccess(SpecialistMapping.api_success, list);
    }
    public List<String> getFrequencyDate(String code,String date,String unit,String time,Long timeType) throws ParseException {
        List<String> list = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String nowDate = date+":00";
        Date date6 = DateUtil.strToDateLong(nowDate);
        String date9 = sdf.format(date6)+" 09:00:00";//白天
        String date21 = sdf.format(date6)+" 21:00:00";//白天
        String date9s = DateUtil.getNextDay(date6,1)+" 09:00:00";//晚上
        Calendar calendar = Calendar.getInstance();
        if (unit.equalsIgnoreCase("D")&&!code.equalsIgnoreCase("qod")){
            String[] str = time.split(",");
            for (int i=0;i<str.length;i++){
                Date date1 = sdf.parse(date);
                calendar.setTime(date1);
                String lastDay = sdf.format(calendar.getTime()) + " "+str[i];
                list.add(lastDay);
            }
        }else if (unit.equalsIgnoreCase("D")&&code.equalsIgnoreCase("qod")){
            Date date1 = sdf.parse(date);
            calendar.setTime(date1);
            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) +1);
            String lastDay = sdf.format(calendar.getTime()) + " "+time;
            list.add(lastDay);
        }else if (unit.equalsIgnoreCase("H")&&code.equalsIgnoreCase("q0.5h")){
            Date date1 = sdf.parse(date);
            calendar.setTime(date1);
            String endTime = null;
            String lastDay = null;
            if (timeType == 0){
                lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
                endTime = sdf.format(calendar.getTime()) + " 23:59:59";
            }else if ( timeType == 1){
                lastDay = date9;
                endTime = date21;
            }else if (timeType == 2){
                lastDay = date21;
                endTime = date9s;
            }
            Date date2 = sdf1.parse(lastDay);
            Date date3 = sdf1.parse(endTime);
            Long time1 = date2.getTime();
            for (int i=0;i<47;i++){
                time1 += 30*60*1000;
                String day = sdf1.format(time1);
                Date date4 = sdf1.parse(day);
                if (date4.compareTo(date3)==-1 || date4.compareTo(date3) == 0){
                    list.add(day);
                }
            }
        }else if (unit.equalsIgnoreCase("H")&& code.equalsIgnoreCase("q2h")){
            Date date1 = sdf.parse(date);
            calendar.setTime(date1);
            /*      String lastDay = sdf.format(calendar.getTime()) + " 00:00:00";*/
            String endTime = null;
            String lastDay = null;
            if (timeType == 0){
                lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
                endTime = sdf.format(calendar.getTime()) + " 23:59:59";
            }else if ( timeType == 1){
                lastDay = date9;
                endTime = date21;
            }else if (timeType == 2){
                lastDay = date21;
                endTime = date9s;
            }
            Date date2 = sdf1.parse(lastDay);
            Date date3 = sdf1.parse(endTime);
            calendar.setTime(date2);
            for (int i=0;i<11;i++){
                calendar.set(Calendar.HOUR,calendar.get(Calendar.HOUR)+2);
                Date date4 = sdf1.parse(sdf1.format(calendar.getTime()));
                System.out.print(sdf1.format(calendar.getTime()));
                if (date4.compareTo(date3)==-1||date4.compareTo(date3) == 0){
                    list.add(sdf1.format(calendar.getTime()));
                }
            }
        }else if (unit.equalsIgnoreCase("H")&&code.equalsIgnoreCase("q3h")){
            Date date1 = sdf.parse(date);
            calendar.setTime(date1);
            //String lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
            String endTime = null;
            String lastDay = null;
            if (timeType == 0){
                lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
                endTime = sdf.format(calendar.getTime()) + " 23:59:59";
            }else if ( timeType == 1){
                lastDay = date9;
                endTime = date21;
            }else if (timeType == 2){
                lastDay = date21;
                endTime = date9s;
            }
            Date date2 = sdf1.parse(lastDay);
            Date date3 = sdf1.parse(endTime);
            calendar.setTime(date2);
            for (int i=0;i<7;i++){
                calendar.set(Calendar.HOUR,calendar.get(Calendar.HOUR)+3);
                Date date4 = sdf1.parse(sdf1.format(calendar.getTime()));
                if (date4.compareTo(date3)==-1||date4.compareTo(date3) == 0){
                    list.add(sdf1.format(calendar.getTime()));
                }
            }
        }else if (unit.equalsIgnoreCase("H")&&code.equalsIgnoreCase("q4h")){
            Date date1 = sdf.parse(date);
            calendar.setTime(date1);
            //String lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
            String endTime = null;
            String lastDay = null;
            if (timeType == 0){
                lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
                endTime = sdf.format(calendar.getTime()) + " 23:59:59";
            }else if ( timeType == 1){
                lastDay = date9;
                endTime = date21;
            }else if (timeType == 2){
                lastDay = date21;
                endTime = date9s;
            }
            Date date2 = sdf1.parse(lastDay);
            Date date3 = sdf1.parse(endTime);
            calendar.setTime(date2);
            for (int i=0;i<5;i++){
                calendar.set(Calendar.HOUR,calendar.get(Calendar.HOUR)+4);
                Date date4 = sdf1.parse(sdf1.format(calendar.getTime()));
                if (date4.compareTo(date3)==-1||date4.compareTo(date3) == 0){
                    list.add(sdf1.format(calendar.getTime()));
                }
            }
        }else if (unit.equalsIgnoreCase("H")&&code.equalsIgnoreCase("qh")){
            Date date1 = sdf.parse(date);
            calendar.setTime(date1);
            //String lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
            String endTime = null;
            String lastDay = null;
            if (timeType == 0){
                lastDay = sdf.format(calendar.getTime()) + " 00:00:00";
                endTime = sdf.format(calendar.getTime()) + " 23:59:59";
            }else if ( timeType == 1){
                lastDay = date9;
                endTime = date21;
            }else if (timeType == 2){
                lastDay = date21;
                endTime = date9s;
            }
            Date date2 = sdf1.parse(lastDay);
            Date date3 = sdf1.parse(endTime);
            calendar.setTime(date2);
            for (int i=0;i<23;i++){
                calendar.set(Calendar.HOUR,calendar.get(Calendar.HOUR)+1);
                Date date4 = sdf1.parse(sdf1.format(calendar.getTime()));
                if (date4.compareTo(date3)==-1||date4.compareTo(date3) == 0){
                    list.add(sdf1.format(calendar.getTime()));
                }
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_1")){
            String date2 = DateUtil.getWeek(date,"1")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_2")){
            String date2 = DateUtil.getWeek(date,"2")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_3")){
            String date2 = DateUtil.getWeek(date,"3")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_4")){
            String date2 = DateUtil.getWeek(date,"4")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_5")){
            String date2 = DateUtil.getWeek(date,"5")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_6")){
            String date2 = DateUtil.getWeek(date,"6")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("qw_7")){
            String date2 = DateUtil.getWeek(date,"7")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("tiw135")){
            String date2 = DateUtil.getWeek(date,"1")+" 08:00:00";
            String date4 = DateUtil.getWeek(date,"3")+" 08:00:00";
            String date5 = DateUtil.getWeek(date,"5")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
            if (date4.compareTo(date3)==1){
                list.add(date2);
            }
            if (date5.compareTo(date3) == 1){
                list.add(date2);
            }
        }else if (unit.equalsIgnoreCase("W")&&code.equalsIgnoreCase("tiw246")){
            String date2 = DateUtil.getWeek(date,"2")+" 08:00:00";
            String date4 = DateUtil.getWeek(date,"4")+" 08:00:00";
            String date5 = DateUtil.getWeek(date,"6")+" 08:00:00";
            Date date1 = new Date();
            String date3 = sdf1.format(date1);
            if (date2.compareTo(date3)==1){
                list.add(date2);
            }
            if (date4.compareTo(date3)==1){
                list.add(date2);
            }
            if (date5.compareTo(date3) == 1){
                list.add(date2);
            }
        }
        return list;
    }
}

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

@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.BaseFrequencyDictDao;
import com.yihu.jw.dict.dao.FrequencyDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.door.SignPatientLabelInfo;
import com.yihu.jw.entity.hospital.DmHospitalDO;
import com.yihu.jw.entity.hospital.appointment.WlyySpecialDiseaseDO;
import com.yihu.jw.entity.hospital.doctor.Frequency;
import com.yihu.jw.entity.rehabilitation.PatientDischargeDO;
@ -23,6 +26,8 @@ import com.yihu.jw.hospital.async.AsynService;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationPatientInfoDao;
import com.yihu.jw.hospital.module.specialist.dao.PatientDiseaseServerDao;
import com.yihu.jw.hospital.team.dao.SignPatientLabelInfoDao;
import com.yihu.jw.hospital.team.dao.WlyyAdminTeamDao;
import com.yihu.jw.hospital.team.dao.WlyySignFamilyDao;
import com.yihu.jw.patient.dao.BasePatientDao;
@ -46,6 +51,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yihu.jw.util.html.HtmlUtil;
/**
 * Created by liub on 2020/9/29.
@ -56,9 +62,9 @@ public class SynchronizePatientService  {
    private Logger logger = LoggerFactory.getLogger(SynchronizePatientService.class);
    @Value("${specialist.url}")
//    @Value("${specialist.url}")
    private String specialistUrl;
    @Value("${demo.flag}")
//    @Value("${demo.flag}")
    private Boolean demoFlag;
    private Map<String,List> hospitalSyncDisease = new HashMap<>();//医院自动下转疾病配置
    @Autowired
@ -84,7 +90,11 @@ public class SynchronizePatientService  {
    @Autowired
    private FollowUpService followUpService;
    @Autowired
    private BaseFrequencyDictDao frequencyDao;
    private BaseFrequencyDictDao baseFrequencyDao;
    @Autowired
    private FrequencyDao frequencyDao;
    @Autowired
    private AsynService asynService;
    @Autowired
@ -141,7 +151,7 @@ public class SynchronizePatientService  {
            saveModifyList(modifyList);
            return "未查询到该医院: "+re.getHospitalName()+",无法进行下转";
        }
        Hospital hos = hospitalDao.findByCode(hospitalCode);
        DmHospitalDO hos = hospitalDao.findByCode(hospitalCode);
        if(hos==null){
            infoUpdate(tmpList,4,modifyList,null);
            saveModifyList(modifyList);
@ -159,7 +169,7 @@ public class SynchronizePatientService  {
        }
        Long teamId = wlyyAdminTeamDao.findTeamID(diseaseObj.getString("disease"), 0, hos.getCode());
        String leaderCode = wlyyAdminTeamDao.findTeamLeader(diseaseObj.getString("disease"), 0, hos.getCode());
        BaseDoctorDO doctor = doctorDao.findByCode(leaderCode);
        BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
        //如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
        String hospitalDoctor = re.getHospitalDoctor();  //   曾昭萍/350*******64
        if (StringUtils.isNoneBlank(hospitalDoctor)){
@ -167,7 +177,7 @@ public class SynchronizePatientService  {
            if (tmp.length==2){//存在唯一标识身份证
                String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
                        " where doc.del=1 and doc.idcard='"+tmp[1]+"'";
                List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
                List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
                if (doctors.size()>0){
                    doctor = doctors.get(0);
                }
@ -482,7 +492,7 @@ public class SynchronizePatientService  {
    public void saveModifyList(List<RehabilitationPatientInfoDO> modifyList){
        if(modifyList.size()>0){
            rehabilitationPatientInfoDao.save(modifyList);
            rehabilitationPatientInfoDao.saveAll(modifyList);
        }
    }
@ -534,7 +544,7 @@ public class SynchronizePatientService  {
                infoUpdate(tmpList,4,modifyList,null);
                continue;
            }
            Hospital hos = hospitalDao.findByCode(hospitalCode);
            DmHospitalDO  hos = hospitalDao.findByCode(hospitalCode);
            if(hos==null){
                results.append(re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转\n");
                logger.info("康复计划自动下转————" + re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转");
@ -557,7 +567,7 @@ public class SynchronizePatientService  {
            Long teamId = wlyyAdminTeamDao.findTeamID(diseaseObj.getString("disease"), 0, hos.getCode());
//            AdminTeam adminTeam = wlyyAdminTeamDao.findAdminTeamById(teamId);//接收该病种团队
            String leaderCode = wlyyAdminTeamDao.findTeamLeader(diseaseObj.getString("disease"), 0, hos.getCode());
            BaseDoctorDO doctor = doctorDao.findByCode(leaderCode);
            BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
            //如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
            String hospitalDoctor = re.getHospitalDoctor();  //   曾昭萍/350*******64
            if (StringUtils.isNoneBlank(hospitalDoctor)){
@ -565,7 +575,7 @@ public class SynchronizePatientService  {
                if (tmp.length==2){//存在唯一标识身份证
                    String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
                            " where doc.del=1 and doc.idcard='"+tmp[1]+"'";
                    List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
                    List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
                    if (doctors.size()>0){
                        doctor = doctors.get(0);
                    }
@ -788,7 +798,7 @@ public class SynchronizePatientService  {
            PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
            PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(doctor.getId(), patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
            BaseDoctorDO familyDoctor = doctorDao.findByCode(signFamily.getDoctor());
            BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
            if (patientMedicalRecordsDO1 == null) {
                results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
                logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
@ -940,7 +950,7 @@ public class SynchronizePatientService  {
//            sendMessageToDoctor(syncObject);//APP端发送消息通知
//            sendMessageToDoctorTemplates(syncObject);//i健康助手发送消息通知
//        }
        rehabilitationPatientInfoDao.save(modifyList);
        rehabilitationPatientInfoDao.saveAll(modifyList);
        return results;
    }
@ -993,7 +1003,7 @@ public class SynchronizePatientService  {
                infoUpdate(tmpList,4,modifyList,null);
                continue;
            }
            Hospital hos = hospitalDao.findByCode(hospitalCode);
            DmHospitalDO  hos = hospitalDao.findByCode(hospitalCode);
            if(hos==null){
                results.append(re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转\n");
                logger.info("康复计划自动下转————" + re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转");
@ -1016,7 +1026,7 @@ public class SynchronizePatientService  {
            Long teamId = wlyyAdminTeamDao.findTeamID(diseaseObj.getString("disease"), 0, hos.getCode());
//            AdminTeam adminTeam = wlyyAdminTeamDao.findAdminTeamById(teamId);//接收该病种团队
            String leaderCode = wlyyAdminTeamDao.findTeamLeader(diseaseObj.getString("disease"), 0, hos.getCode());
            BaseDoctorDO doctor = doctorDao.findByCode(leaderCode);
            BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
            //如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
            String hospitalDoctor = re.getHospitalDoctor();  //   曾昭萍/350*******64
            if (StringUtils.isNoneBlank(hospitalDoctor)){
@ -1024,7 +1034,7 @@ public class SynchronizePatientService  {
                if (tmp.length==2){//存在唯一标识身份证
                    String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
                            " where doc.del=1 and doc.idcard='"+tmp[1]+"'";
                    List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
                    List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
                    if (doctors.size()>0){
                        doctor = doctors.get(0);
                    }
@ -1247,7 +1257,7 @@ public class SynchronizePatientService  {
            PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
            PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(doctor.getId(), patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
            BaseDoctorDO familyDoctor = doctorDao.findByCode(signFamily.getDoctor());
            BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
            if (patientMedicalRecordsDO1 == null) {
                results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
                logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
@ -1436,8 +1446,9 @@ public class SynchronizePatientService  {
                    detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
                    detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
                    detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
                    detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
                    detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                    //先注释-20231013
//                    detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
//                    detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                    detailArray.put(detail);
                }else if(bl&&("6".equals(templateMap.get("code").toString())||"7".equals(templateMap.get("code").toString()))){
                    //判断厦心出转病人,创建复诊计划
@ -1459,8 +1470,9 @@ public class SynchronizePatientService  {
                            detail.put("timeType", 0);//
                            detail.put("remark", "");//
                            detail.put("expense", 0);//
                            detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
                            detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                            //先注释-20231013
//                            detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
//                            detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                            detail.put("reservationType",2);//复诊类型:1线上,2线下,3远程
                            detailArray.put(detail);
                        }
@ -1480,8 +1492,9 @@ public class SynchronizePatientService  {
                            detail.put("timeType", 0);//
                            detail.put("remark", "");//
                            detail.put("expense", 0);//
                            detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
                            detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                            //先注释-20231013
//                            detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
//                            detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                            detail.put("reservationType",2);//复诊类型:1线上,2线下,3远程
                            detailArray.put(detail);
                        }
@ -1526,8 +1539,9 @@ public class SynchronizePatientService  {
                    detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
                    detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
                    detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
                    detail.put("hospital", doctor.getHospital());
                    detail.put("hospitalName", doctor.getHospitalName());
                    //先注释20231013
//                    detail.put("hospital", doctor.getHospital());
//                    detail.put("hospitalName", doctor.getHospitalName());
                    detailArray.put(detail);
                }
            }
@ -1565,17 +1579,17 @@ public class SynchronizePatientService  {
            json.put("id", planId);
            SignFamily signFamily = signFamilyDao.findByPatient(patient);
            BaseDoctorDO familyDoctor = doctorDao.findByCode(signFamily.getDoctor());
            BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
            Long teamId = wlyyAdminTeamDao.findTeamID("3", 0, "97fbc7707643471b8458-6def1ff92496");
            String leaderCode = wlyyAdminTeamDao.findTeamLeader("3", 0, "97fbc7707643471b8458-6def1ff92496");
            BaseDoctorDO doctor = doctorDao.findByCode(leaderCode);
            BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
            //如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
            if (StringUtils.isNoneBlank(hospitalDoctor)){
                String[] tmp = hospitalDoctor.split("/");
                if (tmp.length==2){//存在唯一标识身份证
                    String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
                            " where doc.del=1 and doc.idcard='"+tmp[1]+"'";
                    List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
                    List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
                    if (doctors.size()>0){
                        doctor = doctors.get(0);
                    }
@ -1666,8 +1680,9 @@ public class SynchronizePatientService  {
                    detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
                    detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
                    detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
                    detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
                    detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                    //先注释20231013
//                    detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
//                    detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
                    detailArray.put(detail);
                }else if("6".equals(templateMap.get("code").toString())||"7".equals(templateMap.get("code").toString())){
@ -1680,7 +1695,7 @@ public class SynchronizePatientService  {
                        String executeTimes = templateMap.get("executeTimes").toString();
                        String frequencyCode = templateMap.get("frequencyCode").toString();
                        if (StringUtils.isNotBlank(executeTimes) && StringUtils.isNoneBlank(frequencyCode)) {
                            BaseFrequencyDictDO frequency = frequencyDao.findByCode(frequencyCode);
                            Frequency frequency = frequencyDao.findByCode(frequencyCode);
                            List<String> list = new ArrayList<>();
                            String[] executeTime = executeTimes.split(",");
                            for (int i = 0; i < executeTime.length; i++) {
@ -1711,8 +1726,8 @@ public class SynchronizePatientService  {
                    detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
                    detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
                    detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
                    detail.put("hospital", doctor.getHospital());
                    detail.put("hospitalName", doctor.getHospitalName());
//                    detail.put("hospital", doctor.getHospital());
//                    detail.put("hospitalName", doctor.getHospitalName());
                    detailArray.put(detail);
                }
            }
@ -1840,15 +1855,25 @@ public class SynchronizePatientService  {
    public String getDiseaseCodeByProblemCode(String problemCode){
        if(problemCode.equals("1001")) return "11"; //肺癌
        else if(problemCode.equals("1002")) return "14"; // "慢性胃肠病";
        else if(problemCode.equals("1003")) return "3"; // "冠心病";
        else if(problemCode.equals("1004")) return "10"; // "慢性前列腺";
        else if(problemCode.equals("1005")) return "13"; // "慢性乳腺疾病";
        else if(problemCode.equals("1006")) return "15"; // "慢性阻塞性肺病";
        else if(problemCode.equals("1007")) return "16"; // "慢性肝病";
        else if(problemCode.equals("1008")) return "17"; // "慢性妇科炎症";
        else if(problemCode.equals("1009")) return "9"; // "脑卒中";
        else if(problemCode.equals("1010")) return "12"; // "慢性肾病";
        else if(problemCode.equals("1002")) {
            return "14"; // "慢性胃肠病";
        } else if(problemCode.equals("1003")) {
            return "3"; // "冠心病";
        } else if(problemCode.equals("1004")) {
            return "10"; // "慢性前列腺";
        } else if(problemCode.equals("1005")) {
            return "13"; // "慢性乳腺疾病";
        } else if(problemCode.equals("1006")) {
            return "15"; // "慢性阻塞性肺病";
        } else if(problemCode.equals("1007")) {
            return "16"; // "慢性肝病";
        } else if(problemCode.equals("1008")) {
            return "17"; // "慢性妇科炎症";
        } else if(problemCode.equals("1009")) {
            return "9"; // "脑卒中";
        } else if(problemCode.equals("1010")) {
            return "12"; // "慢性肾病";
        }
        return null;
    }

File diff suppressed because it is too large
+ 159 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/ZsRehabilitationInfoService.java


+ 29 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/specialist/dao/PatientDiseaseServerDao.java

@ -0,0 +1,29 @@
package com.yihu.jw.hospital.module.specialist.dao;
import com.yihu.jw.entity.specialist.rehabilitation.PatientDiseaseServer;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/7/4.
 */
public interface PatientDiseaseServerDao extends
        PagingAndSortingRepository<PatientDiseaseServer, Long>,
        JpaSpecificationExecutor<PatientDiseaseServer> {
    List<PatientDiseaseServer> findByPatientAndDel(String patient, String del);
    List<PatientDiseaseServer> findBySpecialistRelationCodeAndDel(String code, String del);
    @Query(value = "select  p from PatientDiseaseServer p where p.specialistRelationCode=?1 and p.disease=?2 and p.del=?3")
    PatientDiseaseServer findBySpecialistRelationCodeAndDiseaseAndCode(String specialistRelationCode, String disease, String del);
    @Modifying
    @Query("update PatientDiseaseServer pds set pds.del=0 where pds.specialistRelationCode=?1")
    void updateBySpecialistRelationCodeAndDel(String code);
}

+ 19 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/specialist/dao/PatientMedicalRecordsRehabilitationDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.hospital.module.specialist.dao;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientMedicalRecordsRehabilitationDao extends PagingAndSortingRepository<PatientMedicalRecordsDO, Long>, JpaSpecificationExecutor<PatientMedicalRecordsDO> {
    @Query("select p from PatientMedicalRecordsDO p where p.code = ?1")
    PatientMedicalRecordsDO findByCode(String code);
    
    List<PatientMedicalRecordsDO> findByPatient(String patient);
    
    
}

+ 2 - 0
svr/svr-visit-behind/src/main/resources/application.yml

@ -1457,6 +1457,8 @@ basedb:
  name: base
base:
  url: http://172.17.110.212:10020/
# ====================================================