Browse Source

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

wangzhinan 2 years ago
parent
commit
22837eec17
33 changed files with 514 additions and 621 deletions
  1. 14 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageLogService.java
  2. 30 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionLogService.java
  3. 8 4
      business/base-service/src/main/java/com/yihu/jw/message/service/WxMessageUtil.java
  4. 3 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java
  5. 0 2
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  6. 4 1
      common/common-entity/sql记录
  7. 135 0
      common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/PatientDischargeDO.java
  8. 9 9
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/dao/followup/FollowUpDao.java
  9. 26 0
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/dao/rehabilitation/PatientDischargeDao.java
  10. 1 1
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/dao/rehabilitation/PatientMedicalRecordsRehabilitationDao.java
  11. 4 4
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/endpoint/health/DoctorHealthController.java
  12. 1 15
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/endpoint/rehabilitation/DoctorRehabilitaionInfoController.java
  13. 1 1
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/device/PatientDeviceLogService.java
  14. 1 1
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/device/PatientDeviceService.java
  15. 7 9
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/followup/FollowUpService.java
  16. 0 2
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PatientPrescriptionPayService.java
  17. 1 0
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionAdjustService.java
  18. 14 14
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionDiagnosisService.java
  19. 1 1
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionDispensaryCodeService.java
  20. 0 28
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionExpressageLogService.java
  21. 6 6
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionInfoService.java
  22. 0 60
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionLogService.java
  23. 14 14
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/WlyyPrescriptionExpressageService.java
  24. 1 4
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/WlyyPrescriptionService.java
  25. 7 7
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationGuidanceService.java
  26. 77 152
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationInfoService.java
  27. 8 18
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationManageService.java
  28. 2 69
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationPlanService.java
  29. 5 5
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/SpecialistScreenResultService.java
  30. 75 128
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/SpecialistService.java
  31. 45 63
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/WlyyRehabilitationManageService.java
  32. 3 3
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/WlyyRehabilitationPlanService.java
  33. 11 0
      svr/svr-after-diagnosis/src/mian/resources/application.yml

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageLogService.java

@ -3,8 +3,11 @@ package com.yihu.jw.hospital.prescription.service;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageLogDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageLogDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 *  门诊物流日志服务
 * lith 2019.06.04
@ -13,4 +16,15 @@ import org.springframework.stereotype.Service;
@Service
public class PrescriptionExpressageLogService extends BaseJpaService<WlyyPrescriptionExpressageLogDO, PrescriptionExpressageLogDao> {
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    /**
     * 根据处方号获取该处方的物流配送日志,按路由节点发生的时间倒序排序
     * @param prescriptionCode
     * @return
     */
    public List<WlyyPrescriptionExpressageLogDO> findByPrescriptionCode(String prescriptionCode){
        return prescriptionExpressageLogDao.queryByOutpatientId(prescriptionCode);
    }
}

+ 30 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionLogService.java

@ -107,4 +107,34 @@ public class PrescriptionLogService  extends BaseJpaService<WlyyPrescriptionLogD
        list.clear();
        return wlyyPrescriptionLogDOList;
    }
    /**
     * 添加日志
     *
     * @param prescription
     * @param type         类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
     * @param flag         1成功 0失败
     * @param userType     1 患者 2医生
     */
    public void addLog(WlyyPrescriptionDO prescription, Integer type, Integer flag, Integer userType) {
        WlyyPrescriptionLogDO log = null;
        List<WlyyPrescriptionLogDO> prescriptionLogs = logDao.findByPrescriptionCodeAndStutas(prescription.getId(), prescription.getStatus());
        if (prescriptionLogs == null || prescriptionLogs.size() == 0) {
            log = new WlyyPrescriptionLogDO();
        } else {
            log = logDao.findById(prescriptionLogs.get(0).getId()).orElse(null);
        }
        log.setStatus(prescription.getStatus());
        log.setCreateTime(new Date());
        log.setPrescriptionCode(prescription.getId());
        if (userType == 1) {
            log.setUserCode(prescription.getPatientCode());
            log.setUserName(prescription.getPatientName());
        } else {
            log.setUserCode(prescription.getDoctor());
            log.setUserName(prescription.getDoctorName());
        }
        log.setUserType(userType);
        logDao.save(log);
    }
}

+ 8 - 4
business/base-service/src/main/java/com/yihu/jw/message/service/WxMessageUtil.java

