|  | @ -3,7 +3,6 @@ package com.yihu.jw.hospital.prescription.service.entrance;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.BaseDictJobTitleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.DictDoctorDutyDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.DictHospitalDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
	
		
			
				|  | @ -18,13 +17,19 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.AES;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.rm.base.BaseRequestMapping;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
	
		
			
				|  | @ -32,21 +37,19 @@ import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.WebserviceUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.security.MD5;
 | 
	
		
			
				|  |  | import net.sf.json.xml.XMLSerializer;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.checkerframework.checker.units.qual.A;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.transaction.Transactional;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | import java.util.Random;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 心脏中心内网his对接服务
 | 
	
	
		
			
				|  | @ -54,7 +57,7 @@ import java.util.Random;
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional
 | 
	
		
			
				|  |  | public class XzzxEntranceService {
 | 
	
		
			
				|  |  | public class XzzxEntranceService extends BaseJpaService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private static Logger logger = LoggerFactory.getLogger(XzzxEntranceService.class);
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -75,12 +78,29 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorMappingDao doctorMappingDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao basePatientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientWechatDao basePatientWechatDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HttpClientUtil httpClientUtil;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao patientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientMappingDao patientMappingDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OutpatientDao outpatientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientRegisterDao patientRegisterDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyHttpLogDao wlyyHttpLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionDao prescriptionDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionDiagnosisDao diagnosisDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionInfoDao prescriptionInfoDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyInspectionDao wlyyInspectionDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private static String key="bvvsf3JA0mUXMU+mVnMaOQ==";
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -711,7 +731,7 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     //处方状态变更
 | 
	
		
			
				|  |  |     public String updatePreStatus(String admNo,String realOrder,String status)throws Exception{
 | 
	
		
			
				|  |  |     public String updatePrescriptionStatus(String admNo,String realOrder,String status)throws Exception{
 | 
	
		
			
				|  |  |         String api = "UpdatePreStatus";
 | 
	
		
			
				|  |  |         String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
 | 
	
		
			
				|  |  |                 "<root> " +
 | 
	
	
		
			
				|  | @ -854,7 +874,7 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String ehospitalNotice(String userName, String idCard, String phone, String title, String url, String content, String contentString) {
 | 
	
		
			
				|  |  |         logger.info("ehospitalNotice:");
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idCard,"1");
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientDao.findByIdcardAndDel(idCard,"1");
 | 
	
		
			
				|  |  |         if(patientDO!=null&&StringUtils.isNotBlank(patientDO.getIdcard())){
 | 
	
		
			
				|  |  |             sendMes("xm_xzzx_wx",patientDO.getId(),null,content,contentString,"",url);
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -871,14 +891,43 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询患者就诊卡
 | 
	
		
			
				|  |  |      * @param idCard 身份证号
 | 
	
		
			
				|  |  |      * @param patient 身份证号
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String selectPateintCard(String idCard){
 | 
	
		
			
				|  |  |     public JSONArray selectPateintCard(String patient) throws Exception {
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientDao.findById(patient);
 | 
	
		
			
				|  |  |         String idCard = "";
 | 
	
		
			
				|  |  |         if (patientDO==null||StringUtil.isBlank(patientDO.getIdcard())){
 | 
	
		
			
				|  |  |             throw new Exception("居民身份证不存在");
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             idCard = patientDO.getIdcard();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         String response="";
 | 
	
		
			
				|  |  |         String url = entranceUrl+"findPatientCard?idCard="+idCard;
 | 
	
		
			
				|  |  |         response = httpClientUtil.get(url,"GBK");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         if(object.getInteger("status")==200){
 | 
	
		
			
				|  |  |             String obj = object.getString("obj");
 | 
	
		
			
				|  |  |             JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
 | 
	
		
			
				|  |  |             if (array!=null&&array.size()!=0){
 | 
	
		
			
				|  |  |                 JSONObject object1 = array.getJSONObject(0);
 | 
	
		
			
				|  |  |                 if (patientMappingDO==null){
 | 
	
		
			
				|  |  |                     patientMappingDO.setIdcard(patientDO.getIdcard());
 | 
	
		
			
				|  |  |                     patientMappingDO.setPatientName(patientDO.getName());
 | 
	
		
			
				|  |  |                     patientMappingDO.setPatient(patientDO.getId());
 | 
	
		
			
				|  |  |                     patientMappingDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                     patientMappingDO.setSource("1");
 | 
	
		
			
				|  |  |                     patientMappingDO.setMappingCode(object1.getString("SICKID"));
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     patientMappingDO.setMappingCode(object1.getString("SICKID"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 patientMappingDao.save(patientMappingDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return array;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -886,11 +935,16 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  |      * @param cardNo 就诊卡
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String selectCardInfo(String cardNo){
 | 
	
		
			
				|  |  |     public JSONArray selectCardInfo(String cardNo){
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         String response="";
 | 
	
		
			
				|  |  |         String url = entranceUrl+"getCardInfo?cardNo="+cardNo;
 | 
	
		
			
				|  |  |         response = httpClientUtil.get(url,"GBK");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         if (object.getInteger("status")==200){
 | 
	
		
			
				|  |  |             array = JSONArray.parseArray(object.getString("obj")).getJSONArray(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return array;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -900,27 +954,219 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  |      * @param conNo 就诊次数
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String selectOutpatientInfo(String patient,String conNo){
 | 
	
		
			
				|  |  |     public WlyyOutpatientVO selectOutpatientInfo(String patient,String conNo){
 | 
	
		
			
				|  |  |         WlyyOutpatientVO outpatientVO = new WlyyOutpatientVO();
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         String response="";
 | 
	
		
			
				|  |  |         String url = entranceUrl+"findOutpatientInfo?patient="+patient+"&conNo="+conNo;
 | 
	
		
			
				|  |  |         response = httpClientUtil.get(url,"GBK");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |         JSONObject jsonObject = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         if (jsonObject.getInteger("status")==200){
 | 
	
		
			
				|  |  |             array = JSONArray.parseArray(jsonObject.getString("obj")).getJSONArray(0);
 | 
	
		
			
				|  |  |             JSONObject object = array.getJSONObject(0);
 | 
	
		
			
				|  |  |             outpatientVO.setAdmNo(isEmty(object.getString("admNo")));
 | 
	
		
			
				|  |  |             outpatientVO.setOriginAdmNo(isEmty(object.getString("originAdmNo")));
 | 
	
		
			
				|  |  |             outpatientVO.setRegisterNo(isEmty(object.getString("registerNo")));
 | 
	
		
			
				|  |  |             outpatientVO.setOriginRegisterNo(isEmty(object.getString("originRegisterNo")));
 | 
	
		
			
				|  |  |             outpatientVO.setDept(isEmty(object.getString("dept")));
 | 
	
		
			
				|  |  |             outpatientVO.setDeptName(isEmty(object.getString("deptName")));
 | 
	
		
			
				|  |  |             outpatientVO.setPatient(isEmty(object.getString("patient")));
 | 
	
		
			
				|  |  |             outpatientVO.setPatientName(isEmty(object.getString("patientName")));
 | 
	
		
			
				|  |  |             outpatientVO.setDoctor(isEmty(object.getString("doctor")));
 | 
	
		
			
				|  |  |             outpatientVO.setIdcard(isEmty(object.getString("idcard")));
 | 
	
		
			
				|  |  |             outpatientVO.setMjz(isEmty(object.getString("mjz")));
 | 
	
		
			
				|  |  |             outpatientVO.setIcd10(isEmty(object.getString("icd10")));
 | 
	
		
			
				|  |  |             outpatientVO.setIcd10Name(isEmty(object.getString("icd10Name")));
 | 
	
		
			
				|  |  |             outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("admDate")));
 | 
	
		
			
				|  |  |             outpatientVO.setConDate(DateUtil.strToDate(object.getString("conDate")));
 | 
	
		
			
				|  |  |             outpatientVO.setDescription(isEmty(object.getString("description")));
 | 
	
		
			
				|  |  |             outpatientVO.setDiseaseImg(isEmty(object.getString("diseaseImg")));
 | 
	
		
			
				|  |  |             outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("createTime")));
 | 
	
		
			
				|  |  |             outpatientVO.setStatus(isEmty(object.getString("status")));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return outpatientVO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取门诊下所有处方信息
 | 
	
		
			
				|  |  |      * @param registerSn 流水号
 | 
	
		
			
				|  |  |      * @param patNo 病人id
 | 
	
		
			
				|  |  |      * @param patNo 居民id
 | 
	
		
			
				|  |  |      * @param admNo 住院唯一号
 | 
	
		
			
				|  |  |      * @param realOrder 处方号
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String selectOriginPrescriptionList(String registerSn,String patNo,String admNo,String realOrder){
 | 
	
		
			
				|  |  |     public List<WlyyPrescriptionVO> selectOriginPrescriptionList(String registerSn,String patNo,String admNo,String realOrder){
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionVO> prescriptionVOList = new ArrayList<>();
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         String response="";
 | 
	
		
			
				|  |  |         String url = entranceUrl+"getOriginPrescriptionList?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+"&realOrder"+realOrder;
 | 
	
		
			
				|  |  |         String params = "";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(realOrder)){
 | 
	
		
			
				|  |  |             params +="&realOrder="+realOrder;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String url = entranceUrl+"getOriginPrescriptionList?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+params;
 | 
	
		
			
				|  |  |         response = httpClientUtil.get(url,"GBK");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         if (object.getInteger("status")==200){
 | 
	
		
			
				|  |  |             array = JSONArray.parseArray(object.getString("obj")).getJSONArray(0);
 | 
	
		
			
				|  |  |             for (int i=0;i<array.size();i++){
 | 
	
		
			
				|  |  |                 WlyyPrescriptionVO wlyyPrescriptionVO = new WlyyPrescriptionVO();
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = array.getJSONObject(i);
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setId(isEmty(jsonObject.getString("id")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCreateTime(DateUtil.strToDate(isEmty(jsonObject.getString("createTime"))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCreateUser(isEmty(jsonObject.getString("createUser")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCreateUserName(isEmty(jsonObject.getString("createUserName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setUpdateTime(DateUtil.strToDate(isEmty(jsonObject.getString("updateTime"))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setUpdateUser(isEmty(jsonObject.getString("updateUser")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setUpdateUserName(isEmty(jsonObject.getString("updateUserName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setRealOrder(isEmty(jsonObject.getString("realOrder")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setOriginRealOrder(isEmty(jsonObject.getString("originRealOrder")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setAdmNo(isEmty(jsonObject.getString("admNo")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setOriginAdmNo(isEmty(jsonObject.getString("originAdmNo")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setSerialNo(isEmty(jsonObject.getString("serialNo")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setOriginSerialNo(isEmty(jsonObject.getString("originSerialNo")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setType(jsonObject.getInteger("type"));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setPatientCode(isEmty(jsonObject.getString("patientCode")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setPatientName(isEmty(jsonObject.getString("patientName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setIdcard(isEmty(jsonObject.getString("idcard")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCardNo(isEmty(jsonObject.getString("cardNo")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setSsc(isEmty(jsonObject.getString("ssc")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDoctor(isEmty(jsonObject.getString("doctor")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDoctorName(isEmty(jsonObject.getString("doctorName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setStatus(jsonObject.getInteger("status"));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setMkFailReason(isEmty(jsonObject.getString("mkFailReason")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setMkTime(DateUtil.strToDate(isEmty(jsonObject.getString("mkTime"))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setPrescribeTime(DateUtil.strToDate(isEmty(jsonObject.getString("prescribeTime"))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setPrescribeReason(isEmty(jsonObject.getString("prescribeReason")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setPayTime(DateUtil.strToDate(isEmty(jsonObject.getString("payTime"))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDosageTime(DateUtil.strToDate(isEmty(jsonObject.getString("dosageTime"))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setFinishTime(DateUtil.strToDate(isEmty(jsonObject.getString(""))));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDept(isEmty(jsonObject.getString("dept")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDeptName(isEmty(jsonObject.getString("deptName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHospital(isEmty(jsonObject.getString("hospital")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHospitalName(isEmty(jsonObject.getString("hospitalName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setConsult(isEmty(jsonObject.getString("consult")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDispensaryType(jsonObject.getInteger("dispensaryType"));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setReason(isEmty(jsonObject.getString("reason")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDiseaseImg(isEmty(jsonObject.getString("diseaseImg")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setRemark(isEmty(jsonObject.getString("remark")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCancelReason(isEmty(jsonObject.getString("cancelReason")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCaCertData(isEmty(jsonObject.getString("caCertData")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setCaMessage(isEmty(jsonObject.getString("caMessage")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDigitalSignNo(isEmty(jsonObject.getString("digitalSignNo")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setOriginalDataAbstract(isEmty(jsonObject.getString("originalDataAbstract")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setStrOriginalData(isEmty(jsonObject.getString("strOriginalData")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHisDeptCode(isEmty(jsonObject.getString("hisDeptCode")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHisDoctorCode(isEmty(jsonObject.getString("hisDoctorCode")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHisGisterTypeCode(isEmty(jsonObject.getString("hisGisterTypeCode")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHisRateTypeCode(isEmty(jsonObject.getString("hisRateTypeCode")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHisHospital(isEmty(jsonObject.getString("hisHospital")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setHisRegisterFee(jsonObject.getInteger("hisRegisterFee"));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setPayStatus(jsonObject.getInteger("payStatus"));
 | 
	
		
			
				|  |  |                 //TODO 快递数据
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDispUser(isEmty(jsonObject.getString("dispUser")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDispUserName(isEmty(jsonObject.getString("dispUserName")));
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDispDate(DateUtil.strToDate(isEmty(jsonObject.getString("dispDate"))));
 | 
	
		
			
				|  |  |                 //诊断
 | 
	
		
			
				|  |  |                 List<WlyyPrescriptionDiagnosisVO> prescriptionDiagnosisVOS = new ArrayList<>();
 | 
	
		
			
				|  |  |                 JSONArray jsonArray = jsonObject.getJSONArray("diagnosisVOs");
 | 
	
		
			
				|  |  |                 for (int j=0;j<jsonArray.size();j++){
 | 
	
		
			
				|  |  |                     JSONObject disagnosisJson = jsonArray.getJSONObject(j);
 | 
	
		
			
				|  |  |                     WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = new WlyyPrescriptionDiagnosisVO();
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setId(isEmty(disagnosisJson.getString("id")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setCreateTime(DateUtil.strToDate(isEmty(disagnosisJson.getString("createTime"))));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setCreateUser(isEmty(disagnosisJson.getString("createUser")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setCreateUserName(isEmty(disagnosisJson.getString("createUserName")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setUpdateTime(DateUtil.strToDate(isEmty(disagnosisJson.getString("updateTime"))));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setUpdateUser(isEmty(disagnosisJson.getString("updateUser")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setUpdateUserName(isEmty(disagnosisJson.getString("updateUserName")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setPrescriptionId(isEmty(disagnosisJson.getString("prescriptionId")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setCode(isEmty(disagnosisJson.getString("code")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setName(isEmty(disagnosisJson.getString("name")));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVO.setType(disagnosisJson.getInteger("type"));
 | 
	
		
			
				|  |  |                     prescriptionDiagnosisVOS.add(prescriptionDiagnosisVO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setDiagnosisVOs(prescriptionDiagnosisVOS);
 | 
	
		
			
				|  |  |                 //药品
 | 
	
		
			
				|  |  |                 List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOList = new ArrayList<>();
 | 
	
		
			
				|  |  |                 JSONArray infoArray = jsonObject.getJSONArray("infoVOs");
 | 
	
		
			
				|  |  |                 for (int j=0;j<infoArray.size();j++){
 | 
	
		
			
				|  |  |                     WlyyPrescriptionInfoVO prescriptionInfoVO = new WlyyPrescriptionInfoVO();
 | 
	
		
			
				|  |  |                     JSONObject infoJson = infoArray.getJSONObject(j);
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setId(isEmty(infoJson.getString("id")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setCreateTime(DateUtil.strToDate(isEmty(infoJson.getString("createTime"))));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setCreateUser(isEmty(infoJson.getString("createUser")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setCreateUserName(infoJson.getString("createUserName"));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUpdateTime(DateUtil.strToDate(isEmty(infoJson.getString("updateTime"))));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUpdateUser(isEmty(infoJson.getString("updateUser")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUpdateUserName(isEmty(infoJson.getString("updateUserName")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setPrescriptionId(isEmty(infoJson.getString("prescriptionId")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setDrugNo(isEmty(infoJson.getString("drugNo")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setDrugName(isEmty(infoJson.getString("drugName")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setDispDeposite(isEmty(infoJson.getString("dispDeposite")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setDosage(isEmty(infoJson.getString("dosage")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setQuantity(isEmty(infoJson.getString("quantity")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUnit(isEmty(infoJson.getString("unit")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUnitName(isEmty(infoJson.getString("unitName")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setPackUnitName(isEmty(infoJson.getString("packUnitName")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setPackUnit(isEmty(infoJson.getString("packUnit")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUsageCode(isEmty(infoJson.getString("usageCode")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setUsageName(isEmty(infoJson.getString("usageName")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setSupplyCode(isEmty(infoJson.getString("supplyCode")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setSupplyName(isEmty(infoJson.getString("supplyName")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setDays(isEmty(infoJson.getString("days")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setFrequency(isEmty(infoJson.getString("frequency")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setSerial(isEmty(infoJson.getString("serial")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setGroupNo(isEmty(infoJson.getString("groupNo")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setSpecification(isEmty(infoJson.getString("specification")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setPackRetprice(infoJson.getDouble("packRetprice"));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setHerbalCount(isEmty(infoJson.getString("herbalCount")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setPostCount(isEmty(infoJson.getString("postCount")));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setDel(infoJson.getInteger("del"));
 | 
	
		
			
				|  |  |                     prescriptionInfoVO.setComm(infoJson.getString("comm"));
 | 
	
		
			
				|  |  |                     wlyyPrescriptionInfoVOList.add(prescriptionInfoVO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOList);
 | 
	
		
			
				|  |  |                 //检查检验内容
 | 
	
		
			
				|  |  |                 List<WlyyInspectionVO> wlyyInspectionVOList = new ArrayList<>();
 | 
	
		
			
				|  |  |                 JSONArray inspectionArray = jsonObject.getJSONArray("inspectionVOs");
 | 
	
		
			
				|  |  |                 for (int j=0;j<inspectionArray.size();j++){
 | 
	
		
			
				|  |  |                     WlyyInspectionVO inspectionVO = new WlyyInspectionVO();
 | 
	
		
			
				|  |  |                     JSONObject inspectionJson = inspectionArray.getJSONObject(j);
 | 
	
		
			
				|  |  |                     inspectionVO.setId(isEmty(inspectionJson.getString("id")));
 | 
	
		
			
				|  |  |                     inspectionVO.setOutpatientId(isEmty(inspectionJson.getString("outpatientId")));
 | 
	
		
			
				|  |  |                     inspectionVO.setDept(isEmty(inspectionJson.getString("dept")));
 | 
	
		
			
				|  |  |                     inspectionVO.setDeptName(isEmty(inspectionJson.getString("deptName")));
 | 
	
		
			
				|  |  |                     inspectionVO.setGroupName(isEmty(inspectionJson.getString("groupName")));
 | 
	
		
			
				|  |  |                     inspectionVO.setQuantity(inspectionJson.getInteger("quantity"));
 | 
	
		
			
				|  |  |                     inspectionVO.setFrequency(isEmty(inspectionJson.getString("frequency")));
 | 
	
		
			
				|  |  |                     inspectionVO.setParentCode(isEmty(inspectionJson.getString("parentCode")));
 | 
	
		
			
				|  |  |                     inspectionVO.setParentName(isEmty(inspectionJson.getString("parentName")));
 | 
	
		
			
				|  |  |                     inspectionVO.setCode(isEmty(inspectionJson.getString("code")));
 | 
	
		
			
				|  |  |                     inspectionVO.setName(isEmty(inspectionJson.getString("name")));
 | 
	
		
			
				|  |  |                     inspectionVO.setInformation(isEmty(inspectionJson.getString("information")));
 | 
	
		
			
				|  |  |                     inspectionVO.setCheckEquip(isEmty(inspectionJson.getString("checkEquip")));
 | 
	
		
			
				|  |  |                     inspectionVO.setCheckPartName(isEmty(inspectionJson.getString("checkPartName")));
 | 
	
		
			
				|  |  |                     inspectionVO.setCheckPart(isEmty(inspectionJson.getString("checkPart")));
 | 
	
		
			
				|  |  |                     inspectionVO.setAdresult(isEmty(inspectionJson.getString("adresult")));
 | 
	
		
			
				|  |  |                     inspectionVO.setGoal(isEmty(inspectionJson.getString("goal")));
 | 
	
		
			
				|  |  |                     inspectionVO.setOpview(isEmty(inspectionJson.getString("opview")));
 | 
	
		
			
				|  |  |                     inspectionVO.setSpecimenName(isEmty(inspectionJson.getString("specimenName")));
 | 
	
		
			
				|  |  |                     inspectionVO.setSpecimenNum(isEmty(inspectionJson.getString("specimenNum")));
 | 
	
		
			
				|  |  |                     inspectionVO.setYwjcResult(isEmty(inspectionJson.getString("ywjcResult")));
 | 
	
		
			
				|  |  |                     inspectionVO.setYwjcDate(isEmty(inspectionJson.getString("ywjcDate")));
 | 
	
		
			
				|  |  |                     inspectionVO.setBlzd(isEmty(inspectionJson.getString("blzd")));
 | 
	
		
			
				|  |  |                     inspectionVO.setFixationfluid(isEmty(inspectionJson.getString("fixationfluid")));
 | 
	
		
			
				|  |  |                     inspectionVO.setCreateTime(DateUtil.strToDate(isEmty(inspectionJson.getString("createTime"))));
 | 
	
		
			
				|  |  |                     inspectionVO.setCheckbox(isEmty(inspectionJson.getString("checkbox")));
 | 
	
		
			
				|  |  |                     inspectionVO.setMzpg(isEmty(inspectionJson.getString("mzpg")));
 | 
	
		
			
				|  |  |                     inspectionVO.setSfzg(isEmty(inspectionJson.getString("sfzg")));
 | 
	
		
			
				|  |  |                     wlyyInspectionVOList.add(inspectionVO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 wlyyPrescriptionVO.setInspectionVOs(wlyyInspectionVOList);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return prescriptionVOList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -933,14 +1179,276 @@ public class XzzxEntranceService {
 | 
	
		
			
				|  |  |      * @param clinicclass 挂号类别(必填)
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String registeredOperate(String doctor,String dept,String sickId,String clinicclass){
 | 
	
		
			
				|  |  |     public JSONArray registeredOperate(String doctor,String dept,String sickId,String clinicclass){
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         String response="";
 | 
	
		
			
				|  |  |         String url = entranceUrl+"registered?doctor="+doctor+"&dept="+dept+"&sickId="+sickId+"&clinicclass"+clinicclass;
 | 
	
		
			
				|  |  |         response = httpClientUtil.get(url,"GBK");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         if (object.getInteger("status")==200){
 | 
	
		
			
				|  |  |             array = JSONArray.parseArray(object.getString("obj")).getJSONArray(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return array;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //=====================hospital应用调用entrance应用============end=================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //============================hospital业务层==================start====================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 挂号接口
 | 
	
		
			
				|  |  |      * @param outPatientId
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      * @param chargeType
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject registerOutPatient(String outPatientId, String doctor,String chargeType){
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
 | 
	
		
			
				|  |  |         if (doctorMappingDO == null) {
 | 
	
		
			
				|  |  |             throw new RuntimeException("未找到医生映射信息");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         if (patientMappingDO==null){
 | 
	
		
			
				|  |  |             throw new RuntimeException("未找到居民映射信息");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //查找居民当天挂号记录
 | 
	
		
			
				|  |  |         String date = DateUtil.dateToStr(new Date(), "yyyy-MM-dd");
 | 
	
		
			
				|  |  |         List<WlyyPatientRegisterDO> patientRegisterDOs = patientRegisterDao.findByPatientAndDateAndDoctor(outpatientDO.getPatient(), date, doctor);
 | 
	
		
			
				|  |  |         if (patientRegisterDOs != null && patientRegisterDOs.size() > 0) {
 | 
	
		
			
				|  |  |             WlyyPatientRegisterDO registerDO = patientRegisterDOs.get(0);
 | 
	
		
			
				|  |  |             //判断是否已经挂号,如果已经挂号
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(registerDO.getRegisterNo())) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 JSONObject res = new JSONObject();
 | 
	
		
			
				|  |  |                 res.put("@RESULT", "0");
 | 
	
		
			
				|  |  |                 logger.info("已经挂号 res: " + res.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //更新挂号流水号
 | 
	
		
			
				|  |  |                 outpatientDO.setConNo(registerDO.getConNo());
 | 
	
		
			
				|  |  |                 outpatientDO.setRegisterNo(registerDO.getRegisterNo());
 | 
	
		
			
				|  |  |                 outpatientDO.setAdmDate(registerDO.getCreateTime());
 | 
	
		
			
				|  |  |                 outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |                 return res;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONArray response =  registeredOperate(doctorMappingDO.getMappingCode(),outpatientDO.getDept(),patientMappingDO.getMappingCode(),chargeType);
 | 
	
		
			
				|  |  |         JSONObject res = response.getJSONObject(0);
 | 
	
		
			
				|  |  |         logger.info("挂号结果 res: " + response.toString());
 | 
	
		
			
				|  |  |         String rsCode = res.getString("registerNo");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if ("0".equals(rsCode)) {
 | 
	
		
			
				|  |  |             //存储挂号号
 | 
	
		
			
				|  |  |             String serialNo = (String) res.get("registerNo");
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |             outpatientDO.setAdmDate(new Date());
 | 
	
		
			
				|  |  |             logger.info("挂号流水 registerNo: ");
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //存储就诊记录
 | 
	
		
			
				|  |  |             WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
 | 
	
		
			
				|  |  |             // 存储挂号医生与挂号科室
 | 
	
		
			
				|  |  |             registerDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             registerDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |             registerDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |             registerDO.setDeptName(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             registerDO.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             registerDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |             //挂号流水号与挂号次数
 | 
	
		
			
				|  |  |             registerDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |             registerDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
 | 
	
		
			
				|  |  |             patientRegisterDao.save(registerDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else if ("-2".equals(rsCode)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String serialNo = (String) res.get("registerNo");
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |             outpatientDO.setAdmDate(new Date());
 | 
	
		
			
				|  |  |             logger.info("挂号流水 registerNo: " + serialNo );
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //存储就诊记录
 | 
	
		
			
				|  |  |             WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             registerDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             registerDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |             registerDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |             registerDO.setDeptName(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             registerDO.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             registerDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |             registerDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |             registerDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             patientRegisterDao.save(registerDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存日志
 | 
	
		
			
				|  |  |         WlyyHttpLogDO log = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         log.setCode("registerOutPatient");
 | 
	
		
			
				|  |  |         log.setName("挂号");
 | 
	
		
			
				|  |  |         log.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         log.setDoctor(doctor);
 | 
	
		
			
				|  |  |         log.setResponse(response.toString());
 | 
	
		
			
				|  |  |         log.setRequest("outPatientId=" + outPatientId + "&doctor=" + doctor);
 | 
	
		
			
				|  |  |         log.setStatus(rsCode);
 | 
	
		
			
				|  |  |         log.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyHttpLogDao.save(log);
 | 
	
		
			
				|  |  |         return res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询单条门诊记录
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @param conNo
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public WlyyOutpatientVO findOutpatientData(String patient, String conNo)throws Exception{
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patient:"+patient);
 | 
	
		
			
				|  |  |         String patNo =findHisPatNoByPatient(patient);
 | 
	
		
			
				|  |  |         if(StringUtils.isBlank(patNo)){
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patNo:"+patNo);
 | 
	
		
			
				|  |  |         WlyyOutpatientVO outpatientVO=selectOutpatientInfo(patNo,conNo);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(outpatientVO!=null){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             BasePatientDO patientDO = patientDao.findById(patient);
 | 
	
		
			
				|  |  |             outpatientVO.setSex(patientDO.getSex()+"");
 | 
	
		
			
				|  |  |             outpatientVO.setBirthday(patientDO.getBirthday());
 | 
	
		
			
				|  |  |             return outpatientVO;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return outpatientVO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String isEmty(String str){
 | 
	
		
			
				|  |  |         if (str.equalsIgnoreCase("[]")){
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             return str;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取his居民id
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String findHisPatNoByPatient(String patient)throws Exception{
 | 
	
		
			
				|  |  |         logger.info("findHisPatNoByPatient:"+patient);
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientDao.findById(patient);
 | 
	
		
			
				|  |  |         logger.info("patientDO:"+patientDO.toString());
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         if(patientMappingDO!=null){
 | 
	
		
			
				|  |  |             return patientMappingDO.getMappingCode();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String patientId = "";
 | 
	
		
			
				|  |  |         JSONArray rs = selectPateintCard(patient);
 | 
	
		
			
				|  |  |         if (rs!=null&&rs.size()!=0){
 | 
	
		
			
				|  |  |             JSONObject object = rs.getJSONObject(0);
 | 
	
		
			
				|  |  |             patientId = object.getString("SICKID");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return patientId;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /*
 | 
	
		
			
				|  |  |      * @param registerSn 流水号
 | 
	
		
			
				|  |  |      * @param patient 居民code
 | 
	
		
			
				|  |  |      * @param admNo 住院唯一号
 | 
	
		
			
				|  |  |      * @param realOrder 处方号
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<WlyyPrescriptionVO> findPrescriptionList(String outPatientId,String realOrder) throws Exception {
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId);
 | 
	
		
			
				|  |  |         if (outpatientDO==null){
 | 
	
		
			
				|  |  |             throw new Exception("该门诊记录不存在!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String registerSn = outpatientDO.getRegisterNo();
 | 
	
		
			
				|  |  |         if (!StringUtils.isNoneBlank(registerSn)){
 | 
	
		
			
				|  |  |             throw new Exception("挂号流水号不存在");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String admNo = outpatientDO.getAdmNo();
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         if (patientMappingDO==null||!StringUtils.isNoneBlank(patientMappingDO.getMappingCode())){
 | 
	
		
			
				|  |  |             throw new Exception("该居民映射表不存在!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionVO> wlyyPrescriptionVOList = selectOriginPrescriptionList(registerSn,patientMappingDO.getMappingCode(),admNo,realOrder);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return wlyyPrescriptionVOList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String,Object> updatePreStatus(String admNo,String realOrder,String status) throws Exception {
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> wlyyOutpatientDOList = outpatientDao.findByAdmNo(admNo);
 | 
	
		
			
				|  |  |         if (wlyyOutpatientDOList!=null&&wlyyOutpatientDOList.size()!=0){
 | 
	
		
			
				|  |  |             throw new Exception("该就诊号查不到!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for (WlyyOutpatientDO wlyyOutpatientDO:wlyyOutpatientDOList){
 | 
	
		
			
				|  |  |             String registerNo = wlyyOutpatientDO.getRegisterNo();
 | 
	
		
			
				|  |  |             if (!StringUtils.isNoneBlank(registerNo)){
 | 
	
		
			
				|  |  |                 throw new Exception("挂号流水号为空!");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(wlyyOutpatientDO.getPatient());
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByOutpatientId(wlyyOutpatientDO.getId());
 | 
	
		
			
				|  |  |             if (prescriptionDOList==null||prescriptionDOList.size()==0){
 | 
	
		
			
				|  |  |                 List<WlyyPrescriptionVO> prescriptionVOList = selectOriginPrescriptionList(registerNo,patientMappingDO.getMappingCode(),admNo,realOrder);
 | 
	
		
			
				|  |  |                 for (WlyyPrescriptionVO prescriptionVO:prescriptionVOList){
 | 
	
		
			
				|  |  |                     WlyyPrescriptionDO prescriptionDO = new WlyyPrescriptionDO();
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(prescriptionVO, prescriptionDO);
 | 
	
		
			
				|  |  |                     prescriptionDO.setOutpatientId(wlyyOutpatientDO.getId());
 | 
	
		
			
				|  |  |                     if (status.equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |                         prescriptionDO.setStatus(30);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     prescriptionDO= prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  |                     //处方诊断表vo
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionDiagnosisVO> diagnosisVOS = prescriptionVO.getDiagnosisVOs();
 | 
	
		
			
				|  |  |                     for (WlyyPrescriptionDiagnosisVO diagnosisVO:diagnosisVOS){
 | 
	
		
			
				|  |  |                         WlyyPrescriptionDiagnosisDO prescriptionDiagnosisDO = new WlyyPrescriptionDiagnosisDO();
 | 
	
		
			
				|  |  |                         BeanUtils.copyProperties(diagnosisVO,prescriptionDiagnosisDO);
 | 
	
		
			
				|  |  |                         prescriptionDiagnosisDO.setPrescriptionId(prescriptionDO.getId());
 | 
	
		
			
				|  |  |                         diagnosisDao.save(prescriptionDiagnosisDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     //药品表
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionInfoVO> infoVOList = prescriptionVO.getInfoVOs();
 | 
	
		
			
				|  |  |                     for (WlyyPrescriptionInfoVO infoVO:infoVOList){
 | 
	
		
			
				|  |  |                         WlyyPrescriptionInfoDO infoDO = new WlyyPrescriptionInfoDO();
 | 
	
		
			
				|  |  |                         BeanUtils.copyProperties(infoVO,infoDO);
 | 
	
		
			
				|  |  |                         infoDO.setPrescriptionId(prescriptionDO.getId());
 | 
	
		
			
				|  |  |                         prescriptionInfoDao.save(infoDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     List<WlyyInspectionVO> inspectionVOList = prescriptionVO.getInspectionVOs();
 | 
	
		
			
				|  |  |                     for (WlyyInspectionVO inspectionVO:inspectionVOList){
 | 
	
		
			
				|  |  |                         WlyyInspectionDO inspectionDO = new WlyyInspectionDO();
 | 
	
		
			
				|  |  |                         BeanUtils.copyProperties(inspectionVO,inspectionDO);
 | 
	
		
			
				|  |  |                         inspectionDO.setPrescriptionId(prescriptionDO.getId());
 | 
	
		
			
				|  |  |                         wlyyInspectionDao.save(inspectionDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //============================hospital业务层==================start====================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |