Sfoglia il codice sorgente

调用健康档案转接服务

zhenglingfeng 8 anni fa
parent
commit
d17d27c7da

+ 48 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/record/OutpatientService.java

@ -1,6 +1,10 @@
package com.yihu.wlyy.service.app.record;
import com.google.common.annotations.VisibleForTesting;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
@ -8,11 +12,13 @@ import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by zhenglingfeng on 2016/10/17.
@ -20,11 +26,15 @@ import java.util.List;
@Service
public class OutpatientService extends BaseService {
    @Autowired
    SystemDictService systemDictService;
    /**
     * 获取门/急诊记录
     */
    public String getOutpatientRecord(String strSSID, String startDate, String endDate, 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";
@ -36,20 +46,50 @@ public class OutpatientService extends BaseService {
        params.add(new BasicNameValuePair("endNum", endNum));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONArray result = new JSONArray();
        JSONArray resultArray = new JSONArray();
        List<SystemDict> systemDictList = systemDictService.getDictByDictName("EHR_CATALOG");
        Map<String, String> systemDictMap = new HashMap<>();
        for (SystemDict systemDict : systemDictList) {
            systemDictMap.put(systemDict.getCode(), systemDict.getValue());
        }
        if (!StringUtils.isEmpty(response)){
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            if (status == 200){
                String data = jsonObject.getString("data");
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data)){
                    JSONObject jsonData = new JSONObject(data);
                    result = jsonData.getJSONArray("EhrList");
                    JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                    if (!jsonArray.isNull(0) && jsonArray.getJSONObject(0).length() != 0) {
                        Map<String, JSONObject> jsonObjectMap = new HashMap<>();
                        for (int i=0; i<jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            String patientId = jsonObject.getString("XMAN_ID");
                            String eventNo = jsonObject.getString("EVENT");
                            Integer orgId = jsonObject.getInt("ORG_ID");
                            String key = patientId + eventNo + orgId;
                            JSONObject catalogObject = new JSONObject();
                            String catalogCode = jsonObject.get("CATALOG_CODE").toString();
                            String catalogValue = systemDictMap.get(catalogCode);
                            jsonObject.remove("CATALOG_CODE");
                            if (jsonObjectMap.containsKey(key)) {
                                jsonObject = jsonObjectMap.get(key);
                                catalogObject = jsonObject.getJSONObject("CATALOG");
                            }
                            catalogObject.put(catalogCode, catalogValue);
                            jsonObject.put("CATALOG", catalogObject);
                            jsonObjectMap.put(key, jsonObject);
                        }
                        for (String key : jsonObjectMap.keySet()) {
                            resultArray.put(jsonObjectMap.get(key));
                        }
                    }
                }
            }
        }
        return result.toString();
        return resultArray.toString();
    }
}

+ 2 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/record/OutpatientController.java

@ -31,19 +31,14 @@ public class OutpatientController extends BaseController {
    @ApiOperation("获取门/急诊数据")
    @RequestMapping(value = "/outpatient", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getOutpatientRecord(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "A20140513123")
    public String getOutpatientRecord(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "B09036263193")
                      @RequestParam(value="strSSID",required = true) String strSSID,
                      @ApiParam(name="startDate",value="查询的开始日期",defaultValue = "2015-01-01")
                      @RequestParam(value="startDate",required = true) String startDate,
                      @ApiParam(name="endDate",value="查询的结束日期",defaultValue = "2016-10-01")
                      @RequestParam(value="endDate",required = true) String endDate,
                      @ApiParam(name="startNum",value="需要获取的起始行数",defaultValue = "0")
                      @RequestParam(value="startNum",required = true) String startNum,
                      @ApiParam(name="endNum",value="需要获取的结束的行数",defaultValue = "10")
                      @RequestParam(value="endNum",required = true) String endNum) {
        try {
            String result = outpatientService.getOutpatientRecord(strSSID,
                    startDate, endDate, startNum, endNum);
            String result = outpatientService.getOutpatientRecord(strSSID, startNum, endNum);
            return write(200, "获取门/急诊数据成功!", "data", result);
        } catch (Exception e) {
            error(e);