|
@ -5,17 +5,11 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
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.dict.SystemDictDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
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.service.BaseService;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.ImUtill;
|
|
import com.yihu.wlyy.util.ImUtill;
|
|
@ -54,6 +48,8 @@ public class PrescriptionInfoService extends BaseService {
|
|
@Autowired
|
|
@Autowired
|
|
private PrescriptionAdjustDao prescriptionAdjustDao;
|
|
private PrescriptionAdjustDao prescriptionAdjustDao;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
private PrescriptionReviewedDao prescriptionReviewedDao;
|
|
|
|
@Autowired
|
|
private ImUtill imUtill;
|
|
private ImUtill imUtill;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -74,10 +70,10 @@ public class PrescriptionInfoService extends BaseService {
|
|
List<Map<String,Object>> diseases = new ArrayList<>();
|
|
List<Map<String,Object>> diseases = new ArrayList<>();
|
|
Map<String,Object> dis1 = new HashMap<>();
|
|
Map<String,Object> dis1 = new HashMap<>();
|
|
dis1.put("code","1");
|
|
dis1.put("code","1");
|
|
dis1.put("name","糖尿病");
|
|
|
|
|
|
dis1.put("name","高血压");
|
|
Map<String,Object> dis2 = new HashMap<>();
|
|
Map<String,Object> dis2 = new HashMap<>();
|
|
dis2.put("code","2");
|
|
dis2.put("code","2");
|
|
dis2.put("name","高血压");
|
|
|
|
|
|
dis2.put("name","糖尿病");
|
|
diseases.add(dis1);
|
|
diseases.add(dis1);
|
|
diseases.add(dis2);
|
|
diseases.add(dis2);
|
|
rs.put("diseases",diseases);
|
|
rs.put("diseases",diseases);
|
|
@ -112,6 +108,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
sqlBuffer.append(" AND p.create_time <= ?");
|
|
sqlBuffer.append(" AND p.create_time <= ?");
|
|
params.add(endDate+" 23:59:59");
|
|
params.add(endDate+" 23:59:59");
|
|
}
|
|
}
|
|
|
|
sqlBuffer.append(" ORDER BY p.create_time DESC ");
|
|
if(page!=null&&page>0&&size!=null&&size>0){
|
|
if(page!=null&&page>0&&size!=null&&size>0){
|
|
sqlBuffer.append(" LIMIT "+(page-1)*size+","+size);
|
|
sqlBuffer.append(" LIMIT "+(page-1)*size+","+size);
|
|
}
|
|
}
|
|
@ -137,13 +134,23 @@ public class PrescriptionInfoService extends BaseService {
|
|
public JSONObject getContinuedPrescription(String code){
|
|
public JSONObject getContinuedPrescription(String code){
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
JSONObject rs = new JSONObject();
|
|
JSONObject rs = new JSONObject();
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
|
rs.put("reviewed",reviewed);
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
|
|
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{
|
|
}else{
|
|
rs.put("doctor","");
|
|
|
|
|
|
rs.put("isCertified",false);
|
|
|
|
rs.put("doctorName","");
|
|
}
|
|
}
|
|
return rs;
|
|
return rs;
|
|
}
|
|
}
|
|
@ -160,6 +167,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
public JSONObject getPrescriptionProcess(String code){
|
|
public JSONObject getPrescriptionProcess(String code){
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
JSONObject rs = new JSONObject();
|
|
JSONObject rs = new JSONObject();
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
@ -167,16 +175,18 @@ public class PrescriptionInfoService extends BaseService {
|
|
}else{
|
|
}else{
|
|
rs.put("patient","");
|
|
rs.put("patient","");
|
|
}
|
|
}
|
|
|
|
|
|
if(prescription.getStatus()==10){
|
|
if(prescription.getStatus()==10){
|
|
Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
|
|
Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
|
|
rs.put("time",s);
|
|
rs.put("time",s);
|
|
if(s>172800){
|
|
if(s>172800){
|
|
prescription.setStatus(-3);
|
|
|
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue());
|
|
prescriptionDao.save(prescription);
|
|
prescriptionDao.save(prescription);
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
rs.put("time","");
|
|
rs.put("time","");
|
|
}
|
|
}
|
|
|
|
rs.put("reviewed",reviewed);
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
return rs;
|
|
return rs;
|
|
@ -189,12 +199,12 @@ public class PrescriptionInfoService extends BaseService {
|
|
*/
|
|
*/
|
|
public int cancelPrescriotion(String code){
|
|
public int cancelPrescriotion(String code){
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
p.setStatus(-2);
|
|
|
|
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
|
|
prescriptionDao.save(p);
|
|
prescriptionDao.save(p);
|
|
//患者操作日志
|
|
//患者操作日志
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
log.setCode(getCode());
|
|
log.setCode(getCode());
|
|
log.setStatus(-2);
|
|
|
|
|
|
log.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
|
|
log.setType(-1);
|
|
log.setType(-1);
|
|
log.setCreateTime(new Date());
|
|
log.setCreateTime(new Date());
|
|
log.setPrescriptionCode(p.getCode());
|
|
log.setPrescriptionCode(p.getCode());
|
|
@ -217,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 " +
|
|
StringBuffer pre_sql = new StringBuffer("SELECT " +
|
|
" p.`name`, " +
|
|
" p.`name`, " +
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
|
|
@ -239,12 +249,12 @@ public class PrescriptionInfoService extends BaseService {
|
|
" AND pr.admin_team_id =? AND s.code = ?");
|
|
" AND pr.admin_team_id =? AND s.code = ?");
|
|
params.add(teamCode);
|
|
params.add(teamCode);
|
|
params.add(diseases);
|
|
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{
|
|
}else{
|
|
//查询所有疾病类型表
|
|
//查询所有疾病类型表
|
|
pre_sql.append(" WHERE pr.admin_team_id =?");
|
|
pre_sql.append(" WHERE pr.admin_team_id =?");
|
|
params.add(teamCode);
|
|
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());
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
|
|
|
|
|
|
@ -257,23 +267,26 @@ public class PrescriptionInfoService extends BaseService {
|
|
return new JSONArray(rs);
|
|
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)){
|
|
if(StringUtils.isNotBlank(state)){
|
|
pre_sql.append(" AND pr.status = ?");
|
|
|
|
params.add(state);
|
|
|
|
|
|
pre_sql.append(" AND pr.status IN ("+state+") ");
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(startDate)){
|
|
if(StringUtils.isNotBlank(startDate)){
|
|
pre_sql.append(" AND pr.create_time >= ?");
|
|
|
|
|
|
pre_sql.append(" AND pr.create_time >= ? ");
|
|
params.add(startDate);
|
|
params.add(startDate);
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(endDate)){
|
|
if(StringUtils.isNotBlank(endDate)){
|
|
pre_sql.append(" AND pr.create_time <= ?");
|
|
|
|
|
|
pre_sql.append(" AND pr.create_time <= ? ");
|
|
params.add(endDate);
|
|
params.add(endDate);
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(nameKeyword)){
|
|
if(StringUtils.isNotBlank(nameKeyword)){
|
|
pre_sql.append(" AND pr.patient_name like ?");
|
|
|
|
|
|
pre_sql.append(" AND pr.patient_name like ? ");
|
|
params.add("%"+nameKeyword+"%");
|
|
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");
|
|
pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");
|
|
if(page!=null&&page>0&&size!=null&&size>0){
|
|
if(page!=null&&page>0&&size!=null&&size>0){
|
|
pre_sql.append(" LIMIT "+(page-1)*size+","+size);
|
|
pre_sql.append(" LIMIT "+(page-1)*size+","+size);
|
|
@ -288,29 +301,56 @@ public class PrescriptionInfoService extends BaseService {
|
|
public JSONObject getContinuedPrescriptionAsDoctor(String code){
|
|
public JSONObject getContinuedPrescriptionAsDoctor(String code){
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
|
|
JSONObject rs = new JSONObject();
|
|
JSONObject rs = new JSONObject();
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
|
rs.put("reviewed",reviewed);
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
|
|
rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
|
|
rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
|
|
}else{
|
|
}else{
|
|
rs.put("doctor","");
|
|
rs.put("doctor","");
|
|
}
|
|
}
|
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
|
|
rs.put("patient",patientDao.findByCode(prescription.getPatient()));
|
|
|
|
}else{
|
|
|
|
rs.put("patient","");
|
|
|
|
}
|
|
return rs;
|
|
return rs;
|
|
}
|
|
}
|
|
|
|
|
|
public int reviewPrescription(String code ,String reason,String state){
|
|
public int reviewPrescription(String code ,String reason,String state){
|
|
if(StringUtils.isNotBlank(state)){
|
|
if(StringUtils.isNotBlank(state)){
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
|
|
//更新审核记录
|
|
|
|
PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(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)){
|
|
if("1".equals(state)){
|
|
//审核通过
|
|
//审核通过
|
|
p.setStatus(10);
|
|
|
|
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue());
|
|
p.setReviewedTime(new Date());
|
|
p.setReviewedTime(new Date());
|
|
|
|
reviewed.setReviewedTime(new Date());
|
|
|
|
reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.reviewed_success.getValue());
|
|
}else{
|
|
}else{
|
|
//审核不通过
|
|
//审核不通过
|
|
p.setStatus(-1);
|
|
|
|
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue());
|
|
p.setReviewedTime(new Date());
|
|
p.setReviewedTime(new Date());
|
|
|
|
reviewed.setReason(reason);
|
|
|
|
reviewed.setReviewedTime(new Date());
|
|
|
|
reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.del.getValue());
|
|
}
|
|
}
|
|
|
|
prescriptionReviewedDao.save(reviewed);
|
|
prescriptionDao.save(p);
|
|
prescriptionDao.save(p);
|
|
|
|
|
|
//医生操作日志
|
|
//医生操作日志
|
|
@ -409,4 +449,11 @@ public class PrescriptionInfoService extends BaseService {
|
|
public String upload(){
|
|
public String upload(){
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public JSONArray getDrugTimes(){
|
|
|
|
|
|
|
|
List<SystemDict> list = systemDictDao.findByLikeName("%PRES_DRUG_TIME_%");
|
|
|
|
|
|
|
|
return new JSONArray(list);
|
|
|
|
}
|
|
}
|
|
}
|