浏览代码

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

wangzhinan 4 年之前
父节点
当前提交
b20b045b05
共有 26 个文件被更改,包括 569 次插入66 次删除
  1. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  2. 29 7
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TnPrescriptionService.java
  3. 10 9
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java
  4. 2 2
      business/base-service/src/main/java/com/yihu/jw/utils/hibernate/HibenateUtils.java
  5. 10 6
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  6. 5 0
      common/common-entity-es/pom.xml
  7. 25 1
      common/common-entity/sql记录
  8. 104 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupDrugs.java
  9. 18 1
      svr/svr-door-serivce/sql/初始sql.sql
  10. 2 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/followup/DoctorFollowUpController.java
  11. 64 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/followup/DoctorFollowupDrugsController.java
  12. 5 2
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/followup/FollowUpDao.java
  13. 22 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/followup/FollowupDrugsDao.java
  14. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java
  15. 46 5
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/followup/FollowUpService.java
  16. 80 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/followup/FollowupDrugsService.java
  17. 2 2
      svr/svr-door-serivce/src/main/resources/application.yml
  18. 45 24
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java
  19. 1 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  20. 2 2
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/OverdueJob.java
  21. 7 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  22. 15 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java
  23. 3 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java
  24. 3 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java
  25. 3 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java
  26. 62 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java

@ -82,6 +82,9 @@ public class PatientMappingService {
    public String findYkyyPatNoByPatient(String patient,boolean demoFlag)throws Exception{
        logger.info("findYkyyPatNoByPatient:"+patient);
        BasePatientDO patientDO = basePatientDao.findById(patient);
        if(patientDO == null){
            return patient;
        }
        logger.info("patientDO:"+patientDO.toString());
        PatientMappingDO patientMappingDO = patientMappingDao.findByIdcardAndSource(patientDO.getIdcard(),"1");
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");

+ 29 - 7
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TnPrescriptionService.java

@ -34,6 +34,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.mysql.query.BaseJpaService;
@ -186,12 +187,31 @@ public class TnPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pr
     *
     */
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn, String patient, String realOrder, String admNo, boolean demoFlag)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient,null);
        if(StringUtils.isBlank(patNo)){
            return null;
        String patNo = "";
        if (!StringUtil.isEmpty(patient)){
            PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
            if (patientMappingDO!=null){
                patNo = patientMappingDO.getMappingCode();
            }else {
                BasePatientDO basePatientDO = basePatientDao.findById(patient);
                if (basePatientDO!=null){
                    JSONArray res = tnyyEntranceService.selectPatientMappingCode(basePatientDO.getIdcard());
                    if (res!=null&&res.size()!=0){
                        JSONObject object = res.getJSONObject(0);
                        patNo = object.getString("BRID");
                        patientMappingDO= new PatientMappingDO();
                        patientMappingDO.setPatientName(basePatientDO.getName());
                        patientMappingDO.setPatient(patient);
                        patientMappingDO.setMappingCode(patNo);
                        patientMappingDO.setSource("1");
                        patientMappingDO.setIdcard(basePatientDO.getIdcard());
                        patientMappingDao.save(patientMappingDO);
                    }
                }
            }
        }
        //BS16017(String REGISTER_SN,String realOrder,String PAT_NO,String ADM_NO,boolean demoFlag) throws Exception {
        logger.info("findOriginPrescriptionList: registerSn:"+registerSn+" patient"+patient+" patNo:"+patNo+" realOrder:"+realOrder+" admNo:"+admNo);
        logger.info("findOriginPrescriptionList: registerSn:"+registerSn+" patient"+patient+" realOrder:"+realOrder+" admNo:"+admNo);
        return tnyyEntranceService.findMS_CF01And02(admNo,demoFlag);
    }
@ -212,9 +232,11 @@ public class TnPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pr
        if (wlyyOutpatientVOS!=null&&wlyyOutpatientVOS.size()!=0){
            WlyyOutpatientVO outpatientVO = wlyyOutpatientVOS.get(0);
            BasePatientDO patientDO = basePatientDao.findById(patient);
            outpatientVO.setSex(patientDO.getSex()+"");
            outpatientVO.setBirthday(patientDO.getBirthday());
            outpatientVO.setIdcard(patientDO.getIdcard());
            if (patientDO!=null){
                outpatientVO.setSex(patientDO.getSex()+"");
                outpatientVO.setBirthday(patientDO.getBirthday());
                outpatientVO.setIdcard(patientDO.getIdcard());
            }
            return outpatientVO;
        }
       return null;

+ 10 - 9
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java

@ -408,7 +408,8 @@ public class TnyyEntranceService {
     * @throws Exception
     */
    public JSONArray findV_ZKSG_HZCX_HIS(String brid,String conNo,String startTime,String endTime,String ksdm) throws Exception{
        String sql = "SELECT h.JZXH,h.GHXH,h.BRBH,h.KSDM,h.YSDM,h.ZYZD,h.KSSJ,h.JSSJ,h.JZZT,h.FZRQ,h.GHFZ,ks.KSMC,yg.YGXM  from YS_MZ_JZLS h,GY_KSDM ks,GY_YGDM yg WHERE yg.YGDM=h.YSDM and ks.KSDM=h.KSDM and  h.BRBH = "+brid+" ";
        String sql = "SELECT h.JZXH,h.GHXH,h.BRBH,h.KSDM,h.YSDM,zd.JBMC as ZYZD,h.KSSJ,h.JSSJ,h.JZZT,h.FZRQ,h.GHFZ,ks.KSMC,yg.YGXM  from YS_MZ_JZLS h,GY_KSDM ks,GY_YGDM yg " +
                " ,GY_JBBM zd  WHERE yg.YGDM=h.YSDM and ks.KSDM=h.KSDM and h.ZYZD = zd.JBXH and  h.BRBH = "+brid+" ";
        if(!StringUtil.isBlank(conNo)){
            sql += " and h.JZXH = " + conNo;
        }
@ -455,19 +456,17 @@ public class TnyyEntranceService {
        logger.info("EntranceService " + fid + " PAT_NO :" + PAT_NO + " conNo:" + conNo + " startTime:" + startTime + " endTime:" + endTime);
        String resp = "";
        String orgCode = "350211A5004";
        String orgName = "厦门大学附属厦门眼科中心";
        String orgCode = "350211A1002";
        String orgName = "泰安市中医医院";
        //居民id转化
        PatientMappingDO patientMappingDO = patientMappingDao.findByMappingCodeAndSource(PAT_NO,"1");
        if(patientMappingDO == null){
            return null;
        }
//KSSJ,h.BRID,h.BRXM,h.SJHM,h.JZKH,h.SFZH,h.BRXZ,h.YSDM,h.KDYS" +
//                ",h.KSDM,h.KSMC,h.ZDMC,h.JZXH
        JSONArray jsonArray = new JSONArray();
        jsonArray = findV_ZKSG_HZCX_HIS(patientMappingDO.getMappingCode(),conNo,startTime,endTime,ksdm);
        jsonArray = findV_ZKSG_HZCX_HIS(PAT_NO,conNo,startTime,endTime,ksdm);
        //查找眼科数据
        if (jsonArray.size() == 0) {
            return null;
@ -485,8 +484,10 @@ public class TnyyEntranceService {
                //wlyyOutpatientVO.setRegisterNo(null == jsonObjectMgsInfo.get("REGISTER_SN") ? "" : jsonObjectMgsInfo.get("REGISTER_SN") + "");
                wlyyOutpatientVO.setDept(null == jsonObjectMgsInfo.get("KSDM") ? "" : jsonObjectMgsInfo.get("KSDM") + "");
                wlyyOutpatientVO.setDeptName(null == jsonObjectMgsInfo.get("KSMC") ? "" : jsonObjectMgsInfo.get("KSMC") + "");
                wlyyOutpatientVO.setPatient(patientMappingDO.getPatient());
                wlyyOutpatientVO.setPatientName(patientMappingDO.getPatientName());
                if (patientMappingDO!=null){
                    wlyyOutpatientVO.setPatient(patientMappingDO.getPatient());
                    wlyyOutpatientVO.setPatientName(patientMappingDO.getPatientName());
                }
                wlyyOutpatientVO.setConNo(null == jsonObjectMgsInfo.get("JZXH") ? "" : jsonObjectMgsInfo.get("JZXH") + "");
                String doctor = null == jsonObjectMgsInfo.get("YSDM") ? "" : jsonObjectMgsInfo.get("YSDM") + "";

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/utils/hibernate/HibenateUtils.java

@ -47,7 +47,7 @@ public class HibenateUtils {
        SQLQuery query = session.createSQLQuery(sql);
        query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
        if(page!=null&&size!=null){
            query.setFirstResult(page * size);
            query.setFirstResult((page - 1) * size);
            query.setMaxResults(size);
        }
        List<Map<String, Object>> list = query.list();
@ -89,7 +89,7 @@ public class HibenateUtils {
        setSqlQueryByMap(query, params);
        if(page!=null&&size!=null){
            query.setFirstResult(page * size);
            query.setFirstResult((page-1) * size);
            query.setMaxResults(size);
        }
        List<Map<String, Object>> list = query.list();

+ 10 - 6
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -2273,9 +2273,9 @@ public class ImService {
			WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionVO.getOutpatientId());
			if (wlyyOutpatientDO.getOutpatientType()!=null){
				if (wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("1")&&wlyyOutpatientDO.getType().equalsIgnoreCase("1")){
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyPrescriptionVO.getPatientCode()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_9", "24", JSON.toJSONString(wlyyPrescriptionDiagnosisVOS),"1",null);
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyOutpatientDO.getConsumer()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_9", "24", JSON.toJSONString(wlyyPrescriptionDiagnosisVOS),"1",null);
				}else if (wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("1")&&wlyyOutpatientDO.getType().equalsIgnoreCase("2")){
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyPrescriptionVO.getPatientCode()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_16", "24", JSON.toJSONString(wlyyPrescriptionDiagnosisVOS),"1",null);
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyOutpatientDO.getConsumer()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_16", "24", JSON.toJSONString(wlyyPrescriptionDiagnosisVOS),"1",null);
				}
			}
		}
@ -2291,9 +2291,9 @@ public class ImService {
			WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionVO.getOutpatientId());
			if (wlyyOutpatientDO.getOutpatientType()!=null){
				if (wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("1")&&wlyyOutpatientDO.getType().equalsIgnoreCase("1")){
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyPrescriptionVO.getPatientCode()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_9", "27", JSON.toJSONString(object),"1",null);
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyOutpatientDO.getConsumer()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_9", "27", JSON.toJSONString(object),"1",null);
				}else if (wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("1")&&wlyyOutpatientDO.getType().equalsIgnoreCase("2")){
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyPrescriptionVO.getPatientCode()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_16", "27", JSON.toJSONString(object),"1",null);
					String response = imUtil.sendImMsg(wlyyPrescriptionVO.getDoctor(), wlyyPrescriptionVO.getDoctorName(), wlyyOutpatientDO.getConsumer()+"_"+wlyyPrescriptionVO.getOutpatientId()+"_16", "27", JSON.toJSONString(object),"1",null);
				}
			}
		}
@ -2347,9 +2347,13 @@ public class ImService {
	 * @return
	 * @throws Exception
	 */
	public String pushPrescriptionBackMsg(com.alibaba.fastjson.JSONObject jsonObject,String doctor,String doctorName,String outpatientId,String patient,String outpatientType) throws Exception {
	public String pushPrescriptionBackMsg(com.alibaba.fastjson.JSONObject jsonObject,String doctor,String doctorName,String outpatientId,String patient,String outpatientType,String type) throws Exception {
		if("1".equals(outpatientType)){
			return imUtil.sendImMsg(doctor, doctorName, patient+"_"+outpatientId+"_9", "33",jsonObject.toString(),"1",null);
			if ("1".equalsIgnoreCase(type)){
				return imUtil.sendImMsg(doctor, doctorName, patient+"_"+outpatientId+"_9", "33",jsonObject.toString(),"1",null);
			}else {
				return imUtil.sendImMsg(doctor, doctorName, patient+"_"+outpatientId+"_16", "33",jsonObject.toString(),"1",null);
			}
		}else if("2".equals(outpatientType)){
			return imUtil.sendImMsg(doctor, doctorName, patient+"_"+outpatientId+"_12", "33",jsonObject.toString(),"1",null);
		}else{

+ 5 - 0
common/common-entity-es/pom.xml

@ -38,5 +38,10 @@
            <artifactId>jest-common</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.1.0</version>
        </dependency>
    </dependencies>
</project>

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

@ -1,3 +1,4 @@
-- 2021-01-11 ysj 新增随访相关
DROP TABLE IF EXISTS `wlyy_followup`;
CREATE TABLE `wlyy_followup` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
@ -45,4 +46,27 @@ CREATE TABLE `wlyy_followup` (
  KEY `idx_prescription_code` (`prescription_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1889415 DEFAULT CHARSET=utf8mb4 COMMENT='随访计划表';
ALTER TABLE wlyy_door_service_order ADD followup_date varchar(50) COMMENT '随访时间' ;
ALTER TABLE wlyy_door_service_order ADD followup_date varchar(50) COMMENT '随访时间' ;
-------
-- 2021-01-12 ysj 新增随访相关
CREATE TABLE `wlyy_followup_drugs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `followup_id` int(11) DEFAULT NULL COMMENT '随访ID',
  `drugs_code` varchar(50) DEFAULT NULL COMMENT '药品代码',
  `drugs_name` varchar(50) DEFAULT NULL COMMENT '药品名称',
  `drugs_group` varchar(50) DEFAULT NULL COMMENT '药品分组(糖尿病--胰岛特殊处理)',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `dose` varchar(200) DEFAULT NULL COMMENT '次剂量',
  `unit` varchar(50) DEFAULT NULL COMMENT '用药单位【字典MEASURE_UNIT_DICT】',
  `frequency` varchar(50) DEFAULT NULL COMMENT '用药频率【字典RECIPE_FREQUENCY_DICT】',
  PRIMARY KEY (`id`),
  KEY `wlyy_followup_drugs_followup_id_index` (`followup_id`)
) ENGINE=InnoDB AUTO_INCREMENT=436 DEFAULT CHARSET=utf8mb4 COMMENT='随访用药记录';

+ 104 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupDrugs.java

@ -0,0 +1,104 @@
package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
/**
 * 随访用药记录
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup_drugs")
@SequenceGenerator(name="id_generated", sequenceName="wlyy_followup_drugs")
public class FollowupDrugs extends IdEntity {
	//随访ID
	private Long followupId;
	//药品代码
	private String drugsCode;
	//药品名称
	private String drugsName;
	//药品分组(糖尿病--胰岛特殊处理)胰岛素分类insulin,其他药品为normal
	private String drugsGroup;
	//次剂量
	private String dose;
	//用药单位【字典MEASURE_UNIT_DICT】
	private String unit;
	//用药频率【字典RECIPE_FREQUENCY_DICT】
	private String frequency;
	//创建时间
	private Date createTime;
	public Long getFollowupId() {
		return followupId;
	}
	public void setFollowupId(Long followupId) {
		this.followupId = followupId;
	}
	public String getDrugsCode() {
		return drugsCode;
	}
	public void setDrugsCode(String drugsCode) {
		this.drugsCode = drugsCode;
	}
	public String getDrugsName() {
		return drugsName;
	}
	public void setDrugsName(String drugsName) {
		this.drugsName = drugsName;
	}
	public String getDrugsGroup() {
		return drugsGroup;
	}
	public void setDrugsGroup(String drugsGroup) {
		this.drugsGroup = drugsGroup;
	}
	
	public String getDose() {
		return dose;
	}
	
	public void setDose(String dose) {
		this.dose = dose;
	}
	
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public String getFrequency() {
		return frequency;
	}
	public void setFrequency(String frequency) {
		this.frequency = frequency;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 18 - 1
svr/svr-door-serivce/sql/初始sql.sql

@ -750,7 +750,7 @@ DROP TABLE IF EXISTS `wlyy_followup`;
CREATE TABLE `wlyy_followup` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `followup_no` varchar(50) DEFAULT NULL,
  `followup_date` datetime NOT NULL COMMENT '随访时间',
  `followup_date` datetime NULL COMMENT '随访时间',
  `followup_plan_date` datetime DEFAULT NULL COMMENT '计划随访时间',
  `followup_next_date` datetime DEFAULT NULL COMMENT '计划下次随访时间',
  `followup_type` varchar(50) DEFAULT NULL COMMENT '随访方式【字典FOLLOWUP_WAY_DICT】',
@ -793,6 +793,8 @@ CREATE TABLE `wlyy_followup` (
  KEY `idx_prescription_code` (`prescription_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1889415 DEFAULT CHARSET=utf8mb4 COMMENT='随访计划表';
ALTER TABLE wlyy_door_service_order ADD followup_date varchar(50) COMMENT '随访时间' ;
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('29', NULL, 'FOLLOWUP_PROJECT', '1', '1', '症状', NULL, NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('30', NULL, 'FOLLOWUP_PROJECT', '2', '1', '体征', NULL, NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('31', NULL, 'FOLLOWUP_PROJECT', '3', '1', '实验室检查', NULL, NULL);
@ -811,5 +813,20 @@ INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('42', NULL, 'FOLLOWUP_MANAGER_STATUS', '2', '1', '失管', '2', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('43', NULL, 'FOLLOWUP_MANAGER_STATUS', '2', '1', '拒管', '3', NULL);
CREATE TABLE `wlyy_followup_drugs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `followup_id` int(11) DEFAULT NULL COMMENT '随访ID',
  `drugs_code` varchar(50) DEFAULT NULL COMMENT '药品代码',
  `drugs_name` varchar(50) DEFAULT NULL COMMENT '药品名称',
  `drugs_group` varchar(50) DEFAULT NULL COMMENT '药品分组(糖尿病--胰岛特殊处理)',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `dose` varchar(200) DEFAULT NULL COMMENT '次剂量',
  `unit` varchar(50) DEFAULT NULL COMMENT '用药单位【字典MEASURE_UNIT_DICT】',
  `frequency` varchar(50) DEFAULT NULL COMMENT '用药频率【字典RECIPE_FREQUENCY_DICT】',
  PRIMARY KEY (`id`),
  KEY `wlyy_followup_drugs_followup_id_index` (`followup_id`)
) ENGINE=InnoDB AUTO_INCREMENT=436 DEFAULT CHARSET=utf8mb4 COMMENT='随访用药记录';
-- 统计

+ 2 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/followup/DoctorFollowUpController.java

@ -31,6 +31,8 @@ public class DoctorFollowUpController extends BaseController {
    @Autowired
    private DoorOrderService doorOrderService;
    @ApiOperation("暂不需要新增随访")
    @PostMapping(value = "/notAddFollowup")
    public String notAddFollowup(@ApiParam(name = "orderId", value = "订单id", defaultValue = "4")

+ 64 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/followup/DoctorFollowupDrugsController.java

@ -0,0 +1,64 @@
package com.yihu.jw.door.controller.doctor.followup;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.followup.FollowupDrugsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
 * 医生端:随访接口
 * 
 * @author hzp add 2016-12-07
 *
 */
@RestController
@RequestMapping(value = "/doctor/followup/drugs", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访用药接口")
public class DoctorFollowupDrugsController extends BaseController {
	@Autowired
	private FollowupDrugsService followupDrugsService;
	@ApiOperation("获取面访用药数据")
	@RequestMapping(value = "/getFollowupDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	public String getFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									@RequestParam(value="id",required = true) String id)
	{
		try {
			Map<String,Object> response = followupDrugsService.getFollowupDrugs(id);
			return write(200, "获取面访用药数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访用药数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存面访用药数据")
	@RequestMapping(value = "/saveFollowupDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	public String saveFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
										  @RequestParam(value="id",required = true) String id,
									      @ApiParam(name="drugsData",value="面访用药数据",defaultValue = "[]")
										  @RequestParam(value="drugsData",required = true) String drugsData)
	{
		try {
			followupDrugsService.saveFollowupDrugs(id,drugsData);
			return write(200, "保存面访用药数据成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "保存面访用药数据失败!"+e.getMessage());
		}
	}
}

+ 5 - 2
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/followup/FollowUpDao.java

@ -71,8 +71,11 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.status <> '0'")
	Followup getFollowupByPrescriptionCode(String prescriptionCode);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.followupType = ?2 and a.status <> '0'")
    Followup getFollowupByPrescriptionCode(String prescriptionCode,String followupType);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.followupClass = ?2 and a.status <> '0'")
    Followup getFollowupByPrescriptionCode(String prescriptionCode,String followupClass);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.followupClass = ?2 and a.status <> '0'")
    List<Followup> getFollowupListByPrescriptionCode(String prescriptionCode,String followupClass);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.status <> '0'")
    List<Followup> getFollowupListByPrescriptionCode(String prescriptionCode);

+ 22 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/followup/FollowupDrugsDao.java

@ -0,0 +1,22 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.door.dao.followup;
import com.yihu.jw.entity.followup.FollowupDrugs;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FollowupDrugsDao extends PagingAndSortingRepository<FollowupDrugs, Long>, JpaSpecificationExecutor<FollowupDrugs> {
    @Modifying
    @Query("delete FollowupDrugs a where a.followupId=?1")
    int deleteByFollowupId(Long followupId) throws Exception;
    List<FollowupDrugs> findByFollowupId(Long followupId) throws Exception;
}

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java

@ -358,7 +358,7 @@ public class DoorOrderService {
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(id);
        if (null != consult) {
            doorServiceOrder.setSessionId(doorServiceOrder.getProxyPatient() + "_" + consult.getId() + "_"  + doorServiceOrder.getNumber() +  "_" +  consult.getType());
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_"  + doorServiceOrder.getNumber() +  "_" +  consult.getType());
        }
        // 设置服务小结

+ 46 - 5
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/followup/FollowUpService.java

@ -2,11 +2,13 @@ package com.yihu.jw.door.service.followup;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.door.dao.WlyyDoorServiceOrderDao;
import com.yihu.jw.door.dao.followup.FollowUpDao;
import com.yihu.jw.door.service.common.WlyySystemDictService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.es.es.ElasticFactory;
import com.yihu.jw.es.es.ElastricSearchSave;
@ -53,6 +55,37 @@ public class FollowUpService {
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private WlyyDoorServiceOrderDao doorServiceOrderDao;
    /**
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        JestClient jestClient = null;
        FollowupContentESDO followupContentESDO = null;
        try {
            //根据随访ID、分类ID获取随访记录详情
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDO;
    }
    /**
     * 新增临时随访记录(返回ID)
@ -73,8 +106,8 @@ public class FollowUpService {
        String followupClasss[] = followupClass.split(",");
        for (String followupClassTemp:followupClasss){
            Followup followupTemp = followupDao.getFollowupByPrescriptionCode(relateCode,followupClassTemp);
            if(followupTemp != null){
            List<Followup> followupTemp = followupDao.getFollowupListByPrescriptionCode(relateCode,followupClassTemp);
            if(followupTemp.size()>0){
                continue;
            }
            Followup followup = new Followup();
@ -82,6 +115,8 @@ public class FollowUpService {
                Date followDate = DateUtil.strToDate(date);
                followup.setFollowupDate(followDate);
                followup.setFollowupPlanDate(followDate);
            }else{
                followup.setFollowupDate(new Date());
            }
            followup.setDoctorCode(doctorCode);
@ -140,6 +175,11 @@ public class FollowUpService {
            }
            followupDao.save(followup);
        }
        WlyyDoorServiceOrderDO orderDO = doorServiceOrderDao.findOne(relateCode);
        if(orderDO!=null){
            orderDO.setFollowupDate(DateUtil.getStringDate());
        }
    }
@ -344,7 +384,6 @@ public class FollowUpService {
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        String followupClass = followup.getFollowupClass();
        re.put("followupClass", followupClass);
@ -364,8 +403,10 @@ public class FollowUpService {
        //随访管理状态转译
        re.put("followupManagerStatus", followup.getFollowupManagerStatus());
        String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS", followup.getFollowupManagerStatus());
        re.put("followupManagerStatusName", followupManagerStatusName);
        if(StringUtils.isNoneBlank(followup.getFollowupManagerStatus())){
            String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS", followup.getFollowupManagerStatus());
            re.put("followupManagerStatusName", followupManagerStatusName);
        }
        re.put("doctorCode", followup.getDoctorCode());
        re.put("doctorName", followup.getDoctorName());

+ 80 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/followup/FollowupDrugsService.java

@ -0,0 +1,80 @@
package com.yihu.jw.door.service.followup;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.door.dao.followup.FollowupDrugsDao;
import com.yihu.jw.entity.followup.FollowupDrugs;
import com.yihu.jw.followup.FollowupContentESDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.*;
/**
 * Created by yeshijie on 2021/1/11.
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowupDrugsService {
    @Autowired
    private FollowupDrugsDao followupDrugsDao;
    @Autowired
    private FollowUpService followUpService;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 获取面访用药数据
     */
    public Map<String,Object> getFollowupDrugs(String id) throws Exception
    {
        Map<String,Object> re = new HashMap<>();
        FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(id, "6");
        if(followupContentESDO != null){
            re.put("DRUG_COMPLIANCE_CODE",followupContentESDO.getDRUG_COMPLIANCE_CODE());
        }
        //获取用药记录
        List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(id));
        re.put("DRUG_LIST",drugsList);
        return re;
    }
    /**
     *保存面访用药数据
     */
    @Transactional
    public void saveFollowupDrugs(String id,String drugsData) throws Exception {
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String,String>> list = objectMapper.readValue(drugsData,javaType);
        Long followupId = Long.valueOf(id);
        //删除原有用药记录
        followupDrugsDao.deleteByFollowupId(Long.valueOf(followupId));
        if(list!=null && list.size()>0)
        {
            List<FollowupDrugs> newList = new ArrayList<>();
            for(Map<String,String> item:list)
            {
                FollowupDrugs drug = new FollowupDrugs();
                drug.setFollowupId(followupId);
                drug.setDrugsGroup(item.get("drugsGroup"));
                drug.setDrugsCode(item.get("drugsCode"));
                drug.setDrugsName(item.get("drugsName"));
                drug.setDose(item.get("dose"));
                drug.setUnit(item.get("unit"));
                drug.setFrequency(item.get("frequency"));
                drug.setCreateTime(new Date());
                newList.add(drug);
            }
            followupDrugsDao.save(newList);
        }
    }
}

+ 2 - 2
svr/svr-door-serivce/src/main/resources/application.yml

@ -303,11 +303,11 @@ spring:
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://365q88j171.oicp.vip:44840/fastdfs/
  fastdfs_file_url: https://365q88j171.oicp.vip/fastdfs/
fast-dfs:
  tracker-server: 10.9.1.247:22122
  public-server: http://365q88j171.oicp.vip:44840/fastdfs/
  public-server: https://365q88j171.oicp.vip/fastdfs/
neiwang:
  enable: true

+ 45 - 24
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java

@ -306,12 +306,22 @@ public class PrescriptionStatusUpdateService {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int i = calendar.get(Calendar.HOUR_OF_DAY);
        if(i==0){
            //将所有的已接诊的处方记录
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
            if(outpatientDOs!=null&&outpatientDOs.size()>0){
                System.out.println(outpatientDOs.get(0).getId()+"id______-");
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){
        //将所有的已接诊的处方记录
        List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
        if(outpatientDOs!=null&&outpatientDOs.size()>0){
            System.out.println(outpatientDOs.get(0).getId()+"id______-");
            for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                long currentTime = new Date().getTime();
                Date temp = new Date();
                if (outpatientDO.getConDate()==null){
                    temp = outpatientDO.getCreateTime();
                }else {
                    temp = outpatientDO.getConDate();
                }
                long outpatientTime = outpatientDO.getAdmDate()==null?temp.getTime():outpatientDO.getAdmDate().getTime();
                if(currentTime-outpatientTime>24*60*60*1000){
                    logger.info("结束接诊时间满足条件");
                    //结束门诊
                    outpatientDO.setStatus("3");
                    outpatientDO.setEndTime(new Date());
@ -328,30 +338,41 @@ public class PrescriptionStatusUpdateService {
                    }
                    logger.info(outpatientDO.getId()+"的处方记录设置为结束");
                }
                outpatientDao.save(outpatientDOs);
                //退费
                for (WlyyOutpatientDO outpatientDO:outpatientDOs){
            }
            outpatientDao.save(outpatientDOs);
            //退费
            for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                long currentTime = new Date().getTime();
                Date temp = new Date();
                if (outpatientDO.getConDate()==null){
                    temp = outpatientDO.getCreateTime();
                }else {
                    temp = outpatientDO.getConDate();
                }
                long outpatientTime = outpatientDO.getAdmDate()==null?temp.getTime():outpatientDO.getAdmDate().getTime();
                if(currentTime-outpatientTime>24*60*60*1000) {
                    logger.info("退费时间满足条件");
                    try {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    if (businessOrderDO!=null){
                        if (businessOrderDO.getPayType()==1){
                            businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        }else if (businessOrderDO.getPayType()==3){
        /*
                            businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
        */
                        }
                    } } catch (Exception e) {
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                        if (businessOrderDO!=null){
                            if (businessOrderDO.getPayType()==1){
                                businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                            }else if (businessOrderDO.getPayType()==3){
    /*
                        businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
    */
                            }
                        } } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                logger.info("setOutPatientOver count :"+outpatientDOs.size());
            }else {
                logger.info("setOutPatientOver count :"+0);
            }
            logger.info("setOutPatientOver end ");
            logger.info("setOutPatientOver count :"+outpatientDOs.size());
        }else {
            logger.info("setOutPatientOver count :"+0);
        }
        logger.info("setOutPatientOver end ");
    }

+ 1 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -198,7 +198,7 @@ public class UnSettledHISPrescriptionService {
                        msgObj.put("reason","处方驳回");
                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
                        System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
                        String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
                        String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
                        System.out.println("发送诊断消息成功:"+immsg);
                    }
                }

+ 2 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/OverdueJob.java

@ -27,9 +27,9 @@ import java.util.List;
@EnableScheduling
public class OverdueJob implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(OverdueJob.class);
    private static String cron = "0 0 0 * * ?";
    private static String cron = "0 */5 * * * ?";//"0 0 0 * * ?";
    public OverdueJob(){
        cron="0 0 0 * * ?";
        cron="0 */5 * * * ?";
        System.out.println("初始化时的corn"+cron);
    }
    @Autowired

+ 7 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -143,8 +143,12 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                              @RequestParam(value = "cardNo",required = false)String cardNo,
                                          @ApiParam(name = "flag", value = "标识", required = false)
                                              @RequestParam(value = "flag",required = false)String flag) throws Exception {
        startTime = startTime+" 00:00:00";
        endTime =endTime+" 23:59:59";
        if(StringUtils.isNoneBlank(startTime)){
            startTime = startTime+" 00:00:00";
        }
        if(StringUtils.isNoneBlank(endTime)){
            endTime =endTime+" 23:59:59";
        }
        List<WlyyOutpatientVO> vos = new ArrayList<>();
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag,ksdm,cardNo);
@ -1711,7 +1715,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                msgObj.put("outpatientid",wlyyPrescriptionDO.getOutpatientId());
                msgObj.put("prescriptionId",prescriptionId);
                msgObj.put("reason",reason);
                String immsg = imService.pushPrescriptionBackMsg(msgObj,operate,operateName,wlyyPrescriptionDO.getOutpatientId(),wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
                String immsg = imService.pushPrescriptionBackMsg(msgObj,operate,operateName,wlyyPrescriptionDO.getOutpatientId(),wlyyOutpatientDO.getConsumer(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
                System.out.println("发送诊断消息成功:"+immsg);
            }else if (status==2){
                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);

+ 15 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -531,4 +531,19 @@ public class SpecialistController extends EnvelopRestEndpoint {
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value="/transferPatients")
    @ApiOperation(value = "专科端转移居民")
    public Envelop transferPatients(@ApiParam(name="teamCode",value = "医生所在团队",required = true)@RequestParam(value = "teamCode",required = true) String teamCode,
                                    @ApiParam(name="doctorCode",value = "当前医生code",required = true)@RequestParam(value = "doctorCode",required = true)String doctorCode,
                                    @ApiParam(name="toDoctorCode",value = "接收患者医生code",required = true)@RequestParam(value = "toDoctorCode",required = true)String toDoctorCode,
                                    @ApiParam(name="patients",value = "患者JsonArray列表(包含code)",required = true)@RequestParam(value = "patients",required = true)String patients){
        try {
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,specialistService.transferPatients(teamCode, doctorCode, toDoctorCode, patients));
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 3 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java

@ -32,4 +32,7 @@ public interface SpecialistPatientRelationDao extends PagingAndSortingRepository
    @Query("select p from SpecialistPatientRelationDO p where p.doctor=?1 and p.patient =?2 and p.teamCode =?3 and p.status>=0 and p.signStatus=1")
    public SpecialistPatientRelationDO findByDoctorAndPatientAndTeamCode(String doctor,String patient,Integer teamCode);
    @Query("select p from SpecialistPatientRelationDO p where p.teamCode=?1 and p.patient=?2 and p.doctor=?3 and p.status>=0 and p.signStatus=1")
    List<SpecialistPatientRelationDO> findListByTeamCodeAndPatientAndDoctor(Integer teamCode,String patient,String doctor);
}

+ 3 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java

@ -21,6 +21,9 @@ public interface PatientRehabilitationPlanDao extends PagingAndSortingRepository
    @Query(" select p from PatientRehabilitationPlanDO p where p.patient=?1 and p.createUser=?2 order by p.createTime desc ")
    List<PatientRehabilitationPlanDO> findByPatientAndCreateUser(String patient, String doctor);
    @Query(" select p from PatientRehabilitationPlanDO p where p.patient=?1 and p.createUser=?2 and p.teamCode=?3 order by p.createTime desc ")
    List<PatientRehabilitationPlanDO> findByPatientAndCreateUserAAndTeamCode(String patient, String doctor,Integer teamCode);
    @Query(" select p from PatientRehabilitationPlanDO p where p.patient=?1 order by p.createTime desc ")
    List<PatientRehabilitationPlanDO> findByPatients(String patientCode);

+ 3 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java

@ -88,4 +88,7 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    @Modifying
    @Query("delete from RehabilitationDetailDO t where t.planId = ?1 and (t.executeTime > ?2 OR t.executeTime is null OR t.executeTime<>'')  and t.status <> 1 ")
    void deleteDetailByPlanId(String planId, Date dateShort);
    @Query("select d from RehabilitationDetailDO d where d.planId=?1 and d.type=?2 and d.doctor=?3 ")
    List<RehabilitationDetailDO> findByPlanIdAndTypeAndDoctor(String planId,Integer type,String doctor);
}

+ 62 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -1,9 +1,15 @@
package com.yihu.jw.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dao.PatientHospitalRecordDao;
import com.yihu.jw.dao.SpecialistPatientRelationDao;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationDetailAppointmentDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationDetailDao;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.restmodel.specialist.*;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -47,6 +53,12 @@ public class SpecialistService{
    private String basedb;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientRehabilitationPlanDao patientRehabilitationPlanDao;
    @Autowired
    private RehabilitationDetailDao rehabilitationDetailDao;
    @Autowired
    private RehabilitationDetailAppointmentDao rehabilitationDetailAppointmentDao;
    public MixEnvelop<Boolean, Boolean> createSpecialistsPatientRelation(SpecialistPatientRelationDO specialistPatientRelationDO){
        specialistPatientRelationDao.save(specialistPatientRelationDO);
@ -1275,4 +1287,54 @@ public class SpecialistService{
        specialistPatientRelationDao.updateSpecialistByPatient(patient, doctor, doctorName);
        return Envelop.getSuccess("更新成功!");
    }
    public JSONObject transferPatients(String teamCode,String doctorCode,String toDoctorCode,String patients){
        String[] patient = patients.split(",");
        String sql =" select name from wlyy.wlyy_doctor where code='"+toDoctorCode+"'";
        String toDoctorName = jdbcTemplate.queryForObject(sql,String.class);
        sql =" select name from wlyy.wlyy_doctor where code='"+doctorCode+"'";
        String doctorName = jdbcTemplate.queryForObject(sql,String.class);
        JSONObject result = new JSONObject();
        JSONArray planObject = new JSONArray();
        JSONArray planDetailObject = new JSONArray();
        JSONArray specialistPatientRelation = new JSONArray();
        for (String patientCode:patient){
            List<PatientRehabilitationPlanDO> planList  = patientRehabilitationPlanDao.findByPatientAndCreateUserAAndTeamCode(patientCode,doctorCode,Integer.parseInt(teamCode));{
                for (PatientRehabilitationPlanDO plan:planList){
                    plan.setCreateUser(toDoctorCode);
                    plan.setCreateUserName(toDoctorName);
                    plan.setUpdateUser(doctorCode);
                    plan.setUpdateUserName(doctorName);
                    plan.setUpdateTime(new Date());
                    patientRehabilitationPlanDao.save(plan);
                    planObject.add(plan.getId());
                    List<RehabilitationDetailDO> planDetails  = rehabilitationDetailDao.findByPlanIdAndTypeAndDoctor(plan.getId(),2,doctorCode);
                    for (RehabilitationDetailDO planDetail:planDetails){
                        planDetail.setDoctor(toDoctorCode);
                        planDetail.setDoctorName(toDoctorName);
                        planDetail.setUpdateTime(new Date());
                        planDetail.setUpdateUser(doctorCode);
                        planDetail.setUpdateUserName(doctorName);
                        rehabilitationDetailDao.save(planDetail);
                        planDetailObject.add(planDetail.getId());
                    }
                }
            }
            List<SpecialistPatientRelationDO> relations = specialistPatientRelationDao.findListByTeamCodeAndPatientAndDoctor(Integer.parseInt(teamCode),patientCode,doctorCode);
            for (SpecialistPatientRelationDO relation:relations){
                relation.setDoctor(toDoctorCode);
                relation.setDoctorName(toDoctorName);
                relation.setUpdateTime(new Date());
                relation.setUpdateUser(doctorCode);
                relation.setUpdateUserName(doctorName);
                specialistPatientRelationDao.save(relation);
                specialistPatientRelation.add(relation.getId());
            }
        }
        result.put("planList",planObject);
        result.put("planDetailList",planDetailObject);
        result.put("relationList",specialistPatientRelation);
        return  result;
    }
}