Browse Source

代码修改

yeshijie 7 years ago
parent
commit
331b6bbb4b

+ 139 - 9
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftService.java

@ -1,8 +1,11 @@
package com.yihu.wlyy.service.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.entity.DoctorMapping;
import com.zoe.phip.ssp.sdk.ApiException;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -10,7 +13,9 @@ import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/9/9.
@ -172,6 +177,66 @@ public class ZysoftService {
        return re;
    }
    /**
     * 基卫二次封装Post接口
     */
    private String postSecond(String api, String content, com.alibaba.fastjson.JSONObject jsonParams, Map<String,String> headers) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = com.alibaba.fastjson.JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue);
        String msgHeader = JSONObject.fromObject(headers).toString();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        //System.out.print("msgHeader:"+msgHeader+"\r\n");
        //System.out.print("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        try {
            re = ZysoftApi.getSingleton().post("base/CallEhrInterface", paramsList, null,true);
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
            if(!code.equals("1"))
            {
                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
            }
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
            isSuccess = false;
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /*************************** 格式转换 *******************************************************/
    /**
@ -224,9 +289,9 @@ public class ZysoftService {
    }
    /**
     * 查询居民健康档案信息接口
     * 查询是否已签约
     */
    public String getSickArchiveRecord(String idcard,String hospital,String licence)  throws Exception
    public String getSickFamilySignFlag(String idcard,String hospital,String licence)  throws Exception
    {
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
@ -235,24 +300,28 @@ public class ZysoftService {
        Map<String,String> params = new HashMap<>();
        params.put("IDENTITY_CARD_NO",idcard);
        String response = postSecond("getSickArchiveRecord","查询居民健康档案信息",params,header,false);
        String response = postSecond("getSickFamilySignFlag","查询是否已签约",params,header,false);
        return response;
    }
    /**
     * 查询是否已签约
     * 7.51查询家庭医生签约人数上限接口
     * @param jwTeamCode 智业行政团队code
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getSickFamilySignFlag(String idcard,String hospital,String licence)  throws Exception
    {
    public String getSickFamilyDoctorSignLimit(String jwTeamCode,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("TEAM_CODE",jwTeamCode);
        String response = postSecond("getSickFamilySignFlag","查询是否已签约",params,header,false);
        String response = postSecond("getSickFamilyDoctorSignLimit","查询家庭医生签约人数上限接口",params,header,false);
        return response;
    }
@ -603,6 +672,67 @@ public class ZysoftService {
        }
    }
    /**************************** 建档相关接口 add by ysj at 2017-09-11 *************************************************/
    /**
     * 7.1查询居民是否有建立健康档案接口
     * @param idcard
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getSickArchiveFlag(String idcard,String hospital,String licence)  throws Exception
    {
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("IDENTITY_CARD_NO",idcard);
        String response = postSecond("getSickArchiveFlag","查询居民是否有建立健康档案接口",params,header,false);
        return response;
    }
    /**
     * 查询居民健康档案信息接口
     */
    public String getSickArchiveRecord(String idcard,String hospital,String licence)  throws Exception
    {
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("IDENTITY_CARD_NO",idcard);
        String response = postSecond("getSickArchiveRecord","查询居民健康档案信息",params,header,false);
        return response;
    }
    /**
     * 上传居民档案建档信息接口
     * @param json
     * @param hospital
     * @param licence
     * @param doctor
     * @return
     */
    public String saveSickArchiveRecord(String json, String hospital, String licence, DoctorMapping doctor) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        header.put("OPERATOR",doctor.getJwDoctor());
        com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
        jsonObject.put("ARCHIVE_OPERATOR_NAME",doctor.getJwDoctorName());
        String response = postSecond("saveSickArchiveRecord","上传居民档案建档信息接口",jsonObject,header);
        return response;
    }
    /**************************** 妇幼相关接口 add by hzp at 2017-07-12 *********************************************************/