瀏覽代碼

专科医生发起签约:居民及签约信息获取

zdm 6 年之前
父節點
當前提交
19d5733fa1

+ 4 - 2
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -1,6 +1,7 @@
package com.yihu.jw.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -391,13 +392,14 @@ public class SpecialistController extends EnvelopRestEndpoint {
    @GetMapping(value = SpecialistMapping.specialist.searchPatientInSpeciaInfo)
    @ApiOperation(value = "根据病人和医生id病人的家签信息、专科开通信息")
    public ObjEnvelop searchPatientInSpecialist(
    public ObjEnvelop<Object> searchPatientInSpecialist(
            @ApiParam(name = "doctorCode", value = "医生code",required = true)
            @RequestParam(value = "doctorCode",required = true)String doctorCode,
            @ApiParam(name = "patientCode", value = "居民id")
            @RequestParam(value = "patientCode",required = true)String patientCode){
        try {
            return specialistService.doctorForSpecialistInfo(doctorCode,patientCode);
            JSONObject object=specialistService.doctorForSpecialistInfo(doctorCode,patientCode);
            return  success(object);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());

+ 43 - 6
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -1,5 +1,6 @@
package com.yihu.jw.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dao.*;
import com.yihu.jw.entity.specialist.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by Trick on 2018/4/25.
@ -821,12 +823,47 @@ public class SpecialistService{
     * @param doctorCode 医生code
     * @param patientCode 病人id
     */
    public ObjEnvelop doctorForSpecialistInfo(String doctorCode, String patientCode){
        Map<String,Object> resultMap = new HashMap<>();
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
    public JSONObject doctorForSpecialistInfo(String doctorCode, String patientCode)  throws Exception{
        JSONObject jsonObject = new JSONObject();
        //1、获取居民基础信息
        String preSql = "SELECT p.name as name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END as sex,IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') as age," +
                " p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wsf.doctor_name is null THEN '无' ELSE wsf.doctor_name END as doctorName,CASE  WHEN wsf.hospital_name is NULL THEN '无' ELSE wsf.hospital_name END as hospitalName,CASE  WHEN wsf.mobile is NULL THEN '无' ELSE wsf.mobile END as doctorMobole ";
        String patientSql = " from " + basedb + ".wlyy_patient p LEFT JOIN " + basedb + ".wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
                " LEFT JOIN " + basedb + ".wlyy_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
        //一个居民 生效的家签信息只会有一条
        Map<String, Object> map = jdbcTemplate.queryForMap(preSql + patientSql);
        jsonObject.put("patientInfo", map);
        //2、获取医生信息(所属医院、科室、姓名)
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";
        jsonObject.put("doctorInfo", jdbcTemplate.queryForMap(doctorSql));
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
        List<Map<String, Object>> mapList = new ArrayList<>();
        for (Integer i : m.keySet()) {
            Map<String, Object> objectMap = new HashMap<>();
            objectMap.put("teamId", i);
            objectMap.put("teamName", m.get(i).get(0).get("teamName"));
            objectMap.put("teamDoctors", m.get(i));
            mapList.add(objectMap);
        }
        jsonObject.put("teamAndDoctors", mapList);
        //获取专科团队疾病标签
        teamSql = "SELECT wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND wtdr.del='1'";
        //new BeanPropertyRowMapper(
        List<String> stringList = jdbcTemplate.queryForList(teamSql, String.class);
        jsonObject.put("teamDisease", stringList.stream().collect(Collectors.joining(" ")));
        //疾病标签
        teamSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(teamSql);
        jsonObject.put("signPatientLabels", signPatientLabelList);
        return jsonObject;
    }
}