|  | @ -411,12 +411,13 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |      * 调阅历史处方接口
 | 
	
		
			
				|  |  |      * @param cardNo 社保卡号
 | 
	
		
			
				|  |  |      * @param recipeNo 医嘱号
 | 
	
		
			
				|  |  |      * @param recipeNo 指定医嘱(处方)号时,直接返回该指定医嘱(处方)的信息
 | 
	
		
			
				|  |  |      * @param applyTimeFrom 开始时间
 | 
	
		
			
				|  |  |      * @param applyTimeEnd 结束时间
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getLastRecipe(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd)  throws Exception
 | 
	
		
			
				|  |  |     public String getLastRecipe(String cardNo,String recipeNo,String appointRecipeNo,String applyTimeFrom,String applyTimeEnd)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         Patient patient = patientDao.findBySsc(cardNo);
 | 
	
		
			
				|  |  |         SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
 | 
	
	
		
			
				|  | @ -436,6 +437,9 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |             recipeNo = "0";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         params.put("recipeNo",recipeNo);
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(appointRecipeNo)){
 | 
	
		
			
				|  |  |             params.put("appointRecipeNo",appointRecipeNo);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(applyTimeFrom)){
 | 
	
		
			
				|  |  |             applyTimeEnd = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |             applyTimeFrom = DateUtil.getNextDay(new Date(),-60);
 | 
	
	
		
			
				|  | @ -448,6 +452,54 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 调阅处方详情接口
 | 
	
		
			
				|  |  |      * @param cardNo 社保卡号
 | 
	
		
			
				|  |  |      * @param appointRecipeNo 指定医嘱(处方)号时,直接返回该指定医嘱(处方)的信息
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getRecipe(String cardNo,String appointRecipeNo)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         Patient patient = patientDao.findBySsc(cardNo);
 | 
	
		
			
				|  |  |         SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
 | 
	
		
			
				|  |  |         //
 | 
	
		
			
				|  |  |         String[] hospitalMapping = getHospitalMapping(signFamily.getHospital()); //获取机构映射
 | 
	
		
			
				|  |  |         String hospital = hospitalMapping[0];
 | 
	
		
			
				|  |  |         String licence = hospitalMapping[1];
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,String> header = new HashMap<>();
 | 
	
		
			
				|  |  |         header.put("ORGCODE",hospital);
 | 
	
		
			
				|  |  |         header.put("LICENCE",licence);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,String> params = new HashMap<>();
 | 
	
		
			
				|  |  |         params.put("cardNo",cardNo);
 | 
	
		
			
				|  |  |         params.put("recipeNo","0");
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(appointRecipeNo)){
 | 
	
		
			
				|  |  |             params.put("appointRecipeNo",appointRecipeNo);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String applyTimeEnd = null;
 | 
	
		
			
				|  |  |         String applyTimeFrom = null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //判断是否存在续方记录,存在就取续方的创建时间为开始时间,保证从续方详情跳转处方详情是有数据
 | 
	
		
			
				|  |  |         Prescription prescription = prescriptionDao.findByJwCode(appointRecipeNo);
 | 
	
		
			
				|  |  |         if(prescription == null){
 | 
	
		
			
				|  |  |             applyTimeEnd = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |             applyTimeFrom = DateUtil.getNextDay(new Date(),-60);
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             applyTimeEnd = DateUtil.getNextDay(prescription.getCreateTime(),10);
 | 
	
		
			
				|  |  |             applyTimeFrom = DateUtil.getNextDay(prescription.getCreateTime(),-10);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         params.put("applyTimeFrom",applyTimeFrom);
 | 
	
		
			
				|  |  |         params.put("applyTimeEnd",applyTimeEnd);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = postSecond("getLastRecipe","调阅处方详情接口",params,null,header,false,2);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 7.4 挂号开处方接口,调整处方接口
 | 
	
		
			
				|  |  |      * 开方和调整处方接口的区别-开方会传ca认证
 | 
	
	
		
			
				|  | @ -455,7 +507,6 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public String saveRecipe(String prescriptionCode)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
 | 
	
	
		
			
				|  | @ -471,25 +522,28 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |         //拼接开方参数
 | 
	
		
			
				|  |  |         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": "开单人员编码",
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         json.put("saveDept",prescription.getJwDeptCode());//开单科室编码
 | 
	
		
			
				|  |  |         json.put("saveOperator",prescription.getJwDoctorCode());// "saveOperator": "开单人员编码",
 | 
	
		
			
				|  |  |         json.put("RATE_TYPE","2");//费别类型编码
 | 
	
		
			
				|  |  |         json.put("REGISTER_TYPE",prescription.getJwGisterTypeCode());//挂号类型编码
 | 
	
		
			
				|  |  |         List<PrescriptionDiagnosis> prescriptionDiagnosisList = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode);
 | 
	
		
			
				|  |  |         json.put("DIAGNOSE_CODE",prescriptionDiagnosisList.get(0).getCode());//"DIAGNOSE_CODE": "诊断编码",
 | 
	
		
			
				|  |  |         if(prescriptionDiagnosisList.size()>1){
 | 
	
		
			
				|  |  |             json.put("DIAGNOSE_SUB_CODE",prescriptionDiagnosisList.get(1).getCode());//"DIAGNOSE_CODE": "次诊断编码",
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(prescription.getCaCertData()==null){
 | 
	
		
			
				|  |  |             json.put("OriginalData",prescription.getStrOriginalData());//原文
 | 
	
		
			
				|  |  |             json.put("OriginalDataMD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
 | 
	
		
			
				|  |  |             json.put("CA_SignData",prescription.getCaMessage());//签名值
 | 
	
		
			
				|  |  |             json.put("CA_CertMainData",prescription.getCaCertData());//签名证书主体数据
 | 
	
		
			
				|  |  |             json.put("CA_DigitalSignStreamNoUuid",prescription.getDigitalSignNo());//CA数字签名唯一流水号
 | 
	
		
			
				|  |  |             json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
 | 
	
		
			
				|  |  |             json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
 | 
	
		
			
				|  |  |             json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
 | 
	
		
			
				|  |  |             json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据
 | 
	
		
			
				|  |  |             json.put("CA_DIGITAL_SIGN_STREAM_NO_UUID",prescription.getDigitalSignNo());//CA数字签名唯一流水号
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             json.put("OriginalData",null);
 | 
	
		
			
				|  |  |             json.put("OriginalDataMD5",null);
 | 
	
		
			
				|  |  |             json.put("CA_SignData",null);
 | 
	
		
			
				|  |  |             json.put("CA_CertMainData",null);
 | 
	
		
			
				|  |  |             json.put("CA_DigitalSignStreamNoUuid",null);
 | 
	
		
			
				|  |  |             json.put("ORIGINAL_DATA",null);
 | 
	
		
			
				|  |  |             json.put("ORIGINAL_DATA_MD5",null);
 | 
	
		
			
				|  |  |             json.put("CA_SIGN_DATA",null);
 | 
	
		
			
				|  |  |             json.put("CA_CERTMAIN_DATA",null);
 | 
	
		
			
				|  |  |             json.put("CA_DIGITAL_SIGN_STREAM_NO_UUID",null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
 | 
	
	
		
			
				|  | @ -502,8 +556,8 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |             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("ITEM_PRICE",intToDouble(info.getPrice()));// "ITEM_PRICE": "药品单价",
 | 
	
		
			
				|  |  |             js.put("COST",intToDouble(info.getCost()));// "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": "用药天数",
 | 
	
	
		
			
				|  | @ -524,6 +578,19 @@ public class PrescriptionService extends ZysoftBaseService{
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 整型除以100转
 | 
	
		
			
				|  |  |      * @param num
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     private Double intToDouble(Integer num){
 | 
	
		
			
				|  |  |         if(num==null){
 | 
	
		
			
				|  |  |             return 0.0d;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return (double)num/100;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 7.5 查询处方结算结果列表
 | 
	
		
			
				|  |  |      * @param cardNo 病人卡号
 |