|
@ -8,21 +8,24 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.prescription.*;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.UUID;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2017/7/27.
|
|
|
* 订单物流相关
|
|
|
*/
|
|
|
@Service
|
|
|
public class PrescriptionExpressageService {
|
|
|
public class PrescriptionExpressageService extends BaseService {
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageDao prescriptionExpressageDao;
|
|
|
@Autowired
|
|
@ -43,6 +46,8 @@ public class PrescriptionExpressageService {
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
@ -247,8 +252,8 @@ public class PrescriptionExpressageService {
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
|
|
|
//回填配送表的配送时间
|
|
|
PrescriptionExpressage prescriptionExpressage=prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionExpressage.setExpressageTime(expressageing );
|
|
|
PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionExpressage.setExpressageTime(expressageing);
|
|
|
|
|
|
//得到patient
|
|
|
Patient patient = patientDao.findByCode(prescription.getPatient());
|
|
@ -458,4 +463,195 @@ public class PrescriptionExpressageService {
|
|
|
prescriptionExpressage.setExpressageHospitalAddress(hospitalAddress);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getDrugDeliveryState() {
|
|
|
String sql = "SELECT * FROM system_dict t WHERE t.dict_name = 'DRUGDELIVERY_STATE' ORDER BY DESC";
|
|
|
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getEsListByIDCardOrSSC(String keyWord, Integer page, Integer pageSize) {
|
|
|
|
|
|
Patient p = null;
|
|
|
if (StringUtils.isNotBlank(keyWord)) {
|
|
|
p = patientDao.findByIdcard(keyWord);
|
|
|
if (p == null) {
|
|
|
p = patientDao.findBySsc(keyWord);
|
|
|
}
|
|
|
if (p != null) {
|
|
|
int start = (page - 1) * pageSize;
|
|
|
String sql = "SELECT " +
|
|
|
" py.charge_no AS chargeNo, " +
|
|
|
" p.patient_name AS patientName, " +
|
|
|
" p.patient AS patientCode, " +
|
|
|
" py.pay_time AS payTime, " +
|
|
|
" p.dispensary_type AS dispensaryType, " +
|
|
|
" p.`status` " +
|
|
|
" FROM " +
|
|
|
" wlyy_prescription p " +
|
|
|
" JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
|
|
|
" WHERE " +
|
|
|
" p.patient = '" + p.getCode() + "' " +
|
|
|
" AND p.`status`>=50 " +
|
|
|
" ORDER BY p.`status` ASC " +
|
|
|
" LIMIT " + start + "," + pageSize;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String saveDrugDelivery(String doctor, String prescriptionCode, String reasonCode, String reasonName, String reason) {
|
|
|
Prescription p = prescriptionDao.findByCode(prescriptionCode);
|
|
|
Doctor d = doctorDao.findByCode(doctor);
|
|
|
if (p != null) {
|
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
p.setDrugDeliveryflag(1);
|
|
|
p.setDrugDeliveryOperator(doctor);
|
|
|
p.setDrugDeliveryOperatorName(d.getName());
|
|
|
p.setDrugDeliveryReason(reason);
|
|
|
p.setDrugDeliveryReasonCode(reasonCode);
|
|
|
p.setDrugDeliveryOperatorName(reasonName);
|
|
|
p.setDrugDeliveryTime(new Date());
|
|
|
prescriptionDao.save(p);
|
|
|
|
|
|
//更新日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setPrescriptionCode(p.getCode());
|
|
|
prescriptionLog.setCode(getCode());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setUserCode(doctor);
|
|
|
prescriptionLog.setUserName(d.getName());
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
|
|
|
//更新二维码(isUse)
|
|
|
PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
|
|
|
//修改取药码code为已经使用
|
|
|
prescriptionDispensaryCode.setIsUse(1);
|
|
|
prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
|
|
|
|
|
|
//更新配送信息
|
|
|
PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionExpressage.setHospitalDoctor(doctor);
|
|
|
prescriptionExpressage.setHospitalDoctorCode(d.getCode());
|
|
|
prescriptionExpressage.setFetchingMedicineTime(new Date());
|
|
|
prescriptionExpressageDao.save(prescriptionExpressage);
|
|
|
|
|
|
return "1";
|
|
|
}
|
|
|
return "0";
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getPresStatesList() {
|
|
|
List<Map<String, Object>> rs = new ArrayList<>();
|
|
|
Map<String, Object> map1 = new HashedMap();
|
|
|
map1.put("code", PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
|
|
|
map1.put("name", PrescriptionLog.PrescriptionLogStatus.pay_success.getName());
|
|
|
rs.add(map1);
|
|
|
|
|
|
Map<String, Object> map2 = new HashedMap();
|
|
|
map2.put("code", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
|
|
|
map2.put("name", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getName());
|
|
|
rs.add(map2);
|
|
|
|
|
|
Map<String, Object> map3 = new HashedMap();
|
|
|
map3.put("code", PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
map3.put("name", PrescriptionLog.PrescriptionLogStatus.expressageing.getName());
|
|
|
rs.add(map3);
|
|
|
|
|
|
Map<String, Object> map4 = new HashedMap();
|
|
|
map4.put("code", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
map4.put("name", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getName());
|
|
|
rs.add(map4);
|
|
|
|
|
|
Map<String, Object> map5 = new HashedMap();
|
|
|
map5.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
map5.put("name", PrescriptionLog.PrescriptionLogStatus.finish.getName());
|
|
|
rs.add(map5);
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getPresEsPayList(String keyWord, String state, String type, String startDate, String endDate, String operator,String flag,Integer page, Integer pageSize) {
|
|
|
int start = (page - 1) * pageSize;
|
|
|
String sql = "SELECT " +
|
|
|
" py.charge_no AS chargeNo, " +
|
|
|
" p.patient_name AS patientName, " +
|
|
|
" p.patient AS patientCode, " +
|
|
|
" py.pay_time AS payTime, " +
|
|
|
" p.dispensary_type AS dispensaryType, " +
|
|
|
" p.drug_delivery_operator_name AS operatorName," +
|
|
|
" p.drug_delivery_flag AS drugDeliveryFlag, " +
|
|
|
" p.`status` " +
|
|
|
" FROM " +
|
|
|
" wlyy_prescription p " +
|
|
|
" JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
|
|
|
" WHERE" +
|
|
|
" 1=1 ";
|
|
|
sql = setSQL( sql,keyWord,state,type,startDate,endDate,operator,flag);
|
|
|
sql += " AND p.`status`>=50 " +
|
|
|
" ORDER BY py.create_time DESC " +
|
|
|
" LIMIT " + start + "," + pageSize;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public String setSQL(String sql,String keyWord, String state, String type, String startDate, String endDate,String operator,String flag){
|
|
|
//关键字搜索
|
|
|
if(StringUtils.isNotBlank(keyWord)){
|
|
|
Patient p = patientDao.findByIdcard(keyWord);
|
|
|
if(p!=null){
|
|
|
sql += " AND p.patient = '"+p.getCode()+"' ";
|
|
|
}else{
|
|
|
p = patientDao.findBySsc(keyWord);
|
|
|
if(p!=null){
|
|
|
sql += " AND p.patient = '"+p.getCode()+"' ";
|
|
|
}else{
|
|
|
sql += " AND ( py.charge_no = '"+keyWord+"' OR p.patient_name ='"+keyWord+"' )";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(state)){
|
|
|
sql += " AND p.status = "+state ;
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(type)){
|
|
|
sql +=" AND p.dispensary_type =" +type;
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(startDate)){
|
|
|
startDate +=" 00:00:00";
|
|
|
sql += " AND py.create_time >='"+startDate+"' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(endDate)){
|
|
|
endDate +=" 23:59:59";
|
|
|
sql += " AND py.create_time <='"+endDate+"' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(operator)){
|
|
|
sql += " AND p.drug_delivery_operator ='"+operator+"' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(flag)){
|
|
|
sql += " AND p.drug_delivery_flag ="+flag+" ";
|
|
|
}
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getHospitalOperator(String doctor){
|
|
|
Doctor d = doctorDao.findByCode(doctor);
|
|
|
String sql = "SELECT " +
|
|
|
" p.drug_delivery_operator AS operator, " +
|
|
|
" p.drug_delivery_operator_name AS operatorName " +
|
|
|
" FROM " +
|
|
|
" wlyy_prescription p " +
|
|
|
" WHERE " +
|
|
|
" p.hospital = '"+d.getHospital()+"' " +
|
|
|
" GROUP BY " +
|
|
|
" p.drug_delivery_operator ";
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
}
|