@ -4,16 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorHealthUploadDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
@ -51,6 +49,12 @@ public class WxMessageUtil {
    private BasePatientWechatDao basePatientWechatDao;
    @Resource
    private BaseOrgDao orgDao;
    @Resource
    private WechatDao wechatDao;
    public WxWechatDO getWxWechat(){
        return wechatDao.findById(wechatId).orElse(null);
    }
    public String getWechatId(){

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

@ -59,4 +59,7 @@ public interface BasePatientDao extends JpaRepository<BasePatientDO, String>, Jp
    BasePatientDO findByIdAndDel(String id,String del);
    List<BasePatientDO> findByNameAndIdcard(String name,String idcard);
    @Query("select p from BasePatientDO p where (p.idcard = ?1 or p.ssc = ?1 )  and p.del = '1'")
    List<BasePatientDO> getPatientByIdcardOrSsc(String patientInfo);
}

+ 0 - 2
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -79,8 +79,6 @@ public class ElasticsearchUtil {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${es.type.Statistics}")
    private String esType;
    @Value("${es.index.Statistics}")
    private String esIndex;

+ 4 - 1
common/common-entity/sql记录

@ -2151,4 +2151,7 @@ CREATE TABLE `base_yujing_dict` (
ALTER table base_daily_report_item add COLUMN `project_code` varchar(50) DEFAULT NULL COMMENT '项目code 字典base_daily_report_item';
ALTER table base_daily_report_item add COLUMN `ac_begin_time` varchar(50) DEFAULT NULL COMMENT '项目实际开始时间';
ALTER table base_daily_report_item add COLUMN `dept` varchar(50) DEFAULT NULL COMMENT '部门';
ALTER table base_daily_report_item add COLUMN `dept_name` varchar(50) DEFAULT NULL COMMENT '部门名称';
ALTER table base_daily_report_item add COLUMN `dept_name` varchar(50) DEFAULT NULL COMMENT '部门名称';
-- 2023-02-27
base_patient_doctor 暂时用来代替 wlyy_sign_family

+ 135 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/PatientDischargeDO.java

@ -0,0 +1,135 @@
package com.yihu.jw.entity.rehabilitation;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name = "wlyy_patient_discharge")
public class PatientDischargeDO extends IdEntity {
    // 业务主键
    private String code;
    private String patient;    //居民code
    // 身份证号
    private String idcard;
    // 姓名
    private String name;
    // 社保卡號
    private String ssc;
    private String hospital;//居民签约所在机构code
    private String hospitalName;//机构名称
    private String address;//地址
    private Integer type;//1患者家签列表 2康复下转列表
    private Integer signStatus;//签约状态(1已家签 0 待家签)
    private String createUser;//创建code
    private String createUserName;//创建者
    private Date createTime;//创建时间
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public Integer getSignStatus() {
        return signStatus;
    }
    public void setSignStatus(Integer signStatus) {
        this.signStatus = signStatus;
    }
}

+ 9 - 9
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/dao/followup/FollowUpDao.java

@ -48,10 +48,10 @@ 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 order by a.followupPlanDate DESC")
    List<Followup> findAllDoctorPlan(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.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")
    @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,7 +70,7 @@ 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")
    @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'")
    Page<Object> findByPatientAndTeam(String patient, Long teamCode, String doctor,Pageable pageable);
    /**
@ -79,7 +79,7 @@ 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")
    @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, Pageable pageable);
    /**
@ -88,7 +88,7 @@ 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'")
    @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, Pageable pageable);
    /**
@ -97,7 +97,7 @@ 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')")
    @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, Pageable pageable);
    
    /**
@ -107,7 +107,7 @@ 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'")
    @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'")
    Page<Object> findPlanByPatientAndTeam(String patient, Long teamCode,String doctor, Pageable pageable);
@ -118,7 +118,7 @@ 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')")
    @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')")
    Page<Object> findRecordByPatientAndTeam(String patient, Long teamCode,String doctor, Pageable pageable);
    
    /**
@ -133,7 +133,7 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("update Followup a set a.status=?2 where a.prescriptionCode = ?1 ")
    void updateStatusByPrescriptionCode(String prescriptionCode, String status);
    @Query("select a from Followup a where a.patientCode = ?1 and a.followupClass = ?2 and a.status = 1 order by a.followupDate desc")
    @Query("select a from Followup a where a.patientCode = ?1 and a.followupClass = ?2 and a.status = '1' order by a.followupDate desc")
    List<Followup> findAllByPatientCodeAndClass(String patientCode, String followupClass);

+ 26 - 0
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/dao/rehabilitation/PatientDischargeDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.afterDiagnosis.dao.rehabilitation;
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;
public interface PatientDischargeDao extends PagingAndSortingRepository<PatientDischargeDO, Long>, JpaSpecificationExecutor<PatientDischargeDO> {
    List<PatientDischargeDO> findAllByType(Integer type);
    List<PatientDischargeDO> findAllByTypeAndIdcardAndCreateUser(Integer type, String idcard, String createUser);
    List<PatientDischargeDO> findAllByTypeAndCreateUser(Integer type, String createUser);
    List<PatientDischargeDO> findAllByIdcardAndCreateUser(String idcard, String createUser);
    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);
}

+ 1 - 1
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/dao/rehabilitation/PatientMedicalRecordsRehabilitationDao.java

@ -7,7 +7,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientMedicalRecordsRehabilitationDao extends PagingAndSortingRepository<PatientMedicalRecordsDO, Long>, JpaSpecificationExecutor<PatientMedicalRecordsDO> {
public interface PatientMedicalRecordsRehabilitationDao extends PagingAndSortingRepository<PatientMedicalRecordsDO, String>, JpaSpecificationExecutor<PatientMedicalRecordsDO> {
    @Query("select p from PatientMedicalRecordsDO p where p.code = ?1")
    PatientMedicalRecordsDO findByCode(String code);

+ 4 - 4
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/endpoint/health/DoctorHealthController.java

@ -6,6 +6,7 @@ import com.yihu.jw.afterDiagnosis.service.device.PatientHealthIndexService;
import com.yihu.jw.contant.DeviceHealthContant;
import com.yihu.jw.entity.base.device.DoctorHealthStandard;
import com.yihu.jw.entity.base.device.PatientHealthStandard;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
@ -567,8 +568,7 @@ public class DoctorHealthController extends BaseController {
				return error(-1, "保存失败!");
			}
//			List<Patient> patients = patientService.findAllSignPatientTeamcode(teamcode,getUID());
			List<Patient> patients = new ArrayList<>();
			List<BasePatientDO> patients = new ArrayList<>();
			if(!patients.isEmpty()){
				// 生成数据对象
@ -583,7 +583,7 @@ public class DoctorHealthController extends BaseController {
						continue;
					}
					for (Patient patient: patients) {
					for (BasePatientDO patient: patients) {
						PatientHealthStandard standard = new PatientHealthStandard();
						standard.setDoctor(getUID());
						standard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
@ -591,7 +591,7 @@ public class DoctorHealthController extends BaseController {
						standard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
						standard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
						standard.setType(obj.getInt("type"));
						standard.setPatient(patient.getCode());
						standard.setPatient(patient.getId());
						standard.setCzrq(new Date());
						list.add(standard);
					}

+ 1 - 15
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/endpoint/rehabilitation/DoctorRehabilitaionInfoController.java

@ -94,7 +94,7 @@ public class DoctorRehabilitaionInfoController extends BaseController {
                                       @ApiParam(name = "jsonData", value = "住院病历相关数据")
                                       @RequestParam(value = "jsonData", required = true) String jsonData,
                                       @ApiParam(name = "id", value = "模板id,编辑时传入")
                                           @RequestParam(value = "id", required = false) Long id) {
                                           @RequestParam(value = "id", required = false) String id) {
        try {
            if (StringUtils.isBlank(doctorCode)) {
@ -189,20 +189,6 @@ public class DoctorRehabilitaionInfoController extends BaseController {
    }
    @RequestMapping(value = "sendWxMsgRemindSign", method = RequestMethod.POST)
    @ApiOperation("发送微信模板提醒签约消息")
    public String sendWxTemplate(@ApiParam(name = "patient", value = "居民code", required = false)
                                 @RequestParam(value = "patient", required = false)String patient){
        try {
            rehabilitationInfoService.sendWxMsgRemindSign(patient);
            return write(200, "发送成功!");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value = "getPatientByIdcardOrSsc", method = RequestMethod.POST)
    @ApiOperation("根据患者身份证或社保卡号进行搜索添加出院记录")
    public String getPatientByIdcardOrSsc(@ApiParam(name = "patientInfo", value = "居民身份证或者社保卡", required = true)

+ 1 - 1
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/device/PatientDeviceLogService.java

@ -85,7 +85,7 @@ public class PatientDeviceLogService {
                "  SELECT sf.name, pd.* FROM wlyy_patient_device_log pd" +
                "  LEFT JOIN wlyy_sign_family sf ON pd.patient = sf.patient" +
                "  WHERE" +
                "  pd.is_del = 1 and (sf.doctor= '"+doctor+"' or sf.doctor_health = '"+doctor+"') and sf.`status`>0"+
                "  pd.is_del = 1 and sf.doctor= '"+doctor+"'  and sf.`status`>0"+
                "  ORDER BY" +
                "  pd.create_time DESC) a" +
                " GROUP BY a.device_sn,a.patient) b" +

+ 1 - 1
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/device/PatientDeviceService.java

@ -502,7 +502,7 @@ public class PatientDeviceService  {
    public Map<String,Object> getDeviceByDeviceSn(String deviceSn)throws Exception {
        Map<String,Object> map  = new HashedMap();
        String sql = "SELECT d.id,d.device_name deviceName,d.device_model deviceMode,d.sim,CAST(e.is_multi_user AS UNSIGNED INTEGER) isMultiUser,e.category_code as deviceType,e.multi_user multiUser,e.id as device_id FROM device.wlyy_devices d LEFT JOIN wlyy.dm_device e ON d.device_model = e.model WHERE d.device_code='"+deviceSn+"'";
        String sql = "SELECT d.id,d.device_name deviceName,d.device_model deviceMode,d.sim,CAST(e.is_multi_user AS UNSIGNED INTEGER) isMultiUser,e.category_code as deviceType,e.multi_user multiUser,e.id as device_id FROM device.wlyy_devices d LEFT JOIN dm_device e ON d.device_model = e.model WHERE d.device_code='"+deviceSn+"'";
        List<Map<String,Object>> mapSqlList = jdbcTemplate.queryForList(sql);
        if (mapSqlList!=null && mapSqlList.size()>0){
            map = mapSqlList.get(0);

+ 7 - 9
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/followup/FollowUpService.java

@ -105,8 +105,6 @@ public class FollowUpService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private FollowupDrugsDao followupDrugsDao;
    @Value("${es.type.FollowUpContent}")
    private String esType;
    @Value("${es.index.FollowUp}")
    private String esIndex;
    @Autowired
@ -1552,11 +1550,11 @@ public class FollowUpService {
     */
    public Map<String,Object> findFollowUpPatient(String namekey,String doctor,String labelCode,Integer page,Integer size)throws Exception{
        String totalSql = " SELECT " +
                " DISTINCT p.code " +
                " DISTINCT p.id " +
                " FROM " +
                " wlyy_followup_label l " +
                " JOIN wlyy_followup_label_patient lp ON l.label_code = lp.label_code " +
                " JOIN wlyy_patient p ON lp.patient = p.code " +
                " JOIN base_patient p ON lp.patient = p.id " +
                " WHERE " +
                " 1=1 ";
        if(StringUtils.isNotBlank(namekey)){
@ -1573,7 +1571,7 @@ public class FollowUpService {
        String sql = " SELECT DISTINCT" +
                " p.code, " +
                " p.id, " +
                " p.`name`, " +
                " p.sex, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
@ -1581,7 +1579,7 @@ public class FollowUpService {
                " FROM " +
                " wlyy_followup_label l " +
                " JOIN wlyy_followup_label_patient lp ON l.label_code = lp.label_code " +
                " JOIN wlyy_patient p ON lp.patient = p.code " +
                " JOIN base_patient p ON lp.patient = p.id " +
                " WHERE " +
                " 1=1 ";
        if(StringUtils.isNotBlank(namekey)){
@ -1656,7 +1654,7 @@ public class FollowUpService {
    public Map<String,Object> findPatientInfo(String patient){
        String sql = " SELECT " +
                " p.`name`, " +
                " p.code, " +
                " p.id, " +
                " p.sex, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo, " +
@ -1668,9 +1666,9 @@ public class FollowUpService {
                " FROM " +
                " wlyy_followup_label l " +
                " JOIN wlyy_followup_label_patient lp ON l.label_code = lp.label_code " +
                " JOIN wlyy_patient p ON lp.patient = p.code " +
                " JOIN base_patient p ON lp.patient = p.id " +
                " WHERE " +
                " p.code = '"+patient+ "'";
                " p.id = '"+patient+ "'";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        if(rs!=null&&rs.size()>0){
            return rs.get(0);

+ 0 - 2
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PatientPrescriptionPayService.java

@ -50,8 +50,6 @@ public class PatientPrescriptionPayService {
    @Autowired
    private PrescriptionPayDao payDao;
    @Autowired
    private PrescriptionLogService payLogService;
    @Autowired
    private WlyyPrescriptionService prescriptionService;
    @Autowired
    private PrescriptionInfoDao infoDao;

+ 1 - 0
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionAdjustService.java

@ -8,6 +8,7 @@ import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionLogDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionReviewedDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;

+ 14 - 14
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionDiagnosisService.java

@ -1,10 +1,10 @@
package com.yihu.jw.afterDiagnosis.service.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.prescription.PrescriptionDiagnosisDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
 * Created by yeshijie on 2017/7/28.
 */
@Service
public class PrescriptionDiagnosisService extends BaseService{
public class PrescriptionDiagnosisService {
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
@ -46,12 +46,12 @@ public class PrescriptionDiagnosisService extends BaseService{
                re = redisTemplate.opsForValue().get(key);
                if(StringUtils.isEmpty(re))
                {
                    List<PrescriptionDiagnosis> list = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode);
                    List<WlyyPrescriptionDiagnosisDO> list = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionCode,1);
                    if(list!=null&&list.size()>0){
                        for (PrescriptionDiagnosis diagnosis:list){
                        for (WlyyPrescriptionDiagnosisDO diagnosis:list){
                            JSONObject json = new JSONObject();
                            json.put("code",diagnosis.getHealthProblem());//疾病代码
                            json.put("name",diagnosis.getHealthProblemName());//疾病名称
                            json.put("code",diagnosis.getCode());//疾病代码
                            json.put("name",diagnosis.getName());//疾病名称
                            jsonArray.add(json);
                        }
                        re = jsonArray.toString();
@ -85,7 +85,7 @@ public class PrescriptionDiagnosisService extends BaseService{
                re = redisTemplate.opsForValue().get(key);
                if(StringUtils.isEmpty(re))
                {
                    List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
                    List<WlyyPrescriptionInfoDO> list = prescriptionInfoDao.findByPrescriptionId(prescriptionCode,1);
                    if(list!=null&&list.size()>0){
                        jsonArray = JSONArray.fromObject(list);
                        re = jsonArray.toString();
@ -114,10 +114,10 @@ public class PrescriptionDiagnosisService extends BaseService{
            {
                //判断该续方的疾病类型redis是否存在
                String key = "prescription:"+prescriptionCode+":diseaseTypes";
                List<PrescriptionDiagnosis> list = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode);
                List<WlyyPrescriptionDiagnosisDO> list = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionCode,1);
                if(list!=null&&list.size()>0){
                    JSONArray jsonArray = new JSONArray();
                    for (PrescriptionDiagnosis diagnosis:list){
                    for (WlyyPrescriptionDiagnosisDO diagnosis:list){
                        JSONObject json = new JSONObject();
                        json.put("code",diagnosis.getCode());//疾病代码
                        json.put("name",diagnosis.getName());//疾病名称
@ -146,7 +146,7 @@ public class PrescriptionDiagnosisService extends BaseService{
            {
                //判断该续方的药品信息redis是否存在
                String key = "prescription:"+prescriptionCode+":drugInfo";
                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
                List<WlyyPrescriptionInfoDO> list = prescriptionInfoDao.findByPrescriptionId(prescriptionCode,1);
                if(list!=null&&list.size()>0){
                    String re = JSONArray.fromObject(list).toString();
                    redisTemplate.opsForValue().set(key,re,180, TimeUnit.DAYS);

+ 1 - 1
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionDispensaryCodeService.java

@ -279,7 +279,7 @@ public class PrescriptionDispensaryCodeService {
    public Map<String, Object> getJumiQrcode(String prescriptionCode) throws Exception {
        String sql = "SELECT jpc.del isUse,pick_code dispensaryCode ,jpc.qr_code img_url ,p.hospital_name hospitalName FROM wlyy_jumi_pick_code jpc , wlyy_prescription p\n" +
                "WHERE jpc.prescription_code = '"+prescriptionCode+"' AND jpc.prescription_code = p.`code` AND jpc.del = 0 ORDER BY jpc.id DESC";
                "WHERE jpc.prescription_code = '"+prescriptionCode+"' AND jpc.prescription_code = p.id AND jpc.del = 0 ORDER BY jpc.id DESC";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
        if(result.size()>0){
            return result.get(0);

+ 0 - 28
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionExpressageLogService.java

@ -1,28 +0,0 @@
package com.yihu.jw.afterDiagnosis.service.prescription;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageLogDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 处方物流配送详情
 * @author  huangwenjie 2017.08.03
 */
@Service
public class PrescriptionExpressageLogService {
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    /**
     * 根据处方号获取该处方的物流配送日志,按路由节点发生的时间倒序排序
     * @param prescriptionCode
     * @return
     */
    public List<WlyyPrescriptionExpressageLogDO> findByPrescriptionCode(String prescriptionCode){
        return prescriptionExpressageLogDao.queryByOutpatientId(prescriptionCode);
    }
}

+ 6 - 6
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionInfoService.java

@ -275,7 +275,7 @@ public class PrescriptionInfoService {
                return pres;
            } else {
                BasePatientDO p = patientDao.findById(patient).orElse(null);
                StringBuffer sqlBuffer = new StringBuffer("SELECT p.code,LEFT(p.create_time,19) AS createTime,p.status,p.hospital_name As hospitalName FROM wlyy_prescription p " +
                StringBuffer sqlBuffer = new StringBuffer("SELECT p.id,LEFT(p.create_time,19) AS createTime,p.status,p.hospital_name As hospitalName FROM wlyy_prescription p " +
                        "WHERE p.patient=?");
                List<Object> params = new ArrayList<>();
                params.add(patient);
@ -737,7 +737,7 @@ public class PrescriptionInfoService {
                " LEFT(pr.pres_create_time,19) AS presCreateTime " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` ");
                " LEFT JOIN base_patient p ON pr.patient = p.id ");
        List<Object> params = new ArrayList<>();
        //先判断疾病类型是否为空
        if (StringUtils.isNotBlank(diseases)) {
@ -854,7 +854,7 @@ public class PrescriptionInfoService {
        StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS total" +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` ");
                " LEFT JOIN base_patient p ON pr.patient = p.id ");
        List<Object> params = new ArrayList<>();
        //先判断疾病类型是否为空
        if (StringUtils.isNotBlank(diseases)) {
@ -1197,7 +1197,7 @@ public class PrescriptionInfoService {
        StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS total " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
                " LEFT JOIN base_patient p ON pr.patient = p.id " +
                " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                " WHERE 1=1 AND pr.status >="+WlyyPrescriptionLogDO.PrescriptionLogStatus.pay_success.getValue()+" ");
        List<Object> params = new ArrayList<>();
@ -1477,7 +1477,7 @@ public class PrescriptionInfoService {
                " e.patient_hospital_code AS patientHospitalCode " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
                " LEFT JOIN base_patient p ON pr.patient = p.id " +
                " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                " JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code " +
                " WHERE r.status=1 AND pr.status >="+WlyyPrescriptionLogDO.PrescriptionLogStatus.pay_success.getValue()+" ");
@ -1498,7 +1498,7 @@ public class PrescriptionInfoService {
        StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS total " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
                " LEFT JOIN base_patient p ON pr.patient = p.id " +
                " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                " JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code " +
                " WHERE r.status=1 AND pr.status >="+WlyyPrescriptionLogDO.PrescriptionLogStatus.pay_success.getValue()+" ");

+ 0 - 60
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/PrescriptionLogService.java

@ -1,60 +0,0 @@
package com.yihu.jw.afterDiagnosis.service.prescription;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionLogDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
@Service
public class PrescriptionLogService {
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    /**
     * 根据处方code 和 types查询处方的流程日志 时间倒叙
     *
     * @param prescriptionCode 处方code
     * @param status           需要查询的status
     * @return
     */
    public List<WlyyPrescriptionLogDO> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] status) {
        return prescriptionLogDao.findPrescriptionLogsByPrescriptionCode(prescriptionCode, status);
    }
    /**
     * 添加日志
     *
     * @param prescription
     * @param type         类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
     * @param flag         1成功 0失败
     * @param userType     1 患者 2医生
     */
    public void addLog(WlyyPrescriptionDO prescription, Integer type, Integer flag, Integer userType) {
        WlyyPrescriptionLogDO log = null;
        List<WlyyPrescriptionLogDO> prescriptionLogs = prescriptionLogDao.findByPrescriptionCodeAndStutas(prescription.getId(), prescription.getStatus());
        if (prescriptionLogs == null || prescriptionLogs.size() == 0) {
            log = new WlyyPrescriptionLogDO();
        } else {
            log = prescriptionLogDao.findById(prescriptionLogs.get(0).getId()).orElse(null);
        }
        log.setStatus(prescription.getStatus());
        log.setCreateTime(new Date());
        log.setPrescriptionCode(prescription.getId());
        if (userType == 1) {
            log.setUserCode(prescription.getPatientCode());
            log.setUserName(prescription.getPatientName());
        } else {
            log.setUserCode(prescription.getDoctor());
            log.setUserName(prescription.getDoctorName());
        }
        log.setUserType(userType);
        prescriptionLogDao.save(log);
    }
}

+ 14 - 14
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/WlyyPrescriptionExpressageService.java

@ -485,7 +485,7 @@ public class WlyyPrescriptionExpressageService {
                String sqlTotal ="SELECT count(1) AS total" +
                        " FROM " +
                        " wlyy_prescription p " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.id " +
                        " WHERE " +
                        " p.patient = '" + p.getId() + "' " +
                        " AND py.trade_status ='1' " +
@ -509,10 +509,10 @@ public class WlyyPrescriptionExpressageService {
                        "  py.charge_time AS chargeTime, " +
                        "  p.dispensary_type AS dispensaryType, " +
                        "  p.`status` ," +
                        "  p.code AS prescriptionCode " +
                        "  p.id AS prescriptionCode " +
                        " FROM " +
                        " wlyy_prescription p " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.id " +
                        " WHERE " +
                        " p.patient = '" + p.getId() + "'" +
                        " AND py.trade_status ='1' " +
@ -622,8 +622,8 @@ public class WlyyPrescriptionExpressageService {
        String totalSql = "SELECT count(1) AS total " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.code = e.prescription_code" +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.id " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.id = e.prescription_code" +
                " WHERE" +
//                " p.hospital = '"+d.getHospital()+"' AND" +
                "  py.trade_status = '1' ";
@ -650,7 +650,7 @@ public class WlyyPrescriptionExpressageService {
                "  e.hospital_doctor AS operatorName," +
                "  p.drug_delivery_flag AS drugDeliveryFlag, " +
                "  e.fetching_medicine_time AS drugDeliveryTime," +
                "  p.code AS prescriptionCode," +
                "  p.id AS prescriptionCode," +
                "  p.`status`, " +
                "  qrcode.img_url as img_url, " +
                "  e.province_name as provinceName, " +
@ -661,9 +661,9 @@ public class WlyyPrescriptionExpressageService {
                "  e.address as address " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.code = e.prescription_code" +
                " LEFT JOIN wlyy_prescription_dispensary_code qrcode on p.CODE = qrcode.prescription_code and qrcode.is_use=0 and qrcode.type=1" +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.id " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.id = e.prescription_code" +
                " LEFT JOIN wlyy_prescription_dispensary_code qrcode on p.id = qrcode.prescription_code and qrcode.is_use=0 and qrcode.type=1" +
                " WHERE" +
//                " p.hospital = '"+d.getHospital()+"' AND" +
                "  py.trade_status = '1' ";
@ -745,8 +745,8 @@ public class WlyyPrescriptionExpressageService {
        String totalSql = "SELECT count(1) AS total " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.code = e.prescription_code" +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.id " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.id = e.prescription_code" +
                " WHERE" +
//                " p.hospital = '"+d.getHospital()+"' AND" +
                "  py.trade_status = '1' ";
@ -773,12 +773,12 @@ public class WlyyPrescriptionExpressageService {
                "  e.hospital_doctor AS operatorName," +
                "  p.drug_delivery_flag AS drugDeliveryFlag, " +
                "  e.fetching_medicine_time AS drugDeliveryTime," +
                "  p.code AS prescriptionCode," +
                "  p.id AS prescriptionCode," +
                "  p.`status` " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.code = e.prescription_code" +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.id " +
                " LEFT JOIN wlyy_prescription_expressage e ON p.id = e.prescription_code" +
                " WHERE" +
//                " p.hospital = '"+d.getHospital()+"' AND" +
                "  py.trade_status = '1' ";

+ 1 - 4
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/prescription/WlyyPrescriptionService.java

@ -19,6 +19,7 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.CommonUtil;
@ -29,7 +30,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
@ -45,9 +45,6 @@ public class WlyyPrescriptionService {
    private static Logger logger = LoggerFactory.getLogger(WlyyPrescriptionService.class);
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired

+ 7 - 7
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationGuidanceService.java

@ -63,7 +63,7 @@ public class RehabilitationGuidanceService {
    public List<Map<String,Object>> selectType(String planId){
        String disease="";
        if (StringUtils.isNoneBlank(planId)){
            String sql ="select * from wlyy_specialist.wlyy_patient_rehabilitation_plan where id='"+planId+"' ";
            String sql ="select * from wlyy_patient_rehabilitation_plan where id='"+planId+"' ";
            Map<String,Object> map = jdbcTemplate.queryForMap(sql);
            if (map.get("disease")!=null&&StringUtils.isNoneBlank(map.get("disease").toString())){
                disease = map.get("disease").toString();
@ -91,7 +91,7 @@ public class RehabilitationGuidanceService {
    public Page<RehabilitationguidanceDO> select(String title, Integer type, String code, String planId, Integer page, Integer pagesize){
        String disease="";
        if (StringUtils.isNoneBlank(planId)){
            String sql ="select * from wlyy_specialist.wlyy_patient_rehabilitation_plan where id='"+planId+"' ";
            String sql ="select * from wlyy_patient_rehabilitation_plan where id='"+planId+"' ";
            Map<String,Object> map = jdbcTemplate.queryForMap(sql);
            if (map.get("disease")!=null&&StringUtils.isNoneBlank(map.get("disease").toString())){
                disease = map.get("disease").toString();
@ -265,7 +265,7 @@ public class RehabilitationGuidanceService {
            //反馈处理30
            sendType=30;
            String sql = "SELECT pr.manage_time as manageTime,pr.is_manage as isManage " +
                    "FROM wlyy_specialist.`wlyy_specialist_patient_relation` pr " +
                    "FROM `wlyy_specialist_patient_relation` pr " +
                    "where pr.doctor = '"+doctorCode+"' and pr.patient = '"+patientCode+"' and pr.sign_status=1 and pr.`status`=1";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
            String manageTime = "";
@ -284,11 +284,11 @@ public class RehabilitationGuidanceService {
            //复诊提醒3
            //更新复诊类型
            if(StringUtils.isNoneBlank(reservationType)){
                String updSql = "update wlyy_specialist.wlyy_rehabilitation_plan_detail set reservation_type = "+reservationType +" where id = '"+relationCode+"'";
                String updSql = "update wlyy_rehabilitation_plan_detail set reservation_type = "+reservationType +" where id = '"+relationCode+"'";
                jdbcTemplate.execute(updSql);
            }
            sendType=11;//待办事项
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
                    "where pd.id ='"+relationCode+"' and pd.hospital_service_item_id='7' and pd.status <>1 order by pd.execute_time desc ";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
            String excuteTime="";
@ -309,7 +309,7 @@ public class RehabilitationGuidanceService {
        }else if (type==4){
            //上门服务提醒 4
            sendType=11;//待办事项
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
                    "where pd.id ='"+relationCode+"' and pd.hospital_service_item_id='4' and pd.status <>1 order by pd.execute_time desc ";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
            String excuteTime="";
@ -333,7 +333,7 @@ public class RehabilitationGuidanceService {
        }else if (type==5){
            //家签提醒 5
            sendType=11;//待办事项
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
                    "where pd.plan_id ='"+planId+"' and pd.hospital_service_item_id='4' and pd.status <>1 order by pd.execute_time desc ";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
            String excuteTime="";

+ 77 - 152
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationInfoService.java

@ -2,23 +2,23 @@ package com.yihu.jw.afterDiagnosis.service.rehabilitation;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.afterDiagnosis.dao.rehabilitation.PatientDischargeDao;
import com.yihu.jw.afterDiagnosis.dao.rehabilitation.PatientMedicalRecordsRehabilitationDao;
import com.yihu.jw.afterDiagnosis.dao.rehabilitation.RehabilitationAdviceDao;
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.hospital.consult.WlyyHospitalSysDictDO;
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.hospital.HospitalDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.CommonUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -46,10 +46,6 @@ public class RehabilitationInfoService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
@ -217,32 +213,31 @@ public class RehabilitationInfoService {
     * @param id
     * @return
     */
    public PatientMedicalRecordsDO createMedicalRecords(String doctorCode, String patient, String patientName, PatientMedicalRecordsDO patientMedicalRecordsDO, Long id) {
        Doctor doctor = doctorDao.findByCode(doctorCode);
    public PatientMedicalRecordsDO createMedicalRecords(String doctorCode, String patient, String patientName, PatientMedicalRecordsDO patientMedicalRecordsDO, String id) {
        BaseDoctorDO doctor = doctorDao.findByIdAndDel(doctorCode);
        if(id != null){
            PatientMedicalRecordsDO oldRecord  = patientMedicalRecordsDao.findOne(id);
            PatientMedicalRecordsDO oldRecord  = patientMedicalRecordsDao.findById(id).orElse(null);
            patientMedicalRecordsDO.setId(id);
            patientMedicalRecordsDO.setCode(oldRecord.getCode());
        }else {
            patientMedicalRecordsDO.setCode(getCode());
            patientMedicalRecordsDO.setCode(CommonUtil.getCode());
        }
        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());
                patientMedicalRecordsDO.setHospital(hospital.getCode());
                patientMedicalRecordsDO.setHospitalName(hospital.getName());
//                Hospital 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.setHospitalName(hospitalMapping.getName());
            }
        }
@ -265,16 +260,16 @@ public class RehabilitationInfoService {
        List<Map<String, Object>> nosignList = new ArrayList<>();
        //获取当前医生映射机构
//        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(hospital);
        String value = systemDictDao.findByDictNameAndCode("kfxz",hospital);
        if(value != null) {
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findOneByDictNameAndDictCode("kfxz",hospital);
        if(dictDO != null) {
            //查询已签约居民
            String signSql = "SELECT  i.idcard,s.patient,i.`name` patientName, i.sex,i.age,i.address,CONCAT(s.doctor_name ,'(全科医生)') as doctorName,IFNULL(CONCAT(s.doctor_health_name ,'(健管师)'),s.doctor_health_name) doctorHealthName, s.hospital_name hospitalName,s.admin_team_code teamCode " +
                    "FROM `wlyy_rehabilitation_patient_info` i , wlyy_sign_family s where i.jw_hospital_code='" + value + "' and  i.idcard = s.idcard and s.`status` = 1 and s.expenses_status = 1 group by i.idcard ORDER BY i.crzq desc ";
            String signSql = "SELECT  i.idcard,s.patient,i.`name` patientName, i.sex,i.age,i.address,CONCAT(s.doctor_name ,'(全科医生)') as doctorName, s.hospital_name hospitalName,s.admin_team_code teamCode " +
                    "FROM `wlyy_rehabilitation_patient_info` i , wlyy_sign_family s where i.jw_hospital_code='" + dictDO.getDictValue() + "' and  i.idcard = s.idcard and s.`status` = 1 and s.expenses_status = 1 group by i.idcard ORDER BY i.crzq desc ";
            signList = jdbcTemplate.queryForList(signSql);
            //查询代签约居民
            String nosignSql = "SELECT  i.idcard,p.`code` patient,i.`name` patientName, i.sex,i.age,i.address " +
                    "FROM `wlyy_rehabilitation_patient_info` i JOIN wlyy_patient p on i.idcard =  p.idcard and p.`status` = 1  LEFT JOIN wlyy_sign_family s on i.idcard = s.idcard " +
                    "where i.jw_hospital_code='" + value + "' and ( s.sign_year != '"+DateUtil.getSignYear() + "' or ( s.sign_year = '"+DateUtil.getSignYear() +"' and ( s.expenses_status != 1 or s.`status` != 1))) group by i.idcard ORDER BY i.crzq desc ";
            String nosignSql = "SELECT  i.idcard,p.id patient,i.`name` patientName, i.sex,i.age,i.address " +
                    "FROM `wlyy_rehabilitation_patient_info` i JOIN base_patient p on i.idcard =  p.idcard and p.`status` = 1  LEFT JOIN wlyy_sign_family s on i.idcard = s.idcard " +
                    "where i.jw_hospital_code='" + dictDO.getDictValue() + "' and ( s.sign_year != '"+DateUtil.getSignYear() + "' or ( s.sign_year = '"+DateUtil.getSignYear() +"' and ( s.expenses_status != 1 or s.`status` != 1))) group by i.idcard ORDER BY i.crzq desc ";
            nosignList = jdbcTemplate.queryForList(nosignSql);
        }
        //获取自助添加出院居民列表
@ -290,17 +285,6 @@ public class RehabilitationInfoService {
            Integer age = IdCardUtil.getAgeForIdcard(idcard);
            jsonObject.put("sex", sex);
            jsonObject.put("age", age);
            SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(idcard);
            if(signFamily != null){
                jsonObject.put("doctorName",signFamily.getDoctorName() + "(全科医生)");
                if(StringUtils.isNotBlank(signFamily.getDoctorHealthName())) {
                    jsonObject.put("doctorHealthName", signFamily.getDoctorHealthName() + "(健管师)");
                }
                jsonObject.put("hospitalName", signFamily.getHospitalName());
                signList.add(jsonObject);
            }else {
                nosignList.add(jsonObject);
            }
        }
        result.put("noSignArray", nosignList);
        result.put("signArray", signList);
@ -316,9 +300,9 @@ public class RehabilitationInfoService {
        if(StringUtils.isNotBlank(idcard)){
            aa += " and  p.idcard like '%" + idcard + "%' ";
        }
        String sql = "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address  from wlyy_patient_discharge d,wlyy_patient p\n" +
        String sql = "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address  from wlyy_patient_discharge d,base_patient p\n" +
                "where "+aa+" and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient NOT IN (SELECT patient FROM wlyy_sign_family WHERE sign_year='"+DateUtil.getSignYear()+"' AND `status`=1) AND d.patient NOT IN \n" +
                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "(   SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc) GROUP BY d.patient ORDER BY d.create_time DESC ";
        sql += " LIMIT "+(page-1)*pagesize+","+pagesize;
@ -344,22 +328,22 @@ public class RehabilitationInfoService {
     */
    public JSONObject noDownCount(String doctorCode,JSONObject object){
        //未下转所有
        String notTurnedDownCountSql = "select count(*) from wlyy_patient_discharge d,wlyy_patient p where d.create_user ='"+doctorCode+"' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient NOT IN (   \n" +
                "SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p WHERE i.create_user = '"+doctorCode+"' AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)\n";
        String notTurnedDownCountSql = "select count(*) from wlyy_patient_discharge d,base_patient p where d.create_user ='"+doctorCode+"' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient NOT IN (   \n" +
                "SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p WHERE i.create_user = '"+doctorCode+"' AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)\n";
        Integer allCount = jdbcTemplate.queryForObject(notTurnedDownCountSql, Integer.class);
        String notSignedAtHomeSql = "SELECT count(*) FROM (\n" +
                "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address  from wlyy_patient_discharge d,wlyy_patient p\n" +
                "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address  from wlyy_patient_discharge d,base_patient p\n" +
                "where d.create_user ='"+doctorCode+"' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient NOT IN (SELECT patient FROM wlyy_sign_family WHERE sign_year='"+DateUtil.getSignYear()+"' AND `status`=1) AND d.patient NOT IN \n" +
                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "(   SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC\n" +
                ")aa\n" ;
        Integer notSignedAtHome = jdbcTemplate.queryForObject(notSignedAtHomeSql, Integer.class);
        String notSignedAtHome1Sql = "SELECT count(*) FROM (\n" +
                "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus,f.czrq  from wlyy_patient_discharge d,wlyy_patient p,wlyy_sign_family f\n" +
                "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus,f.czrq  from wlyy_patient_discharge d,base_patient p,wlyy_sign_family f\n" +
                "where d.create_user = '"+doctorCode+"' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient=f.patient AND f.`status`=1 AND f.sign_year='"+DateUtil.getSignYear()+"' AND d.patient NOT IN \n" +
                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "(   SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC\n" +
                ")aa\n" +
                "WHERE aa.signStatus = 1";
@ -379,10 +363,10 @@ public class RehabilitationInfoService {
            aa += " and  p.idcard like '%" + idcard + "%' ";
        }
        String sql = "select '' id, p.idcard,p.code patient,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus," +
                "f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode " +
                " from wlyy_patient_discharge d,wlyy_patient p,wlyy_sign_family f\n" +
                "f.czrq,f.doctor_name doctorName,f.hospital_name hospitalName,f.admin_team_code teamCode " +
                " from wlyy_patient_discharge d,base_patient p,wlyy_sign_family f\n" +
                "where "+aa+" and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient=f.patient AND f.`status`=1 AND f.sign_year='"+DateUtil.getSignYear()+"' AND d.patient NOT IN \n" +
                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "(   SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC ";
        sql += " LIMIT "+(page-1)*pagesize+","+pagesize;
@ -410,12 +394,12 @@ public class RehabilitationInfoService {
            aa += " and  p.idcard like '%" + idcard + "%' ";
        }
        String sql = "select '' id, p.idcard,p.code patient,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus," +
                "f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode," +
                "f.czrq,f.doctor_name doctorName,f.hospital_name hospitalName,f.admin_team_code teamCode," +
                " if(f.id is null,-2,-1) as isTurnDown " +
                " from wlyy_patient p,wlyy_patient_discharge d " +
                " from base_patient p,wlyy_patient_discharge d " +
                " left JOIN wlyy_sign_family f on d.patient=f.patient AND f.`status`=1 AND f.sign_year='"+DateUtil.getSignYear()+"'"+
                "where "+aa+" and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient  AND d.patient NOT IN \n" +
                "(   SELECT DISTINCT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "(   SELECT DISTINCT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   WHERE i.create_user = '"+doctorCode+"' \n" +
                "AND i. STATUS != 0 AND p. CODE = i.patient )GROUP BY d.patient ORDER BY d.create_time DESC ";
        sql += " LIMIT "+(page-1)*pagesize+","+pagesize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
@ -433,11 +417,10 @@ public class RehabilitationInfoService {
     */
    public JSONObject downAndNoSign(String idcard, String doctorCode, Integer page, Integer pagesize,JSONObject object){
        String sql2 = "SELECT i.disease_name diseaseName,s.doctor,s.idcard,p.sex, s.patient,CAST(IFNULL(p.birthday,'') AS char ) birthday," +
                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 " +
                " and  (pr.is_manage != 1 OR isnull(pr.is_manage)) " ;
@ -473,23 +456,23 @@ public class RehabilitationInfoService {
     */
    public JSONObject downCount(String doctorCode,JSONObject object){
        String sql1 ="SELECT COUNT(distinct i.patient) \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 ";
        Integer list1 = jdbcTemplate.queryForObject(sql1, Integer.class);
        //康复计划数量
        String sql2 = "SELECT COUNT(distinct i.id) \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p\n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient \n" +
                "AND s.status = 1 AND s.expenses_status = 1 ";
        Integer list2 = jdbcTemplate.queryForObject(sql2, Integer.class);
        //家医接收
        String sql3 ="SELECT COUNT(distinct i.patient) " +
                " FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                " wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                " FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                " wlyy_specialist_patient_relation pr \n" +
                " WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                " AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 and pr.is_manage=1";
        Integer list3 = jdbcTemplate.queryForObject(sql3, Integer.class);
@ -506,11 +489,10 @@ public class RehabilitationInfoService {
     */
    public JSONObject downAndSign(String idcard, String doctorCode, Integer page, Integer pagesize,JSONObject object){
        String sql2 = "SELECT i.disease_name diseaseName,s.doctor,s.idcard,p.sex, s.patient,CAST(IFNULL(p.birthday,'') AS char ) birthday," +
                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 and pr.is_manage=1" ;
        if(StringUtils.isNotBlank(idcard)){
@ -544,11 +526,10 @@ public class RehabilitationInfoService {
     */
    public JSONObject down(String idcard, String doctorCode, Integer page, Integer pagesize,JSONObject object){
        String sql2 = "SELECT i.disease_name diseaseName,s.doctor,s.idcard,p.sex, s.patient,CAST(IFNULL(p.birthday,'') AS char ) birthday," +
                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 ";
@ -664,18 +645,17 @@ public class RehabilitationInfoService {
    public JSONObject getDeorsumvergenceCount(String doctorCode){
        JSONObject object = new JSONObject();
        //已下转
        String sql1 ="SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
        String sql1 ="SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code  GROUP BY i.patient ORDER BY i.create_time DESC ";
        List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
        //康复计划数量
        String sql2 = "SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, s.admin_team_code teamCode \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" +
                " s.hospital_name hospitalName, s.admin_team_code teamCode \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p\n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient \n" +
                "AND s.status = 1 AND s.expenses_status = 1 GROUP BY i.id";
        List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
@ -683,10 +663,10 @@ public class RehabilitationInfoService {
        String sql3 ="SELECT * \n" +
                "FROM (\n" +
                "SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
                " s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, base_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '"+doctorCode+"' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code  GROUP BY i.patient ORDER BY i.create_time DESC\n" +
                ") aa\n" +
@ -699,42 +679,6 @@ public class RehabilitationInfoService {
        return object;
    }
    /**
     * 提醒居民家签
     * @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);
                    }
                }
            }
        }
    }
    /**
     *
     * @param patientInfo
@ -745,13 +689,10 @@ public class RehabilitationInfoService {
    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){
                patient = patientService.addPaitentByIdcard(patientInfo);
            }
        }else{
            patient = patientList.get(0);
        }
@ -762,7 +703,7 @@ public class RehabilitationInfoService {
            return data;
        }
        Doctor doctor = doctorDao.findByCode(doctorCode);
        BaseDoctorDO doctor = doctorDao.findByIdAndDel(doctorCode);
        //判断是否添加过该居民
        Integer patientDischargeDOS =0;
        if (type==2){//查询下转是否存在该患者:sign_status=1(包括type==null,type==2) 1.6.8后新增未家签的也能添加患者 判断条件(d.type=2 and sign_status=0)
@ -780,9 +721,9 @@ public class RehabilitationInfoService {
        }
        PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
        patientDischargeDO.setCode(getCode());
        patientDischargeDO.setCode(CommonUtil.getCode());
        patientDischargeDO.setType(2);//统一保存为2
        patientDischargeDO.setPatient(patient.getCode());
        patientDischargeDO.setPatient(patient.getId());
        patientDischargeDO.setName(patient.getName());
        patientDischargeDO.setIdcard(patient.getIdcard());
        patientDischargeDO.setSsc(patient.getSsc());
@ -790,24 +731,8 @@ public class RehabilitationInfoService {
        patientDischargeDO.setCreateUser(doctorCode);
        patientDischargeDO.setCreateUserName(doctor.getName());
        patientDischargeDO.setCreateTime(new Date());
        //判断是否家签  修改
        SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
        if(signFamily != null ) {
            patientDischargeDO.setSignStatus(1);
            patientDischargeDO.setHospital(signFamily.getHospital());
            patientDischargeDO.setHospitalName(signFamily.getHospitalName());
            patientDischargeDao.save(patientDischargeDO);
        }else {
            patientDischargeDO.setSignStatus(0);
//            if (type == 1){//添加签约患者加签列表
            patientDischargeDao.save(patientDischargeDO);
//            }else if(type == 2) {
//                patientDischargeDao.save(patientDischargeDO);
//                data.put("status", -1);
//                data.put("msg", "该患者未家签,请家签后重试");
//                return data;
//            }
        }
        patientDischargeDao.save(patientDischargeDO);
        data.put("status", 200);
        data.put("data", patientDischargeDO);
@ -815,22 +740,22 @@ public class RehabilitationInfoService {
    }
    public JSONObject getUnm(String doctor,String patient){
        String sqlMe = "select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code from wlyy_specialist.wlyy_rehabilitation_plan_detail d \n" +
                "LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id\n" +
                "LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  \n" +
                "where d.plan_id IN (SELECT id FROM wlyy_specialist.wlyy_patient_rehabilitation_plan WHERE patient ='"+patient+"') \n" +
        String sqlMe = "select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code from wlyy_rehabilitation_plan_detail d \n" +
                "LEFT JOIN wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id\n" +
                "LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  \n" +
                "where d.plan_id IN (SELECT id FROM wlyy_patient_rehabilitation_plan WHERE patient ='"+patient+"') \n" +
                "AND d.doctor = '"+doctor+"'  ";//我的任务
        List<Map<String, Object>> listMe = jdbcTemplate.queryForList(sqlMe);
        String sqlAll = "select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code from wlyy_specialist.wlyy_rehabilitation_plan_detail d \n" +
                "LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id\n" +
                "LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  \n" +
                "where d.plan_id IN (SELECT id FROM wlyy_specialist.wlyy_patient_rehabilitation_plan WHERE patient ='"+patient+"') ";//全部任务
        String sqlAll = "select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code from wlyy_rehabilitation_plan_detail d \n" +
                "LEFT JOIN wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id\n" +
                "LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  \n" +
                "where d.plan_id IN (SELECT id FROM wlyy_patient_rehabilitation_plan WHERE patient ='"+patient+"') ";//全部任务
        List<Map<String, Object>> listAll = jdbcTemplate.queryForList(sqlAll);
        String newDetailSql = "select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code,r.complete_time createTime, r.doctor_name doctorName \n" +
                "from wlyy_specialist.wlyy_rehabilitation_plan_detail d INNER JOIN wlyy_specialist.wlyy_rehabilitation_operate_records r ON d.id = r.rehabilitation_detail_id\n" +
                "LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id\n" +
                "LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  \n" +
                "where d.plan_id IN (SELECT id FROM wlyy_specialist.wlyy_patient_rehabilitation_plan WHERE patient ='"+patient+"')\n" +
                "from wlyy_rehabilitation_plan_detail d INNER JOIN wlyy_rehabilitation_operate_records r ON d.id = r.rehabilitation_detail_id\n" +
                "LEFT JOIN wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id\n" +
                "LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  \n" +
                "where d.plan_id IN (SELECT id FROM wlyy_patient_rehabilitation_plan WHERE patient ='"+patient+"')\n" +
                " and r.`status`=1 GROUP BY r.complete_time DESC LIMIT 0,1 ";
        List<Map<String, Object>> newDetail = jdbcTemplate.queryForList(newDetailSql);
        JSONObject object = new JSONObject();

+ 8 - 18
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationManageService.java

@ -128,10 +128,10 @@ public class RehabilitationManageService {
                " from wlyy_rehabilitation_plan_detail a INNER JOIN wlyy_patient_rehabilitation_plan p " +
                " on a.plan_id = p.id  " ;
        if(doctorType==2){//家医是根据签约关系过滤
            sql+=" INNER JOIN wlyy.wlyy_sign_family f ON f.patient = p.patient \n" +
            sql+=" INNER JOIN wlyy_sign_family f ON f.patient = p.patient \n" +
                    "\tand f.expenses_status=1\n" +
                    "\tAND f.STATUS >= 1 \n" +
                    "\tAND ( f.doctor = '"+doctorCode+"' OR f.doctor_health = '"+doctorCode+"' )  ";
                    "\tAND f.doctor = '"+doctorCode+"' ";
        }
        sql += " where 1=1 ";
        if(todaybacklog!=null&&todaybacklog==1){
@ -146,7 +146,7 @@ public class RehabilitationManageService {
            sql+=" and p.disease='"+diseaseCode+"'";
        }
        if(StringUtils.isNotEmpty(patientCondition)){//姓名idcard模糊查询
            sql +=" AND EXISTS (select code from wlyy.wlyy_patient where  `code` = p.patient and ( `name` LIKE '%"+patientCondition+"%' or idcard like '%"+patientCondition+"%') )";
            sql +=" AND EXISTS (select code from base_patient where  `code` = p.patient and ( `name` LIKE '%"+patientCondition+"%' or idcard like '%"+patientCondition+"%') )";
        }
        if (doctorType==1){
            sql +=" AND (p.create_user = '"+doctorCode+"' \n" +
@ -275,17 +275,8 @@ public class RehabilitationManageService {
                Integer familyFinishCount1 = rehabilitationDetailDao.findItemByDoctor(signFamilyMap.get("doctor") + "", patientCode);
                Integer familyServiceCount1 = rehabilitationDetailDao.completeServiceByDoctor(signFamilyMap.get("doctor") + "", patientCode, 1);
                if ((signFamilyMap.get("doctor") + "").equals(signFamilyMap.get("doctor_health") + "")) {
                    resultMap.put("signFamilyFinishItemCount", familyFinishCount1 - familyUnfinishCount1);//完成项目
                    resultMap.put("signFamilyServiceRecordCount", familyServiceCount1);//服务次数
                } else {
                    Integer familyUnfinishCount2 = rehabilitationDetailDao.unfinishItemByDoctor(signFamilyMap.get("doctor_health") + "", patientCode, 1);
                    Integer familyFinishCount2 = rehabilitationDetailDao.findItemByDoctor(signFamilyMap.get("doctor_health") + "", patientCode);
                    Integer familyServiceCount2 = rehabilitationDetailDao.completeServiceByDoctor(signFamilyMap.get("doctor_health") + "", patientCode, 1);
                    resultMap.put("signFamilyFinishItemCount", familyFinishCount1 - familyUnfinishCount1 + familyFinishCount2 - familyUnfinishCount2);//完成项目
                    resultMap.put("signFamilyServiceRecordCount", familyServiceCount1 + familyServiceCount2);//服务次数
                }
                resultMap.put("signFamilyFinishItemCount", familyFinishCount1 - familyUnfinishCount1);//完成项目
                resultMap.put("signFamilyServiceRecordCount", familyServiceCount1 );//服务次数
                //基础信息
                resultMap.put("hospitalName", signFamilyMap.get("hospital_name"));
@ -548,16 +539,15 @@ public class RehabilitationManageService {
            if (7 == searchTask){ //处方续方 flag 用于判断 1.7.0.5 新增
                String cfxfSql = "SELECT LEFT ( pr.create_time, 19 ) AS executeTime ,LEFT ( pr.pres_create_time, 19 ) AS buildCreateTime , pr.doctor AS doctorCode, pr.doctor_name AS doctorNmae,pr.`status`," +
                        " pr.hospital_name, pr.hospital, p.`name` AS patientName,p.code AS patientCode,pr.`code` AS id,7 as code, 2 as flag " +
                        " FROM  wlyy.wlyy_prescription pr  LEFT JOIN wlyy.wlyy_patient p ON pr.patient = p.`code` WHERE " +
                        " FROM  wlyy_prescription pr  LEFT JOIN base_patient p ON pr.patient = p.id WHERE " +
                        "  1 = 1  AND pr.STATUS = '100' AND p.code= '"+patient+"' GROUP BY  pr.CODE ";
                list = jdbcTemplate.queryForList(cfxfSql);
            }
            if (6 == searchTask){ //随访
                String sfSql = "SELECT DISTINCT DATE_FORMAT(wf.followup_date,'%Y/%m/%d %H:%i') followupDate,DATE_FORMAT(wf.followup_plan_date,'%Y/%m/%d %H:%i') executeTime,wf.doctor_code doctorCode,wf.followup_class followupClass, " +
                        " wf.patient_code AS patientCode,wf.patient_name AS patientName,wf.doctor_name doctorName,wf.`status` AS `status`,wf.org_name orgName," +
                        " wf.org_code orgCode,sd.value AS `value`, wf.followup_type  followupType,wf.id AS id, 6 AS code,2 as flag FROM  wlyy.wlyy_followup wf " +
                        " LEFT JOIN wlyy.system_dict sd ON wf.followup_type = sd.CODE " +
                        " wf.org_code orgCode,sd.value AS `value`, wf.followup_type  followupType,wf.id AS id, 6 AS code,2 as flag FROM  wlyy_followup wf " +
                        " LEFT JOIN system_dict sd ON wf.followup_type = sd.CODE " +
                        " AND sd.dict_name = 'FOLLOWUP_WAY_DICT' WHERE wf.status !=0  AND wf.patient_code = '"+patient+"' order by wf.followup_plan_date desc  ";
                list = jdbcTemplate.queryForList(sfSql);
            }

+ 2 - 69
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/RehabilitationPlanService.java

@ -20,13 +20,11 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -43,10 +41,6 @@ import java.util.stream.Collectors;
@Transactional
public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlanningDO, PatientRehabilitationPlanDao> {
    @Value("${base.url}")
    private String baseUrl;
    @Autowired
    private RehabilitationPlanTemplateDao templateDao;
    @Autowired
@ -85,7 +79,7 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
        String user = templateDO.getCreateUser();
        String userName = templateDO.getCreateUserName();
        //默认新增服务项
        String sql = "SELECT code from wlyy.system_dict WHERE `dict_name` = 'default_service_item_id'";
        String sql = "SELECT code from system_dict WHERE `dict_name` = 'default_service_item_id'";
        List<String> list = jdbcTemplate.queryForList(sql,String.class);
        if(list!=null&&list.size()>0){
            list.stream().forEach(code->{
@ -180,7 +174,7 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
        planDO.setUpdateTime(new Date());
        //判断是否签约,如果签约 新增家签团队id
        try{
            String sql = "SELECT a.admin_team_code  from wlyy.wlyy_sign_family a WHERE patient = '"+planDO.getPatient()+"' and `status`>0 and expenses_status =1 order by id desc limit 1 ";
            String sql = "SELECT a.admin_team_code  from wlyy_sign_family a WHERE patient = '"+planDO.getPatient()+"' and `status`>0 and expenses_status =1 order by id desc limit 1 ";
            List<Map<String,Object>> list =  jdbcTemplate.queryForList(sql);
            if(list!=null&&list.size()>0){
                planDO.setAdminTeamCode(Long.valueOf(list.get(0).get("admin_team_code")+""));
@ -258,67 +252,6 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
        return MixEnvelop.getSuccessList(SpecialistMapping.api_success, jsonArray);
    }
    /**
     * 调用服务包创建接口
     * @param planDO
     * @param details
     */
    public String addServicePackage(PatientRehabilitationPlanDO planDO, List<RehabilitationDetailDO> details) {
        JSONObject jsonData = new JSONObject();
        JSONObject servicePackageVO = new JSONObject();
        JSONObject signRecordVO = new JSONObject();
        JSONArray detailsVOList = new JSONArray();
        //服务项目数据
        for(RehabilitationDetailDO detail : details){
            JSONObject detailsVO = new JSONObject();
            detailsVO.put("executionType", "1");
            detailsVO.put("executionTime", DateUtil.dateToStr(detail.getExecuteTime(), "yyyy-MM-dd hh:mm:ss"));
            List<String> hospitalServiceIds = new ArrayList<>();
            hospitalServiceIds.add(detail.getHospitalServiceItemId());
            HospitalServiceItemDO signHospitalServiceItemDO = hospitalServiceItemService.selectById(hospitalServiceIds).getDetailModelList().get(0);
            detailsVO.put("code", signHospitalServiceItemDO.getServiceItemId());
            detailsVO.put("name", signHospitalServiceItemDO.getSpecialistServiceItemDO().getTitle());
            detailsVOList.add(detailsVO);
        }
        //服务包数据
        servicePackageVO.put("detailsVOList", detailsVOList);
        servicePackageVO.put("num", detailsVOList.size());
        servicePackageVO.put("saasId", "xmihealth");
        servicePackageVO.put("name", planDO.getTitle());
        servicePackageVO.put("introduce", planDO.getTitle());
        servicePackageVO.put("creater", planDO.getCreateUser());
        servicePackageVO.put("type", "1");
        servicePackageVO.put("price", planDO.getTotalExpense());
        //签约记录数据
        signRecordVO.put("servicePackageName", planDO.getTitle());
        signRecordVO.put("patient", planDO.getPatient());
        signRecordVO.put("name", planDO.getName());
        PatientSignInfoVO patientSignInfoVO = (PatientSignInfoVO) specialistService.findPatientSignSpecialistInfo(planDO.getPatient(), planDO.getCreateUser()).getObj();
        signRecordVO.put("idcard", patientSignInfoVO.getIdcard());
        signRecordVO.put("ssc", patientSignInfoVO.getSsc());
        signRecordVO.put("signDoctor", patientSignInfoVO.getDoctor());
        signRecordVO.put("signDoctorName", patientSignInfoVO.getDoctorName());
        signRecordVO.put("hospital", patientSignInfoVO.getHospital());
        signRecordVO.put("hospitalName", patientSignInfoVO.getHospitalName());
        signRecordVO.put("adminTeamCode", patientSignInfoVO.getTeamCode());
        signRecordVO.put("price", planDO.getTotalExpense());
        signRecordVO.put("saasId", "xmihealth");
        jsonData.put("servicePackageVO", servicePackageVO);
        jsonData.put("signRecordVO", signRecordVO);
        String response = null;
        try {
            response = httpClientUtil.postBody(baseUrl + "base_rehabilitation/create", jsonData);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = JSONObject.parseObject(response);
        if ("success".equals(rs.getString("message"))) {
            return rs.getJSONObject("obj").getString("id");
        }
        return null;
    }
    public void updateServicePackageId(String planId, String servicePackageId) {
        patientRehabilitationPlanDao.updateServicePackageId(planId, servicePackageId);

File diff suppressed because it is too large
+ 5 - 5
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/SpecialistScreenResultService.java


+ 75 - 128
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/SpecialistService.java

@ -122,7 +122,7 @@ public class SpecialistService{
                " rd.create_time AS createTime ," +
                " p.sex " +
                " FROM " +
                " wlyy_specialist_patient_relation r JOIN wlyy_patient p ON p.code = r.patient  " +
                " wlyy_specialist_patient_relation r JOIN base_patient p ON p.code = r.patient  " +
                " LEFT JOIN wlyy_patient_hospital_record rd ON r.discharge_record = rd.id " +
                " WHERE " +
                " r.doctor = '"+doctor+"' AND r.status >=0  AND r.sign_status >0" +
@ -163,7 +163,7 @@ public class SpecialistService{
                " h.label_name as health, " +
                " h.label AS healthcode " +
                " FROM " +
                " wlyy_specialist_patient_relation r JOIN wlyy_patient p ON p.`code` = r.patient " +
                " wlyy_specialist_patient_relation r JOIN base_patient p ON p.id = r.patient " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  t.label, " +
@ -219,10 +219,10 @@ public class SpecialistService{
                "  AND i.label_type = '"+labelType+"' " +
                "  AND i.`status` = '1' " +
                " ) lb " +
                " JOIN wlyy_patient p ON p. CODE = lb.patient " +
                " JOIN base_patient p ON p. CODE = lb.patient " +
                " JOIN wlyy_specialist_patient_relation s ON s.patient = lb.patient ";
        if(StringUtils.isNotBlank(shareDoctor)){
            sql = sql + " JOIN wlyy_doctor_special_share sp ON s.id = sp.special_code and sp.doctor = '"+shareDoctor+"' ";
            sql = sql + " JOIN base_doctor_special_share sp ON s.id = sp.special_code and sp.doctor = '"+shareDoctor+"' ";
        }
        sql = sql +" WHERE s.team_code ='" +teamCode+"' "+
                " AND s.status >=0  AND s.sign_status >0"+
@ -242,11 +242,11 @@ public class SpecialistService{
//                    "a.health_assistant_name AS healthAssistantName, " +
                    " a.is_manage AS isManage, " +
                    "a.id AS specialCode " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                    "FROM wlyy_specialist_patient_relation a " +
                    "JOIN wlyy_patient_disease_server b ON a.id=b.specialist_relation_code AND b.disease=" +labelCode+" and b.del=1 "+
                    "JOIN wlyy_patient c ON a.patient=c.CODE ";
                    "JOIN base_patient c ON a.patient=c.CODE ";
            if(StringUtils.isNotBlank(shareDoctor)){
                sql = sql + " JOIN wlyy_doctor_special_share sp ON a.id = sp.special_code and sp.doctor = '"+shareDoctor+"' ";
                sql = sql + " JOIN base_doctor_special_share sp ON a.id = sp.special_code and sp.doctor = '"+shareDoctor+"' ";
            }
            sql = sql +"LEFT JOIN wlyy_sign_patient_label_info d ON a.patient=d.patient AND d.label_type=8 AND d.`status`=1" +
                    " WHERE a.sign_status> 0 AND a.`status`>=0 " +
@ -264,8 +264,8 @@ public class SpecialistService{
                    "a.health_assistant AS healthAssistant,a.health_assistant_name as healthAssistantName" +
//                    "a.health_assistant_name AS healthAssistantName, " +
                    ",a.is_manage AS isManage " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                    "JOIN wlyy_patient c ON a.patient=c.CODE " +
                    "FROM wlyy_specialist_patient_relation a " +
                    "JOIN base_patient c ON a.patient=c.CODE " +
                    " WHERE a.sign_status> 0 AND a.`status`>=0 AND (a.is_manage = 0 or a.is_manage is null)" +
                    " AND a.team_code ='" +teamCode+"' "+
                    " LIMIT "+(page-1)*size+","+size;
@ -289,7 +289,7 @@ public class SpecialistService{
                " FROM " +
                " wlyy_specialist_patient_relation a ";
        if(StringUtils.isNotBlank(shareDoctor)){
            sql = sql + " JOIN wlyy.wlyy_doctor_special_share b ON b.special_code = a.id AND b.doctor = '"+shareDoctor+"' ";
            sql = sql + " JOIN base_doctor_special_share b ON b.special_code = a.id AND b.doctor = '"+shareDoctor+"' ";
        }
        sql = sql+" WHERE " +
                " a.team_code = '"+teamCode+"' " +
@ -327,7 +327,7 @@ public class SpecialistService{
                " h.label AS healthcode " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_patient p ON r.patient = p.`code` " +
                " JOIN base_patient p ON r.patient = p.id " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  t.label, " +
@ -340,7 +340,7 @@ public class SpecialistService{
                " AND t.`status` = '1' " +
                " ) h ON h.patient = r.patient " +
                " WHERE " +
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy.wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                "' ) " +
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND " + "r.patient_name" + " LIKE '%"+nameKey+"%' "+
@ -364,7 +364,7 @@ public class SpecialistService{
                " h.label AS healthcode " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_patient p ON r.patient = p.`code` " +
                " JOIN base_patient p ON r.patient = p.id " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  t.label, " +
@ -377,7 +377,7 @@ public class SpecialistService{
                " AND t.`status` = '1' " +
                " ) h ON h.patient = r.patient " +
                " WHERE " +
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy.wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                " r.doctor IN ( SELECT m.doctor_code FROM wlyy_admin_team_member m WHERE m.team_id ='" +teamCode+
                "' ) " +
                " AND r.status >=0  AND r.sign_status >0 " +
                " AND (" +  "r.patient_name"  + " LIKE '%"+filter+"%' OR p.idcard LIKE '%"+filter+"%') "+
@ -396,7 +396,7 @@ public class SpecialistService{
                " COUNT(1) AS total" +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_patient p ON r.patient = p.`code` " +
                " JOIN base_patient p ON r.patient = p.id " +
                " JOIN ( " +
                " SELECT " +
                "  t.label, " +
@ -420,8 +420,6 @@ public class SpecialistService{
        String sql ="SELECT " +
                " p.code AS patient ,r.patient_name as patientName" +
                //AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " p.`name` AS patientName, " +
                " ,p.photo, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.sex, " +
@ -429,7 +427,7 @@ public class SpecialistService{
                " h.label AS healthcode " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_patient p ON r.patient = p.`code` " +
                " JOIN base_patient p ON r.patient = p.id " +
                " JOIN ( " +
                " SELECT " +
                "  t.label, " +
@ -458,18 +456,14 @@ public class SpecialistService{
        String checkDoctorSql = "SELECT " +
                " r.id AS relationCode," +
                " r.patient ,r.patient_name as patientName " +
                //AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.team_code AS teamCode, " +
                " t.`name`, " +
                " d.photo ," +
                " d.code AS doctor, r.doctor_name as doctorName" +
               // AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
//                " d.name AS doctorName" +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_admin_team t ON t.id = r.team_code " +
                " JOIN wlyy_doctor d ON d. CODE = r.doctor " +
                " JOIN base_doctor d ON d.id = r.doctor " +
                " WHERE " +
                " r.patient = '"+patient+"' " +
                " AND r.doctor = '"+doctor+"' " +
@ -498,7 +492,7 @@ public class SpecialistService{
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_admin_team t ON t.id = r.team_code " +
                " JOIN wlyy_doctor d ON d. CODE = r.doctor " +
                " JOIN base_doctor d ON d.id = r.doctor " +
                " WHERE " +
                " r.patient = '"+patient+"' " +
                " AND r.team_code = " +teamCode+
@ -538,7 +532,7 @@ public class SpecialistService{
                        " d.`name` AS doctorName " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " JOIN wlyy_doctor d ON m.doctor_code = d.`code` " +
                " JOIN base_doctor d ON m.doctor_code = d.id " +
                " WHERE  " +
                " m.available='1' " +
                " AND m.team_id="+teamId;
@ -570,11 +564,7 @@ public class SpecialistService{
    public MixEnvelop<PatientSignInfoVO, PatientSignInfoVO> findPatientSigninfo(String code){
        String sql = "SELECT " +
                " r.patient ,r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.doctor ,r.doctor_name as doctorName" +
                //AesEncryptUtils.decryptMysql("r.doctor_name","doctorName") +
//                " r.doctor_name AS doctorName, " +
                " ,d.hospital, " +
                " d.hospital_name AS hospitalName, " +
                " d.photo, " +
@ -588,7 +578,7 @@ public class SpecialistService{
                " r.team_code AS teamCode  " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_doctor d ON r.doctor = d.code " +
                " JOIN base_doctor d ON r.doctor = d.code " +
                " JOIN wlyy_admin_team t ON t.id = r.team_code " +
                " WHERE " +
                " r.id = '"+code+"'";
@ -601,20 +591,16 @@ public class SpecialistService{
        String sql = "SELECT " +
                " r.id AS relationCode, " +
                " r.patient, r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
                " ,r.team_code,r.sign_date , " +
                " t.`name` AS name," +
                " d.photo," +
                " md.code AS doctor,md.name as doctorName" +
              //  AesEncryptUtils.decryptMysql("md.name","doctorName") +
//                " md.name AS doctorName," +
                ",d.hospital,d.hospital_name " +
                " FROM " +
                " wlyy_specialist_patient_relation r  " +
                " JOIN wlyy_admin_team t ON t.id = r.team_code " +
                " JOIN wlyy_doctor d ON t.leader_code = d.`code` " +
                " JOIN wlyy_doctor md ON md.code = r.doctor " +
                " JOIN base_doctor d ON t.leader_code = d.id " +
                " JOIN base_doctor md ON md.code = r.doctor " +
                " WHERE " +
                " r.patient = '"+patient+"' " +
                " AND r.`status` >=0  " +
@ -635,11 +621,7 @@ public class SpecialistService{
                " r.id AS relationCode, " +
                " r.patient, " +
                " r.team_code AS teamCode,r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
//                " r.patient_name AS patientName, " +
//                " d.name AS doctorName, " +
                ",d.name as doctorName"+
               // AesEncryptUtils.decryptMysql("d.name","doctorName") +
                " ,d.code AS doctor, " +
                " d.photo, " +
                " d.dept, " +
@ -651,7 +633,7 @@ public class SpecialistService{
                " d.`level` " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN wlyy_doctor d ON r.doctor = d.`code` " +
                " JOIN base_doctor d ON r.doctor = d.id " +
                " WHERE  " +
                " r.patient ='"+patient+"' " +
                " AND r.`status`>=0 " +
@ -668,11 +650,8 @@ public class SpecialistService{
                " r.id AS relationCode," +
                " r.patient, " +
                " r.team_code AS teamCode,r.patient_name as patientName" +
               // AesEncryptUtils.decryptMysql("r.patient_name","patientName") +
                " ,r.health_assistant AS healthAssistant,r.health_assistant_name as healthAssistantName" +
                //AesEncryptUtils.decryptMysql("r.health_assistant_name","healthAssistantName") +
                " ,r.create_time AS createTime," +
//                AesEncryptUtils.decryptMysql("d.name","doctorName") +
                " d.name AS doctorName, " +
                " ,d.code AS doctor, " +
                " d.photo, " +
@ -683,16 +662,16 @@ public class SpecialistService{
                " r.id AS specialCode, " +
                " d.`level` " +
                " FROM " +
                " wlyy_specialist.wlyy_specialist_patient_relation r " +
                " JOIN wlyy_doctor d ON r.doctor = d.`code` " +
                " wlyy_specialist_patient_relation r " +
                " JOIN base_doctor d ON r.doctor = d.id " +
                " WHERE  " +
                " r.patient ='"+patient+"' " +
                " AND r.doctor in" +
                " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in  " +
                "  (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id  " +
                " (SELECT m.doctor_code FROM  wlyy_admin_team_member m where m.team_id in  " +
                "  (SELECT dt.id FROM  wlyy_admin_team dt LEFT JOIN  wlyy_admin_team_member watm ON dt.id=watm.team_id  " +
                "  WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1')" +
//                " AND r.`status`>=0 " +
                " AND r.sign_status >0 ) r join wlyy_patient p on r.patient = p.code order by p.czrq DESC ";
                " AND r.sign_status >0 ) r join base_patient p on r.patient = p.code order by p.czrq DESC ";
        List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientSignInfoVO.class));
        PatientSignInfoVO patientSignInfoVO = (null != patientSignInfoVOs && patientSignInfoVOs.size() > 0 )? patientSignInfoVOs.get(0):null;
        return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientSignInfoVO);
@ -705,7 +684,6 @@ public class SpecialistService{
        if(StringUtils.isNotBlank(name)){
            sql = "SELECT " +
                    "doctor.CODE AS CODE" +
//                    AesEncryptUtils.decryptMysql("doctor.name","name") +
                    ",doctor.NAME AS NAME" +
                    ",doctor.sex AS sex," +
                    "doctor.birthday AS birthday," +
@ -722,19 +700,13 @@ public class SpecialistService{
                    "doctor.czrq AS czrq," +
                    "doctor.del AS del," +
                    "doctor.idcard AS idcard " +
                    "FROM wlyy.wlyy_doctor doctor JOIN ( " +
                    "SELECT a.doctor AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                    "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                    "UNION  " +
                    "SELECT a.doctor_health AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                    "FROM base_doctor doctor JOIN ( " +
                    "SELECT a.doctor AS doctorcode FROM wlyy_sign_family a RIGHT JOIN ( " +
                    "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                    ") " +
                    "t ON doctor.CODE=t.doctorcode and doctor.NAME like '%"+name+"%'";
                    ")  t ON doctor.CODE=t.doctorcode and doctor.NAME like '%"+name+"%'";
        }else{
            sql = "SELECT " +
                    "doctor.CODE AS CODE" +
//                    AesEncryptUtils.decryptMysql("doctor.name","name") +
                    ",doctor.NAME AS NAME" +
                    ",doctor.sex AS sex," +
                    "doctor.birthday AS birthday," +
@ -751,14 +723,10 @@ public class SpecialistService{
                    "doctor.czrq AS czrq," +
                    "doctor.del AS del," +
                    "doctor.idcard AS idcard " +
                    "FROM wlyy.wlyy_doctor doctor JOIN ( " +
                    "SELECT a.doctor AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                    "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                    "UNION  " +
                    "SELECT a.doctor_health AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                    "FROM base_doctor doctor JOIN ( " +
                    "SELECT a.doctor AS doctorcode FROM wlyy_sign_family a RIGHT JOIN ( " +
                    "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                    ") " +
                    "t ON doctor.CODE=t.doctorcode";
                    ")  t ON doctor.CODE=t.doctorcode";
        }
        
        List<SignFamilyDoctorVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamilyDoctorVO.class));
@ -768,11 +736,11 @@ public class SpecialistService{
    public MixEnvelop<Long,Long> findSpecialistSignFamilyPatientCout(String specialdoctor, String familydoctor) {
    
        String sql = "SELECT count(1) AS total " +
                "FROM wlyy.wlyy_sign_family a WHERE a.`status`=1 AND a.expenses_status=1 " +
                "FROM wlyy_sign_family a WHERE a.`status`=1 AND a.expenses_status=1 " +
                "AND patient IN (" +
                "SELECT patient FROM wlyy_specialist.wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "AND doctor='"+specialdoctor+"') " +
                "AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
                "AND a.doctor='"+familydoctor+"' ";
    
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
        Long count = 0L;
@ -785,20 +753,18 @@ public class SpecialistService{
    public MixEnvelop<PatientRelationVO,PatientRelationVO> getSpecialistSignFamilyPatientByName(String specialdoctor, String familydoctor, String nameKey, Integer page, Integer size) {
        String sql ="SELECT " +
                "p.CODE AS patient" +
//                AesEncryptUtils.decryptMysql("p.name","patientName") +
                ",p.`name` AS patientName" +
                ",p.photo," +
                "IFNULL(YEAR (from_days(datediff(now(),p.birthday))),'未知') age," +
                "p.sex " +
                "FROM wlyy.wlyy_patient p " +
                "FROM base_patient p " +
                "JOIN ( " +
                " SELECT a.patient FROM wlyy.wlyy_sign_family a WHERE patient IN (" +
                " SELECT a.patient FROM wlyy_sign_family a WHERE patient IN (" +
                "  SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "  AND doctor='"+specialdoctor+"') " +
                "  AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
                "  AND a.doctor='"+familydoctor+"'  ";
        if(StringUtils.isNotBlank(nameKey)){
            sql= sql + " AND  a.name LIKE '%"+nameKey+"%' ";
//            sql= sql + " AND " + AesEncryptUtils.decryptMysqlNo("a.name") + " LIKE '%"+nameKey+"%' ";
        }
        sql= sql +" AND a.`status`=1 AND a.expenses_status=1) s ON p.CODE=s.patient" +
                " LIMIT "+(page-1)*size+","+size;
@ -815,11 +781,10 @@ public class SpecialistService{
                "IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                "p.birthday, " +
                "p.photo " +
//                "FROM (SELECT s.disease,s.disease_name,s.patient" + AesEncryptUtils.decryptMysql("s.patient_name","patient_name") + ",r.team_code from " +
                "FROM (SELECT s.disease,s.disease_name,s.patient s.patient_name,r.team_code from " +
                "(SELECT id, team_code FROM wlyy_specialist_patient_relation WHERE doctor='" + doctor + "' and sign_status > 0 and `status` >= 0) r " +
                "JOIN wlyy_patient_disease_server s on r.id = s.specialist_relation_code WHERE s.del = 1) s " +
                "JOIN wlyy_patient p on s.patient = p.`code` where p.`status` >0 ";
                "JOIN base_patient p on s.patient = p.id where p.`status` >0 ";
        if(StringUtils.isNotBlank(patientInfo)){
            sql += " and p.idcard like '%"+ patientInfo +"%' or patient_name  like '%" + patientInfo + "%'";
        }
@ -842,19 +807,18 @@ public class SpecialistService{
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo ";
        String whereSql ="";
        if(!StringUtils.isEmpty(keywords)){
//            whereSql+=" and (p.name like '%"+keywords+"%' or p.idcard like '%"+keywords+"%' or p.mobile like '%"+keywords+"%') ";
            whereSql+=" and  p.mobile ='"+keywords+"'";
        }
        String centerSql =" from wlyy_patient p  " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' " +
        String centerSql =" from base_patient p  " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist_patient_relation r WHERE r.sign_status = '1' " +
                " AND doctor in (SELECT m.doctor_code FROM  wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  wlyy_admin_team dt LEFT JOIN  wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1'))"
                +" AND p.openid IS NOT NULL "+
               whereSql;
        String countCenterSql =" from wlyy_patient p " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1'" +
        String countCenterSql =" from base_patient p " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist_patient_relation r WHERE r.sign_status = '1'" +
                " AND doctor in (SELECT m.doctor_code FROM  wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  wlyy_admin_team dt LEFT JOIN  wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1'))"
@ -871,7 +835,7 @@ public class SpecialistService{
        String sexName="";
        for(Map<String,Object> one:map){
            StringBuffer statusSql =new StringBuffer( " select CASE WHEN wsf.status ='-4' THEN '已到期' WHEN wsf.status ='0' THEN '待签约' WHEN wsf.status ='1' THEN '已签约' WHEN wsf.status ='2' THEN '已签约' WHEN wsf.status ='3' THEN '已签约' ELSE '待签约' END  status  ");
            statusSql.append("FROM wlyy.wlyy_sign_family wsf, (SELECT patient,Max(apply_date) applyDate FROM wlyy.wlyy_sign_family WHERE type = '2' AND patient='"+one.get("code")+"' GROUP BY patient) temp WHERE wsf.patient=temp.patient AND wsf.apply_date=temp.applyDate");
            statusSql.append("FROM wlyy_sign_family wsf, (SELECT patient,Max(apply_date) applyDate FROM wlyy_sign_family WHERE type = '2' AND patient='"+one.get("code")+"' GROUP BY patient) temp WHERE wsf.patient=temp.patient AND wsf.apply_date=temp.applyDate");
            List<Map<String,Object>> strMap= jdbcTemplate.queryForList(statusSql.toString());
            m = new HashMap();
            age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
@ -894,7 +858,6 @@ public class SpecialistService{
        }
        Long co=Long.parseLong("100");
        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,countMap.size()>0?Long.valueOf(countMap.get(0).get("num")+""):0);
//        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,co);
    }
    /**
@ -913,9 +876,9 @@ public class SpecialistService{
        //1、获取居民基础信息
        String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
        String patientSql = " from wlyy_patient p LEFT JOIN wlyy_sign_family wsf " +
        String patientSql = " from base_patient p LEFT JOIN wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
                " LEFT JOIN wlyy_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
                " LEFT JOIN base_doctor wd ON wsf.doctor =wd.code WHERE p.id='" + patientCode + "'";
        //一个居民 生效的家签信息只会有一条
        Map<String, Object> map = jdbcTemplate.queryForMap(preSql + patientSql);
        map.put("age",IdCardUtil.getAgeForIdcard(map.get("idcard")+""));
@ -932,11 +895,11 @@ public class SpecialistService{
        jsonObject.put("patientInfo", map);
        //2、获取医生信息(所属医院、科室、姓名)
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM base_doctor wd WHERE wd.code='" + doctorCode + "'";
        jsonObject.put("doctorInfo", jdbcTemplate.queryForMap(doctorSql));
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM wlyy_doctor wd LEFT JOIN  wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, wlyy_admin_team at " +
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM base_doctor wd LEFT JOIN  wlyy_admin_team_member tm ON wd.id = tm.doctor_code, wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
@ -947,13 +910,11 @@ public class SpecialistService{
            objectMap.put("teamName", m.get(i).get(0).get("teamName"));
            objectMap.put("teamDoctors", m.get(i));
            //获取专科团队疾病标签
           String disSql = "SELECT wtdr.disease_code, wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code ='" + i + "'" +"  AND wtdr.del='1'";
            //new BeanPropertyRowMapper(
           String disSql = "SELECT wtdr.disease_code, wtdr.disease_name from  wlyy_team_disease_relation wtdr WHERE wtdr.team_code ='" + i + "'" +"  AND wtdr.del='1'";
            List<Map<String, Object>>  stringList = jdbcTemplate.queryForList(disSql);
            String areaSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1'";
            String areaSql = "SELECT wpds.disease FROM wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1'";
            List<String> signDiseaseList = jdbcTemplate.queryForList(areaSql,String.class);
            Set<String> stringSet =new HashSet<>(signDiseaseList);
//            stringSet.addAll(new HashSet<>(signDiseaseList));
            //已签约的疾病状态改成1
            stringList.stream().forEach(item->{
                item.put("status",stringSet.contains( item.get("disease_code"))?1:0) ;
@ -964,7 +925,7 @@ public class SpecialistService{
        jsonObject.put("teamAndDoctors", mapList);
        //康复情况标签
        String labelSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        String labelSql = "SELECT wspl.label_code,wspl.label_name from  wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(labelSql);
        jsonObject.put("signPatientLabels", signPatientLabelList);
        return jsonObject;
@ -989,9 +950,9 @@ public class SpecialistService{
        //1、获取居民基础信息
        String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
        String patientSql = " from wlyy_patient p LEFT JOIN wlyy_sign_family wsf " +
        String patientSql = " from base_patient p LEFT JOIN wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
                " LEFT JOIN wlyy_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
                " LEFT JOIN base_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
        //一个居民 生效的家签信息只会有一条
        Map<String, Object> map = jdbcTemplate.queryForMap(preSql + patientSql);
        map.put("age",IdCardUtil.getAgeForIdcard(map.get("idcard")+""));
@ -1008,9 +969,9 @@ public class SpecialistService{
        jsonObject.put("patientInfo", map);
        //2、获取医生信息(所属医院、科室、姓名)
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";;
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM base_doctor wd WHERE wd.code='" + doctorCode + "'";;
        if("0".equals(signStatus)){
            doctorSql="SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM wlyy_doctor wd WHERE wd.code='" + specialistPatientRelationDO.getDoctor() + "'";
            doctorSql="SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM base_doctor wd WHERE wd.code='" + specialistPatientRelationDO.getDoctor() + "'";
        }
        Map<String,Object> result =jdbcTemplate.queryForMap(doctorSql);
        if ("0".equals(signStatus) && !(doctorCode.equals(specialistPatientRelationDO.getDoctor()))) {
@ -1021,7 +982,7 @@ public class SpecialistService{
        jsonObject.put("doctorInfo", result);
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM wlyy_doctor wd LEFT JOIN  wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, wlyy_admin_team at " +
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM base_doctor wd LEFT JOIN  wlyy_admin_team_member tm ON wd.id = tm.doctor_code, wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
@ -1037,15 +998,15 @@ public class SpecialistService{
            objectMap.put("teamName", m.get(i).get(0).get("teamName"));
            objectMap.put("teamDoctors", m.get(i));
            //获取专科团队疾病标签
            String disSql = "SELECT wtdr.disease_code, wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code ='" + i + "'" +"  AND wtdr.del='1'";
            String disSql = "SELECT wtdr.disease_code, wtdr.disease_name from  wlyy_team_disease_relation wtdr WHERE wtdr.team_code ='" + i + "'" +"  AND wtdr.del='1'";
            //new BeanPropertyRowMapper(
            List<Map<String, Object>>  stringList = jdbcTemplate.queryForList(disSql);
            String areaSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1'";
            String areaSql = "SELECT wpds.disease FROM wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1'";
            List<String> signDiseaseList = jdbcTemplate.queryForList(areaSql,String.class);
            Set<String> stringSet =new HashSet<>(signDiseaseList);
            List<String> speciaSignDiseaseList = new ArrayList<>();
            if("0".equals(signStatus) ){
                String speciaSignSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1' and wpds.specialist_relation_code='" + specialistPatientRelationDO.getId() + "'";
                String speciaSignSql = "SELECT wpds.disease FROM wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1' and wpds.specialist_relation_code='" + specialistPatientRelationDO.getId() + "'";
                speciaSignDiseaseList = jdbcTemplate.queryForList(speciaSignSql,String.class);
            }
@ -1069,12 +1030,12 @@ public class SpecialistService{
        jsonObject.put("teamAndDoctors", mapList);
        //康复情况标签
        String labelSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        String labelSql = "SELECT wspl.label_code,wspl.label_name from  wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(labelSql);
        List<String> patientLabelList = new ArrayList<>();
        if("0".equals(signStatus) ){
            //居民的康复情况
            String patientLabelSql = "SELECT wspl.label from  wlyy.wlyy_sign_patient_label_info wspl WHERE wspl.patient='"+patientCode+"' and  wspl.label_type='8' AND status='1'";
            String patientLabelSql = "SELECT wspl.label from  wlyy_sign_patient_label_info wspl WHERE wspl.patient='"+patientCode+"' and  wspl.label_type='8' AND status='1'";
            patientLabelList = jdbcTemplate.queryForList(patientLabelSql,String.class);
        }
        Set<String> patientLabelSet =new HashSet<>(patientLabelList);
@ -1140,7 +1101,6 @@ public class SpecialistService{
     * @return
     */
    public List<SpecialistPatientRelationDO> selectByAssistant(String patient,String doctor){
        String sql = "select *" +
                " from wlyy_specialist_patient_relation r where r.health_assistant = '"+doctor+"' and r.patient = '"+patient+"' ";
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
@ -1160,9 +1120,9 @@ public class SpecialistService{
            whereSql+=" and  p.mobile ='"+keywords+"'";
        }
        //根据手机号码精确查找居民
        String centerSql =" from wlyy_patient p /*LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r ON p.code=r.patient */where  p.openid IS NOT NULL "+whereSql;
        String centerSql =" from base_patient p where  p.openid IS NOT NULL "+whereSql;
        String signSql ="SELECT r.patient,r.sign_status  FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE (r.sign_status = '1' or r.sign_status = '0') " +
        String signSql ="SELECT r.patient,r.sign_status  FROM  wlyy_specialist_patient_relation r WHERE (r.sign_status = '1' or r.sign_status = '0') " +
                " AND doctor in (SELECT m.doctor_code FROM  wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  wlyy_admin_team dt LEFT JOIN  wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1')";
@ -1224,9 +1184,9 @@ public class SpecialistService{
     * @return
     */
    public SpecialistPatientRelationDO selectByDoctorAndPatient(String doctor,String patient){
        String sql = "select * from wlyy_specialist.wlyy_specialist_patient_relation r where r.doctor in ( " +
                " SELECT m.doctor_code  FROM wlyy.wlyy_admin_team_member m " +
                " WHERE  m.team_id IN ( SELECT dt.id  FROM  wlyy.wlyy_admin_team dt LEFT JOIN wlyy.wlyy_admin_team_member watm ON dt.id = watm.team_id   WHERE " +
        String sql = "select * from wlyy_specialist_patient_relation r where r.doctor in ( " +
                " SELECT m.doctor_code  FROM wlyy_admin_team_member m " +
                " WHERE  m.team_id IN ( SELECT dt.id  FROM  wlyy_admin_team dt LEFT JOIN wlyy_admin_team_member watm ON dt.id = watm.team_id   WHERE " +
                " dt.available = '1' AND watm.available = '1'  AND watm.doctor_code = '"+doctor+"') AND m.available = '1'  ) and r.patient = '"+patient+"' and r.sign_status=0";
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
        SpecialistPatientRelationDO specialistPatientRelationDO=null!=relationDOS&&relationDOS.size()>0?relationDOS.get(0):new SpecialistPatientRelationDO();
@ -1239,7 +1199,7 @@ public class SpecialistService{
     * @return
     */
    public Map<String,Object> getMessageByRelationId(String relationId){
        String sql = "select w.* from wlyy.wlyy_message w where w.type='16' and  w.relation_code='" + relationId + "' ";
        String sql = "select w.* from wlyy_message w where w.type='16' and  w.relation_code='" + relationId + "' ";
       List<Map<String,Object>> res= jdbcTemplate.queryForList(sql);
       if(null!=res&&res.size()>0){
           return res.get(0);
@ -1253,7 +1213,7 @@ public class SpecialistService{
     * @return
     */
    public void updateMessageByRelationId(String relationId){
        String sql = "update wlyy.wlyy_message set has_read=0 ,over=0  where relation_code='" + relationId + "' ";
        String sql = "update wlyy_message set has_read=0 ,over=0  where relation_code='" + relationId + "' ";
        jdbcTemplate.execute(sql);
    }
@ -1269,32 +1229,19 @@ public class SpecialistService{
        if (!teamCode.equals(toTeamCode)){//跨团队
            flag=true;
        }
        String sql =" select name from wlyy.wlyy_doctor where code='"+toDoctorCode+"'";
        String sql =" select name from base_doctor where code='"+toDoctorCode+"'";
        String toDoctorName = jdbcTemplate.queryForObject(sql,String.class);
//        toDoctorName = AesEncryptUtils.decrypt(toDoctorName);
        sql =" select name from wlyy.wlyy_doctor where code='"+doctorCode+"'";
        sql =" select name from base_doctor where code='"+doctorCode+"'";
        String doctorName = jdbcTemplate.queryForObject(sql,String.class);
//        doctorName = AesEncryptUtils.decrypt(doctorName);
        JSONObject result = new JSONObject();
        JSONArray planObject = new JSONArray();
        JSONArray planDetailObject = new JSONArray();
        JSONArray specialistPatientRelation = new JSONArray();
        JSONArray rehabilitationOperateRecords = new JSONArray();
        for (String patientCode:patient){
            sql ="select name from wlyy.wlyy_patient where code='"+patientCode+"' ";
            sql ="select name from base_patient where code='"+patientCode+"' ";
            String patientName = jdbcTemplate.queryForObject(sql,String.class);
            Long admin_team_code = 0L;
            //判断是否签约,如果签约 新增家签团队id
            try{
                String sqltmp = "SELECT a.admin_team_code  from wlyy.wlyy_sign_family a WHERE patient = '"+patientCode+"' and `status`>0 and expenses_status =1 order by id desc limit 1 ";
                List<Map<String,Object>> list =  jdbcTemplate.queryForList(sqltmp);
                if(list!=null&&list.size()>0){
                    admin_team_code = Long.valueOf(list.get(0).get("admin_team_code")+"");
                }
            }catch (Exception e){
                e.printStackTrace();
            }
//            patientName = AesEncryptUtils.decrypt(patientName);
            List<PatientRehabilitationPlanDO> planList  = patientRehabilitationPlanDao.findByPatientAndCreateUserAndTeamCode(patientCode,doctorCode,Integer.parseInt(teamCode));{
                for (PatientRehabilitationPlanDO plan:planList){
                    plan.setCreateUser(toDoctorCode);
@ -1377,7 +1324,7 @@ public class SpecialistService{
                    }
                    specialistPatientRelationDao.save(relationDO);
                    specialistPatientRelation.add(relationDO.getId());
                    sql = "UPDATE wlyy.wlyy_patient_disease_server set specialist_relation_code='"+relationDO.getId()+"' \n" +
                    sql = "UPDATE wlyy_patient_disease_server set specialist_relation_code='"+relationDO.getId()+"' \n" +
                            "where specialist_relation_code='"+relationDoBefore.getId()+"'";
                    jdbcTemplate.execute(sql);
                }
@ -1391,7 +1338,7 @@ public class SpecialistService{
                    relations.setUpdateUserName(doctorName);
                    specialistPatientRelationDao.save(relations);
                    specialistPatientRelation.add(relations.getId());
                    sql = "UPDATE wlyy.wlyy_patient_disease_server set specialist_relation_code='"+relations.getId()+"' \n" +
                    sql = "UPDATE wlyy_patient_disease_server set specialist_relation_code='"+relations.getId()+"' \n" +
                            "where specialist_relation_code='"+relationDoBefore.getId()+"'";
                    jdbcTemplate.execute(sql);
                }

+ 45 - 63
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/WlyyRehabilitationManageService.java

@ -15,6 +15,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorPatientDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorPatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.doctor.Frequency;
@ -61,21 +62,14 @@ import java.util.*;
public class WlyyRehabilitationManageService{
    private Logger logger = LoggerFactory.getLogger(RehabilitationManageService.class);
    private static String URL = "health:blank:url";
    @Value("${specialist.url}")
    private String specialistUrl;
    @Value("${demo.flag}")
    private Boolean demoFlag;
    @Autowired
    private ObjectMapper objectMapper;
    @Value("${im.data_base_name}")
    private String imDBName;
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Autowired
    private RehabilitationInfoService rehabilitationInfoService;
    @Value("${wechat.appId}")
    private String appId;
    @Autowired
    private FastDFSUtil fastDFSUtil;
    @Value("${fastDFS.fastdfs_file_url}")
@ -139,28 +133,28 @@ public class WlyyRehabilitationManageService{
//        BaseDoctorDO doctorObj = doctorDao.findByIdAndDel(doctor);
        List<Map<String, Object>> result = new ArrayList<>();
        String sqlCount = "SELECT count(distinct pr.id) total,count(distinct pr.id,IF(pr.is_manage=1,pr.is_manage,null) ) 'manageTotal' FROM" +
                " wlyy_doctor doc,`wlyy_specialist_patient_relation` pr" +
                " LEFT JOIN wlyy_patient p ON p.`code` = pr.patient ";
        String sql = "SELECT DISTINCT pr.id,p.`name`, p.`code`, p.idcard,p.photo, YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) as age," +
                " base_doctor doc,`wlyy_specialist_patient_relation` pr" +
                " LEFT JOIN base_patient p ON p.id = pr.patient ";
        String sql = "SELECT DISTINCT pr.id,p.`name`, p.id, p.idcard,p.photo, YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) as age," +
                "p.sex,pr.doctor AS specialist,pr.doctor_name AS specialistName,doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,pr.disease_code,sf.doctor_name ," +
                "sf.doctor, sf.doctor_health, sf.doctor_health_name, sf.hospital, sf.hospital_name,pr.is_manage,pr.manage_user,pr.manage_time FROM" +
                " wlyy_doctor doc,`wlyy_specialist_patient_relation` pr" +
                " LEFT JOIN wlyy_patient p ON p.`code` = pr.patient ";
                "sf.doctor, sf.hospital, sf.hospital_name,pr.is_manage,pr.manage_user,pr.manage_time FROM" +
                " base_doctor doc,`wlyy_specialist_patient_relation` pr" +
                " LEFT JOIN base_patient p ON p.id = pr.patient ";
        //关联居民计划表
        if("1".equals(filterPlan)){
            sql = sql + " INNER JOIN `wlyy_patient_rehabilitation_plan` plan on plan.patient = pr.patient ";
            sqlCount = sqlCount + " INNER JOIN `wlyy_patient_rehabilitation_plan` plan on plan.patient = pr.patient ";
        }
        sql =sql+  " LEFT JOIN wlyy_sign_family sf ON sf.patient=pr.patient AND sf.`status`=1 AND sf.type =2"  +
                " WHERE  doc.`code` = pr.doctor AND pr.sign_status > 0 AND pr.`status` = 1 ";
                " WHERE  doc.id = pr.doctor AND pr.sign_status > 0 AND pr.`status` = 1 ";
        sqlCount = sqlCount+  " LEFT JOIN wlyy_sign_family sf ON sf.patient=pr.patient AND sf.`status`=1 AND sf.type =2"  +
                " WHERE  doc.`code` = pr.doctor AND pr.sign_status > 0 AND pr.`status` = 1 ";
                " WHERE  doc.id = pr.doctor AND pr.sign_status > 0 AND pr.`status` = 1 ";
        String sqlCondition = "";
        if (doctorType.equalsIgnoreCase("1")){
            sqlCondition +=" AND pr.doctor = '"+doctor+"'";
        }else {
            sqlCondition +=" AND (sf.doctor = '"+doctor+"' or sf.doctor_health = '"+doctor+"')";
            sqlCondition +=" AND sf.doctor = '"+doctor+"' ";
        }
        if(StringUtils.isNoneBlank(patientInfo)){
@ -241,25 +235,25 @@ public class WlyyRehabilitationManageService{
        //家医端未下转(签约居民,但是还未下转的居民) 专科医生端未下转(与未下转列表同-去除未家签)
        if (doctorType.equalsIgnoreCase("1")){//专科
            sql = "select null as id,p.`name`,p.`code`,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
                    "doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,s.doctor_name,s.doctor,s.doctor_health,s.doctor_health_name, s.hospital,s.hospital_name,null as is_manage,null as manage_user,null as manage_time \n" +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p  " +
            sql = "select null as id,p.`name`,p.id,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
                    "doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,s.doctor_name,s.doctor, s.hospital,s.hospital_name,null as is_manage,null as manage_user,null as manage_time \n" +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,base_patient p  " +
                    "WHERE i.create_user='"+doctor+"' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    " ,wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND d.create_user='"+doctor+"' ";
                    " ,wlyy_sign_family s,base_patient p ,base_doctor doc where doc.id = d.create_user AND d.create_user='"+doctor+"' ";
            sqlCount = "select count(distinct d.patient) " +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p  " +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,base_patient p  " +
                    "WHERE i.create_user='"+doctor+"' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    " ,wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND d.create_user='"+doctor+"' ";
                    " ,wlyy_sign_family s,base_patient p ,base_doctor doc where doc.id = d.create_user AND d.create_user='"+doctor+"' ";
        }else{//家庭
            sql = "select null as id,p.`name`,p.`code`,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
                    "doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,s.doctor_name,s.doctor,s.doctor_health,s.doctor_health_name, s.hospital,s.hospital_name,null as is_manage,null as manage_user,null as manage_time \n" +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p " +
            sql = "select null as id,p.`name`,p.id,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
                    "doc.hospital AS specialHospital,doc.hospital_name AS specialHospitalName,s.doctor_name,s.doctor, s.hospital,s.hospital_name,null as is_manage,null as manage_user,null as manage_time \n" +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,base_patient p " +
                    "WHERE s.doctor='"+doctor+"' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    ",wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND s.doctor='"+doctor+"' ";
                    ",wlyy_sign_family s,base_patient p ,base_doctor doc where doc.id = d.create_user AND s.doctor='"+doctor+"' ";
            sqlCount = "select count(distinct d.patient) " +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,wlyy_patient p " +
                    "from wlyy_patient_discharge d LEFT JOIN ( SELECT distinct i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_sign_family s,base_patient p " +
                    "WHERE s.doctor='"+doctor+"' AND i. STATUS != 0 AND i.patient = s.patient AND p. CODE = i.patient AND s. STATUS = 1 AND s.type =2 AND s.expenses_status = 1 )A on d.patient =A.patient " +
                    ",wlyy_sign_family s,wlyy_patient p ,wlyy_doctor doc where doc.`code` = d.create_user AND s.doctor='"+doctor+"' ";
                    ",wlyy_sign_family s,base_patient p ,base_doctor doc where doc.id = d.create_user AND s.doctor='"+doctor+"' ";
        }
        sqlCondition="";
@ -402,15 +396,11 @@ public class WlyyRehabilitationManageService{
                return query;
            }
        }
        String sql = "SELECT pmrr.* FROM wlyy.wlyy_patient_medical_records_rehabilitation pmrr WHERE pmrr.patient = '"+patient+"' and (data_from=3 or  data_from=4) GROUP BY id DESC LIMIT 0,1";//find_in_set('"+diseaseCode+"',disease)
        String sql = "SELECT pmrr.* FROM wlyy_patient_medical_records_rehabilitation pmrr WHERE pmrr.patient = '"+patient+"' and (data_from=3 or  data_from=4) GROUP BY id DESC LIMIT 0,1";//find_in_set('"+diseaseCode+"',disease)
        query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(PatientMedicalRecordsDO.class));
        return query;
    }
    public void deleteMedicalRecordsRehabilitation(int id){
        medicalRecordsRehabilitationDao.deleteById((long) id);
    }
    public List<Map<String,Object>> selectByGuidance(String planId,String itemCode){
        String sql ="SELECT gm.* FROM wlyy_guidance_message_log gm LEFT JOIN wlyy_rehabilitation_plan_detail pd ON pd.id = gm.plan_detail_id " +
                "WHERE pd.plan_id = '"+planId+"' AND pd.hospital_service_item_id = '"+itemCode+"' ORDER BY gm.create_time DESC ";
@ -528,7 +518,7 @@ public class WlyyRehabilitationManageService{
              if (map.get("code").toString().equalsIgnoreCase("7")){
                  String allPrescrSql = "SELECT p.`name`, TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, p.sex, p.photo, pr.`status`, pr.`code`, \n" +
                          "LEFT(pr.create_time,19) AS createTime, pr.doctor, pr.min_drug_day AS minDrugDay, LEFT(pr.pres_create_time,19) AS presCreateTime \n" +
                          "FROM wlyy_prescription pr LEFT JOIN wlyy_patient p ON pr.patient = p.`code` WHERE 1=1 AND pr.patient = '"+map.get("patient")+"' AND pr.status = 100 GROUP BY pr.`code`;";
                          "FROM wlyy_prescription pr LEFT JOIN base_patient p ON pr.patient = p.id WHERE 1=1 AND pr.patient = '"+map.get("patient")+"' AND pr.status = 100 GROUP BY pr.`code`;";
                  List<Map<String , Object>> allPrescrList = jdbcTemplate.queryForList(allPrescrSql);
                  count = allPrescrList.size();
              }
@ -559,7 +549,7 @@ public class WlyyRehabilitationManageService{
                  //居民的处方续方,需要同步展示到康复计划-康复复诊内
                  String allPrescrSql = "SELECT p.`name`, TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, p.sex, p.photo, pr.`status`, pr.`code`, \n" +
                          "LEFT(pr.create_time,19) AS createTime, pr.doctor, pr.min_drug_day AS minDrugDay, LEFT(pr.pres_create_time,19) AS presCreateTime \n" +
                          "FROM wlyy_prescription pr LEFT JOIN wlyy_patient p ON pr.patient = p.`code` WHERE 1=1 AND pr.patient = '"+map.get("patient")+"' AND pr.status = 100 GROUP BY pr.`code`;";
                          "FROM wlyy_prescription pr LEFT JOIN base_patient p ON pr.patient = p.id WHERE 1=1 AND pr.patient = '"+map.get("patient")+"' AND pr.status = 100 GROUP BY pr.`code`;";
                  List<Map<String , Object>> allPrescrList = jdbcTemplate.queryForList(allPrescrSql);
                  codeCount = allPrescrList.size();
                  map.put("allPrescrList",allPrescrList);
@ -726,7 +716,7 @@ public class WlyyRehabilitationManageService{
                " wlyy_rehabilitation_operate_records r " +
                "LEFT JOIN wlyy_rehabilitation_plan_detail pd ON r.rehabilitation_detail_id = pd.id " +
                "LEFT JOIN wlyy_rehabilitation_service_item si ON si.code= pd.hospital_service_item_id " +
                "LEFT JOIN wlyy_doctor d ON d.`code` = r.doctor_code " +
                "LEFT JOIN base_doctor d ON d.`code` = r.doctor_code " +
                "WHERE " +
                " pd.plan_id = '"+planId+"' " +
                " AND pd.hospital_service_item_id = '"+code+"' ";
@ -736,7 +726,7 @@ public class WlyyRehabilitationManageService{
                "\twlyy_rehabilitation_operate_records r\n" +
                "LEFT JOIN wlyy_rehabilitation_plan_detail pd ON r.rehabilitation_detail_id = pd.id\n" +
                "LEFT JOIN wlyy_rehabilitation_service_item si ON si.code= pd.hospital_service_item_id\n" +
                "LEFT JOIN wlyy_doctor d ON d.`code` = r.doctor_code\n" +
                "LEFT JOIN base_doctor d ON d.`code` = r.doctor_code\n" +
                "WHERE\n" +
                "\t pd.plan_id = '"+planId+"'\n" +
                "\t\tAND pd.hospital_service_item_id = '"+code+"'\n";
@ -781,12 +771,12 @@ public class WlyyRehabilitationManageService{
                        " p.`name`, '' AS code,'' AS plan_id,pr.`code` AS id ,'' AS relationCode," +
                        " '' AS flag,3 AS flagType " +
                        "FROM  wlyy_prescription pr" +
                        " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` WHERE" +
                        " LEFT JOIN base_patient p ON pr.patient = p.id WHERE" +
                        " 1 = 1 AND pr.patient = '"+patient+"' AND pr.STATUS = '100'GROUP BY  pr.CODE ";
                sqlCount +="UNION SELECT " +
                        "count(DISTINCT pr.id)total FROM wlyy_prescription pr" +
                        " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` WHERE 1 = 1 " +
                        " LEFT JOIN base_patient p ON pr.patient = p.id WHERE 1 = 1 " +
                        "AND pr.patient = '"+patient+"' AND pr.STATUS = '100' ) total";
            }else {
                sqlCount +=" ) total";
@ -860,7 +850,7 @@ public class WlyyRehabilitationManageService{
        String sql = "select d.code as doctor,p.create_time as createTime,p.id,d.photo,p.title,d.idcard,YEAR (now()) - YEAR (substring(d.idcard, 7, 8)) AS age, d.sex,p.name,p.patient,d.name as doctorName,d.dept_name as deptName,hospital_name as hospitalName,p.advice_content as adviceContent,p.medical_records_code as medicalRecordsCode,p.create_time as create_time " +
                " FROM wlyy_patient_rehabilitation_plan p " +
                " LEFT JOIN wlyy_doctor d ON d.code = p.create_user " +
                " LEFT JOIN base_doctor d ON d.code = p.create_user " +
                "WHERE p.patient='"+patient+"'";
        if (status!=null){
            sql +=" and p.status ="+status;
@ -890,7 +880,7 @@ public class WlyyRehabilitationManageService{
                "p.create_time AS create_time " +
                "FROM " +
                "wlyy_patient_rehabilitation_plan p " +
                "LEFT JOIN wlyy_doctor d ON d.CODE=p.create_user" +
                "LEFT JOIN base_doctor d ON d.CODE=p.create_user" +
                " LEFT JOIN (" +
                "SELECT sr.patient AS patient,sr.team_code AS team_code " +
                "FROM wlyy_specialist_patient_relation sr " +
@ -915,7 +905,7 @@ public class WlyyRehabilitationManageService{
    public List<Map<String,Object>> getPatientAllRehabilitationPlan(String patient,String doctor){
        String sql = "select p.team_code as teamCode,d.code as doctor,p.create_time as createTime,p.id,d.photo,p.title,d.idcard,YEAR (now()) - YEAR (substring(d.idcard, 7, 8)) AS age, d.sex,p.name,p.patient,p.disease,p.disease_name,d.name as doctorName,d.dept_name as deptName,hospital_name as hospitalName,p.advice_content as adviceContent,p.medical_records_code as medicalRecordsCode,p.create_time as create_time " +
                " FROM wlyy_patient_rehabilitation_plan p " +
                " LEFT JOIN wlyy_doctor d ON d.code = p.create_user " +
                " LEFT JOIN base_doctor d ON d.code = p.create_user " +
                "WHERE p.patient='"+patient+"'";
        sql = sql +" union "+
                "SELECT p.team_code as teamCode,d.CODE AS doctor," +
@ -935,7 +925,7 @@ public class WlyyRehabilitationManageService{
                "p.create_time AS create_time " +
                "FROM " +
                "wlyy_patient_rehabilitation_plan p " +
                "LEFT JOIN wlyy_doctor d ON d.CODE=p.create_user" +
                "LEFT JOIN base_doctor d ON d.CODE=p.create_user" +
                " LEFT JOIN (" +
                "SELECT sr.patient AS patient,sr.team_code AS team_code " +
                "FROM wlyy_specialist_patient_relation sr " +
@ -1002,13 +992,13 @@ public class WlyyRehabilitationManageService{
        String sql ="select A.id 'planId',pdl.id,pdl.frequency_code,A.patient,A.`name`,si.id 'code',si.`name` 'serviceName',opr.complete_time 'czrq' from  \n" +
                "(select p.team_code as teamCode,d.code as doctor,p.create_time as createTime,p.id,p.patient,p.name " +
                "from wlyy_patient_rehabilitation_plan p\n" +
                "LEFT JOIN wlyy_doctor d ON d.code = p.create_user\n" +
                "LEFT JOIN base_doctor d ON d.code = p.create_user\n" +
                "WHERE p.patient='"+patient+"'\n" +
                "union\n" +
                "SELECT p.team_code as teamCode,d.CODE AS doctor,p.create_time AS createTime,p.id,p.patient,p.name " +
                "from \n" +
                "wlyy_patient_rehabilitation_plan p\n" +
                "LEFT JOIN wlyy_doctor d ON d.CODE=p.create_user\n" +
                "LEFT JOIN base_doctor d ON d.CODE=p.create_user\n" +
                "LEFT JOIN (\n" +
                "SELECT sr.patient AS patient,sr.team_code AS team_code \n" +
                "FROM wlyy_specialist_patient_relation sr \n" +
@ -1107,7 +1097,7 @@ public class WlyyRehabilitationManageService{
    public List<Map<String,Object>> getPatientInfo(String planId,String patient){
        String sql = "SELECT pr.id,d.code, d. NAME AS doctorName, d.hospital_name AS hospitalName,pr.health_status_code,pr.disease_code FROM wlyy_patient_rehabilitation_plan p " +
                " LEFT JOIN wlyy_specialist_patient_relation pr ON  pr.doctor = p.create_user and pr.patient = p.patient" +
                " LEFT JOIN wlyy_doctor d ON d.code = p.create_user WHERE p.id='"+planId+"' and p.patient='"+patient+"' ";
                " LEFT JOIN base_doctor d ON d.code = p.create_user WHERE p.id='"+planId+"' and p.patient='"+patient+"' ";
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        for(Map<String,Object> map:mapList){
            String doctor = map.get("code").toString();
@ -1156,9 +1146,10 @@ public class WlyyRehabilitationManageService{
     */
    public String createSpecialDoctorQrCode(String doctorCode,String teamCode,String teamName) throws Exception{
        Map<String, Object> param = new HashedMap();
        WxWechatDO wxWechatDO = wxMessageUtil.getWxWechat();
        String fileUrl = "";
        //生成二维码图片
        String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wechat_base_url+"%2fwx%2fhtml%2fkfgl%2fhtml%2frecover_manage.html%3FdoctorCode%3D"+doctorCode+"%26teamCode%3D"+teamCode+"%26teamName%3D"+teamName+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
        String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+wxWechatDO.getAppId()+"&redirect_uri="+wxWechatDO.getBaseUrl()+"%2fwx%2fhtml%2fkfgl%2fhtml%2frecover_manage.html%3FdoctorCode%3D"+doctorCode+"%26teamCode%3D"+teamCode+"%26teamName%3D"+teamName+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
        InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
            // 圖片列表
        List<String> tempPaths = new ArrayList<String>();
@ -1194,7 +1185,8 @@ public class WlyyRehabilitationManageService{
        }
        if (StringUtils.isEmpty(fileUrl) || "null".equals(fileUrl)){
            //生成二维码图片
            String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wechat_base_url+"/wx/html/kfgl/html/confirm-service.html"+"?paramStr="+planDetailId+","+doctorCode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
            WxWechatDO wxWechatDO = wxMessageUtil.getWxWechat();
            String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+wxWechatDO.getAppId()+"&redirect_uri="+wxWechatDO.getBaseUrl()+"/wx/html/kfgl/html/confirm-service.html"+"?paramStr="+planDetailId+","+doctorCode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
            InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
            // 圖片列表
            List<String> tempPaths = new ArrayList<String>();
@ -1397,7 +1389,7 @@ public class WlyyRehabilitationManageService{
    public List<PatientRehabilitationPlanDO> getRehabilitationPlanList(String patient, String diseaseCode){
        String sql = "SELECT rp.*,d.hospital,d.hospital_name FROM wlyy_patient_rehabilitation_plan rp,wlyy_doctor d  WHERE patient = '"+patient+"' \n" +
        String sql = "SELECT rp.*,d.hospital,d.hospital_name FROM wlyy_patient_rehabilitation_plan rp,base_doctor d  WHERE patient = '"+patient+"' \n" +
                "AND find_in_set('"+diseaseCode+"',disease) AND rp.create_user=d.`code` ORDER BY create_time DESC ";//DESC LIMIT 0,10
        return  jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(PatientRehabilitationPlanDO.class));
    }
@ -1729,7 +1721,7 @@ public class WlyyRehabilitationManageService{
        }
        
        //获取医院医生数量
        String hospitalDoctorCountSql = "SELECT count(d.id) AS total FROM wlyy_hospital_specialist h,wlyy_doctor d WHERE h.hospital=d.hospital AND h.code = '"+diseaseType+"'";
        String hospitalDoctorCountSql = "SELECT count(d.id) AS total FROM wlyy_hospital_specialist h,base_doctor d WHERE h.hospital=d.hospital AND h.code = '"+diseaseType+"'";
        List<Map<String,Object>> hospitalDoctorList = jdbcTemplate.queryForList(hospitalDoctorCountSql);
        if (hospitalDoctorList!=null && hospitalDoctorList.size()!=0){
            result.put("doctorCount",hospitalDoctorList.get(0).get("total"));
@ -1869,25 +1861,15 @@ public class WlyyRehabilitationManageService{
        JSONObject result = new JSONObject();
        //专科列表
        String sql = "SELECT DISTINCT p.patient, p.name AS patient_name, d.`code` as special_code, d.`name` as special_name, d.photo,d.dept_name,d.hospital_name \n" +
                "FROM wlyy_patient_rehabilitation_plan p, wlyy_doctor d\n" +
                "FROM wlyy_patient_rehabilitation_plan p, base_doctor d\n" +
                "WHERE p.patient = '"+patientCode+"' AND d.`code`= p.create_user GROUP BY p.patient, p.create_user";
        List<Map<String,Object>> specialList = jdbcTemplate.queryForList(sql);
        result.put("specialList",specialList);
        //全科 健康管理师列表
        sql  ="select s.patient,s.`name`,s.doctor,doc.photo as doctor_photo,s.doctor_name,s.doctor_health,s.doctor_health_name \n" +
                "\t\tfrom wlyy_sign_family s ,wlyy_doctor doc\n" +
        sql  ="select s.patient,s.`name`,s.doctor,doc.photo as doctor_photo,s.doctor_name " +
                "\t\tfrom wlyy_sign_family s ,base_doctor doc\n" +
                "\t\twhere s.patient ='"+patientCode+"' and doc.`code` =s.doctor and s.type=2 and s.`status`=1;";
        Map<String,Object> doctor = jdbcTemplate.queryForMap(sql);
        String doctor_health = doctor.get("doctor_health")==null?"":doctor.get("doctor_health").toString();
        if(StringUtils.isBlank(doctor_health)){
            doctor.put("health_photo","");
            doctor.put("doctor_health","");
        }
        else{
            sql = "select photo from wlyy_doctor where `code`='"+doctor_health+"'";
            String health_photo = jdbcTemplate.queryForObject(sql,String.class);
            doctor.put("health_photo",health_photo);
        }
        result.put("doctor",doctor);
        return  result;
    }

+ 3 - 3
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/service/rehabilitation/WlyyRehabilitationPlanService.java

@ -122,7 +122,7 @@ public class WlyyRehabilitationPlanService {
        String user = templateDO.getCreateUser();
        String userName = templateDO.getCreateUserName();
        //默认新增服务项
        String sql = "SELECT code from wlyy.system_dict WHERE `dict_name` = 'default_service_item_id'";
        String sql = "SELECT code from system_dict WHERE `dict_name` = 'default_service_item_id'";
        List<String> list = jdbcTemplate.queryForList(sql,String.class);
        if(list!=null&&list.size()>0){
            list.stream().forEach(code->{
@ -693,7 +693,7 @@ public class WlyyRehabilitationPlanService {
        String updateTime = DateUtil.dateToStrLong(details.get(0).getCreateTime());
        //康复计划修改 日志添加
        String sql ="INSERT INTO wlyy_specialist.wlyy_patient_rehabilitation_plan_log(id,plan_id,create_user,create_user_name,create_time) " +
        String sql ="INSERT INTO wlyy_patient_rehabilitation_plan_log(id,plan_id,create_user,create_user_name,create_time) " +
                "VALUES('"+ CommonUtil.getCode()+"','"+planId+"','"+doctor.getId()+"','"+ doctor.getName()+"','"+updateTime+"')";
        jdbcTemplate.execute(sql);
@ -706,7 +706,7 @@ public class WlyyRehabilitationPlanService {
     * @return
     */
    public List<Map<String,Object>> getRehabilitationPlanLog(String planId){
        String sql ="select * from wlyy_specialist.wlyy_patient_rehabilitation_plan_log where plan_id = '"+planId+"' ORDER BY create_time DESC";
        String sql ="select * from wlyy_patient_rehabilitation_plan_log where plan_id = '"+planId+"' ORDER BY create_time DESC";
        List<Map<String,Object>> planLogList = jdbcTemplate.queryForList(sql);
        return planLogList;
    }

+ 11 - 0
svr/svr-after-diagnosis/src/mian/resources/application.yml

@ -1429,3 +1429,14 @@ express:
  sf_code: HD000001
  sf_check_word: AAAABBBBCCCCDDDD
#消息队列
activemq:
  username: admin
  password: admin
  url: tcp://172.19.103.87:61616
  queue:
    #    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送
    #    deviceMeasurementRemindingQueue : deviceMeasurementChannel_dev #设备测量提醒
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
    birthdayWishesQueue: birthdayWishesChannel_test  #生日祝福推送