Browse Source

导出分数和答案

sd
zhizhi wu 4 years ago
parent
commit
8727b3d558
  1. 23
      ht/src/main/java/com/ccsens/ht/api/PatientReportController.java
  2. 12
      ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java
  3. 15
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  4. 7
      ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java
  5. 7
      ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java
  6. 44
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  7. 2
      ht/src/main/resources/logback-spring.xml
  8. 27
      ht/src/main/resources/mapper_dao/HtPatientReportDao.xml

23
ht/src/main/java/com/ccsens/ht/api/PatientReportController.java

@ -1,6 +1,7 @@
package com.ccsens.ht.api;
import cn.hutool.core.util.CharsetUtil;
import com.ccsens.ht.annotation.DoctorAudit;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.ht.bean.dto.PatientReportDto;
@ -14,14 +15,14 @@ import com.ccsens.util.JsonResponse;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
/**
@ -252,4 +253,18 @@ public class PatientReportController {
}
@ApiOperation(value = "导出指定题型的分数和答案",notes = "导出指定题型的分数和答案")
@ApiImplicitParams({
})
@RequestMapping(value="/exportAnswer", method = RequestMethod.GET)
public void exportAnswer(@ApiParam PatientReportDto.Answer answer, HttpServletResponse response) throws Exception {
//查询报告单信息
log.info("导出指定题型的分数和答案:{}", answer);
Workbook workbook = patientReportService.exportAnswer(answer);
log.info("导出指定题型的分数和答案结束");
String fileName = "答案记录.xlsx";
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CharsetUtil.UTF_8));
workbook.write(response.getOutputStream());
}
}

12
ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java

@ -232,4 +232,16 @@ public class PatientReportDto {
@ApiModelProperty("题目id")
private Long questionId;
}
@ApiModel("分数导出")
@Data
public static class Answer {
@NotBlank(message = "题目类型不能为空")
@ApiModelProperty("题目类型 MMSE")
private String questionCode;
@NotBlank(message = "请指定第几题")
@ApiModelProperty("排序")
private int sort;
}
}

15
ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java

@ -844,4 +844,19 @@ public class PatientReportVo {
private BigDecimal totalScore;
}
@ApiModel("分数和答案")
@Data
public static class AnswerAndScore{
@ApiModelProperty("报告单ID")
private Long patientReportId;
@ApiModelProperty("患者ID")
private Long patientId;
@ApiModelProperty("分数")
private String score;
@ApiModelProperty("答案")
private String recordValue;
@ApiModelProperty("诊断结果")
private String clinicalDiagnosis;
}
}

7
ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java

@ -130,5 +130,10 @@ public interface HtPatientReportDao extends HtPatientReportMapper {
*/
List<PatientReportVo.Analyse> queryReportAnalyseScore(@Param("ids") List<Long> ids);
/**
* 查询指定答案和分数
* @param answer 请求参数
* @return 分数记录临床诊断
*/
List<PatientReportVo.AnswerAndScore> queryAnswer(@Param("param") PatientReportDto.Answer answer);
}

7
ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java

@ -180,4 +180,11 @@ public interface IPatientReportService {
* @return
*/
List<PatientReportVo.ReportScore> getReportScores(List<PatientReportVo.ReportScore> reportScores, long reportId);
/***
* 导出指定题目的所有答案
* @param answer param
* @return 表格
*/
Workbook exportAnswer(PatientReportDto.Answer answer);
}

44
ht/src/main/java/com/ccsens/ht/service/PatientReportService.java

@ -1117,6 +1117,50 @@ public class PatientReportService implements IPatientReportService {
return scores;
}
@Override
public Workbook exportAnswer(PatientReportDto.Answer answer) {
List<PatientReportVo.AnswerAndScore> scores = htPatientReportDao.queryAnswer(answer);
List<List< PoiUtil.PoiUtilCell >> allRows = new ArrayList<>();
// 标题 表头
List<PoiUtil.PoiUtilCell> headRow = new ArrayList<>();
headRow.add(new PoiUtil.PoiUtilCell("报告单ID"));
headRow.add(new PoiUtil.PoiUtilCell("患者ID"));
headRow.add(new PoiUtil.PoiUtilCell("临床诊断"));
headRow.add(new PoiUtil.PoiUtilCell("分数"));
headRow.add(new PoiUtil.PoiUtilCell("记录"));
allRows.add(headRow);
String sheetName = "分数和答案";
if (CollectionUtil.isEmpty(scores)) {
Workbook workbook = new XSSFWorkbook();
PoiUtil.exportWB(sheetName, allRows, workbook);
return workbook;
}
// 填充数据
for (PatientReportVo.AnswerAndScore score: scores) {
List<PoiUtil.PoiUtilCell> dataRow = new ArrayList<>();
dataRow.add(new PoiUtil.PoiUtilCell(score.getPatientReportId() + "",1,1));
dataRow.add(new PoiUtil.PoiUtilCell(score.getPatientId() + "",1,1));
dataRow.add(new PoiUtil.PoiUtilCell(score.getClinicalDiagnosis(),1,1));
dataRow.add(new PoiUtil.PoiUtilCell(score.getScore(),1,1));
dataRow.add(new PoiUtil.PoiUtilCell(score.getRecordValue(),1,1));
allRows.add(dataRow);
}
Workbook workbook = new XSSFWorkbook();
PoiUtil.exportWB(sheetName, allRows, workbook);
return workbook;
}
private void initQuestionBody(int questionSpan, PatientReportVo.QuestionAndAnswer question, PdfUtil.Row row, boolean isLast, int optionSize) {
addCell(row, question == null ? Constant.Ht.STRING_DEFAULT : String.valueOf(question.getSort()), 1, 1);
addCell(row, question == null ? Constant.Ht.STRING_DEFAULT : question.getQuestion(), questionSpan, 1);

2
ht/src/main/resources/logback-spring.xml

@ -80,7 +80,7 @@
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--<maxHistory>15</maxHistory>-->
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">

27
ht/src/main/resources/mapper_dao/HtPatientReportDao.xml

@ -443,6 +443,33 @@
group by q.evaluation_code, s.patient_report_id) score
on report.id = score.scoreReportId
</select>
<select id="queryAnswer" resultType="com.ccsens.ht.bean.vo.PatientReportVo$AnswerAndScore">
SELECT
r.id as patientReportId,
r.patient_id as patientId,
r.clinical_diagnosis as clinicalDiagnosis,
s.score,
pr.record_value as recordValue
FROM
t_ht_patient_report r,
t_ht_question q,
t_ht_patient_score s,
t_ht_patient_question_record pr,
t_ht_patient p
WHERE
r.id = s.patient_report_id
AND r.id = pr.patient_report_id
AND q.id = s.question_id
AND q.id = pr.question_id
AND r.patient_id = p.id
AND q.evaluation_code = #{param.questionCode}
AND q.sort = #{param.sort}
AND r.is_del = 0
AND q.is_del = 0
AND s.is_del = 0
AND pr.is_del = 0
AND p.is_del = 0
</select>
</mapper>
Loading…
Cancel
Save