Browse Source

挂号接口整合

zdm 6 years ago
parent
commit
a5e6132909

+ 80 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -113,7 +114,7 @@ public class EntranceService {
        }else{
            //先调用银医通获取下载余额到his,再查询his中卡余额
            net.sf.json.JSONObject jsonObject= callYYTServerService(cardNo);
           if(null==jsonObject && "success".equals(jsonObject.get("code").toString())){
           if(null!=jsonObject && "1".equals(jsonObject.get("code").toString())){
               JSONObject msg=new JSONObject();
               msg.put("endNum","20000");
               msg.put("Msg", new net.sf.json.JSONArray() );
@ -848,11 +849,11 @@ public class EntranceService {
        if ("ok".equals(errorCode)) {
            JSON json2 = xmlSerializer.read(((net.sf.json.JSONObject) json).get("response").toString());
            System.out.println("银医通下载response:" + json2.toString(1));
            jsonObject.element("code","success");
            jsonObject.element("code","1");
            jsonObject.element("obj",json);
        } else {
            Object errorMsg = ((net.sf.json.JSONObject) json).get("error_msg");
            jsonObject.element("code","error");
            jsonObject.element("code","-1");
            jsonObject.element("obj","银医通下载失败," +errorMsg);
            //{"error_type":"0","error_code":"10002","error_msg":"卡号无效"}
        }
@ -866,4 +867,80 @@ public class EntranceService {
        return jsonObject;
    }
    /**
     *  患者门诊就诊记录
     *  按照患者唯一号、科室、医生、获取当前时间往前24小时的挂号记录。获取最新一条判断是否有效(医保当天有效,自费24小时有效)
     *  若是自费,则有效
     *  若是医保,判断日期是否和当前时间同一天,否则无效
     *  @param patNo 居民唯一号 必传参数
     *  @param dept 挂号科室 必传参数
     *  @param doctor 挂号医生 必传参数
     * @return true 已挂号 ,false 未挂号
     * @throws Exception
     */
    public boolean guahao(String patNo,String dept,String doctor,boolean demoFlag) throws Exception {
        String fid = BS30025;
        StringBuffer sbs = new StringBuffer();
        String resp;
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
        } else {
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><onceFlag>1</onceFlag><startNum>1</startNum><endNum>50000</endNum><Msg/>");
            if (StringUtils.isNotBlank(patNo)) {
                sbs.append("<query compy=\"=\" item=\"PAT_NO\" splice=\"and\" value=\"'" + patNo + "'\"/>");
            }
            if (StringUtils.isNotBlank(dept)) {
                sbs.append("<query compy=\"=\" item=\"ADM_SPEC\" splice=\"and\" value=\"'" + dept + "'\"/>");
            }
            if (StringUtils.isNotBlank(doctor)) {
                sbs.append("<query compy=\"=\" item=\"CON_DOC\" splice=\"and\" value=\"'" + doctor + "'\"/>");
            }
            //获取当前时间 查询当前时间往前推24小时是否有挂号 (医保当天有效,自费24小时有效)
            String now = DateUtil.dateToStr(DateUtil.getNowDate(), DateUtil.YYYY_MM_DD_HH_MM_SS);
            String preday = DateUtil.dateToStr(DateUtil.getPreDays(DateUtil.getNowDate(), -1), DateUtil.YYYY_MM_DD_HH_MM_SS);
            if (StringUtils.isNotBlank(preday)) {
                sbs.append("<query compy=\"&gt;\" item=\"ADM_DAT\" splice=\"and\" value=\"'" + preday + "'\"/>");
            }
            if (StringUtils.isNotBlank(now)) {
                sbs.append("<query compy=\"&lt;\" item=\"ADM_DAT\" splice=\"and\" value=\"'" + now + "'\"/>");
            }
            sbs.append("<order item=\"ADM_DAT\" sort=\"desc\"/>");
            //查询信息结束
            sbs.append("</MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        //解析返回结果
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(resp);
        if (null != jsonObject.get("MsgInfo")) {
            net.sf.json.JSONArray jsonArray = (net.sf.json.JSONArray) jsonObject.get("MsgInfo");
            //获取第一条
            net.sf.json.JSONObject object = (net.sf.json.JSONObject) jsonArray.get(0);
            //市医保,1;省医保,2;自费,3,其他医保,99)
            if (null != object.get("yb_flag") && "2".equals(object.get("yb_flag").toString())) {
                return true;
            }
            if (null != object.get("yb_flag") && ("1".equals(object.get("yb_flag").toString())) || "3".equals(object.get("yb_flag").toString())) {
                String admDateStr = object.get("ADM_DAT").toString();
                //挂号时间
                Date admDate = DateUtil.strToDate(admDateStr + "", DateUtil.YYYY_MM_DD);
                SimpleDateFormat format = new SimpleDateFormat(DateUtil.yyyy_MM_dd_HH_mm_ss);
                //获取当前时间
                String dateString = format.format(new Date());
                Date nowDate = DateUtil.strToDate(dateString, DateUtil.YYYY_MM_DD);
                if (0 == nowDate.compareTo(admDate)) {
                    return true;
                } else {
                    return false;
                }
            }
        }
        return false;
    }
}

+ 19 - 115
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java

@ -203,100 +203,6 @@ public class MqSdkController extends EnvelopRestEndpoint {
        return success(obj);
    }
    /**
     * 返回单个对象数据解析
     * @param obj
     * @return
     * @throws Exception
     */
    public ObjEnvelop convertObjectEnvelopByString(String obj)throws Exception{
        JSONObject jsonObject=JSONObject.fromObject(obj);
        if(null!=jsonObject&&"1".equals(jsonObject.get("code").toString())){
            JSONObject jsonObjectMgsInfo=(JSONObject)jsonObject.get("MsgInfo");
            if(null!=jsonObjectMgsInfo){
                return  ObjEnvelop.getSuccess("获取成功",jsonObjectMgsInfo.get("Msg").toString());
            }else {
                return null;
            }
        }else {
            return ObjEnvelop.getError("获取失败");
        }
    }
    /**
     * 返回对象数组数据解析
     * @param obj
     * @return
     * @throws Exception
     */
    public ListEnvelop convertListEnvelopByString(String obj)throws Exception{
        JSONObject jsonObject=JSONObject.fromObject(obj);
        if(null!=jsonObject&&"1".equals(jsonObject.get("code").toString())){
            JSONArray jsonObjectMgsInfo=(JSONArray)jsonObject.get("MsgInfo");
            if(null!=jsonObjectMgsInfo){
                return success(jsonObjectMgsInfo);
            }else {
                return null;
            }
        }else {
            return  null;
        }
    }
    /**
     * 返回对象数组数据解析
     * @param obj
     * @return
     * @throws Exception
     */
    public ListEnvelop convertListEnvelopInBodyRow(String obj)throws Exception{
        JSONObject jsonObject=JSONObject.fromObject(obj);
        JSONArray jsonArray=new JSONArray();
        if(null!=jsonObject&&"1".equals(jsonObject.get("code").toString())){
            JSONArray jsonObjectMgsInfo=(JSONArray)jsonObject.get("MsgInfo");
            if(null!=jsonObjectMgsInfo){
                for (Object object : jsonObjectMgsInfo) {
                    JSONObject jsonObjectBody=(JSONObject)object;
                    jsonObjectBody= (JSONObject)jsonObjectBody.get("body");
                  if(null!=jsonObjectBody){
                      jsonArray.add(jsonObjectBody.get("row")) ;
                  }
                }
                return success(jsonArray);
            }else {
                return null;
            }
        }else {
            return  null;
        }
    }
    /**
     * 返回对象数组数据解析
     * @param obj
     * @return
     * @throws Exception
     */
    public ListEnvelop convertListEnvelopInRow(String obj)throws Exception{
        JSONObject jsonObject=JSONObject.fromObject(obj);
        JSONArray jsonArray=new JSONArray();
        if(null!=jsonObject&&"1".equals(jsonObject.get("code").toString())){
            JSONArray jsonObjectMgsInfo=(JSONArray)jsonObject.get("MsgInfo");
            if(null!=jsonObjectMgsInfo){
                for (Object object : jsonObjectMgsInfo) {
                    JSONObject jsonObjectBody=(JSONObject)object;
                    if(null!=jsonObjectBody){
                        jsonArray.add(jsonObjectBody.get("row")) ;
                    }
                }
                return success(jsonArray);
            }else {
                return null;
            }
        }else {
            return  null;
        }
    }
    /**
     * 返回对象数组数据解析
@ -332,25 +238,6 @@ public class MqSdkController extends EnvelopRestEndpoint {
        }
    }
    /**
     * 返回对象数组数据解析
     * @param obj
     * @return
     * @throws Exception
     */
    public ObjEnvelop convertListEnvelopInRequest(String obj)throws Exception{
        JSONObject jsonObject=JSONObject.fromObject(obj);
        if(null!=jsonObject&&"1".equals(jsonObject.get("code").toString())){
            JSONArray jsonObjectMgsInfo=(JSONArray)jsonObject.get("MsgInfo");
            if(null!=jsonObjectMgsInfo){
                for (Object object : jsonObjectMgsInfo) {
                    JSONObject jsonObjectBody = (JSONObject) object;
                    return ObjEnvelop.getSuccess("获取成功", jsonObjectBody.get("resquest"));
                }
            }
        }
        return  null;
    }
    @GetMapping(value = "/MS25002")
    @ApiOperation(value = " 检查检验字典接口 ")
@ -375,18 +262,35 @@ public class MqSdkController extends EnvelopRestEndpoint {
    @GetMapping(value = "/yytDown")
    @ApiOperation(value = " 银医通下载 ")
    public JSONObject yytDown(
    public ObjEnvelop yytDown(
            @ApiParam(name = "cardNo", value = "卡号", required = true)
            @RequestParam(value = "cardNo") String cardNo) {
        try {
            JSONObject  obj= entranceService.callYYTServerService(cardNo);
            return obj;
            return success(obj);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    @GetMapping(value = "/guahao")
    @ApiOperation(value = " 查询某个时间段的患者门诊就诊记录 V1.00")
    public ObjEnvelop guahao(@ApiParam(name = "patNo", value = "居民id")
                         @RequestParam(value = "patNo",required = false) String patNo,
                         @ApiParam(name = "dept", value = "挂号科室")
                         @RequestParam(value = "dept",required = false) String dept,
                         @ApiParam(name = "doctor", value = "就诊医生")
                         @RequestParam(value = "doctor",required = false) String doctor) {
        try {
            boolean  obj = entranceService.guahao(patNo,dept,doctor,demoFlag);
            return success(obj);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败:"+e.getMessage());
        }
    }
}