Browse Source

Merge branch 'dev' of huangwenjie/wlyy2.0 into dev

huangwenjie 5 years ago
parent
commit
8b1016192f

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -17,4 +17,6 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    List<WlyyOutpatientDO> findByPatientList(String patient);
    List<WlyyOutpatientDO> findByPatientList(String patient);
    List<WlyyOutpatientDO> findByDoctorAndStatus(String doctor,String status);
    List<WlyyOutpatientDO> findByDoctorAndStatus(String doctor,String status);
    
    List<WlyyOutpatientDO> findByDoctor(String doctor);
}
}

+ 300 - 9
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -7,6 +7,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
@ -38,7 +39,6 @@ import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.doctor.WlyyDoctorWorkTimeVO;
import com.yihu.jw.restmodel.hospital.doctor.WlyyDoctorWorkTimeVO;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
@ -118,6 +118,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private WlyyDoctorClinicRoomDao wlyyDoctorClinicRoomDao;
    private WlyyDoctorClinicRoomDao wlyyDoctorClinicRoomDao;
    @Autowired
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    
    
    @Value("${demo.flag}")
    @Value("${demo.flag}")
@ -1601,6 +1602,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            rs.put("outpatientType",doctorDO.getOutpatientType());
            rs.put("outpatientType",doctorDO.getOutpatientType());
            rs.put("expertise",doctorDO.getExpertise());
            rs.put("expertise",doctorDO.getExpertise());
            rs.put("introduce",doctorDO.getIntroduce());
            rs.put("introduce",doctorDO.getIntroduce());
            rs.put("consultStatus",doctorDO.getConsultStatus());// 咨询在线状态
            //机构科室信息
            //机构科室信息
            List<BaseDoctorHospitalDO> hospitalDOs =  baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
            List<BaseDoctorHospitalDO> hospitalDOs =  baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
@ -1608,9 +1610,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
               rs.put("hospital",hospitalDOs.get(0));
               rs.put("hospital",hospitalDOs.get(0));
               BaseOrgDO org = baseOrgDao.findByCode(hospitalDOs.get(0).getOrgCode());
               BaseOrgDO org = baseOrgDao.findByCode(hospitalDOs.get(0).getOrgCode());
               rs.put("winNo",org.getWinNo());
               rs.put("winNo",org.getWinNo());
               rs.put("deptName",hospitalDOs.get(0).getDeptName());
            }else{
            }else{
               rs.put("hospital",null);
               rs.put("hospital",null);
               rs.put("winNo",null);
               rs.put("winNo",null);
               rs.put("deptName",null);
            }
            }
