Browse Source

添加完整报告

whszxyjhyy
ccsens_zhengzhichuan 1 week ago
parent
commit
0405fadcb3
  1. 2
      ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/service/AmsReportService.java
  2. 221
      ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/service/impl/AmsReportServiceImpl.java
  3. 1
      ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/service/impl/PmsPatientServiceImpl.java
  4. 54
      ruisi_java/ruisi-web-client/src/test/java/ServiceTest.java

2
ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/service/AmsReportService.java

@ -36,4 +36,6 @@ public interface AmsReportService {
* @return
*/
AmsReportVo.Result exportYx(RmsDto.ExportReport1Dto dto);
AmsReportVo.Result exportAll(RmsDto.ExportReport1Dto dto);
}

221
ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/service/impl/AmsReportServiceImpl.java

@ -12,6 +12,7 @@ import com.ccsens.client.persist.dao.ClientEvaDao;
import com.ccsens.client.persist.dao.HmsDoctorDao;
import com.ccsens.client.persist.dao.RmsDao;
import com.ccsens.client.service.AmsReportService;
import com.ccsens.client.service.IPmsPatientService;
import com.ccsens.client.service.IReportInfoService;
import com.ccsens.client.service.IRmsService;
import com.ccsens.common.constant.CultureEnum;
@ -64,6 +65,8 @@ public class AmsReportServiceImpl implements AmsReportService {
@Resource
private IRmsService rmsService;
@Resource
private IPmsPatientService pmsPatientService;
@Resource
private RmsDao rmsDao;
@Resource
private RmsReportMapper rmsReportMapper;
@ -87,6 +90,8 @@ public class AmsReportServiceImpl implements AmsReportService {
private String grPath;
@Value("${file.ysPath}")
private String ysPath;
@Value("${file.allPath}")
private String allPath;
@Override
public AmsReportVo.Result export(RmsDto.ExportReportDto dto) throws IOException {
@ -990,7 +995,7 @@ public class AmsReportServiceImpl implements AmsReportService {
RmsDto.QueryDetail queryDetail = new RmsDto.QueryDetail();
queryDetail.setEvaluationId(dto.getEvaluationId());
RmsVo.ReportDetail detail = rmsService.queryReportDetail(queryDetail);
RmsVo.ReportDetail detail = rmsService.queryReport(queryDetail);
//查询测评量表
List<RmsVo.ReportScore> scores = rmsDao.queryEmsScaleScore(dto.getEvaluationId(), CollectionUtil.newArrayList());
if (CollUtil.isNotEmpty(scores)) {
@ -1625,4 +1630,218 @@ public class AmsReportServiceImpl implements AmsReportService {
return pattern.matcher(str).matches();
}
@Override
public AmsReportVo.Result exportAll(RmsDto.ExportReport1Dto dto) {
RmsReport report = rmsReportMapper.selectByPrimaryKey(dto.getReportId());
if (ObjectUtil.isNotNull(report) && StrUtil.isNotBlank(report.getUrl())) {
AmsReportVo.Result result = new AmsReportVo.Result();
result.setPath(report.getUrl());
return result;
}
RmsDto.QueryDetail queryDetail = new RmsDto.QueryDetail();
queryDetail.setEvaluationId(dto.getEvaluationId());
RmsVo.ReportDetail detail = rmsService.queryReport(queryDetail);
//查询测评量表
List<RmsVo.ReportScore> scores = rmsDao.queryEmsScaleScore(dto.getEvaluationId(), CollectionUtil.newArrayList());
if (CollUtil.isNotEmpty(scores)) {
//组装成父子级关系
scores = rmsService.buildReportScoreTree(scores, 0L);
}
if (detail == null) {
return null;
}
EmsEvaluation emsEvaluation = emsEvaluationMapper.selectByPrimaryKey(dto.getEvaluationId());
if (emsEvaluation == null) {
return null;
}
//查询就诊、诊断信息
PmsPatientVo.PatientInfo patientInfoById = pmsPatientService.getPatientInfoById(emsEvaluation.getPatientId());
//查询
RmsVo.ReportPatient patientInfo = detail.getPatient();
HashMap<String, Object> params = new HashMap<>();
XWPFTemplate template = XWPFTemplate.compile(ysPath);
params.put("h_name", patientInfo.getHospitalName());
// params.put("qrcode_img_url", Pictures.ofLocal(reportPath + patientInfo.getQrCodeUrl()).size(130, 130).create());
params.put("p_name", patientInfo.getPatientName());
params.put("p_sex", patientInfo.getSex() == 0 ? "男" : "女");
params.put("p_age", patientInfo.getPatientAge());
CultureEnum cultureEnum = null;
if (dto.getSignId() != null) {
HmsDoctorSign emsEvaluationInformedConsent = hmsDoctorSignMapper.selectByPrimaryKey(dto.getSignId());
if (emsEvaluationInformedConsent != null) {
params.put("cpy_img_url", Pictures.ofLocal(prefixWord + emsEvaluationInformedConsent.getPath()).size(80, 40).create());
}
} else {
//签名信息
Long userId = SecurityUtils.getUserId();
List<HmsVo.QuerySign> querySigns = hmsDoctorDao.querySign(userId);
if (CollUtil.isNotEmpty(querySigns)) {
HmsVo.QuerySign querySign = querySigns.get(0);
if (ObjectUtil.isNotNull(querySign) && StrUtil.isNotEmpty(querySign.getSignUrl())) {
params.put("cpy_img_url", Pictures.ofLocal(prefixWord + querySign.getSignUrl()).size(80, 40).create());
}
}
}
if (patientInfoById != null) {
params.put("contactPhone", patientInfoById.getContactMobile());
params.put("contactRelation", patientInfoById.getContactRelation());
params.put("contact", patientInfoById.getContactName());
}
try {
cultureEnum = BaseEnum.codeOf(CultureEnum.class, patientInfo.getEducationalStatus().intValue());
} catch (Exception e) {
//处理educationStatus为null的情况,后台导入的数据educationStatus为null
//默认为初中
cultureEnum = CultureEnum.YW;
}
if (cultureEnum != null) {
params.put("p_grade", cultureEnum.getDesc());
}
if (patientInfo.getCareer() != null) {
JobEnum jobEnum = BaseEnum.codeOf(JobEnum.class, patientInfo.getCareer().intValue());
// params.put("p_no", patientInfo.getSerialNumber());
if (jobEnum != null) {
params.put("p_Career", jobEnum.getDesc());
}
}
params.put("p_dept", patientInfo.getDepartment());
params.put("p_bedno", patientInfo.getBedNumber());
params.put("p_Patient_number", patientInfo.getHospitalNumber());
params.put("p_Clinical_diagnosis", patientInfo.getClinicalDiagnosis());
params.put("p_Inspection_date", DateUtil.format(new Date(patientInfo.getReportTime()), "yyyy-MM-dd"));
// params.put("score", detail.getScore());
//AD8
// params.put("cpy_img_url", patientInfo.getName());
params.put("report_date", DateUtil.date(patientInfo.getReportTime()));
//生成表格
// 创建带有样式的文本
TextRenderData text1 = Texts.of("评估结论").bold().fontSize(12).create();
TextRenderData text2 = Texts.of("评估结论").bold().fontSize(12).create();
TextRenderData text3 = Texts.of("评估结论").bold().fontSize(12).create();
TextRenderData text4 = Texts.of("评估结论").bold().fontSize(12).create();
// TextRenderData text5 = Texts.of("评估结论").bold().fontSize(12).create();
RowRenderData headerRow = Rows.of(text1, text2, text3, text4).create();
//查询
List<RmsVo.ExportInfo> exportInfos = rmsDao.queryReportExportInfo(dto.getEvaluationId());
if (CollUtil.isEmpty(exportInfos)) {
return null;
}
RowRenderData titleRow = Rows.of("一级指标/二级指标", "量表名称", "得分", "结论").create();
Tables.TableBuilder of = Tables.of(headerRow, titleRow);
for (int i = 0; i < exportInfos.size(); i++) {
params.put("yjzb", exportInfos.get(i).getComboParentName());
params.put("ejzb", exportInfos.get(i).getComboName());
if (exportInfos.get(i).getNeedPlan() != null && exportInfos.get(i).getNeedPlan() == 1) {
TextRenderData textStr = Texts.of(StrUtil.isEmpty(exportInfos.get(i).getComboParentName()) ? "" : exportInfos.get(i).getComboParentName() + "/" + exportInfos.get(i).getComboName()).bold().color("FF0000").create();
TextRenderData textName = Texts.of(scores.get(i).getName()).bold().color("FF0000").create();
TextRenderData textScore = Texts.of(scores.get(i).getScore() == null ? "" : scores.get(i).getScore() + "").bold().color("FF0000").create();
TextRenderData textImpression = Texts.of(StrUtil.isEmpty(exportInfos.get(i).getImpression()) ? exportInfos.get(i).getResult() : exportInfos.get(i).getImpression()).bold().color("FF0000").create();
//查询一二级套餐
RowRenderData row1 = Rows.of(
textStr,
textName,
textScore,
textImpression
).create();
// if (StrUtil.isNotEmpty(exportInfos.get(i).getComboName() + "/" + exportInfos.get(i).getComboParentName())) {
// of.mergeRule(MergeCellRule.builder().map(MergeCellRule.Grid.of(i + 1, i + 1), MergeCellRule.Grid.of(0, 1)).build());
// }
of.addRow(row1);
} else {
if (!"JI_SHAO".equals(exportInfos.get(i).getScaleCode())) {
TextRenderData textStr = Texts.of(StrUtil.isEmpty(exportInfos.get(i).getComboParentName()) ? "" : exportInfos.get(i).getComboParentName() + "/" + exportInfos.get(i).getComboName()).bold().create();
TextRenderData textName = Texts.of("JI_SHAO".equals(exportInfos.get(i).getScaleCode()) ? "肌少总结论" : exportInfos.get(i).getScaleName()).bold().create();
TextRenderData textScore = Texts.of(exportInfos.get(i).getScore() == null ? "" : exportInfos.get(i).getScore() + "").bold().create();
//中医体质辨识添加结论 结论为初步印象
TextRenderData textImpression = Texts.of(
StrUtil.isEmpty(exportInfos.get(i).getImpression()) ? exportInfos.get(i).getResult() : exportInfos.get(i).getImpression()).bold().create();
//查询一二级套餐
RowRenderData row1 = Rows.of(
textStr,
textName,
textScore,
textImpression
).create();
of.addRow(row1);
} else {
TextRenderData textStr = Texts.of(exportInfos.get(i).getImpression().contains("\n") ? "量表结论" + "\n" + "肌少总结论" : "肌少总结论").bold().create();
TextRenderData textName = Texts.of("").bold().create();
TextRenderData textScore = Texts.of(exportInfos.get(i).getScore() == null ? "" : exportInfos.get(i).getScore() + "").bold().create();
//中医体质辨识添加结论 结论为初步印象
TextRenderData textImpression = Texts.of(
exportInfos.get(i).getImpression() == null ? exportInfos.get(i).getResult() : exportInfos.get(i).getImpression()).bold().create();
//查询一二级套餐
RowRenderData row1 = Rows.of(
textStr,
textName,
textImpression,
textScore
).create();
if (StrUtil.isNotEmpty(exportInfos.get(i).getComboName() + "/" + exportInfos.get(i).getComboParentName())) {
of.mergeRule(
MergeCellRule.builder().map(
MergeCellRule.Grid.of(i + 2, 0), MergeCellRule.Grid.of(i + 2, 1))
.map(MergeCellRule.Grid.of(i + 2, 2), MergeCellRule.Grid.of(i + 2, 3)
).build()
);
}
of.addRow(row1);
}
}
}
if (emsEvaluation.getVersion() != null) {
HmsVersion hmsVersion = hmsVersionMapper.selectByPrimaryKey(Long.parseLong(emsEvaluation.getVersion()));
if (hmsVersion != null) {
params.put("type", hmsVersion.getVersion() + "评估报告");
}
}
TableRenderData tableData = of
.create();
params.put("table", tableData);
String s = IdUtil.randomUUID();
try {
template.render(params);
} catch (
Exception e) {
e.printStackTrace(); // 输出详细的异常信息
}
String filePath = "/profile/" + "/report/" + "老年综合评估_" + s + ".docx";
String pdfPath = "/profile/" + "/report/" + "老年综合评估_" + s + ".pdf";
String aPath = path + "/" + "/report/" + "老年综合评估_" + s + ".docx";
String pPath = path + "/" + "/report/" + "老年综合评估_" + s + ".pdf";
try {
template.writeAndClose(Files.newOutputStream(Paths.get(reportDomain + "/" + "/report/" + "老年综合评估_" + s + ".docx")));
AsposeUtils.doc2pdf(aPath, pPath);
} catch (
Exception e) {
e.printStackTrace();
}
AmsReportVo.Result result = new AmsReportVo.Result();
result.setWord(filePath);
result.setPath(pdfPath);
//将生成的文件路径保存到报告单内
if (ObjectUtil.isNotNull(report)) {
report.setUrl(pdfPath);
rmsReportMapper.updateByPrimaryKeySelective(report);
}
return result;
}
}

1
ruisi_java/ruisi-web-client/src/main/java/com/ccsens/client/service/impl/PmsPatientServiceImpl.java

@ -222,6 +222,7 @@ public class PmsPatientServiceImpl implements IPmsPatientService {
PmsPatientBodyExample patientBodyExample = new PmsPatientBodyExample();
patientBodyExample.createCriteria().andPatientIdEqualTo(pmsPatient.getId())
.andDelFlagEqualTo((byte) 0);
patientBodyExample.setOrderByClause("id desc");
List<PmsPatientBody> pmsPatientBodies = pmsPatientBodyMapper.selectByExample(patientBodyExample);
if (CollUtil.isNotEmpty(pmsPatientBodies)) {
PmsPatientBody body = pmsPatientBodies.get(0);

54
ruisi_java/ruisi-web-client/src/test/java/ServiceTest.java

@ -2,9 +2,14 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.ccsens.RuisiClientApplication;
import com.ccsens.system.domain.po.*;
import com.ccsens.system.persist.mapper.*;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -13,31 +18,52 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author lijunjie
*/
@Slf4j
@SpringBootTest
@RunWith(JUnit4.class)
//@SpringBootTest
//@RunWith(JUnit4.class)
public class ServiceTest {
@Test
public void getBmi(){
String weight = "60.0";
String height = "1722.0";
if (StrUtil.isNotEmpty(weight) && StrUtil.isNotEmpty(height)) {
// return String.valueOf(Double.parseDouble(weight) / (Double.parseDouble(height) * Double.parseDouble(height)));
String s = String.valueOf(new BigDecimal(weight).divide(new BigDecimal(height).multiply(new BigDecimal(height).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP)), 2, BigDecimal.ROUND_HALF_UP));
log.info(s);
}
public void getBmi() throws IOException {
// 构建数据列表
List<Map<String, Object>> employees = new ArrayList<>();
employees.add(new HashMap<String, Object>() {{
put("index", 1);
put("name", "张三");
put("age", 28);
}});
employees.add(new HashMap<String, Object>() {{
put("index", 2);
put("name", "李四");
put("age", 30);
}});
Map<String, Object> map = new HashMap<>();
map.put()
// 或使用 RenderData 和 MiniTableRenderData 更高级表格渲染(后面介绍)
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
Configure config = Configure.builder().bind("employees", policy).bind("employeeList", policy).build();
// 构建渲染数据
Map<String, Object> data = new HashMap<>();
data.put("employees", employees);
data.put("employeeList", employees);
// 渲染模板
String out = "C:/Users/zzc16/Desktop/out.docx";
XWPFTemplate templateDoc = XWPFTemplate.compile("C:/Users/zzc16/Desktop/aaa.docx", config).render(data);
templateDoc.writeToFile(out);
templateDoc.close();
}
// @Resource

Loading…
Cancel
Save