lhh 2 هفته پیش
والد
کامیت
933e398aa5

+ 12 - 7
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java

@ -69,10 +69,12 @@ public class DoctorFollowUpController extends BaseController {
            @ApiParam(value = "随访状态:全部状态、2未完成、1已完成") @RequestParam(value = "followupStatus", required = false) String followupStatus,
            @ApiParam(value = "医生姓名") @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate) {
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(value = "所属科室") @RequestParam(value = "deptCode", required = false) String deptCode,
            @ApiParam(value = "随访表单类型") @RequestParam(value = "followupFormType", required = false) String followupFormType) {
        try {
            return followUpService.followupPage(businessType, businessSource, startDate, endDate, patientName,keyName,
                    followupStatus,doctorName, dept, page, size);
                    followupStatus,doctorName, dept,deptCode ,followupFormType, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");
@ -101,11 +103,13 @@ public class DoctorFollowUpController extends BaseController {
            @ApiParam(value = "医生姓名") @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(value = "开始时间") @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(value = "所属科室") @RequestParam(value = "deptCode", required = false) String deptCode,
            @ApiParam(value = "随访表单类型") @RequestParam(value = "followupFormType", required = false) String followupFormType,
            HttpServletResponse response) {
        try {
            List<Map<String, Object>> list = followUpService.followupList(businessType, businessSource, startDate, endDate, patientName,
                    followupStatus,doctorName);
                    followupStatus,doctorName,deptCode,followupFormType);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("followupPage.xls"));
            OutputStream os = response.getOutputStream();
@ -121,7 +125,7 @@ public class DoctorFollowUpController extends BaseController {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"姓名", "性别", "年龄", "联系电话", "家庭住址", "业务来源", "下转科室","下转医生","下转时间","专病名称","随访医生","所属科室","随访状态","计划完成时间","实际完成时间"};
            String[] header = {"姓名", "性别", "年龄", "联系电话", "家庭住址", "业务来源", "下转科室","下转医生","下转时间","专病名称","随访医生","所属科室","随访表单名称","随访状态","计划完成时间","实际完成时间"};
            int k = 0;
            for (String h : header) {
                exportUtl.addCell(ws, 0, k, h);//表名,行,列,header
@ -142,9 +146,10 @@ public class DoctorFollowUpController extends BaseController {
                exportUtl.addCell(ws, i, 9, m.get("businessTypeName"));
                exportUtl.addCell(ws, i, 10, m.get("doctorName"));
                exportUtl.addCell(ws, i, 11, m.get("deptName"));
                exportUtl.addCell(ws, i, 12, m.get("statusName"));
                exportUtl.addCell(ws, i, 13, m.get("followupPlanDate"));
                exportUtl.addCell(ws, i, 14, m.get("followupDate"));
                exportUtl.addCell(ws, i, 12, m.get("followupFormTypeValue"));
                exportUtl.addCell(ws, i, 13, m.get("statusName"));
                exportUtl.addCell(ws, i, 14, m.get("followupPlanDate"));
                exportUtl.addCell(ws, i, 15, m.get("followupDate"));
                i++;
            }
            wwb.write();

+ 104 - 7
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java

@ -17,9 +17,7 @@ import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.module.followup.dao.FollowUpDao;
import com.yihu.jw.hospital.module.followup.dao.FollowupContentDao;
import com.yihu.jw.hospital.module.followup.dao.FollowupSignDao;
import com.yihu.jw.hospital.module.followup.dao.*;
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
@ -27,7 +25,11 @@ import com.yihu.jw.rehabilitation.ServiceItemPlanDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.encrypt.MD5;
import com.yihu.jw.util.excel.ExportUtl;
import com.yihu.jw.util.idcard.IdCardUtil;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -45,6 +47,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -96,15 +100,92 @@ public class FollowUpService {
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    @Autowired
    private FollowupHandFootDao followupHandFootDao;
    @Autowired
    private FollowupOncologyDao followupOncologyDao;
    @Autowired
    private FollowupOrthopedicsDao followupOrthopedicsDao;
    @Autowired
    private ExportUtl exportUtl;
    public void exportByFollowupFormType(String businessType, String businessSource, String startDate, String endDate, String patientName,
                                         String followupStatus, String doctorName, String deptCode, String followupFormType, OutputStream os) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        List<Map<String, Object>> followupList = followupList(businessType, businessSource, startDate, endDate, patientName, followupStatus, doctorName, deptCode, followupFormType);
        // 根据表单类型分类
        Map<String, List<Map<String, Object>>> followupListGroupingByFormType = followupList.stream()
                .collect(Collectors.groupingBy(item -> (String) item.get("followupFormType")));
        // 处理每种类型的表单
        for (Map.Entry<String, List<Map<String, Object>>> followupEntry : followupListGroupingByFormType.entrySet()) {
            String followupFormType2 = followupEntry.getKey();
            List<Map<String, Object>> followupList2 = followupEntry.getValue();
            String ids = followupList2.stream().map(i -> "'" + i.get("id") + "'")
                    .collect(Collectors.joining(",","(",")"));
            Map<Integer, List<Map<String, Object>>> followupList3 = followupList2.stream()
                    .collect(Collectors.groupingBy(i -> (Integer) i.get("id")));
            // 全院通用随访
            if("1".equals(followupFormType2)) {
                String sql = "select distinct * from wlyy_followup_content c where c.followup_id IN "+ids+" AND c.followup_project='1'";
                List<Map<String, Object>> followupContent = jdbcTemplate.queryForList(sql);
                try {
                    WritableSheet ws = wwb.createSheet("全院通用随访", 1);
                    String[] header = {"随访患者", "随访方式", "随访状态", "随访医生", "随访日期", "随方小结"};
                    int k = 0;
                    for (String h : header) {
                        exportUtl.addCell(ws, 0, k, h);//表名,行,列,header
                        k++;
                    }
                    int i = 1;
                    for (Map<String, Object> m : followupContent) {
                        Integer followupId = (Integer) m.get("followup_id");
                        Map<String, Object> followup = followupList3.get(followupId).get(0);
                        exportUtl.addCell(ws, i, 0, followup.get("patientName")); // 随访患者
                        exportUtl.addCell(ws, i, 1, followup.get("followupTypeValue")); // 随访方式
                        exportUtl.addCell(ws, i, 2, followup.get("statusName")); // 随访状态
                        exportUtl.addCell(ws, i, 3, followup.get("doctorName")); // 随访医生
                        exportUtl.addCell(ws, i, 4, followup.get("followupDate")); // 随访日期
                        exportUtl.addCell(ws, i, 5, m.get("followup_value")); // 随方小结
                        i++;
                    }
                    wwb.write();
                    wwb.close();
                } catch (Exception e) {
                    e.printStackTrace();
                    if (wwb != null) wwb.close();
                    throw e;
                }
            } else if("2".equals(followupFormType2)) {
            } else if("3".equals(followupFormType2)) {
            } else if("4".equals(followupFormType2)) {
            }
        }
    }
    //随访记录列表
    public PageEnvelop followupPage(String businessType, String businessSource, String startDate, String endDate, String patientName,
                                    String keyName,String followupStatus,String doctorName,String dept, Integer page, Integer size){
                                    String keyName,String followupStatus,String doctorName,String dept,
                                    String deptCode,String followupFormType,
                                    Integer page, Integer size){
        String sql = "SELECT DISTINCT f.id,f.patient_name patientName,f.patient_code patientCode,p.photo,p.idcard,p.birthday,p.sex,p.mobile, " +
                "f.doctor_code doctorCode,f.doctor_name doctorName,pl.disease_name businessTypeName,pl.disease businessType,ip.id itemPlanId, " +
                "h.dept_code deptCode,h.dept_name deptName,f.`status`,date_format(f.followup_date, '%Y-%m-%d %H:%i:%s') followupDate,'诊后康复' businessSource," +
                "date_format(f.followup_plan_date, '%Y-%m-%d %H:%i:%s') followupPlanDate,date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate," +
                "if(i.from_source=2,i.doctor_name,pl.plan_doctor_name) planDoctorName,if(i.from_source=2,i.dept_name,h2.dept_name) turnDownDeptName ";
                "if(i.from_source=2,i.doctor_name,pl.plan_doctor_name) planDoctorName,if(i.from_source=2,i.dept_name,h2.dept_name) turnDownDeptName, " +
                "f.followup_form_type followupFormType,d.dict_value followupFormTypeValue ";
        String countSql = "select count(DISTINCT f.id) ";
        String filter = " from wlyy_followup f " +
                "LEFT JOIN base_service_item_plan ip on  f.id = ip.relation_code and ip.relation_type='6' " +
@ -113,6 +194,7 @@ public class FollowUpService {
                "INNER JOIN base_patient p on p.id = f.patient_code " +
                "LEFT JOIN base_doctor_hospital h on f.doctor_code=h.doctor_code and h.del=1 " +
                "LEFT JOIN base_doctor_hospital h2 on pl.plan_doctor=h2.doctor_code and h2.del=1 " +
                "LEFT JOIN wlyy_hospital_sys_dict d ON d.dict_name='followup_form_type' AND d.dict_code=f.followup_form_type " +
                "WHERE 1=1 ";
        if(StringUtils.isNotBlank(businessType)){
            if(businessType.contains(",")){
@ -148,6 +230,12 @@ public class FollowUpService {
        if (StringUtils.isNotBlank(endDate)){
            filter += " and f.followup_date<='"+endDate+" 23:59:59' ";
        }
        if (StringUtils.isNotBlank(deptCode)){
            filter += " AND h.dept_code='" + deptCode + "' ";
        }
        if (StringUtils.isNotBlank(followupFormType)){
            filter += " AND followup_form_type = '" + followupFormType + "' ";
        }
        String orderBy = " order by f.followup_date desc limit "+(page-1)*size+","+size;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        for (Map<String, Object> vo : list) {
@ -181,18 +269,21 @@ public class FollowUpService {
    }
    public List<Map<String, Object>> followupList(String businessType, String businessSource, String startDate, String endDate, String patientName,
                                    String followupStatus,String doctorName){
                                    String followupStatus,String doctorName,String deptCode,String followupFormType){
        String sql = "SELECT DISTINCT f.id,f.patient_name patientName,f.patient_code patientCode,p.idcard,p.birthday,p.sex,p.mobile,p.address, " +
                "f.doctor_code doctorCode,f.doctor_name doctorName,pl.disease_name businessTypeName,pl.disease businessType, " +
                "h.dept_code deptCode,h.dept_name deptName,f.`status`,if(f.`status`=1,date_format(f.followup_date, '%Y-%m-%d %H:%i:%s'),'') followupDate," +
                "'诊后康复' businessSource,date_format(f.followup_plan_date, '%Y-%m-%d %H:%i:%s') followupPlanDate," +
                "date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate,pl.plan_doctor_name planDoctorName,h2.dept_name turnDownDeptName ";
                "date_format(pl.create_time, '%Y-%m-%d %H:%i:%s') turnDownDate,pl.plan_doctor_name planDoctorName,h2.dept_name turnDownDeptName, " +
                "f.followup_form_type followupFormType,d.dict_value followupFormTypeValue, d2.dict_value followupTypeValue ";
        String filter = " from wlyy_followup f " +
                "INNER JOIN base_service_item_plan ip on  f.id = ip.relation_code and ip.relation_type='6' " +
                "LEFT JOIN wlyy_patient_rehabilitation_plan pl on pl.id = ip.plan_id " +
                "INNER JOIN base_patient p on p.id = f.patient_code " +
                "LEFT JOIN base_doctor_hospital h on f.doctor_code=h.doctor_code and h.del=1 " +
                "LEFT JOIN base_doctor_hospital h2 on pl.plan_doctor=h2.doctor_code and h2.del=1 " +
                "LEFT JOIN wlyy_hospital_sys_dict d ON d.dict_name='followup_form_type' AND d.dict_code=f.followup_form_type " +
                "LEFT JOIN wlyy_hospital_sys_dict d2 ON d2.dict_name='FOLLOWUP_WAY_DICT' AND d2.dict_code=f.followup_type " +
                "WHERE 1=1 ";
        if(StringUtils.isNotBlank(businessType)){
            if(businessType.contains(",")){
@ -222,6 +313,12 @@ public class FollowUpService {
        if (StringUtils.isNotBlank(endDate)){
            filter += " and f.followup_date<='"+endDate+" 23:59:59' ";
        }
        if (StringUtils.isNotBlank(deptCode)){
            filter += " AND h.dept_code='" + deptCode + "' ";
        }
        if (StringUtils.isNotBlank(followupFormType)){
            filter += " AND followup_form_type = '" + followupFormType + "' ";
        }
        String orderBy = " order by f.followup_date desc ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        for (Map<String, Object> vo : list) {