@ -1649,6 +1653,69 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                List<WlyyDoctorWorkTimeVO> times = findDoctorWorkTime(doctor);
                List<WlyyDoctorWorkTimeVO> times = findDoctorWorkTime(doctor);
                rs.put("workTime",times);
                rs.put("workTime",times);
            }
            }
    
            //查询医生各项评价平均分
            String sqlscore = "SELECT " +
                    "AVG(a.score) AS score," +
                    "a.score_type AS score_type " +
                    "FROM base_evaluate a,base_evaluate_score b " +
                    "WHERE " +
                    "a.relation_code=b.id " +
                    "AND b.doctor='"+doctor+"' " +
                    "GROUP BY a.score_type";
            List<Map<String,Object>> listscore = jdbcTemplate.queryForList(sqlscore);
    
            if(listscore!=null&&listscore.size()>0){
                rs.put("scoreDoctor",listscore);
            }else{
                rs.put("scoreDoctor",null);
            }
    
            //查询评价明细
            String sqlScoreList = "SELECT " +
                    "a.score as score," +
                    "a.score_type as score_type," +
                    "a.content as content," +
                    "b.create_time as create_time," +
                    "c.type as type," +
                    "c.name as patientname," +
                    "b.id as id," +
                    "c.photo as patientphoto," +
                    "b.type as niming " +
                    "FROM " +
                    "base_evaluate a " +
                    "LEFT JOIN base_evaluate_score b ON b.id=a.relation_code " +
                    "LEFT JOIN wlyy_consult_team c ON c.consult=b.relation_code AND c.doctor='"+doctor+"' " +
                    "WHERE a.relation_code=b.id AND b.doctor='"+doctor+"' ";
            List<Map<String,Object>> scoreList = jdbcTemplate.queryForList(sqlScoreList);
    
            if(scoreList!=null&&scoreList.size()>0){
    
                Set<String> datelist = new HashSet<>();
    
                HashMap<String,List<Map<String,Object>>> waitinglist = new HashMap<>();
    
                if(scoreList!=null&&scoreList.size()>0){
                    for(Map<String,Object> scorepatient :scoreList){
                        String id = (String)scorepatient.get("id");
            
                        if(id == null){
                            continue;
                        }
                        
                        if(waitinglist.keySet().contains(id)){
                            waitinglist.get(id).add(scorepatient);
                        }else{
                            List<Map<String,Object>> _cu = new ArrayList<>();
                            _cu.add(scorepatient);
                            waitinglist.put(id,_cu);
                        }
                    }
                }
                rs.put("scoreList",waitinglist);
            }else{
                rs.put("scoreList",null);
            }
        }
        }
        return rs;
        return rs;
