|
@ -6,11 +6,13 @@ 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.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;
|
|
@ -49,6 +51,8 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
@Autowired
|
|
|
private PrescriptionDiagnosisService prescriptionDiagnosisService;
|
|
|
@Autowired
|
|
|
private PrescriptionAdjustDao prescriptionAdjustDao;
|
|
|
@Autowired
|
|
|
private ImUtill imUtill;
|
|
|
|
|
|
/**
|
|
@ -104,7 +108,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}
|
|
|
//本地库
|
|
|
List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),params.toArray());
|
|
|
|
|
|
//通过缓存查找药品和疾病
|
|
|
for(Map<String,Object> map :rs){
|
|
|
String code = (String)map.get("code");
|
|
|
map.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(code));
|
|
@ -194,7 +198,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate ){
|
|
|
public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate,String nameKeyword){
|
|
|
StringBuffer pre_sql = new StringBuffer("SELECT " +
|
|
|
" p.`name`, " +
|
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
|
|
@ -215,18 +219,25 @@ 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);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate,nameKeyword);
|
|
|
}else{
|
|
|
//查询所有疾病类型表
|
|
|
pre_sql.append(" WHERE pr.admin_team_id =?");
|
|
|
params.add(teamCode);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate);
|
|
|
setSQL(pre_sql,params,state,startDate,endDate,nameKeyword);
|
|
|
}
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
|
|
|
|
|
|
//通过缓存查找药品和疾病
|
|
|
for(Map<String,Object> map :rs){
|
|
|
String code = (String)map.get("code");
|
|
|
map.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(code));
|
|
|
map.put("prescriptionDt", prescriptionDiagnosisService.getPrescriptionDiagnosis(code));
|
|
|
}
|
|
|
return new JSONArray(rs);
|
|
|
}
|
|
|
|
|
|
public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate){
|
|
|
public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword){
|
|
|
if(StringUtils.isNotBlank(state)){
|
|
|
pre_sql.append(" AND pr.status = ?");
|
|
|
params.add(state);
|
|
@ -239,7 +250,11 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
pre_sql.append(" AND pr.create_time <= ?");
|
|
|
params.add(endDate);
|
|
|
}
|
|
|
pre_sql.append(" ORDER BY pr.create_time DESC");
|
|
|
if(StringUtils.isNotBlank(nameKeyword)){
|
|
|
pre_sql.append(" AND pr.patient_name like ?");
|
|
|
params.add("%"+nameKeyword+"%");
|
|
|
}
|
|
|
pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -274,7 +289,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}
|
|
|
prescriptionDao.save(p);
|
|
|
|
|
|
//患者操作日志
|
|
|
//医生操作日志
|
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
|
log.setCode(getCode());
|
|
|
log.setStatus(p.getStatus());
|
|
@ -306,7 +321,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
public int updatePresInfo(String code,String infos){
|
|
|
public int updatePresInfo(String code,String infos,String reason){
|
|
|
if(StringUtils.isNotBlank(code)&&StringUtils.isNotBlank(infos)){
|
|
|
//同步智业接口
|
|
|
upload();
|
|
@ -333,6 +348,35 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
}
|
|
|
//设置处方疾病类型
|
|
|
prescriptionDiagnosisService.setPrescriptionDiagnosis(code);
|
|
|
|
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
|
//记录Log
|
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
|
log.setCode(getCode());
|
|
|
log.setStatus(p.getStatus());
|
|
|
log.setType(4);
|
|
|
log.setCreateTime(new Date());
|
|
|
log.setPrescriptionCode(p.getCode());
|
|
|
log.setUserCode(p.getDoctor());
|
|
|
log.setUserName(p.getDoctorName());
|
|
|
log.setHospitalName(p.getHospitalName());
|
|
|
log.setHospital(p.getHospital());
|
|
|
log.setUserType(2);
|
|
|
log.setFlag(1);
|
|
|
log.setRemark("调整处方");
|
|
|
prescriptionLogDao.save(log);
|
|
|
|
|
|
//记录流水
|
|
|
PrescriptionAdjust prescriptionAdjust = new PrescriptionAdjust();
|
|
|
prescriptionAdjust.setCode(getCode());
|
|
|
prescriptionAdjust.setCreateTime(new Date());
|
|
|
prescriptionAdjust.setReason(reason);
|
|
|
prescriptionAdjust.setUserCode(p.getDoctor());
|
|
|
prescriptionAdjust.setUserName(p.getDoctorName());
|
|
|
prescriptionAdjust.setUserType("1");
|
|
|
prescriptionAdjust.setPrescriptionCode(code);
|
|
|
prescriptionAdjustDao.save(prescriptionAdjust);
|
|
|
|
|
|
return 1 ;
|
|
|
}
|
|
|
return 0;
|