From 4cfe5559023510e66d13a6be61b909d6cfae6acd Mon Sep 17 00:00:00 2001 From: zy_Java <654600784@qq.com> Date: Fri, 25 Dec 2020 10:13:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=BB=E5=9B=BE=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ht/api/PatientReportController.java | 13 + .../ccsens/ht/bean/dto/PatientReportDto.java | 26 +- .../com/ccsens/ht/bean/dto/QuestionDto.java | 6 +- .../ccsens/ht/bean/po/HtPatientCanvas.java | 22 ++ .../ht/bean/po/HtPatientCanvasExample.java | 130 +++++++++ .../ht/bean/po/HtPatientCanvasLine.java | 22 +- .../bean/po/HtPatientCanvasLineExample.java | 70 ----- .../ccsens/ht/bean/vo/PatientReportVo.java | 43 +++ .../com/ccsens/ht/bean/vo/QuestionVo.java | 53 +++- .../ht/persist/dao/HtPatientCanvasDao.java | 3 +- .../ht/persist/dao/HtPatientReportDao.java | 8 + .../mapper/HtPatientCanvasLineMapper.java | 6 + .../ht/service/IPatientReportService.java | 10 + .../ht/service/PatientReportService.java | 7 + .../ccsens/ht/service/QuestionService.java | 148 +++++++++- .../java/com/ccsens/ht/uitl/Constant.java | 12 + .../mapper_dao/HtPatientCanvasDao.xml | 4 +- .../mapper_dao/HtPatientReportDao.xml | 262 +++++++++++------- .../mapper_raw/HtPatientCanvasLineMapper.xml | 84 ++++-- .../mapper_raw/HtPatientCanvasMapper.xml | 42 ++- tall/src/main/resources/application.yml | 4 +- .../test/java/com/ccsens/util/Base64Test.java | 55 ++++ 22 files changed, 813 insertions(+), 217 deletions(-) diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java index d0bb3635..f695b4d1 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java @@ -248,5 +248,18 @@ public class PatientReportController { return JsonResponse.newInstance().ok(reportNamePageInfo); } + @MustLogin + @DoctorAudit + @ApiOperation(value = "查询报告单详细答题信息",notes = "根据报告单id和测评类型,查看报告单的详细信息") + @ApiImplicitParams({ + }) + @RequestMapping(value="/queryReportAnswer", method = RequestMethod.POST) + public JsonResponse> queryReportAnswer(@RequestBody @ApiParam @Valid QueryDto param){ + log.info("查询报告单详细答题信息:{}", param); + List reportDetailAnswers = patientReportService.queryReportAnswer(param.getParam(), param.getUserId()); + log.info("查询报告单详细答题信息完成"); + return JsonResponse.newInstance().ok(reportDetailAnswers); + } + } diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java index f81a7952..90e73931 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java @@ -6,10 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.beans.BeanUtils; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; +import javax.validation.constraints.*; /** * @program: ptpro @@ -159,4 +156,25 @@ public class PatientReportDto { private Long endTime; } + @ApiModel("查询报告单答题信息") + @Data + public static class QueryReportAnswer { + @NotNull(message = "报到单id不能为空") + @ApiModelProperty("报告单id") + private Long id; + @NotBlank(message = "测评类型不能为空") + @ApiModelProperty("测评类型") + private String evaluationCode; + } + + @ApiModel("查询病友画图原图") + @Data + public static class QueryQuestionImg { + @NotNull(message = "报到单id不能为空") + @ApiModelProperty("报告单id") + private Long id; + @NotNull(message = "题目id不能为空") + @ApiModelProperty("题目id") + private Long questionId; + } } diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java index 35c67cbc..69a5046e 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java @@ -62,7 +62,9 @@ public class QuestionDto { @NotNull(message = "测评试题id不能为空") @ApiModelProperty("测评试题id") private Long questionId; - @ApiModelProperty("时间") + @ApiModelProperty("打开画板时间") + private Long openCanvasTime; + @ApiModelProperty("开始画图时间") private Long beginTime; @ApiModelProperty("轨迹,每个字符串是一条轨迹,轨迹内格式(x,y,time;x,y,time;.....)") private List points; @@ -70,6 +72,8 @@ public class QuestionDto { private Canvas canvas; @ApiModelProperty("笔触信息") private CanvasLine line; + @ApiModelProperty("超出占比") + private String beyondProportion; } @Data @ApiModel("画板信息") diff --git a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvas.java b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvas.java index 02ccf05e..0db7571d 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvas.java +++ b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvas.java @@ -26,6 +26,10 @@ public class HtPatientCanvas implements Serializable { private Byte isDel; + private Long openCanvasTime; + + private String beyondProportion; + private static final long serialVersionUID = 1L; public Long getId() { @@ -116,6 +120,22 @@ public class HtPatientCanvas implements Serializable { this.isDel = isDel; } + public Long getOpenCanvasTime() { + return openCanvasTime; + } + + public void setOpenCanvasTime(Long openCanvasTime) { + this.openCanvasTime = openCanvasTime; + } + + public String getBeyondProportion() { + return beyondProportion; + } + + public void setBeyondProportion(String beyondProportion) { + this.beyondProportion = beyondProportion == null ? null : beyondProportion.trim(); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -133,6 +153,8 @@ public class HtPatientCanvas implements Serializable { sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); sb.append(", isDel=").append(isDel); + sb.append(", openCanvasTime=").append(openCanvasTime); + sb.append(", beyondProportion=").append(beyondProportion); sb.append("]"); return sb.toString(); } diff --git a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasExample.java b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasExample.java index cbc35411..1f86c70e 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasExample.java +++ b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasExample.java @@ -774,6 +774,136 @@ public class HtPatientCanvasExample { addCriterion("is_del not between", value1, value2, "isDel"); return (Criteria) this; } + + public Criteria andOpenCanvasTimeIsNull() { + addCriterion("open_canvas_time is null"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeIsNotNull() { + addCriterion("open_canvas_time is not null"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeEqualTo(Long value) { + addCriterion("open_canvas_time =", value, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeNotEqualTo(Long value) { + addCriterion("open_canvas_time <>", value, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeGreaterThan(Long value) { + addCriterion("open_canvas_time >", value, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeGreaterThanOrEqualTo(Long value) { + addCriterion("open_canvas_time >=", value, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeLessThan(Long value) { + addCriterion("open_canvas_time <", value, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeLessThanOrEqualTo(Long value) { + addCriterion("open_canvas_time <=", value, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeIn(List values) { + addCriterion("open_canvas_time in", values, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeNotIn(List values) { + addCriterion("open_canvas_time not in", values, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeBetween(Long value1, Long value2) { + addCriterion("open_canvas_time between", value1, value2, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andOpenCanvasTimeNotBetween(Long value1, Long value2) { + addCriterion("open_canvas_time not between", value1, value2, "openCanvasTime"); + return (Criteria) this; + } + + public Criteria andBeyondProportionIsNull() { + addCriterion("beyond_proportion is null"); + return (Criteria) this; + } + + public Criteria andBeyondProportionIsNotNull() { + addCriterion("beyond_proportion is not null"); + return (Criteria) this; + } + + public Criteria andBeyondProportionEqualTo(String value) { + addCriterion("beyond_proportion =", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionNotEqualTo(String value) { + addCriterion("beyond_proportion <>", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionGreaterThan(String value) { + addCriterion("beyond_proportion >", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionGreaterThanOrEqualTo(String value) { + addCriterion("beyond_proportion >=", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionLessThan(String value) { + addCriterion("beyond_proportion <", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionLessThanOrEqualTo(String value) { + addCriterion("beyond_proportion <=", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionLike(String value) { + addCriterion("beyond_proportion like", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionNotLike(String value) { + addCriterion("beyond_proportion not like", value, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionIn(List values) { + addCriterion("beyond_proportion in", values, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionNotIn(List values) { + addCriterion("beyond_proportion not in", values, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionBetween(String value1, String value2) { + addCriterion("beyond_proportion between", value1, value2, "beyondProportion"); + return (Criteria) this; + } + + public Criteria andBeyondProportionNotBetween(String value1, String value2) { + addCriterion("beyond_proportion not between", value1, value2, "beyondProportion"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLine.java b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLine.java index 6b926a60..a62eced5 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLine.java +++ b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLine.java @@ -8,14 +8,14 @@ public class HtPatientCanvasLine implements Serializable { private Long patientCanvasId; - private String points; - private Date createTime; private Date updateTime; private Byte isDel; + private String points; + private static final long serialVersionUID = 1L; public Long getId() { @@ -34,14 +34,6 @@ public class HtPatientCanvasLine implements Serializable { this.patientCanvasId = patientCanvasId; } - public String getPoints() { - return points; - } - - public void setPoints(String points) { - this.points = points == null ? null : points.trim(); - } - public Date getCreateTime() { return createTime; } @@ -66,6 +58,14 @@ public class HtPatientCanvasLine implements Serializable { this.isDel = isDel; } + public String getPoints() { + return points; + } + + public void setPoints(String points) { + this.points = points == null ? null : points.trim(); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -74,10 +74,10 @@ public class HtPatientCanvasLine implements Serializable { sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", patientCanvasId=").append(patientCanvasId); - sb.append(", points=").append(points); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); sb.append(", isDel=").append(isDel); + sb.append(", points=").append(points); sb.append("]"); return sb.toString(); } diff --git a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLineExample.java b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLineExample.java index 0c95a370..f90f7e3c 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLineExample.java +++ b/ht/src/main/java/com/ccsens/ht/bean/po/HtPatientCanvasLineExample.java @@ -225,76 +225,6 @@ public class HtPatientCanvasLineExample { return (Criteria) this; } - public Criteria andPointsIsNull() { - addCriterion("points is null"); - return (Criteria) this; - } - - public Criteria andPointsIsNotNull() { - addCriterion("points is not null"); - return (Criteria) this; - } - - public Criteria andPointsEqualTo(String value) { - addCriterion("points =", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsNotEqualTo(String value) { - addCriterion("points <>", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsGreaterThan(String value) { - addCriterion("points >", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsGreaterThanOrEqualTo(String value) { - addCriterion("points >=", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsLessThan(String value) { - addCriterion("points <", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsLessThanOrEqualTo(String value) { - addCriterion("points <=", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsLike(String value) { - addCriterion("points like", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsNotLike(String value) { - addCriterion("points not like", value, "points"); - return (Criteria) this; - } - - public Criteria andPointsIn(List values) { - addCriterion("points in", values, "points"); - return (Criteria) this; - } - - public Criteria andPointsNotIn(List values) { - addCriterion("points not in", values, "points"); - return (Criteria) this; - } - - public Criteria andPointsBetween(String value1, String value2) { - addCriterion("points between", value1, value2, "points"); - return (Criteria) this; - } - - public Criteria andPointsNotBetween(String value1, String value2) { - addCriterion("points not between", value1, value2, "points"); - return (Criteria) this; - } - public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java index 7fbb9206..00d51388 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java @@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.ccsens.ht.uitl.Constant; import com.ccsens.util.PdfUtil; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -475,4 +476,46 @@ public class PatientReportVo { private Integer count; } + + + @ApiModel("报告单的详细答题信息") + @Data + public static class ReportDetailAnswer { + @ApiModelProperty("上级选项名") + private String parentCode; + @ApiModelProperty("题目信息") + private List questionList; + } + + @ApiModel("题目详情") + @Data + public static class QuestionInfo { + @ApiModelProperty("试题id") + private Long questionId; + @ApiModelProperty("题目名") + private String questionName; + @ApiModelProperty("题目类型") + private byte type; + @ApiModelProperty("用户操作类型") + private byte operateType; + @ApiModelProperty("题目答案") + private List answers; + @ApiModelProperty("答题信息(图片路径等)") + private String otherValue; + } + @ApiModel("病友的答案") + @Data + public static class Answer { + @JsonIgnore + private String optionName; + @ApiModelProperty("答案") + private String answer; + } + + @ApiModel("病友画图详情") + @Data + public static class QueryQuestionImg { + @ApiModelProperty("图片路径") + private String imgPath; + } } diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java index 98ef2795..7f6fc784 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java @@ -273,15 +273,31 @@ public class QuestionVo { private Long patientReportId; @ApiModelProperty("测评试题id") private Long questionId; + @ApiModelProperty("题目类型") + private byte questionType; + @ApiModelProperty("题目详情(画图题的图片)") + private String questionName; @ApiModelProperty("时间") private Long beginTime; @ApiModelProperty("轨迹,每个字符串是一条轨迹,轨迹内格式(x,y,time;x,y,time;.....)") - private List points; + private List points; @ApiModelProperty("画板大小") private Canvas canvas; @ApiModelProperty("笔触信息") private CanvasLine line; + @ApiModelProperty("统计参数") + private Parameter parameters; } + @Data + @ApiModel("轨迹信息及颜色") + public static class Point{ + @ApiModelProperty("颜色") + private Integer color; + @ApiModelProperty("轨迹坐标值") + private String value; + } + + @Data @ApiModel("画板信息") public static class Canvas{ @@ -298,6 +314,39 @@ public class QuestionVo { @ApiModelProperty("笔触粗细") private Integer width; } + @Data + @ApiModel("轨迹参数统计") + public static class Parameter{ + @ApiModelProperty("打开画板至开始画图的时间") + private Long startDuration; + @ApiModelProperty("画图总时长,下笔到结束") + private Long totalDuration; + @ApiModelProperty("总笔画数") + private int lineNums; + @ApiModelProperty("最长笔画") + private double longLine; + @ApiModelProperty("最短笔画") + private double shortLine; + @ApiModelProperty("笔画中间值") + private double centre; + @ApiModelProperty("平均每分钟画几笔") + private int aveTimes; + @ApiModelProperty("超出占比") + private String beyondProportion; + @ApiModelProperty("每条轨迹的参数") + private List lineParameterList; + } - + @Data + @ApiModel("每条轨迹信息") + public static class LineParameter{ + @ApiModelProperty("笔画长度") + private double length; + @ApiModelProperty("用时") + private long duration; + @ApiModelProperty("速度") + private double speed; + @ApiModelProperty("时间间隔,和上一笔比较") + private long intervalDuration; + } } diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientCanvasDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientCanvasDao.java index 876b9faf..1914869d 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientCanvasDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientCanvasDao.java @@ -1,5 +1,6 @@ package com.ccsens.ht.persist.dao; +import com.ccsens.ht.bean.vo.QuestionVo; import com.ccsens.ht.persist.mapper.HtPatientCanvasMapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -15,5 +16,5 @@ public interface HtPatientCanvasDao extends HtPatientCanvasMapper { /** * 查看用户画图轨迹 */ - List getCanvasPoints(@Param("canvasId") Long canvasId); + List getCanvasPoints(@Param("canvasId") Long canvasId); } diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java index 14a4557d..5e8ecf12 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java @@ -87,4 +87,12 @@ public interface HtPatientReportDao extends HtPatientReportMapper { * @return */ List countByDay(PatientReportDto.Day param); + + /** + * 查询报告单的详细答题洗洗 + * @param id 报告单id + * @param evaluationCode 测试类型 + * @return + */ + List queryReportAnswer(@Param("id")Long id, @Param("evaluationCode")String evaluationCode); } diff --git a/ht/src/main/java/com/ccsens/ht/persist/mapper/HtPatientCanvasLineMapper.java b/ht/src/main/java/com/ccsens/ht/persist/mapper/HtPatientCanvasLineMapper.java index fb33f84c..2ad766c5 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/mapper/HtPatientCanvasLineMapper.java +++ b/ht/src/main/java/com/ccsens/ht/persist/mapper/HtPatientCanvasLineMapper.java @@ -16,15 +16,21 @@ public interface HtPatientCanvasLineMapper { int insertSelective(HtPatientCanvasLine record); + List selectByExampleWithBLOBs(HtPatientCanvasLineExample example); + List selectByExample(HtPatientCanvasLineExample example); HtPatientCanvasLine selectByPrimaryKey(Long id); int updateByExampleSelective(@Param("record") HtPatientCanvasLine record, @Param("example") HtPatientCanvasLineExample example); + int updateByExampleWithBLOBs(@Param("record") HtPatientCanvasLine record, @Param("example") HtPatientCanvasLineExample example); + int updateByExample(@Param("record") HtPatientCanvasLine record, @Param("example") HtPatientCanvasLineExample example); int updateByPrimaryKeySelective(HtPatientCanvasLine record); + int updateByPrimaryKeyWithBLOBs(HtPatientCanvasLine record); + int updateByPrimaryKey(HtPatientCanvasLine record); } \ No newline at end of file diff --git a/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java b/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java index 6fc1d3b3..47bdc37c 100644 --- a/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java @@ -132,4 +132,14 @@ public interface IPatientReportService { * @return */ List countByDay(PatientReportDto.Day param, Long userId); + + /** + * 查询报告单的详细答题信息 + * @param param 报告单ID和测评类型 + * @param userId userId + * @return 返回每个题目和答案 + */ + List queryReportAnswer(PatientReportDto.QueryReportAnswer param, Long userId); + + } diff --git a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java index 4351043a..0675ef8b 100644 --- a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java @@ -554,4 +554,11 @@ public class PatientReportService implements IPatientReportService { public List countByDay(PatientReportDto.Day param, Long userId) { return htPatientReportDao.countByDay(param); } + + @Override + public List queryReportAnswer(PatientReportDto.QueryReportAnswer param, Long userId) { + return htPatientReportDao.queryReportAnswer(param.getId(),param.getEvaluationCode()); + } + + } diff --git a/ht/src/main/java/com/ccsens/ht/service/QuestionService.java b/ht/src/main/java/com/ccsens/ht/service/QuestionService.java index 174c18eb..e110c372 100644 --- a/ht/src/main/java/com/ccsens/ht/service/QuestionService.java +++ b/ht/src/main/java/com/ccsens/ht/service/QuestionService.java @@ -28,6 +28,7 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import java.io.IOException; +import java.math.BigDecimal; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -439,8 +440,9 @@ public class QuestionService implements IQuestionService { patientCanvas.setId(snowflake.nextId()); patientCanvas.setPatientReportId(param.getPatientReportId()); patientCanvas.setQuestionId(param.getQuestionId()); - + patientCanvas.setOpenCanvasTime(param.getOpenCanvasTime()); patientCanvas.setBeginTime(param.getBeginTime()); + patientCanvas.setBeyondProportion(param.getBeyondProportion()); if(ObjectUtil.isNotNull(param.getCanvas())){ patientCanvas.setCanvasWidth(param.getCanvas().getWidth()); patientCanvas.setCanvasHeight(param.getCanvas().getHeight()); @@ -461,10 +463,10 @@ public class QuestionService implements IQuestionService { patientCanvasLineMapper.insertSelective(patientCanvasLine); }); } + //查询轨迹信息 QuestionDto.QueryPatientCanvas patient = new QuestionDto.QueryPatientCanvas(); patient.setPatientReportId(param.getPatientReportId()); patient.setQuestionId(param.getQuestionId()); - return getCanvas(patient,userId); } @@ -479,15 +481,22 @@ public class QuestionService implements IQuestionService { canvasExample.createCriteria().andPatientReportIdEqualTo(param.getPatientReportId()).andQuestionIdEqualTo(param.getQuestionId()); canvasExample.setOrderByClause("begin_time DESC"); List patientCanvasList = patientCanvasDao.selectByExample(canvasExample); - + log.info("查询画图记录:{}",patientCanvasList); if(CollectionUtil.isEmpty(patientCanvasList)){ return canvasList; } + //查询题目信息 + HtQuestion question = htQuestionDao.selectByPrimaryKey(param.getQuestionId()); + if(ObjectUtil.isNull(question)){ + throw new BaseException(CodeEnum.PARAM_ERROR); + } patientCanvasList.forEach(htPatientCanvas ->{ QuestionVo.PatientCanvas patientCanvas = new QuestionVo.PatientCanvas(); patientCanvas.setPatientCanvasId(htPatientCanvas.getId()); patientCanvas.setPatientReportId(htPatientCanvas.getPatientReportId()); patientCanvas.setQuestionId(htPatientCanvas.getQuestionId()); + patientCanvas.setQuestionType(question.getType()); + patientCanvas.setQuestionName(question.getQuestion()); patientCanvas.setBeginTime(htPatientCanvas.getBeginTime()); QuestionVo.Canvas canvas = new QuestionVo.Canvas(); @@ -498,9 +507,140 @@ public class QuestionService implements IQuestionService { canvasLine.setColor(htPatientCanvas.getLineColor()); canvasLine.setWidth(htPatientCanvas.getLineWidth()); patientCanvas.setLine(canvasLine); - patientCanvas.setPoints(patientCanvasDao.getCanvasPoints(htPatientCanvas.getId())); + //颜色和轨迹坐标 + List canvasPoints = getCanvasPoints(htPatientCanvas); + patientCanvas.setPoints(canvasPoints); + //计算参数 + QuestionVo.Parameter parameter = getParameter(htPatientCanvas); + patientCanvas.setParameters(parameter); canvasList.add(patientCanvas); }); return canvasList; } + + private List getCanvasPoints(HtPatientCanvas htPatientCanvas) { + List canvasPoints = patientCanvasDao.getCanvasPoints(htPatientCanvas.getId()); + if(canvasPoints.size() > 16){ + int c = 240 / (((canvasPoints.size() + 1) / 4) - 1); + int a = 0; + int b = 0; + for(QuestionVo.Point point : canvasPoints){ + if(a < 4){ + a++; + }else { + b += c; + a = 0; + } + point.setColor(b); + } + }else { + int a = 0; + int b = 0; + List colours = Constant.LineColour.COLOUR; + for(QuestionVo.Point point : canvasPoints){ + if(a < 4){ + a++; + }else { + b++; + a = 0; + } + point.setColor(colours.get(b)); + } + } + return canvasPoints; + } + + /** + * 统计画图的参数 + * @param htPatientCanvas 画板信息 + * @return 返回此次画图的参数 + */ + private QuestionVo.Parameter getParameter(HtPatientCanvas htPatientCanvas) { + QuestionVo.Parameter parameter = new QuestionVo.Parameter(); + //开始画图时长:打开画板到第一笔画图时长 + parameter.setStartDuration(htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime()); + //获取轨迹信息 + List canvasPoints = patientCanvasDao.getCanvasPoints(htPatientCanvas.getId()); + //最后一笔的结束时间 + String[] pointsLast = canvasPoints.get(canvasPoints.size() - 1).getValue().split(";"); + String[] split = pointsLast[pointsLast.length - 1].split(","); + long endTime = Long.parseLong(split[split.length - 1]); + //超出占比 + parameter.setBeyondProportion(htPatientCanvas.getBeyondProportion()); + //画图总时长 + parameter.setTotalDuration(endTime); + //总笔画数 + parameter.setLineNums(canvasPoints.size()); + //共几分钟 + double d = (double) endTime / 1000 / 60; + //每分钟几笔 + parameter.setAveTimes((int) Math.floor(canvasPoints.size() / d)); + //每笔数据 + List lineParameterList = new ArrayList<>(); + long intervalDuration = 0; + //最长的笔画 + double longLine = 0; + //最短的笔画 + double shortLine = 0; + for(QuestionVo.Point canvas : canvasPoints){ + //时间 + QuestionVo.LineParameter lineParameter = new QuestionVo.LineParameter(); + String[] a = canvas.getValue().split(";"); + if(a.length <= 0){ + continue; + } + String[] s = a[0].split(","); + String[] e = a[a.length - 1].split(","); + long duration = Long.parseLong(e[e.length - 1]) - Long.parseLong(s[s.length - 1]); + lineParameter.setDuration(duration); + //长度 + double length = getLengthByCanvas(a); + lineParameter.setLength(length); + //计算最长最短 + if(longLine == 0){ + longLine = length; + }else if(length > longLine){ + longLine = length; + } + if(shortLine == 0){ + shortLine = length; + }else if(length < shortLine){ + shortLine = length; + } + //速度 + double speed = 0; + if(length != 0 && duration != 0){ + speed = BigDecimal.valueOf(length / duration).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + lineParameter.setSpeed(speed); + //和上一笔的间隔 + if(Long.parseLong(e[e.length - 1]) == 0){ + lineParameter.setIntervalDuration(htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime()); + }else { + intervalDuration = Long.parseLong(e[e.length - 1]) - intervalDuration; + lineParameter.setIntervalDuration(intervalDuration); + } + lineParameterList.add(lineParameter); + } + parameter.setLineParameterList(lineParameterList); + //最长笔画 + parameter.setLongLine(longLine); + //最短笔画 + parameter.setShortLine(shortLine); + //TODO 笔画中间值 + return parameter; + } + + private double getLengthByCanvas(String[] canvas) { + double l = 0; + for (int i = 1; i < canvas.length; i++){ + String[] a = canvas[i].split(","); + String[] b = canvas[i - 1].split(","); + double pow = Math.pow(Integer.parseInt(a[0]) - Integer.parseInt(b[0]), 2); + double pow1 = Math.pow(Integer.parseInt(a[1]) - Integer.parseInt(b[1]), 2); + double sqrt = Math.sqrt(pow + pow1); + l += sqrt; + } + return BigDecimal.valueOf(l).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } } diff --git a/ht/src/main/java/com/ccsens/ht/uitl/Constant.java b/ht/src/main/java/com/ccsens/ht/uitl/Constant.java index ca367d23..f11cbee7 100644 --- a/ht/src/main/java/com/ccsens/ht/uitl/Constant.java +++ b/ht/src/main/java/com/ccsens/ht/uitl/Constant.java @@ -22,7 +22,17 @@ public class Constant { /**上传图片访问路径*/ public static final String UPLOAD_URL = "uploads/"; + /**病友画图轨迹颜色*/ + public static final class LineColour { + public final static List COLOUR = new ArrayList<>(); + static { + COLOUR.add(0); + COLOUR.add(30); + COLOUR.add(120); + COLOUR.add(240); + } + } /**注册来源*/ public static final class Regist { public final static byte SOURCE = 0; @@ -31,6 +41,8 @@ public class Constant { } + + /** * 医疗职称相关常量 */ diff --git a/ht/src/main/resources/mapper_dao/HtPatientCanvasDao.xml b/ht/src/main/resources/mapper_dao/HtPatientCanvasDao.xml index 65958ff6..a67948e0 100644 --- a/ht/src/main/resources/mapper_dao/HtPatientCanvasDao.xml +++ b/ht/src/main/resources/mapper_dao/HtPatientCanvasDao.xml @@ -3,9 +3,9 @@ - SELECT - points + points as `value` FROM t_ht_patient_canvas_line cl WHERE diff --git a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml index 6cb873fd..7ff89458 100644 --- a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml +++ b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml @@ -1,50 +1,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select r.*, d.name as doctor_name, p.name as patient_name, p.sex, p.educational_status, p.educational_status_unit, p.career, p.hospital_number, p.patient_number from t_ht_patient_report r, t_ht_patient p, t_ht_doctor d where r.patient_id = p.id and r.doctor_id = d.id and r.id = #{id, jdbcType=BIGINT} and r.is_del = 0 and p.is_del = 0 and d.is_del = 0 - select t1.code,t1.name, t1.description, t1.total_score, t1.remark,t1.type,t1.parent_code, sum(t2.score) as score from (select code,name, description, total_score, remark, type, parent_code, sort from t_ht_report where is_show = 1 and is_del = 0) t1 @@ -56,13 +56,13 @@ GROUP BY t1.code order by t1.type,t1.sort - select option_name as optionName, sum(score) as score from t_ht_patient_score where patient_report_id = #{id, jdbcType=BIGINT} and question_parent_code = 'NPI' and option_name in ('carer','result') and is_del = 0 group by option_name; - select r.id, r.name, p.id as patientId, p.name as patientName, p.idcard as patientIdCard, r.create_time as createTime, concat('检测到您在', r.create_time, '为患者', p.name,'的检测报告尚未完成,是否继续?') as description , @@ -73,75 +73,149 @@ and r.complete_status = 0 and d.is_del = 0 and r.is_del = 0 and p.is_del = 0 order by r.create_time desc limit 1; - update t_ht_patient_report set complete_status = 2 , show_status = 0 where id = #{id, jdbcType=BIGINT} and complete_status = 0 and is_del = 0 and doctor_id in (select doctor_id from t_ht_doctor where user_id = #{userId, jdbcType=BIGINT} and audit_state = 1 and is_del = 0) + - - select clinical_diagnosis as diagnosis, count(*) as count from t_ht_patient_report where is_del = 0 and show_status = 1 group by diagnosis - select r.patient_age div 10 * 10 as ageLevel, p.sex as sex, count(*) as count from t_ht_patient_report r, t_ht_patient p where r.patient_id = p.id and r.is_del = 0 and r.show_status = 1 group by ageLevel, sex order by ageLevel, sex - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ht/src/main/resources/mapper_raw/HtPatientCanvasLineMapper.xml b/ht/src/main/resources/mapper_raw/HtPatientCanvasLineMapper.xml index c926adf1..8c890aa4 100644 --- a/ht/src/main/resources/mapper_raw/HtPatientCanvasLineMapper.xml +++ b/ht/src/main/resources/mapper_raw/HtPatientCanvasLineMapper.xml @@ -4,11 +4,13 @@ - + + + @@ -68,8 +70,27 @@ - id, patient_canvas_id, points, create_time, update_time, is_del + id, patient_canvas_id, create_time, update_time, is_del + + + points + - select + , + from t_ht_patient_canvas_line where id = #{id,jdbcType=BIGINT} @@ -101,11 +124,11 @@ - insert into t_ht_patient_canvas_line (id, patient_canvas_id, points, - create_time, update_time, is_del + insert into t_ht_patient_canvas_line (id, patient_canvas_id, create_time, + update_time, is_del, points ) - values (#{id,jdbcType=BIGINT}, #{patientCanvasId,jdbcType=BIGINT}, #{points,jdbcType=VARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT} + values (#{id,jdbcType=BIGINT}, #{patientCanvasId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, + #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT}, #{points,jdbcType=LONGVARCHAR} ) @@ -117,9 +140,6 @@ patient_canvas_id, - - points, - create_time, @@ -129,6 +149,9 @@ is_del, + + points, + @@ -137,9 +160,6 @@ #{patientCanvasId,jdbcType=BIGINT}, - - #{points,jdbcType=VARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, @@ -149,6 +169,9 @@ #{isDel,jdbcType=TINYINT}, + + #{points,jdbcType=LONGVARCHAR}, + select @@ -110,11 +112,13 @@ insert into t_ht_patient_canvas (id, patient_report_id, question_id, begin_time, canvas_width, canvas_height, line_color, line_width, create_time, - update_time, is_del) + update_time, is_del, open_canvas_time, + beyond_proportion) values (#{id,jdbcType=BIGINT}, #{patientReportId,jdbcType=BIGINT}, #{questionId,jdbcType=BIGINT}, #{beginTime,jdbcType=BIGINT}, #{canvasWidth,jdbcType=INTEGER}, #{canvasHeight,jdbcType=INTEGER}, #{lineColor,jdbcType=VARCHAR}, #{lineWidth,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, - #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT}) + #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT}, #{openCanvasTime,jdbcType=BIGINT}, + #{beyondProportion,jdbcType=VARCHAR}) insert into t_ht_patient_canvas @@ -152,6 +156,12 @@ is_del, + + open_canvas_time, + + + beyond_proportion, + @@ -187,6 +197,12 @@ #{isDel,jdbcType=TINYINT}, + + #{openCanvasTime,jdbcType=BIGINT}, + + + #{beyondProportion,jdbcType=VARCHAR}, +