wangzhinan 1 tahun lalu
induk
melakukan
318148c865

+ 93 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java

@ -0,0 +1,93 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatAppointmentDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Transactional
public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, PrescriptionDao> {
    private static Logger logger = LoggerFactory.getLogger(DsyyPrescriptionService.class);
    @Autowired
    private DsyyEntranceService dsyyEntranceService;
    //=============查询视图========================
    /**
     * 获取诊断
     *
     * @param pyCode
     * @return
     * @throws Exception
     */
    public JSONArray findIcd10(String pyCode) throws Exception {
        return dsyyEntranceService.findIcd10(pyCode);
    }
    /**
     * 获取药品字典
     *
     * @param chargeCode
     * @param pydm
     * @return
     * @throws Exception
     */
    public JSONArray findDrugs(String chargeCode,String pydm) throws Exception {
        return dsyyEntranceService.findDrugs(chargeCode,pydm);
    }
    /**
     * 获取频次字典
     *
     * @param pydm
     * @return
     * @throws Exception
     */
    public JSONArray getDrugFrequency() throws Exception {
        return dsyyEntranceService.getDrugFrequency();
    }
    /**
     * 获取给药方式
     * @param pydm
     * @return
     * @throws Exception
     */
    public JSONArray getDrugUse(String pydm) throws Exception {
        return dsyyEntranceService.getDrugUse(pydm);
    }
}

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TasyNatService.java

@ -14,6 +14,7 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
@ -58,6 +59,9 @@ public class TasyNatService {
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private DsyyEntranceService dsyyEntranceService;
    public String getOperateUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("TasyWebOperateService");
@ -1179,4 +1183,5 @@ public class TasyNatService {
        }
        return map;
    }
}

+ 175 - 1204
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java

