|
@ -2,6 +2,8 @@ package com.yihu.wlyy.service.app.record;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.system.SystemDictService;
|
|
import com.yihu.wlyy.service.system.SystemDictService;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
@ -34,91 +36,101 @@ public class OutpatientService extends BaseService {
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
EhrService ehrService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取门/急诊记录
|
|
* 获取门/急诊记录
|
|
*/
|
|
*/
|
|
public String getOutpatientRecord(String strSSID, String startNum, String endNum) {
|
|
public String getOutpatientRecord(String strSSID, String startNum, String endNum) {
|
|
|
|
|
|
String startDate = "1900-01-01";
|
|
|
|
String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
|
|
|
|
String url = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
|
|
|
|
url = url + "/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<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
|
|
|
|
Map<String, String> systemDictMap = new HashMap<>();
|
|
|
|
for (SystemDict systemDict : systemDictList) {
|
|
|
|
systemDictMap.put(systemDict.getCode(), systemDict.getValue());
|
|
|
|
|
|
if(SystemConf.getInstance().getEhrUsed()) //演示环境
|
|
|
|
{
|
|
|
|
return ehrService.getOutpatientRecord(strSSID);
|
|
}
|
|
}
|
|
|
|
else{
|
|
|
|
String startDate = "1900-01-01";
|
|
|
|
String endDate = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD);
|
|
|
|
String url = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
|
|
|
|
url = url + "/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<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
|
|
|
|
Map<String, String> systemDictMap = new HashMap<>();
|
|
|
|
for (SystemDict systemDict : systemDictList) {
|
|
|
|
systemDictMap.put(systemDict.getCode(), systemDict.getValue());
|
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isEmpty(response)){
|
|
|
|
JSONObject 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;
|
|
|
|
|
|
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 = jsonObject.getJSONObject("CATALOG");
|
|
|
|
|
|
catalogObject.put(catalogCode, catalogValue);
|
|
|
|
jsonObject.put("CATALOG", catalogObject);
|
|
|
|
jsonObject.put("END_TIME", endTimeNew);
|
|
|
|
jsonObjectMap.put(key, jsonObject);
|
|
}
|
|
}
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
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); // 两个数交换位置
|
|
|
|
|
|
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();
|
|
|
|
|
|
return resultArray.toString();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|