|
@ -5,17 +5,11 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjust;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.*;
|
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionAdjustDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
|
|
|
import com.yihu.wlyy.repository.prescription.*;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.ImUtill;
|
|
@ -54,6 +48,8 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
@Autowired
|
|
|
private PrescriptionAdjustDao prescriptionAdjustDao;
|
|
|
@Autowired
|
|
|
private PrescriptionReviewedDao prescriptionReviewedDao;
|
|
|
@Autowired
|
|
|
private ImUtill imUtill;
|
|
|
|
|
|
/**
|
|
@ -138,13 +134,23 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
public JSONObject getContinuedPrescription(String code){
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
|
JSONObject rs = new JSONObject();
|
|
|
rs.put("prescription",prescription);
|
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
rs.put("reviewed",reviewed);
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
|
|
|
rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
|
|
|
Doctor doctor = doctorDao.findByCode(prescription.getDoctor());
|
|
|
if(doctor.getCertifiedOvertime()!=null &&(new Date().before(doctor.getCertifiedOvertime()))){
|
|
|
rs.put("isCertified",true);
|
|
|
rs.put("doctorName",doctor.getName());
|
|
|
}else{
|
|
|
rs.put("isCertified",false);
|
|
|
rs.put("doctorName",doctor.getName());
|
|
|
}
|
|
|
}else{
|
|
|
rs.put("doctor","");
|
|
|
rs.put("isCertified",false);
|
|
|
rs.put("doctorName","");
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
@ -161,6 +167,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
public JSONObject getPrescriptionProcess(String code){
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
|
JSONObject rs = new JSONObject();
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
@ -168,6 +175,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}else{
|
|
|
rs.put("patient","");
|
|
|
}
|
|
|
|
|
|
if(prescription.getStatus()==10){
|
|
|
Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
|
|
|
rs.put("time",s);
|
|
@ -178,6 +186,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}else{
|
|
|
rs.put("time","");
|
|
|
}
|
|
|
rs.put("reviewed",reviewed);
|
|
|
rs.put("prescription",prescription);
|
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
return rs;
|
|
@ -218,7 +227,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate,String nameKeyword,Integer page,Integer size){
|
|
|
public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate,String nameKeyword,String patient,Integer page,Integer size){
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT " +
|
|
|
" p.`name`, " +
|
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
|
|
@ -240,12 +249,12 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
" AND pr.admin_team_id =? AND s.code = ?");
|
|
|
params.add(teamCode);
|
|
|
params.add(diseases);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,page,size);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,patient,page,size);
|
|
|
}else{
|
|
|
//查询所有疾病类型表
|
|
|
pre_sql.append(" WHERE pr.admin_team_id =?");
|
|
|
params.add(teamCode);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,page,size);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,patient,page,size);
|
|
|
}
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
|
|
|
|
|
@ -258,7 +267,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
return new JSONArray(rs);
|
|
|
}
|
|
|
|
|
|
public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword,Integer page,Integer size){
|
|
|
public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword,String patient,Integer page,Integer size){
|
|
|
if(StringUtils.isNotBlank(state)){
|
|
|
pre_sql.append(" AND pr.status IN ("+state+") ");
|
|
|
}
|
|
@ -274,6 +283,10 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
pre_sql.append(" AND pr.patient_name like ? ");
|
|
|
params.add("%"+nameKeyword+"%");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(patient)){
|
|
|
pre_sql.append(" AND pr.patient = ?");
|
|
|
params.add(patient);
|
|
|
}
|
|
|
pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");
|
|
|
if(page!=null&&page>0&&size!=null&&size>0){
|
|
|
pre_sql.append(" LIMIT "+(page-1)*size+","+size);
|
|
@ -288,30 +301,53 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
public JSONObject getContinuedPrescriptionAsDoctor(String code){
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
|
JSONObject rs = new JSONObject();
|
|
|
rs.put("prescription",prescription);
|
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
rs.put("reviewed",reviewed);
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
|
|
|
rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
|
|
|
}else{
|
|
|
rs.put("doctor","");
|
|
|
}
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
|
rs.put("patient",patientDao.findByCode(prescription.getPatient()));
|
|
|
}else{
|
|
|
rs.put("patient","");
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public int reviewPrescription(String code ,String reason,String state){
|
|
|
if(StringUtils.isNotBlank(state)){
|
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
|
//新增审核记录
|
|
|
PrescriptionReviewed reviewed = new PrescriptionReviewed();
|
|
|
reviewed.setCode(getCode());
|
|
|
reviewed.setPrescriptionCode(code);
|
|
|
reviewed.setCreateTime(new Date());
|
|
|
reviewed.setRemark("医生审核");
|
|
|
reviewed.setDoctor(p.getDoctor());
|
|
|
reviewed.setDoctorName(p.getDoctorName());
|
|
|
reviewed.setHospital(p.getHospital());
|
|
|
reviewed.setHospitalName(p.getHospitalName());
|
|
|
reviewed.setDept(p.getDept());
|
|
|
reviewed.setDeptName(p.getDeptName());
|
|
|
|
|
|
if("1".equals(state)){
|
|
|
//审核通过
|
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue());
|
|
|
p.setReviewedTime(new Date());
|
|
|
reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.reviewed_success.getValue());
|
|
|
}else{
|
|
|
//审核不通过
|
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue());
|
|
|
p.setReviewedReason(reason);
|
|
|
p.setReviewedTime(new Date());
|
|
|
reviewed.setReason(reason);
|
|
|
reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.del.getValue());
|
|
|
}
|
|
|
prescriptionReviewedDao.save(reviewed);
|
|
|
prescriptionDao.save(p);
|
|
|
|
|
|
//医生操作日志
|