Procházet zdrojové kódy

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

liubing před 3 roky
rodič
revize
23a0c35fb2

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

@ -3231,7 +3231,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param size
     * @param size
     * @return
     * @return
     */
     */
    public MixEnvelop findExpressageList2(String status, String oneselfPickupFlg, String nameKey, String startTime, String endTime, Integer page, Integer size, String wxId,String patientName) {
    public MixEnvelop  findExpressageList2(String status, String oneselfPickupFlg, String nameKey, String startTime, String endTime, Integer page, Integer size, String wxId,String patientName) {
        String totalSql = "SELECT " +
        String totalSql = "SELECT " +
                " COUNT(1) AS \"total\" " +
                " COUNT(1) AS \"total\" " +
                " FROM " +
                " FROM " +
@ -3284,9 +3284,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        }
        String sql = "SELECT  ";
        String sql = "SELECT  ";
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
            if (flag) {
                sql = sql + "date_format(e.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"expressCreateTime\",";
                sql = sql + "date_format(e.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"expressCreateTime\",";
            }else {
            } else {
                sql = sql + "to_char(e.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"expressCreateTime\",";
                sql = sql + "to_char(e.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"expressCreateTime\",";
            }
            }
@ -3294,9 +3294,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql = sql + "date_format(e.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"expressCreateTime\",";
            sql = sql + "date_format(e.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"expressCreateTime\",";
        }
        }
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
            if (flag) {
                sql = sql + "date_format(p.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"createTime\",";
                sql = sql + "date_format(p.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"createTime\",";
            }else {
            } else {
                sql = sql + "to_char(p.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"createTime\",";
                sql = sql + "to_char(p.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"createTime\",";
            }
            }
