|
@ -0,0 +1,150 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDiagnosisDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
|
|
|
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.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 长处方疾病类型
|
|
|
* Created by yeshijie on 2017/7/28.
|
|
|
*/
|
|
|
@Service
|
|
|
public class PrescriptionDiagnosisService extends BaseService{
|
|
|
|
|
|
@Autowired
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
@Autowired
|
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
@Autowired
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取续方的疾病类型
|
|
|
* @param prescriptionCode
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPrescriptionDiagnosis(String prescriptionCode){
|
|
|
String re = "";
|
|
|
try {
|
|
|
if(!StringUtils.isEmpty(prescriptionCode))
|
|
|
{
|
|
|
//判断该续方的疾病类型redis是否存在
|
|
|
String key = "prescription:"+prescriptionCode+":diseaseTypes";
|
|
|
re = redisTemplate.opsForValue().get(key);
|
|
|
if(StringUtils.isEmpty(re))
|
|
|
{
|
|
|
List<PrescriptionDiagnosis> list = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
re = new JSONArray(list).toString();
|
|
|
redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return new JSONArray().toString();
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isEmpty(re)){
|
|
|
re = new JSONArray().toString();
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取续方的药品信息
|
|
|
* @param prescriptionCode
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPrescriptionInfo(String prescriptionCode){
|
|
|
String re = "";
|
|
|
try {
|
|
|
if(!StringUtils.isEmpty(prescriptionCode))
|
|
|
{
|
|
|
//判断该续方的药品信息redis是否存在
|
|
|
String key = "prescription:"+prescriptionCode+":drugInfo";
|
|
|
re = redisTemplate.opsForValue().get(key);
|
|
|
if(StringUtils.isEmpty(re))
|
|
|
{
|
|
|
List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
re = new JSONArray(list).toString();
|
|
|
redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return new JSONArray().toString();
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isEmpty(re)){
|
|
|
re = new JSONArray().toString();
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置处方redis疾病类型
|
|
|
* @param prescriptionCode
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean setPrescriptionDiagnosis(String prescriptionCode){
|
|
|
try {
|
|
|
if(!StringUtils.isEmpty(prescriptionCode))
|
|
|
{
|
|
|
//判断该续方的疾病类型redis是否存在
|
|
|
String key = "prescription:"+prescriptionCode+":diseaseTypes";
|
|
|
List<PrescriptionDiagnosis> list = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
String re = new JSONArray(list).toString();
|
|
|
redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置处方redis药品信息
|
|
|
* @param prescriptionCode
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean setPrescriptionInfo(String prescriptionCode){
|
|
|
try {
|
|
|
if(!StringUtils.isEmpty(prescriptionCode))
|
|
|
{
|
|
|
//判断该续方的药品信息redis是否存在
|
|
|
String key = "prescription:"+prescriptionCode+":drugInfo";
|
|
|
List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
String re = new JSONArray(list).toString();
|
|
|
redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
}
|