Przeglądaj źródła

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

LAPTOP-KB9HII50\70708 3 lat temu
rodzic
commit
eab6dee576
42 zmienionych plików z 2369 dodań i 1167 usunięć
  1. 1 1
      business/base-service/pom.xml
  2. 1 1
      business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorHospitalDao.java
  3. 6 1
      business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java
  4. 3 3
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  5. 15 3
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java
  6. 4 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  7. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  8. 1202 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/HcyyPrescriptionService.java
  9. 566 6
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  10. 3 3
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java
  11. 8 1087
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/HcyyEntranceService.java
  12. 26 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  13. 10 0
      business/base-service/src/mqConfig/mqdata/BS15018.json
  14. 38 1
      business/base-service/src/mqConfig/mqdata/MS53001.json
  15. 18 5
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  16. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  17. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDO.java
  18. 13 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/BaseUserMessageDO.java
  19. 15 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionDO.java
  20. 2 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  21. 15 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  22. 1 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  23. 2 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java
  24. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  25. 2 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/activity/ChildActivityEndpoint.java
  26. 33 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  27. 4 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java
  28. 9 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  29. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  30. 48 29
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java
  31. 3 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java
  32. 1 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java
  33. 31 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  34. 16 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleEndpoint.java
  35. 39 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  36. 4 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java
  37. 17 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java
  38. 19 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/message/BaseUserMsgController.java
  39. 3 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/message/SystemMessageController.java
  40. 4 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  41. 129 12
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  42. 16 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

+ 1 - 1
business/base-service/pom.xml

@ -188,7 +188,7 @@
        <dependency>
            <groupId>com.google.code.kaptcha</groupId>
            <artifactId>kaptcha</artifactId>
            <version>RELEASE</version>
            <version>2.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorHospitalDao.java

@ -15,7 +15,7 @@ public interface BaseDoctorHospitalDao extends PagingAndSortingRepository<BaseDo
    List<BaseDoctorHospitalDO> findByDeptCodeAndDoctorCode(String deptCode, String doctorCode);
    @Query("select id from BaseDoctorHospitalDO where doctorCode = ?1")
    @Query("select id from BaseDoctorHospitalDO where doctorCode = ?1 and del=1")
    Set<Object> findIdListByOrgCodeAndDoctorCode(String doctorCode);
    @Query(value = "select org_code as orgCode,org_name as orgName,doctor_duty_code as doctorDutyCode ,doctor_duty_name as doctorDutyName from base_doctor_hospital where doctor_code = ?1 GROUP BY orgCode ORDER BY orgName DESC",nativeQuery = true)

+ 6 - 1
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -673,7 +673,12 @@ public class FileUploadService {
    public boolean isFileFlag(String type){
        List img = new ArrayList(Arrays.asList("jpeg","bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp","xls","xlsx","text/plain"));
        type = type.toLowerCase();
        if (type.contains(".")){
            type = type.substring(type.lastIndexOf("."),type.length()-1);
        }
        logger.info(type);
        List img = new ArrayList(Arrays.asList("jpeg","bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp","xls","xlsx","text/plain","mp4","m4v","avi","ogm","wmv","mpg","webm","ogv","mov","asx","mpeg","image/png"));
        if (!img.contains(type)) {
            return false;
        }

+ 3 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -96,7 +96,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                    return  mixEnvelop;
                }
            }else if (list!=null&&list.size()>0&&basePatientDO==null){
                mixEnvelop.setStatus(408);
                mixEnvelop.setStatus(409);
                mixEnvelop.setMessage("您所添加的家属手机号已被他人占用");
                return  mixEnvelop;
            } else {
@ -213,13 +213,13 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                    System.out.println("眼科转换后的csny"+birth);
                }else {
                    mixEnvelop.setStatus(408);
                    mixEnvelop.setStatus(409);
                    mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
                    return mixEnvelop;
                }
            }else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setStatus(409);
                mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
                return mixEnvelop;
            }

+ 15 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java

