|
@ -1,7 +1,8 @@
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
|
|
|
|
import org.json.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;
|
|
@ -50,6 +51,12 @@ public class PrescriptionInfoService extends BaseService {
|
|
@Autowired
|
|
@Autowired
|
|
private PrescriptionReviewedDao prescriptionReviewedDao;
|
|
private PrescriptionReviewedDao prescriptionReviewedDao;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
|
@Autowired
|
|
|
|
private PrescriptionNoticesService prescriptionNoticesService;
|
|
|
|
@Autowired
|
|
|
|
private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
|
|
|
|
@Autowired
|
|
private ImUtill imUtill;
|
|
private ImUtill imUtill;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -91,6 +98,47 @@ public class PrescriptionInfoService extends BaseService {
|
|
if(StringUtils.isNotBlank(type)){
|
|
if(StringUtils.isNotBlank(type)){
|
|
if("1".equals(type)){
|
|
if("1".equals(type)){
|
|
//基卫接口
|
|
//基卫接口
|
|
|
|
List<Map<String,Object>> prescriptions = new ArrayList<>();
|
|
|
|
Map<String,Object> p1 = new HashMap<>();
|
|
|
|
p1.put("code","2");
|
|
|
|
p1.put("hospital","3502050100");
|
|
|
|
p1.put("hospitalName","海沧区嵩屿街道社区卫生服务中心");
|
|
|
|
p1.put("doctor","hxmD201703150222");
|
|
|
|
p1.put("doctorName","黄小陌(全科)");
|
|
|
|
p1.put("adminTeamId","643");
|
|
|
|
p1.put("prescriptionType","门诊");
|
|
|
|
p1.put("date","2017-08-08 10:10:10");
|
|
|
|
if(StringUtils.isNotBlank((String)p1.get("code"))){
|
|
|
|
String sql = "SELECT p.status FROM wlyy_prescription p WHERE p.parent_code='2'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
int state = (Integer) (list.get(0).get("status"));
|
|
|
|
p1.put("status",state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
|
|
|
|
PrescriptionInfo info1 = new PrescriptionInfo();
|
|
|
|
info1.setCode("2017080700001");
|
|
|
|
info1.setPrescriptionCode("201708070001");
|
|
|
|
info1.setDel(1);
|
|
|
|
info1.setDrugCode("A1");
|
|
|
|
info1.setDrugName("A药品");
|
|
|
|
prescriptionInfos.add(info1);
|
|
|
|
|
|
|
|
List<PrescriptionDiagnosis> diagnosises = new ArrayList<>();
|
|
|
|
PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
|
|
|
|
diagnosis.setCode("1");
|
|
|
|
diagnosis.setName("糖尿病");
|
|
|
|
diagnosises.add(diagnosis);
|
|
|
|
|
|
|
|
p1.put("prescriptionDt",diagnosises);
|
|
|
|
p1.put("prescriptionInfo",prescriptionInfos);
|
|
|
|
|
|
|
|
prescriptions.add(p1);
|
|
|
|
|
|
|
|
return new JSONArray(prescriptions);
|
|
|
|
|
|
}else{
|
|
}else{
|
|
StringBuffer sqlBuffer = new StringBuffer("SELECT p.code,p.create_time AS date,p.status,p.hospital_name As hospitalName FROM wlyy_prescription p " +
|
|
StringBuffer sqlBuffer = new StringBuffer("SELECT p.code,p.create_time AS date,p.status,p.hospital_name As hospitalName FROM wlyy_prescription p " +
|
|
"WHERE p.patient=?");
|
|
"WHERE p.patient=?");
|
|
@ -203,9 +251,10 @@ public class PrescriptionInfoService extends BaseService {
|
|
* @param code
|
|
* @param code
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public int cancelPrescriotion(String code){
|
|
|
|
|
|
public int cancelPrescriotion(String code,String reason){
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
|
|
p.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
|
|
|
|
p.setCancelReason(reason);
|
|
prescriptionDao.save(p);
|
|
prescriptionDao.save(p);
|
|
//患者操作日志
|
|
//患者操作日志
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
@ -312,16 +361,17 @@ public class PrescriptionInfoService extends BaseService {
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescription",prescription);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
rs.put("reviewed",reviewed);
|
|
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.getDoctor())){
|
|
|
|
// rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
|
|
|
|
// }else{
|
|
|
|
// rs.put("doctor","");
|
|
|
|
// }
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
rs.put("patient",patientDao.findByCode(prescription.getPatient()));
|
|
rs.put("patient",patientDao.findByCode(prescription.getPatient()));
|
|
}else{
|
|
}else{
|
|
rs.put("patient","");
|
|
rs.put("patient","");
|
|
}
|
|
}
|
|
|
|
rs.put("diagnosis",prescriptionDiagnosisDao.findByPrescriptionCode(code));
|
|
return rs;
|
|
return rs;
|
|
}
|
|
}
|
|
|
|
|
|
@ -391,7 +441,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
public int updatePresInfo(String code,String infos,String reason){
|
|
|
|
|
|
public int updatePresInfo(String code,String infos,String diagnosis,String reason){
|
|
if(StringUtils.isNotBlank(code)&&StringUtils.isNotBlank(infos)){
|
|
if(StringUtils.isNotBlank(code)&&StringUtils.isNotBlank(infos)){
|
|
//同步智业接口
|
|
//同步智业接口
|
|
upload();
|
|
upload();
|
|
@ -406,18 +456,42 @@ public class PrescriptionInfoService extends BaseService {
|
|
p.setCode(getCode());
|
|
p.setCode(getCode());
|
|
p.setDel(1);
|
|
p.setDel(1);
|
|
p.setPrescriptionCode(code);
|
|
p.setPrescriptionCode(code);
|
|
p.setPrice(info.getInteger("price"));
|
|
|
|
|
|
p.setPrice(info.getInt("price"));
|
|
p.setDrugCode(info.getString("drugCode"));
|
|
p.setDrugCode(info.getString("drugCode"));
|
|
p.setDrugName(info.getString("drugName"));
|
|
p.setDrugName(info.getString("drugName"));
|
|
p.setDrugRate(info.getString("drugRate"));
|
|
p.setDrugRate(info.getString("drugRate"));
|
|
p.setDrugFormat(info.getString("drugFormat"));
|
|
p.setDrugFormat(info.getString("drugFormat"));
|
|
p.setNum(info.getInteger("num"));
|
|
|
|
p.setIsRefrigerate(info.getInteger("isRefrigerate"));
|
|
|
|
|
|
p.setNum(info.getInt("num"));
|
|
|
|
p.setIsRefrigerate(info.getInt("isRefrigerate"));
|
|
p.setDirection(info.getString("direction"));
|
|
p.setDirection(info.getString("direction"));
|
|
prescriptionInfoDao.save(p);
|
|
prescriptionInfoDao.save(p);
|
|
}
|
|
}
|
|
|
|
prescriptionDiagnosisService.setPrescriptionInfo(code);
|
|
|
|
|
|
//设置处方疾病类型
|
|
//设置处方疾病类型
|
|
prescriptionDiagnosisService.setPrescriptionDiagnosis(code);
|
|
|
|
|
|
if(StringUtils.isNotBlank(diagnosis)){
|
|
|
|
|
|
|
|
StringBuffer sql2 = new StringBuffer("UPDATE wlyy_prescription_diagnosis SET del = 0 WHERE prescription_code = '"+code+"'");
|
|
|
|
jdbcTemplate.execute(sql2.toString());
|
|
|
|
|
|
|
|
JSONArray array = new JSONArray(diagnosis);
|
|
|
|
Iterator<Object> itds = jsonArray.iterator();
|
|
|
|
while (itds.hasNext()){
|
|
|
|
JSONObject info = (JSONObject) itds.next();
|
|
|
|
PrescriptionDiagnosis p = new PrescriptionDiagnosis();
|
|
|
|
p.setCode(getCode());
|
|
|
|
p.setCreateTime(new Date());
|
|
|
|
p.setName(info.getString("name"));
|
|
|
|
p.setCode(info.getString("code"));
|
|
|
|
p.setPrescriptionCode(code);
|
|
|
|
prescriptionDiagnosisDao.save(p);
|
|
|
|
}
|
|
|
|
prescriptionDiagnosisService.setPrescriptionDiagnosis(code);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
//记录Log
|
|
//记录Log
|
|
@ -458,7 +532,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
|
|
|
public JSONArray getDrugTimes(){
|
|
public JSONArray getDrugTimes(){
|
|
|
|
|
|
List<SystemDict> list = systemDictDao.findByLikeName("%PRES_DRUG_TIME_%");
|
|
|
|
|
|
List<SystemDict> list = systemDictDao.findByLikeDictName("%PRES_DRUG_TIME_%");
|
|
|
|
|
|
return new JSONArray(list);
|
|
return new JSONArray(list);
|
|
}
|
|
}
|
|
@ -489,7 +563,7 @@ public class PrescriptionInfoService extends BaseService {
|
|
" pr.doctor " +
|
|
" pr.doctor " +
|
|
" FROM " +
|
|
" FROM " +
|
|
" wlyy_prescription pr " +
|
|
" wlyy_prescription pr " +
|
|
" LEFT JOIN wlyy_patient p ON pr.patient = p.`code` ," +
|
|
|
|
|
|
" LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
|
|
" JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
|
|
" JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
|
|
" WHERE 1=1 " );
|
|
" WHERE 1=1 " );
|
|
List<Object> params = new ArrayList<>();
|
|
List<Object> params = new ArrayList<>();
|
|
@ -506,10 +580,10 @@ public class PrescriptionInfoService extends BaseService {
|
|
public void setExpressageSql(StringBuffer pre_sql,List<Object> param,String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
|
|
public void setExpressageSql(StringBuffer pre_sql,List<Object> param,String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
|
|
if(StringUtils.isNotBlank(type)){
|
|
if(StringUtils.isNotBlank(type)){
|
|
if("1".equals(type)){
|
|
if("1".equals(type)){
|
|
pre_sql.append(" AND e.expressageCode = ?");
|
|
|
|
|
|
pre_sql.append(" AND e.expressage_Code = ?");
|
|
param.add(doctor);
|
|
param.add(doctor);
|
|
}else{
|
|
}else{
|
|
pre_sql.append(" AND e.acceptCode = ?");
|
|
|
|
|
|
pre_sql.append(" AND e.accept_Code = ?");
|
|
param.add(doctor);
|
|
param.add(doctor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -539,38 +613,60 @@ public class PrescriptionInfoService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public JSONObject getPrescriptionExpressageFilter(){
|
|
|
|
|
|
public JSONObject getPrescriptionExpressageFilter(String doctor){
|
|
JSONObject rs = new JSONObject();
|
|
JSONObject rs = new JSONObject();
|
|
// List<Map<String,Object>> states = new ArrayList<>();
|
|
|
|
// Map<String,Object> map1 = new HashMap<>();
|
|
|
|
// map1.put("name","订单已支付");
|
|
|
|
// map1.put("code",PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
|
|
|
|
// states.add(map1);
|
|
|
|
//
|
|
|
|
// Map<String,Object> map2 = new HashMap<>();
|
|
|
|
// map2.put("name","配药完成");
|
|
|
|
// map2.put("code",PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
|
|
|
|
// states.add(map2);
|
|
|
|
//
|
|
|
|
// Map<String,Object> map2 = new HashMap<>();
|
|
|
|
// map2.put("name","药品到达服务站");
|
|
|
|
// map2.put("code",PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
|
|
|
|
// states.add(map2);
|
|
|
|
//
|
|
|
|
// Map<String,Object> map3 = new HashMap<>();
|
|
|
|
// map3.put("name","配送中");
|
|
|
|
// map3.put("code",PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
|
// states.add(map3);
|
|
|
|
//
|
|
|
|
// Map<String,Object> map4 = new HashMap<>();
|
|
|
|
// map4.put("name","配药完成");
|
|
|
|
// map4.put("code",PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
|
|
|
|
// states.add(map4);
|
|
|
|
//
|
|
|
|
// Map<String,Object> map5 = new HashMap<>();
|
|
|
|
// map2.put("name","配药完成");
|
|
|
|
// map2.put("code",PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
|
// states.add(map2);
|
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> states = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String,Object> map1 = new HashMap<>();
|
|
|
|
map1.put("name","订单已支付");
|
|
|
|
map1.put("code",PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
|
|
|
|
states.add(map1);
|
|
|
|
|
|
|
|
Map<String,Object> map2 = new HashMap<>();
|
|
|
|
map2.put("name","配药完成");
|
|
|
|
map2.put("code",PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
|
|
|
|
states.add(map2);
|
|
|
|
|
|
|
|
Map<String,Object> map3 = new HashMap<>();
|
|
|
|
map3.put("name","配送中");
|
|
|
|
map3.put("code",PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
|
states.add(map3);
|
|
|
|
|
|
|
|
Map<String,Object> map4 = new HashMap<>();
|
|
|
|
map4.put("name","药品到达服务站");
|
|
|
|
map4.put("code",PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
|
|
|
|
states.add(map4);
|
|
|
|
|
|
|
|
Map<String,Object> map5 = new HashMap<>();
|
|
|
|
map2.put("name","配药完成");
|
|
|
|
map2.put("code",PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
|
states.add(map2);
|
|
|
|
//设置配送状态下拉框
|
|
|
|
rs.put("states",states);
|
|
|
|
//
|
|
|
|
Doctor d = doctorDao.findByCode(doctor);
|
|
|
|
if(d!=null&& StringUtils.isNotBlank(d.getHospital())){
|
|
|
|
String h = d.getHospital().substring(0,8);
|
|
|
|
String sql = "SELECT h.`code`,h.`name` FROM dm_hospital h WHERE h.`code` LIKE '%"+h+"%'";
|
|
|
|
List<Map<String,Object>> hs = jdbcTemplate.queryForList(sql);
|
|
|
|
rs.put("hospitals",hs);
|
|
|
|
}else{
|
|
|
|
rs.put("hospitals","");
|
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
return rs;
|
|
}
|
|
}
|
|
|
|
//
|
|
|
|
public int onMesSquareState(String mes){
|
|
|
|
JSONObject json = new JSONObject(mes);
|
|
|
|
Integer state = json.getInt("state");
|
|
|
|
String code = json.getString("prescription");
|
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
|
|
if(state!=null&&state==1){
|
|
|
|
//prescriptionNoticesService.sendMessages(weiXinAccessTokenUtils.getAccessToken(),prescription.getDoctor(),p.getCode());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
}
|
|
}
|