@ -1756,7 +1823,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    }
    
    
    /**
    /**
     * 医生可接单列表
     * 医生可接单列表(图文)
     * @param doctor
     * @param doctor
     * @param type
     * @param type
     * @return
     * @return
@ -1783,9 +1850,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "WHERE " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND outpatient.status = 0 " +
                "AND (room.doctor IS NULL or room.doctor='"+doctor+"') " +
                "AND room.consult_type="+type;
                "AND outpatient.status = 0 ";
        if(type == 2){
            sql +=  "AND room.doctor IS NULL ";
        }else{
            sql +=  "AND (room.doctor IS NULL or room.doctor='"+doctor+"') ";
            
        }
        
        sql += "AND room.consult_type="+type;
        
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
        if(list!=null&&list.size()>0){
@ -1903,9 +1976,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param orgCode 机构码
     * @param orgCode 机构码
     * @param dept 部门CODE
     * @param dept 部门CODE
     * @param diseaseKey 疾病名称
     * @param diseaseKey 疾病名称
     * @param jobTitleNameKey
     * @param outpatientType
     * @param keyName
     * @param workingTime
     * @param consutlSort
     * @return
     * @return
     */
     */
    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(String orgCode, String dept, String diseaseKey,String doctorNameKey) {
    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(String orgCode, String dept,
                                                                          String diseaseKey, String doctorNameKey,
                                                                          String jobTitleNameKey, String outpatientType,
                                                                          String keyName, String workingTime, String consutlSort) {
    
    
        String sql ="SELECT " +
        String sql ="SELECT " +
                " d.id, " +
                " d.id, " +
@ -1916,11 +1997,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.job_title_code AS jobTitleCode, " +
                " d.job_title_code AS jobTitleCode, " +
                " d.job_title_name AS jobTitleName," +
                " d.job_title_name AS jobTitleName," +
                " d.charge_type AS chargeType," +
                " d.charge_type AS chargeType," +
                " h.dept_name AS deptName" +
                " h.dept_name AS deptName," +
                " a.total as consultTotal" +
                " FROM " +
                " FROM " +
                " base_doctor d " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
                " WHERE  " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id "+
                " Left join ( select count(id) as total,doctor from wlyy_consult_team GROUP BY doctor ) a on a.doctor = d.id ";
                
        if(StringUtils.isNotBlank(workingTime)){
            sql+=" JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
        }
        sql +=  " WHERE  " +
                " h.org_code = '"+orgCode+"'";
                " h.org_code = '"+orgCode+"'";
        if(StringUtils.isNotBlank(diseaseKey)){
        if(StringUtils.isNotBlank(diseaseKey)){
            sql+=" AND d.expertise like '%"+diseaseKey+"%'";
            sql+=" AND d.expertise like '%"+diseaseKey+"%'";
@ -1933,6 +2020,25 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(StringUtils.isNotBlank(dept)){
        if(StringUtils.isNotBlank(dept)){
            sql+=" AND h.dept_code = '"+dept+"' ";
            sql+=" AND h.dept_code = '"+dept+"' ";
        }
        }
    
        if(StringUtils.isNotBlank(jobTitleNameKey)){
            sql+=" AND d.job_title_name AS = '"+jobTitleNameKey+"' ";
        }
    
        if(StringUtils.isNotBlank(outpatientType)){
            sql+=" AND d.outpatient_type AS = '"+outpatientType+"' ";
        }
    
        if(StringUtils.isNotBlank(keyName)){
            sql+=" AND (h.dept_name like '%"+keyName+"%' or d.name like '%"+keyName+"%' or d.expertise like '%"+keyName+"%' )";
        }
    
        if(StringUtils.isNotBlank(workingTime)){
            sql+=" AND wk.date = '"+workingTime+"' ";
        }
    
        sql += " order by a.total "+ consutlSort;
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
    
    
        return list;
        return list;
@ -2142,4 +2248,189 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String res = httpClientUtil.post("http://www.xmtyw.cn/wlyy/iHealth/userInfo", params, "UTF-8");
        String res = httpClientUtil.post("http://www.xmtyw.cn/wlyy/iHealth/userInfo", params, "UTF-8");
        return res;
        return res;
    }
    }
    
    
    /**
     * 获取正在进行中的视频复诊/协同门诊
     * @param doctor
     * @return
     */
    public List<Map<String,Object>> getVideoPrescriptionByDoctor(String doctor) {
        String sql ="SELECT " +
                "room.outpatient_id AS id," +
                "room.patient_id AS patient_id," +
                "room.patient_name AS name," +
                "patient.sex AS sex," +
                "patient.idcard AS idcard," +
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "room.reservation_type AS reservation_type," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "outpatient.origin_con_no AS origin_con_no " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient, " +
                "wlyy_consult_team consult " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND outpatient.status = 1 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.consult_type= 2";
    
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> outpatient :list){
                String idcard = (String)outpatient.get("idcard");
                outpatient.put("age",DateUtil.getAgeForIdcard(idcard));
    
                String outpatient_id = (String)outpatient.get("id");
                
                
            }
        }
    
        return list;
    }
    
    public com.alibaba.fastjson.JSONArray getWaitingForVisitVideoPrescriptionByDoctor(String doctor) {
        
        String sql ="SELECT " +
                "room.outpatient_id AS id," +
                "room.patient_id AS patient_id," +
                "room.patient_name AS name," +
                "patient.sex AS sex," +
                "patient.idcard AS idcard," +
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "date_format(room.reservation_time ,'%Y-%m-%d' ) AS group_date," +
                "room.reservation_type AS reservation_type," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "outpatient.origin_con_no AS origin_con_no " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND outpatient.status = 0 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.reservation_time is not null " +
                "AND room.consult_type= 2 ";
//                "AND room.reservation_time>='"+DateUtil.getStringDate("yyyy-MM-dd")+" 00:00:00"+"' ";
    
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        
        Set<String> datelist = new HashSet<>();
        
        HashMap<String,List<Map<String,Object>>> waitinglist = new HashMap<>();
        
        if(list!=null&&list.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> outpatient :list){
                String idcard = (String)outpatient.get("idcard");
                outpatient.put("age",DateUtil.getAgeForIdcard(idcard));
    
                String group_date = (String)outpatient.get("group_date");
                
                if(waitinglist.keySet().contains(group_date)){
                    waitinglist.get(group_date).add(outpatient);
                }else{
                    List<Map<String,Object>> _cu = new ArrayList<>();
                    _cu.add(outpatient);
                    waitinglist.put(group_date,_cu);
                }
            }
        }
    
        Collection<String> keyset= waitinglist.keySet();
        List<String> _list = new ArrayList<String>(keyset);
    
        //对key键值按字典升序排序
        Collections.sort(_list);
        com.alibaba.fastjson.JSONArray result = new com.alibaba.fastjson.JSONArray();
    
    
        for (int i = 0; i < _list.size(); i++) {
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            if(_list.get(i).equals(DateUtil.getStringDateShort())){
                object.put("day","today");
            }else{
                object.put("day",_list.get(i));
            }
            object.put("data",waitinglist.get(_list.get(i)));
            result.add(object);
        }
        return result;
    }
    
    /**
     * 医生抢单(视频)
     * @param outpatientCode
     * @param doctor
     */
    public void pickVideoPrescripitonWaitingPeople(String outpatientCode, String doctor) throws Exception{
        List<WlyyHospitalWaitingRoomDO> roomDOs =hospitalWaitingRoomDao.findByOutpatientId(outpatientCode);
        if(roomDOs!=null&&roomDOs.size()>0){
            for(WlyyHospitalWaitingRoomDO roomDO:roomDOs){
                    roomDO.setDoctor(doctor);
                    hospitalWaitingRoomDao.save(roomDO);
            }
        }
    }
    
    /**
     * 复诊图文咨询人数,视频咨询人数, 专家咨询未完成
     * @param doctor
     * @return
     */
    public JSONObject doctorIndexConsultCount(String doctor) {
    
        //医生问诊量
        List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByDoctor(doctor);
        
        Integer imgCount = 0;
        
        Integer videoCount = 0;
        
        for(WlyyOutpatientDO wlyyOutpatientDO:wlyyOutpatientDOs){
            //1.图文 2.视频
            if("1".equals(wlyyOutpatientDO.getType())){
                imgCount ++;
            }else if("2".equals(wlyyOutpatientDO.getType())){
                videoCount ++;
            }else{
                continue;
            }
        }
    
        String totalSql = "SELECT count(a.id) AS total " +
                "FROM wlyy_consult a,wlyy_consult_team b " +
                "WHERE a.id=b.consult AND b.doctor='"+doctor+"' AND a.type=1 AND b.`status`=0";
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
    
        Long zjCount = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            zjCount = (Long) rstotal.get(0).get("total");
        }
        
        JSONObject result = new JSONObject();
        result.put("imgCount",imgCount);
        result.put("videoCount",videoCount);
        result.put("zjCount",zjCount);
        
        return result;
        
    }
}
}

