|
@ -1,11 +1,15 @@
|
|
|
package com.yihu.wlyy.service.prescription;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.Patient;
|
|
|
import com.yihu.wlyy.entity.prescription.*;
|
|
|
import com.yihu.wlyy.repository.PatientDao;
|
|
|
import com.yihu.wlyy.repository.prescription.*;
|
|
|
import com.yihu.wlyy.service.jw.JwPrescriptionService;
|
|
|
import com.yihu.wlyy.service.jw.PresModeAdapter;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -15,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author huangwenjie
|
|
@ -52,6 +57,18 @@ public class PrescriptionService {
|
|
|
@Autowired
|
|
|
PrescriptionPayDao prescriptionPayDao;
|
|
|
|
|
|
@Autowired
|
|
|
PrescriptionLogDao prescriptionLogDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
|
|
|
|
|
|
@Autowired
|
|
|
private JwPrescriptionService jwPrescriptionService;
|
|
|
|
|
|
@Autowired
|
|
|
private PresModeAdapter presModeAdapter;
|
|
|
|
|
|
public List<PrescriptionVO> getPrescriptionList(String hospital,
|
|
|
String disease,
|
|
|
String dispensarytype,
|
|
@ -280,33 +297,35 @@ public class PrescriptionService {
|
|
|
*/
|
|
|
public com.alibaba.fastjson.JSONObject getinfo(String code) {
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
|
List<PrescriptionAdjust> prescriptionAdjusts = prescriptionAdjustDao.findByPrescriptionCodeOrderByIdDesc(code);
|
|
|
com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
|
|
|
prescription.setStatusName("");
|
|
|
rs.put("prescription", prescription);
|
|
|
rs.put("createTime", DateUtil.dateToStrLong(prescription.getCreateTime()));
|
|
|
rs.put("reviewedTime",DateUtil.dateToStrLong(reviewed.getCreateTime()));
|
|
|
rs.put("prescriptionInfo", prescriptionInfos);
|
|
|
rs.put("reviewed", reviewed);
|
|
|
if (prescription != null && StringUtils.isNotBlank(prescription.getPatient())) {
|
|
|
rs.put("patient", patientDao.findByCode(prescription.getPatient()));
|
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
|
String rs = jwPrescriptionService.getRecipe(code, p.getSsc());
|
|
|
com.alibaba.fastjson.JSONObject r = presModeAdapter.modelToSinglePrescription(rs);
|
|
|
|
|
|
String rState = presCheckStateObj(code);
|
|
|
if ("1".equals(rState)) {
|
|
|
r.put("reviewedState", 1);
|
|
|
r.put("prescriptionCode", "");
|
|
|
} else {
|
|
|
rs.put("patient", "");
|
|
|
r.put("reviewedState", 0);
|
|
|
r.put("prescriptionCode", rState);
|
|
|
}
|
|
|
rs.put("diagnosis", prescriptionDiagnosisDao.findByPrescriptionCode(code));
|
|
|
|
|
|
if (prescriptionAdjusts != null && prescriptionAdjusts.size() > 0) {
|
|
|
rs.put("prescriptionAdjust", prescriptionAdjusts.get(0));
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
public String presCheckStateObj(String code) {
|
|
|
StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND pr.status >= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() + " AND pr.status < " + PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue());
|
|
|
List<Map<String, Object>> mp = jdbcTemplate.queryForList(sql.toString(), code);
|
|
|
if (mp != null && mp.size() > 0) {
|
|
|
return (String) ((mp.get(0)).get("code"));
|
|
|
} else {
|
|
|
rs.put("prescriptionAdjust", "");
|
|
|
return "1";
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取续方信息
|
|
|
* 获取订单跟踪
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
@ -315,12 +334,19 @@ public class PrescriptionService {
|
|
|
JSONObject jo = new JSONObject();
|
|
|
//获取处方信息
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
|
|
|
// AdminTeam adminTeam = adminTeamService.getTeam(prescription.getAdminTeamId());
|
|
|
//获取处方药品信息
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
//获取付款信息
|
|
|
PrescriptionPay prescriptionPay = prescriptionPayDao.findByPrescriptionPay(code);
|
|
|
//获取配送信息
|
|
|
PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(code);
|
|
|
jo.put("prescriptionExpressage", prescriptionExpressage);
|
|
|
|
|
|
jo.put("prescriptionInfos", prescriptionInfos);
|
|
|
jo.put("prescriptionPay", prescriptionPay);
|
|
|
jo.put("prescriptionExpressage", prescriptionExpressage);
|
|
|
// jo.put("leadCode", adminTeam.getLeaderCode());//团队长code
|
|
|
if (prescription != null) {
|
|
|
jo.put("createTime", prescription.getCreateTime());//创建时间
|
|
|
jo.put("doctorName", prescription.getDoctorName());//审核医生
|
|
@ -329,8 +355,74 @@ public class PrescriptionService {
|
|
|
jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
|
|
|
jo.put("prescriptionStatus", prescription.getStatus());//处方状态
|
|
|
jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), "",""));//处方状态名称
|
|
|
jo.put("ssc",prescription.getSsc());//医保卡号
|
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
|
jo.put("patient",p.getCode());
|
|
|
jo.put("patientName",p.getName());
|
|
|
jo.put("IdCard",p.getIdcard());
|
|
|
jo.put("ssc",p.getSsc());
|
|
|
}
|
|
|
|
|
|
|
|
|
// (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中 , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
|
|
|
// 40配药成功/待配送 41配送失败 42配送中 43配送到服务站 100配送到患者手中/已完成)
|
|
|
Integer[] status = new Integer[]{
|
|
|
PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue(),
|
|
|
// PrescriptionLog.PrescriptionLogStatus.adding.getValue(), //暂无此状态
|
|
|
PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
|
|
|
PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
|
|
|
PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
|
|
|
PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
|
|
|
List<PrescriptionLog> prescriptionLogs = prescriptionLogDao.findPrescriptionLogsByPrescriptionCode(code, status);
|
|
|
|
|
|
//加上快递的log
|
|
|
List<PrescriptionExpressageLog> expressageLogs = prescriptionExpressageLogDao.findByPrescriptionCode(code);
|
|
|
for (int i = 0; i < expressageLogs.size(); i++) {
|
|
|
PrescriptionExpressageLog prescriptionExpressageLog = expressageLogs.get(i);
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
prescriptionLog.setCreateTime(prescriptionExpressageLog.getCreateTime());
|
|
|
prescriptionLog.setHospital(prescriptionExpressageLog.getAcceptHospital());
|
|
|
prescriptionLog.setHospitalName(prescriptionExpressageLog.getAcceptHospitalName());
|
|
|
prescriptionLog.setUserCode(prescriptionExpressageLog.getAcceptUser());
|
|
|
prescriptionLog.setUserName(prescriptionExpressageLog.getAcceptUserName());
|
|
|
prescriptionLogs.add(prescriptionLog);
|
|
|
}
|
|
|
//排序
|
|
|
//排序
|
|
|
prescriptionLogs.sort((o1, o2) -> {
|
|
|
long map1value = o1.getCreateTime().getTime();
|
|
|
long map2value = o2.getCreateTime().getTime();
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return -1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return 1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
});
|
|
|
if (prescriptionLogs != null && prescriptionLogs.size() > 0) {
|
|
|
JSONArray ja = new JSONArray();
|
|
|
for (int i = 0; i < prescriptionLogs.size(); i++) {
|
|
|
PrescriptionLog one = prescriptionLogs.get(i);
|
|
|
org.json.JSONObject eo = new org.json.JSONObject();
|
|
|
eo.put("createTime", DateUtil.dateToStrLong(one.getCreateTime()));
|
|
|
eo.put("statusName", one.getStatusName());
|
|
|
eo.put("drugDeliveryflag", "0");
|
|
|
if(one.getStatus()==100){
|
|
|
prescription = prescriptionDao.findByCode(one.getPrescriptionCode());
|
|
|
if(prescription!=null&&prescription.getDrugDeliveryFlag()==1){
|
|
|
eo.put("drugDeliveryflag", "1");
|
|
|
eo.put("drugDeliveryOperatorName",prescription.getDrugDeliveryOperatorName());
|
|
|
eo.put("drugDelivery",prescription.getDrugDeliveryReasonValue()+","+prescription.getDrugDeliveryReason());
|
|
|
}
|
|
|
}
|
|
|
ja.put(eo);
|
|
|
jo.put("expresslog",jo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
return jo;
|
|
|
}
|
|
|
}
|