Преглед изворни кода

新增接口获取医生有效的关注的患者数目和全部的数目
新增接口获取医生关注的患者

chenweida пре 7 година
родитељ
комит
3a5f4539e3

+ 13 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java

@ -105,6 +105,10 @@ public class Patient extends IdEntity implements Serializable {
    //医疗保险号
    private String medicareNumber;
    //关注是间
    private Date concernCreateTime;//创建时间
    public String getPrincipalCode() {
        return principalCode;
    }
@ -467,4 +471,13 @@ public class Patient extends IdEntity implements Serializable {
    public void setMedicareNumber(String medicareNumber) {
        this.medicareNumber = medicareNumber;
    }
    @Transient
    public Date getConcernCreateTime() {
        return concernCreateTime;
    }
    public void setConcernCreateTime(Date concernCreateTime) {
        this.concernCreateTime = concernCreateTime;
    }
}

+ 5 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/concern/ConcernDao.java

@ -3,12 +3,13 @@ package com.yihu.wlyy.repository.concern;
import com.yihu.wlyy.entity.concern.ConcernDO;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import io.vavr.collection.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2018/4/4 0004.
 */
@ -29,18 +30,13 @@ public interface ConcernDao extends
    @Query("select d from  ConcernDO c,Doctor d where c.concernDoctorCode=d.code and  c.status=1  and  c.patient=?1  ")
    List<Doctor> listDoctorsByPatientCode(String patientCode);
    /**
     * 目前是1个团队一个医生的 所以先这么做
     *
     * @param doctorCode
     * @return
     */
    @Query("select p from  ConcernDO c,Patient p where c.patient=p.code and  c.status=1  and  c.concernDoctorCode=?1")
    List<Patient> listPatientsByDoctorCode(String doctorCode);
    @Query(" from  ConcernDO c where  c.status=1  and  c.patient=?1  and  c.concernDoctorCode=?2")
    ConcernDO findByPatientAndDoctor(String patientCode, String doctorCode);
    @Query("select count(id) from  ConcernDO  where   status=1  and  concernDoctorCode=?1")
    Integer countPatientsByDoctorCode(String doctorCode);
    @Query("select count(id) from  ConcernDO  where   concernDoctorCode=?1 group by patient")
    Integer countAllPatientsByDoctorCode(String doctorCode);
}

+ 24 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/concern/ConcernService.java

@ -11,13 +11,14 @@ import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import io.vavr.collection.List;
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 org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
 * Created by Administrator on 2018/4/4 0004.
@ -148,9 +149,17 @@ public class ConcernService extends BaseService {
     * @param doctorCode
     * @return
     */
    public List<Patient> listPatientsByDoctorCode(String doctorCode) {
        List<Patient> patients = concernDao.listPatientsByDoctorCode(doctorCode);
    public List<Patient> listPatientsByDoctorCode(String doctorCode,Integer page,Integer pageSize) {
        String sql="select  " +
                " p.`code`,p.name,p.idcard,p.sex,p.photo,p.openid,c.create_time concern_create_time " +
                " from wlyy_patient p,wlyy_concern c " +
                " where " +
                " p.`code`=c.patient and " +
                " c.concern_doctor_code= '"+doctorCode+"'and" +
                " c.`status`=1 " +
                " order by concern_create_time desc limit "+page+","+pageSize;
        List<Patient> patients = (List<Patient>) jdbcTemplate.query(sql,new BeanPropertyRowMapper(Patient.class));
        return patients;
    }
    /**
@ -164,4 +173,15 @@ public class ConcernService extends BaseService {
        Integer patients = concernDao.countPatientsByDoctorCode(doctorCode);
        return patients;
    }
    /**
     * 获取医生的关注数 包含失效
     * @param doctorCode
     * @return
     */
    public Integer countAllPatientsByDoctorCode(String doctorCode) {
        Integer patients = concernDao.countAllPatientsByDoctorCode(doctorCode);
        return patients;
    }
}

+ 55 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/concern/DoctorConcernController.java

@ -1,10 +1,15 @@
package com.yihu.wlyy.web.doctor.concern;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.concern.ConcernService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -12,6 +17,8 @@ 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;
/**
 * Created by Administrator on 2018/4/4 0004.
 */
@ -23,15 +30,58 @@ public class DoctorConcernController extends BaseController {
    private ConcernService concernService;
    @RequestMapping(value = "/getConcernPatients", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生关注的患者1", notes = "")
    @ApiOperation(value = "获取医生关注的患者", notes = "", response = Patient.class)
    public String getConcernDoctors(
            @ApiParam(name = "doctor", value = "医生",required = false) @RequestParam(required = false, name = "doctor") String doctor
            @ApiParam(name = "doctor", value = "医生", required = false) @RequestParam(required = false, name = "doctor") String doctor,
            @ApiParam(name = "page", value = "当前页(从0开始)", required = true) @RequestParam(required = true, name = "page") Integer page,
            @ApiParam(name = "pageSize", value = "每页显示条数", required = true) @RequestParam(required = true, name = "pageSize") Integer pageSize
    ) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                doctor = getUID();
            }
            JSONArray array = new JSONArray();
            List<Patient> patients = concernService.listPatientsByDoctorCode(doctor, page, pageSize);
            for (Patient patient : patients) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("code", patient.getCode());
                jsonObject.put("name", patient.getName());
                jsonObject.put("photo", patient.getPhoto());
                jsonObject.put("sex", patient.getSex());
                jsonObject.put("age", IdCardUtil.getAgeForIdcard(patient.getIdcard()));
                jsonObject.put("isWX", StringUtils.isEmpty(patient.getOpenid()) ? "false" : "true");
                jsonObject.put("concernTime", DateUtil.dateToStr(patient.getConcernCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                array.add(jsonObject);
            }
            return write(200, "查询成功", "data", array);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-100, "查询失败");
        }
    }
    @RequestMapping(value = "/getConcernCounts", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生有效的关注的患者数目和全部的数目", notes = "", response = Patient.class)
    public String getConcernCounts(
            @ApiParam(name = "doctor", value = "医生", required = false) @RequestParam(required = false, name = "doctor") String doctor
    ) {
        try {
            if(StringUtils.isEmpty(doctor)){
                doctor=getUID();
            if (StringUtils.isEmpty(doctor)) {
                doctor = getUID();
            }
            return write(200,"查询成功","data",concernService.listPatientsByDoctorCode(doctor));
            JSONObject  jo = new JSONObject();
            //获取有效的关注数
            Integer countPatientStatus1 = concernService.countPatientsByDoctorCode(doctor);
            //获取全部的的关注数
            Integer countPatientAll = concernService.countAllPatientsByDoctorCode(doctor);
            jo.put("countPatientAll",countPatientAll);
            jo.put("countPatientStatus1",countPatientStatus1);
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-100, "查询失败");