|
@ -1,10 +1,16 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.*;
|
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
@ -13,9 +19,9 @@ import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
|
import com.yihu.wlyy.util.ImUtill;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -58,6 +64,8 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
@Autowired
|
|
|
private ImUtill imUtill;
|
|
|
@Autowired
|
|
|
private DoctorAdminTeamDao doctorAdminTeamDao;
|
|
|
@Autowired
|
|
|
private MessageDao messageDao;
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
|
|
@ -546,7 +554,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
* @param size 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getDoctorPrescriptionExpressage(String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
|
|
|
public JSONArray getHDoctorPrescriptionExpressage(String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
|
|
|
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT " +
|
|
|
" p.`name`, " +
|
|
@ -584,7 +592,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(nameKey)){
|
|
|
pre_sql.append(" AND p.name = ? ");
|
|
|
pre_sql.append(" AND p.name LIKE ? ");
|
|
|
param.add("%"+nameKey+"%");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(startDate)){
|
|
@ -672,4 +680,196 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
public JSONObject getPrescriptionExpressageAsdoctorFilter(){
|
|
|
JSONObject rs = new JSONObject();
|
|
|
|
|
|
List<Map<String,Object>> states = new ArrayList<>();
|
|
|
|
|
|
Map<String,Object> map1 = new HashMap<>();
|
|
|
map1.put("name","订单已支付");
|
|
|
map1.put("code",PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
|
|
|
states.add(map1);
|
|
|
|
|
|
Map<String,Object> map2 = new HashMap<>();
|
|
|
map2.put("name","配药完成");
|
|
|
map2.put("code",PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
|
|
|
states.add(map2);
|
|
|
|
|
|
Map<String,Object> map3 = new HashMap<>();
|
|
|
map3.put("name","配送中");
|
|
|
map3.put("code",PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
states.add(map3);
|
|
|
|
|
|
Map<String,Object> map4 = new HashMap<>();
|
|
|
map4.put("name","药品到达服务站");
|
|
|
map4.put("code",PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
states.add(map4);
|
|
|
|
|
|
Map<String,Object> map5 = new HashMap<>();
|
|
|
map2.put("name","配药完成");
|
|
|
map2.put("code",PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
states.add(map2);
|
|
|
//设置配送状态下拉框
|
|
|
rs.put("states",states);
|
|
|
|
|
|
|
|
|
//1 自取 2快递配送 3健管师配送
|
|
|
List<Map<String,Object>> dispensaryTypes = new ArrayList<>();
|
|
|
|
|
|
Map<String,Object> type1 = new HashMap<>();
|
|
|
type1.put("name","自取");
|
|
|
type1.put("code","1");
|
|
|
dispensaryTypes.add(type1);
|
|
|
|
|
|
Map<String,Object> type2 = new HashMap<>();
|
|
|
type2.put("name","快递配送");
|
|
|
type2.put("code","2");
|
|
|
dispensaryTypes.add(type2);
|
|
|
|
|
|
Map<String,Object> type3 = new HashMap<>();
|
|
|
type3.put("name","健管师配送");
|
|
|
type3.put("code","3");
|
|
|
dispensaryTypes.add(type3);
|
|
|
//设置配送状态下拉框
|
|
|
rs.put("dispensaryTypes",dispensaryTypes);
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public JSONArray getDoctorPrescriptionExpressage(String teamCode, String nameKey,String startDate,String endDate,String hospital,String state,String dispensaryType,String AllocationType,Integer page,Integer size){
|
|
|
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT " +
|
|
|
" p.`name`, " +
|
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
|
|
|
" p.sex, " +
|
|
|
" p.photo, " +
|
|
|
" pr.`status`, " +
|
|
|
" pr.`code`, " +
|
|
|
" LEFT(pr.create_time,19) AS createTime, " +
|
|
|
" pr.doctor, " +
|
|
|
" pr.dispensary_type,"+
|
|
|
" e.expressage_code AS expressageCode "+
|
|
|
" FROM " +
|
|
|
" wlyy_prescription pr " +
|
|
|
" LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
|
|
|
" JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
|
|
|
" JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code " +
|
|
|
" WHERE 1=1 " );
|
|
|
List<Object> params = new ArrayList<>();
|
|
|
setDoctorExpressageSql(pre_sql,params, teamCode, nameKey, startDate, endDate, hospital, state,dispensaryType,AllocationType, page, size);
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
|
|
|
//通过缓存查找药品和疾病
|
|
|
for(Map<String,Object> map :rs){
|
|
|
String code = (String)map.get("code");
|
|
|
map.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(code));
|
|
|
map.put("prescriptionDt", prescriptionDiagnosisService.getPrescriptionDiagnosis(code));
|
|
|
}
|
|
|
return new JSONArray(rs);
|
|
|
}
|
|
|
|
|
|
public void setDoctorExpressageSql(StringBuffer pre_sql,List<Object> param,String teamCode, String nameKey,String startDate,String endDate,String hospital,String state,String dispensaryType,String AllocationType,Integer page,Integer size){
|
|
|
if(StringUtils.isNotBlank(nameKey)){
|
|
|
pre_sql.append(" AND p.name LIKE ? ");
|
|
|
param.add("%"+nameKey+"%");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(teamCode)){
|
|
|
pre_sql.append(" AND p.admin_team_id = ? ");
|
|
|
param.add("%"+teamCode+"%");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(startDate)){
|
|
|
pre_sql.append(" AND pr.create_time >= ? ");
|
|
|
param.add(startDate+" 00:00:00");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(endDate)){
|
|
|
pre_sql.append(" AND pr.create_time <= ? ");
|
|
|
param.add(startDate+" 23:59:59");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(hospital)){
|
|
|
pre_sql.append(" AND e.hospital_code = ? ");
|
|
|
param.add(hospital);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(state)){
|
|
|
pre_sql.append(" AND pr.status = ? ");
|
|
|
param.add(state);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(dispensaryType)){
|
|
|
pre_sql.append(" AND pr.dispensary_type = ? ");
|
|
|
param.add(dispensaryType);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(AllocationType)){
|
|
|
//1为未分配建管师列表
|
|
|
if("1".equals(AllocationType)){
|
|
|
pre_sql.append(" AND pr.expressage_code IS NULL ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
pre_sql.append(" ORDER BY r.reviewed_time DESC ");
|
|
|
if(page!=null&&size!=null){
|
|
|
pre_sql.append(" LIMIT "+(page-1)*size+","+size);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public JSONObject getCountExpressage(String teamCode){
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS count FROM " +
|
|
|
" wlyy_prescription pr " +
|
|
|
" JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
|
|
|
" WHERE pr.admin_team_id = ? "+
|
|
|
" AND pr.dispensary_type =3" +
|
|
|
" AND e.expressage_code IS NULL");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(pre_sql.toString(),new Object[]{teamCode});
|
|
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
Map<String,Object> map = list.get(0);
|
|
|
return new JSONObject(map);
|
|
|
}else{
|
|
|
JSONObject rs = new JSONObject();
|
|
|
rs.put("count",0);
|
|
|
return rs;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public JSONArray getHospitalListTitle(String teamCode){
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT e.hospital_code AS hospitalCode ,e.hospital_name AS hospitalName FROM " +
|
|
|
" wlyy_prescription pr " +
|
|
|
" JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
|
|
|
" WHERE pr.admin_team_id = ? "+
|
|
|
" AND e.expressage_code IS NULL " +
|
|
|
" AND pr.dispensary_type =3 " +
|
|
|
" GROUP BY e.hospital_code ");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(pre_sql.toString(),new Object[]{teamCode});
|
|
|
return new JSONArray(list);
|
|
|
}
|
|
|
|
|
|
public JSONArray getTeamHealthDoctorCount(String doctor){
|
|
|
Doctor d = doctorDao.findByCode(doctor);
|
|
|
List<AdminTeam> adminTeams = doctorAdminTeamDao.findByOrgCode(d.getHospital());
|
|
|
List<Map<String,Object>> rsList = new ArrayList<>();
|
|
|
if(adminTeams!=null&&adminTeams.size()>0){
|
|
|
for(AdminTeam adminTeam : adminTeams){
|
|
|
|
|
|
Map<String,Object> m = new HashedMap();
|
|
|
m.put("adminTeamCode",adminTeam.getId());
|
|
|
m.put("adminTeamName",adminTeam.getName());
|
|
|
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT " +
|
|
|
" COUNT(1) AS count " +
|
|
|
" FROM " +
|
|
|
" wlyy_admin_team_member m " +
|
|
|
" JOIN wlyy_doctor d ON d. CODE = m.doctor_code " +
|
|
|
" WHERE " +
|
|
|
" d.`level` = 3 " +
|
|
|
" AND m.team_id = ? ");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(pre_sql.toString(),new Object[]{adminTeam.getId()});
|
|
|
if(list!=null&&list.size()>0){
|
|
|
Map<String,Object> map = list.get(0);
|
|
|
m.put("count",map.get("count"));
|
|
|
}else{
|
|
|
m.put("count",0);
|
|
|
}
|
|
|
rsList.add(m);
|
|
|
}
|
|
|
}
|
|
|
return new JSONArray(rsList);
|
|
|
}
|
|
|
}
|