Browse Source

长处方

trick9191 7 years ago
parent
commit
1fedc6d6b2

+ 47 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -167,7 +167,52 @@ public class PrescriptionInfoService extends BaseService {
    }
    public String getDoctorPrescription(String doctor){
        return null;
    public JSONArray getDoctorPrescription(String doctor,String state,String diseases,String startDate,String endDate ){
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.sex, " +
                " pr.`status`, " +
                " pr.`code`, " +
                " pr.create_time AS createTime, " +
                " pr.doctor " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " );
        List<Object> params = new ArrayList<>();
        //先判断疾病类型是否为空
        if(StringUtils.isNotBlank(diseases)){
            //疾病类型不为空,关联查询疾病类型表
            pre_sql.append(" ,wlyy_prescription_diagnosis s " +
                    " WHERE s.prescription_code = pr.code " +
                    " AND pr.doctor =? AND s.code = ?");
            params.add(doctor);
            params.add(diseases);
            setSQL(pre_sql,params,state,startDate,endDate);
        }else{
            //查询所有疾病类型表
            pre_sql.append(" WHERE pr.doctor =?");
            params.add(doctor);
            setSQL(pre_sql,params,state,startDate,endDate);
        }
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
        return new JSONArray(rs);
    }
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate){
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status = ?");
            params.add(state);
        }
        if(StringUtils.isNotBlank(startDate)){
            pre_sql.append(" AND pr.create_time >= ?");
            params.add(startDate);
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ?");
            params.add(endDate);
        }
        pre_sql.append(" ORDER BY pr.create_time DESC");
    }
}

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -60,9 +60,12 @@ public class PrescriptionInfoController extends BaseController{
    @RequestMapping(value = "/getDoctorPrescription", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取全科医生续方列表")
    public String getDoctorPrescription(){
    public String getDoctorPrescription(@RequestParam(required = true) @ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = true) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = true)@ApiParam(name="startDate",value="开始时间")String startDate,
                                        @RequestParam(required = true)@ApiParam(name="endDate",value="结束时间")String endDate){
        try {
            return write(200, "查询成功!", "data",prescriptionInfoService.getDoctorPrescription());
            return write(200, "查询成功!", "data",prescriptionInfoService.getDoctorPrescription(getUID(),state,diseases,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");