@ -3304,126 +3304,36 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql = sql + "date_format(p.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"createTime\",";
            sql = sql + "date_format(p.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"createTime\",";
        }
        }
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
            if (flag) {
                sql = sql + "date_format(p.pay_time,'YYYY-MM-DD hh24:mi:ss')  AS \"payTime\",";
                sql = sql + "date_format(p.pay_time,'YYYY-MM-DD hh24:mi:ss')  AS \"payTime\",";
            }else {
            } else {
                sql = sql + "to_char(p.pay_time,'YYYY-MM-DD hh24:mi:ss')  AS \"payTime\",";
                sql = sql + "to_char(p.pay_time,'YYYY-MM-DD hh24:mi:ss')  AS \"payTime\",";
            }
            }
        } else {
        } else {
            sql = sql + "date_format(p.pay_time,'%Y-%m-%d %H:%i:%S' )  AS \"payTime\",";
            sql = sql + "date_format(p.pay_time,'%Y-%m-%d %H:%i:%S' )  AS \"payTime\",";
        }
        }
        if ("xm_ykyy_wx".equals(wxId)) {
            sql = sql +
                    "p.id AS \"prescriptionId\",\n" +
                    "p.create_time AS \"time\",\n" +
                    "\te. NAME AS \"name\",\n" +
                    "\tp.pay_time AS \"pay_time\",\n" +
                    "\tp.real_order AS \"realOrder\",\n" +
                    "\to.patient_name AS \"patientName\",\n" +
                    "\tp.create_time AS \"create_time\",\n" +
                    "\te.oneself_pickup_flg AS \"oneself_pickup_flg\",\n" +
                    "\tp. STATUS AS \"status\"\n" +
                    "FROM\n" +
                    "\twlyy_outpatient o\n" +
                    "JOIN wlyy_prescription p ON p.outpatient_id = o.id\n" +
                    "JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id\n" +
                    "WHERE\n" +
                    "\t1 = 1\n";//oracle
            if (StringUtils.isNotBlank(status)) {
                totalSql += " AND p.status in(" + status + ") ";
            }
            if (StringUtils.isNotBlank(oneselfPickupFlg)) {
                totalSql += " AND e.oneself_pickup_flg = " + oneselfPickupFlg+" ";
            }
            if (StringUtils.isNotBlank(nameKey)) {
                totalSql += " AND e.name like '%" + nameKey + "%' ";
            }
            if (StringUtils.isNotBlank(patientName)) {
                totalSql += " AND o.patient_name like '%" + patientName + "%' ";
            }
            if (StringUtils.isNotBlank(startTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    totalSql += " AND p.create_time >='" + startTime + " 00:00:00'";
                }
            }
            if (StringUtils.isNotBlank(endTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    sql += " AND p.create_time <='" + endTime + " 23:59:59'";
                }
            }
        } else {
            sql = sql +
                    "p.id AS \"prescriptionId\",\n" +
                    "\tp.create_time AS \"time\",\n" +
                    "\te. NAME AS \"name\",\n" +
                    "\tp.pay_time AS \"pay_time\",\n" +
                    "\tp.real_order AS \"realOrder\",\n" +
                    "\to.patient_name AS \"patientName\",\n" +
                    "\tp.create_time AS \"create_time\",\n" +
                    "\te.oneself_pickup_flg AS \"oneself_pickup_flg\",\n" +
                    "\tp. STATUS AS \"status\"\n" +
                    "FROM\n" +
                    "\twlyy_outpatient o\n" +
                    "JOIN wlyy_prescription p ON p.outpatient_id = o.id\n" +
                    "JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id\n" +
                    "WHERE\n" +
                    "\t1 = 1\n";//MySQL
            if (StringUtils.isNotBlank(status)) {
                totalSql += " AND p.status in(" + status + ") ";
            }
            if (StringUtils.isNotBlank(oneselfPickupFlg)) {
                totalSql += " AND e.oneself_pickup_flg = " + oneselfPickupFlg+" ";
            }
            if (StringUtils.isNotBlank(nameKey)) {
                totalSql += " AND e.name like '%" + nameKey + "%' ";
            }
            if (StringUtils.isNotBlank(patientName)) {
                totalSql += " AND o.patient_name like '%" + patientName + "%' ";
            }
            if (StringUtils.isNotBlank(startTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    totalSql += " AND p.create_time >='" + startTime + " 00:00:00'";
                }
            }
            if (StringUtils.isNotBlank(endTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    sql += " AND p.create_time <='" + endTime + " 23:59:59'";
                }
            }
        }
        sql = sql + " e.name as \"name\", " +
                " e.oneself_pickup_flg AS \"oneselfPickupFlg\", " +
                " o.id AS \"outpatientId\", " +
                " o.icd10_name AS \"icd10Name\", " +
                " p.status as \"status\", " +
                " p.id AS \"prescriptionId\" ," +
                " e.id AS \"expressageId\" ," +
                " p.real_order AS \"realOrder\" ," +
                " p.origin_real_order AS \"originRealOrder\"," +
                " o.patient_name as \"patientName\" " +
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id " +
                " WHERE" +
                " 1=1";
        if (StringUtils.isNotBlank(status)) {
        if (StringUtils.isNotBlank(status)) {
            sql += " AND p.status in(" + status + ") ";
            sql += " AND p.status in(" + status + ") ";
        }
        }
        if (StringUtils.isNotBlank(oneselfPickupFlg)) {
        if (StringUtils.isNotBlank(oneselfPickupFlg)) {
            sql += " AND e.oneself_pickup_flg =" + oneselfPickupFlg+" ";
            sql += " AND e.oneself_pickup_flg =" + oneselfPickupFlg + " ";
        }
        }
        if (StringUtils.isNotBlank(nameKey)) {
        if (StringUtils.isNotBlank(nameKey)) {
            sql += " AND e.name like '%" + nameKey + "%' ";
            sql += " AND e.name like '%" + nameKey + "%' ";
@ -3431,12 +3341,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (StringUtils.isNotBlank(patientName)) {
        if (StringUtils.isNotBlank(patientName)) {
            sql += " AND o.patient_name like '%" + patientName + "%' ";
            sql += " AND o.patient_name like '%" + patientName + "%' ";
            /*sql += " and (a.patient_name like '" + title + "' OR a.doctor_name like '" + title + "' OR a.dept_name like '" + title + "' )"*/
        }
        }
        if (StringUtils.isNotBlank(startTime)) {
        if (StringUtils.isNotBlank(startTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                if (flag) {
                    sql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }else {
                } else {
                    sql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }
                }
            } else {
            } else {
@ -3446,9 +3357,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        }
        if (StringUtils.isNotBlank(endTime)) {
        if (StringUtils.isNotBlank(endTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                if (flag) {
                    sql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }else {
                } else {
                    sql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }
                }
@ -3457,18 +3368,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
            }
        }
        }
        sql +=" order by p.create_time desc ";
        sql += " order by p.create_time desc ";
        /*       sql += " LIMIT " + (page - 1) * size + "," + size + "";*/
        /*       sql += " LIMIT " + (page - 1) * size + "," + size + "";*/
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql, page, size);
        for (Map<String, Object> map : mapList) {
        for (Map<String, Object> map : mapList) {
            if (map.get("prescriptionId") != null) {
            if (map.get("prescriptionId") != null) {
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(map.get("prescriptionId").toString(), 1);
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(map.get("prescriptionId").toString(), 1);
                map.put("info", wlyyPrescriptionInfoDOS);
                map.put("info", wlyyPrescriptionInfoDOS);
                String infoName = "";
                String infoName = "";
                for (WlyyPrescriptionInfoDO info:wlyyPrescriptionInfoDOS) {
                for (WlyyPrescriptionInfoDO info : wlyyPrescriptionInfoDOS) {
                    infoName += info.getDrugName() + "*" + info.getQuantity() + ",";
                    infoName += info.getDrugName() + "*" + info.getQuantity() + ",";
                }
                }
                map.put("infooName",infoName);
                map.put("infooName", infoName);
            }
            }
        }
        }
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
@ -3837,31 +3748,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            for (Map<String, Object> m : list) {
            for (Map<String, Object> m : list) {
                /*Object status = m.get("status");
                String statuss = "";
                if (status == null) {
                    statuss += " ";
                }else if (status.equals("0")) {
                    statuss += "未支付";
                }else if (status.equals("1")) {
                    statuss += "已支付";
                }else if (status.equals("2")) {
                    statuss += "交易关闭";
                }else if (status.equals("3")) {
                    statuss += "支付超时";
                }else if (status.equals("4")) {
                    statuss += "交易完成";
                }else if (status.equals("5")) {
                    statuss += "交易进行中";
                }else if (status.equals("6")) {
                    statuss += "退款申请";
                }else if (status.equals("9")) {
                    statuss += "退款完成";
                }else {
                    statuss += " ";
                }*/
                String odry = "";
                String odry = "";
                String orderCategory = "";
                String orderCategory = "";
                String odte = "";
                String odte = "";
@ -3871,34 +3757,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if (m.get("orderCategory")==null){
                if (m.get("orderCategory")==null){
                    odry = null;
                    odry = null;
                }else {
                }else {
                    orderCategory = m.get("orderCategory").toString();
                    if (orderCategory.equals("1")) {
                        odry += "专家咨询";
                    }else if (orderCategory.equals("2")) {
                        odry += "复诊";
                    }else if (orderCategory.equals("3")) {
                        odry += "视频诊室";
                    }else if (orderCategory.equals("4")) {
                        odry += "处方";
                        odte += "处方";
                    }else if (orderCategory.equals("5")) {
                        odry += "就诊卡充值";
                        odte += "就诊卡充值";
                    }else {
                        odry += " ";
                    if(m.get("orderType") == null) {
                        odte = null;
                    }else{
                        String orderType =  m.get("orderType").toString();
                        orderCategory = m.get("orderCategory").toString();
                        if (orderCategory.equals("1")) {
                            odry += "专家咨询";
                            if (orderType.equalsIgnoreCase("1")) {
                                odte += "图文";
                            }else if (orderType.equalsIgnoreCase("3")) {
                                odte += "视频";
                            }
                        }else if (orderCategory.equals("2")) {
                            odry += "在线复诊";
                            if (orderType.equalsIgnoreCase("1")) {
                                odte += "图文";
                            }else if (orderType.equalsIgnoreCase("3")) {
                                odte += "视频";
                            }
                        }else if (orderCategory.equals("4")) {
                            odry += "处方";
                            odte += "处方";
                        }else if (orderCategory.equals("5")) {
                            odry += "就诊卡充值";
                            odte += "就诊卡充值";
                        }else {
                            odry += " ";
                        }
                    }
                    }
                }
                }
                if(m.get("orderType") == null) {
                    odte = null;
                }else{
                    String orderType =  m.get("orderType").toString();
                    if (orderType.equalsIgnoreCase("1")) {
                        odte += "图文";
                    }else if (orderType.equalsIgnoreCase("3")) {
                        odte += "视频";
                    }
                }
                if (m.get("status") == null) {
                if (m.get("status") == null) {
                    status = null;
                    status = null;

+ 5 - 3
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -2114,15 +2114,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (StringUtils.isNoneBlank(idCard)){
        if (StringUtils.isNoneBlank(idCard)){
            sql+=" and b.idcard like '%"+idCard+"%'";
            sql+=" and b.idcard like '%"+idCard+"%'";
        }
        }
        if (StringUtils.isNoneBlank(medicard)){
            sql+=" and t.relation_code like '%"+medicard+"%'";
        }
        if (status!=null){
        if (status!=null){
            sql+=" and t.status ="+status+"";
            sql+=" and t.status ="+status+"";
        }
        }
        if (StringUtils.isNoneBlank(orderType)){
        if (StringUtils.isNoneBlank(orderType)){
            sql+=" and t.order_type like %"+orderType+"%";
            sql+=" and t.order_type ="+orderType+"";
        }
        }
        if (StringUtils.isNoneBlank(orderCategory)){
        if (StringUtils.isNoneBlank(orderCategory)){
            if (orderCategory.equalsIgnoreCase("2")){
            if (orderCategory.equalsIgnoreCase("2")){
                sql+=" and t.order_category IN ('2','3') ";
                sql+=" and t.order_category IN ('2','3') ";

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -179,6 +179,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                "\t'未知'\n" +
                "\t'未知'\n" +
                "END AS \"sex\",\n" +
                "END AS \"sex\",\n" +
                " mobile AS \"phone\",\n" +
                " mobile AS \"phone\",\n" +
                " ykt_id AS \"yktId\",\n" +
                " committee_name AS \"committeeName\",\n" +
                " committee_name AS \"committeeName\",\n" +
                " province_name AS \"provinceName\"," +
                " province_name AS \"provinceName\"," +
                " city_name AS \"cityName\", " +
                " city_name AS \"cityName\", " +
@ -340,6 +341,9 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            basePatientDO1.setResidentialArea(basePatientDO.getResidentialArea());
            basePatientDO1.setResidentialArea(basePatientDO.getResidentialArea());
            basePatientDO1.setCommitteeCode(basePatientDO.getCommitteeCode());
            basePatientDO1.setCommitteeCode(basePatientDO.getCommitteeCode());
            basePatientDO1.setCommitteeName(basePatientDO.getCommitteeName());
            basePatientDO1.setCommitteeName(basePatientDO.getCommitteeName());
            if(StringUtils.isNotBlank(basePatientDO.getYktId())){
                basePatientDO1.setYktId(basePatientDO.getYktId());
            }
            // 保存修改的居民信息
            // 保存修改的居民信息
            basePatientDao.save(basePatientDO1);
            basePatientDao.save(basePatientDO1);
        }
        }

+ 50 - 133
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -4316,81 +4316,60 @@ public class ImService {
    public MixEnvelop recordByDoctor(String doctor, String id,String type, Integer status,String title, String start_time, String end_time, String patient) { //
    public MixEnvelop recordByDoctor(String doctor, String id,String type, Integer status,String title, String start_time, String end_time, String patient) { //
        String sql = "";
        String sql = "";
        sql = "SELECT " +
                "a.id AS \"id\"," +
                "op.pay_status AS \"payStatus\"," +
                "op.type as \"type\"," +
                "op.outpatient_type as \"outpatientType\"," +
                "op.description AS \"title\"," +
                "op.description AS \"symptoms\",";
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag) {
                sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
                sql = sql + "date_format(op.end_time,'%Y-%m-%d %H:%i:%S' )  AS \"endTime\", ";
            } else {
                sql = sql + "to_char(op.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"czrq\",";
                sql = sql + "to_char(op.end_time,'YYYY-MM-DD hh24:mi:ss')  AS \"endTime\",";
            }
        } else {
            sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
            sql = sql + "date_format(op.end_time,'%Y-%m-%d %H:%i:%S' )  AS \"endTime\",";
        }
        sql = sql + "op.status AS \"status\"," +
                "b.evaluate AS \"evaluate\"," +
                "d.name AS \"patientName\"," +
                "d.id as \"patientId\"," +
                "d.idcard as \"patientIdcard\"," +
                "d.sex as \"patientSex\"," +
                "op.consumer as \"consumer\"," +
                "op.consumer_name as \"consumerName\"," +
                "op.consumer_mobile as \"consumerMobile\"," +
                "op.id as \"outpatientId\"," +
                "op.type as \"consultType\"," +
                "op.general_doctor as \"generalDoctor\"," +
                "op.icd10_name as \"icd10Name\"," +
                "d.photo AS \"patientPhoto\" , " +
                "op.doctor as \"doctor\" ," +
                "op.source as \"source\"  ," +
                "op.card_no as \"cardNo\"  ," +
                "op.patient_cancel_value as \"patientCancelValue\" ," +
                "op.patient_cancel_remark as \"patient_cancel_remark\"  " +
                "FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
                " LEFT join wlyy_consult_team b on a.id = b.consult" +
                " LEFT JOIN base_patient d on op.patient = d.id " +
                " WHERE 1=1 ";
        if (status == null) {
            sql += " and op.status = 0 and op.pay_status =1 and op.pay_status =2 and op.pay_status =3";
        sql ="SELECT\n" +
                        "\ta.patient_name AS \"pname\",\n" +
                        "\ta.doctor_name AS \"dname\",\n" +
                        "\ta.dept_name AS \"dept\",\n" +
                        "\ta.outpatient_type AS \"type\",\n" +
                        "\ta.create_time AS \"ctime\",\n" +
                        "\ta.register_date AS \"rtime\",\n" +
                        "\ta.end_time AS \"etime\",\n" +
                        "\ta.description AS \"des\",\n" +
                        "\tb. STATUS AS \"pay\",\n" +
                        "\ta. STATUS AS \"STATUS\"\n" +
                        "FROM\n" +
                        "\twlyy_outpatient a\n" +
                        "LEFT JOIN wlyy_prescription b ON a.id = b.outpatient_id\n" +
                        "LEFT JOIN wlyy_consult c ON c.relation_code = a.id\n" +
                        "LEFT JOIN wlyy_consult_team d ON c.id = d.consult\n" +
                        "LEFT JOIN base_patient e ON a.patient = e.id\n" +
                        "WHERE\n" +
                        "\t1 = 1 ";
        if (status == null){
        }else if (status == 1) {
            sql += " and a.status = 0 and a.pay_status =1 ";
        } else if (status == 0) {
        } else if (status == 0) {
        } else if (status == 1) {
            sql += " and op.status = 0 and op.pay_status =1 ";
        } else if (status == 2){
            sql += " and op.status = 1";
        } else if (status == 3) {
            sql += " and op.status = 2";
        } else if (status == 2) {
            sql += " and a.status = 1";
        } else {
            sql += " and a.status = " + status;
        }
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
            sql += " AND op.doctor='" + doctor + "' ";
            sql += " AND a.doctor='" + doctor + "' ";
        }
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(patient)) {
        if (org.apache.commons.lang.StringUtils.isNotBlank(patient)) {
            sql += " AND (op.consumer='" + patient + "' or op.patient ='" + patient + "')";
            sql += " AND (a.consumer='" + patient + "' or a.patient ='" + patient + "')";
        }
        }
        if (!StringUtils.isEmpty(title)) {
        if (!StringUtils.isEmpty(title)) {
            title = "%" + title + "%";
            title = "%" + title + "%";
            sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
            sql += " and (a.patient_name like '" + title + "' OR a.doctor_name like '" + title + "' OR a.dept_name like '" + title + "' )";
        }
        }
        if (!StringUtils.isEmpty(start_time)) {
        if (!StringUtils.isEmpty(start_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                if (flag) {
                    sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                } else {
                    sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
                }
            } else {
            } else {
                sql += " and op.create_time >= '" + start_time + "'";
                sql += " and a.create_time >= '" + start_time + "'";
            }
            }
        }
        }
@ -4398,13 +4377,13 @@ public class ImService {
        if (!StringUtils.isEmpty(end_time)) {
        if (!StringUtils.isEmpty(end_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                if (flag) {
                    sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                } else {
                    sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
                }
            } else {
            } else {
                sql += " and op.create_time <= '" + end_time + "'";
                sql += " and a.create_time <= '" + end_time + "'";
            }
            }
        }
        }
@ -4412,27 +4391,29 @@ public class ImService {
        //咨询类型
        //咨询类型
        if (!StringUtils.isEmpty(type)) {
        if (!StringUtils.isEmpty(type)) {
            if (type.equalsIgnoreCase("9")) {
            if (type.equalsIgnoreCase("9")) {
                sql += " AND op.type =1 and op.outpatient_type = 1";
                sql += " AND a.type =1 and a.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("16")) {
            } else if (type.equalsIgnoreCase("16")) {
                sql += " AND op.type =2 and op.outpatient_type = 1";
                sql += " AND a.type =2 and a.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("1")) {
            } else if (type.equalsIgnoreCase("1")) {
                sql += " AND op.type =1 and op.outpatient_type = 3";
                sql += " AND a.type =1 and a.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("15")) {
            } else if (type.equalsIgnoreCase("15")) {
                sql += " AND op.type =3 and op.outpatient_type = 3";
                sql += " AND a.type =3 and a.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("17")) {
            } else if (type.equalsIgnoreCase("17")) {
                sql += " AND op.type =2 and op.outpatient_type = 3";
                sql += " AND a.type =2 and a.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("12")) {
            } else if (type.equalsIgnoreCase("12")) {
                sql += " AND op.outpatient_type = 2";
                sql += " AND a.outpatient_type = 2";
            } else {
            } else {
                sql += " AND op.type in (1,2,3) ";
                sql += " AND a.type in (1,2,3) ";
            }
            }
        }
        }
        if (!StringUtils.isEmpty(id)) {
        if (!StringUtils.isEmpty(id)) {
            sql += " and a.id = '" + id + "'";
            sql += " and a.id = '" + id + "'";
        }
        }
        sql += " ORDER BY op.create_time desc ";
        List<Map<String, Object>> List = hibenateUtils.createSQLQuery(sql);//
        for (Map<String, Object> map : List) {
        sql = sql + "\tORDER BY a.create_time desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> map : mapList) {
            if (map.get("patientIdcard") != null) {
            if (map.get("patientIdcard") != null) {
                String idcard = map.get("patientIdcard").toString();
                String idcard = map.get("patientIdcard").toString();
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
@ -4503,73 +4484,9 @@ public class ImService {
                }
                }
            }
            }
        }
        }
        String pushSql = "";
        pushSql =
                "SELECT\n" +
                        "\ta.patient_name AS \"pname\",\n" +
                        "\ta.consumer_name AS \"dname\",\n" +
                        "\ta.dept_name AS \"dept\",\n" +
                        "\ta.outpatient_type AS \"type\",\n" +
                        "\ta.create_time AS \"ctime\",\n" +
                        "\ta.register_date AS \"rtime\",\n" +
                        "\ta.end_time AS \"etime\",\n" +
                        "\ta.description AS \"des\",\n" +
                        "\tb. STATUS AS \"pay\",\n" +
                        "\ta. STATUS AS \"STATUS\"\n" +
                        "FROM\n" +
                        "\twlyy_outpatient a\n" +
                        "LEFT JOIN wlyy_prescription b ON a.id = b.outpatient_id\n" +
                        "WHERE\n" +
                        "\t1 = 1";
        if (status != null) {
            pushSql += " AND a. STATUS in(" + status + ") ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(type)) {
            if (type.equals("0")) {
            }else {
                pushSql += " AND a.type = " + type +" ";
            }
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(doctor)) {
            pushSql += " AND a.doctor_name like '%" + doctor + "%' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(patient)) {
            pushSql += " AND a.patient_name like '%" + patient + "%' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(start_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    pushSql += " and a.create_time >= str_to_date('" + start_time + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    pushSql += " and a.create_time >= to_date('" + start_time + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                pushSql += " AND a.create_time >='" + start_time + " 00:00:00'";
            }
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(end_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    pushSql += " and a.create_time <= str_to_date('" + end_time + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    pushSql += " and a.create_time <= to_date('" + end_time + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " AND a.create_time <='" + end_time + " 23:59:59'";
            }
        }
        pushSql = pushSql + "\tORDER BY ctime desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(pushSql);
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
    }
    }
    public List<Map<String, Object>> doctorUpcomingList2(String doctorCode, String type) {
    public List<Map<String, Object>> doctorUpcomingList2(String doctorCode, String type) {
        String sql = "";
        String sql = "";
        if ("1,15,17".equals(type)) {
        if ("1,15,17".equals(type)) {