Selaa lähdekoodia

[医保代码]

wangzhinan 3 vuotta sitten
vanhempi
commit
cbc0bfd0e7

+ 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)

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

@ -674,8 +674,11 @@ public class FileUploadService {
    public boolean isFileFlag(String type){
        type = type.toLowerCase();
        if (type.contains(".")){
            type = type.substring(type.lastIndexOf("."),type.length()-1);
        }
        logger.info(type);
        List img = new ArrayList(Arrays.asList("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"));
        List img = new ArrayList(Arrays.asList("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;
        }

+ 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;
        }
    }
}

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

@ -2727,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);
@ -2883,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", "诊断完成");

+ 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=======================
}

+ 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"
			}
		}
	}]
}

+ 10 - 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;

+ 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";

+ 18 - 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("尚未开发!");
        }
@ -998,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)