Browse Source

咨询记录导出报表

hxm 3 years ago
parent
commit
372249a7d2

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

@ -3394,7 +3394,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"订单日期", "收货人", "诊断结果", "配送方式", "订单状态"};
            String[] header = {"订单日期", "处方编号", "就诊人姓名", "收货人", "订单药品", "配送方式", "支付时间", "是否开方", "订单状态"};//"订单日期", "收货人", "诊断结果", "配送方式", "订单状态"
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
@ -3404,10 +3404,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            int i = 1;
            for (Map<String, Object> m : ls) {
                addCell(ws, i, 0, m.get("createTime").toString());
                addCell(ws, i, 1, m.get("origin_real_order").toString());
                addCell(ws, i, 2, m.get("patient_name").toString());
                addCell(ws, i, 3, m.get(" ").toString());
                addCell(ws, i, 4, m.get(" ").toString());
                addCell(ws, i, 5, m.get("dispensary_type").toString());
                addCell(ws, i, 6, m.get("pay_time").toString());
                addCell(ws, i, 7, m.get("deal_status").toString());
                addCell(ws, i, 8, m.get("pay_status").toString());
                /*addCell(ws, i, 0, m.get("createTime").toString());
                addCell(ws, i, 1, (String) m.get("name"), "");
                addCell(ws, i, 2, (String) m.get("icd10Name"), "");
                addCell(ws, i, 3, getOneselfPickupFlgString((Integer) m.get("oneselfPickupFlg")), "");
                addCell(ws, i, 4, getStatusName((Integer) m.get("status")), "");
                addCell(ws, i, 4, getStatusName((Integer) m.get("status")), "");*/
                i++;
            }
            wwb.write();
@ -3443,7 +3452,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                addCell(ws, i, 6, (String) m.get("etime"));
                addCell(ws, i, 7, (String) m.get("des"));
                addCell(ws, i, 8, (String) m.get("pay"));
                addCell(ws, i, 9, (String) m.get("sta"));
                addCell(ws, i, 9, (String) m.get("status"));
                i++;
            }
            wwb.write();