+ 110 - 3
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -10,7 +10,11 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.score.BaseEvaluateDO;
import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateDao;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
@ -23,6 +27,7 @@ import com.yihu.jw.im.util.ImageCompress;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
@ -68,6 +73,11 @@ public class ImService {
	@Autowired
	@Autowired
	public BasePatientDao basePatientDao;
	public BasePatientDao basePatientDao;
	
	
	@Autowired
	public BaseEvaluateScoreDao baseEvaluateScoreDao;
	@Autowired
	public BaseEvaluateDao baseEvaluateDao;
	
	@Autowired
	@Autowired
	public ImUtil imUtil;
	public ImUtil imUtil;
	
	
@ -980,11 +990,24 @@ public class ImService {
		if (obj.getInteger("status") == -1) {
		if (obj.getInteger("status") == -1) {
			throw new RuntimeException(String.valueOf(obj.get("message")));
			throw new RuntimeException(String.valueOf(obj.get("message")));
		}
		}
		
		
		
		String name = "";
		String name = "";
		String returnJson = "";
		String returnJson = "";
		//推送给IM文字消息
		
		BasePatientDO p = basePatientDao.findById(endOperator);
		BaseDoctorDO d = baseDoctorDao.findById(endOperator);
		name = d.getName();
		
		JSONObject evalueContent = new JSONObject();
		evalueContent.put("patientCode",p.getId());
		evalueContent.put("patientName",p.getName());
		evalueContent.put("doctorCode",d.getId());
		evalueContent.put("doctorName",d.getName());
		evalueContent.put("consultCode",consult);
		
		returnJson = imUtil.sendIM(consultTeam.getDoctor(), consultTeam.getPatient(), "28", name + "结束了本次咨询");
//		//推送给IM文字消息
//		if (endType == 1) {
//		if (endType == 1) {
//			BasePatientDO p = basePatientDao.findById(endOperator);
//			BasePatientDO p = basePatientDao.findById(endOperator);
//			name = p.getName();
//			name = p.getName();
@ -1040,7 +1063,13 @@ public class ImService {
	 */
	 */
	public JSONObject getTopic(String consult) throws Exception {
	public JSONObject getTopic(String consult) throws Exception {
		
		
		return imUtil.getTopic(consult);
		JSONObject object = imUtil.getTopic(consult);
		
		ConsultTeamDo consultTeamDo = consultTeamDao.findOne(consult);
		
		object.put("doctorCode",consultTeamDo.getDoctor());
		
		return object;
	}
	}
	
	
	
	
@ -1097,4 +1126,82 @@ public class ImService {
		}
		}
		return id;
		return id;
	}
	}
	
	/**
	 * 评价咨询
	 * @param consult
	 * @param scoreContent
	 * @param type
	 */
	public void evaluationByConsultCode(String consult, String scoreContent, Integer type) throws Exception{
		JSONArray jsonArray =  JSONArray.parseArray(scoreContent);
		
		Integer totalScore = 0;
		
		ConsultTeamDo consultTeamDo = consultTeamDao.findByConsult(consult);
		
		if(!jsonArray.isEmpty() && jsonArray.size() >0){
			BaseEvaluateScoreDO evaluateScoreDO = new BaseEvaluateScoreDO();
			evaluateScoreDO.setDoctor(consultTeamDo.getDoctor());
			evaluateScoreDO.setDoctorName(consultTeamDo.getDoctorName());
			evaluateScoreDO.setPatient(consultTeamDo.getPatient());
			evaluateScoreDO.setPatientName(consultTeamDo.getName());
			evaluateScoreDO.setRelationCode(consult);
			evaluateScoreDO.setEvaluateType(1);
			evaluateScoreDO.setType(type);
			evaluateScoreDO.setId(UUID.randomUUID().toString());
			
			String content = "";//评价内容
			
			List<BaseEvaluateDO> baseEvaluateDOS = new ArrayList<>();
			for (int i = 0; i < jsonArray.size(); i++) {
				JSONObject job = jsonArray.getJSONObject(i);
				if("4".equals(job.getString("scoreType"))){//非评价类型
					
					content = job.getString("content");
					BaseEvaluateDO baseEvaluateDO = new BaseEvaluateDO();
					baseEvaluateDO.setScoreType(job.getString("scoreType"));
					baseEvaluateDO.setScore(new Double(String.valueOf(job.getInteger("score"))));
					baseEvaluateDO.setRelationCode(evaluateScoreDO.getId());
					baseEvaluateDO.setContent(content);
					baseEvaluateDOS.add(baseEvaluateDO);
				}else{
					BaseEvaluateDO baseEvaluateDO = new BaseEvaluateDO();
					baseEvaluateDO.setScoreType(job.getString("scoreType"));
					baseEvaluateDO.setScore(new Double(String.valueOf(job.getInteger("score"))));
					baseEvaluateDO.setRelationCode(evaluateScoreDO.getId());
					totalScore += job.getInteger("score");
					baseEvaluateDOS.add(baseEvaluateDO);
				}
			}
			evaluateScoreDO.setScore((double) totalScore / 3);
			
			evaluateScoreDO = baseEvaluateScoreDao.save(evaluateScoreDO);
			
			for(BaseEvaluateDO baseEvaluateDO :baseEvaluateDOS){
				baseEvaluateDao.save(baseEvaluateDO);
			}
			
			consultTeamDo.setEvaluate(1);//保存已评价标识
			consultTeamDo.setEvaluateTime(new Date());
			consultTeamDao.save(consultTeamDo);
			
			/**
			 * todo 保存就诊记录表已评价标识
			 */
		
		}
		
	}
	
	/**
	 * 修改医生在线状态
	 * @param consultStatus
	 * @param doctor
	 */
	public void updateDoctorConsultStatus(String consultStatus, String doctor) {
		BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
		baseDoctorDO.setConsultStatus(consultStatus);
		baseDoctorDao.save(baseDoctorDO);
	}
}
}

