|
@ -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) {
|