|
@ -1,17 +1,24 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.*;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2017/7/27.
|
|
@ -27,6 +34,14 @@ public class PrescriptionExpressageService {
|
|
|
private PrescriptionLogDao prescriptionLogDao;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private PrescriptionNoticesService prescriptionNoticesService;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
@Value("${wechat.wechat_base_url}")
|
|
|
private String wechat_base_url;
|
|
|
@Value("${wechat.appId}")
|
|
|
private String appId;
|
|
|
|
|
|
/**
|
|
|
* 获取处方配送信息信息
|
|
@ -155,9 +170,17 @@ public class PrescriptionExpressageService {
|
|
|
* @param prescriptionDispensaryCode
|
|
|
* @return
|
|
|
*/
|
|
|
private Integer dispensaryCode_2(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
|
|
|
private Integer dispensaryCode_2(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode)throws Exception {
|
|
|
//获取配送的医生信息
|
|
|
Doctor doctor=doctorDao.findByCode(userCode);
|
|
|
|
|
|
//修改处方状态为配送中
|
|
|
prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
//修改处方状态为完成
|
|
|
Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
Date expressageing=new Date();
|
|
|
prescription.setExpressageTime(expressageing);
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
|
|
|
|
|
|
//保存配送成功的日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
@ -167,12 +190,22 @@ public class PrescriptionExpressageService {
|
|
|
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=SystemConf.getInstance().getSystemProperties().getProperty("patient_prescription_expressageing");
|
|
|
url = url.replace("{server}",wechat_base_url)
|
|
|
.replace("{appId}",appId)
|
|
|
.replace("{prescriptionCode}",prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
Patient patient = prescriptionDao.findPatientByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionNoticesService.sendMessages(patient.getOpenid(),patient.getName(),doctor.getName(), DateUtil.dateToStrLong(expressageing),3, 0,url );
|
|
|
|
|
|
return prescriptionDispensaryCode.getType();
|
|
|
}
|
|
|
|
|
@ -183,10 +216,15 @@ public class PrescriptionExpressageService {
|
|
|
* @param prescriptionDispensaryCode
|
|
|
* @return
|
|
|
*/
|
|
|
private Integer dispensaryCode_3(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
|
|
|
private Integer dispensaryCode_3(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) throws Exception{
|
|
|
//获取配送的医生信息
|
|
|
Doctor doctor=doctorDao.findByCode(userCode);
|
|
|
|
|
|
//修改处方状态为完成
|
|
|
prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
//修改处方状态为配送到服务站
|
|
|
Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
Date expressage2hospitalDate=new Date();
|
|
|
prescription.setExpressageTime(expressage2hospitalDate);
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
|
|
|
//保存配送成功的日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
@ -196,13 +234,26 @@ public class PrescriptionExpressageService {
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setUserCode(userCode);
|
|
|
prescriptionLog.setUserName(doctor.getName());
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
|
|
|
//修改取药码code为已经使用
|
|
|
prescriptionDispensaryCode.setIsUse(1);
|
|
|
|
|
|
|
|
|
//发送模板消息通知患者取药
|
|
|
String url=SystemConf.getInstance().getSystemProperties().getProperty("patient_prescription_expressage2hospital");
|
|
|
url = url.replace("{server}",wechat_base_url)
|
|
|
.replace("{appId}",appId)
|
|
|
.replace("{prescriptionCode}",prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
|
|
|
Patient patient = prescriptionDao.findPatientByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionNoticesService.sendMessages(patient.getOpenid(),patient.getName(),doctor.getName(), DateUtil.dateToStrLong(expressage2hospitalDate),4, 0, url);
|
|
|
|
|
|
return prescriptionDispensaryCode.getType();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|