| 
					
				 | 
			
			
				@ -1,6 +1,8 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.wlyy.service.app.record; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.dict.SystemDict; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.system.SystemDictService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.HttpClientUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.SystemConf; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -8,6 +10,7 @@ import org.apache.http.NameValuePair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.http.message.BasicNameValuePair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -21,6 +24,8 @@ import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class RegDeptSpeDoctorService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    SystemDictService systemDictService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取转诊预约医生号源信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -37,20 +42,53 @@ public class RegDeptSpeDoctorService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.add(new BasicNameValuePair("DocCode", DocCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String response = HttpClientUtil.post(url, params, "UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray result = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray resultArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> systemDictMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (SystemDict systemDict : systemDictList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            systemDictMap.put(systemDict.getCode(), systemDict.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!StringUtils.isEmpty(response)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject jsonObject = new JSONObject(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int status = jsonObject.getInt("status"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject responseObject = new JSONObject(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int status = responseObject.getInt("status"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (status == 200){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String data = jsonObject.getString("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String data = responseObject.getString("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!StringUtils.isEmpty(data)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (data.startsWith("error")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonData = new JSONObject(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    result = jsonData.getJSONArray("EhrList"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray jsonArray = jsonData.getJSONArray("EhrList"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Map<String, JSONObject> jsonObjectMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (int i=0; i<jsonArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject jsonObject = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String patientId = jsonObject.getString("XMAN_ID"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String eventNo = jsonObject.getString("EVENT"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer orgId = jsonObject.getInt("ORG_ID"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String key = patientId + eventNo + orgId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject catalogObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String catalogCode = jsonObject.get("CATALOG_CODE").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String catalogValue = systemDictMap.get(catalogCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            jsonObject.remove("CATALOG_CODE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (jsonObjectMap.containsKey(key)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                jsonObject = jsonObjectMap.get(key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                catalogObject = jsonObject.getJSONObject("CATALOG"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            catalogObject.put(catalogCode, catalogValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            jsonObject.put("CATALOG", catalogObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            jsonObjectMap.put(key, jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (String key : jsonObjectMap.keySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            resultArray.put(jsonObjectMap.get(key)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return resultArray.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |