Browse Source

根据分数查询报告单

sd
zhizhi wu 4 years ago
parent
commit
a1e27e8094
  1. 6
      ht/src/main/resources/mapper_dao/HtPatientReportDao.xml
  2. 58
      question/src/main/java/com/ccsens/question/api/PatientReportSearchController.java
  3. 38
      question/src/main/java/com/ccsens/question/bean/dto/PatientReportSearchDto.java
  4. 33
      question/src/main/java/com/ccsens/question/bean/vo/PatientReportSearchVo.java
  5. 9
      question/src/main/java/com/ccsens/question/persist/dao/HtPatientReportDao.java
  6. 8
      question/src/main/java/com/ccsens/question/persist/dao/HtReportDao.java
  7. 15
      question/src/main/java/com/ccsens/question/service/IPatientReportService.java
  8. 31
      question/src/main/java/com/ccsens/question/service/PatientReportService.java
  9. 31
      question/src/main/resources/mapper_dao/HtPatientReportDao.xml
  10. 31
      question/src/main/resources/mapper_dao/HtReportDao.xml

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

@ -244,12 +244,12 @@
GROUP BY
patient_report_id
HAVING
<trim>
<trim suffixOverrides="AND">
<if test="item.start != null">
AND sum( score ) &gt;= #{item.start}
sum( score ) &gt;= #{item.start} AND
</if>
<if test="item.end != null">
AND sum( score ) &lt;= #{item.end}
sum( score ) &lt;= #{item.end} AND
</if>
</trim>
</if>

58
question/src/main/java/com/ccsens/question/api/PatientReportSearchController.java

@ -0,0 +1,58 @@
package com.ccsens.question.api;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.question.bean.dto.PatientReportSearchDto;
import com.ccsens.question.bean.vo.PatientReportSearchVo;
import com.ccsens.question.service.IPatientReportService;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto;
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 javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
/**
* @description:
* @author: whj
* @time: 2021/3/10 15:03
*/
@Slf4j
@Api(tags = "报告单搜索",value = "报告单搜索条件,搜索")
@RestController
@RequestMapping("/patientReport")
public class PatientReportSearchController {
@Resource
private IPatientReportService patientReportService;
@MustLogin
@ApiOperation(value = "查询搜索条件",notes = "whj 查询搜索条件")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "查询搜索条件", required = true)
})
@RequestMapping(value="/searchParam", method = RequestMethod.POST)
public JsonResponse<PatientReportSearchVo.SearchParam> searchParam(@RequestBody @ApiParam @Valid QueryDto<PatientReportSearchDto.SearchParam> dto){
log.info("查询搜索条件:{}", dto);
List<PatientReportSearchVo.SearchParam> params = patientReportService.searchParam(dto.getParam());
log.info("查询搜索条件已完成:{}", params);
return JsonResponse.newInstance().ok(params);
}
@MustLogin
@ApiOperation(value = "根据条件搜索报告单",notes = "whj 搜索报告单")
@ApiImplicitParams({
@ApiImplicitParam(name = "json", value = "查询搜索条件", required = true)
})
@RequestMapping(value="/search", method = RequestMethod.POST)
public JsonResponse<PatientReportSearchVo.Search> search(@RequestBody @ApiParam @Valid QueryDto<PatientReportSearchDto.SearchList> dto){
log.info("搜索报告单:{}", dto);
List<PatientReportSearchVo.Search> params = patientReportService.search(dto.getParam());
log.info("搜索报告单已完成");
return JsonResponse.newInstance().ok(params);
}
}

38
question/src/main/java/com/ccsens/question/bean/dto/PatientReportSearchDto.java

@ -0,0 +1,38 @@
package com.ccsens.question.bean.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* @description:
* @author: whj
* @time: 2021/3/10 16:21
*/
public class PatientReportSearchDto {
@Data
@ApiModel("搜索条件-请求参数")
public static class SearchParam{
@ApiModelProperty("查询类型")
@NotEmpty(message = "请输入查询报告单类型")
private String parentCode;
}
@Data
@ApiModel("搜索报告单参数列表-请求")
public static class SearchList {
private List<Search> codes;
}
@Data
@ApiModel("搜索报告单参数-请求")
public static class Search {
@NotEmpty(message="请选择查询类型")
private String code;
private Integer start;
private Integer end;
}
}

33
question/src/main/java/com/ccsens/question/bean/vo/PatientReportSearchVo.java

@ -0,0 +1,33 @@
package com.ccsens.question.bean.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @author: whj
* @time: 2021/3/10 16:06
*/
public class PatientReportSearchVo {
@Data
@ApiModel("搜索条件-响应")
public static class SearchParam {
private Long id;
private String code;
private String name;
private byte optionStatus;
private String parentCode;
private List<SearchParam> children = new ArrayList<>();
}
@Data
@ApiModel("搜索-响应")
public static class Search {
private Long id;
private String name;
}
}

9
question/src/main/java/com/ccsens/question/persist/dao/HtPatientReportDao.java

@ -1,6 +1,8 @@
package com.ccsens.question.persist.dao;
import com.ccsens.question.bean.dto.PatientReportDto;
import com.ccsens.question.bean.dto.PatientReportSearchDto;
import com.ccsens.question.bean.vo.PatientReportSearchVo;
import com.ccsens.question.bean.vo.PatientReportVo;
import com.ccsens.question.persist.mapper.HtPatientReportMapper;
import org.apache.ibatis.annotations.Param;
@ -95,4 +97,11 @@ public interface HtPatientReportDao extends HtPatientReportMapper {
* @return
*/
List<PatientReportVo.ReportDetailAnswer> queryReportAnswer(@Param("id") Long id, @Param("evaluationCode") String evaluationCode);
/**
* 根据分数搜索报告单
* @param codes 分数
* @return 报告单
*/
List<PatientReportSearchVo.Search> search(@Param("codes") List<PatientReportSearchDto.Search> codes);
}

8
question/src/main/java/com/ccsens/question/persist/dao/HtReportDao.java

@ -1,6 +1,7 @@
package com.ccsens.question.persist.dao;
import com.ccsens.question.bean.po.HtReport;
import com.ccsens.question.bean.vo.PatientReportSearchVo;
import com.ccsens.question.bean.vo.QuestionVo;
import com.ccsens.question.persist.mapper.HtReportMapper;
import org.apache.ibatis.annotations.Param;
@ -37,4 +38,11 @@ public interface HtReportDao extends HtReportMapper {
* @return 返回测评类型
*/
List<QuestionVo.ReportCode> queryReportCode(@Param("code") String code);
/**
* 查询所有下级菜单和是否有试题
* @param parentCode 父code
* @return 搜索条件
*/
List<PatientReportSearchVo.SearchParam> queryParam(@Param("parentCode") String parentCode);
}

15
question/src/main/java/com/ccsens/question/service/IPatientReportService.java

@ -1,7 +1,9 @@
package com.ccsens.question.service;
import com.ccsens.question.bean.dto.PatientReportDto;
import com.ccsens.question.bean.dto.PatientReportSearchDto;
import com.ccsens.question.bean.po.HtDoctor;
import com.ccsens.question.bean.vo.PatientReportSearchVo;
import com.ccsens.question.bean.vo.PatientReportVo;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
@ -142,4 +144,17 @@ public interface IPatientReportService {
List<PatientReportVo.ReportDetailAnswer> queryReportAnswer(PatientReportDto.QueryReportAnswer param, Long userId);
/**
* 查询报告单的搜索条件
* @param param 父code
* @return 搜索条件
*/
List<PatientReportSearchVo.SearchParam> searchParam(PatientReportSearchDto.SearchParam param);
/**
* 搜索报告单
* @param param 搜索列表
* @return 报告单
*/
List<PatientReportSearchVo.Search> search(PatientReportSearchDto.SearchList param);
}

31
question/src/main/java/com/ccsens/question/service/PatientReportService.java

@ -7,11 +7,14 @@ import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ccsens.question.bean.dto.PatientReportDto;
import com.ccsens.question.bean.dto.PatientReportSearchDto;
import com.ccsens.question.bean.po.*;
import com.ccsens.question.bean.vo.PatientReportSearchVo;
import com.ccsens.question.bean.vo.PatientReportVo;
import com.ccsens.question.persist.dao.HtDoctorDao;
import com.ccsens.question.persist.dao.HtPatientReportDao;
import com.ccsens.question.persist.dao.HtPositionDao;
import com.ccsens.question.persist.dao.HtReportDao;
import com.ccsens.question.persist.mapper.HtPatientFollowUpMapper;
import com.ccsens.question.persist.mapper.HtPatientMapper;
import com.ccsens.question.persist.mapper.HtPatientReportRecordMapper;
@ -46,7 +49,7 @@ import java.util.concurrent.atomic.AtomicReference;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class PatientReportService implements IPatientReportService {
@Autowired
@Resource
private Snowflake snowflake;
@Resource
private HtDoctorDao htDoctorDao;
@ -60,6 +63,8 @@ public class PatientReportService implements IPatientReportService {
private HtPatientReportRecordMapper htPatientReportRecordMapper;
@Resource
private HtPatientFollowUpMapper htPatientFollowUpMapper;
@Resource
private HtReportDao htReportDao;
@Override
public JsonResponse<PatientReportVo.Generate> generatePatientReport(PatientReportDto.Generate generate, Long userId) {
@ -578,5 +583,29 @@ public class PatientReportService implements IPatientReportService {
return htPatientReportDao.queryReportAnswer(param.getId(),param.getEvaluationCode());
}
@Override
public List<PatientReportSearchVo.SearchParam> searchParam(PatientReportSearchDto.SearchParam param) {
List<PatientReportSearchVo.SearchParam> list = htReportDao.queryParam(param.getParentCode());
if (CollectionUtil.isEmpty(list)) {
return list;
}
Map<String, PatientReportSearchVo.SearchParam> map = new HashMap<>();
List<PatientReportSearchVo.SearchParam> nodes = new ArrayList<>();
list.forEach(searchParam -> {
if (param.getParentCode().equals(searchParam.getParentCode())) {
nodes.add(searchParam);
} else {
PatientReportSearchVo.SearchParam parent = map.get(searchParam.getParentCode());
parent.getChildren().add(searchParam);
}
map.put(searchParam.getCode(), searchParam);
});
return nodes;
}
@Override
public List<PatientReportSearchVo.Search> search(PatientReportSearchDto.SearchList param) {
List<PatientReportSearchVo.Search> list = htPatientReportDao.search(param.getCodes());
return list;
}
}

31
question/src/main/resources/mapper_dao/HtPatientReportDao.xml

@ -225,6 +225,37 @@
and a.questionId = t.question_id
ORDER BY a.questionId ,a.sort
</select>
<select id="search" resultType="com.ccsens.question.bean.vo.PatientReportSearchVo$Search">
<foreach collection="codes" item="item" separator="INTERSECT">
<if test="item.code != null and item.code != '' and (item.start != null or item.end != null)">
SELECT
r.id,
r.NAME
FROM
t_ht_patient_score s,
t_ht_question q,
t_ht_patient_report r
WHERE
s.question_id = q.id
AND s.patient_report_id = r.id
AND s.question_parent_code = #{item.code}
AND s.type IN ( 0, 2 )
AND s.is_del = 0
AND q.is_del = 0
GROUP BY
patient_report_id
HAVING
<trim suffixOverrides="AND">
<if test="item.start != null">
sum( score ) &gt;= #{item.start} AND
</if>
<if test="item.end != null">
sum( score ) &lt;= #{item.end} AND
</if>
</trim>
</if>
</foreach>
</select>
</mapper>

31
question/src/main/resources/mapper_dao/HtReportDao.xml

@ -47,5 +47,36 @@
parent_code = #{code}
ORDER BY sort
</select>
<select id="queryParam" resultType="com.ccsens.question.bean.vo.PatientReportSearchVo$SearchParam">
SELECT
t.id,
t.code,
t.parent_code as parentCode,
t.name,
IF( count( q.id ) > 0, 1, 0 ) AS optionStatus
FROM
(
SELECT
t.id,
t.CODE,
t.parent_code,
t.NAME,
t.type,
t.sort
FROM
(
SELECT
t1.*,
IF ( find_in_set( parent_code, @pcodes ) > 0, @pcodes := concat( @pcodes, ',', CODE ), 0 ) AS ischild
FROM
( SELECT id, CODE, parent_code, NAME, type, sort FROM t_ht_report WHERE is_del = 0 ) t1,
( SELECT @pcodes := #{parentCode} ) t2
) t
WHERE t.ischild != '0'
) t
LEFT JOIN t_ht_question q ON t.CODE = q.parent_code AND q.is_del = 0
GROUP BY t.CODE
ORDER BY t.type,t.parent_code,t.sort
</select>
</mapper>
Loading…
Cancel
Save