|
|
|
@ -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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|