|
@ -11,8 +11,10 @@ import com.yihu.wlyy.repository.prescription.*;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
|
|
|
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
|
|
|
import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService;
|
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
|
import com.yihu.wlyy.service.common.account.RoleService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -49,13 +51,12 @@ public class PrescriptionExpressagePCService extends BaseService {
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageService prescriptionExpressageService;
|
|
|
private PrescriptionNoticesService prescriptionNoticesService;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
public JSONObject getMedicine(String code,String userCode) throws Exception{
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
@ -155,6 +156,7 @@ public class PrescriptionExpressagePCService extends BaseService {
|
|
|
break;
|
|
|
}
|
|
|
default:{
|
|
|
jsonObject.put("status",-3);
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setPrescriptionCode(result.get("prescriptionCode").toString());
|
|
@ -183,6 +185,7 @@ public class PrescriptionExpressagePCService extends BaseService {
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
|
|
|
prescriptionLog.setRemark("PC端取药码输入错误!");
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
|
|
|
}
|
|
|
|
|
|
return jsonObject;
|
|
@ -196,57 +199,158 @@ public class PrescriptionExpressagePCService extends BaseService {
|
|
|
|
|
|
//更新二维码(isUse)
|
|
|
PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
|
|
|
prescriptionDispensaryCode.setIsUse(1);
|
|
|
prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
|
|
|
//更新处方状态
|
|
|
//判断二维码是居民取药码还是健管师取药码
|
|
|
// prescriptionDispensaryCode.setIsUse(1);
|
|
|
// prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
|
|
|
// //更新处方状态
|
|
|
// //判断二维码是居民取药码还是健管师取药码
|
|
|
Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
if(prescriptionDispensaryCode.getType()==1){//居民取药码
|
|
|
// if(prescriptionDispensaryCode.getType()==1){//居民取药码
|
|
|
//
|
|
|
// prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
// }else if(prescriptionDispensaryCode.getType()==2){
|
|
|
// prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
// }
|
|
|
// prescriptionDao.save(prescription);
|
|
|
//
|
|
|
// //处方日志
|
|
|
// PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
// prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
// prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
// prescriptionLog.setCreateTime(new Date());
|
|
|
// PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode("e707487f063540e1b6d581b16bb8fb12");
|
|
|
// if(prescriptionDispensaryCode.getType()==1){//居民取药码
|
|
|
//
|
|
|
// prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
// prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
|
|
|
// prescriptionLog.setUserCode(prescription.getPatient());
|
|
|
// prescriptionLog.setUserName(prescription.getPatientName());
|
|
|
// prescriptionLog.setUserType(1);
|
|
|
// }else if(prescriptionDispensaryCode.getType()==2){
|
|
|
// prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
// prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
|
|
|
// prescriptionLog.setUserCode(prescriptionExpressage.getExpressageCode());
|
|
|
// prescriptionLog.setUserName(prescriptionExpressage.getExpressageName());
|
|
|
// prescriptionLog.setUserType(2);
|
|
|
// //发送模板消息通知患者药品开始配送
|
|
|
//
|
|
|
// }
|
|
|
// prescriptionLog.setFlag(1);
|
|
|
// prescriptionLog.setHospital(prescriptionExpressage.getHospitalCode());
|
|
|
// prescriptionLog.setHospitalName(prescriptionExpressage.getHospitalName());
|
|
|
// prescriptionLogDao.save(prescriptionLog);
|
|
|
//// prescriptionLog.setType();
|
|
|
//// prescriptionLogDao
|
|
|
// if(prescriptionDispensaryCode.getType()==2){
|
|
|
// Patient patient = patientDao.findByCode(prescription.getPatient());
|
|
|
// String url="prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
|
|
|
// "&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName() ;
|
|
|
// }
|
|
|
// prescriptionExpressage.setExpressageTime(new Date());
|
|
|
// Doctor doctor = doctorDao.findByCode(userCode);
|
|
|
// prescriptionExpressage.setHospitalDoctorCode(userCode);
|
|
|
// prescriptionExpressage.setHospitalDoctor(doctor.getName());
|
|
|
// prescriptionExpressage.setFetchingMedicineTime(new Date());
|
|
|
// prescriptionExpressageDao.save(prescriptionExpressage);
|
|
|
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
}else if(prescriptionDispensaryCode.getType()==2){
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
|
|
|
switch (prescriptionDispensaryCode.getType()) {
|
|
|
case 1: {
|
|
|
//判断是1 居民取药码
|
|
|
dispensaryCode_1(userCode, prescriptionDispensaryCode);
|
|
|
break;
|
|
|
}
|
|
|
case 2: {
|
|
|
//判断是2 配送员(健管师)取药码
|
|
|
dispensaryCode_2(userCode,prescription.getPatient(), prescriptionDispensaryCode);
|
|
|
break;
|
|
|
}
|
|
|
default: {
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setUserCode(userCode);
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
|
|
|
prescriptionLog.setRemark("编码类型错误");
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
}
|
|
|
}
|
|
|
prescriptionDao.save(prescription);
|
|
|
}
|
|
|
|
|
|
//处方日志
|
|
|
/**
|
|
|
* 1 居民取药码 业务
|
|
|
*
|
|
|
* @param userCode
|
|
|
* @param prescriptionDispensaryCode
|
|
|
* @return
|
|
|
*/
|
|
|
public void dispensaryCode_1(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
|
|
|
|
|
|
//修改处方状态为完成
|
|
|
prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
|
|
|
//保存配送成功的日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode("e707487f063540e1b6d581b16bb8fb12");
|
|
|
if(prescriptionDispensaryCode.getType()==1){//居民取药码
|
|
|
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
|
|
|
prescriptionLog.setUserCode(prescription.getPatient());
|
|
|
prescriptionLog.setUserName(prescription.getPatientName());
|
|
|
prescriptionLog.setUserType(1);
|
|
|
}else if(prescriptionDispensaryCode.getType()==2){
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
|
|
|
prescriptionLog.setUserCode(prescriptionExpressage.getExpressageCode());
|
|
|
prescriptionLog.setUserName(prescriptionExpressage.getExpressageName());
|
|
|
prescriptionLog.setUserType(2);
|
|
|
//发送模板消息通知患者药品开始配送
|
|
|
|
|
|
}
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setHospital(prescriptionExpressage.getHospitalCode());
|
|
|
prescriptionLog.setHospitalName(prescriptionExpressage.getHospitalName());
|
|
|
prescriptionLog.setUserCode(userCode);
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
// prescriptionLog.setType();
|
|
|
// prescriptionLogDao
|
|
|
if(prescriptionDispensaryCode.getType()==2){
|
|
|
Patient patient = patientDao.findByCode(prescription.getPatient());
|
|
|
String url="prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
|
|
|
"&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName() ;
|
|
|
}
|
|
|
prescriptionExpressage.setExpressageTime(new Date());
|
|
|
|
|
|
//修改取药码code为已经使用
|
|
|
prescriptionDispensaryCode.setIsUse(1);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 配送员(健管师)取药码 业务
|
|
|
*
|
|
|
* @param userCode
|
|
|
* @param prescriptionDispensaryCode
|
|
|
* @return
|
|
|
*/
|
|
|
public void dispensaryCode_2(String userCode,String patientCode, PrescriptionDispensaryCode prescriptionDispensaryCode) throws Exception {
|
|
|
//获取配送的医生信息
|
|
|
Doctor doctor = doctorDao.findByCode(userCode);
|
|
|
prescriptionExpressage.setHospitalDoctorCode(userCode);
|
|
|
prescriptionExpressage.setHospitalDoctor(doctor.getName());
|
|
|
prescriptionExpressage.setFetchingMedicineTime(new Date());
|
|
|
prescriptionExpressageDao.save(prescriptionExpressage);
|
|
|
|
|
|
//修改处方状态为配送中
|
|
|
Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
Date expressageing = new Date();
|
|
|
prescription.setExpressageTime(expressageing);
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
|
|
|
//得到patient
|
|
|
Patient patient = patientDao.findByCode(prescription.getPatient());
|
|
|
|
|
|
//保存配送成功的日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setUserCode(userCode);
|
|
|
prescriptionLog.setUserName(doctor.getName());
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
|
|
|
//修改取药码code为已经使用
|
|
|
prescriptionDispensaryCode.setIsUse(1);
|
|
|
|
|
|
//发送模板消息通知患者药品开始配送
|
|
|
String url = "prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
|
|
|
"&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName();
|
|
|
|
|
|
|
|
|
prescriptionNoticesService.sendMessages(patientCode, doctor.getName(), DateUtil.dateToStrLong(expressageing), 3, 0, url);
|
|
|
|
|
|
}
|
|
|
}
|