|
@ -24,12 +24,15 @@ import com.yihu.wlyy.service.app.message.MessageService;
|
|
|
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.CommonUtil;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.MessageType;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.orm.jpa.JpaTransactionManager;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
@ -37,10 +40,7 @@ import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2017/7/27.
|
|
@ -80,6 +80,12 @@ public class PrescriptionService extends BaseService {
|
|
|
private FollowUpDao followUpDao;
|
|
|
@Autowired
|
|
|
private MessageService messageService;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
//健康问题 高血压
|
|
|
private static final String gxy = "HP0093";
|
|
|
//健康问题 糖尿病
|
|
|
private static final String tnb = "HP0047";
|
|
|
|
|
|
/**
|
|
|
* 获取处方信息
|
|
@ -390,4 +396,159 @@ public class PrescriptionService extends BaseService {
|
|
|
}
|
|
|
return statusObj;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 长处方统计-点击柱状图获取详情
|
|
|
* @param interval
|
|
|
* @param date
|
|
|
* @param disease
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> getPrescriptionTotalDetailTime(int interval,String date,String disease,String type){
|
|
|
//如果是日就是按一天,周就是从本周一到本周日,月就是本月第一天到本月最后一天
|
|
|
String startTime = "";
|
|
|
String endTime = "";
|
|
|
if (interval==1){
|
|
|
startTime = date+" 00:00:00";
|
|
|
endTime = " 23:59:59";
|
|
|
}else if (interval==2){
|
|
|
startTime = DateUtil.getMondayOfThisDate(DateUtil.strToDate(date));
|
|
|
endTime = DateUtil.getSundayOfThisDate(DateUtil.strToDate(date));
|
|
|
startTime += " 00:00:00";
|
|
|
endTime += "23:59:59";
|
|
|
}else if (interval==3){
|
|
|
startTime = DateUtil.getFristDayOfMonthThisDate(DateUtil.strToDate(date+"-01"));
|
|
|
endTime = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(date+"-01"));
|
|
|
startTime += " 00:00:00";
|
|
|
endTime += " 23:59:59";
|
|
|
}
|
|
|
String sql = "SELECT * FROM wlyy_prescription p ";
|
|
|
if(StringUtils.isNotBlank(disease)){
|
|
|
sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
|
|
|
}else{
|
|
|
sql +=" WHERE 1=1 ";
|
|
|
}
|
|
|
if ("2".equals(type)){//已完成
|
|
|
sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.finish.getValue() ;
|
|
|
}else if ("3".equals(type)){//居民取消
|
|
|
sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue() ;
|
|
|
}else if ("4".equals(type)){//审核不通过
|
|
|
sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue() ;
|
|
|
}else if ("5".equals(type)){//进行中
|
|
|
sql += " AND p.`status` < " + PrescriptionLog.PrescriptionLogStatus.finish.getValue() +
|
|
|
" AND p.`status`>= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() ;
|
|
|
}else if ("6".equals(type)){//其他原因取消
|
|
|
sql += " AND p.`status` <= "+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue() ;
|
|
|
}
|
|
|
sql += " AND p.create_time <= ? " +
|
|
|
" AND p.create_time >= ? ";
|
|
|
List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{endTime,startTime});
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 长处方统计--长处方记录筛选
|
|
|
* @param level
|
|
|
* @param area
|
|
|
* @param disease
|
|
|
* @param status
|
|
|
* @param type
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> getPrescriptionByCondition(String level, String area, String disease, String status, String type, String startTime,String endTime){
|
|
|
|
|
|
String sql = "SELECT * FROM wlyy_prescription p ";
|
|
|
//判断疾病
|
|
|
if(StringUtils.isNotBlank(disease)){
|
|
|
if ("1".equals(disease)){
|
|
|
disease = gxy;
|
|
|
}else if ("2".equals(disease)){
|
|
|
disease = tnb;
|
|
|
}
|
|
|
sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
|
|
|
}else{
|
|
|
sql +=" WHERE 1=1 ";
|
|
|
}
|
|
|
//判断状态
|
|
|
if ("2".equals(status)){//已完成
|
|
|
sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.finish.getValue() ;
|
|
|
}else if ("3".equals(status)){//居民取消
|
|
|
sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue() ;
|
|
|
}else if ("4".equals(status)){//审核不通过
|
|
|
sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue() ;
|
|
|
}else if ("5".equals(status)){//进行中
|
|
|
sql += " AND p.`status` < " + PrescriptionLog.PrescriptionLogStatus.finish.getValue() +
|
|
|
" AND p.`status`>= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() ;
|
|
|
}else if ("6".equals(status)){//其他原因取消
|
|
|
sql += " AND p.`status` <= "+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue() ;
|
|
|
}
|
|
|
//判断取药方式
|
|
|
if (StringUtils.isNotBlank(type)){
|
|
|
//类型1.自取,2.快递配送,3.健管师配送
|
|
|
if("1".equals(type)){
|
|
|
sql +=" AND p.dispensary_type ="+type;
|
|
|
}else if("2".equals(type)){
|
|
|
sql +=" AND p.dispensary_type ="+type;
|
|
|
}else if("3".equals(type)){
|
|
|
sql +=" AND p.dispensary_type ="+type;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//市区
|
|
|
if("4".equals(level)){
|
|
|
//市区无过滤
|
|
|
//区级
|
|
|
}else if("3".equals(level)){
|
|
|
sql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
|
|
|
//机构
|
|
|
}else if("2".equals(level)){
|
|
|
sql += "AND p.hospital = '"+area+"' ";
|
|
|
}
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
|
|
startTime += " 00:00:00";
|
|
|
endTime += " 23:59:59";
|
|
|
sql += " AND p.create_time <= ? " +
|
|
|
" AND p.create_time >= ? ";
|
|
|
resultList = jdbcTemplate.queryForList(sql,new Object[]{endTime,startTime});
|
|
|
}else{
|
|
|
resultList = jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 长处方统计--上方模糊搜索
|
|
|
* @param keyWord
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> getPrescriptionByKeyWord(String keyWord){
|
|
|
String sql = "SELECT * FROM wlyy_prescription p where 1=1";
|
|
|
//判断关键字
|
|
|
if (StringUtils.isNotBlank(keyWord)){
|
|
|
sql += " AND (p.patient_name like '%"+keyWord+"%' or p.doctor_name like '%"+keyWord+"%')";
|
|
|
}
|
|
|
List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql);
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 长处方统计--点击查看详情
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String,Object> getPrescriptionByCode(String code){
|
|
|
Map<String,Object> rsMap = new HashedMap();
|
|
|
String sql ="SELECT p.code,p.patient_name,p.doctor_name,p.hospital_name,p.dispensary_type,d.health_problem " +
|
|
|
"FROM wlyy_prescription p LEFT JOIN wlyy_prescription_diagnosis d ON d.prescription_code = p.code " +
|
|
|
"WHERE p.code=? ";
|
|
|
List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{code});
|
|
|
if (resultList!=null && resultList.size()>0){
|
|
|
rsMap = resultList.get(0);
|
|
|
}
|
|
|
return rsMap;
|
|
|
}
|
|
|
}
|