@ -168,7 +168,7 @@ public class DsyyEntranceService {
    public String getOperateUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("hcyyWebOperateService");
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("dsyyHisOperateService");
        String url = list.get(0).getDictCode();
        return url;
@ -182,9 +182,9 @@ public class DsyyEntranceService {
        return url;
    }
    public String getCaServiceUrl(){
    public String getJhServiceUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("hcyyCaService");
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("dsyyJhService");
        String url = list.get(0).getDictCode();
        return url;
@ -195,30 +195,46 @@ public class DsyyEntranceService {
        return sysDictDO.getDictCode();
    }
    /**
     * his 调用
     * @param api
     * @param params
     * @param url
     * @return
     * @throws Exception
     */
    public String getDsyyWebServiceInfo(String api, Map<String,String> params,String url)throws Exception{
        logger.info("url"+url);
        List<WlyyHospitalSysDictDO> xzzxNamespaces =  wlyyHospitalSysDictDao.findByDictName("hcyyNamespace");
        List<WlyyHospitalSysDictDO> xzzxNamespaces =  wlyyHospitalSysDictDao.findByDictName("dsyyNamespace");
        String xzzxNamespace = xzzxNamespaces.get(0).getDictCode();
        logger.info("hcyyNamespace",xzzxNamespace);
        logger.info("dsyyNamespace",xzzxNamespace);
        return WebserviceUtil.post(url,xzzxNamespace,api,params);
    }
    public String getDsyyCAWebServiceInfo(String api, Map<String,String> params,String url)throws Exception{
    /**
     * 集成平台地址
     * @param api
     * @param params
     * @param url
     * @return
     * @throws Exception
     */
    public String getDsyyJhWebServiceInfo(String api, Map<String,String> params,String url)throws Exception{
        logger.info("url"+url);
        List<WlyyHospitalSysDictDO> xzzxNamespaces =  wlyyHospitalSysDictDao.findByDictName("hcyyCaNamespace");
        List<WlyyHospitalSysDictDO> dsyyJhNamespaces =  wlyyHospitalSysDictDao.findByDictName("hcyyJhNamespace");
        String xzzxNamespace = xzzxNamespaces.get(0).getDictCode();
        String dsyyNamespace = dsyyJhNamespaces.get(0).getDictCode();
        logger.info("hcyyCaNamespace",xzzxNamespace);
        logger.info("hcyyCaNamespace",dsyyNamespace);
        return WebserviceUtil.post(url,xzzxNamespace,api,params);
        return WebserviceUtil.post(url,dsyyNamespace,api,params);
    }
    public List<Map<String, Object>> createSQLQuery(String sql, Map<String, Object> params, Integer page, Integer size){
@ -266,6 +282,7 @@ public class DsyyEntranceService {
                        //新增
                        DictHospitalDeptDO deptDO = new DictHospitalDeptDO();
                        deptDO.setOrgCode(orgCode);
                        deptDO.setOrgName("厦门市第三医院");
                        deptDO.setCode(code);
                        deptDO.setName(deptjson.getString("name"));
                        deptDO.setConsultDeptFlag(deptjson.getString("consultDeptFlag"));
@ -430,18 +447,13 @@ public class DsyyEntranceService {
     * 获取icd10诊断
     *
     * @param pyCode
     * @param demoFlag
     * @return
     * @throws Exception
     */
    public JSONArray findIcd10(String pyCode,String name,boolean demoFlag) throws Exception {
    public JSONArray findIcd10(String pyCode) throws Exception {
        String sql = "select i.code as \"code\",i.name as \"name\",i.disea_reason as \"disea_reason\",i.death_reason as \"death_reason\",i.py_code as \"py_code\",i.flag as \"flag\",i.add_code as \"add_code\",i.emr as \"emr\" from v_internet_diagnosis_info i where 1=1 ";
        JSONArray array = new JSONArray();
        if (StringUtils.isNoneBlank(pyCode)){
            sql +=" and  lower(i.py_code) like '%"+pyCode.toLowerCase()+"%'";
        }
        if (StringUtils.isNoneBlank(name)){
            sql +=" and  i.name like '%"+name+"%'";
            sql +=" and  (lower(i.py_code) like '%"+pyCode.toLowerCase()+"%' or i.name like '%"+pyCode+"%' )";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -460,12 +472,9 @@ public class DsyyEntranceService {
    /**
     * 查询药品信息
     * @param ypdm
     * @param ypmc
     * @param kusl
     * @return
     */
    public JSONArray findYkYpxx(String ypdm,String ypmc,String kusl,String pydm ,String hisCode) throws Exception {
    public JSONArray findDrugs(String chagreCode,String pydm) throws Exception {
        String sql ="SELECT\n" +
                "\tcharge_code as \"charge_code\",\n" +
                "\tserial as \"serial\",\n" +
@ -494,11 +503,8 @@ public class DsyyEntranceService {
                "\tv_internet_physic_dict_info \n" +
                "WHERE\n" +
                "\t1 = 1 ";
        if (StringUtils.isNoneBlank(ypdm)){
            sql+=" and lower(yp.charge_code) like '%"+ypdm.toLowerCase()+"%' ";
        }
        if (StringUtils.isNoneBlank(ypmc)){
            sql+=" and lower(yp.py_code) like '%"+ypmc.toLowerCase()+"%' ";
        if (StringUtils.isNoneBlank(chagreCode)){
            sql+=" and (lower(yp.charge_code) like '%"+chagreCode.toLowerCase()+"%' or chagreCode like '%"+chagreCode+"%' ) ";
        }
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
@ -550,700 +556,105 @@ public class DsyyEntranceService {
    }
    public String randomString(int length) {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();
        for(int i = 0; i < length; ++i) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }
        return buffer.toString();
    }
    /**
     * 获取职称字典
     * @return
     */
    public String getJobTitle()throws Exception{
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = "";
        logger.info("getJobTitleInfo json:"+json);
        JSONArray list = JSONArray.parseArray(json).getJSONArray(0);
        if(list!=null&&list.size()>0){
            for(int i=0;i<list.size();i++){
                JSONObject object = list.getJSONObject(i);
                logger.info("getJobTitleInfo object:"+object.toJSONString());
                String code = object.getString("code");
                String name = object.getString("name");
                DictDoctorDutyDO dictDoctorDutyDO = dictDoctorDutyDao.findByCode(code);
                if (dictDoctorDutyDO!=null){
                    dictDoctorDutyDO.setName(name);
                    dictDoctorDutyDao.save(dictDoctorDutyDO);
                }else {
                    DictDoctorDutyDO dictDoctorDutyDO1 = new DictDoctorDutyDO();
                    dictDoctorDutyDO1.setCode(code);
                    dictDoctorDutyDO1.setName(name);
                    dictDoctorDutyDO1.setCreateTime(new Date());
                    dictDoctorDutyDao.save(dictDoctorDutyDO1);
                }
            }
        }
        return json;
    }
    /**
     * 获取号别字典
     * @return
     */
    public String getChargeDict()throws Exception{
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = "";
        logger.info("getChargeDictInfo json:"+json);
        JSONArray list = JSONArray.parseArray(json).getJSONArray(0);
        if(list!=null&&list.size()>0){
            for(int i=0;i<list.size();i++){
                JSONObject object = list.getJSONObject(i);
                logger.info("getJobTitleInfo object:"+object.toJSONString());
                String code = object.getString("chargeType");
                String name = object.getString("chargeTypeName");
                String reqFee = object.getString("reqFee");
                Double reqFees = 0.0;
                if (StringUtils.isNoneBlank(reqFee)&&!reqFee.equalsIgnoreCase("[]")){
                    reqFees= Double.parseDouble(reqFee);
                }
                WlyyChargeDictDO chargeDictDO = chargeDictDao.findByChargeType(code);
                if (chargeDictDO!=null){
                    chargeDictDO.setChargeType(code);
                    chargeDictDO.setChargeName(name);
                    chargeDictDO.setReqFee(reqFees);
                    chargeDictDao.save(chargeDictDO);
                }else {
                    WlyyChargeDictDO chargeDictDO1 = new WlyyChargeDictDO();
                    chargeDictDO1.setChargeType(code);
                    chargeDictDO1.setChargeName(name);
                    chargeDictDO1.setReqFee(reqFees);
                    chargeDictDO1.setCreateTime(new Date());
                    chargeDictDao.save(chargeDictDO1);
                }
            }
        }
        return json;
    }
    /**
     * 查询患者就诊卡
     * @param
     * @return
     * @throws Exception
     */
    //查询患者就诊卡
    public String findPatientCard(String patient)throws Exception{
        BasePatientDO patientDO = patientDao.getOne(patient);
        if (patientDO==null){
            throw new Exception("不存在该患者!");
        }
        String json = "";
        logger.info("findPatientCard json:"+json);
        return json;
    }
    /**
     * 获取频次字典
     *
     *  获取卡信息
     *
     * @param cardNo 卡号(必填)
     * @return
     * @throws Exception
     */
    //获取卡信息
    public String getCardInfo(String cardNo)throws Exception{
        String json="";
        logger.info("getCardInfo json:"+json);
        return json;
    }
    /**
     * 获取单条门诊就诊记录
     * @param patient 居民id
     * @param conNo 就诊次数
     * @return
     * @throws Exception
     */
    //获取单条门诊就诊记录
    public String findOutpatientInfo(String patient,String conNo,String startTime,String endTime)throws Exception{
        String api = "FindOutpatientInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(patient)&&!patient.equalsIgnoreCase("null")){
            condition += "<patient>"+patient+"</patient>";
        }
        if (!StringUtils.isEmpty(conNo)&&!conNo.equalsIgnoreCase("null")){
            condition += "<conNo>"+conNo+"</conNo>";
        }
        if (!StringUtils.isEmpty(startTime)&&!startTime.equalsIgnoreCase("null")){
            condition += "<startTime>"+startTime+"</startTime>";
        }
        if (!StringUtils.isEmpty(endTime)&&!endTime.equalsIgnoreCase("null")){
            condition += "<endTime>"+endTime+"</endTime>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("FindOutpatientInfo params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("FindOutpatientInfo json:"+json);
        return json;
    }
    /**
     * 获取门诊下所有处方信息
     * @param registerSn 流水号(必传)
     * @param patNo 病人id(必传)
     * @param admNo 住院唯一号(必传)
     * @param realOrder 处方号(非必传,传相当于查单条处方)
     * @return
     * @throws Exception
     */
    //获取门诊下所有处方信息
    public String getOriginPrescriptionList(String registerSn,String patNo,String admNo,String realOrder,String startTime,String endTime)throws Exception{
        String api = "GetOriginPrescriptionList";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        logger.info("registerSn"+registerSn+"patNo"+patNo+"admNo"+admNo+"realOrder"+realOrder);
        if (!StringUtils.isEmpty(registerSn)&&!registerSn.equalsIgnoreCase("null")){
            condition += "<registerSn>"+registerSn+"</registerSn>";
        }
        if (!StringUtils.isEmpty(patNo)&&!patNo.equalsIgnoreCase("null")){
            condition += "<patNo>"+patNo+"</patNo>";
        }
        if (!StringUtils.isEmpty(admNo)&&!admNo.equalsIgnoreCase("null")){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (!StringUtils.isEmpty(realOrder)&&!realOrder.equalsIgnoreCase("null")){
            condition += "<realOrder>"+realOrder+"</realOrder>";
        }
        if (!StringUtils.isEmpty(startTime)&&!startTime.equalsIgnoreCase("null")){
            condition += "<startTime>"+startTime+"</startTime>";
        }
        if (!StringUtils.isEmpty(endTime)&&!endTime.equalsIgnoreCase("null")){
            condition += "<endTime>"+endTime+"</endTime>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("getOriginPrescriptionList params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getOriginPrescriptionList json:"+json);
        return json;
    }
    /**
     * 获取门诊病人诊断
     * @param registerSn
     * @param patNo
     * @param admNo
     * @param realOrder
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public String getOutpatientDiagnosis(String registerSn,String patNo,String admNo,String realOrder,String startTime,String endTime)throws Exception{
        String api = "GetOutpatientDiagnosis";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(registerSn)&&!registerSn.equalsIgnoreCase("null")){
            condition += "<registerSn>"+registerSn+"</registerSn>";
        }
        if (!StringUtils.isEmpty(patNo)&&!patNo.equalsIgnoreCase("null")){
            condition += "<patNo>"+patNo+"</patNo>";
        }
        if (!StringUtils.isEmpty(admNo)&&!admNo.equalsIgnoreCase("null")){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (!StringUtils.isEmpty(realOrder)&&!realOrder.equalsIgnoreCase("null")){
            condition += "<realOrder>"+realOrder+"</realOrder>";
        }
        if (!StringUtils.isEmpty(startTime)&&!startTime.equalsIgnoreCase("null")){
            condition += "<startTime>"+startTime+"</startTime>";
        }
        if (!StringUtils.isEmpty(endTime)&&!endTime.equalsIgnoreCase("null")){
            condition += "<endTime>"+endTime+"</endTime>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("getOutpatientDiagnosis params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getOutpatientDiagnosis json:"+json);
        return json;
    }
    /**
     * 获取门诊病人处方药品信息
     *
     * @param registerSn
     * @param patNo
     * @param admNo
     * @param realOrder
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public String getOutpatientDrugInfo(String registerSn,String patNo,String admNo,String realOrder,String startTime,String endTime)throws Exception{
        String api = "GetOutpatientDrugInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(registerSn)&&!registerSn.equalsIgnoreCase("null")){
            condition += "<registerSn>"+registerSn+"</registerSn>";
        }
        if (!StringUtils.isEmpty(patNo)&&!patNo.equalsIgnoreCase("null")){
            condition += "<patNo>"+patNo+"</patNo>";
        }
        if (!StringUtils.isEmpty(admNo)&&!admNo.equalsIgnoreCase("null")){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (!StringUtils.isEmpty(realOrder)&&!realOrder.equalsIgnoreCase("null")){
            condition += "<realOrder>"+realOrder+"</realOrder>";
        }
        if (!StringUtils.isEmpty(startTime)&&!startTime.equalsIgnoreCase("null")){
            condition += "<startTime>"+startTime+"</startTime>";
        }
        if (!StringUtils.isEmpty(endTime)&&!endTime.equalsIgnoreCase("null")){
            condition += "<endTime>"+endTime+"</endTime>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("getOutpatientDrugInfo params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getOutpatientDrugInfo json:"+json);
        return json;
    }
    public String getOutpatientCheckTestInfo(String registerSn,String patNo,String admNo,String realOrder,String startTime,String endTime)throws Exception{
        String api = "GetOutpatientCheckTestInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(registerSn)&&!registerSn.equalsIgnoreCase("null")){
            condition += "<registerSn>"+registerSn+"</registerSn>";
        }
        if (!StringUtils.isEmpty(patNo)&&!patNo.equalsIgnoreCase("null")){
            condition += "<patNo>"+patNo+"</patNo>";
        }
        if (!StringUtils.isEmpty(admNo)&&!admNo.equalsIgnoreCase("null")){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (!StringUtils.isEmpty(realOrder)&&!realOrder.equalsIgnoreCase("null")){
            condition += "<realOrder>"+realOrder+"</realOrder>";
        }
        if (!StringUtils.isEmpty(startTime)&&!startTime.equalsIgnoreCase("null")){
            condition += "<startTime>"+startTime+"</startTime>";
        }
        if (!StringUtils.isEmpty(endTime)&&!endTime.equalsIgnoreCase("null")){
            condition += "<endTime>"+endTime+"</endTime>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("getOutpatientCheckTestInfo params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getOutpatientCheckTestInfo json:"+json);
        return json;
    }
    /**
     * 挂号(调his后台包)
     * @param doctor 医生ID(必填)
     * @param dept 科室编码(必填)
     * @param sickId 病人id
     * @param clinicclass 挂号类别(必填)
     * @return
     * @throws Exception
     */
    //挂号(调his后台包)
    public String registered(String doctor,String dept,String sickId,String clinicclass,String courierflag)throws Exception{
        String api = "Registered";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        logger.info("clinicclass:"+clinicclass);
        if (!StringUtils.isEmpty(doctor)&&!doctor.equalsIgnoreCase("null")){
            condition += "<doctor>"+doctor+"</doctor>";
        }
        if (!StringUtils.isEmpty(dept)&&!dept.equalsIgnoreCase("null")){
            condition +="<dept>"+dept+"</dept>";
        }
        if (!StringUtils.isEmpty(sickId)&&!sickId.equalsIgnoreCase("null")){
            condition += "<sickid>"+sickId+"</sickid>";
        }
        if (!StringUtils.isEmpty(clinicclass)&&!clinicclass.equalsIgnoreCase("null")){
            condition +="<clinicclass>"+clinicclass+"</clinicclass>";
        }
        if (!StringUtils.isEmpty(courierflag)&&!courierflag.equalsIgnoreCase("null")){
            condition +="<courierflag>"+courierflag+"</courierflag>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("registered params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        return json;
    }
    /**
     * 处方状态变更
     * @param admNo 就诊唯一号(必填)
     * @param realOrder 处方号(必填)
     * @param status 处方状态:3结算完成(必填)
     * @return
     * @throws Exception
     */
    //处方状态变更
    public String updatePrescriptionStatus(String admNo,String realOrder,String status)throws Exception{
        String api = "UpdatePreStatus";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(admNo)){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (!StringUtils.isEmpty(realOrder)){
            condition +="<realOrder>"+realOrder+"</realOrder>";
        }
        if (!StringUtils.isEmpty(status)){
            condition += "<status>"+status+"</status>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("updatePreStatus params:"+params.toString());
        String xml = getDsyyWebServiceInfo("UpdatePreStatus",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("updatePreStatus json:"+json);
        return json;
    }
    /**
     *
     *  获取icd10字典
     *
     * @param spellCode spellCode
     * @return
     * @throws Exception
     */
    public String GetICD10Dict(String spellCode)throws Exception{
        String api = "GetICD10Dict";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition += "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetICD10Dict params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetICD10Dict json:"+json);
        return json;
    }
    /**
     *
     *  获取药品字典
     *
     * @param spellCode spellCode
     * @return
     * @throws Exception
     */
    public String GetDrugDict(String spellCode,String drugNo)throws Exception{
        String api = "GetDrugDict";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        logger.info("spellCode"+spellCode+drugNo+"spellCode");
        if (!StringUtils.isEmpty(spellCode)){
            condition += "<spell_code>"+spellCode+"</spell_code>";
        }
        if (!StringUtils.isEmpty(drugNo)){
            condition += "<physic_code>"+drugNo+"</physic_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetDrugDict params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetDrugDict json:"+json);
        return json;
    }
    /**
     *
     *  查询药品用药方法
     * @return
     * @throws Exception
     */
    public String GetMedicineUsed(String spellCode)throws Exception{
        String api = "GetMedicineUsed";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetMedicineUsed params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetMedicineUsed json:"+json);
        return json;
    }
    /**
     *
     *  获取药品用药频次字典
     * @return
     * @throws Exception
     */
    public String GetFrequencyDict()throws Exception{
        String api = "GetFrequencyDict";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetFrequencyDict params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetFrequencyDict json:"+json);
        return json;
    }
    /**
     *
     *  获取检查部位字典
     * @return
     * @throws Exception
     */
    public String  GetCheckBody(String spellCode)throws Exception{
        String api = "GetCheckBody";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
    public JSONArray getDrugFrequency() throws Exception {
        String sql = "SELECT\n" +
                "\tfreq_code AS \"FREQ_CODE\",\n" +
                "\tfreq_name AS \"FREQ_NAME\",\n" +
                "\tfreq_sp AS \"FREQ_SP\",\n" +
                "\tdaily_times AS \"DAILY_TIMES\",\n" +
                "\tweekly_times AS \"WEEKLY_TIMES\",\n" +
                "\thosp_code AS \"HOSP_CODE\",\n" +
                "\tis_op_ip AS \"IS_OP_IP\" \n" +
                "FROM\n" +
                "\tv_internet_frequency_dict_info where 1=1 ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ypxx:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info(" GetCheckBody params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" GetCheckBody json:"+json);
        return json;
        return array;
    }
    /**
     * 获取用法
     *
     *  获取检查项目信息
     * @return
     * @throws Exception
     */
    public String GetExamApply(String spellCode)throws Exception{
        String api = "GetExamApply";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
    public JSONArray getDrugUse(String pydm) throws Exception {
        String sql ="SELECT\n" +
                "\tsupply_code as \"supply_code\",\n" +
                "\tsupply_name as \"supply_name\",\n" +
                "\tsupply_occ as \"supply_occ\",\n" +
                "\tdel_flag as \"del_flag\",\n" +
                "\tsort_code as \"sort_code\",\n" +
                "\tclass as \"class\",\n" +
                "\tpy_code as \"py_code\",\n" +
                "\td_code as \"d_code\",\n" +
                "\tyb_code as \"yb_code\",\n" +
                "\tyb_name as \"yb_name\"\n" +
                "FROM\n" +
                "\tv_internet_take_medicine_ways\n" +
                "\tWHERE 1=1  ";
        if (StringUtils.isNoneBlank(pydm)){
            sql+=" and (lower(yp.py_code) like '%"+pydm.toLowerCase()+"%' or supply_name like '%"+pydm+"%' ) ";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ypxx:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        return array;
    }
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetExamApply params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" GetExamApply json:"+json);
        return json;
    public String randomString(int length) {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();
        for(int i = 0; i < length; ++i) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }
        return buffer.toString();
    }
   //=============his webservice 调用开始 =============================
    /**
     *
     *  获取检验单据信息
     * 挂号(调his后台包)
     * @param doctor 医生ID(必填)
     * @param dept 科室编码(必填)
     * @param sickId 病人id
     * @param clinicclass 挂号类别(必填)
     * @return
     * @throws Exception
     */
    public String GetLisApply(String spellCode)throws Exception{
        String api = "GetLisApply";
    //挂号(调his后台包)
    public String registered(String doctor,String dept,String sickId,String clinicclass,String courierflag)throws Exception{
        String api = "Registered";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
@ -1252,23 +663,39 @@ public class DsyyEntranceService {
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
        logger.info("clinicclass:"+clinicclass);
        if (!StringUtils.isEmpty(doctor)&&!doctor.equalsIgnoreCase("null")){
            condition += "<doctor>"+doctor+"</doctor>";
        }
        if (!StringUtils.isEmpty(dept)&&!dept.equalsIgnoreCase("null")){
            condition +="<dept>"+dept+"</dept>";
        }
        if (!StringUtils.isEmpty(sickId)&&!sickId.equalsIgnoreCase("null")){
            condition += "<sickid>"+sickId+"</sickid>";
        }
        if (!StringUtils.isEmpty(clinicclass)&&!clinicclass.equalsIgnoreCase("null")){
            condition +="<clinicclass>"+clinicclass+"</clinicclass>";
        }
        if (!StringUtils.isEmpty(courierflag)&&!courierflag.equalsIgnoreCase("null")){
            condition +="<courierflag>"+courierflag+"</courierflag>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetLisApply params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getSelectUrl());
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("registered params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" GetLisApply json:"+json);
        return json;
    }
    /**
     * 互联网医院开处方信息更新到his
     * @param IoFlag  门诊住院标志
@ -1409,15 +836,10 @@ public class DsyyEntranceService {
     * @param ApplyNo
     * @param DiagnosisName
     * @param DiagnosisCode
     * @param ChnSymPtomsCode
     * @param ChnSymPtomsName
     * @param ChnDiagnosisCode
     * @param ChnDiagnosisName
     * @return
     * @throws Exception
     */
    public String saveDiagnosis(String ApplyNo,String DiagnosisName,String DiagnosisCode,
                                             String ChnSymPtomsCode,String ChnSymPtomsName,String ChnDiagnosisCode,String ChnDiagnosisName)throws Exception{
    public String saveDiagnosis(String ApplyNo,String DiagnosisName,String DiagnosisCode)throws Exception{
        String api = "saveDiagnosis";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
@ -1553,8 +975,47 @@ public class DsyyEntranceService {
    }
    //=============his webservice 调用结束=========================
    //========================集成平台调用开始===========================
   /* *//**
     * 发送退号信息到his
     * @return
     * @throws Exception
     *//*
    public String refundConsultation(String ApplyNo,String PayCardNo)throws Exception{
        String api = "refundConsultation";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(ApplyNo)){
            condition += "<ApplyNo>"+ApplyNo+"</ApplyNo>";
        }
        if (!StringUtils.isEmpty(PayCardNo)){
            condition += "<PayCardNo>"+PayCardNo+"</PayCardNo>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("refundConsultation params:"+params.toString());
        String xml = getDsyyWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("refundConsultation json:"+json);
        return json;
    }*/
    //========================集成平台调用结束===========================
    public String replaceHtml(String demoData,String oldChar,String newChar){
        return demoData.replace(oldChar,null==newChar?"无":newChar);
@ -1807,496 +1268,6 @@ public class DsyyEntranceService {
        logger.info("BrowseSingleEMR json:"+xml);
        return xml;
    }
//=====================微信模板消息推送===================================
    public String sendMes(String wxId,String patient,String cardNo,String first,String noticeContent,String remark,String redirectUrl){
        JSONObject params = new JSONObject();
        params.put("transType","sms.hospital.notice");
        params.put("merchId","3501000014");
        JSONObject p = new JSONObject();
        String openId = "";
        if(StringUtils.isNotBlank(patient)){
            List<BasePatientWechatDo> paientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient);
            if(paientWechatDos!=null&&paientWechatDos.size()>0){
                openId = paientWechatDos.get(0).getOpenid();
                p.put("openId",openId);
            }
        }else {
            p.put("cardNo",cardNo);
        }
        p.put("first",first);
        p.put("noticeTime", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        p.put("noticeContent",noticeContent);
        if(StringUtils.isNotBlank(redirectUrl)){
            p.put("redirectUrl",redirectUrl);
        }
        p.put("remark",remark);
        params.put("param",p);
        logger.info("params :"+params.toString());
        if(StringUtils.isNotBlank(openId)||StringUtils.isNotBlank(cardNo)){
            String rs = HttpUtil.sendPost(sendMessageUrl,params.toJSONString());
            logger.info("rs :"+rs);
            JSONObject rsJson = JSON.parseObject(rs);
            String resCode = rsJson.getString("respCode");
            if("000000".equals(resCode)){
                return "1";
            }
            return "0";
        }else {
            return "-1";
        }
    }
    /**
     * 获取海沧医院微信token
     * @return
     * @throws Exception
     */
    public String getHcToken() throws Exception{
        String rs = HttpUtil.sendGet("https://wx.xmhcyy.com/weixin/100123/WXXMHC01/getToken.do");
        logger.info("rs :"+rs);
        return rs;
    }
    public String ehospitalNotice(String userName, String idCard, String phone, String title, String url, String content, String contentString) {
        logger.info("ehospitalNotice:");
        BasePatientDO patientDO = patientDao.findByIdcardAndDel(idCard,"1");
        if(patientDO!=null&&StringUtils.isNotBlank(patientDO.getIdcard())){
            sendMes("xm_xzzx_wx",patientDO.getId(),null,content,contentString,"",url);
        }
        return "-2";
    }
//=====================微信模板消息推送接口================================
//=====================hospital应用调用entrance应用============start=================
    public Map<String,Object> updatePreStatusLocal(String admNo,String realOrder,String status) throws Exception {
        Map<String,Object> map = new HashedMap();
        logger.info("admNo"+admNo+"=========realOrder"+realOrder+"===========status"+status);
        if (status.equalsIgnoreCase("1")){
            List<WlyyOutpatientDO> wlyyOutpatientDOList = outpatientDao.findByAdmNo(admNo);
            if (wlyyOutpatientDOList==null||wlyyOutpatientDOList.size()==0){
                throw new Exception("该就诊号查不到!");
            }
            for (WlyyOutpatientDO wlyyOutpatientDO:wlyyOutpatientDOList){
                String registerNo = wlyyOutpatientDO.getRegisterNo();
                if (!StringUtils.isNoneBlank(registerNo)){
                    throw new Exception("挂号流水号为空!");
                }
                PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(wlyyOutpatientDO.getPatient());
                List<WlyyPrescriptionVO> prescriptionVOList = selectOriginPrescriptionListLocal(registerNo,patientMappingDO.getMappingCode(),admNo,realOrder);
                for (WlyyPrescriptionVO prescriptionVO:prescriptionVOList){
                    WlyyPrescriptionDO prescriptionDO =JSONObject.toJavaObject(JSONObject.parseObject(JSONObject.toJSONString(prescriptionVO)),WlyyPrescriptionDO.class);
                    prescriptionDO.setOutpatientId(wlyyOutpatientDO.getId());
                    if (status.equalsIgnoreCase("1")){
                        prescriptionDO.setStatus(20);
                    }
                    prescriptionDO.setDoctor(wlyyOutpatientDO.getDoctor());
                    prescriptionDO.setPatientCode(wlyyOutpatientDO.getPatient());
                    prescriptionDO= prescriptionDao.save(prescriptionDO);
                    //处方诊断表vo
                    List<WlyyPrescriptionDiagnosisVO> diagnosisVOS = prescriptionVO.getDiagnosisVOs();
                    for (WlyyPrescriptionDiagnosisVO diagnosisVO:diagnosisVOS){
                        WlyyPrescriptionDiagnosisDO prescriptionDiagnosisDO = JSONObject.toJavaObject(JSONObject.parseObject(JSONObject.toJSONString(diagnosisVO)),WlyyPrescriptionDiagnosisDO.class);
                        prescriptionDiagnosisDO.setPrescriptionId(prescriptionDO.getId());
                        prescriptionDiagnosisDO.setDel(1);
                        diagnosisDao.save(prescriptionDiagnosisDO);
                    }
                    //药品表
                    List<WlyyPrescriptionInfoVO> infoVOList = prescriptionVO.getInfoVOs();
                    for (WlyyPrescriptionInfoVO infoVO:infoVOList){
                        WlyyPrescriptionInfoDO infoDO = JSONObject.toJavaObject(JSONObject.parseObject(JSONObject.toJSONString(infoVO)),WlyyPrescriptionInfoDO.class);
                        infoDO.setPrescriptionId(prescriptionDO.getId());
                        infoDO.setDel(1);
                        prescriptionInfoDao.save(infoDO);
                    }
                    List<WlyyInspectionVO> inspectionVOList = prescriptionVO.getInspectionVOs();
                    for (WlyyInspectionVO inspectionVO:inspectionVOList){
                        WlyyInspectionDO inspectionDO = JSONObject.toJavaObject(JSONObject.parseObject(JSONObject.toJSONString(inspectionVO)),WlyyInspectionDO.class);
                        BeanUtils.copyProperties(inspectionVO,inspectionDO);
                        inspectionDO.setPrescriptionId(prescriptionDO.getId());
                        inspectionDO.setDel(1);
                        wlyyInspectionDao.save(inspectionDO);
                    }
                }
            }
        }else if (status.equalsIgnoreCase("2")){
            List<WlyyPrescriptionDO> prescriptionDOList =  prescriptionDao.findByAdmNoAndRealOrderList(admNo,realOrder);
            for (WlyyPrescriptionDO wlyyPrescriptionDO:prescriptionDOList){
                wlyyPrescriptionDO.setStatus(-1);
                prescriptionDao.save(wlyyPrescriptionDO);
                //检查
                List<WlyyInspectionDO> wlyyInspectionDOS = wlyyInspectionDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                for (WlyyInspectionDO inspectionDO:wlyyInspectionDOS){
                    inspectionDO.setDel(0);
                    wlyyInspectionDao.save(inspectionDO);
                }
                //药品
                List<WlyyPrescriptionInfoDO> prescriptionInfoDOS=prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                for (WlyyPrescriptionInfoDO prescriptionInfoDO:prescriptionInfoDOS){
                    prescriptionInfoDO.setDel(0);
                    prescriptionInfoDao.save(prescriptionInfoDO);
                }
                //诊断
                List<WlyyPrescriptionDiagnosisDO> diagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                for (WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOS){
                    diagnosisDO.setDel(0);
                    prescriptionDiagnosisDao.save(diagnosisDO);
                }
            }
        }else if (status.equalsIgnoreCase("3")){
            List<WlyyPrescriptionDO> prescriptionDOList =  prescriptionDao.findByAdmNoAndRealOrderList(admNo,realOrder);
            for (WlyyPrescriptionDO wlyyPrescriptionDO:prescriptionDOList){
                wlyyPrescriptionDO.setStatus(30);
                prescriptionDao.save(wlyyPrescriptionDO);
            }
        }
        return map;
    }
    /**
     * 获取门诊下所有处方信息---内网调下
     * @param registerSn 流水号
     * @param patNo 居民id
     * @param admNo 住院唯一号
     * @param realOrder 处方号
     * @return
     */
    public List<WlyyPrescriptionVO> selectOriginPrescriptionListLocal(String registerSn,String patNo,String admNo,String realOrder){
        List<WlyyPrescriptionVO> prescriptionVOList = new ArrayList<>();
        String response="";
        String params = "";
        if (StringUtils.isNoneBlank(realOrder)){
            params +="&realOrder="+realOrder;
        }
        logger.info("处方request:"+registerSn+"=="+patNo+"==="+admNo+"===="+realOrder);
        String url = entranceUrlLocal+"getOriginPrescriptionList?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+params;
        response = httpClientUtil.get(url,"GBK");
        logger.info("处方response:"+response+"===="+url);
        JSONObject object = JSONObject.parseObject(response);
        if (object!=null&&object.getInteger("status")==200){
            JSONArray array = new JSONArray();
            array = JSONArray.parseArray(object.getString("obj")).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                WlyyPrescriptionVO wlyyPrescriptionVO = new WlyyPrescriptionVO();
                JSONObject jsonObject = array.getJSONObject(i);
                wlyyPrescriptionVO.setCreateTime(DateUtil.strToDate(isEmty(jsonObject.getString("CREATETIME"))));
                wlyyPrescriptionVO.setCreateUser(isEmty(jsonObject.getString("CREATEUSER")));
                wlyyPrescriptionVO.setCreateUserName(isEmty(jsonObject.getString("CREATENAME")));
                wlyyPrescriptionVO.setUpdateTime(DateUtil.strToDate(isEmty(jsonObject.getString("UPDATETIME"))));
                wlyyPrescriptionVO.setUpdateUser(isEmty(jsonObject.getString("UPDATEUSER")));
                wlyyPrescriptionVO.setUpdateUserName(isEmty(jsonObject.getString("UPDATEUSERNAME")));
                wlyyPrescriptionVO.setRealOrder(isEmty(jsonObject.getString("REALORDER")));
                wlyyPrescriptionVO.setOriginRealOrder(isEmty(jsonObject.getString("ORIGINREALORDER")));
                wlyyPrescriptionVO.setAdmNo(isEmty(jsonObject.getString("ADMNO")));
                wlyyPrescriptionVO.setOriginAdmNo(isEmty(jsonObject.getString("ORIGINADMNO")));
                wlyyPrescriptionVO.setSerialNo(isEmty(jsonObject.getString("SERIALNO")));
                wlyyPrescriptionVO.setOriginSerialNo(isEmty(jsonObject.getString("ORIGINSERIALNO")));
                wlyyPrescriptionVO.setType(jsonObject.getInteger("TYPE"));
                wlyyPrescriptionVO.setPatientCode(isEmty(jsonObject.getString("PATIENTCODE")));
                wlyyPrescriptionVO.setPatientName(isEmty(jsonObject.getString("PATEINTNAME")));
                wlyyPrescriptionVO.setIdcard(isEmty(jsonObject.getString("IDCARD")));
                wlyyPrescriptionVO.setCardNo(isEmty(jsonObject.getString("CARDNO")));
                wlyyPrescriptionVO.setSsc(isEmty(jsonObject.getString("SSC")));
                wlyyPrescriptionVO.setDoctor(isEmty(jsonObject.getString("DOCTOR")));
                wlyyPrescriptionVO.setDoctorName(isEmty(jsonObject.getString("DOCTORNAME")));
                wlyyPrescriptionVO.setStatus(jsonObject.getInteger("STATUS"));
                wlyyPrescriptionVO.setMkFailReason(isEmty(jsonObject.getString("MKFAILREASON")));
                wlyyPrescriptionVO.setMkTime(DateUtil.strToDate(isEmty(jsonObject.getString("MKTIME"))));
                wlyyPrescriptionVO.setPrescribeTime(DateUtil.strToDate(isEmty(jsonObject.getString("PRESCRIBETIME"))));
                wlyyPrescriptionVO.setPrescribeReason(isEmty(jsonObject.getString("PRESCRIBEREASON")));
                wlyyPrescriptionVO.setPayTime(DateUtil.strToDate(isEmty(jsonObject.getString("PAYTIME"))));
                wlyyPrescriptionVO.setDosageTime(DateUtil.strToDate(isEmty(jsonObject.getString("DOSAGETIME"))));
                wlyyPrescriptionVO.setFinishTime(DateUtil.strToDate(isEmty(jsonObject.getString("FINISHTIME"))));
                wlyyPrescriptionVO.setDept(isEmty(jsonObject.getString("DEPT")));
                wlyyPrescriptionVO.setDeptName(isEmty(jsonObject.getString("DEPTNAME")));
                wlyyPrescriptionVO.setHospital(isEmty(jsonObject.getString("HOSPITAL")));
                wlyyPrescriptionVO.setHospitalName(isEmty(jsonObject.getString("HOSPITALNAME")));
                wlyyPrescriptionVO.setConsult(isEmty(jsonObject.getString("CONSULT")));
                wlyyPrescriptionVO.setDispensaryType(isEmty(jsonObject.getString("DISPENSARYTYPE"))!=null?Integer.parseInt(isEmty(jsonObject.getString("DISPENSARYTYPE"))):null);
                wlyyPrescriptionVO.setReason(isEmty(jsonObject.getString("REASON")));
                wlyyPrescriptionVO.setDiseaseImg(isEmty(jsonObject.getString("DISEASEIMG")));
                wlyyPrescriptionVO.setRemark(isEmty(jsonObject.getString("REMARK")));
                wlyyPrescriptionVO.setCancelReason(isEmty(jsonObject.getString("CANCELREASON")));
                wlyyPrescriptionVO.setCaCertData(isEmty(jsonObject.getString("CACERTDATA")));
                wlyyPrescriptionVO.setCaMessage(isEmty(jsonObject.getString("CAMESSAGE")));
                wlyyPrescriptionVO.setDigitalSignNo(isEmty(jsonObject.getString("DIGITALSIGNNO")));
                wlyyPrescriptionVO.setOriginalDataAbstract(isEmty(jsonObject.getString("ORIGINALDATAABSTRACT")));
                wlyyPrescriptionVO.setStrOriginalData(isEmty(jsonObject.getString("STRORIGINALDATA")));
                wlyyPrescriptionVO.setHisDeptCode(isEmty(jsonObject.getString("HISDEPTCODE")));
                wlyyPrescriptionVO.setHisDoctorCode(isEmty(jsonObject.getString("HISDOCTORCODE")));
                wlyyPrescriptionVO.setHisGisterTypeCode(isEmty(jsonObject.getString("HISGISTERTYPECODE")));
                wlyyPrescriptionVO.setHisRateTypeCode(isEmty(jsonObject.getString("HISRATETYPECODE")));
                wlyyPrescriptionVO.setHisHospital(isEmty(jsonObject.getString("HISHOSPITAL")));
                wlyyPrescriptionVO.setHisRegisterFee(isEmty(jsonObject.getString("HISREGISTERFEE"))!=null?Integer.parseInt(isEmty(jsonObject.getString("HISREGISTERFEE"))):null);
                wlyyPrescriptionVO.setPayStatus(isEmty(jsonObject.getString("PAYSTATUS"))!=null?Integer.parseInt(isEmty(jsonObject.getString("PAYSTATUS"))):null);
                //TODO 快递数据
                wlyyPrescriptionVO.setDispUser(isEmty(jsonObject.getString("DISPUSER")));
                wlyyPrescriptionVO.setDispUserName(isEmty(jsonObject.getString("DISPUSERNAME")));
                wlyyPrescriptionVO.setDispDate(DateUtil.strToDate(isEmty(jsonObject.getString("DISPDATE"))));
                //诊断
                String disagnosisUrl = entranceUrlLocal+"getOutpatientDiagnosis?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+"&realOrder="+jsonObject.getString("REALORDER");
                String disagnosisResponse = httpClientUtil.get(disagnosisUrl,"GBK");
                logger.info("诊断disagnosisResponse:"+disagnosisResponse);
                JSONObject object1 = JSONObject.parseObject(disagnosisResponse);
                if (object1.getString("status").equalsIgnoreCase("200")){
                    JSONArray jsonArray = JSONArray.parseArray(object1.getString("obj")).getJSONArray(0);
                    logger.info("诊断"+jsonArray.toJSONString());
                    List<WlyyPrescriptionDiagnosisVO> prescriptionDiagnosisVOS = new ArrayList<>();
                    for (int j=0;j<jsonArray.size();j++){
                        JSONObject disagnosisJson = jsonArray.getJSONObject(j);
                        WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = new WlyyPrescriptionDiagnosisVO();
                        prescriptionDiagnosisVO.setCode(isEmty(disagnosisJson.getString("DIAGNOSECODE")));
                        prescriptionDiagnosisVO.setName(isEmty(disagnosisJson.getString("DIAGNOSENAME")));
                        prescriptionDiagnosisVO.setType(isEmty(disagnosisJson.getString("DIAGNOSETYPE"))==null?null:Integer.parseInt(disagnosisJson.getString("DIAGNOSETYPE")));
                        prescriptionDiagnosisVOS.add(prescriptionDiagnosisVO);
                    }
                    wlyyPrescriptionVO.setDiagnosisVOs(prescriptionDiagnosisVOS);
                }
                String infoUrl = entranceUrlLocal+"getOutpatientDrugInfo?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+"&realOrder="+jsonObject.getString("REALORDER");
                String infoResponse = httpClientUtil.get(infoUrl,"GBK");
                logger.info("药品infoResponse:"+infoResponse);
                JSONObject infoObject = JSONObject.parseObject(infoResponse);
                if (infoObject.getString("status").equalsIgnoreCase("200")) {
                    JSONArray infoArray = JSONArray.parseArray(infoObject.getString("obj")).getJSONArray(0);
                    //药品
                    List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOList = new ArrayList<>();
                    for (int j=0;j<infoArray.size();j++){
                        WlyyPrescriptionInfoVO prescriptionInfoVO = new WlyyPrescriptionInfoVO();
                        JSONObject infoJson = infoArray.getJSONObject(j);
                        prescriptionInfoVO.setDrugNo(isEmty(infoJson.getString("DRUGNO")));
                        prescriptionInfoVO.setDrugName(isEmty(infoJson.getString("DRUGNAME")));
                        prescriptionInfoVO.setDispDeposite(isEmty(infoJson.getString("DISPDEPOSITE")));
                        prescriptionInfoVO.setDosage(isEmty(infoJson.getString("DOSAGE")));
                        prescriptionInfoVO.setQuantity(isEmty(infoJson.getString("QUANTITY")));
                        prescriptionInfoVO.setUnit(isEmty(infoJson.getString("UNIT")));
                        prescriptionInfoVO.setUnitName(isEmty(infoJson.getString("UNITNAME")));
                        prescriptionInfoVO.setPackUnitName(isEmty(infoJson.getString("PACKUNITNAME")));
                        prescriptionInfoVO.setPackUnit(isEmty(infoJson.getString("PACKUNIT")));
                        prescriptionInfoVO.setUsageCode(isEmty(infoJson.getString("USAGECODE")));
                        prescriptionInfoVO.setUsageName(isEmty(infoJson.getString("USAGENAME")));
                        prescriptionInfoVO.setSupplyCode(isEmty(infoJson.getString("SUPPLYCODE")));
                        prescriptionInfoVO.setSupplyName(isEmty(infoJson.getString("SUPPLYNAME")));
                        prescriptionInfoVO.setDays(isEmty(infoJson.getString("DAYS")));
                        prescriptionInfoVO.setFrequency(isEmty(infoJson.getString("FREQUENCY")));
                        prescriptionInfoVO.setSerial(isEmty(infoJson.getString("SERIAL")));
                    /*    prescriptionInfoVO.setGroupNo(isEmty(infoJson.getString("groupNo")));*/
                        prescriptionInfoVO.setSpecification(isEmty(infoJson.getString("SPECIFICATION")));
                        prescriptionInfoVO.setPackRetprice(isEmty(infoJson.getString("PACKRETPRICE"))!=null?Double.parseDouble(isEmty(infoJson.getString("PACKRETPRICE"))):null);
                        prescriptionInfoVO.setHerbalCount(isEmty(infoJson.getString("HERBALCOUNT")));
                        prescriptionInfoVO.setPostCount(isEmty(infoJson.getString("POSTCOUNT")));
                        prescriptionInfoVO.setDel(isEmty(infoJson.getString("DEL"))!=null?Integer.parseInt(infoJson.getString("DEL")):null);
                        prescriptionInfoVO.setComm(infoJson.getString("COMM"));
                        wlyyPrescriptionInfoVOList.add(prescriptionInfoVO);
                        wlyyPrescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOList);
                    }
                }
                //检查检验内容
                String inspectionUrl = entranceUrlLocal+"getOutpatientCheckTestInfo?registerSn="+registerSn+"&patNo="+patNo+"&admNo="+admNo+"&realOrder="+jsonObject.getString("REALORDER");
                String inspectionResponse = httpClientUtil.get(inspectionUrl,"GBK");
                logger.info("检查检验内容inspectionResponse:"+inspectionResponse);
                JSONObject inspectionObject = JSONObject.parseObject(inspectionResponse);
                if (inspectionObject.getString("status").equalsIgnoreCase("200")) {
                    List<WlyyInspectionVO> wlyyInspectionVOList = new ArrayList<>();
                    JSONArray inspectionArray = JSONArray.parseArray(inspectionObject.getString("obj")).getJSONArray(0);
                    for (int j=0;j<inspectionArray.size();j++){
                        WlyyInspectionVO inspectionVO = new WlyyInspectionVO();
                        JSONObject inspectionJson = inspectionArray.getJSONObject(j);
                        inspectionVO.setGroupName(isEmty(inspectionJson.getString("GROUPNAME")));
                        inspectionVO.setQuantity(isEmty(inspectionJson.getString("QUANTITYS"))!=null?Integer.parseInt(isEmty(inspectionJson.getString("QUANTITYS"))):null);
                        inspectionVO.setFrequency(isEmty(inspectionJson.getString("FREQUENCYS")));
                        inspectionVO.setParentCode(isEmty(inspectionJson.getString("PARENTCODE")));
                        inspectionVO.setParentName(isEmty(inspectionJson.getString("PARENTCODENAME")));
                        inspectionVO.setCode(isEmty(inspectionJson.getString("CODES")));
                        inspectionVO.setName(isEmty(inspectionJson.getString("NAMES")));
                        inspectionVO.setInformation(isEmty(inspectionJson.getString("INFORMATION")));
                        inspectionVO.setCheckEquip(isEmty(inspectionJson.getString("CHECKEQUIP")));
                        inspectionVO.setCheckPartName(isEmty(inspectionJson.getString("CHECKPARTNAME")));
                        inspectionVO.setCheckPart(isEmty(inspectionJson.getString("CHECKPART")));
                        wlyyInspectionVOList.add(inspectionVO);
                    }
                    wlyyPrescriptionVO.setInspectionVOs(wlyyInspectionVOList);
                }
                prescriptionVOList.add(wlyyPrescriptionVO);
            }
        }
        return prescriptionVOList;
    }
    /**
     *
     * 挂号(调his后台包)
     * @param doctor 医生ID(必填)
     * @param dept 科室编码(必填)
     * @param sickId 病人id
     * @param clinicclass 挂号类别(必填)
     * @return
     */
    public JSONObject registeredOperate(String doctor,String dept,String sickId,String clinicclass,String courierflag){
        JSONObject jsonObject= new JSONObject();
        String response="";
        logger.info("clinicclass:"+clinicclass);
        logger.info("courierflag:"+courierflag);
        String url = entranceUrl+"registered?doctor="+doctor+"&dept="+dept+"&sickId="+sickId+"&clinicclass="+clinicclass+"&courierflag="+courierflag;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            jsonObject = JSONObject.parseObject(object.getString("obj"));
        }
        return jsonObject;
    }
    /**
     * 获取icd10字典
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectIcd10Dict(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getICD10Dict?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("add_code","");
                object1.put("code",jsonObject.getString("ICD10_CODE"));
                object1.put("d_code",jsonObject.getString(""));
                object1.put("name",jsonObject.getString("ICD10_NAME"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("valid_flag",jsonObject.getString("VALID_FLAG"));
                object1.put("icd10_type",jsonObject.getString("ICD10_TYPE"));
                object1.put("icd10_class",jsonObject.getString("ICD10_CLASS"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询药品用药方法
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectMedicineUsed(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getMedicineUsed?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("d_code",jsonObject.getString("ITEM_CODE"));
                object1.put("supply_code",jsonObject.getString("TAKE_MEDICINE_WAYS_CODE"));
                object1.put("supply_name",jsonObject.getString("TAKE_MEDICINE_WAYS_NAME"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("del_flag","");
                object1.put("yb_code","");
                object1.put("yb_name",jsonObject.getString("MEMO"));
                object1.put("print_name",jsonObject.getString("TAKE_MEDICINE_WAYS_NAME"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
//=====================hospital应用调用entrance应用============end=================
//============================hospital业务层==================start====================
    public String isEmty(String str){
        if (str.equalsIgnoreCase("[]")){
            return null;
        }else {
            return str;
        }
    }
//============================hospital业务层==================start====================
//===========================entrance访问hospital============start=======================
    /**
     *
     * @param admNo
     * @param realOrder
     * @return
     */
    public JSONObject getSFExpressInfoToHospital(String admNo, String realOrder) throws Exception {
        String response="";
        String url = hospitalUrl+"open/noLogin/getSFExpressInfoNew";
        Map<String,String> map = new HashedMap();
        map.put("admNo",admNo);
        map.put("realOrder",realOrder);
        logger.info("jsonobject"+map.toString());
        response = httpClientUtil.httpPost(url,map);
        JSONObject object = JSONObject.parseObject(response);
        JSONObject jsonObject1 = new JSONObject();
        logger.info("object"+object.toJSONString());
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            object = JSONObject.parseObject(obj);
            jsonObject1.put("mailNo",object.getString("mailNo"));
        }
        return jsonObject1;
    }
//===========================entrance访问hospital============end=======================
    //===========================杭州逸曜合理用药======================================
@ -2636,7 +1607,7 @@ public class DsyyEntranceService {
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info(apiName+" params:"+params.toString());
        String xml = getDsyyCAWebServiceInfo("CallInterface",params,getCaServiceUrl());
        String xml = getDsyyJhWebServiceInfo("CallInterface",params,getJhServiceUrl());
        wlyyHttpLogDO.setResponse(xml);
        wlyyHttpLogDO.setCreateTime(new Date());
@ -2805,7 +1776,7 @@ public class DsyyEntranceService {
        params.put("msgBody",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("获取医生手写签名图片的base64编码 params:"+params.toString());
        String xml = getDsyyCAWebServiceInfo("CallInterface",params,getCaServiceUrl());
        String xml = getDsyyJhWebServiceInfo("CallInterface",params,getJhServiceUrl());
        wlyyHttpLogDO.setResponse(xml);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setCode(api);

+ 10 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1313,6 +1313,16 @@ public class BaseHospitalRequestMapping {
        public static final String commenSystemMessage  = "/commenSystemMessage";
    }
    public static class DsyyPrescription extends Basic {
        public static final String PREFIX  = "/DsyyPrescription";
        public static final String addMessage  = "/addMessage";
        public static final String updateMessage  = "/updateMessage";
        public static final String searchMessagePageList  = "/searchMessagePageList";
        public static final String queryById  = "/queryById";
        public static final String commenSystemMessage  = "/commenSystemMessage";
    }
    /**
     * 医生锦旗管理
     */

+ 106 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java

@ -1,5 +1,6 @@
package com.yihu.jw.entrance.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -62,6 +64,110 @@ public class DsyyController extends EnvelopRestEndpoint {
        return success(dsyyEntranceService.jdbcSQLQuery(sql));
    }
    @GetMapping(value = "/registered")
    @ApiOperation(value = "挂号(调his后台包)")
    public Envelop registered(@ApiParam(name = "doctor", value = "医生ID(必填)", required = false)
                                    @RequestParam(value = "doctor",required = false)String doctor,
                                    @ApiParam(name = "dept", value = "科室编码(必填)", required = false)
                                    @RequestParam(value = "dept",required = false)String dept,
                                    @ApiParam(name = "sickId", value = "病人id", required = false)
                                        @RequestParam(value = "sickId",required = false)String sickId,
                                    @ApiParam(name = "clinicclass", value = "挂号类别(必填)", required = false)
                                        @RequestParam(value = "clinicclass",required = false)String clinicclass,
                                    @ApiParam(name = "courierflag", value = "courierflag", required = false)
                                        @RequestParam(value = "courierflag",required = false)String courierflag) throws Exception {
        return success(dsyyEntranceService.registered( doctor,dept,sickId,clinicclass,courierflag));
    }
    @GetMapping(value = "/refundConsultation")
    @ApiOperation(value = "发送退号信息到his")
    public Envelop refundConsultation(@ApiParam(name = "applyNo", value = "挂号号", required = false)
                              @RequestParam(value = "applyNo",required = false)String applyNo,
                              @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                              @RequestParam(value = "PayCardNo",required = false)String PayCardNo) throws Exception {
        return success(dsyyEntranceService.refundConsultation(applyNo,PayCardNo));
    }
    @GetMapping(value = "/savePrescriptionToHospital")
    @ApiOperation(value = "互联网医院开处方信息更新到his")
    public Envelop savePrescriptionToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
                                @ApiParam(name = "NullahNumber", value = "挂号流水号", required = false)
                                @RequestParam(value = "NullahNumber",required = false)String NullahNumber,
                                @ApiParam(name = "ApplyDept", value = "执行科室", required = false)
                                @RequestParam(value = "ApplyDept",required = false)String ApplyDept,
                                @ApiParam(name = "ApplyDoctor", value = "开单医生", required = false)
                                @RequestParam(value = "ApplyDoctor",required = false)String ApplyDoctor,
                                @ApiParam(name = "ExecuteDept", value = "执行科室(药房)", required = false)
                                    @RequestParam(value = "ExecuteDept",required = false)String ExecuteDept,
                                @ApiParam(name = "infoJson", value = "药品列表", required = false)
                                    @RequestParam(value = "infoJson",required = false)String infoJson) throws Exception {
        JSONArray array  = JSONArray.parseArray(infoJson);
        List<WlyyPrescriptionInfoDO> prescriptionInfoDOList= new ArrayList<>();
        for (int i=0;i<array.size();i++){
            WlyyPrescriptionInfoDO infoDO = objectMapper.readValue(array.getJSONObject(i).toJSONString(),WlyyPrescriptionInfoDO.class);
            prescriptionInfoDOList.add(infoDO);
        }
        return success(dsyyEntranceService.savePrescriptionToHospital(IoFlag,PayCardNo,NullahNumber,
                ApplyDept,ApplyDoctor,ExecuteDept,prescriptionInfoDOList));
    }
    @GetMapping(value = "/delHisPrescriptionByHisNo")
    @ApiOperation(value = "作废处方")
    public Envelop delHisPrescriptionByHisNo(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
                                @ApiParam(name = "NullahNumber", value = "挂号流水号", required = false)
                                @RequestParam(value = "NullahNumber",required = false)String NullahNumber,
                                @ApiParam(name = "ApplyDept", value = "执行科室", required = false)
                                @RequestParam(value = "ApplyDept",required = false)String ApplyDept,
                                @ApiParam(name = "ApplyDoctor", value = "开单医生", required = false)
                                @RequestParam(value = "ApplyDoctor",required = false)String ApplyDoctor,
                                @ApiParam(name = "ExecuteDept", value = "执行科室(药房)", required = false)
                                @RequestParam(value = "ExecuteDept",required = false)String ExecuteDept,
                                @ApiParam(name = "PresNo", value = "必填,医嘱号", required = false)
                                @RequestParam(value = "PresNo",required = false)String PresNo) throws Exception {
        return success(dsyyEntranceService.delHisPrescriptionByHisNo(IoFlag,PayCardNo,NullahNumber,
                ApplyDept,ApplyDoctor,ExecuteDept,PresNo));
    }
    @GetMapping(value = "/saveDiagnosis")
    @ApiOperation(value = "保存诊断到his")
    public Envelop saveDiagnosis(@ApiParam(name = "applyNo", value = "挂号号", required = false)
                                             @RequestParam(value = "applyNo",required = false)String applyNo,
                                             @ApiParam(name = "DiagnosisName", value = "诊断名称", required = false)
                                             @RequestParam(value = "DiagnosisName",required = false)String DiagnosisName,
                                             @ApiParam(name = "DiagnosisCode", value = "诊断编码", required = false)
                                             @RequestParam(value = "DiagnosisCode",required = false)String DiagnosisCode) throws Exception {
        return success(dsyyEntranceService.saveDiagnosis(applyNo,DiagnosisName,DiagnosisCode));
    }
    @GetMapping(value = "/saveInspectToHospital")
    @ApiOperation(value = "组装检查检验项目参数到his")
    public Envelop saveInspectToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                              @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                              @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                              @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
                                              @ApiParam(name = "NullahNumber", value = "挂号流水号", required = false)
                                              @RequestParam(value = "NullahNumber",required = false)String NullahNumber,
                                              @ApiParam(name = "ApplyDept", value = "执行科室", required = false)
                                              @RequestParam(value = "ApplyDept",required = false)String ApplyDept,
                                              @ApiParam(name = "ApplyDoctor", value = "开单医生", required = false)
                                              @RequestParam(value = "ApplyDoctor",required = false)String ApplyDoctor,
                                              @ApiParam(name = "inspectJson", value = "检查项目", required = false)
                                              @RequestParam(value = "inspectJson",required = false)String inspectJson) throws Exception {
        JSONArray array  = JSONArray.parseArray(inspectJson);
        List<WlyyInspectionDO> inspectionDOList= new ArrayList<>();
        for (int i=0;i<array.size();i++){
            WlyyInspectionDO inspectionDO = objectMapper.readValue(array.getJSONObject(i).toJSONString(),WlyyInspectionDO.class);
            inspectionDOList.add(inspectionDO);
        }
        return success(dsyyEntranceService.saveInspectToHospital(IoFlag,PayCardNo,NullahNumber,
                ApplyDept,ApplyDoctor,inspectionDOList));
    }
}

+ 5 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/DsyyPrescriptionCotroller.java

@ -31,7 +31,7 @@ import java.util.Map;
 * Created by Trick on 2020/3/18.
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.HcyyPrescription.PREFIX)
@RequestMapping(value = BaseHospitalRequestMapping.DsyyPrescription.PREFIX)
@Api(value = "第三医院平台服务", description = "第三医院平台服务", tags = {"第三医院平台服务"})
public class DsyyPrescriptionCotroller extends EnvelopRestEndpoint {
@ -56,11 +56,14 @@ public class DsyyPrescriptionCotroller extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "/getDoctorInfo")
    @GetMapping(value = "/updateDoctor")
    @ApiOperation(value = "同步医生信息", notes = "同步医生信息")
    public ObjEnvelop getDoctorInfo(@ApiParam(name = "idCard", value = "身份证号", required = false)
                                        @RequestParam(value = "idCard",required = false)String idcard)throws Exception{
        return ObjEnvelop.getSuccess("ok",dsyyEntranceService.updateDoctor(idcard));
    }
}

+ 10 - 8
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -143,6 +143,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private HcyyPrescriptionService hcyyPrescriptionService;
    @Autowired
    private MlwyyEntranceService mlwyyEntranceService;
    @Autowired
    private DsyyPrescriptionService dsyyPrescriptionService;
    @Value("${qywx.id}")
    private String qywxId;
@ -646,8 +648,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(tnPrescriptionService.getICD10(pyKey, false));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            return success(hcyyPrescriptionService.selectIcd10Dict(pyKey));
        } if (wxId.equalsIgnoreCase("xm_tasy_wx")) {
            return success(prescriptionService.getICD10(pyKey));
        } if (wxId.equalsIgnoreCase("xm_dsyy_wx")) {
            return success(dsyyPrescriptionService.findIcd10(pyKey));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -680,8 +682,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            logger.info("pyKey"+pyKey);
            return success(hcyyPrescriptionService.selectDrugDict(pyKey,drugNo));
        } else if (wxId.equalsIgnoreCase("xm_tasy_wx")) {
            return success(prescriptionService.getDrugDictionary(drugNo, pyKey, winNo, groupNo));
        } else if (wxId.equalsIgnoreCase("xm_dsyy_wx")) {
            return success(dsyyPrescriptionService.findDrugs(drugNo, pyKey));
        }  else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -702,8 +704,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(tnPrescriptionService.getDrugUse(pyKey, demoFlag));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            return success(hcyyPrescriptionService.selectMedicineUsed(pyKey));
        } else if (wxId.equalsIgnoreCase("xm_tasy_wx")) {
            return success(prescriptionService.getDrugUse(drugNo, pyKey));
        } else if (wxId.equalsIgnoreCase("xm_dsyy_wx")) {
            return success(dsyyPrescriptionService.getDrugUse(pyKey));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -722,8 +724,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(tnPrescriptionService.getDrugFrequency(demoFlag));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            return success(hcyyPrescriptionService.selectFrequencyDict());
        } else if (wxId.equalsIgnoreCase("xm_tasy_wx")) {
            return success(prescriptionService.getDrugFrequency());
        } else if (wxId.equalsIgnoreCase("xm_dsyy_wx")) {
            return success(dsyyPrescriptionService.getDrugFrequency());
        }else {
            return ListEnvelop.getError("尚未开发!");
        }