@ -199,14 +199,23 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        baseUserMsgContentDao.save(baseUserMsgContentDO);
    }
    //修改留言显示
    @Transactional
    public BaseUserMessageDO updateIsShow(String id,Integer isShow) {
        BaseUserMessageDO baseUserMessageDOS = baseUserMessageDao.findOne(id);
        baseUserMessageDOS.setIsShow(isShow);
        return baseUserMessageDao.save(baseUserMessageDOS);
    }
    //评论留言展示
    public Envelop getMessage(String doctor, String showAll, String showAllType, String beginTime, String endTime,String patient, Integer page, Integer pageSize) {
    public Envelop getMessage(String doctor, String showAll, String showAllType, String beginTime, String endTime,String patient, Integer page, Integer pageSize,Integer isShow) {
        StringBuffer sql = new StringBuffer();
        Map<String,Object> params = new HashedMap();
        sql.append("select t.id as \"id\" ,t.content as \"content\",t.type as \"type\"," +
                "t.sender as \"sender\",t.sender_name as \"sender_name\",t.receiver as \"receiver\"," +
                "t.receiver_name as \"receiver_name\",t.relation_type as \"relation_type\"," +
                "t.relation_code as \"relation_code\",t.relation_name as \"relation_name\",t.status as \"status\",t.update_time as \"update_time\"");
                "t.relation_code as \"relation_code\",t.relation_name as \"relation_name\",t.status as \"status\",t.is_show as \"isShow\",t.update_time as \"update_time\"");
        /*if("xm_ykyy_wx".equals(wxId)){
            flag = true;
            if (flag){
@ -231,6 +240,9 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        if (StringUtils.isNotEmpty(showAllType)) {
            sql.append(" and t.relation_type = " + showAllType);
        }
        if (isShow!=null) {
            sql.append(" and t.is_show = " + isShow);
        }
        if (StringUtils.isNotEmpty(beginTime)) {
            //sql.append(" and t.update_time > '" + beginTime+"'");//DateUtil.stringToDate(beginTime,"yyyy-MM-dd HH:mm:ss")
            if ("xm_ykyy_wx".equals(wxId)) {
@ -302,7 +314,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
                }
            }
            baseUserMsgDO.setIsShow(null==map.get("isShow")?0:Integer.parseInt(map.get("isShow").toString()));
            baseUserMsgDO.setContent(content);
            baseUserMsgDO.setRelationCode(null==map.get("relation_code")?"":map.get("relation_code").toString());
            baseUserMsgDO.setRelationType(null==map.get("relation_type")?0:Integer.valueOf(map.get("relation_type").toString()));

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -99,4 +99,8 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    List<WlyyOutpatientDO> findByDoctorAndOutpatientType(String doctor,String outpatientType,String patient);
    @Query("from WlyyOutpatientDO a where a.consumer = ?1 and a.status in(1,2,3) and a.payStatus =1 order by a.createTime desc")
    List<WlyyOutpatientDO> findOutpatientAndPatient(String patient);
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java

@ -65,6 +65,9 @@ public interface PrescriptionDao extends PagingAndSortingRepository<WlyyPrescrip
    @Query("select a from WlyyPrescriptionDO a where a.createTime>?1 and  a.createTime <?2 and a.status <30 and a.status>=0")
    List<WlyyPrescriptionDO> findListByCheckStatus(Date startTime,Date endTime);
    @Query("select a from WlyyPrescriptionDO a where a.createTime>?1 and  a.createTime <?2 and a.status >=30 ")
    List<WlyyPrescriptionDO> findListBySuccessStatus(Date startTime,Date endTime);
    @Query("select a from WlyyPrescriptionDO a,WlyyDoorPrescriptionDO p where a.id=p.code and p.orderId = ?1 and p.isAfterDoor = ?2  order by a.createTime desc")
    List<WlyyPrescriptionDO> findByOrderIdAndIsAfterDoor(String id, Integer isAfterDoor);
}

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

@ -0,0 +1,1202 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.ca.OauthCaConfigDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.HcyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
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.text.DecimalFormat;
import java.util.*;
/**
 * Created by 海沧医院三方对接业务层
 */
@Service
@Transactional
public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, PrescriptionDao> {
    private static final Logger logger = LoggerFactory.getLogger(HcyyPrescriptionService.class);
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private PatientRegisterDao patientRegisterDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OauthCaConfigDao oauthCaConfigDao;
    @Autowired
    private PrescriptionInfoDao infoDao;
    @Autowired
    private PrescriptionDiagnosisDao diagnosisDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionEmrDao prescriptionEmrDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private HcyyEntranceService hcyyEntranceService;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 获取卡信息 余额
     * @param cardNo 就诊卡
     * @return
     */
    public JSONObject selectCardInfo(String cardNo) throws Exception {
        if (StringUtils.isNoneBlank(cardNo)){
            throw new Exception("卡号不能为空");
        }
        JSONObject jsonObject = new JSONObject();
        String response=hcyyEntranceService.getCardInfo(cardNo);
        if (StringUtils.isNoneBlank(response)){
            JSONArray jsonArray = JSONObject.parseArray(response);
            if (jsonArray!=null&&jsonArray.size()!=0){
                for (int i =0;i<jsonArray.size();i++){
                    JSONObject object = jsonArray.getJSONObject(i);
                    if (object.getString("CARD_STAT").equalsIgnoreCase("正常")){
                        jsonObject = object;
                    }
                }
            }
        }
        return jsonObject;
    }
    /**
     * 保存患者hisid
     * @param patient
     * @return
     */
    public String savePatientMapping(String patient) throws Exception {
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        String mappingCode="";
        String obj =hcyyEntranceService.findPatientCard(patient);
        if (StringUtils.isNoneBlank(obj)){
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            if (array!=null&&array.size()!=0){
                JSONObject object1 = array.getJSONObject(0);
                if (patientMappingDO==null){
                    patientMappingDO = new PatientMappingDO();
                    patientMappingDO.setIdcard(patientDO.getIdcard());
                    patientMappingDO.setPatientName(patientDO.getName());
                    patientMappingDO.setPatient(patientDO.getId());
                    patientMappingDO.setCreateTime(new Date());
                    patientMappingDO.setSource("1");
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }else {
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }
                mappingCode=object1.getString("SICKID");
                patientMappingDO = patientMappingDao.save(patientMappingDO);
            }
        }
        return mappingCode;
    }
    /**
     * 更新患者hisid
     * @param patient
     * @param cardNo
     * @return
     * @throws Exception
     */
    public String updatePatientMapping(String patient,String cardNo) throws Exception {
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        String obj =hcyyEntranceService.findPatientCard(patient);
        if (StringUtils.isNoneBlank(obj)){
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject object1 = array.getJSONObject(i);
                logger.info("判断卡号是否相同:"+object1.getString("CARD_NO")+"cardNo:"+cardNo);
                if (object1.getString("CARD_NO").equalsIgnoreCase(cardNo)){
                    logger.info("卡号相同");
                    if (patientMappingDO==null){
                        patientMappingDO = new PatientMappingDO();
                        patientMappingDO.setIdcard(patientDO.getIdcard());
                        patientMappingDO.setPatientName(patientDO.getName());
                        patientMappingDO.setPatient(patientDO.getId());
                        patientMappingDO.setCreateTime(new Date());
                        patientMappingDO.setSource("1");
                        patientMappingDO.setMappingCode(object1.getString("SICKID"));
                    }else {
                        patientMappingDO.setMappingCode(object1.getString("SICKID"));
                    }
                    patientMappingDO = patientMappingDao.save(patientMappingDO);
                }
            }
        }
        return patientMappingDO.getMappingCode();
    }
    /**
     * 获取门诊就诊记录列表
     * @param patient 居民id
     * @return
     */
    public List<WlyyOutpatientVO> selectOutpatientList(String patient, String startTime, String endTime, String cardNo) throws Exception {
        List<WlyyOutpatientVO> wlyyOutpatientVOList = new ArrayList<>();
        JSONArray array = new JSONArray();
        String response="";
        patient = updatePatientMapping(patient,cardNo);
        String obj = hcyyEntranceService.findOutpatientInfo(patient,null,startTime,endTime);
        if (StringUtils.isNoneBlank(obj)){
            array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                WlyyOutpatientVO outpatientVO = new WlyyOutpatientVO();
                outpatientVO.setAdmNo(isEmty(object.getString("ADMNO")));
                outpatientVO.setOriginAdmNo(isEmty(object.getString("ORIGINADMNO")));
                outpatientVO.setRegisterNo(isEmty(object.getString("REGISTERNO")));
                outpatientVO.setOriginRegisterNo(isEmty(object.getString("ORIGINREGISTERNO")));
                outpatientVO.setDept(isEmty(object.getString("DEPT")));
                outpatientVO.setDeptName(isEmty(object.getString("DEPTNAME")));
                outpatientVO.setPatient(isEmty(object.getString("PATIENT")));
                outpatientVO.setPatientName(isEmty(object.getString("PATIENTNAME")));
                outpatientVO.setDoctor(isEmty(object.getString("DOCTOR")));
                outpatientVO.setDoctorName(isEmty(object.getString("DOCTORNAME")));
                outpatientVO.setIdcard(isEmty(object.getString("IDCARD")));
                outpatientVO.setMjz(isEmty(object.getString("MJZ")));
                outpatientVO.setIcd10(isEmty(object.getString("ICDCODE")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICDNAME")));
                outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("ADMDATE")));
                outpatientVO.setConDate(DateUtil.strToDate(object.getString("CONDATE")));
                outpatientVO.setDescription(isEmty(object.getString("DESCRIPTION")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                outpatientVO.setPatient(patient);
                wlyyOutpatientVOList.add(outpatientVO);
            }
        }
        return wlyyOutpatientVOList;
    }
    /**
     * 获取单条门诊就诊记录
     * @param patient 居民id
     * @param conNo 就诊次数
     * @return
     */
    public WlyyOutpatientVO selectOutpatientInfo(String patient,String conNo) throws Exception {
        WlyyOutpatientVO outpatientVO = new WlyyOutpatientVO();
        JSONArray array = new JSONArray();
        String response="";
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO!=null){
            patient = patientMappingDO.getMappingCode();
        }else {
            patient = savePatientMapping(patient);
        }
        if (StringUtils.isNoneBlank(patient)) {
            String obj = hcyyEntranceService.findOutpatientInfo(patient, conNo, null, null);
            if (StringUtils.isNoneBlank(obj)) {
                array = JSONArray.parseArray(obj).getJSONArray(0);
                if (array != null && array.size() != 0) {
                    JSONObject object = array.getJSONObject(0);
                    outpatientVO.setAdmNo(isEmty(object.getString("ADMNO")));
                    outpatientVO.setOriginAdmNo(isEmty(object.getString("ORIGINADMNO")));
                    outpatientVO.setRegisterNo(isEmty(object.getString("REGISTERNO")));
                    outpatientVO.setOriginRegisterNo(isEmty(object.getString("ORIGINREGISTERNO")));
                    outpatientVO.setDept(isEmty(object.getString("DEPT")));
                    outpatientVO.setDeptName(isEmty(object.getString("DEPTNAME")));
                    outpatientVO.setPatientName(isEmty(object.getString("PATIENTNAME")));
                    outpatientVO.setDoctor(isEmty(object.getString("DOCTOR")));
                    outpatientVO.setDoctorName(isEmty(object.getString("DOCTORNAME")));
                    outpatientVO.setIdcard(isEmty(object.getString("IDCARD")));
                    outpatientVO.setMjz(isEmty(object.getString("MJZ")));
                    outpatientVO.setIcd10(isEmty(object.getString("ICDCODE")));
                    outpatientVO.setIcd10Name(isEmty(object.getString("ICDNAME")));
                    outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("ADMDATE")));
                    outpatientVO.setConDate(DateUtil.strToDate(object.getString("CONDATE")));
                    outpatientVO.setDescription(isEmty(object.getString("DESCRIPTION")));
                    outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                    outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                    outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                    outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                    outpatientVO.setHospitalName("海沧医院");
                    outpatientVO.setHospital("350211A1002");
                    outpatientVO.setSex(patientDO.getSex() + "");
                    outpatientVO.setPatient(patientDO.getId());
                    outpatientVO.setBirthday(patientDO.getBirthday());
                }
            }
        }
        return outpatientVO;
    }
    /**
     * 获取药品字典
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectDrugDict(String spellCode,String drugNo) throws Exception {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetDrugDict(spellCode,drugNo);
        if (StringUtils.isNoneBlank(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("charge_code",jsonObject.getString("PHYSIC_CODE"));
                object1.put("serial","");
                object1.put("group_no","");
                object1.put("drugname",jsonObject.getString("PHYSIC_NAME"));
                object1.put("dosage",jsonObject.getString("DOSE_UNIT"));
                object1.put("MIN_DOSE",jsonObject.getString("MIN_DOSE"));
                object1.put("mini_unit",jsonObject.getString("PHYSIC_UNIT"));
                object1.put("pack_size",jsonObject.getString("PACK_SPEC"));
                object1.put("retprice",jsonObject.getString("RETAIL_PRICE"));
                object1.put("specification",jsonObject.getString("PHYSIC_SPEC"));
                object1.put("pack_retprice",jsonObject.getString("RETAIL_PRICE"));
                object1.put("stock_amount",jsonObject.getString("QUANTITY"));
                object1.put("visible_flag",jsonObject.getString("VALID_FLAG"));
                object1.put("drug_flag",jsonObject.getString("OTC_FLAG"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("pack_unit",jsonObject.getString("PRICE_UNIT"));
                object1.put("manu_name",jsonObject.getString("SUPPLIER_NAME"));
                object1.put("weigh_unit",jsonObject.getString("DOSE_UNIT"));
                object1.put("vol_unit","");
                object1.put("mini_unit_name",jsonObject.getString("PHYSIC_UNIT"));
                DecimalFormat df =new DecimalFormat("0.00");
                Double packSize=Double.parseDouble(jsonObject.get("PACK_SPEC").toString().equals("[]")?"1":jsonObject.getString("PACK_SPEC"));
                Double retprice=Double.parseDouble(jsonObject.get("RETAIL_PRICE").toString().equals("[]")?"0":jsonObject.getString("RETAIL_PRICE"));
                Double miniUnitPrice=0.00;
                if (0.00!=packSize){
                    miniUnitPrice=retprice/packSize;
                }
                object1.put("mini_unit_price",df.format(miniUnitPrice));
                object1.put("pack_unit_name",jsonObject.getString("PRICE_UNIT"));
                object1.put("weigh_unit_name",jsonObject.getString("DOSE_UNIT"));
                object1.put("vol_unit_name","");
                object1.put("win_no","");
                object1.put("jbyw",jsonObject.getString("BASE_PHYSIC_FLAG"));
                object1.put("gwyp","");
                object1.put("bz_dosage",jsonObject.getString("DOSEAGE"));
                object1.put("bz_supply",jsonObject.getString("USAGE"));
                object1.put("bz_supply_name",jsonObject.getString("USAGE"));
                object1.put("bz_unit",jsonObject.getString("DOSEAGE_UNIT"));
                object1.put("bz_unit_name",jsonObject.getString("DOSEAGE_UNIT"));
                object1.put("bz_usage",jsonObject.getString("FREQUENCY"));
                object1.put("bz_usage_name",jsonObject.getString("FREQUENCY"));
                object1.put("QUANTITY",jsonObject.getString("QUANTITY"));
                object1.put("DAY_COUNT",jsonObject.getString("DAY_COUNT"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 获取icd10字典
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectIcd10Dict(String spellCode) throws Exception {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetICD10Dict(spellCode);
        if (StringUtils.isNoneBlank(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 {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetMedicineUsed(spellCode);
        if (StringUtils.isNoneBlank(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;
    }
    /**
     * 获取药品用药频次字典
     * @return
     */
    public JSONArray selectFrequencyDict() throws Exception {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetFrequencyDict();
        if (StringUtils.isNoneBlank(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("DAILY_TIMES",jsonObject.getString("FREQ_COUNT"));
                object1.put("FREQ_CODE",jsonObject.getString("FREQ_DESCRIBE"));
                object1.put("FREQ_DESCRIBE_CODE",jsonObject.getString("FREQ_DESCRIBE_CODE"));
                object1.put("FREQ_DESCRIBE",jsonObject.getString("FREQ_DESCRIBE"));
                object1.put("PHYSIC_NOTUSE_FLAG",jsonObject.getString("PHYSIC_NOTUSE_FLAG"));
                object1.put("FREQ_NAME",jsonObject.getString("FREQ_MEMO"));
                object1.put("INSUR_FREQ_DESCRIBE",jsonObject.getString("INSUR_FREQ_DESCRIBE"));
                object1.put("FREQ_INTERVAL",jsonObject.getString("FREQ_INTERVAL"));
                object1.put("FREQ_INTERVAL_UNIT",jsonObject.getString("FREQ_INTERVAL_UNIT"));
                object1.put("DEFAULT_SCHEDULE",jsonObject.getString("DEFAULT_SCHEDULE"));
                object1.put("EXECUTE_TIME_FLAG",jsonObject.getString("EXECUTE_TIME_FLAG"));
                object1.put("DAY_FLAG",jsonObject.getString("DAY_FLAG"));
                object1.put("WEEK_FLAG",jsonObject.getString("WEEK_FLAG"));
                object1.put("WEEK_1",jsonObject.getString("WEEK_1"));
                object1.put("WEEK_2",jsonObject.getString("WEEK_2"));
                object1.put("WEEK_3",jsonObject.getString("WEEK_3"));
                object1.put("WEEK_4",jsonObject.getString("WEEK_4"));
                object1.put("WEEK_5",jsonObject.getString("WEEK_5"));
                object1.put("WEEK_6",jsonObject.getString("WEEK_6"));
                object1.put("WEEK_7",jsonObject.getString("WEEK_7"));
                object1.put("SPELL_CODE",jsonObject.getString("SPELL_CODE"));
                object1.put("VALID_FLAG",jsonObject.getString("VALID_FLAG"));
                object1.put("WEEKLY_TIMES","");
                object1.put("IS_OP_IP","");
                object1.put("HOSP_CODE","");
                object1.put("FREQ_SP",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 获取历史病历
     * @param patientId 病人id
     * @param eventNo 病人住院号
     * @return
     */
    public List<WlyyPrescriptionEmrDO> selectHistoryEmr(String patientId,String eventNo) throws Exception {
        List<WlyyPrescriptionEmrDO> wlyyPrescriptionEmrDOList = new ArrayList<>();
        String obj = hcyyEntranceService.SelectEmrInfo(patientId,patientId);
        if("[[]]".equalsIgnoreCase(obj)||"[]".equalsIgnoreCase(obj)||StringUtils.isBlank(obj)){
            return null;
        }else {
            logger.info("obj:" + obj);
            JSONArray array = JSONArray.parseArray(obj.replace("[]", "\"\"")).getJSONArray(0);
            logger.info("arrayResponse:" + array.toJSONString());
            for (int i = 0; i < array.size(); i++) {
                JSONObject jsonObject = array.getJSONObject(i);
                logger.info("jsonObject:" + jsonObject);
                WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = new WlyyPrescriptionEmrDO();
                wlyyPrescriptionEmrDO.setComplaint(null == jsonObject.get("CHIEF_COMPLAINT") ? "" : jsonObject.get("CHIEF_COMPLAINT").toString());
                wlyyPrescriptionEmrDO.setMedicalHistory(null == jsonObject.get("PRESENT_ILLNESS") ? "" : jsonObject.get("PRESENT_ILLNESS").toString());
                wlyyPrescriptionEmrDO.setPastHistory(null == jsonObject.get("PAST_HISTORY") ? "" : jsonObject.get("PAST_HISTORY").toString());
                wlyyPrescriptionEmrDO.setPhysicalExamination(null == jsonObject.get("PHYSICAL_EXAMINATION") ? "" : jsonObject.get("PHYSICAL_EXAMINATION").toString());
                wlyyPrescriptionEmrDO.setAssistExamination(null == jsonObject.get("OBSERVE_RESULT") ? "" : jsonObject.get("OBSERVE_RESULT").toString());
                wlyyPrescriptionEmrDO.setAllergicHistory(null == jsonObject.get("ALLERGY_HISTORY") ? "" : jsonObject.get("ALLERGY_HISTORY").toString());
                wlyyPrescriptionEmrDO.setPopularHistory(null == jsonObject.get("EPIDEMIOLOGICAL") ? "" : jsonObject.get("EPIDEMIOLOGICAL").toString());
                wlyyPrescriptionEmrDO.setSpecialHistory(null == jsonObject.get("SPECIAL_HISTORY") ? "" : jsonObject.get("SPECIAL_HISTORY").toString());
                wlyyPrescriptionEmrDOList.add(wlyyPrescriptionEmrDO);
            }
        }
        return wlyyPrescriptionEmrDOList;
    }
    /**
     * 获取门诊下所有处方信息---内网调下
     * @param registerSn 流水号
     * @param patNo 居民id
     * @param admNo 住院唯一号
     * @param realOrder 处方号
     * @return
     */
    public List<WlyyPrescriptionVO> selectOriginPrescriptionListLocal(String registerSn, String patNo, String admNo, String realOrder) throws Exception {
        List<WlyyPrescriptionVO> prescriptionVOList = new ArrayList<>();
        String response="";
        String params = "";
        if (StringUtils.isNoneBlank(realOrder)){
            params +="&realOrder="+realOrder;
        }
        logger.info("处方request:"+registerSn+"=="+patNo+"==="+admNo+"===="+realOrder);
        String obj = hcyyEntranceService.getOriginPrescriptionList(registerSn,patNo,admNo,realOrder,null,null);
        if (StringUtils.isNoneBlank(obj)){
            JSONArray array = new JSONArray();
            array = JSONArray.parseArray(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 disagnosisObj = hcyyEntranceService.getOutpatientDiagnosis(registerSn,patNo,admNo,realOrder,null,null);
                JSONArray jsonArray = JSONArray.parseArray(disagnosisObj).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 infoObj = hcyyEntranceService.getOutpatientDrugInfo(registerSn,patNo,admNo,realOrder,null,null);
                JSONArray infoArray = JSONArray.parseArray(infoObj).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 inspectObj = hcyyEntranceService.getOutpatientCheckTestInfo(registerSn,patNo,admNo,realOrder,null,null);
                logger.info("检查检验内容inspectionResponse:"+inspectObj);
                List<WlyyInspectionVO> wlyyInspectionVOList = new ArrayList<>();
                JSONArray inspectionArray = JSONArray.parseArray(inspectObj).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;
    }
    /**
     * 查询病历文书html信息
     * @param bstrEmrID
     * @return
     */
    public String selectBrowseSingleEMR(String bstrEmrID) throws Exception {
      String obj = hcyyEntranceService.BrowseSingleEMR(bstrEmrID);
        if(StringUtils.isNoneBlank(obj)){
            return obj;
        }else {
            return "获取失败";
        }
    }
    /**
     * 获取历史病历
     * @param patientId
     * @param eventNo
     * @return
     * @throws Exception
     */
    public JSONArray selectHistoryEmrFromEntrance(String patientId,String eventNo) throws Exception {
        String response="";
        JSONArray jsonArray = new JSONArray();
        PatientMappingDO mappingDO = patientMappingDao.findByPatient(patientId);
        String patient = null;
        if (mappingDO!=null){
            patient = mappingDO.getMappingCode();
        }
        String obj = hcyyEntranceService.SelectEmrInfo(patient,eventNo);
        if("[[]]".equalsIgnoreCase(obj)||"[]".equalsIgnoreCase(obj)||StringUtils.isBlank(obj)){
            return null;
        }else {
            logger.info("obj:"+obj);
            JSONArray array = JSONArray.parseArray(obj.replace("[]","\"\"")).getJSONArray(0);
            logger.info("arrayResponse:"+array.toJSONString());
            for (int j=0;j<array.size();j++){
                JSONObject object1 = array.getJSONObject(j);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("DEPT_NAME",object1.getString("DEPT_NAME"));
                jsonObject.put("TREAT_DATE_TIME",DateUtil.getYyyymmddhhmmss(DateUtil.strToDateLong(object1.getString("VISIT_TIME"))));
                jsonObject.put("OPID",object1.getString("EMR_ID"));
                String firstFlag = object1.getString("FIRST_FLAG");
                if (firstFlag.equalsIgnoreCase("复诊")){
                    jsonObject.put("TREAT_DOCTOR_NAME",object1.getString("RETURN_DOC_SIGN"));
                }else if (firstFlag.equalsIgnoreCase("初诊")){
                    jsonObject.put("TREAT_DOCTOR_NAME",object1.getString("DOCTOR_SIGNATURE"));
                }
                jsonArray.add(jsonObject);
            }
            return jsonArray;
        }
    }
    /**
     * 查询历次就诊门诊病历文书
     * @param templateId
     * @param patientId 病人id
     * @param eventNo 病人住院号
     * @return
     */
    public String selectHistoryEmrRecord(String templateId,String patientId,String eventNo) throws Exception {
        String obj = hcyyEntranceService.SelectEmrDispRecord(templateId,patientId,eventNo);
        if(StringUtils.isNoneBlank(obj)){
            return obj;
        }else {
            return "获取失败";
        }
    }
    /**
     * 保存电子病历
     * @param prescriptionId 处方id
     * @return
     * @throws Exception
     */
    public String  saveEmrToEntrance(String prescriptionId,String baseSign) throws Exception {
        Map<String,String> params = new HashedMap();
        WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = new WlyyPrescriptionEmrDO();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
        JSONObject paramRequest = new JSONObject();
        if (null!=wlyyPrescriptionDO){
            paramRequest.put("patientName",wlyyPrescriptionDO.getPatientName());
            PatientMappingDO patientMappingDO =  patientMappingDao.findByPatient(wlyyPrescriptionDO.getPatientCode());
            BasePatientDO basePatientDO = patientDao.findById(wlyyPrescriptionDO.getPatientCode());
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if(null!=patientMappingDO){
                paramRequest.put("patientid",patientMappingDO.getMappingCode());
            }
            //获取医生编号
            BaseDoctorDO doctorDO = doctorDao.findById(wlyyOutpatientDO.getDoctor());
            String operatorId = null;
            if (doctorDO!=null){
                String obj = hcyyEntranceService.selectDoctorInfo(doctorDO.getIdcard());
                JSONArray array = JSONArray.parseArray(obj);
                if (array!=null&&array.size()!=0){
                    JSONObject jsonObject = array.getJSONObject(0);
                    operatorId = jsonObject.getString("staffNo");
                }
            }
            if(null!=doctorMappingDO){
                paramRequest.put("operatorid",operatorId);
                paramRequest.put("operatorname",wlyyPrescriptionDO.getDoctorName());
            }
            paramRequest.put("type","2");
            wlyyPrescriptionEmrDO =  prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
            if (null!=wlyyPrescriptionEmrDO){
                paramRequest.put("id",wlyyPrescriptionEmrDO.getId());
                params.put("emrInfo", JSON.toJSONString(wlyyPrescriptionEmrDO));
            }
            if (null!=basePatientDO){
                paramRequest.put("patientAge",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientsex",IdCardUtil.getSexForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientName",basePatientDO.getName());
                paramRequest.put("patientClan","0"); }
            if (null!=wlyyOutpatientDO){
                paramRequest.put("deptCode",wlyyOutpatientDO.getDeptName());
                paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
                paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
            }
            paramRequest.put("templateid","1158");
            paramRequest.put("catalogid","50");
            paramRequest.put("emrtype","93");
            paramRequest.put("emrtitle","互联网医院");
            if (StringUtils.isNoneBlank(baseSign)){
                //UploadVO uploadVO=fileUploadService.uploadImagesBase64(baseSign,fastdfs_file_url);
                //paramRequest.put("baseSign","https://ih.xmheart.com/fastdfs/"+uploadVO.getFullUri());
                paramRequest.put("baseSign",baseSign);
            }
        }
        params.put("jsonInfo",paramRequest.toJSONString());
        JSONObject jsonObject = JSONObject.parseObject(paramRequest.toJSONString());
        String obj = hcyyEntranceService.returnEmrHtmlByHLW(jsonObject,wlyyPrescriptionEmrDO);
        logger.info("保存电子病历"+obj);
        if (obj.contains("error")||obj.contains("ERROR")){
            return "faild";
        }else {
            return "success";
        }
    }
    /**
     * 查询检查部位
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectCheckBody(String spellCode) throws Exception {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetCheckBody(spellCode);
        if (StringUtils.isNoneBlank(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("name",jsonObject.getString("NAME"));
                object1.put("code",jsonObject.getString("CODE"));
                object1.put("data",jsonObject.getString("DATA"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                object1.put("wb_code",jsonObject.getString("WBZX_CODE"));
                object1.put("sequence",jsonObject.getString("SEQUENCE"));
                object1.put("valid",jsonObject.getString("VALID"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检查项目
     * @param spellCode 拼音码或药品名字
     * @return
     */
    public JSONArray selectExamApply(String spellCode) throws Exception {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetExamApply(spellCode);
        if (StringUtils.isNoneBlank(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("name",jsonObject.getString("ITEM_NAME"));
                object1.put("code",jsonObject.getString("ITEM_CODE"));
                object1.put("type",jsonObject.getString("ITEM_CLASS"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("charge_amount",jsonObject.getString("FACT_PRICE"));
                object1.put("child_amount",jsonObject.getString("CHILD_PRICE"));
                object1.put("charge_unit",jsonObject.getString("UNIT"));
                object1.put("wb_code",jsonObject.getString("FIVE_PEN_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检验项目
     * @param spellCode 拼音码或药品名字
     * @return
     */
    public JSONArray selectLisApply(String spellCode) throws Exception {
        JSONArray jsonArray = new JSONArray();
        String obj = hcyyEntranceService.GetLisApply(spellCode);
        if (StringUtils.isNoneBlank(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("name",jsonObject.getString("ITEM_NAME"));
                object1.put("code",jsonObject.getString("ITEM_CODE"));
                object1.put("type",jsonObject.getString("ITEM_CLASS"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("charge_amount",jsonObject.getString("FACT_PRICE"));
                object1.put("child_amount",jsonObject.getString("CHILD_PRICE"));
                object1.put("charge_unit",jsonObject.getString("UNIT"));
                object1.put("wb_code",jsonObject.getString("FIVE_PEN_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 检查检验项目同步his
     * @param
     * @return
     */
    public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,List<WlyyInspectionDO> wlyyInspectionS) throws Exception {
        Map resultMap=new HashMap();
        String obj = hcyyEntranceService.saveInspectToHospital(IoFlag,PayCardNo,NullahNumber,ApplyDept,ApplyDoctor,wlyyInspectionS);
        JSONObject rootObject = JSONObject.parseObject(obj);
        if (null!=rootObject&&"0".equalsIgnoreCase(rootObject.getString("code"))){
            resultMap.put("success",rootObject.getString("success"));
            resultMap.put("code",rootObject.getString("code"));
            resultMap.put("msg",rootObject.getString("msg"));
            JSONObject dataObj = JSONObject.parseObject(rootObject.getString("data"));
            if (null!=dataObj){
                JSONObject presDetailobj = JSONObject.parseObject(dataObj.getString("PresDetail"));
                resultMap.put("msg",presDetailobj.getString("PresNo"));
                logger.info("his医嘱号:"+presDetailobj.getString("PresNo"));
            }
        }else if(null!=rootObject&&!"0".equalsIgnoreCase(rootObject.getString("code"))){
            resultMap.put("success",rootObject.getString("success"));
            resultMap.put("code",rootObject.getString("code"));
            resultMap.put("msg",rootObject.getString("msg"));
        }else {
            resultMap.put("success","obj转化失败");
        }
        return resultMap;
    }
    /**
     * 保存处方到entrance
     * @param ioFlag 门诊住院标志
     * @param payCardNo 就诊卡号
     * @param nullahNumber 挂号流水号
     * @param applyDept 执行科室
     * @param applyDoctor 开单医生
     * @param executeDept 执行科室(药房)
     * @return
     * @throws Exception
     */
    public JSONObject savePrescriptionToEntrance(String ioFlag,String payCardNo,String nullahNumber,String applyDept,String applyDoctor,String executeDept,List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS) throws Exception {
        JSONObject jsonObject = new JSONObject();
        ObjectMapper mapper = new ObjectMapper();
        String obj = hcyyEntranceService.savePrescriptionToHospital(ioFlag,payCardNo,nullahNumber,applyDept,applyDoctor,executeDept,wlyyPrescriptionInfoDOS);
        logger.info("开方成功"+obj);
        if (StringUtils.isNoneBlank(obj)){
            jsonObject = JSONObject.parseObject(obj);
        }
        return jsonObject;
    }
    /**
     * 保存诊断到entrance
     * @param applyNo 必填,流水号
     * @param diagnosisName 必填,诊断名称
     * @param diagnosisCode 诊断代码
     * @return
     * @throws Exception
     */
    public JSONObject saveDiagnosisToEntrance(String applyNo,String diagnosisName,String diagnosisCode) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String obj = hcyyEntranceService.saveDiagnosis(applyNo,diagnosisName,diagnosisCode,null,null,null,null);
        if (StringUtils.isNoneBlank(obj)){
            jsonObject = JSONObject.parseObject(obj);
        }
        return jsonObject;
    }
    /**
     * 发送退号信息到entrance
     * @param applyNo 必填,流水号
     * @param payCardNo 必填,卡号
     * @return
     * @throws Exception
     */
    public JSONObject refundConsultationToEntrance(String applyNo,String payCardNo) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String obj = hcyyEntranceService.refundConsultation(applyNo,payCardNo);
        if (StringUtils.isNoneBlank(obj)){
            jsonObject = JSONObject.parseObject(obj);
        }
        return jsonObject;
    }
    /**
     * 退号
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public JSONObject refundRegisterNo(String outpatientId) throws Exception {
        JSONObject object = new JSONObject();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO!=null){
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
            if (StringUtils.isNoneBlank(outpatientDO.getRegisterNo())){
                String obj = hcyyEntranceService.refundConsultation(outpatientDO.getRegisterNo(), outpatientDO.getCardNo());
                if (StringUtils.isNoneBlank(obj)){
                    object = JSONObject.parseObject(obj);
                }
                logger.info("退号结果 res: " + object.toString());
                if (object!=null&&object.getString("code").equalsIgnoreCase("0")){
                    WlyyPatientRegisterDO wlyyPatientRegisterDO = patientRegisterDao.findByRegisterNo(outpatientDO.getRegisterNo());
                    wlyyPatientRegisterDO.setDel(0);
                    patientRegisterDao.save(wlyyPatientRegisterDO);
                    outpatientDO.setHisStatus(-1);
                    outpatientDao.save(outpatientDO);
                }
                //保存日志
                WlyyHttpLogDO log = new WlyyHttpLogDO();
                log.setCode("refundregisterOutPatient");
                log.setName("退号");
                log.setPatient(outpatientDO.getPatient());
                log.setDoctor(outpatientDO.getDoctor());
                log.setResponse(object.toString());
                log.setRequest("outPatientId=" + outpatientId + "&doctor=" + outpatientDO.getDoctor());
                log.setStatus(object.getString("code"));
                log.setCreateTime(new Date());
                wlyyHttpLogDao.save(log);
            }
        }
        return  object;
    }
    /**
     * 删除处方信息
     * @param realOrder his处方号
     * @return
     * @throws Exception
     */
    public JSONObject deletePrescriptionToEntrance(String realOrder) throws Exception {
        Map<String,String> params = new HashedMap();
        JSONObject jsonObject = new JSONObject();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findByRealOrder(realOrder);
        if (null!=wlyyPrescriptionDO){
            params.put("IoFlag","0");
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            String PayCardNo = "";
            String ApplyDept = "";
            String NullahNumber = "";
            if (null!=wlyyOutpatientDO){
                PayCardNo=wlyyOutpatientDO.getCardNo();
                ApplyDept=wlyyOutpatientDO.getDept();
                NullahNumber=wlyyOutpatientDO.getRegisterNo();
            }
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            String ApplyDoctor = "";
            if (null!=doctorMappingDO){
                ApplyDoctor=doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode();
            }
            String ExecuteDept="50100";
            String PresNo=realOrder;
            String obj = hcyyEntranceService.delHisPrescriptionByHisNo("0",PayCardNo,NullahNumber,ApplyDept,ApplyDoctor,ExecuteDept,PresNo);
            logger.info("删除处方信息"+obj);
            jsonObject = JSONObject.parseObject(obj);
        }
        return jsonObject;
    }
    /**
     * 挂号接口
     * @param outPatientId
     * @param doctor
     * @return
     */
    public JSONObject registerOutPatient(String outPatientId, String doctor){
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        List<WlyyPrescriptionExpressageDO> expressageDOS =prescriptionExpressageDao.findByOutpatientId(outPatientId);
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        if (doctorMappingDO == null) {
            throw new RuntimeException("未找到医生映射信息");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
        if (patientMappingDO==null){
            throw new RuntimeException("未找到居民映射信息");
        }
        //查找居民当天挂号记录
        String date = DateUtil.dateToStr(new Date(), "yyyy-MM-dd");
        List<WlyyPatientRegisterDO> patientRegisterDOs = patientRegisterDao.findByPatientAndDateAndDoctorAndDel(outpatientDO.getPatient(), date, doctor,1);
        if (patientRegisterDOs != null && patientRegisterDOs.size() > 0) {
            WlyyPatientRegisterDO registerDO = patientRegisterDOs.get(0);
            //判断是否已经挂号,如果已经挂号
            if (StringUtils.isNotBlank(registerDO.getRegisterNo())) {
                JSONObject res = new JSONObject();
                res.put("@RESULT", "0");
                logger.info("已经挂号 res: " + res.toString());
                //更新挂号流水号
                outpatientDO.setConNo(registerDO.getConNo());
                outpatientDO.setRegisterNo(registerDO.getRegisterNo());
                outpatientDO.setAdmDate(registerDO.getCreateTime());
                outpatientDO.setAdmNo(registerDO.getRegisterNo());
                outpatientDao.save(outpatientDO);
                return res;
            }
        }
        String doctorFlag =  doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode();
        String courierflag = "N";
        if (expressageDOS!=null&&expressageDOS.size()!=0){
            WlyyPrescriptionExpressageDO expressageDO = expressageDOS.get(0);
            if (expressageDO.getOneselfPickupFlg()!=null&&expressageDO.getOneselfPickupFlg()==1){
                courierflag="N";
            }else if (expressageDO.getOneselfPickupFlg()!=null&&expressageDO.getOneselfPickupFlg()==0){
                courierflag="Y";
            }
        }
        String chargeType = "";
        if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getTwfzChargeType();
        }else if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getSpfzChargeType();
        }else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getTwzxChargeType();
        }else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getSpzxChargeType();
        }else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())&&"3".equalsIgnoreCase(outpatientDO.getType())){
            chargeType = doctorDO.getJyzxChargeType();
        }else if ("2".equalsIgnoreCase(outpatientDO.getOutpatientType())){
            chargeType = doctorDO.getXtfzChargeType();
        }else {
            chargeType = doctorDO.getChargeType();
        }
        JSONObject res = null;
        try {
            String obj = hcyyEntranceService.registered(doctorFlag,outpatientDO.getDept(),patientMappingDO.getMappingCode(),chargeType,courierflag);
            if (StringUtils.isNoneBlank(obj)){
                res = JSONObject.parseObject(obj);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject result = new JSONObject();
        logger.info("挂号结果 res: " + res.toString());
        String rsCode = "";
        String serialNo = "";
        if (res!=null){
            JSONObject object = res.getJSONObject("returnContents");
            serialNo = object.getString("registerNo");
            if (object!=null){
                result.put("@RESULT", "0");
                result.put("@MSG","挂号成功!");
                rsCode = object.getString("registerNo");
            }
        }else {
            result.put("@RESULT", "-1");
            result.put("@MSG","挂号失败");
        }
        if (StringUtils.isNoneBlank(rsCode)) {
            //存储挂号号
            outpatientDO.setRegisterNo(serialNo);
            outpatientDO.setAdmDate(new Date());
            outpatientDO.setAdmNo(serialNo);
            logger.info("挂号流水 registerNo: ");
            outpatientDao.save(outpatientDO);
            //存储就诊记录
            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
            // 存储挂号医生与挂号科室
            registerDO.setDoctor(outpatientDO.getDoctor());
            registerDO.setDoctorName(outpatientDO.getDoctorName());
            registerDO.setDept(outpatientDO.getDept());
            registerDO.setDeptName(outpatientDO.getDeptName());
            registerDO.setDel(1);
            registerDO.setPatient(outpatientDO.getPatient());
            registerDO.setPatientName(outpatientDO.getPatientName());
            //挂号流水号与挂号次数
            registerDO.setRegisterNo(serialNo);
            registerDO.setCreateTime(new Date());
            registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
            patientRegisterDao.save(registerDO);
        } else if ("-2".equals(rsCode)) {
            outpatientDO.setRegisterNo(serialNo);
            outpatientDO.setAdmDate(new Date());
            outpatientDO.setAdmNo(serialNo);
            logger.info("挂号流水 registerNo: " + serialNo );
            outpatientDao.save(outpatientDO);
            //存储就诊记录
            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
            registerDO.setDoctor(outpatientDO.getDoctor());
            registerDO.setDoctorName(outpatientDO.getDoctorName());
            registerDO.setDept(outpatientDO.getDept());
            registerDO.setDeptName(outpatientDO.getDeptName());
            registerDO.setDel(1);
            registerDO.setPatient(outpatientDO.getPatient());
            registerDO.setPatientName(outpatientDO.getPatientName());
            registerDO.setRegisterNo(serialNo);
            registerDO.setCreateTime(new Date());
            registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
            patientRegisterDao.save(registerDO);
        }
        //保存日志
        WlyyHttpLogDO log = new WlyyHttpLogDO();
        log.setCode("registerOutPatient");
        log.setName("挂号");
        log.setPatient(outpatientDO.getPatient());
        log.setDoctor(doctor);
        log.setResponse(res.toString());
        log.setRequest("outPatientId=" + outPatientId + "&doctor=" + doctor);
        log.setStatus("1");
        log.setCreateTime(new Date());
        wlyyHttpLogDao.save(log);
        return result;
    }
    public String isEmty(String str){
        if (str.equalsIgnoreCase("[]")){
            return null;
        }else {
            return str;
        }
    }
}

+ 566 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -120,6 +120,8 @@ import com.ylzinfo.ehc.trans.TransRequest;
import com.ylzinfo.ehc.trans.TransResponse;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.HikariPoolMXBean;
import jxl.format.*;
import jxl.format.VerticalAlignment;
import jxl.write.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@ -143,6 +145,7 @@ import org.springframework.util.CollectionUtils;
import javax.management.JMX;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.io.DataOutput;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.Boolean;
@ -1371,6 +1374,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            JSONObject data = new JSONObject();
            data.put("name", outpatient.getPatientName());
            data.put("consumerName",outpatient.getConsumerName());
            data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
            data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
            data.put("recipeType", prescriptionDO.getDispensaryType());
@ -2723,13 +2727,39 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if (StringUtils.isNotBlank(infoJsons)) {
                //药品
                List<WlyyPrescriptionInfoDO> infoDOs = (List<WlyyPrescriptionInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(infoJsons, WlyyPrescriptionInfoDO.class);
                String name ="";
                Integer j = 0;
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("drugInfo");
                Boolean flag = false;
                String dictValues = "";
                if (hospitalSysDictDO!=null){
                    String dictValue = hospitalSysDictDO.getDictValue();
                    if (StringUtils.isNoneBlank(dictValue)){
                        flag = true;
                        dictValues=dictValue;
                    }
                }
                logger.info("flag:"+flag);
                for (WlyyPrescriptionInfoDO info : infoDOs) {
                    if (flag){
                        if (dictValues.contains(info.getDrugNo())){
                            j++;
                            name+=info.getDrugName()+",";
                        }
                    }
                    info.setDel(1);
                    info.setPrescriptionId(prescription.getId());
                }
                logger.info("j:"+j+"===name:"+name);
                if (j>=1){
                    List<WlyyPrescriptionExpressageDO> expressageDOList = prescriptionExpressageDao.findByOutpatientId(outPatientId);
                    if (expressageDOList!=null&&expressageDOList.size()!=0){
                        WlyyPrescriptionExpressageDO expressageDO = expressageDOList.get(0);
                        if (expressageDO.getOneselfPickupFlg()==0){
                            throw new Exception("当前"+j+"种药品:"+name+"不支持快递方式取药,请重新编辑提交!");
                        }
                    }
                }
                //保存药品信息
                prescriptionInfoDao.save(infoDOs);
@ -2879,6 +2909,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                result1.put("mes", "开方提交成功");
                result1.put("prescriptionId",prescription.getId());
                return result1;
            }else if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
                Double price = prescription.getDrugFee();
                businessOrderService.recharge(prescription.getId(), "处方收费", "4", "处方收费", prescription.getPatientCode(), prescription.getPatientName(), prescription.getDoctor(), price);
                //上传his开方
                //sendHisDiagnosis(jsonData, outpatientDO, prescription)
                //zsSynHis(prescription.getId());
                //同步检查检验
                List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescription.getId(),1);
                if (inspectionDOS != null && inspectionDOS.size() > 0) {
                    syCheckParam(outpatientDO.getId());
                }
                Map<String, Object> result1 = new HashedMap();
                result1.put("code", 1);
                result1.put("mes", "开方提交成功");
                result1.put("prescriptionId",prescription.getId());
                return result1;
            }else {
                result.put("code", 1);
                result.put("mes", "诊断完成");
@ -3881,6 +3927,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        ws.addCell(label);
    }
@ -4397,6 +4447,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
            }
            //医生关注
            if(StringUtils.isNotBlank(patient)){
                List<WlyyOutpatientDO> wlyyOutpatientDOList= outpatientDao.findOutpatientAndPatient(patient);
                if (wlyyOutpatientDOList != null && wlyyOutpatientDOList.size() > 0) {
                    rs.put("isComment", "1");
                } else {
                    rs.put("isComment", "0");
                }
            }
            //专家咨询
            String zjCountsql = "SELECT id AS \"id\" FROM wlyy_consult_team WHERE doctor='" + doctor + "' AND (type=1 OR type=15)";
@ -4771,6 +4832,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            try {
                data.put("name", wlyyOutpatientDO.getPatientName());
                data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("question", wlyyOutpatientDO.getIcd10Name());
@ -8264,6 +8326,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setSenderName(outpatient.getPatientName());
                systemMessageDO.setRelationCode(outpatient.getId());
                data.put("name", outpatient.getPatientName());
                data.put("consumerName",outpatient.getConsumerName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                data.put("question", outpatient.getDescription());
@ -8309,6 +8372,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setSenderName(outpatient.getPatientName());
                systemMessageDO.setRelationCode(outpatient.getId());
                data.put("name", outpatient.getPatientName());
                data.put("consumerName",outpatient.getConsumerName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                data.put("question", outpatient.getDescription());
@ -8352,6 +8416,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                data.put("name", outpatient.getPatientName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                data.put("consumerName",outpatient.getConsumerName());
                data.put("question", outpatient.getDescription());
                data.put("msg", msg);
                systemMessageDO.setData(data.toString());
@ -8406,6 +8471,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                data.put("name", outpatient.getPatientName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                data.put("consumerName",outpatient.getConsumerName());
                data.put("question", outpatient.getDescription());
                data.put("msg", msg);
                data.put("type", type);
@ -8444,6 +8510,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            try {
                data.put("name", patientDO.getName());
                data.put("age", IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
                data.put("consumerName",outpatient.getConsumerName());
                data.put("gender", IdCardUtil.getSexForIdcard_new(patientDO.getIdcard()));
                data.put("question", consultTeamDo.getSymptoms());
                data.put("msg", msg);
@ -9931,7 +9998,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
                gender = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            }
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
            String conditiaon="";
            if (wlyyOutpatientDO!=null){
                data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                if (!wlyyOutpatientDO.getConsumerName().equalsIgnoreCase(prescriptionDO.getPatientName())){
                    conditiaon = "("+wlyyOutpatientDO.getConsumerName()+"代问诊)";
                }
            }
            data.put("name", prescriptionDO.getPatientName());
            data.put("age", age);
            data.put("gender", gender);
            data.put("outpatientId", prescriptionDO.getOutpatientId());
@ -9940,7 +10016,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setType("9");
                systemMessageDO.setTitle("审方通过");
                data.put("message", "审方通过");
                data.put("message", "您为" + prescriptionDO.getPatientName() + "(" + age + "岁 " + gender + ")开具的处方已审核通过。");
                data.put("message", "您为" + prescriptionDO.getPatientName() +conditiaon+"(" + age + "岁 " + gender + ")开具的处方已审核通过。");
                /**
                 *  * @param userName      推送人姓名
                 * @param idCard        推送人身份证
@ -9966,7 +10042,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setType("8");
                systemMessageDO.setTitle("审方退回");
                data.put("message", "审方退回");
                data.put("message", "您为" + prescriptionDO.getPatientName() + "(" + age + "岁 " + gender + ")开具的处方被审方退回,请尽快处理");
                data.put("message", "您为" + prescriptionDO.getPatientName() +conditiaon+ "(" + age + "岁 " + gender + ")开具的处方被审方退回,请尽快处理");
            }
            systemMessageDO.setData(data.toString());
            systemMessageService.saveMessage(systemMessageDO);
@ -11055,7 +11131,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " p.check_status as \"checkStatus\"," +
                " p.id as \"id\"," +
                " p.status as \"status\"," +
                " p.check_reason as \"checkReason\" " +
                " p.check_reason as \"checkReason\", " +
                " o.consumer as \"consumer\", "+
                " o.consumer_name as \"consumerName\" "+
                " from wlyy_prescription p left join wlyy_outpatient o on p.outpatient_id  = o.id" +
                " where  1=1 ";
        if (StringUtils.isNotBlank(keyWord)){
@ -13712,4 +13790,486 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    /**
     * 收入日报
     */
    public List<Map<String, Object>> selectPriceTotal(String startTime,String endTime){
        List<Map<String, Object>> mapList = new ArrayList<>();
        Map<String, Object> params = new HashedMap();
        String sql =" SELECT ORDER_CATEGORY as \"orderCategory\",\"SUM\"(PAY_PRICE)/100 as \"payPrice\" FROM BASE_BUSINESS_ORDER_PAY WHERE ORDER_CATEGORY IN(1,2,3,4)  and STATUS=1 ";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time <= to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time <='"+endTime+"' ";
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time >='"+startTime+"' ";
        }
        sql+=" GROUP BY ORDER_CATEGORY ";
        logger.info("sql="+sql);
        mapList = hibenateUtils.createSQLQuery(sql, params);
        return mapList;
    }
    /**
     * 收入日报导出
     * @param os
     * @param ls
     * @param startTime
     * @param endTime
     * @throws Exception
     */
    public void pushListWritePriceTotal(OutputStream os, List<Map<String, Object>> ls,String startTime,String endTime) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"互联网医院收入日报表","","","","",""};//
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            String[] header1 = {"汇总日期:"+startTime+"至"+endTime,"","","","",""};//
            int k1 = 0;
            for (String h : header1) {
                addCell(ws, 1, k1, h);//表名,行,列,header
                k1++;
            }
            String j1="";
            String j2="";
            String j3 ="";
            String j4="";
            String price1 = "";
            String price2 = "";
            String price3 = "";
            String price4 = "";
            for (Map<String, Object> m : ls) {
                if (m.get("orderCategory").toString().equalsIgnoreCase("1")){
                    j1 = m.get("orderCategory").toString();
                    price1=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("2")){
                    j2 = m.get("orderCategory").toString();
                    price2=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("3")){
                    j3 = m.get("orderCategory").toString();
                    price3=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("4")){
                    j4 = m.get("orderCategory").toString();
                    price4=m.get("payPrice").toString();
                }
            }
            DecimalFormat df = new DecimalFormat("#.00");
            Double price5 =Double.parseDouble(price2)+Double.parseDouble(price3);
            String[] header2 = {"咨询费",df.format(Double.parseDouble(price1)),"复诊费",df.format(price5),"处方费",df.format(Double.parseDouble(price4))};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 2, k2, h);//表名,行,列,header
                k2++;
            }
            ws.mergeCells(0,0,5,0);
            ws.mergeCells(0,1,5,1);
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    /**
     * 预交金日报
     */
    public List<Map<String, Object>> selectCardPriceTotal(String startTime,String endTime){
        List<Map<String, Object>> mapList = new ArrayList<>();
        Map<String, Object> params = new HashedMap();
        String sql =" SELECT ORDER_CATEGORY as \"orderCategory\",\"SUM\"(PAY_PRICE) as \"payPrice\" FROM BASE_BUSINESS_ORDER_PAY WHERE ORDER_CATEGORY IN(5)  and STATUS=1 ";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time <= to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time <='"+endTime+"' ";
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time >='"+startTime+"' ";
        }
        sql+=" GROUP BY ORDER_CATEGORY ";
        logger.info("sql="+sql);
        mapList = hibenateUtils.createSQLQuery(sql, params);
        return mapList;
    }
    /**
     * 预交金日报
     * @param os
     * @param ls
     * @param startTime
     * @param endTime
     * @throws Exception
     */
    public void pushListCardPriceTotal(OutputStream os, List<Map<String, Object>> ls,String startTime,String endTime) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"互联网医院预缴金日报表","","","",""};//
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            String[] header1 = {"汇总日期:"+startTime+"至"+endTime,"","","",""};//
            int k1 = 0;
            for (String h : header1) {
                addCell(ws, 1, k1, h);//表名,行,列,header
                k1++;
            }
            String[] header2 = {"上期结存","本期发生","充值HIS系统","合计","本期期末余额"};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 2, k2, h);//表名,行,列,header
                k2++;
            }
            String j1="";
            String price1 = "";
            for (Map<String, Object> m : ls) {
                if (m.get("orderCategory").toString().equalsIgnoreCase("5")){
                    j1 = m.get("orderCategory").toString();
                    price1=m.get("payPrice").toString();
                }
            }
            DecimalFormat df = new DecimalFormat("#.00");
            String[] header3 = {"无",startTime+"至"+endTime,df.format(Double.parseDouble(price1)),df.format(Double.parseDouble(price1)),"无"};//
            int k3 = 0;
            for (String h : header3) {
                addCell(ws, 3, k3, h);//表名,行,列,header
                k3++;
            }
            ws.mergeCells(0,0,4,0);
            ws.mergeCells(0,1,4,1);
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    /**
     * 资金分部报表
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map<String, Object>> selectTotal(String startTime,String endTime){
        List<Map<String, Object>> mapList = new ArrayList<>();
        Map<String, Object> params = new HashedMap();
        String sql =" SELECT ORDER_CATEGORY as \"orderCategory\",\"SUM\"(PAY_PRICE)/100 as \"payPrice\" FROM BASE_BUSINESS_ORDER_PAY WHERE ORDER_CATEGORY IN(1,2,3,4,5)  and STATUS=1 ";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time <= to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time <='"+endTime+"' ";
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time >='"+startTime+"' ";
        }
        sql+=" GROUP BY ORDER_CATEGORY ";
        logger.info("sql="+sql);
        mapList = hibenateUtils.createSQLQuery(sql, params);
        for (Map<String, Object> map:mapList){
            if (map.get("orderCategory")!=null){
                if(map.get("orderCategory").toString().equalsIgnoreCase("5")){
                    logger.info("payPrice"+Double.parseDouble(map.get("payPrice").toString())+"===="+Double.parseDouble(map.get("payPrice").toString())*100);
                    map.put("payPrice",Double.parseDouble(map.get("payPrice").toString())*100);
                }
            }
        }
        return mapList;
    }
    /**
     * 资金分部报表导出
     * @param os
     * @param ls
     * @param startTime
     * @param endTime
     * @throws Exception
     */
    public void pushListTotal(OutputStream os, List<Map<String, Object>> ls,String startTime,String endTime) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"资金分布报表","","","",""};//
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            String[] header1 = {"汇总日期:"+startTime+"至"+endTime,"","","",""};//
            int k1 = 0;
            for (String h : header1) {
                addCell(ws, 1, k1, h);//表名,行,列,header
                k1++;
            }
            String[] header2 = {"本期发生","互联网医院","充值HIS系统","药店","问诊费"};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 2, k2, h);//表名,行,列,header
                k2++;
            }
            String j1="";
            String j2="";
            String j3 ="";
            String j4="";
            String j5="";
            String price1 = "";
            String price2 = "";
            String price3 = "";
            String price4 = "";
            String price5="";
            for (Map<String, Object> m : ls) {
                if (m.get("orderCategory").toString().equalsIgnoreCase("1")){
                    j1 = m.get("orderCategory").toString();
                    price1=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("2")){
                    j2 = m.get("orderCategory").toString();
                    price2=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("3")){
                    j3 = m.get("orderCategory").toString();
                    price3=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("4")){
                    j4 = m.get("orderCategory").toString();
                    price4=m.get("payPrice").toString();
                }else if (m.get("orderCategory").toString().equalsIgnoreCase("5")){
                    j5 = m.get("orderCategory").toString();
                    price5=m.get("payPrice").toString();
                }
            }
            Double price6 = Double.parseDouble(price1)+Double.parseDouble(price2)+Double.parseDouble(price3);//问诊费
            Double price7 = Double.parseDouble(price4);//处方费
            Double price8 = Double.parseDouble(price5);//就诊卡充值
            DecimalFormat df = new DecimalFormat("#.00");
            String[] header3 = {startTime+"至"+endTime,df.format(price6+price7+price8)+"",df.format(price8)+"",df.format(price7)+"",df.format(price6)+""};//
            int k3 = 0;
            for (String h : header3) {
                addCell(ws, 3, k3, h);//表名,行,列,header
                k3++;
            }
            ws.mergeCells(0,0,4,0);
            ws.mergeCells(0,1,4,1);
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    /**
     * 药品汇总表
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map<String, Object>> selectDoctorTotal(String startTime,String endTime){
        List<Map<String, Object>> mapList = new ArrayList<>();
        Map<String, Object> params = new HashedMap();
        String sql =" SELECT DOCTOR as \"doctor\",DOCTOR_NAME as \"doctorName\",SUM(DRUG_FEE) as \"fee\" FROM WLYY_PRESCRIPTION WHERE STATUS>=30 ";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time <= to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time <='"+endTime+"' ";
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            sql+=" and create_time >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        } else {
            sql+=" and create_time >='"+startTime+"' ";
        }
        sql+=" GROUP BY DOCTOR,DOCTOR_NAME  ";
        logger.info("sql="+sql);
        mapList = hibenateUtils.createSQLQuery(sql, params);
        return mapList;
    }
    /**
     * 药品汇总表导出
     * @param os
     * @param ls
     * @param startTime
     * @param endTime
     * @throws Exception
     */
    public void pushListDoctorTotal(OutputStream os, List<Map<String, Object>> ls,String startTime,String endTime) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"互联网医院药品汇总表","",""};//
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            String[] header1 = {"汇总日期:"+startTime+"至"+endTime,"",""};//
            int k1 = 0;
            for (String h : header1) {
                addCell(ws, 1, k1, h);//表名,行,列,header
                k1++;
            }
            String[] header2 = {"诊疗小组","进货金额","零售金额"};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 2, k2, h);//表名,行,列,header
                k2++;
            }
            int i = 3;
            String n = " ";
            DecimalFormat df = new DecimalFormat("#.00");
            for (Map<String, Object> m : ls) {
                addCell(ws, i, 0,m.get("doctorName")!=null?m.get("doctorName").toString():n);
                addCell(ws, i, 1, "无");
                addCell(ws, i, 2, m.get("fee")!=null?df.format(Double.parseDouble(m.get("fee").toString())):n);
                i++;
            }
            ws.mergeCells(0,0,2,0);
            ws.mergeCells(0,1,2,1);
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    /**
     * 药品明细表
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map<String, Object>> selectDrugTotal(String startTime,String endTime){
        List<Map<String, Object>> mapList = new ArrayList<>();
        Date stateDate = DateUtil.strToDateLong(startTime);
        Date endDate = DateUtil.strToDateLong(endTime);
        List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findListBySuccessStatus(stateDate,endDate);
        for (WlyyPrescriptionDO prescriptionDO:prescriptionDOList){
            com.alibaba.fastjson.JSONObject objectString = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.toJSON(prescriptionDO);
            List<WlyyPrescriptionInfoDO> infoDOList = prescriptionInfoDao.findByPrescriptionId(prescriptionDO.getId(),1);
            objectString.put("info",infoDOList);
            Map<String,Object> map = new HashedMap();
            map.put("prescription",objectString);
            mapList.add(map);
        }
        return mapList;
    }
    /**
     * 药品明细表导出
     * @param os
     * @param ls
     * @param startTime
     * @param endTime
     * @throws Exception
     */
    public void pushListDrugTotal(OutputStream os, List<Map<String, Object>> ls,String startTime,String endTime) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"互联网医院药品明细表","","","","","","","",""};//
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            String[] header1 = {"汇总日期:"+startTime+"至"+endTime,"","","","","","","",""};//
            int k1 = 0;
            for (String h : header1) {
                addCell(ws, 1, k1, h);//表名,行,列,header
                k1++;
            }
            String[] header2 = {"患者名称","订单药品","规格","总量","单位","进价","零售价","进货金额","零售金额","发药时间","审方时间","开方时间","开方医生"};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 2, k2, h);//表名,行,列,header
                k2++;
            }
            int i = 3;
            String n = " ";
            for (Map<String, Object> m : ls) {
                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(m.get("prescription").toString());
                com.alibaba.fastjson.JSONArray array = jsonObject.getJSONArray("info");
                int j = i;
                addCell(ws, i, 0,jsonObject.get("patientName")!=null?jsonObject.get("patientName").toString():n);
                DecimalFormat df = new DecimalFormat("#.00");
                if(array!=null&&array.size()!=0){
                    for (int z=0;z<array.size();z++){
                        com.alibaba.fastjson.JSONObject object = array.getJSONObject(z);
                        addCell(ws, i, 1, object.get("drugName")!=null?object.get("drugName").toString():n);
                        addCell(ws, i, 2, object.get("specification")!=null?object.get("specification").toString():n);
                        addCell(ws, i, 3, object.get("quantity")!=null?object.get("quantity").toString():n);
                        addCell(ws, i, 4, object.get("packUnitName")!=null?object.get("packUnitName").toString():n);
                        addCell(ws, i, 5, "无");
                        addCell(ws, i, 6, object.get("packRetprice")!=null?object.get("packRetprice").toString():n);
                        addCell(ws, i, 7, "无");
                        if (object.get("quantity")!=null){
                            Double quantity = Double.parseDouble(object.get("quantity").toString());
                            Double packRetprice = Double.parseDouble(object.get("packRetprice").toString());
                            addCell(ws, i, 8,df.format(packRetprice*quantity));
                        }else {
                            addCell(ws, i, 8,"");
                        }
                        addCell(ws, i, 9,jsonObject.get("dispDate")!=null?DateUtil.stampToString(jsonObject.get("dispDate").toString()):n);
                        addCell(ws, i, 10,jsonObject.get("checkTime")!=null?DateUtil.stampToString(jsonObject.get("checkTime").toString()):n);
                        addCell(ws, i, 11,jsonObject.get("createTime")!=null?DateUtil.stampToString(jsonObject.get("createTime").toString()):n);
                        addCell(ws, i, 12,jsonObject.get("doctorName")!=null?jsonObject.get("doctorName").toString():n);
                        i++;
                    }
                    ws.mergeCells(0,j,0,i-1);
                }else {
                    i++;
                }
            }
            ws.mergeCells(0,0,12,0);
            ws.mergeCells(0,1,12,1);
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
}

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

