|  | @ -3,8 +3,13 @@ package com.yihu.jw.hospital.prescription.service.entrance;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.core.type.TypeReference;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.DictHospitalDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.service.DictHospitalDeptService;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.HospitalDeptMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.HospitalDeptMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.ConvertUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.util.WebserviceUtil;
 | 
	
	
		
			
				|  | @ -21,6 +26,7 @@ import org.springframework.core.io.ClassPathResource;
 | 
	
		
			
				|  |  | import org.springframework.core.io.Resource;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.transaction.Transactional;
 | 
	
		
			
				|  |  | import java.io.BufferedReader;
 | 
	
		
			
				|  |  | import java.io.InputStream;
 | 
	
		
			
				|  |  | import java.io.InputStreamReader;
 | 
	
	
		
			
				|  | @ -35,6 +41,7 @@ import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  * Created by zdm on 2019/5/20.
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional
 | 
	
		
			
				|  |  | public class EntranceService {
 | 
	
		
			
				|  |  |     //门诊余额查询
 | 
	
		
			
				|  |  |     private static String BS15017="BS15017";
 | 
	
	
		
			
				|  | @ -69,7 +76,9 @@ public class EntranceService {
 | 
	
		
			
				|  |  |     @Value("${hospital.TargetSysCode}")
 | 
	
		
			
				|  |  |     private String targetSysCode;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HospitalDeptMappingDao hospitalDeptMappingDao;
 | 
	
		
			
				|  |  |     private DictHospitalDeptDao dictHospitalDeptDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientMappingDao patientMappingDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取本地示例返参
 | 
	
	
		
			
				|  | @ -262,6 +271,8 @@ public class EntranceService {
 | 
	
		
			
				|  |  |                                 if (!(null != stringSet && stringSet.contains(realOrder))) {
 | 
	
		
			
				|  |  |                                     //初始化处方
 | 
	
		
			
				|  |  |                                     wlyyPrescriptionVO = initWlyyPrescriptionVo(new WlyyPrescriptionVO(), jsonObjectBody, realOrder);
 | 
	
		
			
				|  |  |                                     wlyyPrescriptionVO.setHospital("350211A1002");
 | 
	
		
			
				|  |  |                                     wlyyPrescriptionVO.setHospitalName("厦门市中山医院");
 | 
	
		
			
				|  |  |                                     wlyyPrescriptionVOMap.put(realOrder, wlyyPrescriptionVO);
 | 
	
		
			
				|  |  |                                     //主诊断 毒蛇咬伤&T63.001
 | 
	
		
			
				|  |  |                                     String[] icdName = jsonObjectBody.get("icd_name").toString().split("&");
 | 
	
	
		
			
				|  | @ -347,10 +358,18 @@ public class EntranceService {
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setRealOrder(realOrder);
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setSerialNo(null != jsonObjectBody.get("REGISTER_SN") ? jsonObjectBody.get("REGISTER_SN").toString() : "");
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setType(1);
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setPatientCode(null != jsonObjectBody.get("PAT_NO") ? jsonObjectBody.get("PAT_NO").toString() : "");
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setPatientName(null != jsonObjectBody.get("UOM") ? jsonObjectBody.get("UOM").toString() : "");
 | 
	
		
			
				|  |  |         //TODO 通过映射表获取居民身份证号e
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setIdcard("");
 | 
	
		
			
				|  |  |         String patNo=null != jsonObjectBody.get("PAT_NO") ? jsonObjectBody.get("PAT_NO").toString() : "";
 | 
	
		
			
				|  |  |         String patientName=null != jsonObjectBody.get("UOM") ? jsonObjectBody.get("UOM").toString() : "";
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDo=new PatientMappingDO();
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(patNo)){
 | 
	
		
			
				|  |  |             patientMappingDo=  patientMappingDao.findByMappingCodeAndSource(patNo,"1");
 | 
	
		
			
				|  |  |             patNo=StringUtils.isBlank(patientMappingDo.getPatient())?patNo:patientMappingDo.getPatient();
 | 
	
		
			
				|  |  |             patientName=StringUtils.isBlank(patientMappingDo.getPatientName())?patientName:patientMappingDo.getPatientName();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setPatientCode(patNo);
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setPatientName(patientName);
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setIdcard(patientMappingDo.getIdcard());
 | 
	
		
			
				|  |  |         //TODO 社保卡号
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setSsc("");
 | 
	
		
			
				|  |  |         wlyyPrescriptionVO.setHisDoctorCode(null != jsonObjectBody.get("PRESC_DOC") ? jsonObjectBody.get("PRESC_DOC").toString() : "");
 | 
	
	
		
			
				|  | @ -427,13 +446,22 @@ public class EntranceService {
 | 
	
		
			
				|  |  |             net.sf.json.JSONObject jsonObjectMgsInfo = (net.sf.json.JSONObject) object;
 | 
	
		
			
				|  |  |             if (null != jsonObjectMgsInfo) {
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO = new WlyyOutpatientVO();
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setHospital("350211A1002");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setHospitalName("厦门市中山医院");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setAdmNo(null == jsonObjectMgsInfo.get("ADM_NO") ? "" : jsonObjectMgsInfo.get("ADM_NO") + "");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setRegisterNo(null == jsonObjectMgsInfo.get("REGISTER_SN") ? "" : jsonObjectMgsInfo.get("REGISTER_SN") + "");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setDept(null == jsonObjectMgsInfo.get("ADM_SPEC") ? "" : jsonObjectMgsInfo.get("ADM_SPEC") + "");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setDeptName(null == jsonObjectMgsInfo.get("ADM_SPEC_NAME") ? "" : jsonObjectMgsInfo.get("ADM_SPEC_NAME") + "");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setPatient(null == jsonObjectMgsInfo.get("PAT_NO") ? "" : jsonObjectMgsInfo.get("PAT_NO") + "");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setPatientName(null == jsonObjectMgsInfo.get("PAT_NAME") ? "" : jsonObjectMgsInfo.get("PAT_NAME") + "");
 | 
	
		
			
				|  |  |                 String patNo=null != jsonObjectMgsInfo.get("PAT_NO") ? jsonObjectMgsInfo.get("PAT_NO").toString() : "";
 | 
	
		
			
				|  |  |                 String patientName=null != jsonObjectMgsInfo.get("PAT_NAME") ? jsonObjectMgsInfo.get("PAT_NAME").toString() : "";
 | 
	
		
			
				|  |  |                 PatientMappingDO patientMappingDo=new PatientMappingDO();
 | 
	
		
			
				|  |  |                 if(StringUtils.isNotBlank(patNo)){
 | 
	
		
			
				|  |  |                     patientMappingDo=  patientMappingDao.findByMappingCodeAndSource(patNo,"1");
 | 
	
		
			
				|  |  |                     patNo=StringUtils.isBlank(patientMappingDo.getPatient())?patNo:patientMappingDo.getPatient();
 | 
	
		
			
				|  |  |                     patientName=StringUtils.isBlank(patientMappingDo.getPatientName())?patientName:patientMappingDo.getPatientName();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setPatient(patNo);
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setPatientName(patientName);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setDoctor(null == jsonObjectMgsInfo.get("CON_DOC") ? "" : jsonObjectMgsInfo.get("CON_DOC") + "");
 | 
	
		
			
				|  |  |                 wlyyOutpatientVO.setDoctorName(null == jsonObjectMgsInfo.get("CON_DOC_NAME") ? "" : jsonObjectMgsInfo.get("CON_DOC_NAME") + "");
 | 
	
	
		
			
				|  | @ -697,8 +725,8 @@ public class EntranceService {
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public List<HospitalDeptMappingDO> MS02001(boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  | //    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public List<DictHospitalDeptDO> MS02001(boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  |         String fid=MS02001;
 | 
	
		
			
				|  |  |         String resp="";
 | 
	
		
			
				|  |  |         if (demoFlag) {
 | 
	
	
		
			
				|  | @ -716,14 +744,36 @@ public class EntranceService {
 | 
	
		
			
				|  |  |             resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONArray jsonArray= ConvertUtil.convertListEnvelopInBody(resp);
 | 
	
		
			
				|  |  |         List<HospitalDeptMappingDO> hospitalDeptMappingDOS=new ArrayList<>();
 | 
	
		
			
				|  |  |         HospitalDeptMappingDO hdmDo;
 | 
	
		
			
				|  |  |         List<DictHospitalDeptDO> hospitalDeptMappingDOS=new ArrayList<>();
 | 
	
		
			
				|  |  |         DictHospitalDeptDO hdmDo;
 | 
	
		
			
				|  |  |         String orgCode="350211A1002";
 | 
	
		
			
				|  |  |         Map<String,String> orgCodeMap=new HashMap<>();
 | 
	
		
			
				|  |  |         //6总部7金榜8夏禾
 | 
	
		
			
				|  |  |         orgCodeMap.put("6",orgCode);
 | 
	
		
			
				|  |  |         orgCodeMap.put("7","");
 | 
	
		
			
				|  |  |         orgCodeMap.put("8","");
 | 
	
		
			
				|  |  |         //删除旧数据
 | 
	
		
			
				|  |  |         hospitalDeptMappingDao.deleteBySource("1");
 | 
	
		
			
				|  |  |         List<String> strings=new ArrayList<>(orgCodeMap.values()) ;
 | 
	
		
			
				|  |  |         for(String s:strings) {
 | 
	
		
			
				|  |  |             if(StringUtils.isNotBlank(s)){
 | 
	
		
			
				|  |  |                 dictHospitalDeptDao.deleteByOrgCode(s);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for(Object object:jsonArray){
 | 
	
		
			
				|  |  |             hdmDo=new HospitalDeptMappingDO();
 | 
	
		
			
				|  |  |             hdmDo=new DictHospitalDeptDO();
 | 
	
		
			
				|  |  |             net.sf.json.JSONObject jsonObjectBody=(net.sf.json.JSONObject)object;
 | 
	
		
			
				|  |  |             hdmDo.setSerialNo(null==jsonObjectBody.get("Serial_No")?"":jsonObjectBody.get("Serial_No").toString());
 | 
	
		
			
				|  |  |             String deptTypeCode=null==jsonObjectBody.get("Dept_Type_Code")?"":jsonObjectBody.get("Dept_Type_Code").toString();
 | 
	
		
			
				|  |  |             if(StringUtils.isNotBlank(orgCodeMap.get(deptTypeCode))){
 | 
	
		
			
				|  |  |                 hdmDo.setOrgCode(orgCode);
 | 
	
		
			
				|  |  |                 hdmDo.setCode(null==jsonObjectBody.get("Dept_Code")?"":jsonObjectBody.get("Dept_Code").toString());
 | 
	
		
			
				|  |  |                 hdmDo.setName(null==jsonObjectBody.get("Dept_Name")?"":jsonObjectBody.get("Dept_Name").toString());
 | 
	
		
			
				|  |  |                 hdmDo.setDeptTypeCode(deptTypeCode);
 | 
	
		
			
				|  |  |                 hdmDo.setCreateTime(new Date());
 | 
	
		
			
				|  |  | //                DictHospitalDeptDao.save(hdmDo);
 | 
	
		
			
				|  |  |                 hospitalDeptMappingDOS.add(hdmDo);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |        /*     hdmDo.setSerialNo(null==jsonObjectBody.get("Serial_No")?"":jsonObjectBody.get("Serial_No").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDeptCode(null==jsonObjectBody.get("Dept_Code")?"":jsonObjectBody.get("Dept_Code").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDeptName(null==jsonObjectBody.get("Dept_Name")?"":jsonObjectBody.get("Dept_Name").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDeptAlias(null==jsonObjectBody.get("Dept_Alias")?"":jsonObjectBody.get("Dept_Alias").toString());
 | 
	
	
		
			
				|  | @ -736,7 +786,6 @@ public class EntranceService {
 | 
	
		
			
				|  |  |             hdmDo.setInputCode(null==jsonObjectBody.get("Input_Code")?"":jsonObjectBody.get("Input_Code").toString());
 | 
	
		
			
				|  |  |             hdmDo.setPinyinCode(null==jsonObjectBody.get("Pinyin_Code")?"":jsonObjectBody.get("Pinyin_Code").toString());
 | 
	
		
			
				|  |  |             hdmDo.setWubiCode(null==jsonObjectBody.get("Wubi_Code")?"":jsonObjectBody.get("Wubi_Code").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDeptTypeCode(null==jsonObjectBody.get("Dept_Type_Code")?"":jsonObjectBody.get("Dept_Type_Code").toString());
 | 
	
		
			
				|  |  |             hdmDo.setLocation(null==jsonObjectBody.get("Location")?"":jsonObjectBody.get("Location").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDisplaySequence(null==jsonObjectBody.get("Display_Sequence")?"":jsonObjectBody.get("Display_Sequence").toString());
 | 
	
		
			
				|  |  |             hdmDo.setOpenBedNum(null==jsonObjectBody.get("Open_Bed_Num")?"":jsonObjectBody.get("Open_Bed_Num").toString());
 | 
	
	
		
			
				|  | @ -749,11 +798,11 @@ public class EntranceService {
 | 
	
		
			
				|  |  |             hdmDo.setDeptZipCode(null==jsonObjectBody.get("Dept_Zip_Code")?"":jsonObjectBody.get("Dept_Zip_Code").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDeDlid(null==jsonObjectBody.get("De_Dlid")?"":jsonObjectBody.get("De_Dlid").toString());
 | 
	
		
			
				|  |  |             hdmDo.setDeLcid(null==jsonObjectBody.get("De_Lcid")?"":jsonObjectBody.get("De_Lcid").toString());
 | 
	
		
			
				|  |  |             hdmDo.setSource("1");
 | 
	
		
			
				|  |  |             hdmDo.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             hospitalDeptMappingDOS.add(hdmDo);
 | 
	
		
			
				|  |  |             hdmDo.setSource("1");*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         hospitalDeptMappingDao.save(hospitalDeptMappingDOS);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         dictHospitalDeptDao.save(hospitalDeptMappingDOS);
 | 
	
		
			
				|  |  |         return hospitalDeptMappingDOS;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 |