+ 115 - 125
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -4218,23 +4218,105 @@ public class ImService {
    }
    /**
     * 导出医生所有的咨询记录
     * 查询患者所有的咨询记录总数
     * * @param doctor 患者标识
     * * @param id 会话ID(等同IM表topicId)
     * * @param type 咨询会话类型
     * * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
     * * @param title 标题关键字
     * * @param start_time 开始时间
     * * @param end_time 结束时间
     *
     * @param doctor     医生标识
     * @param id         会话ID(等同IM表topicId)
     * @param type       咨询会话类型 : 0 全部
     * @param status     咨询状态:0全部,1候诊中,2就诊中,3结束
     * @param title      标题关键字
     * @param start_time 开始时间
     * @param end_time   结束时间
     * @return
     */
    @Transactional(readOnly = true)
    public List<Map<String, Object>> findRecordNew(String doctor, String id,
                                                   String type, Integer status,
                                                   String title, String start_time, String end_time, String patient) {
    public Long countConsultRecordByDoctor2(String doctor, String id, String type, Integer status, String title, String start_time, String end_time) {
        String sql = "";
        sql = "SELECT " +
                " COUNT(1) AS \"total\" " +
                "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 == 1) {
            sql += " and op.status = 0";
        } else if (status == 0) {
        } else if (status == 2) {
            sql += " and op.status = 1";
        } else {
            sql += " and op.status = " + status;
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
            sql += " AND op.doctor='" + doctor + "' ";
        }
        if (!StringUtils.isEmpty(title)) {
            title = "%" + title + "%";
            sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
        }
        if (!StringUtils.isEmpty(start_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                    sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time >= '" + start_time + "'";
            }
        }
        if (!StringUtils.isEmpty(end_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                    sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time <= '" + end_time + "'";
            }
        }
        //咨询类型
        if (!StringUtils.isEmpty(type)) {
            if (type.equalsIgnoreCase("9")) {
                sql += " AND op.type =1 and op.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("16")) {
                sql += " AND op.type =2 and op.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("1")) {
                sql += " AND op.type =1 and op.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("15")) {
                sql += " AND op.type =3 and op.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("17")) {
                sql += " AND op.type =2 and op.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("12")) {
                sql += " AND op.outpatient_type = 2";
            } else {
                sql += " AND op.type in (1,2,3) ";
            }
        }
        if (!StringUtils.isEmpty(id)) {
            sql += " and a.id = '" + id + "'";
        }
        sql += " ORDER BY op.create_time desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        Long count = 0L;
        if (mapList != null && mapList.size() > 0) {
            count = Long.parseLong(mapList.get(0).get("total").toString());
        }
        return count;
    }
    public MixEnvelop recordByDoctor() { //String doctor, String id,String type, Integer status,String title, String start_time, String end_time, String patient
        String sql = "";
        /*sql = "SELECT " +
                "a.id AS \"id\"," +
                "op.pay_status AS \"payStatus\"," +
                "op.type as \"type\"," +
@ -4347,7 +4429,7 @@ public class ImService {
            sql += " and a.id = '" + id + "'";
        }
        sql += " ORDER BY op.create_time desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql, page, pagesize);
        for (Map<String, Object> map : mapList) {
            if (map.get("patientIdcard") != null) {
                String idcard = map.get("patientIdcard").toString();
@ -4419,126 +4501,34 @@ public class ImService {
                }
            }
        }
        return mapList;
    }
    /**
     * 查询患者所有的咨询记录总数
     * * @param doctor 患者标识
     * * @param id 会话ID(等同IM表topicId)
     * * @param type 咨询会话类型
     * * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
     * * @param title 标题关键字
     * * @param start_time 开始时间
     * * @param end_time 结束时间
     *
     * @return
     */
    public Long countConsultRecordByDoctor2(String doctor, String id, String type, Integer status, String title, String start_time, String end_time) {
        String sql = "";
        sql = "SELECT " +
                " COUNT(1) AS \"total\" " +
                "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 == 1) {
            sql += " and op.status = 0";
        } else if (status == 0) {
        } else if (status == 2) {
            sql += " and op.status = 1";
        } else {
            sql += " and op.status = " + status;
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
            sql += " AND op.doctor='" + doctor + "' ";
        }
        if (!StringUtils.isEmpty(title)) {
            title = "%" + title + "%";
            sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
        }
        if (!StringUtils.isEmpty(start_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                    sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time >= '" + start_time + "'";
            }
        }
        if (!StringUtils.isEmpty(end_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                    sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time <= '" + end_time + "'";
            }
        }
        //咨询类型
        if (!StringUtils.isEmpty(type)) {
            if (type.equalsIgnoreCase("9")) {
                sql += " AND op.type =1 and op.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("16")) {
                sql += " AND op.type =2 and op.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("1")) {
                sql += " AND op.type =1 and op.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("15")) {
                sql += " AND op.type =3 and op.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("17")) {
                sql += " AND op.type =2 and op.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("12")) {
                sql += " AND op.outpatient_type = 2";
            } else {
                sql += " AND op.type in (1,2,3) ";
            }
        }
        if (!StringUtils.isEmpty(id)) {
            sql += " and a.id = '" + id + "'";
        }
        sql += " ORDER BY op.create_time desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        Long count = 0L;
        if (mapList != null && mapList.size() > 0) {
            count = Long.parseLong(mapList.get(0).get("total").toString());
        }
        return count;
    }
    public MixEnvelop recordByDoctor() {
        String sql = "";
        return mapList;*/
        sql = "select \n" +
                "IFNULL(a.patient_name,'null') AS pname,\n" +
                "IFNULL(a.doctor_name,'null') as dname,\n" +
                "IFNULL(a.dept_name,'null') as dept,\n" +
                "IFNULL(a.outpatient_type,'null') as type,\n" +
                "IFNULL(a.create_time,'null') as ctime,\n" +
                "IFNULL(a.register_date,'null') as rtime,\n" +
                "IFNULL(a.end_time,'null') as etime,\n" +
                "IFNULL(a.description,'null') as des,\n" +
                "IFNULL(a.patient_name,' ') AS pname,\n" +
                "IFNULL(a.doctor_name,' ') as dname,\n" +
                "IFNULL(a.dept_name,' ') as dept,\n" +
                "CASE a.outpatient_type\n" +
                "when 1 then '在线复诊'\n" +
                "when 2 then '协同门诊'\n" +
                "when 3 then '专家咨询'\n" +
                "else ' ' end type,\n" +
                "IFNULL(a.create_time,' ') as ctime,\n" +
                "IFNULL(a.con_date,' ') as rtime,\n" +
                "IFNULL(a.end_time,' ') as etime,\n" +
                "IFNULL(a.description,' ') as des,\n" +
                "IF(b.status >= 20 ,\"是\",\"否\") AS pay,\n" +
                "IFNULL(a.status,'null') as sta\n" +
                "CASE a.status \n" +
                "WHEN '0' THEN '全部'\n" +
                "WHEN '1' THEN '候诊中'\n" +
                "WHEN '2' THEN '就诊中'\n" +
                "when '3' then '结束'\n" +
                "ELSE '取消' end status\n" +
                "from \n" +
                "wlyy_outpatient a \n" +
                "LEFT JOIN \n" +
                "wlyy_prescription b \n" +
                "on a.patient_name = b.patient_name \n" +
                "where 1=1";
                "where 1=1;";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);

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

@ -812,7 +812,6 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
							consult.put("generalDeptName",baseDoctorHospitalDO.getDeptName());
						}
					}
				}
			}

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

@ -838,9 +838,25 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.searchRecordWrite)
    @ApiOperation(value = "咨询记录导出", notes = "咨询记录导出")
    public Envelop searchRecordWrite(HttpServletResponse response) throws Exception {
        try {
            MixEnvelop expressages = imService.recordByDoctor();
    public Envelop searchRecordWrite(/*@ApiParam(name = "doctor", value = "医生id")
                                         @RequestParam(value = "doctor",required = false) String doctor,
                                     @ApiParam(name = "title", value = "咨询标题关键字")
                                         @RequestParam(value = "title",required = false) String title,
                                     @ApiParam(name = "patient", value = "患者id")
                                         @RequestParam(value = "patient",required = false) String patient,
                                     @ApiParam(name = "id", value = "咨询ID")
                                         @RequestParam(value = "id",required = false) String id,
                                     @ApiParam(name = "type", value = "咨询类型")
                                         @RequestParam(value = "type",required = true) String type,
                                     @ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
                                         @RequestParam(value = "status",required = true) Integer status,
                                     @ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
                                         @RequestParam(value = "start_time",required = false) String start_time,
                                     @ApiParam(name = "end_time", value = "结束时间 YYYY-MM-DD HH:MM:SS")
                                         @RequestParam(value = "end_time",required = false) String end_time,*/
                                     HttpServletResponse response) throws Exception {
        try {
            MixEnvelop expressages = imService.recordByDoctor();//doctor, id, type, status, title, start_time, end_time, patient
            List<Map<String, Object>> list = expressages.getDetailModelList();
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("searchRecordWrite.xls"));