|
@ -11,6 +11,7 @@ import com.yihu.wlyy.service.common.util.DateUtil;
|
|
|
import com.yihu.wlyy.service.dao.*;
|
|
|
import com.yihu.wlyy.service.dao.consult.ConsultTeamDao;
|
|
|
import com.yihu.wlyy.service.dao.prescription.*;
|
|
|
import com.yihu.wlyy.service.dao.zydict.ZyIvPhysicDictDao;
|
|
|
import com.yihu.wlyy.service.entity.*;
|
|
|
import com.yihu.wlyy.service.entity.consult.ConsultTeam;
|
|
|
import com.yihu.wlyy.service.entity.prescription.*;
|
|
@ -75,6 +76,8 @@ public class PrescriptionService extends ZysoftBaseService{
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
@Autowired
|
|
|
private AmoutUtils amoutUtils;
|
|
|
@Autowired
|
|
|
private ZyIvPhysicDictDao zyIvPhysicDictDao;
|
|
|
|
|
|
/**
|
|
|
* 新增续方日志
|
|
@ -115,118 +118,126 @@ public class PrescriptionService extends ZysoftBaseService{
|
|
|
JSONObject pre = json.getJSONObject("Data");
|
|
|
String recipeNo = pre.getString("RECIPE_NO");
|
|
|
Prescription prescription = prescriptionDao.findByRecipeNo(recipeNo);
|
|
|
if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.changeing.getValue()||prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
|
|
|
if(CODE==1){
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.change_success.getValue());
|
|
|
prescriptionDao.save(prescription);
|
|
|
|
|
|
//调整续方的药品信息
|
|
|
JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL");
|
|
|
List<PrescriptionInfo> infoList = new ArrayList<>();
|
|
|
for(int i =0;i<prescription_detail.size();i++){
|
|
|
JSONObject info = prescription_detail.getJSONObject(i);
|
|
|
PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
|
|
|
prescriptionInfo.setRemark(info.getString("REMARK"));
|
|
|
prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
|
|
|
prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
|
|
|
prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
|
|
|
prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
|
|
|
prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
|
|
|
prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
|
|
|
String subjectClass = info.getString("SUBJECT_CLASS");
|
|
|
if(StringUtils.isBlank(subjectClass)){//处理默认药品的科目类型为空
|
|
|
StringBuffer sql = new StringBuffer("SELECT subject_class from zy_iv_physic_dict WHERE physic_code = ?");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString(),info.getString("ITEM_CODE"));
|
|
|
if(list!=null&&list.size()>0){
|
|
|
Object subject_class = list.get(0).get("subject_class");
|
|
|
if(subject_class!=null){
|
|
|
subjectClass = subject_class.toString();
|
|
|
if(prescription==null){
|
|
|
error = "没有找到对应的续方";
|
|
|
errMsg = "没有找到对应的续方";
|
|
|
status = "0";
|
|
|
}else {
|
|
|
if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.changeing.getValue()||prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
|
|
|
if(CODE==1){
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.change_success.getValue());
|
|
|
prescriptionDao.save(prescription);
|
|
|
|
|
|
//调整续方的药品信息
|
|
|
JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL");
|
|
|
List<PrescriptionInfo> infoList = new ArrayList<>();
|
|
|
for(int i =0;i<prescription_detail.size();i++){
|
|
|
JSONObject info = prescription_detail.getJSONObject(i);
|
|
|
PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
|
|
|
prescriptionInfo.setCode(getCode());
|
|
|
prescriptionInfo.setRemark(info.getString("REMARK"));
|
|
|
prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
|
|
|
prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
|
|
|
prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
|
|
|
prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
|
|
|
prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
|
|
|
prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
|
|
|
String subjectClass = info.getString("SUBJECT_CLASS");
|
|
|
if(StringUtils.isBlank(subjectClass)){//处理默认药品的科目类型为空
|
|
|
StringBuffer sql = new StringBuffer("SELECT subject_class from zy_iv_physic_dict WHERE physic_code = ?");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString(),info.getString("ITEM_CODE"));
|
|
|
if(list!=null&&list.size()>0){
|
|
|
Object subject_class = list.get(0).get("subject_class");
|
|
|
if(subject_class!=null){
|
|
|
subjectClass = subject_class.toString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
prescriptionInfo.setSubjectClass(subjectClass);//科目编码
|
|
|
//prescriptionInfo.setSubjectClass(info.getString("SUBJECT_CLASS"));//"科目类别编码",
|
|
|
prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
|
|
|
prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
|
|
|
prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
|
|
|
prescriptionInfo.setJwSubCode(info.getString("SUB_NO"));//智业子处方号
|
|
|
prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
|
|
|
prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
|
|
|
prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
|
|
|
prescriptionInfo.setCharge(CommonUtil.doubleToInt(info.getDouble("CHARGE")));//自付
|
|
|
prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
|
|
|
prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
|
|
|
prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
|
|
|
prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
|
|
|
prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
|
|
|
prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
|
|
|
prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
|
|
|
prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
|
|
|
prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
|
|
|
prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
|
|
|
prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
|
|
|
prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
|
|
|
prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
|
|
|
prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
|
|
|
prescriptionInfo.setPrescriptionCode(prescription.getCode());
|
|
|
//设置是否冷藏
|
|
|
Integer isRefrigerate = 0;
|
|
|
StringBuffer sqlbuf = new StringBuffer("SELECT storage_conditions from zy_iv_physic_dict WHERE physic_code = '"+info.getString("ITEM_CODE")+"'");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlbuf.toString());
|
|
|
if(list!=null&&list.size()>0){
|
|
|
Object storage_conditions = list.get(0).get("storage_conditions");
|
|
|
if(storage_conditions!=null){
|
|
|
String storageConditions = storage_conditions.toString();
|
|
|
isRefrigerate = "2".equals(storageConditions)?1:isRefrigerate;
|
|
|
prescriptionInfo.setSubjectClass(subjectClass);//科目编码
|
|
|
//prescriptionInfo.setSubjectClass(info.getString("SUBJECT_CLASS"));//"科目类别编码",
|
|
|
prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
|
|
|
prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
|
|
|
prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
|
|
|
prescriptionInfo.setJwSubCode(info.getString("SUB_NO"));//智业子处方号
|
|
|
prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
|
|
|
prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
|
|
|
prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
|
|
|
prescriptionInfo.setCharge(CommonUtil.doubleToInt(info.getDouble("CHARGE")));//自付
|
|
|
prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
|
|
|
prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
|
|
|
prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
|
|
|
prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
|
|
|
prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
|
|
|
prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
|
|
|
prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
|
|
|
prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
|
|
|
prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
|
|
|
prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
|
|
|
prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
|
|
|
prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
|
|
|
prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
|
|
|
prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
|
|
|
prescriptionInfo.setPrescriptionCode(prescription.getCode());
|
|
|
prescriptionInfo.setDel(1);
|
|
|
//设置是否冷藏
|
|
|
Integer isRefrigerate = 0;
|
|
|
StringBuffer sqlbuf = new StringBuffer("SELECT storage_conditions from zy_iv_physic_dict WHERE physic_code = '"+info.getString("ITEM_CODE")+"'");
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlbuf.toString());
|
|
|
if(list!=null&&list.size()>0){
|
|
|
Object storage_conditions = list.get(0).get("storage_conditions");
|
|
|
if(storage_conditions!=null){
|
|
|
String storageConditions = storage_conditions.toString();
|
|
|
isRefrigerate = "2".equals(storageConditions)?1:isRefrigerate;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
prescriptionInfo.setIsRefrigerate(isRefrigerate);
|
|
|
prescriptionInfo.setIsRefrigerate(isRefrigerate);
|
|
|
|
|
|
//用药频率
|
|
|
prescriptionInfo.setDrugRateName(getZyCommonDictName(info.getString("drugRate")));
|
|
|
//用药频率
|
|
|
prescriptionInfo.setDrugRateName(getZyCommonDictName(info.getString("drugRate")));
|
|
|
|
|
|
infoList.add(prescriptionInfo);
|
|
|
}
|
|
|
|
|
|
infoList.add(prescriptionInfo);
|
|
|
//删除所有药品
|
|
|
StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription_info SET del = 0 WHERE prescription_code = '" + prescription.getCode() + "'");
|
|
|
jdbcTemplate.execute(sql.toString());
|
|
|
//保存新的药品
|
|
|
prescriptionInfoDao.save(infoList);
|
|
|
|
|
|
//发送系统消息
|
|
|
Message message = new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setContent("您有1个续方申请已在线下调整完成,请点击进行CA认证。");
|
|
|
message.setRead(1);//设置未读
|
|
|
message.setReceiver(prescription.getDoctor());//设置接受医生的code
|
|
|
message.setSender("系统");//设置发送的用户
|
|
|
message.setSenderName("system");
|
|
|
message.setCode(getCode());
|
|
|
message.setTitle("新增系统消息");
|
|
|
message.setType(9);
|
|
|
message.setReadonly(1);//是否只读消息
|
|
|
message.setOver("1");//未处理
|
|
|
message.setRelationCode(prescription.getCode());
|
|
|
messageDao.save(message);
|
|
|
|
|
|
// redis 的发布 {tilte:redisAddPrescription state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE }
|
|
|
// JSONObject redisMessage = new JSONObject();
|
|
|
// redisMessage.put("title","adjustPrescription");
|
|
|
// redisMessage.put("state",1);
|
|
|
// redisMessage.put("prescription",prescription.getCode());
|
|
|
// redisMessage.put("mes","调整处方完成");
|
|
|
// redisTemplate.opsForList().leftPush(channelTopic,redisMessage.toString());
|
|
|
}else {
|
|
|
//调整失败
|
|
|
prescription.setStatus(4);
|
|
|
prescriptionDao.save(prescription);
|
|
|
msg = json.getString("MSG");
|
|
|
}
|
|
|
|
|
|
//删除所有药品
|
|
|
StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription_info SET del = 0 WHERE prescription_code = '" + prescription.getCode() + "'");
|
|
|
jdbcTemplate.execute(sql.toString());
|
|
|
//保存新的药品
|
|
|
prescriptionInfoDao.save(infoList);
|
|
|
|
|
|
//发送系统消息
|
|
|
Message message = new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setContent("您有1个续方申请已在线下调整完成,请点击进行CA认证。");
|
|
|
message.setRead(1);//设置未读
|
|
|
message.setReceiver(prescription.getDoctor());//设置接受医生的code
|
|
|
message.setSender("系统");//设置发送的用户
|
|
|
message.setSenderName("system");
|
|
|
message.setCode(getCode());
|
|
|
message.setTitle("新增系统消息");
|
|
|
message.setType(9);
|
|
|
message.setReadonly(1);//是否只读消息
|
|
|
message.setOver("1");//未处理
|
|
|
message.setRelationCode(prescription.getCode());
|
|
|
messageDao.save(message);
|
|
|
|
|
|
// redis 的发布 {tilte:redisAddPrescription state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE }
|
|
|
// JSONObject redisMessage = new JSONObject();
|
|
|
// redisMessage.put("title","adjustPrescription");
|
|
|
// redisMessage.put("state",1);
|
|
|
// redisMessage.put("prescription",prescription.getCode());
|
|
|
// redisMessage.put("mes","调整处方完成");
|
|
|
// redisTemplate.opsForList().leftPush(channelTopic,redisMessage.toString());
|
|
|
}else {
|
|
|
//调整失败
|
|
|
prescription.setStatus(4);
|
|
|
prescriptionDao.save(prescription);
|
|
|
msg = json.getString("MSG");
|
|
|
//新增续方日志
|
|
|
addPrescriptionLog(prescription,"接收线下处方调整完成消息-"+msg);
|
|
|
}
|
|
|
|
|
|
//新增续方日志
|
|
|
addPrescriptionLog(prescription,"接收线下处方调整完成消息-"+msg);
|
|
|
}
|
|
|
}catch (JSONException ex){
|
|
|
ex.printStackTrace();
|
|
@ -860,7 +871,7 @@ public class PrescriptionService extends ZysoftBaseService{
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("cardNo",prescription.getSsc());// "cardNo": "病人卡号",
|
|
|
json.put("settleDept",prescription.getJwDeptCode());//结算科室编码
|
|
|
json.put("saveOperator",prescription.getJwDoctorCode());// "saveOperator": "开单人员编码",
|
|
|
json.put("settleOperator",prescription.getJwDoctorCode());// "saveOperator": "开单人员编码",
|
|
|
json.put("visitNo",prescription.getVisitNo());// "院内挂号号,取费用列表中最小的院内挂号号
|
|
|
|
|
|
//医保支付需要组装以下参数
|