|  | @ -0,0 +1,1453 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.hospital.prescription.service.entrance;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.booking.PatientReservation;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.booking.ReservationHospitalDept;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.booking.dao.PatientReservationDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.vo.GuahaoDoctor;
 | 
	
		
			
				|  |  | import com.yihu.jw.sms.dao.HospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.entity.ServiceException;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.apache.http.NameValuePair;
 | 
	
		
			
				|  |  | import org.apache.http.message.BasicNameValuePair;
 | 
	
		
			
				|  |  | import org.dom4j.Document;
 | 
	
		
			
				|  |  | import org.dom4j.DocumentHelper;
 | 
	
		
			
				|  |  | import org.json.JSONArray;
 | 
	
		
			
				|  |  | import org.json.JSONObject;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.Resource;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by ysj on 2022/11/22.
 | 
	
		
			
				|  |  |  * 与统一接口平台对接
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | public class JwSmjkEntranceService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //基卫服务地址
 | 
	
		
			
				|  |  | //    @Value("${sign.check_upload}")
 | 
	
		
			
				|  |  |     private String jwUrl="";
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HttpClientUtil HttpClientUtil;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  |     @Resource
 | 
	
		
			
				|  |  |     private HospitalSysDictDao hospitalSysDictDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //未对接 模拟数据
 | 
	
		
			
				|  |  |     private boolean isdemo =true;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /****************************************************************************************************************************/
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取门/急诊记录 + 住院记录
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getResidentEventListJson(String strSSID,String type,String page,String pageSize)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String re = "";
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/ResidentEventList";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(type)) {
 | 
	
		
			
				|  |  |                 params.add(new BasicNameValuePair("type", type));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("page", page));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("pageSize", pageSize));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject responseObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = responseObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     String data = responseObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
 | 
	
		
			
				|  |  |                         throw new ServiceException(data);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  |                         JSONArray jsonArray = jsonData.getJSONArray("EventList");
 | 
	
		
			
				|  |  |                         re = jsonArray.toString();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(responseObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(re.contains("[{}]"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 re = re.replace("[{}]","[]");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return re;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 通过event获取档案类型列表
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getEventCatalog(String strSSID,String strEvent)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/EventCatalog";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strEvent", strEvent));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             String result = "";
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     result = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                     if (result.startsWith("error")) {
 | 
	
		
			
				|  |  |                         throw new ServiceException(result);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取健康档案信息详情
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getHealthData(String strSSID, String strEvent, String strCatalog, String strSerial) throws Exception {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  | //            return ehrService.getHealthData(strSSID,strEvent,strCatalog,strSerial);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/HealthData";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strEvent", strEvent));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strCatalog", strCatalog));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSerial", strSerial));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             String result = "";
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     result = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                     result = result.replaceAll("<\\?xml version=\"1.0\" encoding=\"utf-8\"\\?>", "");
 | 
	
		
			
				|  |  |                     if (result.startsWith("error")) {
 | 
	
		
			
				|  |  |                         throw new ServiceException(result);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取检查检验列表
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getExamAndLabReport(String strSSID,String page,String pageSize) throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/ExamAndLabReport";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("page", page));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("pageSize", pageSize));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             String re = "";
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     String data = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
 | 
	
		
			
				|  |  |                         throw new ServiceException(data);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  |                         JSONArray jsonArray = jsonData.getJSONArray("EhrList");
 | 
	
		
			
				|  |  |                         re = jsonArray.toString();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(re.contains("[{}]"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 re = re.replace("[{}]","[]");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return re;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取心电记录
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String EcGList(String strSSID,String strStart,String strEnd) throws Exception {
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/getEcGList";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strStart", strStart));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strEnd", strEnd));
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             String re = "";
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     String data = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
 | 
	
		
			
				|  |  |                         return "暂无心电检查记录";
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         re = data;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if(re.contains("[{}]"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 re = re.replace("[{}]","[]");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return re;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> getEcGList(String strSSID,String strStart,String strEnd) throws Exception {
 | 
	
		
			
				|  |  |         String response = this.EcGList(strSSID, strStart, strEnd);
 | 
	
		
			
				|  |  |         if (response.equals("暂无心电检查记录")){
 | 
	
		
			
				|  |  |             List<Map<String, Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  |             Map<String,Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("fhsb","暂无心电检查记录");
 | 
	
		
			
				|  |  |             list.add(map);
 | 
	
		
			
				|  |  |             return list;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return  xmlToList(response);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private List<Map<String, Object>> xmlToList(String xml) throws Exception {
 | 
	
		
			
				|  |  |         List<Map<String, Object>> re = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(xml)) {
 | 
	
		
			
				|  |  |             // 请求失败
 | 
	
		
			
				|  |  |             throw new ServiceException("获取心电失败!");
 | 
	
		
			
				|  |  |         } else if (StringUtils.startsWith(xml, "System-Error")) {
 | 
	
		
			
				|  |  |             // 调用失败
 | 
	
		
			
				|  |  |             throw new ServiceException(xml.substring(xml.indexOf(":") + 1, xml.length()));
 | 
	
		
			
				|  |  |         } else if (StringUtils.startsWith(xml, "Error")) {
 | 
	
		
			
				|  |  |             // 调用失败
 | 
	
		
			
				|  |  |             throw new ServiceException(xml.substring(xml.indexOf(":") + 1, xml.length()));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Document document = DocumentHelper.parseText(xml);
 | 
	
		
			
				|  |  |         org.dom4j.Element root = document.getRootElement();
 | 
	
		
			
				|  |  |         if (root.element("\"item\"") != null)     //包含item节点
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             root = root.element("\"item\"");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<?> child = root.elements();
 | 
	
		
			
				|  |  |         for (Object o : child) {
 | 
	
		
			
				|  |  |             org.dom4j.Element e = (org.dom4j.Element) o;
 | 
	
		
			
				|  |  |             String ssid = e.attributeValue("ssid");
 | 
	
		
			
				|  |  |             String url = e.attributeValue("url");
 | 
	
		
			
				|  |  |             String orgcode = e.attributeValue("orgcode");
 | 
	
		
			
				|  |  |             String orgname = e.attributeValue("orgname");
 | 
	
		
			
				|  |  |             String diagnosis = e.attributeValue("diagnosis");
 | 
	
		
			
				|  |  |             String reporttime = e.attributeValue("reporttime");
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("ssid", ssid);
 | 
	
		
			
				|  |  |             map.put("url", url);
 | 
	
		
			
				|  |  |             map.put("orgcode", orgcode);
 | 
	
		
			
				|  |  |             map.put("orgname", orgname);
 | 
	
		
			
				|  |  |             map.put("diagnosis", diagnosis);
 | 
	
		
			
				|  |  |             map.put("reporttime", reporttime);
 | 
	
		
			
				|  |  |             re.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取用药列表
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getDrugsListPage(String strSSID,String page,String pageSize) throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/DrugsListPage";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("page", page));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("pageSize", pageSize));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             String result = "";
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     result = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(result.contains("[{}]"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 result = result.replace("[{}]","[]");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /****************************************************************************************************************************/
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * (内网)获取转诊预约医生号源信息
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getRegDeptSpeDoctorSectionList(String OrgCode,String DeptCode,String strStart,String strEnd,String DocCode)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         String re = "";
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/smjk/RegDeptSpeDoctorSectionList";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("OrgCode", OrgCode));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("DeptCode", DeptCode));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("strStart", strStart));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("strEnd", strEnd));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("DocCode", DocCode));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response =  HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 String data = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                 if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
 | 
	
		
			
				|  |  |                     throw new ServiceException(data);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     re = data;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * (内网)预约挂号接口
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String webRegisterByFamily(String idcard,String patientName,String ssid,String sectionType,String startTime,String orgCode,String deptCode,String deptName,String doctorCode,String doctorName,String patientPhone)  throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         String re = "";
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/smjk/WebRegisterByFamily";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("idcard", idcard));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patientName", patientName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("ssid", ssid));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("sectionType", sectionType));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("startTime", startTime));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("orgCode", orgCode));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("deptCode", deptCode));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("deptName", deptName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorCode", doctorCode));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorName", doctorName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patientPhone", patientPhone));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 String data = jsonObject.getString("data");
 | 
	
		
			
				|  |  |                 if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
 | 
	
		
			
				|  |  |                     throw new ServiceException(doMsg(data));
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     re = data;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException(doMsg(jsonObject.getString("msg")));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new ServiceException("预约失败,请稍后再试!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //返回挂号单
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 处理异常
 | 
	
		
			
				|  |  |      * @param msg
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String doMsg(String msg){
 | 
	
		
			
				|  |  |         if(StringUtils.isNoneBlank(msg)&&msg.lastIndexOf(":")>0){
 | 
	
		
			
				|  |  |             String re = "市民健康系统提示" + msg.substring(msg.lastIndexOf(":"));
 | 
	
		
			
				|  |  |             return re;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return msg;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医院列表
 | 
	
		
			
				|  |  |      * @param type
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetOrgList(String type) throws Exception{
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetOrgList";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("type", type));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 从数据中获取科室
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @param name
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<ReservationHospitalDept> GetOrgDepListToMysql(String hospitalId, String name) throws Exception{
 | 
	
		
			
				|  |  |         StringBuffer buffer = new StringBuffer();
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(name)){
 | 
	
		
			
				|  |  |             buffer.append(" and rh.name like '%"+name+"%'");
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             buffer.append("");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "select *  from wlyy_reservation_hospital_dept rh where 1=1 "+buffer;
 | 
	
		
			
				|  |  |         List<ReservationHospitalDept> reservationHospitals = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ReservationHospitalDept.class));
 | 
	
		
			
				|  |  |         return reservationHospitals;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取科室接口
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetOrgDepList(String hospitalId) throws Exception{
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetOrgDepList";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生列表接口
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetDoctorList(String hospitalId,String hosDeptId) throws Exception{
 | 
	
		
			
				|  |  |         if(isdemo){
 | 
	
		
			
				|  |  |             return "{\n" +
 | 
	
		
			
				|  |  |                     "  \"status\": 200,\n" +
 | 
	
		
			
				|  |  |                     "  \"msg\": \"获取医生列表成功!\",\n" +
 | 
	
		
			
				|  |  |                     "  \"data\": [\n" +
 | 
	
		
			
				|  |  |                     "    {\n" +
 | 
	
		
			
				|  |  |                     "      \"id\": \"259724\",\n" +
 | 
	
		
			
				|  |  |                     "      \"name\": \"陈水龙\",\n" +
 | 
	
		
			
				|  |  |                     "      \"sex\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "      \"title\": \"主任医师\",\n" +
 | 
	
		
			
				|  |  |                     "      \"edu\": \"硕士\",\n" +
 | 
	
		
			
				|  |  |                     "      \"introduce\": \"主任医师、硕士,毕业于福建医科大学。现任科教部副主任,心内二科医疗组长。\\r\\n从事心血管内科临床及教学工作20余年,积累了丰富的临床工作经验。擅长高血压、冠心病、心力衰竭的临床诊治工作,在高血压的诊治方面有独到的造诣。\",\n" +
 | 
	
		
			
				|  |  |                     "      \"photo\": \"\",\n" +
 | 
	
		
			
				|  |  |                     "      \"fee\": null,\n" +
 | 
	
		
			
				|  |  |                     "      \"hosDeptId\": \"30100\",\n" +
 | 
	
		
			
				|  |  |                     "      \"hosDeptName\": \"心内科门诊\",\n" +
 | 
	
		
			
				|  |  |                     "      \"hospitalId\": \"350211A1002\",\n" +
 | 
	
		
			
				|  |  |                     "      \"hospitalName\": \"马銮湾医院\"\n" +
 | 
	
		
			
				|  |  |                     "    },\n" +
 | 
	
		
			
				|  |  |                     "    {\n" +
 | 
	
		
			
				|  |  |                     "      \"id\": \"259726\",\n" +
 | 
	
		
			
				|  |  |                     "      \"name\": \"王斌\",\n" +
 | 
	
		
			
				|  |  |                     "      \"sex\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "      \"title\": \"主任医师\",\n" +
 | 
	
		
			
				|  |  |                     "      \"edu\": \"博士\",\n" +
 | 
	
		
			
				|  |  |                     "      \"introduce\": \"主任医师、博士,毕业于四川大学华西临床医学院。现任急诊科主任。\\r\\n主要从事心血管内科临床、冠脉介入、瓣膜性心脏病微创介入及胸痛中心建设、维护及认证工作。\",\n" +
 | 
	
		
			
				|  |  |                     "      \"photo\": \"\",\n" +
 | 
	
		
			
				|  |  |                     "      \"fee\": null,\n" +
 | 
	
		
			
				|  |  |                     "      \"hosDeptId\": \"30100\",\n" +
 | 
	
		
			
				|  |  |                     "      \"hosDeptName\": \"心内科门诊\",\n" +
 | 
	
		
			
				|  |  |                     "      \"hospitalId\": \"350211A1002\",\n" +
 | 
	
		
			
				|  |  |                     "      \"hospitalName\": \"马銮湾医院\"\n" +
 | 
	
		
			
				|  |  |                     "    }\n" +
 | 
	
		
			
				|  |  |                     "  ]\n" +
 | 
	
		
			
				|  |  |                     "}";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetDoctorList";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生排班接口(包含排班详细)
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetDoctorArrange(String hospitalId,String hosDeptId,String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         if(isdemo){
 | 
	
		
			
				|  |  |             return "{\n" +
 | 
	
		
			
				|  |  |                     "  \"status\": 200,\n" +
 | 
	
		
			
				|  |  |                     "  \"message\": \"获取医生排班成功!\",\n" +
 | 
	
		
			
				|  |  |                     "  \"data\": [\n" +
 | 
	
		
			
				|  |  |                     "    {\n" +
 | 
	
		
			
				|  |  |                     "      \"date\": \"2022/12/23 0:00:00\",\n" +
 | 
	
		
			
				|  |  |                     "      \"max\": \"28\",\n" +
 | 
	
		
			
				|  |  |                     "      \"fee\": \"50\",\n" +
 | 
	
		
			
				|  |  |                     "      \"time\": \"a\",\n" +
 | 
	
		
			
				|  |  |                     "      \"used\": \"14\",\n" +
 | 
	
		
			
				|  |  |                     "      \"regType\": \"主任号\",\n" +
 | 
	
		
			
				|  |  |                     "      \"sections\": [\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 8:34:40\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 8:42:00\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 8:42:00\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 8:49:20\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 8:49:20\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 8:56:40\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 9:26:00\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 9:33:20\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 9:48:00\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 9:55:20\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 9:55:20\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 10:02:40\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 10:17:20\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 10:24:40\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 10:54:00\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:01:20\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 11:01:20\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:08:40\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 11:08:40\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:16:00\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 11:16:00\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:23:20\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 11:23:20\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:30:40\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 11:30:40\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:38:00\"\n" +
 | 
	
		
			
				|  |  |                     "        },\n" +
 | 
	
		
			
				|  |  |                     "        {\n" +
 | 
	
		
			
				|  |  |                     "          \"max\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "          \"startTime\": \"2022/12/23 11:38:00\",\n" +
 | 
	
		
			
				|  |  |                     "          \"used\": \"0\",\n" +
 | 
	
		
			
				|  |  |                     "          \"endTime\": \"2022/12/23 11:45:20\"\n" +
 | 
	
		
			
				|  |  |                     "        }\n" +
 | 
	
		
			
				|  |  |                     "      ],\n" +
 | 
	
		
			
				|  |  |                     "      \"status\": \"1\"\n" +
 | 
	
		
			
				|  |  |                     "    }\n" +
 | 
	
		
			
				|  |  |                     "  ]\n" +
 | 
	
		
			
				|  |  |                     "}";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetDoctorArrange";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorId", doctorId));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生排班接口(一级)
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetDoctorArrangeSimple(String hospitalId,String hosDeptId,String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetDoctorArrangeSimple";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorId", doctorId));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Resource
 | 
	
		
			
				|  |  |     private PatientReservationDao patientReservationDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 创建挂号单
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,
 | 
	
		
			
				|  |  |                                String doctorId,String doctorName,String arrangeDate,String patient,
 | 
	
		
			
				|  |  |                                String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
 | 
	
		
			
				|  |  |         if(isdemo){
 | 
	
		
			
				|  |  |             String code = UUID.randomUUID().toString().replace("-","");
 | 
	
		
			
				|  |  |             PatientReservation reservation = new PatientReservation();
 | 
	
		
			
				|  |  |             reservation.setCode(code);
 | 
	
		
			
				|  |  |             reservation.setCzrq(new Date());
 | 
	
		
			
				|  |  |             reservation.setType("1");
 | 
	
		
			
				|  |  |             reservation.setOrgCode(hospitalId);
 | 
	
		
			
				|  |  |             reservation.setOrgName(hospitalName);
 | 
	
		
			
				|  |  |             reservation.setDeptCode(hosDeptId);
 | 
	
		
			
				|  |  |             reservation.setDeptName(hosDeptName);
 | 
	
		
			
				|  |  |             reservation.setDoctorCode(doctorId);
 | 
	
		
			
				|  |  |             reservation.setDoctorName(doctorName);
 | 
	
		
			
				|  |  |             reservation.setDoctorJob("主任医师");
 | 
	
		
			
				|  |  |             reservation.setDoctorPhoto("");
 | 
	
		
			
				|  |  |             reservation.setIdcard(cardNo);
 | 
	
		
			
				|  |  |             reservation.setName(patientName);
 | 
	
		
			
				|  |  |             reservation.setPatient(patient);
 | 
	
		
			
				|  |  |             reservation.setPhone(patientPhone);
 | 
	
		
			
				|  |  |             reservation.setSectionType("a");
 | 
	
		
			
				|  |  |             reservation.setSsc(clinicCard);
 | 
	
		
			
				|  |  |             reservation.setStartTime(DateUtil.strToDate("2022-12-23 10:00:00"));
 | 
	
		
			
				|  |  |             reservation.setEndTime(DateUtil.strToDate("2022-12-23 10:40:00"));
 | 
	
		
			
				|  |  |             reservation.setStatus(1);
 | 
	
		
			
				|  |  |             patientReservationDao.save(reservation);
 | 
	
		
			
				|  |  |             return code;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String re = "";
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/CreateOrder";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalName", hospitalName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptName", hosDeptName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorId", doctorId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorName", doctorName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("arrangeDate", arrangeDate));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patient", patient));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patientName", patientName));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("cardNo", cardNo));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("clinicCard", clinicCard));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patientPhone", patientPhone));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 re = jsonObject.getString("data");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 String msg = "处理失败,请联系管理员";
 | 
	
		
			
				|  |  |                 if(!jsonObject.isNull("msg")){
 | 
	
		
			
				|  |  |                     msg = jsonObject.getString("msg");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 throw new ServiceException(doMsg(msg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 取消挂号单
 | 
	
		
			
				|  |  |      * @param orderId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean CancelOrder(String orderId,String clinicCard) throws Exception{
 | 
	
		
			
				|  |  |         if(isdemo){
 | 
	
		
			
				|  |  |             return true;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         boolean re = false;
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/CancelOrder";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("orderId", orderId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("clinicCard", clinicCard));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 re = jsonObject.getBoolean("data");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 String msg = "处理失败,请联系管理员";
 | 
	
		
			
				|  |  |                 if(!jsonObject.isNull("msg")){
 | 
	
		
			
				|  |  |                     msg = jsonObject.getString("msg");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 throw new ServiceException(msg);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new ServiceException("取消挂号单失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生信息
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetDoctorInfo(String hospitalId,String hosDeptId,String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         String re = "";
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetDoctorInfo";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorId", doctorId));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生信息
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @param hosDeptId
 | 
	
		
			
				|  |  |      * @param doctorId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public GuahaoDoctor getGuahaoDoctor(String hospitalId, String hosDeptId, String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         String response = GetDoctorInfo(hospitalId,hosDeptId,doctorId);
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 GuahaoDoctor doctor = new GuahaoDoctor();
 | 
	
		
			
				|  |  |                 JSONObject json = jsonObject.getJSONObject("data");
 | 
	
		
			
				|  |  |                 doctor.setId(json.isNull("id")?"":json.getString("id"));//医生编码
 | 
	
		
			
				|  |  |                 doctor.setName(json.isNull("name")?"":json.getString("name"));//医生姓名
 | 
	
		
			
				|  |  |                 doctor.setSex(json.isNull("sex")?"":json.getString("sex"));//医生性别
 | 
	
		
			
				|  |  |                 doctor.setTitle(json.isNull("title")?"":json.getString("title"));//医生职称
 | 
	
		
			
				|  |  |                 doctor.setEdu(json.isNull("edu")?"":json.getString("edu"));//医生学历
 | 
	
		
			
				|  |  |                 doctor.setIntroduce(json.isNull("introduce")?"":json.getString("introduce"));//医生简介
 | 
	
		
			
				|  |  |                 doctor.setPhoto(json.isNull("photo")?"":json.getString("photo"));//医生头像
 | 
	
		
			
				|  |  |                 doctor.setFee(json.isNull("fee")?"":json.getString("fee"));//医生挂号费
 | 
	
		
			
				|  |  |                 doctor.setHosDeptId(json.isNull("hosDeptId")?"":json.getString("hosDeptId"));//医生科室编码
 | 
	
		
			
				|  |  |                 doctor.setHosDeptName(json.isNull("hosDeptName")?"":json.getString("hosDeptName"));//医生科室名称
 | 
	
		
			
				|  |  |                 doctor.setHospitalId(json.isNull("hospitalId")?"":json.getString("hospitalId"));//医生医院编码
 | 
	
		
			
				|  |  |                 doctor.setHospitalName(json.isNull("hospitalName")?"":json.getString("hospitalName"));//医生医院名称
 | 
	
		
			
				|  |  |                 return doctor;
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 String msg = "处理失败,请联系管理员";
 | 
	
		
			
				|  |  |                 if(!jsonObject.isNull("msg")){
 | 
	
		
			
				|  |  |                     msg = jsonObject.getString("msg");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 throw new ServiceException(msg);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new ServiceException("获取挂号医生信息失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取预约状态(0 撤销 1 确认 2 已诊  3停诊)
 | 
	
		
			
				|  |  |      * @param hospitalId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Integer GetOrderStatus(String hospitalId,String hosDeptId,String doctorId) throws Exception{
 | 
	
		
			
				|  |  |         Integer re = null;
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetOrderStatus";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hospitalId", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("doctorId", doctorId));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = jsonObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 re = jsonObject.getInt("data");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据患者医保卡获取近三个月的预约记录
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetRegList(String patient) throws Exception{
 | 
	
		
			
				|  |  |         if(isdemo){
 | 
	
		
			
				|  |  |             List<PatientReservation> list = patientReservationDao.findByPatientAndStartTime(patient,DateUtil.getNextDay1(new Date(),-90),DateUtil.getNextDay1(new Date(),31));
 | 
	
		
			
				|  |  |             JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  |             json.put("status",200);
 | 
	
		
			
				|  |  |             json.put("message","获取成功");
 | 
	
		
			
				|  |  |             json.put("data",new JSONArray(list));
 | 
	
		
			
				|  |  |             return json.toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetRegList";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patient", patient));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据患者,预约编号,机构编号获取单条记录预约记录
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String GetRegDetail(String patient,String orgCode,String regCode) throws Exception{
 | 
	
		
			
				|  |  |         String re = "";
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/guahao/GetRegDetail";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("patient", patient));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("orgCode", orgCode));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("regCode", regCode));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /*************************************** 旧版本函数 *************************************************************************/
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取住院记录(X)
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getHospitalizationRecord(String strSSID, String startNum, String endNum) throws Exception {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  | //            return ehrService.getHospitalizationRecord(strSSID);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String startDate = "1900-01-01";
 | 
	
		
			
				|  |  |             String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/InpatientRecord";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("startDate", startDate));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("endDate", endDate));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("startNum", startNum));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("endNum", endNum));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             JSONArray resultArray = new JSONArray();
 | 
	
		
			
				|  |  |             List<WlyyHospitalSysDictDO> systemDictList = hospitalSysDictDao.findByDictName("EHR_CATALOG");
 | 
	
		
			
				|  |  |             Map<String, String> systemDictMap = new HashMap<>();
 | 
	
		
			
				|  |  |             for (WlyyHospitalSysDictDO systemDict : systemDictList) {
 | 
	
		
			
				|  |  |                 systemDictMap.put(systemDict.getDictCode(), systemDict.getDictValue());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject responseObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = responseObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     String data = responseObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data)) {
 | 
	
		
			
				|  |  |                         if (data.startsWith("error")) {
 | 
	
		
			
				|  |  |                             return data;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  |                         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 endTimeNew = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                 String catalogValue = systemDictMap.get(catalogCode);
 | 
	
		
			
				|  |  |                                 jsonObject.remove("CATALOG_CODE");
 | 
	
		
			
				|  |  |                                 if (jsonObjectMap.containsKey(key)) {
 | 
	
		
			
				|  |  |                                     jsonObject = jsonObjectMap.get(key);
 | 
	
		
			
				|  |  |                                     String endTimeOld = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     if (endTimeNew.compareTo(endTimeOld) < 0) {
 | 
	
		
			
				|  |  |                                         endTimeNew = endTimeOld;
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                     catalogObject = jsonObject.getJSONObject("CATALOG");
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 catalogObject.put(catalogCode, catalogValue);
 | 
	
		
			
				|  |  |                                 jsonObject.put("CATALOG", catalogObject);
 | 
	
		
			
				|  |  |                                 jsonObject.put("END_TIME", endTimeNew);
 | 
	
		
			
				|  |  |                                 jsonObjectMap.put(key, jsonObject);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             for (String key : jsonObjectMap.keySet()) {
 | 
	
		
			
				|  |  |                                 resultArray.put(jsonObjectMap.get(key));
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             JSONObject temp;
 | 
	
		
			
				|  |  |                             for (int i = 0; i < resultArray.length(); i++) {
 | 
	
		
			
				|  |  |                                 for (int j = i + 1; j < resultArray.length(); j++) {
 | 
	
		
			
				|  |  |                                     String endTimeNew = resultArray.getJSONObject(j).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     String endTimeOld = resultArray.getJSONObject(i).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     if (endTimeNew.compareTo(endTimeOld) > 0) {
 | 
	
		
			
				|  |  |                                         temp = resultArray.getJSONObject(i);
 | 
	
		
			
				|  |  |                                         resultArray.put(i, resultArray.getJSONObject(j));
 | 
	
		
			
				|  |  |                                         resultArray.put(j, temp);  // 两个数交换位置
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return resultArray.toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取门/急诊记录(X)
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getOutpatientRecord(String strSSID, String startNum, String endNum) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  | //            return ehrService.getOutpatientRecord(strSSID);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else{
 | 
	
		
			
				|  |  |             String startDate = "1900-01-01";
 | 
	
		
			
				|  |  |             String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/OutpatientRecord";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("startDate", startDate));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("endDate", endDate));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("startNum", startNum));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("endNum", endNum));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             JSONArray resultArray = new JSONArray();
 | 
	
		
			
				|  |  |             List<WlyyHospitalSysDictDO> systemDictList = hospitalSysDictDao.findByDictName("EHR_CATALOG");
 | 
	
		
			
				|  |  |             Map<String, String> systemDictMap = new HashMap<>();
 | 
	
		
			
				|  |  |             for (WlyyHospitalSysDictDO systemDict : systemDictList) {
 | 
	
		
			
				|  |  |                 systemDictMap.put(systemDict.getDictCode(), systemDict.getDictValue());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)){
 | 
	
		
			
				|  |  |                 JSONObject responseObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = responseObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200){
 | 
	
		
			
				|  |  |                     String data = responseObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data)){
 | 
	
		
			
				|  |  |                         if (data.startsWith("error")) {
 | 
	
		
			
				|  |  |                             return data;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  |                         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 endTimeNew = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                 String catalogValue = systemDictMap.get(catalogCode);
 | 
	
		
			
				|  |  |                                 jsonObject.remove("CATALOG_CODE");
 | 
	
		
			
				|  |  |                                 if (jsonObjectMap.containsKey(key)) {
 | 
	
		
			
				|  |  |                                     jsonObject = jsonObjectMap.get(key);
 | 
	
		
			
				|  |  |                                     String endTimeOld = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     if (endTimeNew.compareTo(endTimeOld) < 0) {
 | 
	
		
			
				|  |  |                                         endTimeNew = endTimeOld;
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                     catalogObject = jsonObject.getJSONObject("CATALOG");
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 catalogObject.put(catalogCode, catalogValue);
 | 
	
		
			
				|  |  |                                 jsonObject.put("CATALOG", catalogObject);
 | 
	
		
			
				|  |  |                                 jsonObject.put("END_TIME", endTimeNew);
 | 
	
		
			
				|  |  |                                 jsonObjectMap.put(key, jsonObject);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             for (String key : jsonObjectMap.keySet()) {
 | 
	
		
			
				|  |  |                                 resultArray.put(jsonObjectMap.get(key));
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             JSONObject temp;
 | 
	
		
			
				|  |  |                             for (int i = 0; i < resultArray.length(); i++) {
 | 
	
		
			
				|  |  |                                 for (int j = i+1; j < resultArray.length(); j++) {
 | 
	
		
			
				|  |  |                                     String endTimeNew = resultArray.getJSONObject(j).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     String endTimeOld = resultArray.getJSONObject(i).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     if (endTimeNew.compareTo(endTimeOld) > 0) {
 | 
	
		
			
				|  |  |                                         temp = resultArray.getJSONObject(i);
 | 
	
		
			
				|  |  |                                         resultArray.put(i, resultArray.getJSONObject(j));
 | 
	
		
			
				|  |  |                                         resultArray.put(j, temp);  // 两个数交换位置
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return resultArray.toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取检查报告信息 (X)
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     private JSONArray getChecking(String strSSID, String startNum, String endNum) throws Exception {
 | 
	
		
			
				|  |  |         String api = "/third/smjk/ExamReport";
 | 
	
		
			
				|  |  |         return getResult(api, strSSID, startNum, endNum);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取检验报告信息(X)
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     private JSONArray getInspection(String strSSID, String startNum, String endNum) throws Exception {
 | 
	
		
			
				|  |  |         String api = "/third/smjk/LabReport";
 | 
	
		
			
				|  |  |         return getResult(api, strSSID, startNum, endNum);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private JSONArray getResult(String api, String strSSID, String startNum, String endNum) {
 | 
	
		
			
				|  |  |         String startDate = "1900-01-01";
 | 
	
		
			
				|  |  |         String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
 | 
	
		
			
				|  |  |         String url = jwUrl + api;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("startDate", startDate));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("endDate", endDate));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("startNum", startNum));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("endNum", endNum));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         JSONArray resultArray = new JSONArray();
 | 
	
		
			
				|  |  |         List<WlyyHospitalSysDictDO> systemDictList = hospitalSysDictDao.findByDictName("EHR_CATALOG");
 | 
	
		
			
				|  |  |         Map<String, String> systemDictMap = new HashMap<>();
 | 
	
		
			
				|  |  |         for (WlyyHospitalSysDictDO systemDict : systemDictList) {
 | 
	
		
			
				|  |  |             systemDictMap.put(systemDict.getDictCode(), systemDict.getDictValue());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(response)){
 | 
	
		
			
				|  |  |             JSONObject responseObject = new JSONObject(response);
 | 
	
		
			
				|  |  |             int status = responseObject.getInt("status");
 | 
	
		
			
				|  |  |             if (status == 200){
 | 
	
		
			
				|  |  |                 String data = responseObject.getString("data");
 | 
	
		
			
				|  |  |                 if (!StringUtils.isEmpty(data)){
 | 
	
		
			
				|  |  |                     if (data.startsWith("error")) {
 | 
	
		
			
				|  |  |                         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |                         jsonObject.put("error", data);
 | 
	
		
			
				|  |  |                         resultArray.put(jsonObject);
 | 
	
		
			
				|  |  |                         return resultArray ;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  |                     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 endTimeNew = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                             String catalogValue = systemDictMap.get(catalogCode);
 | 
	
		
			
				|  |  |                             jsonObject.remove("CATALOG_CODE");
 | 
	
		
			
				|  |  |                             if (jsonObjectMap.containsKey(key)) {
 | 
	
		
			
				|  |  |                                 jsonObject = jsonObjectMap.get(key);
 | 
	
		
			
				|  |  |                                 String endTimeOld = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                 if (endTimeNew.compareTo(endTimeOld) < 0) {
 | 
	
		
			
				|  |  |                                     endTimeNew = endTimeOld;
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 catalogObject = jsonObject.getJSONObject("CATALOG");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                             catalogObject.put(catalogCode, catalogValue);
 | 
	
		
			
				|  |  |                             jsonObject.put("CATALOG", catalogObject);
 | 
	
		
			
				|  |  |                             jsonObject.put("END_TIME", endTimeNew);
 | 
	
		
			
				|  |  |                             jsonObjectMap.put(key, jsonObject);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         for (String key : jsonObjectMap.keySet()) {
 | 
	
		
			
				|  |  |                             resultArray.put(jsonObjectMap.get(key));
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return resultArray;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取检查检验 信息(X)
 | 
	
		
			
				|  |  |      * @param strSSID
 | 
	
		
			
				|  |  |      * @param startNum
 | 
	
		
			
				|  |  |      * @param endNum
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getInspectionAndChecking(String strSSID, String startNum, String endNum) throws Exception {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  | //            return ehrService.getInspectionAndChecking(strSSID);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             JSONArray total = new JSONArray();
 | 
	
		
			
				|  |  |             JSONArray check = getChecking(strSSID, startNum, endNum);
 | 
	
		
			
				|  |  |             if (!check.isNull(0)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = check.getJSONObject(0);
 | 
	
		
			
				|  |  |                 if (jsonObject.has("error")) {
 | 
	
		
			
				|  |  |                     return jsonObject.get("error").toString();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONArray inspect = getInspection(strSSID, startNum, endNum);
 | 
	
		
			
				|  |  |             if (!inspect.isNull(0)) {
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = inspect.getJSONObject(0);
 | 
	
		
			
				|  |  |                 if (jsonObject.has("error")) {
 | 
	
		
			
				|  |  |                     return jsonObject.get("error").toString();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //TODO 检查检验数据合并
 | 
	
		
			
				|  |  |             for (int i = 0; i < check.length(); i++) {
 | 
	
		
			
				|  |  |                 total.put(check.getJSONObject(i));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             for (int i = 0; i < inspect.length(); i++) {
 | 
	
		
			
				|  |  |                 total.put(inspect.getJSONObject(i));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject temp;
 | 
	
		
			
				|  |  |             for (int i = 0; i < total.length(); i++) {
 | 
	
		
			
				|  |  |                 for (int j = i + 1; j < total.length(); j++) {
 | 
	
		
			
				|  |  |                     String endTimeNew = total.getJSONObject(j).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                     String endTimeOld = total.getJSONObject(i).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                     if (endTimeNew.compareTo(endTimeOld) > 0) {
 | 
	
		
			
				|  |  |                         temp = total.getJSONObject(i);
 | 
	
		
			
				|  |  |                         total.put(i, total.getJSONObject(j));
 | 
	
		
			
				|  |  |                         total.put(j, temp);  // 两个数交换位置
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return total.toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取用药记录(X)
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getDrugsList(String strSSID, String startNum,String endNum) throws Exception {
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  | //            return ehrService.getDrugsList(strSSID);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String startDate = "1900-01-01";
 | 
	
		
			
				|  |  |             String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/DrugsList";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", strSSID));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("startDate", startDate));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("endDate", endDate));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("startNum", startNum));
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("endNum", endNum));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |             JSONArray resultArray = new JSONArray();
 | 
	
		
			
				|  |  |             List<WlyyHospitalSysDictDO> systemDictList = hospitalSysDictDao.findByDictName("EHR_CATALOG");
 | 
	
		
			
				|  |  |             Map<String, String> systemDictMap = new HashMap<>();
 | 
	
		
			
				|  |  |             for (WlyyHospitalSysDictDO systemDict : systemDictList) {
 | 
	
		
			
				|  |  |                 systemDictMap.put(systemDict.getDictCode(), systemDict.getDictValue());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject responseObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = responseObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     String data = responseObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data)) {
 | 
	
		
			
				|  |  |                         if (data.startsWith("error")) {
 | 
	
		
			
				|  |  |                             return data;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  |                         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 endTimeNew = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                 String catalogValue = systemDictMap.get(catalogCode);
 | 
	
		
			
				|  |  |                                 jsonObject.remove("CATALOG_CODE");
 | 
	
		
			
				|  |  |                                 if (jsonObjectMap.containsKey(key)) {
 | 
	
		
			
				|  |  |                                     jsonObject = jsonObjectMap.get(key);
 | 
	
		
			
				|  |  |                                     String endTimeOld = jsonObject.get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     if (endTimeNew.compareTo(endTimeOld) < 0) {
 | 
	
		
			
				|  |  |                                         endTimeNew = endTimeOld;
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                     catalogObject = jsonObject.getJSONObject("CATALOG");
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 catalogObject.put(catalogCode, catalogValue);
 | 
	
		
			
				|  |  |                                 jsonObject.put("CATALOG", catalogObject);
 | 
	
		
			
				|  |  |                                 jsonObject.put("END_TIME", endTimeNew);
 | 
	
		
			
				|  |  |                                 jsonObjectMap.put(key, jsonObject);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             for (String key : jsonObjectMap.keySet()) {
 | 
	
		
			
				|  |  |                                 resultArray.put(jsonObjectMap.get(key));
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             JSONObject temp;
 | 
	
		
			
				|  |  |                             for (int i = 0; i < resultArray.length(); i++) {
 | 
	
		
			
				|  |  |                                 for (int j = i + 1; j < resultArray.length(); j++) {
 | 
	
		
			
				|  |  |                                     String endTimeNew = resultArray.getJSONObject(j).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     String endTimeOld = resultArray.getJSONObject(i).get("END_TIME").toString();
 | 
	
		
			
				|  |  |                                     if (endTimeNew.compareTo(endTimeOld) > 0) {
 | 
	
		
			
				|  |  |                                         temp = resultArray.getJSONObject(i);
 | 
	
		
			
				|  |  |                                         resultArray.put(i, resultArray.getJSONObject(j));
 | 
	
		
			
				|  |  |                                         resultArray.put(j, temp);  // 两个数交换位置
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return resultArray.toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public JSONObject GetDoctorInfoTen(String hospitalId, String hosDeptId, String doctorId) {
 | 
	
		
			
				|  |  |         if(isdemo){
 | 
	
		
			
				|  |  |             String tmp = "{\n" +
 | 
	
		
			
				|  |  |                     "  \"message\": \"获取医生详细信息成功!\",\n" +
 | 
	
		
			
				|  |  |                     "  \"data\": {\n" +
 | 
	
		
			
				|  |  |                     "    \"hosDeptId\": \"30100\",\n" +
 | 
	
		
			
				|  |  |                     "    \"hospitalId\": \"350211A1002\",\n" +
 | 
	
		
			
				|  |  |                     "    \"introduce\": \"主任医师、硕士,毕业于福建医科大学。现任科教部副主任,心内二科医疗组长。\\r\\n从事心血管内科临床及教学工作20余年,积累了丰富的临床工作经验。擅长高血压、冠心病、心力衰竭的临床诊治工作,在高血压的诊治方面有独到的造诣。\",\n" +
 | 
	
		
			
				|  |  |                     "    \"hosDeptName\": \"心内科门诊\",\n" +
 | 
	
		
			
				|  |  |                     "    \"sex\": \"1\",\n" +
 | 
	
		
			
				|  |  |                     "    \"edu\": \"硕士\",\n" +
 | 
	
		
			
				|  |  |                     "    \"fee\": null,\n" +
 | 
	
		
			
				|  |  |                     "    \"name\": \"陈水龙\",\n" +
 | 
	
		
			
				|  |  |                     "    \"photo\": \"\",\n" +
 | 
	
		
			
				|  |  |                     "    \"id\": \"259724\",\n" +
 | 
	
		
			
				|  |  |                     "    \"hospitalName\": \"马銮湾医院\",\n" +
 | 
	
		
			
				|  |  |                     "    \"title\": \"主任医师\"\n" +
 | 
	
		
			
				|  |  |                     "  },\n" +
 | 
	
		
			
				|  |  |                     "  \"status\": 200\n" +
 | 
	
		
			
				|  |  |                     "}";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return new JSONObject(tmp);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String url = jwUrl + "/third/smjk/RegDeptSpeDoctorList";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //当前时间;
 | 
	
		
			
				|  |  |         String strStart = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |         //10天预约
 | 
	
		
			
				|  |  |         String strEnd = DateUtil.getNextDay(strStart, 11);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("orgCode", hospitalId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("deptCode", hosDeptId));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("strStart", strStart));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("strEnd", strEnd));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         JSONObject jsonData = new JSONObject(response);
 | 
	
		
			
				|  |  |         JSONArray  jsonArray = jsonData.getJSONArray("data");
 | 
	
		
			
				|  |  |         for (int i=0; i<jsonArray.length(); i++) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject jsonObject = jsonArray.getJSONObject(i);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(doctorId.equals(jsonObject.getString("id"))){
 | 
	
		
			
				|  |  |                 return jsonObject;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取市民健康系统居民基本信息
 | 
	
		
			
				|  |  |      * @param ssc
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getSmjkBaseInfo(String ssc)throws Exception{
 | 
	
		
			
				|  |  |         if(isdemo)     //演示环境
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             return "";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |             String re = "";
 | 
	
		
			
				|  |  |             String url = jwUrl + "/third/smjk/getXmanInfo";
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("strSSID", ssc));
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(response)) {
 | 
	
		
			
				|  |  |                 JSONObject responseObject = new JSONObject(response);
 | 
	
		
			
				|  |  |                 int status = responseObject.getInt("status");
 | 
	
		
			
				|  |  |                 if (status == 200) {
 | 
	
		
			
				|  |  |                     String data = responseObject.getString("data");
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
 | 
	
		
			
				|  |  |                         throw new ServiceException(data);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  | //                        JSONObject jsonData = new JSONObject(data);
 | 
	
		
			
				|  |  | //                        JSONArray jsonArray = jsonData.getJSONArray("EventList");
 | 
	
		
			
				|  |  |                         re = data;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     throw new ServiceException(responseObject.getString("msg"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 throw new ServiceException("null response.");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |             if(re.contains("[{}]"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 re = re.replace("[{}]","[]");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |             return re;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |