Browse Source

代码修改

LAPTOP-KB9HII50\70708 1 year ago
parent
commit
aafb7c0094
17 changed files with 2110 additions and 208 deletions
  1. 16 4
      business/base-service/src/main/java/com/yihu/jw/dict/service/HospitalDeptService.java
  2. 23 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServiceItemPlanDO.java
  3. 10 2
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/GuidanceMessageLogDO.java
  4. 52 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationDetailDO.java
  5. 1 2
      svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/endpoint/followup/DoctorFollowupDrugsController.java
  6. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java
  7. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  8. 843 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/BaseController.java
  9. 3 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/dao/ServiceItemPlanDao.java
  10. 725 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java
  11. 78 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowupDrugsController.java
  12. 39 26
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java
  13. 98 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowupDrugsService.java
  14. 26 41
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/PatientRehabilitationManageController.java
  15. 60 21
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/RehabilitationManageController.java
  16. 2 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/dao/RehabilitationDetailDao.java
  17. 128 108
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

+ 16 - 4
business/base-service/src/main/java/com/yihu/jw/dict/service/HospitalDeptService.java

@ -7,6 +7,8 @@ import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@ -16,13 +18,23 @@ import java.util.List;
public class HospitalDeptService extends BaseJpaService<BaseCityDO, BaseCityDao> {
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    // 基于机构编码,获取该机构下所有的科室列表
    public List<DictHospitalDeptDO> getHosDeptByCode(String orgCode,String consultDeptFlag) {
    public List<DictHospitalDeptDO> getHosDeptByCode(String orgCode,String consultDeptFlag,String name) {
        String sql = "select * from dict_hospital_dept where 1=1";
        if(StringUtils.isNotBlank(orgCode)){
            sql+=" and org_code = '"+orgCode+"' ";
        }
        if(StringUtils.isNotBlank(consultDeptFlag)){
            return dictHospitalDeptDao.findByOrgCodeAndConsultDeptFlag(orgCode,consultDeptFlag);
        }else{
            return dictHospitalDeptDao.findByOrgCode(orgCode);
            sql += " and consult_dept_flag = '"+consultDeptFlag+"' ";
        }
        if(StringUtils.isNotBlank(name)){
            sql += " and name like '%"+name+"%' ";
        }
        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DictHospitalDeptDO.class));
    }
}

+ 23 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServiceItemPlanDO.java