+ 11 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/score/BaseEvaluateDO.java

@ -14,8 +14,9 @@ import javax.persistence.Table;
public class BaseEvaluateDO extends UuidIdentityEntityWithOperator {
public class BaseEvaluateDO extends UuidIdentityEntityWithOperator {
    private String relationCode;//关联业务CODE(关联主表evlute_score)',
    private String relationCode;//关联业务CODE(关联主表evlute_score)',
    private String scoreType;//评价类型:1、专业能力,2、服务态度,3、回复速度 (可拓展字段)',
    private String scoreType;//评价类型:1、专业能力,2、服务态度,3、回复速度 (可拓展字段),4其他',
    private Double score;//单项得分',
    private Double score;//单项得分',
    private String content;//评语
    @Column(name = "relation_code")
    @Column(name = "relation_code")
    public String getRelationCode() {
    public String getRelationCode() {
@ -43,4 +44,13 @@ public class BaseEvaluateDO extends UuidIdentityEntityWithOperator {
    public void setScore(Double score) {
    public void setScore(Double score) {
        this.score = score;
        this.score = score;
    }
    }
    
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
}
}

+ 19 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -312,6 +312,9 @@ public class BaseHospitalRequestMapping {
        
        
        //根据复诊记录ID获取咨询CODE
        //根据复诊记录ID获取咨询CODE
        public static final String getConsultCodeByOutpatientId = "/getConsultCodeByOutpatientId";
        public static final String getConsultCodeByOutpatientId = "/getConsultCodeByOutpatientId";
        
        //评价咨询
        public static final String evaluationByConsultCode = "/evaluationByConsultCode";
        
        
    }
    }
@ -325,7 +328,7 @@ public class BaseHospitalRequestMapping {
        //添加复诊咨询
        //添加复诊咨询
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
        
        
        //医生可接单列表
        //医生可接单列表(图文)
        public static final String findWaitingRoomOutpatientByDoctor = "findWaitingRoomOutpatientByDoctor";
        public static final String findWaitingRoomOutpatientByDoctor = "findWaitingRoomOutpatientByDoctor";
    
    
        //导诊台居民列表
        //导诊台居民列表
@ -349,6 +352,21 @@ public class BaseHospitalRequestMapping {
        //根据咨询CODE获取就诊记录ID
        //根据咨询CODE获取就诊记录ID
        public static final String getOutpatientidByConsoultCode = "/getOutpatientidByConsoultCode";
        public static final String getOutpatientidByConsoultCode = "/getOutpatientidByConsoultCode";
        
        
        //获取正在进行中的视频复诊/协同门诊
        public static final String getVideoPrescriptionByDoctor ="getVideoPrescriptionByDoctor";
    
        //获取等待就诊的视频复诊/协同门诊
        public static final String getWaitingForVisitVideoPrescriptionByDoctor ="getWaitingForVisitVideoPrescriptionByDoctor";
    
        //医生抢单(视频)
        public static final String pickVideoPrescripitonWaitingPeople= "pickVideoPrescripitonWaitingPeople";
    
        //修改医生咨询在线状态
        public static final String updateDoctorConsultStatus= "updateDoctorConsultStatus";
        
        //复诊图文咨询人数,视频咨询人数
        public static final String doctorIndexConsultCount="doctorIndexConsultCount";
        
    }
    }
    /**
    /**

+ 50 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -30,7 +30,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	
	
	
	
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomOutpatientByDoctor)
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomOutpatientByDoctor)
	@ApiOperation(value = "医生可接单列表", notes = "医生可接单列表")
	@ApiOperation(value = "医生可接单列表(图文)", notes = "医生可接单列表(图文)")
	public ListEnvelop findPrescriptionConsultByDoctor(
	public ListEnvelop findPrescriptionConsultByDoctor(
			@ApiParam(name = "doctor", value = "医生CODE",defaultValue = "1cd15ffe6b3a11e69f7c005056850d66")
			@ApiParam(name = "doctor", value = "医生CODE",defaultValue = "1cd15ffe6b3a11e69f7c005056850d66")
			@RequestParam(value = "doctor",required = true) String doctor,
			@RequestParam(value = "doctor",required = true) String doctor,
@ -146,7 +146,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			return success("操作成功",result);
			return success("操作成功",result);
	}
	}
	
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.finish)
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.finish)
	@ApiOperation(value = "医生结束咨询", notes = "医生结束咨询")
	@ApiOperation(value = "医生结束咨询", notes = "医生结束咨询")
	public Envelop finish(
	public Envelop finish(
			@ApiParam(name = "consult", value = "咨询CODE")
			@ApiParam(name = "consult", value = "咨询CODE")
@ -176,4 +176,52 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "consult",required = false) String consult)throws Exception {
			@RequestParam(value = "consult",required = false) String consult)throws Exception {
		return success("请求成功",imService.getOutpatientidByConsoultCode(consult));
		return success("请求成功",imService.getOutpatientidByConsoultCode(consult));
	}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.getVideoPrescriptionByDoctor)
	@ApiOperation(value = "获取正在进行中的视频复诊/协同门诊", notes = "获取正在进行中的视频复诊/协同门诊")
	public ListEnvelop getVideoPrescriptionByDoctor(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor)throws Exception{
		return success("请求成功",prescriptionService.getVideoPrescriptionByDoctor(doctor));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.getWaitingForVisitVideoPrescriptionByDoctor)
	@ApiOperation(value = "获取等待就诊的视频复诊/协同门诊", notes = "获取等待就诊的视频复诊/协同门诊")
	public ListEnvelop getWaitingForVisitVideoPrescriptionByDoctor(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor)throws Exception{
		return success("请求成功",prescriptionService.getWaitingForVisitVideoPrescriptionByDoctor(doctor));
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.pickVideoPrescripitonWaitingPeople)
	@ApiOperation(value = "医生抢单(视频)", notes = "医生抢单(视频)")
	public Envelop pickVideoPrescripitonWaitingPeople(
			@ApiParam(name = "outpatientCode", value = "HIS就诊记录CODE", defaultValue = "1")
	        @RequestParam(value = "outpatientCode", required = true) String outpatientCode,
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor)throws Exception{
		prescriptionService.pickVideoPrescripitonWaitingPeople(outpatientCode,doctor);
		return success("请求成功");
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.updateDoctorConsultStatus)
	@ApiOperation(value = "修改医生咨询在线状态", notes = "修改医生咨询在线状态")
	public Envelop updateDoctorConsultStatus(
			@ApiParam(name = "consultStatus", value = "1在线接诊,0下线", defaultValue = "1")
			@RequestParam(value = "consultStatus", required = true) String consultStatus,
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor){
		imService.updateDoctorConsultStatus(consultStatus,doctor);
		return success("请求成功");
	}
	
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.doctorIndexConsultCount)
	@ApiOperation(value = "复诊图文咨询人数,视频咨询人数", notes = "复诊图文咨询人数,视频咨询人数")
	public Envelop doctorIndexConsultCount(@ApiParam(name = "doctor", value = "医生CODE")
	                                           @RequestParam(value = "doctor",required = true) String doctor){
		return success("请求成功",prescriptionService.doctorIndexConsultCount(doctor));
	}
	
	
}
}

+ 33 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -180,8 +180,23 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	                                               @ApiParam(name = "diseaseKey", value = "疾病名称关键字")
	                                               @ApiParam(name = "diseaseKey", value = "疾病名称关键字")
	                                               @RequestParam(value = "diseaseKey", required = false)String diseaseKey,
	                                               @RequestParam(value = "diseaseKey", required = false)String diseaseKey,
                                                   @ApiParam(name = "doctorNameKey", value = "医生名称关键字")
                                                   @ApiParam(name = "doctorNameKey", value = "医生名称关键字")
	                                               @RequestParam(value = "doctorNameKey", required = false)String doctorNameKey) throws Exception{
		return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(orgCode,dept,diseaseKey,doctorNameKey));
	                                               @RequestParam(value = "doctorNameKey", required = false)String doctorNameKey,
                                                   @ApiParam(name = "jobTitleNameKey", value = "医生职称关键字")
                                                   @RequestParam(value = "jobTitleNameKey", required = false)String jobTitleNameKey,
                                                   @ApiParam(name = "outpatientType", value = "咨询类型1图文,2视频")
                                                   @RequestParam(value = "outpatientType", required = false)String outpatientType,
                                                   @ApiParam(name = "keyName", value = "姓名/科室/疾病模糊搜索关键字")
                                                   @RequestParam(value = "keyName", required = false)String keyName,
                                                   @ApiParam(name = "workingTime", value = "排班时间YYYY-MM-DD")
	                                               @RequestParam(value = "workingTime", required = false)String workingTime,
                                                   @ApiParam(name = "consutlSort", value = "咨询量排序")
                                                   @RequestParam(value = "consutlSort", required = true,defaultValue = "DESC")String consutlSort
	) throws Exception{
		return success(prescriptionService.findDoctorByHospitalAndDiseaseAndDept(
				orgCode,dept,
				diseaseKey,doctorNameKey,
				jobTitleNameKey,outpatientType,
				keyName,workingTime,consutlSort));
	}
	}
	
	
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findHotDeptAndDiseaseDict)
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findHotDeptAndDiseaseDict)
@ -276,5 +291,21 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "outpatientid",required = true) String outpatientid)throws Exception {
			@RequestParam(value = "outpatientid",required = true) String outpatientid)throws Exception {
		return success("请求成功",imService.getConsultCodeByOutpatientId(outpatientid));
		return success("请求成功",imService.getConsultCodeByOutpatientId(outpatientid));
	}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.evaluationByConsultCode)
	@ApiOperation(value = "评价咨询", notes = "评价咨询")
	public Envelop evaluationByConsultCode(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult,
			@ApiParam(name = "scoreContent", value = "评价内容")
			@RequestParam(value = "scoreContent",required = false) String scoreContent,
			@ApiParam(name = "type", value = "1、实名,2、匿名")
			@RequestParam(value = "type",required = true) Integer type)throws Exception{
		if(StringUtils.isEmpty(scoreContent)){
			scoreContent= "[{\"scoreType\":\"1\",\"score\":100,\"content\":\"\"},{\"scoreType\":\"2\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"3\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"4\",\"score\":0,\"content\":\"测试评语。。。。123123\"}]";
		}
		imService.evaluationByConsultCode(consult,scoreContent,type);
		return success("请求成功");
	}
}
}