|
@ -1,19 +1,27 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
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.PrescriptionDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2017/7/25.
|
|
@ -25,6 +33,16 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
@Autowired
|
|
|
private SystemDictDao systemDictDao;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private PrescriptionLogDao prescriptionLogDao;
|
|
|
/**
|
|
|
* 获取处方下的详细药品
|
|
|
* @param prescriptionCode
|
|
@ -48,4 +66,104 @@ public class PrescriptionInfoService extends BaseService {
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 1:查询处方;2我的续方;3:续方记录
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getPrescriptionInfos(String type,String state,String startDate,String endDate,String diagnosisCode,String patient){
|
|
|
|
|
|
if(StringUtils.isNotBlank(type)){
|
|
|
if("1".equals(type)){
|
|
|
//基卫接口
|
|
|
}else{
|
|
|
StringBuffer sqlBuffer = new StringBuffer("SELECT p.code,p.create_time AS date,p.status,p.hospital_name As hospital FROM wlyy_prescription p " +
|
|
|
"WHERE p.status =? AND p.create_time >=? AND p.create_time <=? AND p.patient=?");
|
|
|
//本地库
|
|
|
List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),
|
|
|
new Object[]{state,startDate+" 00:00:00",endDate+" 23:59:59",patient});
|
|
|
return new JSONArray(rs);
|
|
|
}
|
|
|
}
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取续方信息
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getContinuedPrescription(String code){
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
JSONObject rs = new JSONObject();
|
|
|
rs.put("prescription",prescription);
|
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
|
|
|
rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
|
|
|
}else{
|
|
|
rs.put("doctor","");
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取处方详情
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getPrescription(String code){
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public JSONObject getPrescriptionProcess(String code){
|
|
|
Prescription prescription = prescriptionDao.findByCode(code);
|
|
|
List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
|
|
|
JSONObject rs = new JSONObject();
|
|
|
rs.put("prescription",prescription);
|
|
|
rs.put("prescriptionInfos",prescriptionInfos);
|
|
|
if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
|
|
|
Patient p = patientDao.findByCode(prescription.getPatient());
|
|
|
rs.put("patient",p);
|
|
|
}else{
|
|
|
rs.put("patient","");
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消续方
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public int cancelPrescriotion(String code){
|
|
|
Prescription p = prescriptionDao.findByCode(code);
|
|
|
p.setStatus(-2);
|
|
|
prescriptionDao.save(p);
|
|
|
//患者操作日志
|
|
|
PrescriptionLog log = new PrescriptionLog();
|
|
|
log.setCode(getCode());
|
|
|
log.setStatus(-2);
|
|
|
log.setType(-1);
|
|
|
log.setCreateTime(new Date());
|
|
|
log.setPrescriptionCode(p.getCode());
|
|
|
log.setUserCode(p.getPatient());
|
|
|
log.setUserName(p.getPatientName());
|
|
|
log.setHospitalName(p.getHospitalName());
|
|
|
log.setHospital(p.getHospital());
|
|
|
log.setUserType(1);
|
|
|
log.setFlag(1);
|
|
|
log.setRemark("患者取消");
|
|
|
prescriptionLogDao.save(log);
|
|
|
|
|
|
//同步智业接口
|
|
|
upLoadPrescriotionState();
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
public void upLoadPrescriotionState(){
|
|
|
|
|
|
}
|
|
|
}
|