@ -1,10 +1,12 @@
package com.yihu.jw.entity.base.servicePackage;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import com.yihu.jw.entity.followup.Followup;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 服务项执行计划
@ -26,6 +28,9 @@ public class ServiceItemPlanDO extends UuidIdentityEntityWithCreateTime {
    private String relationCode;//关联业务id
    private String relationType;//关联业务类型 1电话/短信关怀 2康复咨询 3康复咨询 4上门服务 5康复指导 6康复随访 7康复复诊
    private String guidanceMessage;//指导留言
    private Followup followup;//随访
    @Column(name = "patient")
    public String getPatient() {
        return patient;
@ -116,4 +121,22 @@ public class ServiceItemPlanDO extends UuidIdentityEntityWithCreateTime {
    public void setCompleteTime(String completeTime) {
        this.completeTime = completeTime;
    }
    @Transient
    public String getGuidanceMessage() {
        return guidanceMessage;
    }
    public void setGuidanceMessage(String guidanceMessage) {
        this.guidanceMessage = guidanceMessage;
    }
    @Transient
    public Followup getFollowup() {
        return followup;
    }
    public void setFollowup(Followup followup) {
        this.followup = followup;
    }
}

+ 10 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/GuidanceMessageLogDO.java

@ -1,10 +1,8 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.yihu.jw.entity.UuidIdentityEntityWithOperatorAES;
import com.yihu.jw.entity.util.StringFStringEncryptConverter;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@ -22,6 +20,7 @@ public class GuidanceMessageLogDO extends UuidIdentityEntityWithOperatorAES impl
    private String content;
    private String doctor;
    private String doctorName;
    private String imgs;//附件
    private Integer doctorType;
    private Integer adminTeamCode;
    private String adminTeamName;
@ -117,4 +116,13 @@ public class GuidanceMessageLogDO extends UuidIdentityEntityWithOperatorAES impl
    public void setContentType(Integer contentType) {
        this.contentType = contentType;
    }
    @Column(name = "imgs")
    public String getImgs() {
        return imgs;
    }
    public void setImgs(String imgs) {
        this.imgs = imgs;
    }
}

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

@ -7,6 +7,7 @@ import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
@ -69,6 +70,13 @@ public class RehabilitationDetailDO extends UuidIdentityEntity implements Serial
    private String updateUser;
    private String updateUserName;
    //非数据库字段
    private String name;//服务项名称
    private Integer finishNum;//已完成数
    private Integer totalNum;//总数
    private String completeTime;//上次完成时间
    private String planTime;//计划时间
    @Column(name = "reservation_type")
    public Integer getReservationType() {
        return reservationType;
@ -318,4 +326,48 @@ public class RehabilitationDetailDO extends UuidIdentityEntity implements Serial
    public void setFollowupDetailType(Integer followupDetailType) {
        this.followupDetailType = followupDetailType;
    }
    @Transient
    public Integer getFinishNum() {
        return finishNum;
    }
    public void setFinishNum(Integer finishNum) {
        this.finishNum = finishNum;
    }
    @Transient
    public Integer getTotalNum() {
        return totalNum;
    }
    public void setTotalNum(Integer totalNum) {
        this.totalNum = totalNum;
    }
    @Transient
    public String getCompleteTime() {
        return completeTime;
    }
    public void setCompleteTime(String completeTime) {
        this.completeTime = completeTime;
    }
    @Transient
    public String getPlanTime() {
        return planTime;
    }
    public void setPlanTime(String planTime) {
        this.planTime = planTime;
    }
    public String getName() {
        return name;
    }
    @Transient
    public void setName(String name) {
        this.name = name;
    }
}

+ 1 - 2
svr/svr-after-diagnosis/src/mian/java/com/yihu/jw/afterDiagnosis/endpoint/followup/DoctorFollowupDrugsController.java

@ -8,7 +8,6 @@ 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;
@ -24,7 +23,7 @@ import java.util.Map;
 *
 */
@RestController
@RequestMapping(value = "/doctor/followup/drugs", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/doctor/followup/drugs")
@Api(description = "医生端-随访用药接口")
public class DoctorFollowupDrugsController extends BaseController {

+ 3 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/base/BaseInfoEndpoint.java

@ -114,11 +114,13 @@ public class BaseInfoEndpoint extends EnvelopRestEndpoint {
    public Envelop getDeptByOrgCode(
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "name", value = "科室名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "consultDeptFlag", value = "是否是就诊科室,1为查询门诊,不传为全部")
            @RequestParam(value = "consultDeptFlag", required = false) String consultDeptFlag)  {
        try {
            List<DictHospitalDeptDO> res =  hospitalDeptService.getHosDeptByCode(orgCode,consultDeptFlag);
            List<DictHospitalDeptDO> res =  hospitalDeptService.getHosDeptByCode(orgCode,consultDeptFlag,name);
            if(res != null && res.size() > 0 ){
                return  success(res);
            }else{

+ 3 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -455,10 +455,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    public Envelop getDeptByOrgCode(
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "name", value = "科室名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "consultDeptFlag", value = "是否是就诊科室,1为查询门诊,不传为全部")
            @RequestParam(value = "consultDeptFlag", required = false) String consultDeptFlag)  {
        try {
            List<DictHospitalDeptDO> res =  hospitalDeptService.getHosDeptByCode(orgCode,consultDeptFlag);
            List<DictHospitalDeptDO> res =  hospitalDeptService.getHosDeptByCode(orgCode,consultDeptFlag,name);
            if(res != null && res.size() > 0 ){
                return  success(res);
            }else{

+ 843 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/BaseController.java

@ -0,0 +1,843 @@
package com.yihu.jw.hospital.module.common;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.IdEntity;
import com.yihu.jw.entity.base.dict.BaseExceptionDictDO;
import com.yihu.jw.restmodel.exception.dao.BaseExceptionDictDao;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ReflectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "返回的json里的status是200,成功"),
        @ApiResponse(code = 403, message = "返回的json里的status是403,该操作没有权限"),
        @ApiResponse(code = 997, message = "返回的json里的status是997,重新登陆"),
        @ApiResponse(code = 998, message = "返回的json里的status是998,登录超时,请重新登录"),
        @ApiResponse(code = 999, message = "返回的json里的status是999,帐号在别处登录,请重新登录")
})
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger("error_logger");
    @Autowired
    protected HttpServletRequest request;
    @Autowired
    private BaseExceptionDictDao baseExceptionDictDao;
    @Autowired
    protected ObjectMapper objectMapper;
    /**
     * 獲取髮送請求用戶的uid
     * @return
     */
    public String getUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取被代理人的code
     * @return
     */
    public String getRepresentedUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("represented");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取平台端
     * @return
     */
    public Integer getPlatform() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getInt("platform");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取被代理人code,若没有则返回当前登录者
     * @return
     */
    public String getRepUID(){
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            if(json.isNull("represented")){
                return json.getString("uid");
            }
            return json.getString("represented");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getLastUid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            String id = json.getString("lastUid");
            if(StringUtils.isNoneBlank(id)){
                return id;
            }else{
               return json.getString("uid");
            }
        } catch (Exception e) {
            return null;
        }
    }
    public String getAppVersion() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("appVersion");
        } catch (Exception e) {
            return null;
        }
    }
    public String getOpenid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("openid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取用户ID
     *
     * @return
     */
    public long getId() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getLong("id");
        } catch (Exception e) {
            return 0;
        }
    }
    public String getIMEI() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("imei");
        } catch (Exception e) {
            return null;
        }
    }
    public String getToken() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("token");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取当前用户的角色级别
     * @return
     */
    public String getCurrentRoleLevel(){
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getJSONObject("currentUserRole").get("level")+"";
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取当前用户的角色是否是管理员
     * @return
     */
    public String getCurrentRoleIsManange(){
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getJSONObject("currentUserRole").getString("isManage");
        } catch (Exception e) {
            return null;
        }
    }
    public void error(Exception e) {
        logger.error(DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+":"+getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void error(Exception e,String method,String key,String param) {
        try {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            pw.flush();
            sw.flush();
            String exception = sw.toString();
            if(StringUtils.isNotBlank(exception)){
                exception = exception.length()>30000? exception.substring(0,30000):exception;
            }
        }catch (Exception e1){
            e1.printStackTrace();
        }
    }
    public void warn(Exception e) {
        logger.warn(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void infoMessage(String message) {
        logger.info(message);
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    public String errorResult(Exception e) {
        try {
            e.printStackTrace();
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            BaseExceptionDictDO baseExceptionDictDO =baseExceptionDictDao.findByExceptionInfo(e.getClass().toString());
            if (baseExceptionDictDO!=null){
                map.put("status", Integer.parseInt(baseExceptionDictDO.getCode()));
                map.put("msg", baseExceptionDictDO.getRemindContent());
            }else {
                map.put("status", -10000);
                map.put("msg", "系统繁忙,请稍后再试");
            }
            return mapper.writeValueAsString(map);
        } catch (Exception e1) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 接口处理成功
     *
     * @param msg
     * @return
     */
    public String success(String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, list);
            String s = mapper.writeValueAsString(map);
            return s;
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, List<?> list,String key2,Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, list);
            map.put(key2, value);
            String s = mapper.writeValueAsString(map);
            return s;
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONObject value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONArray value,String key2, JSONObject value2) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            json.put(key2, value2);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param total 总数
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, int total, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put("total", total);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, int total, String key, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            map.put("status", code);
            map.put("msg", msg);
            map.put("total", total);
            map.put(key, list);
            String s = mapper.writeValueAsString(map);
            return s;
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, Page<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            // 是否为第一页
            map.put("isFirst", list.isFirst());
            // 是否为最后一页
            map.put("isLast", list.isLast());
            // 总条数
            map.put("total", list.getTotalElements());
            // 总页数
            map.put("totalPages", list.getTotalPages());
            map.put(key, list.getContent());
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", page == null ? false : page.isFirst());
            // 是否为最后一页
            json.put("isLast", page == null ? true : page.isLast());
            // 总条数
            json.put("total", page == null ? 0 : page.getTotalElements());
            // 总页数
            json.put("totalPages", page == null ? 0 : page.getTotalPages());
            json.put(key, array);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Map<?, ?> value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, String value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, IdEntity entity) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, entity);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", isFirst);
            // 是否为最后一页
            json.put("isLast", isLast);
            // 总条数
            json.put("total", total);
            // 总页数
            json.put("totalPages", totalPages);
            json.put(key, values);
            return json.toString();
        } catch (Exception e) {
            logger.error("BaseController:", e.getMessage());
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public String trimEnd(String param, String trimChars) {
        if (param.endsWith(trimChars)) {
            param = param.substring(0, param.length() - trimChars.length());
        }
        return param;
    }
    public List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String... propertyNames) {
        List<Map<String, Object>> result = new ArrayList<>();
        for (Object bean : beans) {
            result.add(copyBeanProperties(bean, propertyNames));
        }
        return result;
    }
    /**
     * 复制特定属性。
     *
     * @param bean
     * @param propertyNames
     * @return
     */
    public Map<String, Object> copyBeanProperties(Object bean, String... propertyNames) {
        Map<String, Object> simplifiedBean = new HashMap<>();
        for (String propertyName : propertyNames) {
            Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
            if (field != null) {
                field.setAccessible(true);
                Object value = ReflectionUtils.getField(field, bean);
                simplifiedBean.put(propertyName, value == null ? "" : value);
            } else {
                simplifiedBean.put(propertyName, "");
            }
        }
        return simplifiedBean;
    }
    /**
     * 数据保留两位小数,**.0 去掉小数点
     * @param obj
     * @return
     */
    public String getNumberFormat(Object obj){
        if(obj != null){
            Double d = Double.valueOf(obj.toString());
            NumberFormat df = NumberFormat.getInstance();
            df.setGroupingUsed(false);
            df.setMaximumFractionDigits(2);
            return df.format(d);
        }else {
            return "";
        }
    }
    public String write(int code, String errorMsg, int page, int rows, long total, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("successFlg", code == 0);
            map.put("errorMsg", errorMsg);
            // 是否为第一页
            map.put("errorCode", code);
            // 是否为最后一页
            map.put("currPage", page);
            // 分页大小
            map.put("pageSize", rows);
            // 总条数
            map.put("totalCount", total);
            // 总页数
            map.put("totalPage", Math.ceil((double)total/(rows)));
            // 结果集
            map.put("detailModelList", list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    
    /**
     * 判断是否是观察者模式
     * @return
     */
    public boolean getObserverStatus () {
    
        String userAgent = request.getHeader("userAgent");
        if (StringUtils.isEmpty(userAgent)) {
            userAgent = request.getHeader("User-Agent");
        }
        logger.debug("userAgent:" + userAgent);
        JSONObject json = new JSONObject(userAgent);
        String observer = json.has("observer") ? json.getString("observer") : "";
        //如果是观察者直接返回true
        if (!org.springframework.util.StringUtils.isEmpty(observer) && observer.equals("1")) {
            return true;
        }else{
            return false;
        }
    }
    //获取ip地址
    public String getIpAddr() {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        if ("0:0:0:0:0:0:0:1".equals(ip)) {
            ip = "127.0.0.1";
        }
        if (ip.split(",").length > 1) {
            ip = ip.split(",")[0];
        }
        return ip;
    }
    //获取手机型号
    public String getPhoneType(){
        String userAgent = request.getHeader("User-Agent");
        Pattern pattern = Pattern.compile(";\\s?(\\S*?\\s?\\S*?)\\s?(Build)?/");
        Matcher matcher = pattern.matcher(userAgent);
        String model = null;
        if (matcher.find()) {
            model = matcher.group(1).trim();
        }else{
            model = "未知型号";
        }
        return model;
    }
    /**
     * 无效用户消息返回
     *
     * @param e
     * @param defaultCode
     * @param defaultMsg
     * @return
     */
    public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
        try {
            // if (e instanceof UndeclaredThrowableException) {
            // UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
            // InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
            // if (iue != null) {
            // return error(iue.getCode(), iue.getMsg());
            // }
            // }
            return errorResult(e);
        } catch (Exception e2) {
            return null;
        }
    }
}

+ 3 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/dao/ServiceItemPlanDao.java

@ -8,12 +8,15 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2023/10/28.
 */
public interface ServiceItemPlanDao extends PagingAndSortingRepository<ServiceItemPlanDO, String>, JpaSpecificationExecutor<ServiceItemPlanDO> {
    @Query("from ServiceItemPlanDO w where w.planId =?1 ")
    List<ServiceItemPlanDO> findByPlanId(String planId);
    @Modifying
    @Query(value ="UPDATE  base_service_item_plan SET status='1' ,complete_time=?3 WHERE status='0' AND plan_id=?1 AND plan_detail_id=?2 ORDER BY plan_time DESC LIMIT 1", nativeQuery = true)

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

@ -0,0 +1,725 @@
package com.yihu.jw.hospital.module.followup.controller;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
import com.yihu.jw.hospital.module.followup.service.FollowupDrugsService;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
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.List;
import java.util.Map;
/**
 * 医生端:随访接口
 *
 * @author hzp add 2016-12-07
 */
@RestController
@RequestMapping(value = "/doctor/followup")
@Api(description = "医生端-随访接口")
public class DoctorFollowUpController extends BaseController {
    @Autowired
    private FollowUpService followUpService;
    @Autowired
    private FollowupDrugsService followupDrugsService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /*************************************** 随访计划 ****************************************************************************/
    @ApiOperation("获取随访列表")
    @RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getList(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2016-12-07 00:00:00")
                          @RequestParam(value = "startTime", required = true) String startTime,
                          @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2016-12-14 00:00:00")
                          @RequestParam(value = "endTime", required = true) String endTime) {
        try {
            List<Map<String, Object>> result = followUpService.getListByDoctor(getUID(), startTime, endTime);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
            return write(200, "获取随访列表成功!", "data", result);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访列表失败!" + e.getMessage());
        }
    }
    /**
     * 查询居民随访列表
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/list_by_team", method = {RequestMethod.GET,RequestMethod.POST})
    @ApiOperation(value = "查询居民随访列表")
    public String getListByPatientAndTeam(@RequestParam @ApiParam(value = "居民Code") String patient,
                                          @RequestParam @ApiParam(value = "医生Code") String doctor,
                                          @RequestParam @ApiParam(value = "团队code") Long teamCode,
                                          @RequestParam @ApiParam(value = "第几页") int page,
                                          @RequestParam @ApiParam(value = "页大小") int pagesize,
                                          @RequestParam(value = "type",required = false) @ApiParam(value = "类型:放空为全部,1计划,2记录",defaultValue = "0") String type) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray result = followUpService.getListByPatientAndTeam(patient,doctor, teamCode, page, pagesize,type);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    /**
     * 查询居民随访列表
     *
     * @param patient
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/list_by", method = {RequestMethod.GET,RequestMethod.POST})
    @ApiOperation(value = "查询居民随访列表")
    public String getListByPatient(@RequestParam @ApiParam(value = "居民Code") String patient,
                                          @RequestParam @ApiParam(value = "第几页") int page,
                                          @RequestParam @ApiParam(value = "页大小") int pagesize,
                                          @RequestParam(value = "type",required = false) @ApiParam(value = "类型:放空为全部,1计划,2记录",defaultValue = "0") String type) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray result = followUpService.getListByPatient(patient, page, pagesize,type);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @ApiOperation("获取随访列表(创建者)")
    @RequestMapping(value = "/createrList", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getCreaterList(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2016-12-07 00:00:00")
                                 @RequestParam(value = "startTime", required = true) String startTime,
                                 @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2016-12-14 00:00:00")
                                 @RequestParam(value = "endTime", required = true) String endTime,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                 @RequestParam(value = "page", required = true) String page,
                                 @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                                 @RequestParam(value = "pageSize", required = true) String pageSize) {
        try {
            List<Map<String, String>> result = followUpService.getListByCreater(getUID(), startTime, endTime, page, pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
            return write(200, "获取随访列表成功!", "data", result);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增随访计划(批量)")
    @RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String addFollowupPlan(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "data", value = "随访计划列表json", defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
                                  @RequestParam(value = "data", required = true) String data) {
        try {
            Iterable<Followup> followups = followUpService.addFollowupPlan(getUID(), patient, data);
            return write(200, "新增随访计划成功!","data",followups);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("编辑随访计划")
    @RequestMapping(value = "/editFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String editFollowupPlan(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                   @RequestParam(value = "id", required = true) String id,
                                   @ApiParam(name = "planDate", value = "随访计划时间", defaultValue = "2016-12-14 20:00:00")
                                   @RequestParam(value = "planDate", required = true) String planDate,
                                   @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                   @RequestParam(value = "followupType", required = true) String followupType) {
        try {
            followUpService.editFollowupPlan(getUID(), id, planDate, followupType);
            return write(200, "编辑随访计划成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "编辑随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("开始随访记录")
    @RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String startFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                @RequestParam(value = "id", required = true) String id,
                                @ApiParam(name = "followupNo", value = "随访记录编码")
                                @RequestParam(value = "followupNo", required = false) String followupNo,
                                @ApiParam(name = "date", value = "随访时间", defaultValue = "2016-12-14 20:00:00")
                                @RequestParam(value = "date", required = true) String date,
                                @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                @RequestParam(value = "followupType", required = true) String followupType,
                                @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病,3高糖】", defaultValue = "1")
                                @RequestParam(value = "followupClass", required = true) String followupClass,
                                @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                                @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                                @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                                @RequestParam(value = "plandate", required = false) String plandate,
                                @ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
                                    @RequestParam(value = "prescriptioncode", required = false) String prescriptioncode) {
        try {
            Followup followup = followUpService.startFollowup( id, followupNo, date, followupType, followupClass, followupManagerStatus,plandate,prescriptioncode);
            followUpService.getNotStartFollowup(getUID(), followup.getFollowupPlanDate());
            return write(200, "开始随访记录成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "开始随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增临时随访记录(返回ID)")
    @RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String addFollowup(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "date", value = "下次随访时间", defaultValue = "2016-12-15 20:00:00")
                              @RequestParam(value = "date", required = true) String date,
                              @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                              @RequestParam(value = "followupType", required = true) String followupType,
                              @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病 3高糖】", defaultValue = "1")
                              @RequestParam(value = "followupClass", required = true) String followupClass,
                              @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                              @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                              @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                              @RequestParam(value = "plandate", required = false) String plandate,
                              @ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
                              @RequestParam(value = "prescriptioncode", required = false) String prescriptioncode,
                              @ApiParam(name = "type", value = "随访类型", defaultValue = "0")
                              @RequestParam(value = "type", required = false) Integer type) {
        try {
            String response = followUpService.addFollowup(getUID(), patient, date, followupType, followupClass, followupManagerStatus,plandate,prescriptioncode,type);
            return write(200, "新增临时随访记录成功!", "data", response);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增临时随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("取消随访计划")
    @RequestMapping(value = "/cancelFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String cancelFollowupPlan(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.cancelFollowupPlan(id);
            return write(200, "取消随访计划成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "取消随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("完成随访记录")
    @RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String finishFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                 @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.finishFollowup(id);
            return write(200, "完成随访记录成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "完成随访记录失败!" + e.getMessage());
        }
    }
    /*********************************** 随访详情 *******************************************************************/
    @ApiOperation("获取随访信息")
    @RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                              @RequestParam(value = "id", required = true) String id) {
        try {
            Map<String, String> response = followUpService.getFollowup(id);
            try {
                String sql = "UPDATE `wlyy`.`wlyy_followup` SET `doctor_read_status`='1' WHERE (`id`='"+id+"') ";
                jdbcTemplate.update(sql);
            }catch (Exception e){
                e.printStackTrace();
            }
            return write(200, "获取随访信息成功!", "data", response);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访信息失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目列表")
    @RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getFollowupProject(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            List<Map<String, String>> list = followUpService.getFollowupProject(id);
            return write(200, "获取随访项目列表成功!", "data", list);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访项目列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目数据")
    @RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                         @RequestParam(value = "id", required = true) String id,
                                         @ApiParam(name = "followupProject", value = "随访项目")
                                         @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
            Map<String, String> maps = followUpService.getFollowupProjectData(id, followupProject);
            return write(200, "获取随访项目数据成功!", "data", maps);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "获取随访项目数据失败!");
        }
    }
    @ApiOperation("保存随访项目数据")
    @RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String saveFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                          @RequestParam(value = "id", required = true) String id,
                                          @ApiParam(name = "followupProject", value = "随访项目", defaultValue = "2")
                                          @RequestParam(value = "followupProject", required = false) String followupProject,
                                          @ApiParam(name = "followupProjectData", value = "随访项目数据", defaultValue = "{\"BLOOD_SUGAR\":\"33.3\",\"BLOOD_SUGAR_TYPE\":\"1\",\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
                                          @RequestParam(value = "followupProjectData", required = true) String followupProjectData) {
        try {
            followUpService.saveFollowupProjectData(id, followupProject, followupProjectData);
            return write(200, "保存随访项目数据成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }
    /*********************************** 电话随访 *****************************************************************/
    @ApiOperation("获取电话随访内容")
    @RequestMapping(value = "/getFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getFollowupPhone(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                   @RequestParam(value = "id", required = true) String id) {
        try {
            String response = followUpService.getFollowupPhone(id);
            return write(200, "获取电话随访内容成功!", "data", response);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取电话随访内容失败!" + e.getMessage());
        }
    }
    @ApiOperation("记录电话随访内容")
    @RequestMapping(value = "/saveFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String saveFollowupPhone(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                    @RequestParam(value = "id", required = true) String id,
                                    @ApiParam(name = "content", value = "电话随访内容", defaultValue = "")
                                    @RequestParam(value = "content", required = true) String content) {
        try {
            followUpService.saveFollowupPhone(id, content);
            return write(200, "记录电话随访内容成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "记录电话随访内容失败!" + e.getMessage());
        }
    }
    /*************************************** 上次随访 ********************************************/
    @ApiOperation("获取上次随访")
    @RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getLastFollowup(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "followClass", value = "随访类别", defaultValue = "1")
                                  @RequestParam(value = "followClass", required = true) String followClass) {
        try {
            Map<String, String> response = followUpService.getLastFollowup(getUID(), patient, followClass);
            return write(200, "获取上次随访成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取上次随访失败!" + e.getMessage());
        }
    }
//    @ApiOperation("复制上次随访数据")
//    @RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
//    public String copyFollowup(@ApiParam(name = "id", value = "本地随访ID", defaultValue = "")
//                               @RequestParam(value = "id", required = true) Long id,
//                               @ApiParam(name = "fromId", value = "拷贝随访记录ID", defaultValue = "")
//                               @RequestParam(value = "fromId", required = true) Long fromId) {
//        try {
//            followUpService.copyFollowup(id, fromId);
//
//            return write(200, "复制上次随访成功!");
//        } catch (Exception e) {
//            return invalidUserException(e, -1, "复制上次随访失败!" + e.getMessage());
//        }
//    }
    /*************************************** 发送随访计划消息 ********************************************/
    @ApiOperation("发送随访计划消息")
    @RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String sendMessage(@ApiParam(name = "date", value = "日期", defaultValue = "2017-01-05")
                              @RequestParam(value = "date", required = true) String date) {
        try {
            followUpService.sendMessage(date);
            return write(200, "发送随访计划消息成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "发送随访计划消息失败!" + e.getMessage());
        }
    }
    
    
//    @RequestMapping(value = "/checkfollowupcontent", method = RequestMethod.GET)
//    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
//    public String getfollowupcontent(
//            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
//            @RequestParam(value = "followupid", required = true) String followupid,
//            @ApiParam(name = "type", value = "支持传多个以英文逗号连接,drug为药品,1-9为随访分类", defaultValue = "")
//            @RequestParam(value = "type", required = true) String type){
//        try {
//            int count = followUpService.getfollowupcontent(followupid,type);
//            return write(200, "操作成功!","data",count);
//        }catch (Exception e){
//            //日志文件中记录异常信息
//            //返回接口异常信息处理结果
//            return errorResult(e);
//        }
//    }
    
//    @RequestMapping(value = "/checkfollowupcompleted", method = RequestMethod.GET)
//    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
//    public String checkfollowupcompleted(
//            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
//            @RequestParam(value = "followupid", required = true) String followupid){
//        try {
//            boolean completed = followUpService.checkfollowupcompleted(followupid);
//            return write(200, "操作成功!","data",completed);
//        }catch (Exception e){
//            //日志文件中记录异常信息
//            //返回接口异常信息处理结果
//            return errorResult(e);
//        }
//    }
    //=======================1.5.7上门访视相关接口====================================
    @RequestMapping(value = "/findFollowupByMonth",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取访视计划按月日历形式")
    public String findFollowupByMonth(@ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                          @RequestParam(value = "doctor", required = true) String doctor,
                                      @ApiParam(name = "patient", value = "居民")
                                          @RequestParam(value = "patient", required = false) String patient,
                                      @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割")
                                          @RequestParam(value = "followupClass", required = false) String followupClass,
                                      @ApiParam(name = "patientName", value = "居民姓名")
                                          @RequestParam(value = "patientName", required = false) String patientName,
                                      @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                          @RequestParam(value = "startDate", required = false) String startDate,
                                      @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                          @RequestParam(value = "endDate", required = false) String endDate,
                                      @ApiParam(name = "flag", value = "区分上门访视(1-是)")
                                          @RequestParam(value = "flag", required = false) String flag,
                                      @ApiParam(name = "type", value = "区分随访计划1、新增随访2、临时随访3、入户随访")
                                          @RequestParam(value = "type", required = false) Integer type,
                                      @ApiParam(name = "status", value = "随访状态")
                                          @RequestParam(value = "status", required = false) String status){
        try {
            return write(200, "操作成功!","data",followUpService.findFollowupByMonth(doctor,patient,followupClass,patientName,startDate,endDate,flag,type,status));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findFollowupList",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取访视列表形式")
    public String findFollowupList(@ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                       @RequestParam(value = "doctor", required = true) String doctor,
                                   @ApiParam(name = "patient", value = "居民")
                                       @RequestParam(value = "patient", required = false) String patient,
                                   @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割")
                                       @RequestParam(value = "followupClass", required = false) String followupClass,
                                   @ApiParam(name = "patientName", value = "居民姓名")
                                       @RequestParam(value = "patientName", required = false) String patientName,
                                   @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                       @RequestParam(value = "startDate", required = false) String startDate,
                                   @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                       @RequestParam(value = "endDate", required = false) String endDate,
                                   @ApiParam(name = "flag", value = "区分上门访视(1-是)")
                                       @RequestParam(value = "flag", required = false) String flag,
                                   @ApiParam(name = "type", value = "")
                                       @RequestParam(value = "type", required = false) Integer type,
                                   @ApiParam(name = "status", value = "随访状态")
                                       @RequestParam(value = "status", required = false) String status){
        try {
            return write(200, "操作成功!","data",followUpService.findFollowupList(null,doctor,patient,followupClass,patientName,startDate,endDate,flag,type,status));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findLabelListWithCount",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取随访标签列表带居民数")
    public String findLabelListWithCount(){
        try {
            return write(200, "操作成功!","data",followUpService.findLabelListWithCount());
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findFollowupLabel",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取随访标签列表")
    public String findFollowupLabel(){
        try {
            return write(200, "操作成功!","data",followUpService.findFollowupLabel());
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findFollowUpPatient",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取可随访居民列表")
    public String findFollowUpPatient(@ApiParam(name = "namekey", value = "居民姓名模糊", defaultValue = "")
                                      @RequestParam(value = "namekey", required = false)String namekey,
                                      @ApiParam(name = "labelCode", value = "标签code", defaultValue = "1")
                                      @RequestParam(value = "labelCode", required = false)String labelCode,
                                      @ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                      @RequestParam(value = "doctor", required = true)String doctor,
                                      @ApiParam(name = "page", value = "页数,1开始", defaultValue = "1")
                                      @RequestParam(value = "page", required = true)Integer page,
                                      @ApiParam(name = "size", value = "每页大小", defaultValue = "10")
                                      @RequestParam(value = "size", required = true)Integer size)throws Exception {
        try {
            return write(200, "操作成功!","data",followUpService.findFollowUpPatient(namekey,doctor,labelCode,page,size));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findPatientInfo",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取居民单条信息")
    public String findPatientInfo(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                                  @RequestParam(value = "patient", required = true)String patient) {
        try {
            return write(200, "操作成功!","data",followUpService.findPatientInfo(patient));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findPatientFollowList",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取居民随访列表")
    public String findPatientFollowList(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                                        @RequestParam(value = "patient", required = true)String patient,
                                        @ApiParam(name = "doctor", value = "医生code", defaultValue = "")
                                        @RequestParam(value = "doctor", required = true)String doctor){
        try {
            return write(200, "操作成功!","data",followUpService.findPatientFollowList(patient,doctor));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/saveFollowup",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("保存随访访视")
    public String saveFollowup(@ApiParam(name = "jsonFollowup", value = "创建访视json", defaultValue = "")
                               @RequestParam(value = "jsonFollowup", required = true)String jsonFollowup){
        try {
            return write(200, "操作成功!","data",followUpService.saveFollowup(jsonFollowup));
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/delFollowup",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("删除随访访视")
    public String delFollowup(@ApiParam(name = "followupId", value = "随访ID", defaultValue = "")
                               @RequestParam(value = "followupId", required = true)Long followupId)throws Exception {
        try {
            Followup followup = followUpService.delFollowup(followupId);
            followUpService.getNotStartFollowup(getUID(), followup.getFollowupPlanDate());
            return write(200, "操作成功!","data", true);
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findFollowupInfo",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取随访详情")
    public String findFollowupInfo(@ApiParam(name = "followupId", value = "随访ID", defaultValue = "")
                                   @RequestParam(value = "followupId", required = true)Long followupId) {
        try {
            return write(200, "操作成功!","data",followUpService.findFollowupInfo(followupId));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/saveFollowupSign",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("签到")
    public String saveFollowupSign(@ApiParam(name = "jsonSign", value = "签到", defaultValue = "")
                                   @RequestParam(value = "jsonSign", required = true)String jsonSign)throws Exception {
        try {
            return write(200, "操作成功!","data",followUpService.saveFollowupSign(jsonSign));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/updateFollowupSign",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("更新签到")
    public String updateFollowupSign(@ApiParam(name = "jsonSign", value = "签到", defaultValue = "")
                                     @RequestParam(value = "jsonSign", required = true)String jsonSign)throws Exception {
        try {
            return write(200, "操作成功!","data",followUpService.updateFollowupSign(jsonSign));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/urlAnalysis",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("门牌解析上门地址")
    public String urlAnalysis(@ApiParam(name = "url", value = "地址解析", defaultValue = "")
                              @RequestParam(value = "url", required = true)String url)throws Exception {
        try {
            return write(200, "操作成功!","data",followUpService.urlAnalysis(url));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/findByFollowupId",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("签约详情")
    public String findByFollowupId(@ApiParam(name = "followupId", value = "签到", defaultValue = "")
                                   @RequestParam(value = "followupId", required = true)Long followupId) {
        try {
            return write(200, "操作成功!","data",followUpService.findByFollowupId(followupId));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/isFirstTimeFollowup",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("判断居民该类别随访是否为第一次")
    public String isFirstTimeFollowup(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @ApiParam(name = "followupClass", value = "随访类别", defaultValue = "")
                                      @RequestParam(value = "followupClass", required = true)String followupClass,
                                      @ApiParam(name = "followupId", value = "随访类别", defaultValue = "")
                                      @RequestParam(value = "followupId", required = true)Integer followupId) {
        try {
            return write(200, "操作成功!","data",followUpService.isFirstTimeFollowup(getUID(),patient,followupClass,followupId));
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return errorResult(e);
        }
    }
    //=======================end ==================================================
    @ApiOperation("保存全部随访表单数据")
    @RequestMapping(value = "/saveAllFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String saveAllFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID")
                                                 @RequestParam(value = "id", required = true) String id,
                                             @ApiParam(name = "followupNo", value = "随访记录编码")
                                             @RequestParam(value = "followupNo", required = false) String followupNo,
                                             @ApiParam(name = "date", value = "随访时间", defaultValue = "2016-12-14 20:00:00")
                                                 @RequestParam(value = "date", required = false) String date,
                                             @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                                 @RequestParam(value = "followupType", required = false) String followupType,
                                             @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病,3高糖】", defaultValue = "1")
                                                 @RequestParam(value = "followupClass", required = false) String followupClass,
                                             @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                                                 @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                                             @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                                                 @RequestParam(value = "plandate", required = false) String plandate,
                                             @ApiParam(name = "prescriptioncode", value = "续方CODE")
                                                 @RequestParam(value = "prescriptioncode", required = false) String prescriptioncode,
                                          @ApiParam(name = "followupProjectData", value = "随访项目数据", defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
                                          @RequestParam(value = "followupProjectData", required = true) String followupProjectData) {
        try {
            JSONObject jsonObject = new JSONObject(followupProjectData);
            Followup followup = followUpService.startFollowup(id, followupNo, date, followupType, followupClass, followupManagerStatus, plandate, prescriptioncode);
            followUpService.finishFollowup(id);
//            followUpService.saveAllFollowupProjectData(id, jsonObject.getJSONObject("followupProjectData").toString());
            followupDrugsService.saveFollowupDrugs(id,jsonObject.getJSONArray("drugsData").toString());
            return write(200, "保存随访项目数据成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
        } catch (Exception e) {
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }
}

+ 78 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowupDrugsController.java

@ -0,0 +1,78 @@
package com.yihu.jw.hospital.module.followup.controller;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.followup.service.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.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")
@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());
		}
	}
//	@ApiOperation("获取随访类别用药列表")
//	@RequestMapping(value = "/getFollowupClassDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//	public String getFollowupClassDrugs(@ApiParam(name="followupClass",value="随访类别:1.高血压 2.糖尿病",defaultValue = "")
//									@RequestParam(value="followupClass",required = true) String followupClass)
//	{
//		try {
//			List<DmDrugsGroupItem> list = followupDrugsService.getFollowupClassDrugs(followupClass);
//
//			return write(200, "获取随访类别用药列表成功!","data",list);
//		} catch (Exception e) {
//			return invalidUserException(e, -1, "获取随访类别用药列表失败!"+e.getMessage());
//		}
//	}
}

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

@ -6,9 +6,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServiceItemPlanDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.followup.*;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.entity.followup.FollowupContent;
import com.yihu.jw.entity.followup.FollowupMapping;
import com.yihu.jw.entity.followup.FollowupSign;
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
@ -570,6 +574,38 @@ public class FollowUpService {
        return null;
    }
    //添加康复计划随访
    public Followup addRehabilatationFollowup(ServiceItemPlanDO itemPlanDO)  {
        try {
            Followup followup = new Followup();
            followup.setFollowupType("2");
            Date date = DateUtil.strToDate(itemPlanDO.getPlanTime());
            followup.setFollowupDate(date);
            followup.setFollowupPlanDate(date);
            followup.setDoctorCode(itemPlanDO.getDoctor());
            followup.setDoctorName(itemPlanDO.getDoctorName());
//        followup.setOrgCode(doctor.getHospital());
//        followup.setOrgName(doctor.getHospitalName());
            followup.setPatientCode(itemPlanDO.getPatient());
            BasePatientDO patient = patientDao.findById(itemPlanDO.getPatient()).orElse(null);
            followup.setPatientName(patient.getName());
            followup.setIdcard(patient.getIdcard());
            followup.setDataFrom("2");//数据来源 1基卫 2APP
            followup.setStatus("2");//状态 0取消 1已完成 2未开始 3进行中
            followup.setCreateTime(new Date());
            followup.setCreater(itemPlanDO.getDoctor());
            followup.setFollowupClass("21");
            followup.setType(1);
            followup.setSignType(2);
            //新增签约保存CODE
            followup = followupDao.save(followup);
            return followup;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 新增随访计划(单个)
     */
@ -579,9 +615,6 @@ public class FollowUpService {
        if (patient == null) {
            throw new RuntimeException("获取不到用户信息!");
        }
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        Long adminCodeId = 0L;
        //获取医生信息
        BaseDoctorDO doctor = doctorDao.findById(data.getString("doctor")).orElse(null);
        if (doctor == null) {
@ -593,7 +626,7 @@ public class FollowUpService {
        Date date = DateUtil.strToDate(data.getString("date"));
        followup.setFollowupDate(date);
        followup.setFollowupPlanDate(date);
//        followup.setDoctorCode(doctor.getCode());
        followup.setDoctorCode(doctor.getId());
        followup.setDoctorName(doctor.getName());
//        followup.setOrgCode(doctor.getHospital());
//        followup.setOrgName(doctor.getHospitalName());
@ -604,32 +637,12 @@ public class FollowUpService {
        followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
        followup.setCreateTime(new Date());
        followup.setCreater(doctorCode);
        if (!data.getString("followupClass").toString().equalsIgnoreCase("10")) {
            if (signFamily == null) {
                throw new RuntimeException("非家签居民仅支持创建体温异常随访");
            } else {
                adminCodeId = signFamily.getAdminTeamId();
            }
        }
        followup.setFollowupClass(data.getString("followupClass"));
        followup.setType(Integer.parseInt(data.get("type1").toString()));
        followup.setAdminTeamCode(adminCodeId);
//        followup.setAdminTeamCode(adminCodeId);
        followup.setSignType(2);
        //获取随访医生角色类型
//        List<DoctorMapping> doctorMapping = doctorMappingDao.findListByDoctorCode(doctorCode);
//        if(doctorMapping.size() ==1 && StringUtils.isNotBlank(doctorMapping.get(0).getJwDoctorWorkType())){
//            followup.setJwDoctorWorkType(doctorMapping.get(0).getJwDoctorWorkType());
//        }
        //新增签约保存CODE
//        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        followup = followupDao.save(followup);
//        远程2.0接口,参数在改改
//        rehabilitationManageService.updateRelationCodeByDetailId(data.getString("id"),followup.getId()+"");
//        rehabilitationManageService.saveRehabilitationOperateRecord(dataJson);
        return followup;
    }

+ 98 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowupDrugsService.java

@ -0,0 +1,98 @@
package com.yihu.jw.hospital.module.followup.service;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.followup.FollowupDrugs;
import com.yihu.jw.hospital.module.followup.dao.FollowupDrugsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.*;
/**
 * 随访用药服务
 * @author hzp add 2016-12-08
 *
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowupDrugsService {
	@Autowired
	private FollowupDrugsDao followupDrugsDao;
	@Autowired
	private ObjectMapper objectMapper;
	
	@Autowired
	private FollowUpService followUpService;
	private String drugsProject = "6";
	/**
	 * 获取面访用药数据
	 */
	public Map<String,Object> getFollowupDrugs(String id) throws Exception
	{
		Map<String,Object> re = new HashMap<>();
		
		//2017-11-16 修改为从ES获取--huangwenjie
//		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.saveAll(newList);
		}
	}
	/*********************************** 疾病用药 *****************************************************************/
	/**
	 *获取疾病用药
	 */
//	public List<DmDrugsGroupItem> getFollowupClassDrugs(String followupClass) throws Exception {
//		return dmDrugsGroupItemDao.findByFollowupClass(followupClass);
//	}
}

+ 26 - 41
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/PatientRehabilitationManageController.java

@ -12,6 +12,7 @@ import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageSe
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationPlanService;
import com.yihu.jw.hospital.prescription.service.DrugsPlanService;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -316,52 +317,36 @@ public class PatientRehabilitationManageController extends EnvelopRestEndpoint {
    }
    /**
     * w;yy2.0的接口
     */
//    @RequestMapping(value = "calendarPlanDetailList", method = RequestMethod.GET)
//    @ApiOperation("康复管理-康复计划按列表展示-限定频次")
//    public String calendarPlanDetailList(
//            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true) @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
//            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true) @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
//            @ApiParam(name = "planId", value = "计划id", required = true) @RequestParam(value = "planId", required = true)String planId,
//            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)", required = false) @RequestParam(value = "searchTask", required = false)Integer searchTask,
//            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false) @RequestParam(value = "doctorCode", required = false)String doctorCode,
//            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false) @RequestParam(value = "status", required = false)Integer status,
//            @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false) @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor
//    ){
//        try {
//            if(!StringUtils.isNotEmpty(doctorCode)){
//                doctorCode = getRepUID();
//            }
//            JSONArray result = rehabilitationManageService.calendarPlanDetailListWithTaskExecutor(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode,taskExecutor);
//            return write(200, "获取成功", "data", result);
//        }  catch (Exception e) {
//            return error(-1, e.getMessage());
//        }
//    }
    /**
     * i健康接口
     */
    @RequestMapping(value = "calendarPlanDetailList", method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划按列表展示")
    public String calendarPlanDetailList(
            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true) @RequestParam(value = "executeStartTime", required = true) String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true) @RequestParam(value = "executeEndTime", required = true) String executeEndTime,
            @ApiParam(name = "planId", value = "计划id", required = true) @RequestParam(value = "planId", required = true) String planId,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、复诊,4、随访)", required = false) @RequestParam(value = "searchTask", required = false) Integer searchTask,
            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false) @RequestParam(value = "status", required = false) Integer status
    ) {
    @ApiOperation("康复管理-康复计划按列表展示-限定频次")
    public Envelop calendarPlanDetailList(
            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
            @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
            @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
            @ApiParam(name = "planId", value = "计划id", required = true)
            @RequestParam(value = "planId", required = true)String planId,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊 8全部)", required = false)
            @RequestParam(value = "searchTask", required = false)Integer searchTask,
            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
            @RequestParam(value = "doctorCode", required = false)String doctorCode,
            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
            @RequestParam(value = "status", required = false)Integer status,
            @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
            @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor
    ){
        try {
            JSONArray result = rehabilitationManageService.calendarPlanDetailList(executeStartTime, executeEndTime, planId, searchTask, status, null);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            return error(-1, "请求失败");
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getRepUID();
            }
            return rehabilitationManageService.calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor);
        }  catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
//    @RequestMapping(value = "calendarPlanDetailItems", method = RequestMethod.GET)
//    @ApiOperation("康复管理-康复计划服务项目按列表展示")
//    public String calendarPlanDetailItems(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)

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

@ -3,10 +3,10 @@ package com.yihu.jw.hospital.module.rehabilitation.controller;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationOperateRecordsDao;
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
import com.yihu.jw.hospital.module.rehabilitation.service.SynchronizePatientService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -23,7 +23,6 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Map;
//import org.springframework.cloud.sleuth.Tracer;
/**
 * Created by 刘文彬 on 2018/8/16.
@ -35,12 +34,53 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationManageService rehabilitationManageService;
    //    @Autowired
//    private Tracer tracer;
    @Autowired
    private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao;
    @Autowired
    SynchronizePatientService synchronizePatientService;
    private SynchronizePatientService synchronizePatientService;
    @GetMapping(value = "rehabilitationDetailInfo")
    @ApiOperation("康复计划服务项列表")
    public Envelop rehabilitationDetailInfo(
            @ApiParam(name = "planId", value = "康复计划id", required = true)
            @RequestParam(value = "planId", required = true) String planId) {
        try {
            return ListEnvelop.getSuccess("查询成功",rehabilitationManageService.rehabilitationDetailInfo(planId));
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
    @GetMapping(value = "findServiceItemPlanDetail")
    @ApiOperation("执行计划详情")
    public Envelop findServiceItemPlanDetail(
            @ApiParam(name = "itemPlanId", value = "执行计划id", required = true)
            @RequestParam(value = "itemPlanId", required = true) String itemPlanId) {
        try {
            return ObjEnvelop.getSuccess("查询成功",rehabilitationManageService.findServiceItemPlanDetail(itemPlanId));
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
    @GetMapping(value = "findGuidanceMessageDetail")
    @ApiOperation("查询指导留言详情")
    public Envelop findGuidanceMessageDetail(
            @ApiParam(name = "itemPlanId", value = "执行计划id", required = true)
            @RequestParam(value = "itemPlanId", required = true) String itemPlanId) {
        try {
            return ObjEnvelop.getSuccess("查询成功",rehabilitationManageService.findGuidanceMessageDetail(itemPlanId));
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
    @PostMapping(value = "assignExecutor")
    @ApiOperation("计划负责人分配执行人")
@ -72,7 +112,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
            }
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
            return MixEnvelop.getError("操作成功");
        }
    }
@ -94,7 +134,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
            return MixEnvelop.getError("获取失败");
        }
    }
@ -109,7 +149,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError("获取失败");
        }
    }
@ -128,7 +168,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
            return rehabilitationManageService.calendarPlanDetail(executeStartTime, executeEndTime, planId, searchTask, status, doctorCode, taskExecutor);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError("获取失败");
        }
    }
@ -139,7 +179,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)") @RequestParam(value = "executeStartTime", required = false) String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)") @RequestParam(value = "executeEndTime", required = false) String executeEndTime,
            @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true) @RequestParam(value = "planId", required = true) String planId,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)") @RequestParam(value = "searchTask", required = false) Integer searchTask,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊 8所有)") @RequestParam(value = "searchTask", required = false) Integer searchTask,
            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)") @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "taskExecutor", value = "任务执行人:0全部;1我的任务:2他人任务", required = false) @RequestParam(value = "taskExecutor", required = false, defaultValue = "0") String taskExecutor
@ -206,18 +246,18 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
    @ApiOperation(value = "康复管理-保存指导留言")
    public Envelop saveGuidanceMessage(
            @ApiParam(name = "messageId", value = "消息id", required = true) @RequestParam(value = "messageId", required = true) String messageId,
            @ApiParam(name = "patientCode", value = "居民code", required = false) @RequestParam(value = "patientCode", required = false) String patientCode,
            @ApiParam(name = "imgs", value = "附件", required = false) @RequestParam(value = "imgs", required = false) String imgs,
            @ApiParam(name = "doctorCode", value = "医生code", required = true) @RequestParam(value = "doctorCode", required = true) String doctorCode,
            @ApiParam(name = "doctorType", value = "医生类型(1、专科医生,2、家庭医生)", required = true) @RequestParam(value = "doctorType", required = true) Integer doctorType,
            @ApiParam(name = "doctorType", value = "医生类型(1、专科医生)", required = true) @RequestParam(value = "doctorType", required = true) Integer doctorType,
            @ApiParam(name = "content", value = "聊天内容", required = true) @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "planDetailId", value = "服务项目id", required = true) @RequestParam(value = "planDetailId", required = true) String planDetailId,
            @ApiParam(name = "itemPlanId", value = "服务项目执行计划id", required = true) @RequestParam(value = "itemPlanId", required = true) String itemPlanId,
            @ApiParam(name = "contentType", value = "内容类型(1,6,8 - 文本, 2,9- 图片, 3 - 语音, 4-文章, 5,7系统消息。12-语音 18-居民名片, 19-聊天记录)", required = true)
            @RequestParam(value = "contentType", required = true) Integer contentType) {
        try {
            return rehabilitationManageService.saveGuidanceMessage(messageId, doctorCode, doctorType, content, planDetailId, contentType);
            return rehabilitationManageService.saveGuidanceMessage(messageId, doctorCode, doctorType, content,imgs, itemPlanId, contentType);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
            return Envelop.getError("操作失败");
        }
    }
@ -416,7 +456,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.planSchedule)
    @GetMapping(value = "planSchedule")
    @ApiOperation(value = "康复管理-计划总进度")
    public ObjEnvelop planSchedule(
            @ApiParam(name = "planId", value = "计划id", required = true) @RequestParam(value = "planId", required = true) String planId
@ -425,8 +465,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
            return rehabilitationManageService.planSchedule(planId);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError("查询失败");
        }
    }
@ -438,7 +477,7 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
            return rehabilitationManageService.planListByPatient(patientCode);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError("查询失败");
        }
    }

+ 2 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/dao/RehabilitationDetailDao.java

@ -27,8 +27,8 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    @Query("select count(1) from RehabilitationDetailDO where status =?1 and planId=?2 and executeTime>=?3 and executeTime<=?4 ")
    Integer completenessCount(Integer status, String planId, Date executeStartTime, Date executeEndTime);
    @Query("select d from RehabilitationDetailDO d where d.planId=?1 order by d.executeTime desc")
    List<RehabilitationDetailDO> getAllRehabilitationDetail(String programId);
    @Query("select d from RehabilitationDetailDO d where d.planId=?1 order by d.hospitalServiceItemId")
    List<RehabilitationDetailDO> getAllRehabilitationDetail(String planId);
    @Query("select d from RehabilitationDetailDO d where d.executeTime<=?1 and d.executeTime>=?2 and d.planId=?3")
    List<RehabilitationDetailDO> findByPlanId(Date executeStartTime, Date executeEndTime, String planId);

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

@ -8,11 +8,13 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServiceItemPlanDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.entity.specialist.RehabilitationServiceItemDO;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.hospital.module.door.dao.ServiceItemPlanDao;
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
import com.yihu.jw.hospital.module.rehabilitation.dao.*;
import com.yihu.jw.hospital.module.specialist.dao.PatientDiseaseServerDao;
import com.yihu.jw.hospital.module.specialist.dao.PatientMedicalRecordsRehabilitationDao;
@ -51,8 +53,6 @@ import java.util.stream.Collectors;
@Transactional
public class RehabilitationManageService {
    @Value("${basedb.name}")
    private String basedb;
    @Value("${im.data_base_name}")
    private String imDBName;
@ -90,6 +90,8 @@ public class RehabilitationManageService {
    private PatientRehabilitationPlanLogDao patientRehabilitationPlanLogDao;
    @Autowired
    private ServiceItemPlanDao serviceItemPlanDao;
    @Autowired
    private FollowUpService followUpService;
    //添加康复计划日志
    public void addPlanLog(String planId,String doctorCode,String doctorName){
@ -186,6 +188,12 @@ public class RehabilitationManageService {
            itemPlanDO.setPlanDetailId(planDetailId);
            itemPlanDO.setDoctor(doctor);
            itemPlanDO.setDoctorName(doctorName);
            if("6".equals(relationType)){
                Followup followup = followUpService.addRehabilatationFollowup(itemPlanDO);
                if(followup!=null){
                    itemPlanDO.setRelationCode(followup.getId()+"");
                }
            }
            planDOList.add(itemPlanDO);
        }
        return planDOList;
@ -367,7 +375,7 @@ public class RehabilitationManageService {
                resultMap.put("id", one.get("id"));
                resultMap.put("status", one.get("status"));//康复计划状态
                //健康情况
                String healthyConditionSql = " select  label_name,label from " + basedb + ".wlyy_sign_patient_label_info where status=1 and patient='" + one.get("patient") + "' and label_type=8";
                String healthyConditionSql = " select  label_name,label from wlyy_sign_patient_label_info where status=1 and patient='" + one.get("patient") + "' and label_type=8";
                List<Map<String, Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
                String healthyCondition = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label_name") + "" : "";
                String healthyConditionType = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label") + "" : "";
@ -434,14 +442,16 @@ public class RehabilitationManageService {
            Map<String, Object> resultMap = new HashMap<>();
            Integer isOperator = 0;
            resultMap.put("patientCode", patientCode);//居民code
            String healthyConditionSql = " select  label_name,label from " + basedb + ".wlyy_sign_patient_label_info where status=1 and patient='" + patientCode + "' and label_type=8";
            String healthyConditionSql = " select  label_name,label from wlyy_sign_patient_label_info where status=1 and patient='" + patientCode + "' and label_type=8";
            List<Map<String, Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
            String healthyCondition = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label_name") + "" : "";
            String healthyConditionType = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label") + "" : "";
            resultMap.put("healthyCondition", healthyCondition);
            resultMap.put("healthyConditionType", healthyConditionType);
            //专科医生
            String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from wlyy_specialist_patient_relation r left join " + basedb + ".wlyy_admin_team t on r.team_code=t.id left join " + basedb + ".dm_hospital h on t.org_code=h.code where r.sign_status ='1' and r.status in('0','1') and r.patient='" + patientCode + "' and r.doctor='" + doctorCode + "'";
            String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName " +
                    "from wlyy_specialist_patient_relation r left join wlyy_admin_team t on r.team_code=t.id left join " +
                    "dm_hospital h on t.org_code=h.code where r.sign_status ='1' and r.status in('0','1') and r.patient='" + patientCode + "' and r.doctor='" + doctorCode + "'";
            specialistRelationSql = TransforSqlUtl.specialistPatientRelationAll2(specialistRelationSql);
            List<Map<String, Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
            Map<String, Object> specialistMap = specialistRelationList.get(0);
@ -459,7 +469,8 @@ public class RehabilitationManageService {
            resultMap.put("specialistFinishItemCount", specialistFinishCount1 - specialistUnfinishCount1 + specialistFinishCount2 - specialistUnfinishCount2);//完成项目
            resultMap.put("specialistServiceRecordCount", specialistServiceCount1 + specialistServiceCount2);//服务次数
            //家庭医生(包括全科医生、健管师)
            String signFamilySql = "SELECT f.*,t.name as teamName FROM " + basedb + ".wlyy_sign_family f LEFT JOIN " + basedb + ".wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='" + patientCode + "'";
            String signFamilySql = "SELECT f.*,t.name as teamName FROM wlyy_sign_family f LEFT JOIN " +
                    "wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='" + patientCode + "'";
            List<Map<String, Object>> signFamilyList = jdbcTemplate.queryForList(signFamilySql);
            if (signFamilyList != null && signFamilyList.size() > 0) {
                Map<String, Object> signFamilyMap = signFamilyList.get(0);
@ -490,7 +501,7 @@ public class RehabilitationManageService {
                resultMap.put("patientName", signFamilyMap.get("patientName"));
            }
            //疾病类型
            String diseaseSql = " select s.* from " + basedb + ".wlyy_patient_disease_server s where s.del=1 and s.patient='" + patientCode + "' and s.specialist_relation_code='" + specialistMap.get("id") + "' ";
            String diseaseSql = " select s.* from wlyy_patient_disease_server s where s.del=1 and s.patient='" + patientCode + "' and s.specialist_relation_code='" + specialistMap.get("id") + "' ";
            List<Map<String, Object>> diseaseList = jdbcTemplate.queryForList(diseaseSql);
            List<String> disease = new ArrayList<>();
            for (Map<String, Object> one2 : diseaseList) {
@ -698,111 +709,70 @@ public class RehabilitationManageService {
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success, map);
    }
    /**
     * 康复管理-康复计划按列表展示
     *
     * @param executeStartTime
     * @param executeEndTime
     * @param planId
     * @param searchTask
     * @param status
     * @param doctorCode
     * @return
     * @throws Exception
     */
    public JSONArray calendarPlanDetailList(String executeStartTime, String executeEndTime, String planId, Integer searchTask, Integer status, String doctorCode) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("executeStartTime", executeStartTime);
        param.put("executeEndTime", executeEndTime);
        param.put("planId", planId);
        param.put("searchTask", searchTask);
        param.put("status", status);
        param.put("doctorCode", doctorCode);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, "0");
        org.json.JSONObject result = new org.json.JSONObject(objEnvelop);
        if (result.getInt("status") == 200) {
            return result.getJSONArray("obj");
        }
        throw new Exception("请求失败!");
    }
    /**
     * 日历列表
     *
     * @param planId       计划id
     * @param searchTask   快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
     * @param searchTask   快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)
     * @param status       任务状态(0未完成,1已完成,2已预约)
     * @param doctorCode   登陆医生
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetailList(String planId, Integer searchTask, Integer status, String doctorCode, String executeStartTime, String executeEndTime, String taskExecutor) {
    public ObjEnvelop calendarPlanDetailList(String planId, Integer searchTask, Integer status, String doctorCode,
                                             String executeStartTime, String executeEndTime, String taskExecutor) {
        String[] planIdlist = planId.split(",");
        StringBuilder planCondition = new StringBuilder();
        planCondition.append("'" + planIdlist[0] + "'");
        for (int i = 1; i < planIdlist.length; i++) {
            planCondition.append(",'" + planIdlist[i] + "'");
        }
        String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,IF(d.followup_detail_type=1,'社区随访(厦心)',i.name) name,1 as flag from wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  " +
                " where  d.plan_id in (" + planCondition + " )AND  d.execute_time IS NOT NULL  and d.execute_time <>'' ";
        String sql = " select d.* from base_service_item_plan d  where d.plan_id in (" + planCondition + " ) ";
        if (searchTask != null) {
            if (searchTask == 8) {//
                if (StringUtils.isNotBlank(doctorCode)) {
                    sql += " and d.doctor='" + doctorCode + "' ";
                }
                //sql+=" and i.code="+searchTask+" " ;
            } else {
                sql += " and i.code=" + searchTask + " ";
            }/*else if(searchTask==5){
                sql+=" and i.reserve=1 " ;
            }*/
                sql += " and d.relation_type='" + searchTask + "' ";
            }
        }
        if (taskExecutor.equals("1")) { //我的任务
        if ("1".equals(taskExecutor)) { //我的任务
            sql += "and d.doctor='" + doctorCode + "' ";
        }
        if (taskExecutor.equals("2")) {//他人任务
        if ("2".equals(taskExecutor)) {//他人任务
            sql += "and d.doctor <>'" + doctorCode + "' ";
        }
        if (StringUtils.isNoneBlank(executeEndTime) && StringUtils.isNoneBlank(executeStartTime)) {
            sql += "and d.execute_time>='" + executeStartTime + "' and d.execute_time<='" + executeEndTime + "' ";
            sql += "and d.plan_time>='" + executeStartTime + "' and d.plan_time<='" + executeEndTime + " 23:59:59' ";
        }
        if (status != null) {
            sql += "and d.status=" + status;
        }
        sql += "  order by d.execute_time desc ";
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
        List<Map<String, Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
        String planPatientSql = " SELECT p.patient FROM wlyy_patient_rehabilitation_plan p " +
                "INNER JOIN wlyy.wlyy_sign_family f ON p.patient = f.patient  WHERE p.id in (" + planCondition + " ) " +
                "AND f.`status` = 1 AND f.expenses_status = 1 AND  f.doctor = '" + doctorCode + "' ";
        List<Map<String, Object>> patientCodeList = jdbcTemplate.queryForList(planPatientSql);
        List<Map<String, Object>> list = null;
        if (patientCodeList.size() > 0 && null != searchTask) {
            String patient = patientCodeList.get(0).get("patient").toString();
            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 " +
                        "  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 " +
                        " 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);
            }
            if (list != null && list.size() > 0) {
                rehabilitationDetailList.addAll(list);
            }
        }
            sql += "and d.status='" + status+"' ";
        }
        sql += "  order by d.plan_time desc ";
        List<ServiceItemPlanDO> rehabilitationDetailList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
//        if (rehabilitationDetailList.size() > 0 && null != searchTask) {
//            String patient = rehabilitationDetailList.get(0).getPatient();
//            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_prescription pr  LEFT JOIN base_patient p ON pr.patient = p.id WHERE " +
//                        "  1 = 1  AND pr.STATUS = '100' AND p.id= '" + 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.dict_value AS `value`, wf.followup_type  followupType,wf.id AS id, 6 AS code,2 as flag FROM  wlyy_followup wf " +
//                        " LEFT JOIN wlyy_hospital_sys_dict sd ON wf.followup_type = sd.dict_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);
//            }
//            if (list != null && list.size() > 0) {
//                rehabilitationDetailList.addAll(list);
//            }
//        }
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success, rehabilitationDetailList);
    }
@ -1376,18 +1346,82 @@ public class RehabilitationManageService {
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultMap);
    }
    //康复计划服务项列表
    public List<RehabilitationDetailDO> rehabilitationDetailInfo(String planId){
        List<RehabilitationDetailDO> detailDOList = rehabilitationDetailDao.getAllRehabilitationDetail(planId);
        List<RehabilitationServiceItemDO> itemDOList = serviceItemDao.findList();
        Map<String, String> serviceItemMap = itemDOList.stream().collect(Collectors.toMap(RehabilitationServiceItemDO::getCode, RehabilitationServiceItemDO::getName));
        List<ServiceItemPlanDO> planDOList = serviceItemPlanDao.findByPlanId(planId);
        Map<String,List<ServiceItemPlanDO>> planListMap = planDOList.stream().collect(Collectors.groupingBy(ServiceItemPlanDO::getRelationType));
        for (RehabilitationDetailDO detailDO:detailDOList){
            String key = detailDO.getHospitalServiceItemId();
            List<ServiceItemPlanDO> planDOS = planListMap.get(key);
            String completeTime = "";
            String planTime = "";
            int total = planDOS.size();
            int complete = 0;
            for (ServiceItemPlanDO planDO:planDOS){
                if("1".equals(planDO.getStatus())){
                    complete++;
                    if(completeTime.compareTo(planDO.getCompleteTime())<0){
                        completeTime = planDO.getCompleteTime();
                    }
                }else {
                    if("".equals(planTime)){
                        planTime = planDO.getPlanTime();
                    }else if(planTime.compareTo(planDO.getPlanTime())>0){
                        planTime = planDO.getPlanTime();
                    }
                }
            }
            detailDO.setTotalNum(total);
            detailDO.setFinishNum(complete);
            detailDO.setCompleteTime(completeTime);
            detailDO.setPlanTime(planTime);
            detailDO.setName(serviceItemMap.get(key));
        }
        return detailDOList;
    }
    //执行计划详情
    public ServiceItemPlanDO findServiceItemPlanDetail(String id){
        ServiceItemPlanDO planDO = serviceItemPlanDao.findById(id).orElse(null);
        if(planDO!=null){
            String sql = "SELECT content from wlyy_guidance_message_log WHERE plan_detail_id ='"+id+"' LIMIT 1";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            planDO.setGuidanceMessage(list.get(0).get("content")+"");
        }
        if("1".equals(planDO.getStatus())){
            String relationCode = planDO.getRelationCode();
            if("6".equals(planDO.getRelationType())&&StringUtils.isNotBlank(relationCode)){
                Followup followup = followUpService.findFollowupInfo(Long.parseLong(relationCode));
                planDO.setFollowup(followup);
            }
        }
        return planDO;
    }
    //查询指导留言详情
    public GuidanceMessageLogDO findGuidanceMessageDetail(String itemPlanId){
        String sql = "SELECT * from wlyy_guidance_message_log WHERE plan_detail_id ='"+itemPlanId+"' LIMIT 1";
        List<GuidanceMessageLogDO> logDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(GuidanceMessageLogDO.class));
        if(logDOS.size()>0){
            logDOS.get(0);
        }
        return null;
    }
    /**
     * 保存康复管理指导留言信息
     *
     * @param messageId
     * @param doctor
     * @param doctorType 1、专科医生,2、家庭医生
     * @param doctorType 1、专科医生,2、计划负责人
     */
    @Transactional
    public Envelop saveGuidanceMessage(String messageId, String doctor, Integer doctorType, String content, String planDetailId, Integer contentType) throws Exception {
        List<String> patientList = rehabilitationDetailDao.findPatientById(planDetailId);
        String patient = patientList.size() > 0 ? patientList.get(0) : "";
    public Envelop saveGuidanceMessage(String messageId, String doctor, Integer doctorType, String content,String imgs,
                                       String planDetailId, Integer contentType) {
        GuidanceMessageLogDO guidanceMessageLogDO = new GuidanceMessageLogDO();
        guidanceMessageLogDO.setMessageId(messageId);
        guidanceMessageLogDO.setPlanDetailId(planDetailId);
@ -1395,25 +1429,11 @@ public class RehabilitationManageService {
        guidanceMessageLogDO.setDoctor(doctor);
        guidanceMessageLogDO.setContentType(contentType);
        guidanceMessageLogDO.setDoctorType(doctorType);
        Integer adminTeamCode = null;
        String doctorName = null;
        if (doctorType == 1) {
            SpecialistPatientRelationDO specialistPatientRelationDO = specialistPatientRelationDao.findByPatientAndDoctor(doctor, patient);
            adminTeamCode = specialistPatientRelationDO.getTeamCode();
            doctorName = specialistPatientRelationDO.getDoctorName();
        } else if (doctorType == 2) {
            String signFamilySql = " select f.* from " + basedb + ".wlyy_sign_family f where f.status=1 and f.expenses_status='1' and f.patient='" + patient + "'";
            List<Map<String, Object>> signFamily = jdbcTemplate.queryForList(signFamilySql);
            adminTeamCode = (Integer) signFamily.get(0).get("admin_team_code");
            doctorName = signFamily.get(0).get("doctor_name").toString();
        }
        String adminTeamSql = " select t.* from " + basedb + ".wlyy_admin_team t where t.available=1 and t.id=" + adminTeamCode;
        List<Map<String, Object>> adminTeam = jdbcTemplate.queryForList(adminTeamSql);
        String adminTeamName = adminTeam.get(0).get("name").toString();
        guidanceMessageLogDO.setAdminTeamCode(adminTeamCode);
        guidanceMessageLogDO.setAdminTeamName(adminTeamName);
        guidanceMessageLogDO.setDoctorName(doctorName);
        guidanceMessageLogDO.setImgs(imgs);
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
//        guidanceMessageLogDO.setAdminTeamCode(adminTeamCode);
//        guidanceMessageLogDO.setAdminTeamName(adminTeamName);
        guidanceMessageLogDO.setDoctorName(doctorDO.getName());
        guidanceMessageLogDO.setCreateTime(new Date());
        guidanceMessageLogDO.setUpdateTime(new Date());
        guidanceMessageLogDao.save(guidanceMessageLogDO);