@ -625,16 +625,16 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            JSONObject map = mapList.getJSONObject(i);
            JSONObject object = new JSONObject();
            object.put("charge_code",map.get("ypxh"));
            object.put("drugname",map.get("ypmc"));
            object.put("drugname",map.get("ypmc2"));
            object.put("specification",map.get("yfgg"));
            object.put("pack_unit",map.get("yfdw"));
            object.put("pack_unit_name",map.get("yfdw"));
            object.put("yfdw",map.get("yfdw"));
            if (map.get("yfsb")!=null){
                String yfsb = map.get("yfsb").toString();
                if (yfsb.equalsIgnoreCase("9")){
                if (yfsb.equalsIgnoreCase("3")){
                    object.put("yfsb",3);//药房识别 3思明6五缘
                }else if (yfsb.equalsIgnoreCase("10")){
                }else if (yfsb.equalsIgnoreCase("6")){
                    object.put("yfsb",6);//药房识别 3思明6五缘
                }
            }

+ 8 - 1087
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/HcyyEntranceService.java

@ -857,6 +857,7 @@ public class HcyyEntranceService {
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("getOriginPrescriptionList json:"+json);
        return json;
    }
@ -2189,7 +2190,7 @@ public class HcyyEntranceService {
    }
    /**
     * 获取心脏医院token
     * 获取海沧医院微信token
     * @return
     * @throws Exception
     */
@ -2380,194 +2381,6 @@ public class HcyyEntranceService {
    /**
     * 获取卡信息
     * @param cardNo 就诊卡
     * @return
     */
    public JSONObject selectCardInfo(String cardNo){
        JSONArray array = new JSONArray();
        String response="";
        String url = entranceUrl+"getCardInfo?cardNo="+cardNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONObject jsonObject = new JSONObject();
        if (object.getInteger("status")==200){
            array = JSONArray.parseArray(object.getString("obj")).getJSONArray(0);
            if (array!=null&&array.size()!=0){
                jsonObject = array.getJSONObject(0);
            }
        }
        return jsonObject;
    }
    public String savePatientMapping(String patient){
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        String response="";
        String idCard = patientDO.getIdcard();
        String url = entranceUrl+"findPatientCard?idCard="+idCard;
        String mappingCode="";
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            if (array!=null&&array.size()!=0){
                JSONObject object1 = array.getJSONObject(0);
                if (patientMappingDO==null){
                    patientMappingDO = new PatientMappingDO();
                    patientMappingDO.setIdcard(patientDO.getIdcard());
                    patientMappingDO.setPatientName(patientDO.getName());
                    patientMappingDO.setPatient(patientDO.getId());
                    patientMappingDO.setCreateTime(new Date());
                    patientMappingDO.setSource("1");
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }else {
                    patientMappingDO.setMappingCode(object1.getString("SICKID"));
                }
                mappingCode=object1.getString("SICKID");
                patientMappingDO = patientMappingDao.save(patientMappingDO);
            }
        }
        return mappingCode;
    }
    public String updatePatientMapping(String patient,String cardNo){
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        String response="";
        String idCard = patientDO.getIdcard();
        String url = entranceUrl+"findPatientCard?idCard="+idCard;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        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 object1 = array.getJSONObject(i);
                logger.info("判断卡号是否相同:"+object1.getString("CARD_NO")+"cardNo:"+cardNo);
                if (object1.getString("CARD_NO").equalsIgnoreCase(cardNo)){
                    logger.info("卡号相同");
                    if (patientMappingDO==null){
                        patientMappingDO = new PatientMappingDO();
                        patientMappingDO.setIdcard(patientDO.getIdcard());
                        patientMappingDO.setPatientName(patientDO.getName());
                        patientMappingDO.setPatient(patientDO.getId());
                        patientMappingDO.setCreateTime(new Date());
                        patientMappingDO.setSource("1");
                        patientMappingDO.setMappingCode(object1.getString("SICKID"));
                    }else {
                        patientMappingDO.setMappingCode(object1.getString("SICKID"));
                    }
                    patientMappingDO = patientMappingDao.save(patientMappingDO);
                }
            }
        }
        return patientMappingDO.getMappingCode();
    }
    /**
     * 获取门诊就诊记录列表
     * @param patient 居民id
     * @return
     */
    public List<WlyyOutpatientVO> selectOutpatientList(String patient,String startTime,String endTime,String cardNo) throws Exception {
        List<WlyyOutpatientVO> wlyyOutpatientVOList = new ArrayList<>();
        JSONArray array = new JSONArray();
        String response="";
        patient = updatePatientMapping(patient,cardNo);
        String url = entranceUrl+"findOutpatientInfo?patient="+patient+"&startTime="+startTime+"&endTime="+endTime;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject jsonObject = JSONObject.parseObject(response);
        if (jsonObject.getInteger("status")==200){
            array = JSONArray.parseArray(jsonObject.getString("obj")).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                WlyyOutpatientVO outpatientVO = new WlyyOutpatientVO();
                outpatientVO.setAdmNo(isEmty(object.getString("ADMNO")));
                outpatientVO.setOriginAdmNo(isEmty(object.getString("ORIGINADMNO")));
                outpatientVO.setRegisterNo(isEmty(object.getString("REGISTERNO")));
                outpatientVO.setOriginRegisterNo(isEmty(object.getString("ORIGINREGISTERNO")));
                outpatientVO.setDept(isEmty(object.getString("DEPT")));
                outpatientVO.setDeptName(isEmty(object.getString("DEPTNAME")));
                outpatientVO.setPatient(isEmty(object.getString("PATIENT")));
                outpatientVO.setPatientName(isEmty(object.getString("PATIENTNAME")));
                outpatientVO.setDoctor(isEmty(object.getString("DOCTOR")));
                outpatientVO.setDoctorName(isEmty(object.getString("DOCTORNAME")));
                outpatientVO.setIdcard(isEmty(object.getString("IDCARD")));
                outpatientVO.setMjz(isEmty(object.getString("MJZ")));
                outpatientVO.setIcd10(isEmty(object.getString("ICDCODE")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICDNAME")));
                outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("ADMDATE")));
                outpatientVO.setConDate(DateUtil.strToDate(object.getString("CONDATE")));
                outpatientVO.setDescription(isEmty(object.getString("DESCRIPTION")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                outpatientVO.setPatient(patient);
                wlyyOutpatientVOList.add(outpatientVO);
            }
        }
        return wlyyOutpatientVOList;
    }
    /**
     * 获取单条门诊就诊记录
     * @param patient 居民id
     * @param conNo 就诊次数
     * @return
     */
    public WlyyOutpatientVO selectOutpatientInfo(String patient,String conNo){
        WlyyOutpatientVO outpatientVO = new WlyyOutpatientVO();
        JSONArray array = new JSONArray();
        String response="";
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO!=null){
            patient = patientMappingDO.getMappingCode();
        }else {
            patient = savePatientMapping(patient);
        }
        String url = entranceUrl+"findOutpatientInfo?patient="+patient+"&conNo="+conNo;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject jsonObject = JSONObject.parseObject(response);
        if (jsonObject.getInteger("status")==200){
            array = JSONArray.parseArray(jsonObject.getString("obj")).getJSONArray(0);
            if (array!=null&&array.size()!=0){
                JSONObject object = array.getJSONObject(0);
                outpatientVO.setAdmNo(isEmty(object.getString("ADMNO")));
                outpatientVO.setOriginAdmNo(isEmty(object.getString("ORIGINADMNO")));
                outpatientVO.setRegisterNo(isEmty(object.getString("REGISTERNO")));
                outpatientVO.setOriginRegisterNo(isEmty(object.getString("ORIGINREGISTERNO")));
                outpatientVO.setDept(isEmty(object.getString("DEPT")));
                outpatientVO.setDeptName(isEmty(object.getString("DEPTNAME")));
                outpatientVO.setPatientName(isEmty(object.getString("PATIENTNAME")));
                outpatientVO.setDoctor(isEmty(object.getString("DOCTOR")));
                outpatientVO.setDoctorName(isEmty(object.getString("DOCTORNAME")));
                outpatientVO.setIdcard(isEmty(object.getString("IDCARD")));
                outpatientVO.setMjz(isEmty(object.getString("MJZ")));
                outpatientVO.setIcd10(isEmty(object.getString("ICDCODE")));
                outpatientVO.setIcd10Name(isEmty(object.getString("ICDNAME")));
                outpatientVO.setAdmDate(DateUtil.strToDate(object.getString("ADMDATE")));
                outpatientVO.setConDate(DateUtil.strToDate(object.getString("CONDATE")));
                outpatientVO.setDescription(isEmty(object.getString("DESCRIPTION")));
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                outpatientVO.setHospitalName("厦门大学附属心血管病医院");
                outpatientVO.setHospital("350211A5010");
                outpatientVO.setSex(patientDO.getSex()+"");
                outpatientVO.setPatient(patientDO.getId());
                outpatientVO.setBirthday(patientDO.getBirthday());
            }
        }
        return outpatientVO;
    }
    public Map<String,Object> updatePreStatusLocal(String admNo,String realOrder,String status) throws Exception {
        Map<String,Object> map = new HashedMap();
@ -2655,185 +2468,6 @@ public class HcyyEntranceService {
    }
    /**
     * 获取门诊下所有处方信息
     * @param registerSn 流水号
     * @param patNo 居民id
     * @param admNo 住院唯一号
     * @param realOrder 处方号
     * @return
     */
    public List<WlyyPrescriptionVO> selectOriginPrescriptionList(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 = entranceUrl+"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 = entranceUrl+"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 = object1.getJSONArray("obj").getJSONArray(0);
                    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 = entranceUrl+"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 = infoObject.getJSONArray("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?0.0:infoJson.getDouble("PACKRETPRICE"));
                        prescriptionInfoVO.setHerbalCount(isEmty(infoJson.getString("HERBALCOUNT")));
                        prescriptionInfoVO.setPostCount(isEmty(infoJson.getString("POSTCOUNT")));
                        prescriptionInfoVO.setDel(isEmty(infoJson.getString("DEL"))==null?1:infoJson.getInteger("DEL"));
                        prescriptionInfoVO.setComm(infoJson.getString("COMM"));
                        wlyyPrescriptionInfoVOList.add(prescriptionInfoVO);
                        wlyyPrescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOList);
                    }
                }
                //检查检验内容
                String inspectionUrl = entranceUrl+"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 = inspectionObject.getJSONArray("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);
                }
                try {
                    List<WlyyPrescriptionEmrDO> listEmr = selectHistoryEmr(patNo,"");
                    if (null!=listEmr&&listEmr.size()>0){
                        wlyyPrescriptionVO.setWlyyPrescriptionEmrDO(listEmr.get(0));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                prescriptionVOList.add(wlyyPrescriptionVO);
            }
        }
        return prescriptionVOList;
    }
    /**
@ -3068,81 +2702,15 @@ public class HcyyEntranceService {
    }
    /**
     * 获取药品字典
     * 查询药品用药方法
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectDrugDict(String spellCode,String drugNo) throws Exception {
    public JSONArray selectMedicineUsed(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getDrugDict?spellCode="+spellCode+"&drugNo="+drugNo;
        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("charge_code",jsonObject.getString("PHYSIC_CODE"));
                object1.put("serial","");
                object1.put("group_no","");
                object1.put("drugname",jsonObject.getString("PHYSIC_NAME"));
                object1.put("dosage",jsonObject.getString("DOSE_UNIT"));
                object1.put("MIN_DOSE",jsonObject.getString("MIN_DOSE"));
                object1.put("mini_unit",jsonObject.getString("PHYSIC_UNIT"));
                object1.put("pack_size",jsonObject.getString("PACK_SPEC"));
                object1.put("retprice",jsonObject.getString("RETAIL_PRICE"));
                object1.put("specification",jsonObject.getString("PHYSIC_SPEC"));
                object1.put("pack_retprice",jsonObject.getString("RETAIL_PRICE"));
                object1.put("stock_amount",jsonObject.getString("QUANTITY"));
                object1.put("visible_flag",jsonObject.getString("VALID_FLAG"));
                object1.put("drug_flag",jsonObject.getString("OTC_FLAG"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("pack_unit",jsonObject.getString("PRICE_UNIT"));
                object1.put("manu_name",jsonObject.getString("SUPPLIER_NAME"));
                object1.put("weigh_unit",jsonObject.getString("DOSE_UNIT"));
                object1.put("vol_unit","");
                object1.put("mini_unit_name",jsonObject.getString("PHYSIC_UNIT"));
                DecimalFormat df =new DecimalFormat("0.00");
                Double packSize=Double.parseDouble(jsonObject.get("PACK_SPEC").toString().equals("[]")?"1":jsonObject.getString("PACK_SPEC"));
                Double retprice=Double.parseDouble(jsonObject.get("RETAIL_PRICE").toString().equals("[]")?"0":jsonObject.getString("RETAIL_PRICE"));
                Double miniUnitPrice=0.00;
                if (0.00!=packSize){
                    miniUnitPrice=retprice/packSize;
                }
                object1.put("mini_unit_price",df.format(miniUnitPrice));
                object1.put("pack_unit_name",jsonObject.getString("PRICE_UNIT"));
                object1.put("weigh_unit_name",jsonObject.getString("DOSE_UNIT"));
                object1.put("vol_unit_name","");
                object1.put("win_no","");
                object1.put("jbyw",jsonObject.getString("BASE_PHYSIC_FLAG"));
                object1.put("gwyp","");
                object1.put("bz_dosage",jsonObject.getString("DOSEAGE"));
                object1.put("bz_supply",jsonObject.getString("USAGE"));
                object1.put("bz_supply_name",jsonObject.getString("USAGE"));
                object1.put("bz_unit",jsonObject.getString("DOSEAGE_UNIT"));
                object1.put("bz_unit_name",jsonObject.getString("DOSEAGE_UNIT"));
                object1.put("bz_usage",jsonObject.getString("FREQUENCY"));
                object1.put("bz_usage_name",jsonObject.getString("FREQUENCY"));
                object1.put("QUANTITY",jsonObject.getString("QUANTITY"));
                object1.put("DAY_COUNT",jsonObject.getString("DAY_COUNT"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询药品用药方法
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectMedicineUsed(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getMedicineUsed?spellCode="+spellCode;
        String url = entranceUrl+"getMedicineUsed?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
@ -3167,512 +2735,14 @@ public class HcyyEntranceService {
        return jsonArray;
    }
    /**
     * 获取药品用药频次字典
     * @return
     */
    public JSONArray selectFrequencyDict() throws Exception {
        String response="";
        String url = entranceUrl+"getFrequencyDict";
        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("DAILY_TIMES",jsonObject.getString("FREQ_COUNT"));
                object1.put("FREQ_CODE",jsonObject.getString("FREQ_DESCRIBE"));
                object1.put("FREQ_DESCRIBE_CODE",jsonObject.getString("FREQ_DESCRIBE_CODE"));
                object1.put("FREQ_DESCRIBE",jsonObject.getString("FREQ_DESCRIBE"));
                object1.put("PHYSIC_NOTUSE_FLAG",jsonObject.getString("PHYSIC_NOTUSE_FLAG"));
                object1.put("FREQ_NAME",jsonObject.getString("FREQ_MEMO"));
                object1.put("INSUR_FREQ_DESCRIBE",jsonObject.getString("INSUR_FREQ_DESCRIBE"));
                object1.put("FREQ_INTERVAL",jsonObject.getString("FREQ_INTERVAL"));
                object1.put("FREQ_INTERVAL_UNIT",jsonObject.getString("FREQ_INTERVAL_UNIT"));
                object1.put("DEFAULT_SCHEDULE",jsonObject.getString("DEFAULT_SCHEDULE"));
                object1.put("EXECUTE_TIME_FLAG",jsonObject.getString("EXECUTE_TIME_FLAG"));
                object1.put("DAY_FLAG",jsonObject.getString("DAY_FLAG"));
                object1.put("WEEK_FLAG",jsonObject.getString("WEEK_FLAG"));
                object1.put("WEEK_1",jsonObject.getString("WEEK_1"));
                object1.put("WEEK_2",jsonObject.getString("WEEK_2"));
                object1.put("WEEK_3",jsonObject.getString("WEEK_3"));
                object1.put("WEEK_4",jsonObject.getString("WEEK_4"));
                object1.put("WEEK_5",jsonObject.getString("WEEK_5"));
                object1.put("WEEK_6",jsonObject.getString("WEEK_6"));
                object1.put("WEEK_7",jsonObject.getString("WEEK_7"));
                object1.put("SPELL_CODE",jsonObject.getString("SPELL_CODE"));
                object1.put("VALID_FLAG",jsonObject.getString("VALID_FLAG"));
                object1.put("WEEKLY_TIMES","");
                object1.put("IS_OP_IP","");
                object1.put("HOSP_CODE","");
                object1.put("FREQ_SP",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检查部位
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectCheckBody(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getCheckBody?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("name",jsonObject.getString("NAME"));
                object1.put("code",jsonObject.getString("CODE"));
                object1.put("data",jsonObject.getString("DATA"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                object1.put("wb_code",jsonObject.getString("WBZX_CODE"));
                object1.put("sequence",jsonObject.getString("SEQUENCE"));
                object1.put("valid",jsonObject.getString("VALID"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检查项目
     * @param spellCode 拼音码或药品名字
     * @return
     */
    public JSONArray selectExamApply(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getExamApply?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("name",jsonObject.getString("ITEM_NAME"));
                object1.put("code",jsonObject.getString("ITEM_CODE"));
                object1.put("type",jsonObject.getString("ITEM_CLASS"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("charge_amount",jsonObject.getString("FACT_PRICE"));
                object1.put("child_amount",jsonObject.getString("CHILD_PRICE"));
                object1.put("charge_unit",jsonObject.getString("UNIT"));
                object1.put("wb_code",jsonObject.getString("FIVE_PEN_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检验项目
     * @param spellCode 拼音码或药品名字
     * @return
     */
    public JSONArray selectLisApply(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getLisApply?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("name",jsonObject.getString("ITEM_NAME"));
                object1.put("code",jsonObject.getString("ITEM_CODE"));
                object1.put("type",jsonObject.getString("ITEM_CLASS"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("charge_amount",jsonObject.getString("FACT_PRICE"));
                object1.put("child_amount",jsonObject.getString("CHILD_PRICE"));
                object1.put("charge_unit",jsonObject.getString("UNIT"));
                object1.put("wb_code",jsonObject.getString("FIVE_PEN_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
/**
 * 检查检验项目同步his
 * @param
 * @return
 */
public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,String wlyyInspectionS) throws Exception {
    String response="";
    Map resultMap=new HashMap();
    String url = entranceUrl+"saveInspectToHospital?IoFlag="+IoFlag+"&PayCardNo="+PayCardNo+"&NullahNumber="+NullahNumber+
            "&ApplyDept="+ApplyDept+
            "&ApplyDoctor="+ApplyDoctor+"&wlyyInspectionS="+wlyyInspectionS;
    response = httpClientUtil.get(url,"GBK");
    JSONObject object = JSONObject.parseObject(response);
    if(object.getInteger("status")==200){
        String obj = object.getString("obj");
        JSONObject rootObject = JSONObject.parseObject(obj);
        if (null!=rootObject&&"0".equalsIgnoreCase(rootObject.getString("code"))){
            resultMap.put("success",rootObject.getString("success"));
            resultMap.put("code",rootObject.getString("code"));
            resultMap.put("msg",rootObject.getString("msg"));
            JSONObject dataObj = JSONObject.parseObject(rootObject.getString("data"));
            if (null!=dataObj){
                JSONObject presDetailobj = JSONObject.parseObject(dataObj.getString("PresDetail"));
                resultMap.put("msg",presDetailobj.getString("PresNo"));
                logger.info("his医嘱号:"+presDetailobj.getString("PresNo"));
            }
        }else if(null!=rootObject&&!"0".equalsIgnoreCase(rootObject.getString("code"))){
            resultMap.put("success",rootObject.getString("success"));
            resultMap.put("code",rootObject.getString("code"));
            resultMap.put("msg",rootObject.getString("msg"));
        }else {
            resultMap.put("success","obj转化失败");
        }
    }else {
        resultMap.put("success","调用entrance接口返回失败");
    }
    return resultMap;
}
    /**
     * 保存处方到entrance
     * @param ioFlag 门诊住院标志
     * @param payCardNo 就诊卡号
     * @param nullahNumber 挂号流水号
     * @param applyDept 执行科室
     * @param applyDoctor 开单医生
     * @param executeDept 执行科室(药房)
     * @return
     * @throws Exception
     */
    public JSONObject savePrescriptionToEntrance(String ioFlag,String payCardNo,String nullahNumber,String applyDept,String applyDoctor,String executeDept,List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"savePrescriptionToHospital";
        ObjectMapper mapper = new ObjectMapper();
        JSONArray array = new JSONArray();
        for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
            array.add(wlyyPrescriptionInfoDO);
        }
        Map<String,String> params = new HashedMap();
        params.put("IoFlag",ioFlag);
        params.put("PayCardNo",payCardNo);
        params.put("NullahNumber",nullahNumber);
        params.put("ApplyDept",applyDept);
        params.put("ApplyDoctor",applyDoctor);
        params.put("ExecuteDept",executeDept);
        params.put("prescriptionInfoDOS", array.toJSONString());
        logger.info("prescriptionInfoDOS"+params.get("prescriptionInfoDOS"));
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("开方成功"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
             jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 保存诊断到entrance
     * @param applyNo 必填,流水号
     * @param diagnosisName 必填,诊断名称
     * @param diagnosisCode 诊断代码
     * @return
     * @throws Exception
     */
    public JSONObject saveDiagnosisToEntrance(String applyNo,String diagnosisName,String diagnosisCode) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"saveDiagnosis";
        ObjectMapper mapper = new ObjectMapper();
        Map<String,String> params = new HashedMap();
        params.put("ApplyNo",applyNo);
        params.put("DiagnosisName",diagnosisName);
        params.put("DiagnosisCode",diagnosisCode);
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("诊断同步"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 发送退号信息到entrance
     * @param applyNo 必填,流水号
     * @param payCardNo 必填,卡号
     * @return
     * @throws Exception
     */
    public JSONObject refundConsultationToEntrance(String applyNo,String payCardNo) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"refundConsultation";
        ObjectMapper mapper = new ObjectMapper();
        Map<String,String> params = new HashedMap();
        params.put("ApplyNo",applyNo);
        params.put("PayCardNo",payCardNo);
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("诊断同步"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 删除处方信息
     * @param realOrder his处方号
     * @return
     * @throws Exception
     */
    public JSONObject deletePrescriptionToEntrance(String realOrder) throws Exception {
        Map<String,String> params = new HashedMap();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findByRealOrder(realOrder);
        if (null!=wlyyPrescriptionDO){
            params.put("IoFlag","0");
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if (null!=wlyyOutpatientDO){
                params.put("PayCardNo",wlyyOutpatientDO.getCardNo());
                params.put("ApplyDept",wlyyOutpatientDO.getDept());
                params.put("NullahNumber",wlyyOutpatientDO.getRegisterNo());
            }
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            if (null!=doctorMappingDO){
                params.put("ApplyDoctor",doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode());
            }
            params.put("ExecuteDept","50100");
            params.put("PresNo",realOrder);
        }
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"delHisPrescriptionByHisNo";
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("删除处方信息"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 保存电子病历
     * @param prescriptionId 处方id
     * @return
     * @throws Exception
     */
    public String  saveEmrToEntrance(String prescriptionId,String baseSign) throws Exception {
        Map<String,String> params = new HashedMap();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
        JSONObject paramRequest = new JSONObject();
        if (null!=wlyyPrescriptionDO){
            paramRequest.put("patientName",wlyyPrescriptionDO.getPatientName());
            PatientMappingDO patientMappingDO =  patientMappingDao.findByPatient(wlyyPrescriptionDO.getPatientCode());
            BasePatientDO basePatientDO = basePatientDao.findById(wlyyPrescriptionDO.getPatientCode());
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if(null!=patientMappingDO){
                paramRequest.put("patientid",patientMappingDO.getMappingCode());
            }
            //获取医生编号
            BaseDoctorDO doctorDO = doctorDao.findById(wlyyOutpatientDO.getDoctor());
            String operatorId = null;
            if (doctorDO!=null){
                String url = entranceUrl+"selectDoctorInfo?idCard="+doctorDO.getIdcard();
                String response = httpClientUtil.get(url,"GBK");
                JSONObject object = JSONObject.parseObject(response);
                if(object.getInteger("status")==200){
                    String obj = object.getString("obj");
                    JSONArray array = JSONArray.parseArray(obj);
                    if (array!=null&&array.size()!=0){
                        JSONObject jsonObject = array.getJSONObject(0);
                        operatorId = jsonObject.getString("staffNo");
                    }
                }
            }
            if(null!=doctorMappingDO){
                paramRequest.put("operatorid",operatorId);
                paramRequest.put("operatorname",wlyyPrescriptionDO.getDoctorName());
            }
            paramRequest.put("type","2");
            WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO =  prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
            if (null!=wlyyPrescriptionEmrDO){
                paramRequest.put("id",wlyyPrescriptionEmrDO.getId());
                params.put("emrInfo",JSON.toJSONString(wlyyPrescriptionEmrDO));
            }
            if (null!=basePatientDO){
                paramRequest.put("patientAge",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientsex",IdCardUtil.getSexForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientName",basePatientDO.getName());
                paramRequest.put("patientClan","0"); }
            if (null!=wlyyOutpatientDO){
                paramRequest.put("deptCode",wlyyOutpatientDO.getDeptName());
                paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
                paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
            }
            paramRequest.put("templateid","1158");
            paramRequest.put("catalogid","50");
            paramRequest.put("emrtype","93");
            paramRequest.put("emrtitle","互联网医院");
            if (StringUtils.isNoneBlank(baseSign)){
                //UploadVO uploadVO=fileUploadService.uploadImagesBase64(baseSign,fastdfs_file_url);
                //paramRequest.put("baseSign","https://ih.xmheart.com/fastdfs/"+uploadVO.getFullUri());
                paramRequest.put("baseSign",baseSign);
            }
        }
        params.put("jsonInfo",paramRequest.toJSONString());
        String response = "";
        String url = entranceUrl+"returnEmrHtmlByHLW";
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("保存电子病历"+response);
        if (response.contains("error")||response.contains("ERROR")){
            return "faild";
        }else {
            return "success";
        }
    }
    /**
     * 获取历史病历
     * @param patientId 病人id
     * @param eventNo 病人住院号
     * @return
     */
    public List<WlyyPrescriptionEmrDO> selectHistoryEmr(String patientId,String eventNo) throws Exception {
        String response="";
        String url = entranceUrl+"selectEmrInfo?patientId="+patientId+"&eventNo="+eventNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        List<WlyyPrescriptionEmrDO> wlyyPrescriptionEmrDOList = new ArrayList<>();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            if("[[]]".equalsIgnoreCase(obj)||"[]".equalsIgnoreCase(obj)||StringUtils.isBlank(obj)){
                return null;
            }else {
                logger.info("obj:" + obj);
                JSONArray array = JSONArray.parseArray(obj.replace("[]", "\"\"")).getJSONArray(0);
                logger.info("arrayResponse:" + array.toJSONString());
                for (int i = 0; i < array.size(); i++) {
                    JSONObject jsonObject = array.getJSONObject(i);
                    logger.info("jsonObject:" + jsonObject);
                    WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = new WlyyPrescriptionEmrDO();
                    wlyyPrescriptionEmrDO.setComplaint(null == jsonObject.get("CHIEF_COMPLAINT") ? "" : jsonObject.get("CHIEF_COMPLAINT").toString());
                    wlyyPrescriptionEmrDO.setMedicalHistory(null == jsonObject.get("PRESENT_ILLNESS") ? "" : jsonObject.get("PRESENT_ILLNESS").toString());
                    wlyyPrescriptionEmrDO.setPastHistory(null == jsonObject.get("PAST_HISTORY") ? "" : jsonObject.get("PAST_HISTORY").toString());
                    wlyyPrescriptionEmrDO.setPhysicalExamination(null == jsonObject.get("PHYSICAL_EXAMINATION") ? "" : jsonObject.get("PHYSICAL_EXAMINATION").toString());
                    wlyyPrescriptionEmrDO.setAssistExamination(null == jsonObject.get("OBSERVE_RESULT") ? "" : jsonObject.get("OBSERVE_RESULT").toString());
                    wlyyPrescriptionEmrDO.setAllergicHistory(null == jsonObject.get("ALLERGY_HISTORY") ? "" : jsonObject.get("ALLERGY_HISTORY").toString());
                    wlyyPrescriptionEmrDO.setPopularHistory(null == jsonObject.get("EPIDEMIOLOGICAL") ? "" : jsonObject.get("EPIDEMIOLOGICAL").toString());
                    wlyyPrescriptionEmrDO.setSpecialHistory(null == jsonObject.get("SPECIAL_HISTORY") ? "" : jsonObject.get("SPECIAL_HISTORY").toString());
                    wlyyPrescriptionEmrDOList.add(wlyyPrescriptionEmrDO);
                }
            }
        }
        return wlyyPrescriptionEmrDOList;
    }
    /**
     * 查询历次就诊门诊病历文书
     * @param templateId
     * @param patientId 病人id
     * @param eventNo 病人住院号
     * @return
     */
    public String selectHistoryEmrRecord(String templateId,String patientId,String eventNo) throws Exception {
        String response="";
        String url = entranceUrl+"selectEmrDispRecord?templateId="+templateId+"&patientId="+patientId+"&eventNo="+eventNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            return obj;
        }else {
            return "获取失败";
        }
    }
    public JSONArray selectHistoryEmrFromEntrance(String patientId,String eventNo) throws Exception {
        String response="";
        JSONArray jsonArray = new JSONArray();
        PatientMappingDO mappingDO = patientMappingDao.findByPatient(patientId);
        String patient = null;
        if (mappingDO!=null){
            patient = mappingDO.getMappingCode();
        }
        String url = entranceUrl+"selectEmrInfo?patientId="+patient+"&eventNo="+eventNo;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        List<WlyyPrescriptionEmrDO> wlyyPrescriptionEmrDOList = new ArrayList<>();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            if("[[]]".equalsIgnoreCase(obj)||"[]".equalsIgnoreCase(obj)||StringUtils.isBlank(obj)){
                return null;
            }else {
            logger.info("obj:"+obj);
            JSONArray array = JSONArray.parseArray(obj.replace("[]","\"\"")).getJSONArray(0);
            logger.info("arrayResponse:"+array.toJSONString());
            for (int j=0;j<array.size();j++){
                JSONObject object1 = array.getJSONObject(j);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("DEPT_NAME",object1.getString("DEPT_NAME"));
                jsonObject.put("TREAT_DATE_TIME",DateUtil.getYyyymmddhhmmss(DateUtil.strToDateLong(object1.getString("VISIT_TIME"))));
                jsonObject.put("OPID",object1.getString("EMR_ID"));
                String firstFlag = object1.getString("FIRST_FLAG");
                if (firstFlag.equalsIgnoreCase("复诊")){
                    jsonObject.put("TREAT_DOCTOR_NAME",object1.getString("RETURN_DOC_SIGN"));
                }else if (firstFlag.equalsIgnoreCase("初诊")){
                    jsonObject.put("TREAT_DOCTOR_NAME",object1.getString("DOCTOR_SIGNATURE"));
                }
                jsonArray.add(jsonObject);
            }
            return jsonArray;
            }
        }else {
            return null;
        }
    }
    /**
     * 查询病历文书html信息
     * @param bstrEmrID
     * @return
     */
    public String selectBrowseSingleEMR(String bstrEmrID) throws Exception {
        String response="";
        String url = entranceUrl+"browseSingleEMR?bstrEmrID="+bstrEmrID;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            return obj;
        }else {
            return "获取失败";
        }
    }
//=====================hospital应用调用entrance应用============end=================
@ -3683,31 +2753,6 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
    /**
     * 查询单条门诊记录
     * @param patient
     * @param conNo
     * @return
     */
    public WlyyOutpatientVO findOutpatientData(String patient, String conNo)throws Exception{
        logger.info("findOutpatientList patient:"+patient);
        String patNo =findHisPatNoByPatient(patient);
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        logger.info("findOutpatientList patNo:"+patNo);
        WlyyOutpatientVO outpatientVO=selectOutpatientInfo(patNo,conNo);
        if(outpatientVO!=null){
            BasePatientDO patientDO = patientDao.findById(patient);
            outpatientVO.setSex(patientDO.getSex()+"");
            outpatientVO.setBirthday(patientDO.getBirthday());
            return outpatientVO;
        }
        return outpatientVO;
    }
    public String isEmty(String str){
        if (str.equalsIgnoreCase("[]")){
            return null;
@ -3740,133 +2785,7 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
        return patientId;
    }
    /*
     * @param registerSn 流水号
     * @param patient 居民code
     * @param admNo 住院唯一号
     * @param realOrder 处方号
     * @return
     */
    public List<WlyyPrescriptionVO> findPrescriptionList(String outPatientId,String realOrder) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outPatientId);
        if (outpatientDO==null){
            throw new Exception("该门诊记录不存在!");
        }
        String registerSn = outpatientDO.getRegisterNo();
        if (!StringUtils.isNoneBlank(registerSn)){
            throw new Exception("挂号流水号不存在");
        }
        String admNo = outpatientDO.getAdmNo();
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
        if (patientMappingDO==null||!StringUtils.isNoneBlank(patientMappingDO.getMappingCode())){
            throw new Exception("该居民映射表不存在!");
        }
        List<WlyyPrescriptionVO> wlyyPrescriptionVOList = selectOriginPrescriptionList(registerSn,patientMappingDO.getMappingCode(),admNo,realOrder);
        return wlyyPrescriptionVOList;
    }
    public List<WlyyPrescriptionVO> selectPrescriptionList(String registerSn,String patNo,String admNo,String realOrder,String startTime,String endTime) throws Exception {
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patNo);
        if (patientMappingDO==null||!StringUtils.isNoneBlank(patientMappingDO.getMappingCode())){
            throw new Exception("该居民映射表不存在!");
        }
        List<WlyyPrescriptionVO> wlyyPrescriptionVOList = selectOriginPrescriptionList(registerSn,patientMappingDO.getMappingCode(),admNo,realOrder);
        return wlyyPrescriptionVOList;
    }
    public Map<String,Object> updatePreStatus(String admNo,String realOrder,String status) throws Exception {
        Map<String,Object> map = new HashedMap();
        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<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByOutpatientId(wlyyOutpatientDO.getId());
                if (prescriptionDOList==null||prescriptionDOList.size()==0){
                    List<WlyyPrescriptionVO> prescriptionVOList = selectOriginPrescriptionList(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("3")){
                            prescriptionDO.setStatus(30);
                        }
                        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());
                            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());
                            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());
                            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);
            }
        }else if (status.equalsIgnoreCase("4")){
            List<WlyyPrescriptionDO> prescriptionDOList =  prescriptionDao.findByAdmNoAndRealOrderList(admNo,realOrder);
            for (WlyyPrescriptionDO wlyyPrescriptionDO:prescriptionDOList){
                wlyyPrescriptionDO.setStatus(100);
                prescriptionDao.save(wlyyPrescriptionDO);
            }
        }
        return map;
    }
    //组装审药参数并发送到entrance
    public String checkInputInfo(String hisId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS,List<WlyyPrescriptionInfoDO> infos) throws Exception{
        JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
@ -4150,6 +3069,8 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
        return jsonObject1;
    }
//===========================entrance访问hospital============end=======================
}

+ 26 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -582,6 +582,28 @@ public class YkyyEntranceService {
        return wlyyOutpatientVOS;
    }
    /**
     * 查找眼科his 已审核已付款的处方
     * @throws Exception
     */
    public JSONArray getHisPrescriptionInfo() throws Exception{
        String sql = "SELECT h.BRID,h.CFSB,to_char(h.FYRQ,'yyyy-mm-dd hh24:mi:ss' ) as \"fyrq\",to_char(h.SPRQ,'yyyy-mm-dd hh24:mi:ss' ) as \"sprq\" from v_ms_dd01 h WHERE h.SPZT = 1 and h.FKZT = 1 order by h.KFRQ desc ";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        params.put("page","1");
        params.put("size","200");
        HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            return rs.getJSONArray("detailModelList");
        }
        return new JSONArray();
    }
    /**
     * 查找眼科his 已审核未付款的处方
     * @throws Exception
@ -1502,7 +1524,7 @@ public class YkyyEntranceService {
                "yp.gyffmc as \"gyffmc\"," +
                "yp.pzwh as \"pzwh\","+
                "yp.yfsb as \"yfsb\""+" FROM " +
                "V_hlwyy_MZ_YPXX yp where 1=1 and yp.yfsb in(9,10)  ";
                "V_hlwyy_MZ_YPXX yp where 1=1 and yp.yfsb in(3,6)  ";
        if (StringUtils.isNoneBlank(ypdm)){
            sql+=" and lower(yp.ypdm) like '%"+ypdm.toLowerCase()+"%' ";
        }
@ -1997,12 +2019,12 @@ public class YkyyEntranceService {
                WlyyPrescriptionExpressageDO expressageDO = expressageDOList.get(0);
                if (1==expressageDO.getOneselfPickupFlg()){
                    if (expressageDO.getHospitalCode().equalsIgnoreCase("3")){
                        drug="9";
                        drug="3";
                    }else if (expressageDO.getHospitalCode().equalsIgnoreCase("6")){
                        drug="10";
                        drug="6";
                    }
                }else {
                    drug = "10";
                    drug = "6";
                }
            }
            List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(code,1);

+ 10 - 0
business/base-service/src/mqConfig/mqdata/BS15018.json

@ -19,5 +19,15 @@
		"CARD_TYPE_NAME": "社保卡",
		"social_no": "350211198411053024",
		"name":"白海灵"
	},
	{
		"PAT_NO": "P5616242-1",
		"CARD_NO": "DA1872143",
		"CARD_STAT": "激活",
		"OP_DATE": "2014-07-25 08:46:40",
		"CARD_TYPE": "2",
		"CARD_TYPE_NAME": "社保卡",
		"social_no": "230203195211271426",
		"name":"王金妮"
	}]
}

+ 38 - 1
business/base-service/src/mqConfig/mqdata/MS53001.json

@ -12,7 +12,7 @@
		"body": {
			"row": {
				"action": "select",
				"charge_code": "07685 ",
				"charge_code": "07877",
				"serial": "01",
				"group_no": "72",
				"drugname": "贝那普利片",
@ -39,5 +39,42 @@
				"gwyp": []
			}
		}
	},{
		"head": {
			"fId": "BS35014",
			"version": "2",
			"msgName": "药品字典",
			"sourceSysCode": "S01",
			"targetSysCode": "S60",
			"createTime": "20190529094914"
		},
		"body": {
			"row": {
				"action": "select",
				"charge_code": "07877 ",
				"serial": "02",
				"group_no": "71",
				"drugname": "(外用)人碱性成纤维细胞生长因子",
				"dosage": "01  ",
				"mini_unit": "02",
				"pack_size": "1",
				"specification": "10mgx1粒/片",
				"retprice": "3.562",
				"pack_retprice": "3.5619",
				"stock_amount": "275",
				"visible_flag": "0",
				"drug_flag": "1",
				"py_code": "MFHSPPMS",
				"pack_unit": "02",
				"manu_name": "北京萌蒂",
				"weigh_unit": "16",
				"vol_unit": [],
				"mini_unit_name": "粒",
				"pack_unit_name": "粒",
				"weigh_unit_name": "mg",
				"vol_unit_name": [],
				"win_no": "6"
			}
		}
	}]
}

+ 18 - 5
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -37,6 +37,8 @@ import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.HcyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
@ -131,6 +133,8 @@ public class ImService {
    private BaseBannerDoctorDao baseBannerDoctorDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private HcyyEntranceService hcyyEntranceService;
    @Value("${im.data_base_name}")
    private String data_base_name;
@ -152,8 +156,6 @@ public class ImService {
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Autowired
    private WxTemplateService wxTemplateService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
@ -177,9 +179,8 @@ public class ImService {
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private WlyyConsultAdviceDao wlyyConsultAdviceDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    private XzzxEntranceService xzzxEntranceService;
    @Value("${wechat.id}")
    private String wxId;
@ -834,7 +835,11 @@ public class ImService {
            } else {
                throw new Exception("获取ACCESSTOKEN失败");
            }
        } else {
        }else if("xm_xzzx_wx".equals(wxId)){
            accessToken = xzzxEntranceService.getXzToken();
        }else if ("xm_hcyy_wx".equals(wechat_appid)) { //海沧医院
                accessToken = hcyyEntranceService.getHcToken();
        }else {
            accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
        }
        InputStream is = null;
@ -1913,6 +1918,10 @@ public class ImService {
        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
        data.put("name", patient.getName());
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(consultTeam.getRelationCode());
        if (wlyyOutpatientDO!=null){
            data.put("consumerName",wlyyOutpatientDO.getConsumerName());
        }
        data.put("age", IdCardUtil.getAgeForIdcard(patient.getIdcard()));
        data.put("gender", StringUtils.isEmpty(patient.getSex()) ? null : patient.getSex().toString());
        data.put("question", consultTeam.getSymptoms());
@ -3766,6 +3775,7 @@ public class ImService {
                    "patient.NAME AS \"patientName\"," +
                    "patient.id AS \"patientId\"," +
                    "op.consumer AS \"consumer\"," +
                    "op.consumer_name AS \"consumerName\"," +
                    "patient.idcard AS \"patientIdcard\"," +
                    "patient.sex AS \"patientsex\"," +
                    "patient.photo AS \"patientphoto\",";
@ -3851,6 +3861,7 @@ public class ImService {
                    "op.doctor AS \"doctorCode\"," +
                    "op.general_doctor AS \"generalDoctor\"," +
                    "op.consumer AS \"consumer\"," +
                    "op.consumer_name AS \"consumerName\"," +
                    "patient.NAME AS \"patientName\"," +
                    "patient.id AS \"patientId\"," +
                    "patient.idcard AS \"patientIdcard\"," +
@ -4542,6 +4553,7 @@ public class ImService {
                    "patient.NAME AS \"patientName\"," +
                    "patient.id AS \"patientId\"," +
                    "op.consumer AS \"consumer\"," +
                    "op.consumer_name AS \"consumerName\"," +
                    "patient.idcard AS \"patientIdcard\"," +
                    "patient.sex AS \"patientsex\"," +
                    "patient.photo AS \"patientphoto\",";
@ -4626,6 +4638,7 @@ public class ImService {
                    "op.doctor AS \"doctorCode\"," +
                    "op.general_doctor AS \"generalDoctor\"," +
                    "op.consumer AS \"consumer\"," +
                    "op.consumer_name AS \"consumerName\"," +
                    "patient.NAME AS \"patientName\"," +
                    "patient.id AS \"patientId\"," +
                    "patient.idcard AS \"patientIdcard\"," +

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -25,7 +25,7 @@ public abstract class IntegerIdentityEntity implements Serializable {
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
//   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
/*   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeArticleDO.java

@ -44,6 +44,7 @@ public class KnowledgeArticleDO extends UuidIdentityEntity {
	@Column(name = "is_share")
	private Integer share;//分享 数量
	private String intro;//简介
	private Integer isShow;//显示首页:1显示0不显示
	@Transient
	private Integer isUsed;//是否已设置常用
@ -277,4 +278,12 @@ public class KnowledgeArticleDO extends UuidIdentityEntity {
	public void setIntro(String intro) {
		this.intro = intro;
	}
	public Integer getIsShow() {
		return isShow;
	}
	public void setIsShow(Integer isShow) {
		this.isShow = isShow;
	}
}

+ 13 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/BaseUserMessageDO.java

@ -72,6 +72,11 @@ public class BaseUserMessageDO extends UuidIdentityEntityWithOperator {
     */
    private Integer isRead;
    /**
     * 是否展示1展示、0隐藏
     */
    private Integer isShow;
    /**
     * 返回锦旗集合
     */
@ -202,4 +207,12 @@ public class BaseUserMessageDO extends UuidIdentityEntityWithOperator {
    public Integer getRelationType() {
        return relationType;
    }
    public Integer getIsShow() {
        return isShow;
    }
    public void setIsShow(Integer isShow) {
        this.isShow = isShow;
    }
}

+ 15 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionDO.java

@ -249,6 +249,12 @@ public class WlyyPrescriptionDO extends UuidIdentityEntity {
     */
    private String checkReason;
    /**
     * 审方时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date checkTime;
    /**
     * 处理状态 1处方修改2执行处方
     */
@ -280,6 +286,15 @@ public class WlyyPrescriptionDO extends UuidIdentityEntity {
    private Date disableTime;
    @Column(name = "check_time")
    public Date getCheckTime() {
        return checkTime;
    }
    public void setCheckTime(Date checkTime) {
        this.checkTime = checkTime;
    }
    @Column(name = "disable_time")
    public Date getDisableTime() {
        return disableTime;

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -880,6 +880,8 @@ public class BaseRequestMapping {
        public static final String queryHealthIdCard  = "/queryHealthIdCard";
    }
    /**
     * 药店管理接口
     */

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

@ -225,6 +225,16 @@ public class BaseHospitalRequestMapping {
         */
        public static final String pushListWrite="/pushListWrite";
        /**
         * 财务报表导出
         */
        public static final String pushListDrug="/pushListDrug";
        /**
         * 财务报表导出
         */
        public static final String selectListDrug="/selectListDrug";
        /**
         *咨询导出
         */
@ -1163,7 +1173,10 @@ public class BaseHospitalRequestMapping {
    
        //添加/修改文章
        public static final String saveArticle  = "/saveArticle";
    
        //修改文章是否展示首页
        public static final String updateIsShow  = "/updateIsShow";
        //审核/退回文章
        public static final String reviewArticle  = "/reviewArticle";
    
@ -1389,6 +1402,7 @@ public class BaseHospitalRequestMapping {
        public static final String getMessage  = "/getMessage";
        public static final String getPoint  = "/getPoint";
        public static final String showDoctorMessage  = "/showDoctorMessage";
        public static final String updateIsShow  = "/updateIsShow";
    }
    /**

+ 1 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -108,6 +108,7 @@ public class BasicZuulFilter extends ZuulFilter {
                url.contains("/excelControl")||
                url.contains("/open/gc")||
                url.contains("/prescription/pushListWrite")||
                url.contains("/prescription/pushListDrug")||
                url.contains("/open/noLogin/pushYkCardCharge")||
                url.contains("/prescription/searchRecordWrite"))){
            logger.info("入参"+ctx.getRequestQueryParams());

+ 2 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java

@ -61,6 +61,7 @@ public class PostFilter extends ZuulFilter {
        HttpServletRequest request = ctx.getRequest();
        String url = request.getRequestURI();
        if (url.contains("/excelControl")||url.contains("/prescription/pushListWrite")||
                url.contains("/prescription/pushListDrug")||
                url.contains("/open/noLogin/pushYkCardCharge")||
                url.contains("/prescription/searchRecordWrite")){
            return true;
@ -136,6 +137,7 @@ public class PostFilter extends ZuulFilter {
                url.contains("/weixin")||url.contains("/oauth/getSsoPublicKey")||
                url.contains("/open/gc")||
                url.contains("/prescription/pushListWrite")||
                url.contains("/prescription/pushListDrug")||
                url.contains("/open/noLogin/pushYkCardCharge")||
                url.contains("/prescription/searchRecordWrite"))){
            RequestContext.getCurrentContext().setResponseBody(object.toJSONString());

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java

@ -44,6 +44,14 @@ public class AqgConfig {
     */
    public static final String X1_locations = baseUrl+"/api/locationdata/";
    /**
     * X1设备修改
     * 计步1小时 心率30分钟 定位15分钟
     * 计步数据开关、 睡眠开关、轨迹开关、 心率、血氧、血压定时测量开关
     */
    public static final String X1_deviceModify = baseUrl+"/api/device/{0}/4g/edit?frequency_location=15&frequency_step=60" +
            "&frequency_heartrate=30&pedometer_enable=1&sleep_enable=1&track_enable=1&heartrate_enable=1";
    /**
     * 睡眠带 修改心率呼吸率报警阈值
     */

+ 2 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/activity/ChildActivityEndpoint.java

@ -32,10 +32,11 @@ public class ChildActivityEndpoint  extends EnvelopRestEndpoint {
    public PageEnvelop childActivityRegistrationList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "activityType", value = "活动类型 1小鬼来当家 2秋游去 3我喜欢我自己 4乡村音乐") @RequestParam(value = "activityType", required = false) String status,
            @ApiParam(name = "orgCode", value = "orgCode", required = false, defaultValue = "orgCode") @RequestParam(value = "orgCode",required = false) String orgCode,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try{
            return activityRegistrationService.childActivityRegistrationList(patient, status, page, size);
            return activityRegistrationService.childActivityRegistrationList(patient, status,orgCode, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }

+ 33 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -42,6 +43,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import static java.lang.Thread.sleep;
/***
 * @ClassName: PadDeviceController
 * @Description:
@ -66,6 +69,8 @@ public class PadDeviceController extends BaseController {
    private ContactsService contactsService;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 设备列表获取
@ -253,4 +258,32 @@ public class PadDeviceController extends BaseController {
        }
    }
    @RequestMapping(value ="open/updateX1Device",method = RequestMethod.GET)
    @ApiOperation(value = "批量修改爱牵挂手表设备信息")
    public String updateX1Device() {
        try {
            String sql = " select device_code from wlyy_devices wd where wd.category_code=4 ";
            List<String> deviceSns = jdbcTemplate.queryForList(sql,String.class);
            for (String deviceSn:deviceSns) {
                patientDeviceService.updateX1Device(deviceSn);
                sleep(2000);
            }
            System.out.println("MODIFY FINISH");
            return write(200, "获取成功", "data", "success");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value ="open/updateX1DeviceBySn",method = RequestMethod.GET)
    @ApiOperation(value = "修改爱牵挂手表设备信息")
    public String updateX1DeviceBySn(@ApiParam(name = "deviceSn", value = "deviceSn", defaultValue = "deviceSn")
                                 @RequestParam(value = "deviceSn", required = true) String deviceSn) {
        try {
            patientDeviceService.updateX1Device(deviceSn);
            return write(200, "获取成功", "data", "success");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
}

+ 4 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java

@ -66,7 +66,7 @@ public class ChildActivityRegistrationService {
     * @param page
     * @param size
     */
    public PageEnvelop childActivityRegistrationList(String patient,String activityType, int page, int size){
    public PageEnvelop childActivityRegistrationList(String patient,String activityType,String orgCode, int page, int size){
        String sql = "SELECT a.id,a.activity_type activityType,a.patient,p.name,p.sex,p.idcard,p.photo,org.code,org.name orgName,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_child_activity_registration a " +
                "LEFT JOIN base_org org on a.org_code = org.code ,base_patient p " +
                "WHERE a.patient = p.id";
@ -81,6 +81,9 @@ public class ChildActivityRegistrationService {
        if(StringUtils.isNotBlank(activityType)){
            filter += " and a.activity_type = '"+activityType+"' ";
        }
        if (StringUtils.isNotBlank(orgCode)){
            filter += " and a.org_code = '"+orgCode+"' ";
        }
        Long count = jdbcTemplate.queryForObject(sqlCount+filter,Long.class);
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+filter);
        for (Map<String,Object> map:result){

+ 9 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java

@ -55,6 +55,8 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	private String cloudDeviceUrl;
	@Autowired
	private YsDeviceService ysDeviceService;
	@Autowired
	private	 PatientDeviceService patientDeviceService;
	/**
@ -225,7 +227,14 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
			params.add(new BasicNameValuePair("deviceSN", device.getDeviceSn()));
			params.add(new BasicNameValuePair("pushAddress", cloudDeviceUrl+deviceDO.getNeedRegister()));
			String response = httpClientUtil.post(url, params,"UTF-8");
			System.out.println("注册结果:"+response);
			//注册日志
		}
		/**
		 * 手表信息修改
		 */
		if ("4".equals(device.getCategoryCode())){
			patientDeviceService.updateX1Device(device.getDeviceSn());
		}
	}
}

+ 21 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -1954,6 +1954,27 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return response.getBody();
    }
    /**
     * X1设备修改
     * 计步1小时 心率30分钟 定位15分钟
     * 计步数据开关、 睡眠开关、轨迹开关、 心率、血氧、血压定时测量开关
     */
    public  String updateX1Device(String deviceSn){
        String url =MessageFormat.format(AqgConfig.X1_deviceModify, deviceSn) ;
        Map<String,Object> headers = new HashMap<>();
        headers.put("Accept", MediaType.APPLICATION_JSON.toString());
        headers.put("Cookie", getCookie());
        String  responseStr = httpClientUtil.get(url,"utf-8",headers);
        com.alibaba.fastjson.JSONObject resObj = JSON.parseObject(responseStr);
        if (resObj.getBooleanValue("success")){
            System.out.println(deviceSn+":success");
        }else {
            System.out.println(deviceSn+":false--response"+responseStr);
        }
        return "success";
    }
    /******************************************* 爱牵挂设备end *****************************************************/
}

+ 48 - 29
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java

@ -40,6 +40,8 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
    private ServicePackageService servicePackageService;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    public JSONObject getOnLineObj(String patient){
@ -144,8 +146,8 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
            tmpObj.put("avatar",tmp.get("photo"));
            tmpObj.put("userType","1");
            tmpObj.put("doctorId",tmp.get("doctor"));
            tmp.put("doctorLevel",tmp.get("doctorLevel"));
            tmpObj.put("relationName","助老员");
            tmpObj.put("doctorLevel",tmp.get("doctorLevel"));
            tmpObj.put("relationName",null==tmp.get("doctorLevel")?"":"1".equals(tmp.get("doctorLevel").toString())?"社区医生":"助老员");
            doctorResult.add(tmpObj);
        }
@ -153,42 +155,59 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
        if (families.size()>0){
            List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList());
            if(patientArr.size()>0){
                JSONObject tmp = patientArr.getJSONObject(0);
                JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
                for (int i=0;i<participantsTimeArray.size();i++){
                    JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
                    String id =  tmpObj.getString("id");
                    if (!id.equals(patient)&&familyIds.contains(id)){
                        tmp.put("avatar",tmp.getString("photo"));
                        tmp.put("patientId",id);
                        String sql = " select family_relation from base_patient_family_member where " +
                                " patient = '"+patient+"' and family_member='"+id+"' " +
                                " and (del=1 or del is null) ";
                        List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class);
                        if(relations.size()>0){
                            tmp.put("relationName",familyMemberService.relations.get(relations.get(0)));
                        }else {
                            tmp.put("relationName","其他");
                boolean findFlag = false;//有会话的展示会话中的一条 且不为家属
                for (int i=0;i<patientArr.size();i++){
                    JSONObject tmp = patientArr.getJSONObject(i);
                    JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
                    for (int j=0;j<participantsTimeArray.size();j++){
                        JSONObject tmpObj = participantsTimeArray.getJSONObject(j);
                        String id =  tmpObj.getString("id");
                        BasePatientDO patientDO = patientDao.findById(id);
                        if (patientDO.getArchiveType()==3){
                            continue;
                        }
                        if (!id.equals(patient)&&familyIds.contains(id)){
                            tmp.put("avatar",tmp.getString("photo"));
                            tmp.put("patientId",id);
                            String sql = " select family_relation from base_patient_family_member where " +
                                    " patient = '"+patient+"' and family_member='"+id+"' " +
                                    " and (del=1 or del is null) ";
                            List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class);
                            if(relations.size()>0){
                                tmp.put("relationName",familyMemberService.relations.get(relations.get(0)));
                            }else {
                                tmp.put("relationName","其他");
                            }
                            patientResult.add(tmp);
                            findFlag=true;
                            break;
                        }
                        patientResult.add(tmp);
                    }
                    if (findFlag){
                        break;
                    }
                }
            }
            if (patientResult.size()==0){
                if (families.size()>0){
                    JSONObject tmp = families.getJSONObject(0);
                    JSONObject tmpObj = new JSONObject();
                    tmpObj.put("name",tmp.getString("name"));
                    tmpObj.put("unread_count","0");
                    tmpObj.put("avatar",tmp.getString("photo"));
                    tmpObj.put("userType","2");
                    tmpObj.put("patientId",tmp.get("id"));
                    tmpObj.put("relationName",tmp.get("familyRelationName"));
                    patientResult.add(tmpObj);
                    for (int i=0;i<families.size();i++){
                        JSONObject tmp = families.getJSONObject(i);
                        JSONObject tmpObj = new JSONObject();
                        tmpObj.put("name",tmp.getString("name"));
                        tmpObj.put("unread_count","0");
                        tmpObj.put("avatar",tmp.getString("photo"));
                        tmpObj.put("userType","2");
                        BasePatientDO patientDO = patientDao.findById(tmp.get("id").toString());
                        if (patientDO.getArchiveType()==3){
                            continue;
                        }
                        tmpObj.put("patientId",tmp.get("id"));
                        tmpObj.put("relationName",tmp.get("familyRelationName"));
                        patientResult.add(tmpObj);
                        break;
                    }
                }
            }
        }
        result.put("doctors",doctorResult);

+ 3 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java

@ -489,6 +489,7 @@ public class PrescriptionStatusUpdateService {
                try {
                    data.put("name", wlyyOutpatientDO.getPatientName());
                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                    String msg = "";
@ -600,6 +601,7 @@ public class PrescriptionStatusUpdateService {
                        messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                        data.put("name", wlyyOutpatientDO.getPatientName());
                        data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                        data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("question", wlyyOutpatientDO.getIcd10Name());
@ -796,6 +798,7 @@ public class PrescriptionStatusUpdateService {
                        messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                        data.put("name", wlyyOutpatientDO.getPatientName());
                        data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                        data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("question", wlyyOutpatientDO.getIcd10Name());

+ 1 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -156,6 +156,7 @@ public class TimeoutOverDueService {
                                messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                data.put("name", wlyyOutpatientDO.getPatientName());
                                data.put("consumerName",wlyyOutpatientDO.getConsumerName());
                                data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                data.put("question", wlyyOutpatientDO.getIcd10Name());

+ 31 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -314,6 +314,37 @@ public class UnSettledHISPrescriptionService {
                    }
                }
            }
            //获取审核成功支付成功发药时间、审核时间
            logger.info("同步开始");
            JSONArray hisArray = ykyyEntranceService.getHisPrescriptionInfo();
            //发送模板
            if(hisArray!=null&&hisArray.size()>0) {
                for (int i = 0; i<hisArray.size(); i++){
                    JSONObject json = hisArray.getJSONObject(i);
                    String brid = json.getString("BRID");
                    String cfsb = json.getString("CFSB");
                    String yfrq = json.getString("fyrq");
                    String sprq = json.getString("sprq");
                    //查找对应的处方
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' and w.DISP_DATE is NULL  ORDER BY w.CREATE_TIME desc";
                    List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                    if(pre!=null && pre.size()>0){
                        String prescriptionId = pre.get(0).get("ID").toString();
                        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
                        logger.info(sprq+yfrq);
                        if (StringUtils.isNoneBlank(sprq)){
                            logger.info("111111111111");
                            wlyyPrescriptionDO.setCheckTime(DateUtil.strToDateLong(sprq));
                        }
                        if (StringUtils.isNoneBlank(yfrq)){
                            logger.info("222222222222222");
                            wlyyPrescriptionDO.setDispDate(DateUtil.strToDateLong(yfrq));
                        }
                        prescriptionDao.save(wlyyPrescriptionDO);
                    }
                }
            }
        }
    }

+ 16 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleEndpoint.java

@ -169,6 +169,22 @@ public class ArticleEndpoint extends EnvelopRestEndpoint {
			return failedException(e);
		}
	}
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.updateIsShow)
	@ApiOperation(value = "修改文章是否展示首页")
	public Envelop updateIsShow(
			@ApiParam(name = "id", value = "id", required = true)
			@RequestParam String id,
			@ApiParam(name = "isShow", value = "isShow", required = true)
			@RequestParam Integer isShow)throws Exception {
		try {
			knowledgeArticleService.updateIsShow(id,isShow);
			return success("操作成功");
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@PostMapping (value = BaseHospitalRequestMapping.KnowledgeArticle.reviewArticle)
	@ApiOperation(value = "审核/退回文章")

+ 39 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -17,6 +17,7 @@ import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionEmrDO;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.service.HcyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.XzyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
@ -111,6 +112,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	private PrescriptionDao prescriptionDao;
	@Autowired
	private EntranceService entranceService;
	@Autowired
	private HcyyPrescriptionService hcyyPrescriptionService;
	
	@Value("${wechat.id}")
	private String wxId;
@ -259,7 +262,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		
			JSONObject result = new JSONObject();
			synchronized (outpatientCode.intern()){
				if(!"xm_ykyy_wx".equals(wxId)&&!"sd_tnzyy_wx".equals(wxId)){//中山医院-心脏中心需要挂号
				if(!"xm_ykyy_wx".equals(wxId)&&!"sd_tnzyy_wx".equals(wxId)){//中山医院-心脏中心-海沧医院需要挂号
					//1.调用挂号接口
					logger.info("调用挂号接口====START");
					String rsCode = "";
@ -284,6 +287,26 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
							}
						}*/
					}else if("xm_hcyy_wx".equals(wxId)){ //海沧医院挂号
						if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")&&!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
							JSONObject res = hcyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
							rsCode = res.getString("@RESULT");
							mes = res.getString("@MSG");
						}else  {
							rsCode="0";
							mes="已挂号";
						}
						/*if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())){
							if ("2".equalsIgnoreCase(outpatientDO.getType())){
								prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
							}
						}
						if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())){
							if ("2".equalsIgnoreCase(outpatientDO.getType())){
								prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"17","outpatientMsgRemind","");
							}
						}*/
					}else {
						if (demoFlag.equalsIgnoreCase("true")){
							rsCode="0";
@ -353,6 +376,21 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
						}
					}
				}else if("xm_hcyy_wx".equals(wxId)){ //心脏中心挂号
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";
						mes="已退号";
					}else {
						JSONObject res = hcyyPrescriptionService.refundRegisterNo(outpatientCode);
						if (res!=null&&res.getString("code").equalsIgnoreCase("0")){
							rsCode = "0";
							mes="已退号";
						}else {
							rsCode = "-1";
							mes=res.getString("msg");
						}
					}
				}else {
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";

+ 4 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java

@ -170,7 +170,10 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
        files.setChunk(chunk);
        files.setChunkTotal(chunkTotal);
        files.setFile(file);
        if (!fileUploadService.isFileFlag(objectType+"")){
        String originalFilename1 = file.getOriginalFilename();
        String[] fs1 = originalFilename1.split("\\.");
        String type1 = fs1[1];
        if (!fileUploadService.isFileFlag(type1)){
            throw new FileWrongFormatException("不符合文件上传格式");
        }
        files.setObjectType(objectType);

+ 17 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -20,6 +20,7 @@ import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -359,11 +360,26 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
                        if(mixEnvelop.getStatus() == 200) {
                            JSONObject jdObject = ykyyEntranceService.patientJDKH(idCard,familyName,username,medicare,clinicId);
                            if (jdObject.getInteger("status")!=200){
                                mixEnvelop.setStatus(408);
                                mixEnvelop.setStatus(410);
                                mixEnvelop.setMessage(jdObject.getString("message"));
                                return mixEnvelop;
                            }
                        }else {
                            if (mixEnvelop.getStatus()==409){
                                if (medicare==null||medicare==""){
                                    mixEnvelop.setStatus(408);
                                    mixEnvelop.setMessage("社保卡号为空无法建档!请核对社保卡号!");
                                    return mixEnvelop;
                                }
                                JSONObject jdObject = ykyyEntranceService.patientJDKH(idCard,familyName,username,medicare,clinicId);
                                if (jdObject.getInteger("status")!=200){
                                    mixEnvelop.setStatus(410);
                                    mixEnvelop.setMessage(jdObject.getString("message"));
                                    return mixEnvelop;
                                }else {
                                    mixEnvelop = wlyyFamilyMemberService.addFamily(id, patientId, familyName, dictId, cardType, idCard, username, false, medicareType, medicare, clinicId);
                                }
                            }
                            return mixEnvelop;
                        }
                    }

+ 19 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/message/BaseUserMsgController.java

@ -91,13 +91,30 @@ public class BaseUserMsgController extends EnvelopRestEndpoint {
                                           @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
                                           @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                               @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
                                   @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize){
                                   @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize,
                               @ApiParam(name = "isShow", value = "是否显示(1显示0不显示)", required = false)
                                   @RequestParam(value = "isShow", required = false)Integer isShow){
        try {
            return baseUserMsgService.getMessage(doctor,showAll,showAllType,beginTime,endTime,patient,page,pageSize);
            return baseUserMsgService.getMessage(doctor,showAll,showAllType,beginTime,endTime,patient,page,pageSize,isShow);
        }catch (Exception e){
            return failedException(e);
        }
    }
    @ApiOperation("修改留言是否展示")
    @PostMapping(value= BaseHospitalRequestMapping.UserMessage.updateIsShow)
    public Envelop updateIsShow(@ApiParam(name = "id", value = "id", required = false)
                               @RequestParam(value = "id", required = false)String id,
                               @ApiParam(name = "isShow", value = "isShow", required = false)
                               @RequestParam(value = "isShow", required = false)Integer isShow){
        try {
            return success(baseUserMsgService.updateIsShow(id,isShow));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @ApiOperation("医生评论展示")
    @PostMapping(value= BaseHospitalRequestMapping.UserMessage.getSingleMessage)
    public Envelop getSingleMessage(@ApiParam(name = "id", value = "id", required = false)

+ 3 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/message/SystemMessageController.java

@ -99,6 +99,9 @@ public class SystemMessageController extends EnvelopRestEndpoint {
                filters=filters+";del=1";
            }
            List<SystemMessageDO> list  = systemMessageService.search(fields,filters,sorts,page,pageSize);
            for (SystemMessageDO systemMessageDO:list){
            }
            int count = (int) systemMessageService.getCount(filters);
            return success(list, count, page, pageSize, SystemMessageDO.class);
        }catch (Exception e){

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -1651,10 +1651,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                               @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
                               @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                               @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
                               @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize){
                               @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize,
                               @ApiParam(name = "isShow", value = "是否显示(1显示0不显示)", required = false)
                                   @RequestParam(value = "isShow", required = false)Integer isShow){
        try {
            return baseUserMsgService.getMessage(doctor,showAll,showAllType,beginTime,endTime,patient,page,pageSize);
            return baseUserMsgService.getMessage(doctor,showAll,showAllType,beginTime,endTime,patient,page,pageSize,isShow);
        } catch (Exception e) {
            return failedException(e);
        }

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

@ -138,6 +138,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private TasyNatService tasyNatService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private HcyyPrescriptionService hcyyPrescriptionService;
    @Value("${qywx.id}")
    private String qywxId;
@ -225,7 +227,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
                vos = tnPrescriptionService.findOutpatientList(patient, cardNo, startTime, endTime, demoFlag, ksdm, flag);
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
                vos = hcyyPrescriptionService.selectOutpatientList(patient,startTime,endTime,cardNo);
            } else {
                return ListEnvelop.getError("尚未开发!");
            }
@ -250,7 +252,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
                obj = tnPrescriptionService.findOutpatientInfo(patient, conNo, demoFlag, null);
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
                obj = hcyyPrescriptionService.selectOutpatientInfo(patient,conNo);
            } else {
                return ObjEnvelop.getError("尚未开发!");
            }
@ -279,7 +281,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
                obj = tnPrescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo, demoFlag);
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
                obj = hcyyPrescriptionService.selectOriginPrescriptionListLocal(registerSn,patNo,admNo,realOrder);
            } else {
                return ListEnvelop.getError("尚未开发!");
            }
@ -626,8 +628,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getICD10(pyKey, false));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
            return success(hcyyPrescriptionService.selectIcd10Dict(pyKey));
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -652,8 +653,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getDrugDictionary(drugNo, pyKey, null, groupNo, null));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
            return success(hcyyPrescriptionService.selectDrugDict(pyKey,drugNo));
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -673,8 +673,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getDrugUse(pyKey, demoFlag));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
            return success(hcyyPrescriptionService.selectMedicineUsed(pyKey));
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -692,8 +691,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getDrugFrequency(demoFlag));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
            return success(hcyyPrescriptionService.selectFrequencyDict());
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -837,6 +835,117 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.pushListDrug)
    @ApiOperation(value = "财务报表导出", notes = "财务报表导出")
    public Envelop pushListDrug(@ApiParam(name = "type", value = "1收入日报2预缴金报表3资金分部报表4药品汇总表5药品明细表")
                                 @RequestParam(value = "type", required = true) String type,
                                 @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                                 @RequestParam(value = "startTime", required = false) String startTime,
                                 @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                                 @RequestParam(value = "endTime", required = false) String endTime,
                                @ApiParam(name = "businessType", value = "1查询2导出")
                                    @RequestParam(value = "businessType", required = false) String businessType,
                                 HttpServletResponse response) throws Exception {
        try{
            List<Map<String, Object>> list = new ArrayList<>();
            if (type.equalsIgnoreCase("1")){
                //收入日报
                list = prescriptionService.selectPriceTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("2")){
                //预缴金报表
                list = prescriptionService.selectCardPriceTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("3")){
                //资金分部报表
                list = prescriptionService.selectTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("4")){
                //药品汇总表
                list = prescriptionService.selectDoctorTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("5")){
                //药品明细表
                list = prescriptionService.selectDrugTotal(startTime,endTime);
            }
            if (businessType.equalsIgnoreCase("2")){
                if (type.equalsIgnoreCase("1")){
                    response.setContentType("octets/stream");
                    response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("互联网医院收入日报表_"+startTime+"_"+endTime)+".xls"));
                    OutputStream os = response.getOutputStream();
                    prescriptionService.pushListWritePriceTotal(os, list,startTime,endTime);
                }else if (type.equalsIgnoreCase("2")){
                    response.setContentType("octets/stream");
                    response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("互联网医院预缴金日报表_"+startTime+"_"+endTime)+".xls"));
                    OutputStream os = response.getOutputStream();
                    prescriptionService.pushListCardPriceTotal(os, list,startTime,endTime);
                }else if (type.equalsIgnoreCase("3")){
                    response.setContentType("octets/stream");
                    response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("互联网医院收款日报表_"+startTime+"_"+endTime)+".xls"));
                    OutputStream os = response.getOutputStream();
                    prescriptionService.pushListTotal(os, list,startTime,endTime);
                }else if (type.equalsIgnoreCase("4")){
                    response.setContentType("octets/stream");
                    response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("互联网医院药品汇总表_"+startTime+"_"+endTime)+".xls"));
                    OutputStream os = response.getOutputStream();
                    prescriptionService.pushListDoctorTotal(os, list,startTime,endTime);
                }else if (type.equalsIgnoreCase("5")){
                    response.setContentType("octets/stream");
                    response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("互联网医院药品明细表_"+startTime+"_"+endTime)+".xls"));
                    OutputStream os = response.getOutputStream();
                    prescriptionService.pushListDrugTotal(os, list,startTime,endTime);
                }
            }
            return success(list);
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectListDrug)
    @ApiOperation(value = "财务报表导出", notes = "财务报表导出")
    public Envelop selectListDrug(@ApiParam(name = "type", value = "1收入日报2预缴金报表3资金分部报表4药品汇总表5药品明细表")
                                @RequestParam(value = "type", required = true) String type,
                                @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                                @RequestParam(value = "startTime", required = false) String startTime,
                                @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                                @RequestParam(value = "endTime", required = false) String endTime,
                                @ApiParam(name = "businessType", value = "1查询2导出")
                                @RequestParam(value = "businessType", required = false) String businessType,
                                HttpServletResponse response) throws Exception {
        try{
            List<Map<String, Object>> list = new ArrayList<>();
            if (type.equalsIgnoreCase("1")){
                //收入日报
                list = prescriptionService.selectPriceTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("2")){
                //预缴金报表
                list = prescriptionService.selectCardPriceTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("3")){
                //预缴金报表
                list = prescriptionService.selectTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("4")){
                //药品汇总表
                list = prescriptionService.selectDoctorTotal(startTime,endTime);
            }else if (type.equalsIgnoreCase("5")){
                //药品汇总表
                list = prescriptionService.selectDrugTotal(startTime,endTime);
            }
            if (businessType.equalsIgnoreCase("2")){
                if (type.equalsIgnoreCase("1")){
                    response.setContentType("octets/stream");
                    response.setHeader("Content-Disposition", "attachment; filename=" + new String("pushDataListPriceTotal.xls"));
                    OutputStream os = response.getOutputStream();
                    prescriptionService.pushListWritePriceTotal(os, list,startTime,endTime);
                }
            }
            return success(list);
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.searchRecordWrite)
    @ApiOperation(value = "咨询记录导出", notes = "咨询记录导出")
    public Envelop searchRecordWrite(@ApiParam(name = "doctor", value = "医生id")
@ -887,7 +996,15 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取卡信息", notes = "获取卡信息")
    public ObjEnvelop getCardInfo(@ApiParam(name = "cardNo", value = "卡号")
                                  @RequestParam(value = "cardNo", required = false) String cardNo) throws Exception {
        return success(prescriptionService.getCardInfo(cardNo, demoFlag));
        if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            return success(prescriptionService.getCardInfo(cardNo, demoFlag));
        } else if ("xm_hcyy_wx".equalsIgnoreCase(wxId)) {
            return success(hcyyPrescriptionService.selectCardInfo(cardNo));
        }else {
            ObjEnvelop objEnvelop = new ObjEnvelop();
            objEnvelop.setMessage("暂不支持!");
            return objEnvelop;
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorWithWork)

+ 16 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

@ -118,6 +118,22 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
			return  one;
		}
	}
	/**
	 * 更新/保存健康文章
	 * @param jsonData
	 * @return
	 * @throws Exception
	 */
	public KnowledgeArticleDO updateIsShow(String id,Integer isShow) throws  Exception {
		KnowledgeArticleDO one = knowledgeArticleDao.findOne(id);
		one.setIsShow(isShow);
		one.setUpdateTime(new Date());
		knowledgeArticleDao.save(one);
		return  one;
	}
	
	//审核/退回文章
	public KnowledgeArticleDO reviewArticle(String articleId,Integer status,String reason) throws Exception{