|
@ -410,11 +410,33 @@ public class PrescriptionService extends BaseService {
|
|
* @param endTime
|
|
* @param endTime
|
|
* @return
|
|
* @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 " +
|
|
"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(StringUtils.isNotBlank(disease)){
|
|
if ("1".equals(disease)){
|
|
if ("1".equals(disease)){
|
|
@ -422,9 +444,7 @@ public class PrescriptionService extends BaseService {
|
|
}else if ("2".equals(disease)){
|
|
}else if ("2".equals(disease)){
|
|
disease = tnb;
|
|
disease = tnb;
|
|
}
|
|
}
|
|
sql += " WHERE d.health_problem ='"+disease+"' ";
|
|
|
|
}else{
|
|
|
|
sql +=" WHERE 1=1 ";
|
|
|
|
|
|
sql += " and d.health_problem ='"+disease+"' ";
|
|
}
|
|
}
|
|
//判断状态
|
|
//判断状态
|
|
if ("2".equals(status)){//已完成
|
|
if ("2".equals(status)){//已完成
|
|
@ -466,15 +486,25 @@ public class PrescriptionService extends BaseService {
|
|
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
|
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
|
startTime += " 00:00:00";
|
|
startTime += " 00:00:00";
|
|
endTime += " 23:59:59";
|
|
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
|
|
* @param keyWord
|
|
* @return
|
|
* @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" +
|
|
String sql = "SELECT" +
|
|
" p. CODE," +
|
|
" p. CODE," +
|
|
" p.patient_name," +
|
|
" p.patient_name," +
|
|
@ -492,24 +523,34 @@ public class PrescriptionService extends BaseService {
|
|
" p. STATUS," +
|
|
" p. STATUS," +
|
|
" p.create_time," +
|
|
" p.create_time," +
|
|
" GROUP_CONCAT(d.health_problem) AS health_problem," +
|
|
" 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" +
|
|
" FROM" +
|
|
" wlyy_prescription p" +
|
|
" wlyy_prescription p" +
|
|
" LEFT JOIN wlyy_prescription_diagnosis d ON p. CODE = d.prescription_code" +
|
|
" 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" +
|
|
" WHERE" +
|
|
" 1 = 1 " ;
|
|
|
|
|
|
" IF(p.status>50,a.trade_status=1,1=1) " ;
|
|
//判断关键字
|
|
//判断关键字
|
|
if (StringUtils.isNotBlank(keyWord)){
|
|
if (StringUtils.isNotBlank(keyWord)){
|
|
sql += " AND (p.patient_name like '%"+keyWord+"%' or p.doctor_name like '%"+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 ";
|
|
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 ?,?";
|
|
sql+=" limit ?,?";
|
|
int start = (pageNo-1)*pageSize;
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|