Parcourir la source

Merge branch 'dev' of zd_123/patient-co-management into dev

trick9191 il y a 7 ans
Parent
commit
f7b4a4b0a1

+ 63 - 22
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -410,11 +410,33 @@ public class PrescriptionService extends BaseService {
     * @param endTime
     * @return
     */
    public List<Map<String,Object>> getPrescriptionByCondition(String level, String area, String disease, String status, String type, String startTime,String endTime,int pageNo, int pageSize){
    public JSONObject getPrescriptionByCondition(String level, String area, String disease, String status, String type, String startTime,String endTime,int pageNo, int pageSize){
        String sql = "SELECT p.code,p.patient_name,p.doctor_name,p.hospital_name,p.dispensary_type,p.status," +
        /*String sql = "SELECT p.code,p.patient_name,p.doctor_name,p.hospital_name,p.dispensary_type,p.status," +
                "p.create_time,GROUP_CONCAT(d.health_problem) AS health_problem, GROUP_CONCAT(d.health_problem_name) AS health_problem_name " +
                "FROM wlyy_prescription p LEFT JOIN wlyy_prescription_diagnosis d ON p.code = d.prescription_code";
                "FROM wlyy_prescription p LEFT JOIN wlyy_prescription_diagnosis d ON p.code = d.prescription_code";*/
       JSONObject jsonObject = new JSONObject();
        String sql ="SELECT" +
                " p. CODE," +
                " p.patient_name," +
                " p.doctor_name," +
                " p.hospital_name," +
                " p.dispensary_type," +
                " p. STATUS," +
                " p.create_time," +
                " GROUP_CONCAT(d.health_problem) AS health_problem," +
                " GROUP_CONCAT(d.health_problem_name) AS health_problem_name," +
                " a.total_amount" +
                " FROM" +
                " wlyy_prescription p" +
                " LEFT JOIN wlyy_prescription_diagnosis d ON p. CODE = d.prescription_code" +
                " LEFT JOIN wlyy_prescription_pay a ON p. CODE = a.prescription_code" +
                " WHERE" +
                " IF (" +
                " p. STATUS > 50," +
                " a.trade_status = 1," +
                " 1 = 1" +
                ")";
        //判断疾病
        if(StringUtils.isNotBlank(disease)){
            if ("1".equals(disease)){
@ -422,9 +444,7 @@ public class PrescriptionService extends BaseService {
            }else if ("2".equals(disease)){
                disease = tnb;
            }
            sql += " WHERE d.health_problem ='"+disease+"' ";
        }else{
            sql +="  WHERE 1=1 ";
            sql += " and d.health_problem ='"+disease+"' ";
        }
        //判断状态
        if ("2".equals(status)){//已完成
@ -466,15 +486,25 @@ public class PrescriptionService extends BaseService {
        if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
            startTime += " 00:00:00";
            endTime += " 23:59:59";
            sql += " AND p.create_time <= ? " +
                    " AND p.create_time >= ? ";
            sql +=" GROUP BY p.code ORDER  BY p.create_time DESC limit ?,?";
            resultList = jdbcTemplate.queryForList(sql,new Object[]{endTime,startTime,start,pageSize});
        }else{
            sql +=" GROUP BY p.code ORDER  BY p.create_time DESC limit ?,?";
            resultList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
            sql += " AND p.create_time <= '" +endTime+"'"+
                    " AND p.create_time >= '"+startTime+"'";
        }
        sql +=" GROUP BY p.code ORDER  BY p.create_time DESC ";
        resultList = jdbcTemplate.queryForList(sql);
        jsonObject.put("count",resultList.size());
        double totalAmount = 0.0;
        for (Map<String,Object> map : resultList){
            if (map.get("total_amount")!=null){
                totalAmount += Double.valueOf(String.valueOf(map.get("total_amount")));
            }
        }
        return resultList;
        DecimalFormat df = new DecimalFormat("#.0");
        jsonObject.put("totalAmount",totalAmount>0?df.format(totalAmount/100.0):0.0);
        sql += " limit ?,?";
        resultList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        jsonObject.put("list",resultList);
        return jsonObject;
    }
    /**
@ -482,7 +512,8 @@ public class PrescriptionService extends BaseService {
     * @param keyWord
     * @return
     */
    public List<Map<String,Object>> getPrescriptionByKeyWord(String keyWord,int pageNo,int pageSize){
    public JSONObject getPrescriptionByKeyWord(String keyWord,int pageNo,int pageSize){
        JSONObject jsonObject = new JSONObject();
        String sql = "SELECT" +
                " p. CODE," +
                " p.patient_name," +
@ -492,24 +523,34 @@ public class PrescriptionService extends BaseService {
                " p. STATUS," +
                " p.create_time," +
                " GROUP_CONCAT(d.health_problem) AS health_problem," +
                " GROUP_CONCAT(d.health_problem_name) AS health_problem_name"+
                " GROUP_CONCAT(d.health_problem_name) AS health_problem_name,"+
                " a.total_amount"+
                " FROM" +
                " wlyy_prescription p" +
                " LEFT JOIN wlyy_prescription_diagnosis d ON p. CODE = d.prescription_code" +
                //" LEFT JOIN wlyy_prescription_pay a ON p.code = a.prescription_code" +
                " LEFT JOIN wlyy_prescription_pay a ON p.code = a.prescription_code" +
                " WHERE" +
                " 1 = 1 " ;
                " IF(p.status>50,a.trade_status=1,1=1) " ;
        //判断关键字
        if (StringUtils.isNotBlank(keyWord)){
            sql += " AND (p.patient_name like '%"+keyWord+"%' or p.doctor_name like '%"+keyWord+"%')";
        }
        sql += " GROUP BY p.code ORDER  BY p.create_time DESC ";
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql);
        jsonObject.put("count",resultList.size());
        double totalAmount = 0L;
        for (Map<String,Object> map : resultList){
            if (map.get("total_amount")!=null){
                totalAmount += Double.valueOf(String.valueOf(map.get("total_amount")));
            }
        }
        DecimalFormat df = new DecimalFormat("#.0");
        jsonObject.put("totalAmount",totalAmount>0?df.format(totalAmount/100.0):0.0);
        sql+=" limit ?,?";
        int start = (pageNo-1)*pageSize;
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        return resultList;
        resultList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        jsonObject.put("list",resultList);
        return jsonObject;
    }
    /**

+ 29 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -1,6 +1,5 @@
package com.yihu.wlyy.service.app.statistics;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.es.entity.HealthEduArticleESResult;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -16,12 +15,8 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.statistics.PopulationBaseDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.*;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.time.DateUtils;
import org.elasticsearch.common.inject.internal.Join;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -31,15 +26,14 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor;
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by lyr on 2016/08/16.
@ -2304,7 +2298,24 @@ public class StatisticsService extends BaseService {
            rs.put(map);
        }
        //健康教育排行
        String edurc_sql = "SELECT s.rowno AS articleRK FROM " +
        String adminTeamSql ="SELECT m.id FROM wlyy_admin_team m  WHERE m.org_code ='" + orgcode + "'";
        List<Map<String,Object>> adminTeamIds = jdbcTemplate.queryForList(adminTeamSql);
        String adminTeamIdsStr = adminTeamIds.stream().map(one->String.valueOf(one.get("id"))+",").collect(Collectors.joining());
        if (adminTeamIdsStr!= null && adminTeamIdsStr.length()>0){
            adminTeamIdsStr = adminTeamIdsStr.substring(0,adminTeamIdsStr.length()-1);
        }
        startDate = changeDate(startDate);
        endDate = changeDate(endDate);
        String es_edurc_sql ="SELECT count(*) number,adminTeamCode FROM "+esIndex+" where czrq > '"+startDate+"' and czrq < '"+endDate+"' and adminTeamCode in ("+adminTeamIdsStr+") GROUP BY adminTeamCode ORDER BY number DESC";
        List<Map<String, Object>> returnList = elasticsearchUtil.excuteDataModel(es_edurc_sql);
        int rk =0;
        for (Map<String, Object> map : returnList){
            if (Long.valueOf(String.valueOf(map.get("adminTeamCode"))).equals(id)) {
                rk = returnList.indexOf(map)+1;
                break;
            }
        }
        /*String edurc_sql = "SELECT s.rowno AS articleRK FROM " +
                "( " +
                " SELECT (@rowNum :=@rowNum + 1) AS rowno,t.count,t.admin_team_code " +
                " FROM ( " +
@ -2328,7 +2339,10 @@ public class StatisticsService extends BaseService {
            Map<String, Object> map = new HashMap<>();
            map.put("articleRK", 0);
            rs.put(map);
        }
        }*/
        Map<String, Object> map = new HashMap<>();
        map.put("articleRK", rk);
        rs.put(map);
        return rs;
    }
@ -2558,7 +2572,7 @@ public class StatisticsService extends BaseService {
        } else {
            //按月统计
            sql = "SELECT" +
                    " (DATE_FORMAT(c.create_time, '%v')- DATE_FORMAT('2017-12-01 00:00:00', '%v')+ 1)AS weekOfMonth, " +
                    " (DATE_FORMAT(c.create_time, '%v')- DATE_FORMAT('"+startDate+"', '%v')+ 1)AS weekOfMonth, " +
                    " COUNT(1)AS noRely " +
                    " FROM " +
                    " wlyy_admin_team_member m JOIN(" +
@ -2585,7 +2599,7 @@ public class StatisticsService extends BaseService {
                    " GROUP BY weekOfMonth";
            totalSql="SELECT" +
                    " (DATE_FORMAT(c.create_time, '%v')- DATE_FORMAT('2017-12-01 00:00:00', '%v')+ 1)AS weekOfMonth, " +
                    " (DATE_FORMAT(c.create_time, '%v')- DATE_FORMAT('"+startDate+"', '%v')+ 1)AS weekOfMonth, " +
                    " COUNT(1)AS total " +
                    " FROM " +
                    " wlyy_admin_team_member m JOIN(" +
@ -3119,7 +3133,7 @@ public class StatisticsService extends BaseService {
            //按月
            totalSQL = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDateStr + "', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDate +" 17:00:00" + "', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " wlyy_followup w " +
@ -3130,7 +3144,7 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time <= '?2' ";
            planSQL = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDateStr + "', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDate +" 17:00:00"  + "', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    " FROM " +
                    " wlyy_followup w " +
@ -3528,7 +3542,7 @@ public class StatisticsService extends BaseService {
            //查月份
            totalSql = "SELECT " +
                    "  ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('" + startDateStr + "', '%v') + 1 " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('" + startDate+" 17:00:00" + "', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
@ -3754,7 +3768,7 @@ public class StatisticsService extends BaseService {
            //按月统计
            SQL = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDateStr + "', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('" + startDate+" 17:00:00" + "', '%v') + 1 " +
                    " ) AS weekOfMonth, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +