| 
					
				 | 
			
			
				@ -2,14 +2,19 @@ package com.yihu.wlyy.service.service.prescription; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.common.model.Result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.prescription.PrescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.prescription.PrescriptionInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.prescription.PrescriptionLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.prescription.Prescription; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.prescription.PrescriptionInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.prescription.PrescriptionLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.service.ZysoftBaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.redis.core.StringRedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -32,24 +37,27 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionLogDao prescriptionLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private StringRedisTemplate redisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionInfoDao prescriptionInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static final String channelTopic = "prescription"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${redis.channelTopic}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String channelTopic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 新增续方日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescription 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void addPrescriptionLog(Prescription prescription){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void addPrescriptionLog(Prescription prescription,String remark){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PrescriptionLog log = new PrescriptionLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setStatus(prescription.getStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setPrescriptionCode(prescription.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setCode(getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setType(PrescriptionLog.PrescriptionLogType.zy.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setFlag(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setHospital(prescription.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setHospitalName(prescription.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setRemark("接收线下处方调整完成消息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setRemark(remark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setUserCode(prescription.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setUserName(prescription.getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        log.setUserType(2); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -65,27 +73,74 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String error = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String status = "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String errMsg = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String msg = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = JSONObject.fromObject(jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer state= json.getInt("CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String code = json.getString("RECIPE_NO"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Prescription prescription = prescriptionDao.findByCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(prescription.getStatus()==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(state==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer CODE= json.getInt("CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject pre = json.getJSONObject("Data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String prescriptionCode = pre.getString("PRESCRIPTION_CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Prescription prescription = prescriptionDao.findByCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(prescription.getStatus()==2||prescription.getStatus()==4){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(CODE==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescription.setStatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionDao.save(prescription); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //调整续方的药品信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for(int i =0;i<prescription_detail.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject info = prescription_detail.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String infoCode = info.getString("SUB_NO"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        PrescriptionInfo prescriptionInfo = prescriptionInfoDao.findByCode(infoCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setRemark(info.getString("REMARK")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setDirection("口服");//药品用法 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setPrice(info.getInt("ITEM_PRICE"));//药品单价 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setNum(info.getInt("ITEM_QUANTITY"));//药品数目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setJwSubCode("");//智业子处方号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setCost(1);//金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setCharge(0);//自付 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setDayCount(info.getInt("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("");//注射地点编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfoDao.save(prescriptionInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // redis 的发布 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    redisTemplate.convertAndSend(channelTopic,JSONObject.fromObject(prescription).toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //调整失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescription.setStatus(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionDao.save(prescription); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    msg = json.getString("MSG"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionDao.save(prescription); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //新增续方日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                addPrescriptionLog(prescription); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                addPrescriptionLog(prescription,"接收线下处方调整完成消息-"+msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (JSONException ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ex.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            errMsg = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            status = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = e.getMessage(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -104,7 +159,18 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String status = "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String errMsg = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = JSONObject.fromObject(jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer code = json.getInt("CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(code==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String orderNo = json.getString("ORDER_NO");//挂号编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String recipeNo = json.getString("RECIPE_NO");//处方编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (JSONException ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ex.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            errMsg = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            status = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = e.getMessage(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -122,7 +188,18 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String status = "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String errMsg = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = JSONObject.fromObject(jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer code = json.getInt("CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(code==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String orderNo = json.getString("ORDER_NO");//挂号编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String recipeNo = json.getString("RECIPE_NO");//处方编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (JSONException ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ex.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            errMsg = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            status = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = e.getMessage(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -140,7 +217,18 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String status = "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String errMsg = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = JSONObject.fromObject(jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer code = json.getInt("CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(code==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String orderNo = json.getString("ORDER_NO");//挂号编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String recipeNo = json.getString("RECIPE_NO");//处方编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (JSONException ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ex.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            errMsg = ex.getMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            status = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            error = e.getMessage(); 
			 |