|  | @ -10,9 +10,12 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.service.PatientMappingService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
 | 
	
	
		
			
				|  | @ -66,6 +69,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionExpressageDao prescriptionExpressageDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionInfoDao prescriptionInfoDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao;
 | 
	
	
		
			
				|  | @ -80,6 +85,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientMappingService patientMappingService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorMappingService doctorMappingService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OutpatientDao outpatientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ObjectMapper objectMapper;
 | 
	
	
		
			
				|  | @ -185,7 +192,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " o.origin_adm_no AS originAdmNo, " +
 | 
	
		
			
				|  |  |                 " o.register_no AS registerNo, " +
 | 
	
		
			
				|  |  |                 " o.origin_register_no AS originRegisterNo, " +
 | 
	
		
			
				|  |  |                 " o.hos" +
 | 
	
		
			
				|  |  |                 " o.hospital," +
 | 
	
		
			
				|  |  |                 " o.hospital_name AS hospitalName," +
 | 
	
		
			
				|  |  |                 " o.winNo," +
 | 
	
		
			
				|  |  |                 " o.type," +
 | 
	
		
			
				|  |  |                 " o.dept AS dept, " +
 | 
	
		
			
				|  |  |                 " o.dept_name AS deptName, " +
 | 
	
		
			
				|  |  |                 " o.patient AS patient, " +
 | 
	
	
		
			
				|  | @ -243,6 +253,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),outpatientDO.getPatient(),"1");
 | 
	
		
			
				|  |  |         rs.put("ssc",cardDO);
 | 
	
		
			
				|  |  |         rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
 | 
	
		
			
				|  |  |         rs.put("address",basePatientDO.getAddress());
 | 
	
		
			
				|  |  |         rs.put("mobile",basePatientDO.getMobile());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //获取处方信息
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outpatientId);
 | 
	
	
		
			
				|  | @ -269,6 +281,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             rs.put("expressage",null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //物流配送新
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionExpressageLogDO>  expressageLogDOs = prescriptionExpressageLogDao.queryByOutpatientId(outpatientId);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionExpressageLogVO> expressageLogVOs = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(expressageLogDOs!=null&&expressageLogVOs.size()>0){
 | 
	
		
			
				|  |  |             rs.put("expressageLogs",convertToModels(expressageLogDOs,expressageLogVOs, WlyyPrescriptionExpressageLogVO.class));
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             rs.put("expressageLogs",null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -451,6 +473,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson,WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |         expressageDO.setDel(1);
 | 
	
		
			
				|  |  |         expressageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         expressageDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |         prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
	
		
			
				|  | @ -643,5 +666,299 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //    public JSONArray find
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 挂号
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
 | 
	
		
			
				|  |  |         if(doctorMappingDO==null){
 | 
	
		
			
				|  |  |             throw new RuntimeException("未找到医生映射信息");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
 | 
	
		
			
				|  |  |         String rsCode = (String)rs.get("@RESULT");
 | 
	
		
			
				|  |  |         if("0".equals(rsCode)){
 | 
	
		
			
				|  |  |             //存储挂号号
 | 
	
		
			
				|  |  |             String serialNo = (String)rs.get("serial_no");
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取诊断
 | 
	
		
			
				|  |  |      * @param pyKey
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getICD10(String pyKey)throws Exception{
 | 
	
		
			
				|  |  |         return entranceService.MS25001(pyKey,demoFlag);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取药品
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getDrugDictionary(String chargeCode,String pyKey,String winNo)throws Exception{
 | 
	
		
			
				|  |  |         return entranceService.MS53001(chargeCode,pyKey,null,winNo,"0",demoFlag);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取药品用法
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getDrugUse(String pyKey)throws Exception{
 | 
	
		
			
				|  |  |         return entranceService.BS10110(null,pyKey,demoFlag);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 医院频次
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getDrugFrequency()throws Exception{
 | 
	
		
			
				|  |  |         return entranceService.MS30012(demoFlag);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param outPatientId
 | 
	
		
			
				|  |  |      * @param advice
 | 
	
		
			
				|  |  |      * @param type 1带处方,2不带处方
 | 
	
		
			
				|  |  |      * @param infoJsons
 | 
	
		
			
				|  |  |      * @param diagnosisJson
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> makeDiagnosis(String outPatientId,String advice,String type,String infoJsons,String diagnosisJson)throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> result = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //获取门诊记录
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
 | 
	
		
			
				|  |  |         outpatientDO.setAdvice(advice);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //创建处方记录
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = null;
 | 
	
		
			
				|  |  |         if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
 | 
	
		
			
				|  |  |             prescriptionDO = prescriptionDOs.get(0);
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             prescriptionDO = new WlyyPrescriptionDO();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         prescriptionDO.setStatus(10);
 | 
	
		
			
				|  |  |         prescriptionDO.setPatientCode(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         prescriptionDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //下诊断
 | 
	
		
			
				|  |  |         //删除之前诊断
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDiagnosisDO> ds = prescriptionDiagnosisDao.findByPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |         prescriptionDiagnosisDao.delete(ds);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = (List<WlyyPrescriptionDiagnosisDO>) com.alibaba.fastjson.JSONArray.parseArray(diagnosisJson, WlyyPrescriptionDiagnosisDO.class);
 | 
	
		
			
				|  |  |         String Icd10 = "";
 | 
	
		
			
				|  |  |         String Icd10Name = "";
 | 
	
		
			
				|  |  |         for(WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOs){
 | 
	
		
			
				|  |  |             if("1".equals(diagnosisDO.getType())){
 | 
	
		
			
				|  |  |                 Icd10 = diagnosisDO.getCode()+","+Icd10;
 | 
	
		
			
				|  |  |                 Icd10Name+=diagnosisDO.getName()+","+Icd10Name;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 Icd10+=diagnosisDO.getCode()+",";
 | 
	
		
			
				|  |  |                 Icd10Name+=diagnosisDO.getName()+",";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             diagnosisDO.setPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         prescriptionDiagnosisDao.save(diagnosisDOs);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Icd10 = Icd10.substring(0,Icd10.length()-1);
 | 
	
		
			
				|  |  |         Icd10Name = Icd10Name.substring(0,Icd10Name.length()-1);
 | 
	
		
			
				|  |  |         outpatientDO.setIcd10(Icd10);
 | 
	
		
			
				|  |  |         outpatientDO.setIcd10Name(Icd10Name);
 | 
	
		
			
				|  |  |         outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //判断是否需药品,有药品到his开处方,没有药品直接下诊断开方
 | 
	
		
			
				|  |  |         if("1".equals(type)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //doctor转换为his医生
 | 
	
		
			
				|  |  |             DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(),outpatientDO.getHospital());
 | 
	
		
			
				|  |  |             if(doctorMappingDO==null){
 | 
	
		
			
				|  |  |                 throw new RuntimeException("未找到医生映射信息");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //删除原有药品信息
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionInfoDO> oldInfos = prescriptionInfoDao.findByPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |             if(oldInfos!=null&&oldInfos.size()>0){
 | 
	
		
			
				|  |  |                 prescriptionInfoDao.delete(oldInfos);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(StringUtils.isNotBlank(infoJsons)){
 | 
	
		
			
				|  |  |                 //药品
 | 
	
		
			
				|  |  |                 List<WlyyPrescriptionInfoDO> infoDOs = (List<WlyyPrescriptionInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(infoJsons, WlyyPrescriptionInfoDO.class);
 | 
	
		
			
				|  |  |                 //his处方拼接开方条件
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  |                 for(WlyyPrescriptionInfoDO info:infoDOs){
 | 
	
		
			
				|  |  |                     info.setDel(1);
 | 
	
		
			
				|  |  |                     info.setPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |                     json.put("cardNo",outpatientDO.getCardNo());
 | 
	
		
			
				|  |  |                     json.put("doctor",doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |                     json.put("dept",outpatientDO.getDept());
 | 
	
		
			
				|  |  |                     json.put("chargeCode",info.getDrugNo());
 | 
	
		
			
				|  |  |                     json.put("winNo",outpatientDO.getWinNo());
 | 
	
		
			
				|  |  |                     json.put("chargeFlag",1);
 | 
	
		
			
				|  |  |                     json.put("quantity",info.getQuantity());
 | 
	
		
			
				|  |  |                     json.put("serialNo",outpatientDO.getRegisterNo());
 | 
	
		
			
				|  |  |                     json.put("groupNo",info.getGroupNo());
 | 
	
		
			
				|  |  |                     json.put("serial",info.getSerial());
 | 
	
		
			
				|  |  |                     String Icd10s[] = Icd10.split(",");
 | 
	
		
			
				|  |  |                     for(int i=0;i<Icd10s.length;i++){
 | 
	
		
			
				|  |  |                         if(i==0){
 | 
	
		
			
				|  |  |                             json.put("icdCode",Icd10s[i]);
 | 
	
		
			
				|  |  |                         }else if(i==1){
 | 
	
		
			
				|  |  |                             json.put("diagTwo",Icd10s[i]);
 | 
	
		
			
				|  |  |                         }else if(i==2){
 | 
	
		
			
				|  |  |                             json.put("diagThree",Icd10s[i]);
 | 
	
		
			
				|  |  |                         }else if(i==3){
 | 
	
		
			
				|  |  |                             json.put("diagFour",Icd10s[i]);
 | 
	
		
			
				|  |  |                         }else if(i==4){
 | 
	
		
			
				|  |  |                             json.put("diagFive",Icd10s[i]);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     json.put("dosage",info.getDosage());
 | 
	
		
			
				|  |  |                     json.put("unit",info.getUnit());
 | 
	
		
			
				|  |  |                     json.put("usage",info.getUsage());
 | 
	
		
			
				|  |  |                     json.put("supplyCode",info.getSupplyCode());
 | 
	
		
			
				|  |  |                     json.put("days ",info.getDays());
 | 
	
		
			
				|  |  |                     json.put("frequency",info.getFrequency());
 | 
	
		
			
				|  |  |                     jsonData.add(json);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //保存处方
 | 
	
		
			
				|  |  |                 prescriptionInfoDao.save(infoDOs);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //调用his开方接口
 | 
	
		
			
				|  |  |                 net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
 | 
	
		
			
				|  |  |                 //判断返回结果
 | 
	
		
			
				|  |  |                 String rs = jsonObject.getString("@RESULT");
 | 
	
		
			
				|  |  |                 if("0".equals(rs)){
 | 
	
		
			
				|  |  |                     String admNo = jsonObject.getString("@ADM_NO");
 | 
	
		
			
				|  |  |                     String realOrder = jsonObject.getString("@real_order");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     prescription.setAdmNo(admNo);
 | 
	
		
			
				|  |  |                     prescription.setRealOrder(realOrder);
 | 
	
		
			
				|  |  |                     prescriptionDao.save(prescription);
 | 
	
		
			
				|  |  |                     outpatientDO.setAdmNo(admNo);
 | 
	
		
			
				|  |  |                     outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     result.put("code",1);
 | 
	
		
			
				|  |  |                     result.put("mes","开方提交成功");
 | 
	
		
			
				|  |  |                     return result;
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     //开方失败
 | 
	
		
			
				|  |  |                     prescription.setStatus(13);
 | 
	
		
			
				|  |  |                     prescriptionDao.save(prescription);
 | 
	
		
			
				|  |  |                     result.put("code",-1);
 | 
	
		
			
				|  |  |                     result.put("mes","开方提交失败");
 | 
	
		
			
				|  |  |                     return result;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 result.put("code",-2);
 | 
	
		
			
				|  |  |                 result.put("mes","参数错误,药品参数错误");
 | 
	
		
			
				|  |  |                 return result;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             //
 | 
	
		
			
				|  |  |             outpatientDO.setStatus("2");
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |             result.put("code",1);
 | 
	
		
			
				|  |  |             result.put("mes","诊断完成");
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 订单查询
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @param oneselfPickupFlg
 | 
	
		
			
				|  |  |      * @param nameKey
 | 
	
		
			
				|  |  |      * @param startTime
 | 
	
		
			
				|  |  |      * @param endTime
 | 
	
		
			
				|  |  |      * @param page
 | 
	
		
			
				|  |  |      * @param size
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop findExpressageList(String status,String oneselfPickupFlg,String nameKey,String startTime,String endTime,Integer page,Integer size){
 | 
	
		
			
				|  |  |         String totalSql="SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS total " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_outpatient o " +
 | 
	
		
			
				|  |  |                 " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
 | 
	
		
			
				|  |  |                 " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id" +
 | 
	
		
			
				|  |  |                 " WHERE" +
 | 
	
		
			
				|  |  |                 " 1=1";
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(status)){
 | 
	
		
			
				|  |  |             totalSql+=" AND p.status in("+status+")";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(oneselfPickupFlg)){
 | 
	
		
			
				|  |  |             totalSql+=" AND e.oneself_pickup_flg ="+oneselfPickupFlg;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(nameKey)){
 | 
	
		
			
				|  |  |             totalSql+=" AND e.name like '%"+nameKey+"%'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(startTime)){
 | 
	
		
			
				|  |  |             totalSql+=" AND e.create_time >='"+startTime+" 00:00:00'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(endTime)){
 | 
	
		
			
				|  |  |             totalSql+=" AND e.create_time <='"+endTime+" 23:59:59'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
		
			
				|  |  |         if (rstotal != null && rstotal.size() > 0) {
 | 
	
		
			
				|  |  |             count = (Long) rstotal.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql ="SELECT " +
 | 
	
		
			
				|  |  |                 " e.create_time AS createTime, " +
 | 
	
		
			
				|  |  |                 " e.`name`, " +
 | 
	
		
			
				|  |  |                 " e.oneself_pickup_flg AS oneselfPickupFlg, " +
 | 
	
		
			
				|  |  |                 " o.id AS outpatientId, " +
 | 
	
		
			
				|  |  |                 " o.icd10_name AS icd10Name, " +
 | 
	
		
			
				|  |  |                 " p.`status`, " +
 | 
	
		
			
				|  |  |                 " p.id AS prescriptionId " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_outpatient o " +
 | 
	
		
			
				|  |  |                 " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
 | 
	
		
			
				|  |  |                 " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id " +
 | 
	
		
			
				|  |  |                 " WHERE" +
 | 
	
		
			
				|  |  |                 " 1=1";
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(status)){
 | 
	
		
			
				|  |  |             sql+=" AND p.status in("+status+")";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(oneselfPickupFlg)){
 | 
	
		
			
				|  |  |             sql+=" AND e.oneself_pickup_flg ="+oneselfPickupFlg;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(nameKey)){
 | 
	
		
			
				|  |  |             sql+=" AND e.name like '%"+nameKey+"%'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(startTime)){
 | 
	
		
			
				|  |  |             sql+=" AND e.create_time >='"+startTime+" 00:00:00'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(endTime)){
 | 
	
		
			
				|  |  |             sql+=" AND e.create_time <='"+endTime+" 23:59:59'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += " LIMIT " + (page - 1) * size + "," + size + "";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |