| 
					
				 | 
			
			
				@ -1,26 +1,31 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.dao.DoctorMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.HospitalDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.PatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.SignFamilyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.dao.prescription.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.Hospital; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.SignFamily; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.prescription.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.entity.prescription.VO.PrescriptionExpressageVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.service.ZysoftBaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -41,9 +46,20 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private StringRedisTemplate redisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionInfoDao prescriptionInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientDao patientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorMappingDao doctorMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private SignFamilyDao signFamilyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionDiagnosisDao prescriptionDiagnosisDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionExpressageDao prescriptionExpressageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HospitalDao hospitalDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${redis.channelTopic}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String channelTopic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String channelTopic = "redisPrescription"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 新增续方日志 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -83,9 +99,9 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject pre = json.getJSONObject("Data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String prescriptionCode = pre.getString("PRESCRIPTION_CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Prescription prescription = prescriptionDao.findByCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(prescription.getStatus()==2||prescription.getStatus()==4){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.changeing.getValue()||prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(CODE==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescription.setStatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.change_success.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescriptionDao.save(prescription); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //调整续方的药品信息 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -126,8 +142,13 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        prescriptionInfoDao.save(prescriptionInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // redis 的发布 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    redisTemplate.convertAndSend(channelTopic,JSONObject.fromObject(prescription).toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject message = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("title","adjustPrescription"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("state",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("prescription",prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message.put("mes","调整处方完成"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    redisTemplate.convertAndSend(channelTopic,message.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //调整失败 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    prescription.setStatus(4); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -166,6 +187,22 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(code==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String orderNo = json.getString("ORDER_NO");//挂号编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String recipeNo = json.getString("RECIPE_NO");//处方编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //修改续方表状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                Prescription prescription = prescriptionDao.f 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //修改续方审核表状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject message = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("title","redisAddPrescription"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("state",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("prescription","fd3b137cd907456dbcc5b11ecd701741"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                message.put("mes","预结算完成完成"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("mes","success"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                redisTemplate.convertAndSend(channelTopic,message.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (JSONException ex){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -195,6 +232,15 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(code==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String orderNo = json.getString("ORDER_NO");//挂号编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String recipeNo = json.getString("RECIPE_NO");//处方编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //判断健管师配送要添加续方消息,提示健管师有续方代配送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject message = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("title","dispensingComplete"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("state",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("prescription","fd3b137cd907456dbcc5b11ecd701741"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                message.put("mes","预结算完成完成"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.put("mes","success"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                redisTemplate.convertAndSend(channelTopic,message.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (JSONException ex){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -251,17 +297,15 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 7.1字典获取接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param dictName 字典名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param hospital 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param licence 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getDictForI(String dictName,String hospital,String licence)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getDictForI(String dictName,String hospital)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(hospital==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] hospitalMapping = getHospitalMapping(hospital); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> header = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        header.put("ORGCODE",hospital); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -280,17 +324,14 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param staffCode 员工编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deptCode 部门编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param hospital 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param licence 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getRecipeTemplate(String staffCode,String deptCode,String hospital,String licence)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getRecipeTemplate(String staffCode,String deptCode,String hospital)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(hospital==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] hospitalMapping = getHospitalMapping(hospital); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> header = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        header.put("ORGCODE",hospital); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -307,20 +348,25 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 调阅历史处方接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param cardNo 卡号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param cardNo 社保卡号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param recipeNo 医嘱号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param hospital 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param licence 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param applyTimeFrom 开始时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param applyTimeEnd 结束时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getLastRecipe(String cardNo,String recipeNo,String hospital,String licence)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getLastRecipe(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(hospital==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hospital = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String licence = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Patient patient = patientDao.findBySsc(cardNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] hospitalMapping = getHospitalMapping(signFamily.getHospital()); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> header = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        header.put("ORGCODE",hospital); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -329,6 +375,8 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("cardNo",cardNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("recipeNo",recipeNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("applyTimeFrom",applyTimeFrom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("applyTimeEnd",applyTimeEnd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String response = postSecond("getLastRecipe","调阅历史处方接口",params,null,header,false,2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -337,27 +385,63 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 7.4 挂号开处方接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param hospital 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param licence 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String saveRecipe(JSONObject json, String hospital, String licence)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String saveRecipe(String prescriptionCode)  throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(hospital==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Prescription prescription = prescriptionDao.findByCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] hospitalMapping = getHospitalMapping(prescription.getHospital()); //获取机构映射 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hospital = hospitalMapping[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String licence = hospitalMapping[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> header = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        header.put("ORGCODE",hospital); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        header.put("LICENCE",licence); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //拼接开方参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        json.put("cardNo",prescription.getSsc());// "cardNo": "病人卡号", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            "saveDept": "开单科室编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            "REGISTER_TYPE": "挂号类型编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            "RATE_TYPE": "费别类型编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String jwdoctor = doctorMappingDao.findByDocotrCodeAndJwDoctorHospital(prescription.getDoctor(),hospital); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        json.put("saveOperator",jwdoctor);// "saveOperator": "开单人员编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PrescriptionDiagnosis> prescriptionDiagnosisList = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        json.put("DIAGNOSE_CODE",prescriptionDiagnosisList.get(0).getCode());//"DIAGNOSE_CODE": "诊断编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray ja = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (PrescriptionInfo info : list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject js = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("ITEM_CODE",info.getDrugCode());//"ITEM_CODE": "药品代码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("ITEM_NAME",info.getDrugName());//"ITEM_NAME": "药品名称", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("SUBJECT_CLASS",info.getSubjectClass());//"SUBJECT_CLASS": "科目类别编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("ITEM_QUANTITY",info.getNum());//"ITEM_QUANTITY": "药品数量", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("ITEM_UNIT",info.getDrugNumUnit());// "ITEM_UNIT": " 数量单位编码 ", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("ITEM_SPEC",info.getDrugFormat());//  "ITEM_SPEC": "药品规格", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("ITEM_PRICE",info.getPrice());// "ITEM_PRICE": "药品单价", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("COST",info.getCode());// "COST": "药品金额", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("BIND_FLAG",info.getBindFlag());// "BIND_FLAG": " 成组标志, 0.非成组,1.成组", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("FREQUENCY",info.getDrugRate());// "FREQUENCY": "用药频次编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("DAY_COUNT",info.getDayCount());// "DAY_COUNT": "用药天数", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("USAGE",info.getDrugUsage());// "USAGE": "用药方法编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("PHYSIC_DOSE",info.getPhysicDose());// "PHYSIC_DOSE": " 用药剂量", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("PHYSIC_DOSE_UNIT",info.getPhysicDoseUnit());// "PHYSIC_DOSE_UNIT": " 剂量单位编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("PHYSIC_AMOUNT",info.getPhysicAmount());// "PHYSIC_AMOUNT": " 用药总量", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("PHYSIC_AMOUNT_UNIT",info.getPhysicAmountUnit());// "PHYSIC_AMOUNT_UNIT": " 总量单位编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("PHYSIC_INJECT_PLACE",info.getPhysicInjectPlace());// "PHYSIC_INJECT_PLACE": " 注射地点编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("PHYSIC_SKIN_TEST",info.getPhysicSkinTest());// "PHYSIC_SKIN_TEST": " 皮试类型编码", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            js.put("REMARK",info.getRemark());// " REMARK ": " 备注" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ja.add(js); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        json.put("recipeInfo",ja); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String response = postSecond("saveRecipe","挂号开处方接口",null,json,header,false,2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -415,4 +499,60 @@ public class PrescriptionService extends ZysoftBaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /*********************************************请求智业接口数据 end**************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /*********************************************智业请求顺丰快递接口数据 START**************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据基卫处方编码获取顺丰快递相关信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param visitNo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Result getSFExpressInfoByVisitNo(String visitNo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //根据基卫处方编号获取处方信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Prescription prescription = prescriptionDao.findByVisitNo(visitNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(prescription == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return Result.error(-1,"查询失败,未找到处方,挂号单为:"+visitNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //根据处方编码获取处方快递信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionPay(prescription.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(prescriptionExpressage == null || StringUtils.isBlank(prescriptionExpressage.getMailno())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return Result.error(-2,"查询失败,该处方的快递还未成功下单,挂号单为:"+visitNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //根据医院CODE,获取医院详细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Hospital hospital = hospitalDao.findByCode(prescription.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取订单的药品详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PrescriptionInfo> prescriptionInfolist = prescriptionInfoDao.findByPrescriptionCode(prescription.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PrescriptionExpressageVO vo = new PrescriptionExpressageVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setMailno(prescriptionExpressage.getMailno()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setMailtype("标准快递"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setDestcode(prescriptionExpressage.getCityCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //-----寄方信息---- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setJ_name(hospital.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setJ_provinceName(hospital.getProvinceName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setJ_cityName(hospital.getCityName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setJ_townName(hospital.getTownName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setJ_address(hospital.getAddress()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setJ_phone(hospital.getPhone()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //-----收方信息----- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setD_name(prescriptionExpressage.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setD_provinceName(prescriptionExpressage.getProvinceName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setD_cityName(prescriptionExpressage.getCityName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setD_townName(prescriptionExpressage.getTownName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setD_address(prescriptionExpressage.getAddress()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setD_phone(prescriptionExpressage.getPhone()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setPay_method(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setExpress_type(11); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        vo.setInfos(prescriptionInfolist); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Result.success("查询成功",vo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /*********************************************智业请求顺丰快递接口数据 END**************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |