|
|
@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.ht.bean.dto.PatientReportDto; |
|
|
|
import com.ccsens.ht.bean.po.*; |
|
|
|
import com.ccsens.ht.bean.vo.PatientReportVo; |
|
|
|
import com.ccsens.ht.persist.dao.HtDoctorDao; |
|
|
|
import com.ccsens.ht.persist.dao.HtPatientReportDao; |
|
|
|
import com.ccsens.ht.persist.dao.HtPositionDao; |
|
|
|
import com.ccsens.ht.persist.mapper.HtDoctorMapper; |
|
|
@ -48,7 +49,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
@Autowired |
|
|
|
private Snowflake snowflake; |
|
|
|
@Resource |
|
|
|
private HtDoctorMapper htDoctorMapper; |
|
|
|
private HtDoctorDao htDoctorDao; |
|
|
|
@Resource |
|
|
|
private HtPatientReportDao htPatientReportDao; |
|
|
|
@Resource |
|
|
@ -66,7 +67,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
//查询医生信息
|
|
|
|
HtDoctorExample doctorExample = new HtDoctorExample(); |
|
|
|
doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT); |
|
|
|
List<HtDoctor> doctors = htDoctorMapper.selectByExample(doctorExample); |
|
|
|
List<HtDoctor> doctors = htDoctorDao.selectByExample(doctorExample); |
|
|
|
if (CollectionUtils.isEmpty(doctors)) { |
|
|
|
log.info("根据userId未找到审核通过的医生信息:{}", userId); |
|
|
|
return JsonResponse.newInstance().ok(CodeEnum.PARAM_ERROR); |
|
|
@ -109,7 +110,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
//查询修改医生信息
|
|
|
|
HtDoctorExample example = new HtDoctorExample(); |
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS); |
|
|
|
List<HtDoctor> doctors = htDoctorMapper.selectByExample(example); |
|
|
|
List<HtDoctor> doctors = htDoctorDao.selectByExample(example); |
|
|
|
if (CollectionUtils.isEmpty(doctors)) { |
|
|
|
log.info("{}医生信息尚未审核通过"); |
|
|
|
return CodeEnum.AUDIT_NOT_PASS; |
|
|
@ -117,7 +118,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
HtDoctor doctor = doctors.get(0); |
|
|
|
|
|
|
|
//判断该报告单是否为该医生的
|
|
|
|
HtDoctor reportDoctor = htDoctorMapper.selectByPrimaryKey(htPatientReport.getDoctorId()); |
|
|
|
HtDoctor reportDoctor = htDoctorDao.selectByPrimaryKey(htPatientReport.getDoctorId()); |
|
|
|
// 上级医生和报告单医生允许修改
|
|
|
|
List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId()); |
|
|
|
if (!doctor.getId().equals(reportDoctor.getId()) && !lowerPositionIds.contains(reportDoctor.getPositionId())) { |
|
|
@ -160,68 +161,53 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientReportVo.ReportName> queryReports(PatientReportDto.QueryReports query, Long userId) { |
|
|
|
List<PatientReportVo.ReportName> reportVos = new ArrayList<>(); |
|
|
|
//分页查询报告单列表
|
|
|
|
PageHelper.startPage(query.getPageNum(), query.getPageSize()); |
|
|
|
HtPatientReportExample reportExample = new HtPatientReportExample(); |
|
|
|
|
|
|
|
//查询医生信息
|
|
|
|
HtDoctorExample doctorExample = new HtDoctorExample(); |
|
|
|
doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT); |
|
|
|
List<HtDoctor> doctors = htDoctorMapper.selectByExample(doctorExample); |
|
|
|
List<HtDoctor> doctors = htDoctorDao.selectByExample(doctorExample); |
|
|
|
log.info("当前用户是否为医生:{}", CollectionUtil.isNotEmpty(doctors)); |
|
|
|
// 获取医生ID和病人ID
|
|
|
|
Long patientId = null; |
|
|
|
Long doctorId = null; |
|
|
|
if (query.getPatientId() != null) { |
|
|
|
reportExample.createCriteria().andPatientIdEqualTo(query.getPatientId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY); |
|
|
|
//.andInitialImpressionIsNotNull().andInitialImpressionNotEqualTo("");
|
|
|
|
patientId = query.getPatientId(); |
|
|
|
} else if (CollectionUtil.isNotEmpty(doctors)) { |
|
|
|
reportExample.createCriteria().andDoctorIdEqualTo(doctors.get(0).getId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY); |
|
|
|
//.andInitialImpressionIsNotNull().andInitialImpressionNotEqualTo("");
|
|
|
|
doctorId = doctors.get(0).getId(); |
|
|
|
} else { |
|
|
|
log.info("既无病人信息,有无医生信息,不允许查询"); |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
reportExample.setOrderByClause("create_time desc"); |
|
|
|
List<HtPatientReport> reports = htPatientReportDao.selectByExample(reportExample); |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(reports)) { |
|
|
|
//分页查询报告单列表
|
|
|
|
PageHelper.startPage(query.getPageNum(), query.getPageSize()); |
|
|
|
List<PatientReportVo.ReportName> reportVos = htPatientReportDao.queryReportName(doctorId, patientId); |
|
|
|
if (CollectionUtils.isEmpty(reportVos)) { |
|
|
|
return new PageInfo<>(reportVos); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(doctors)) { |
|
|
|
reports.forEach(report -> { |
|
|
|
PatientReportVo.ReportName name = new PatientReportVo.ReportName(); |
|
|
|
name.setId(report.getId()); |
|
|
|
name.setName(report.getName()); |
|
|
|
name.setUrl(report.getUrl()); |
|
|
|
name.setAuthority((byte)0); |
|
|
|
reportVos.add(name); |
|
|
|
}); |
|
|
|
return new PageInfo<>(reportVos); |
|
|
|
} |
|
|
|
HtDoctor doctor = doctors.get(0); |
|
|
|
//查询下属职务
|
|
|
|
List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId()); |
|
|
|
reports.forEach(report -> { |
|
|
|
PatientReportVo.ReportName name = new PatientReportVo.ReportName(); |
|
|
|
name.setId(report.getId()); |
|
|
|
name.setName(report.getName()); |
|
|
|
name.setUrl(report.getUrl()); |
|
|
|
reportVos.forEach(reportVo -> { |
|
|
|
|
|
|
|
//自己的可见详情
|
|
|
|
if (doctor.getId().equals(report.getDoctorId())) { |
|
|
|
name.setAuthority((byte)1); |
|
|
|
if (doctor.getId().equals(reportVo.getDoctorId())) { |
|
|
|
reportVo.setAuthority((byte)1); |
|
|
|
} else if (CollectionUtils.isEmpty(lowerPositionIds)) { |
|
|
|
name.setAuthority((byte)0); |
|
|
|
reportVo.setAuthority((byte)0); |
|
|
|
} else { |
|
|
|
HtDoctor reportDoctor = htDoctorMapper.selectByPrimaryKey(report.getDoctorId()); |
|
|
|
HtDoctor reportDoctor = htDoctorDao.selectByPrimaryKey(reportVo.getDoctorId()); |
|
|
|
//自己下属的可见详情
|
|
|
|
if (lowerPositionIds.contains(reportDoctor.getPositionId())) { |
|
|
|
name.setAuthority((byte)1); |
|
|
|
reportVo.setAuthority((byte)1); |
|
|
|
} else { |
|
|
|
name.setAuthority((byte)0); |
|
|
|
reportVo.setAuthority((byte)0); |
|
|
|
} |
|
|
|
} |
|
|
|
reportVos.add(name); |
|
|
|
}); |
|
|
|
return new PageInfo<>(reportVos); |
|
|
|
} |
|
|
@ -298,7 +284,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
//查询医生信息
|
|
|
|
HtDoctorExample doctorExample = new HtDoctorExample(); |
|
|
|
doctorExample.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS).andIsDelEqualTo(Constant.Ht.NUMBER_DEFAULT); |
|
|
|
List<HtDoctor> doctors = htDoctorMapper.selectByExample(doctorExample); |
|
|
|
List<HtDoctor> doctors = htDoctorDao.selectByExample(doctorExample); |
|
|
|
if (CollectionUtils.isEmpty(doctors)) { |
|
|
|
authorityVo.setAuthority(PatientReportVo.Authority.OLAY_READ); |
|
|
|
return authorityVo; |
|
|
@ -316,7 +302,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
return authorityVo; |
|
|
|
} |
|
|
|
//查询报告单关联医生职位
|
|
|
|
HtDoctor doctor1 = htDoctorMapper.selectByPrimaryKey(htPatientReport.getDoctorId()); |
|
|
|
HtDoctor doctor1 = htDoctorDao.selectByPrimaryKey(htPatientReport.getDoctorId()); |
|
|
|
if (lowerPositionIds.contains(doctor1.getPositionId())) { |
|
|
|
authorityVo.setAuthority(PatientReportVo.Authority.CHECK); |
|
|
|
} else { |
|
|
@ -389,6 +375,7 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
PdfUtil.Cell initImplCell = addCell(row, detail.getPatient().getInitialImpression(), 6, 2); |
|
|
|
initImplCell.setHeight(PdfUtil.Cell.defaultHeight * 2); |
|
|
|
initImplCell.setBorderRight(1); |
|
|
|
initImplCell.setCenter(false); |
|
|
|
content.add(row); |
|
|
|
PdfUtil.Row row2 = new PdfUtil.Row(); |
|
|
|
PdfUtil.Cell doctorCell = addCell(row2, "测评员:", 4, 1, 0); |
|
|
@ -454,4 +441,118 @@ public class PatientReportService implements IPatientReportService { |
|
|
|
log.info("修改报告单二维码路径"); |
|
|
|
return qrCodeUrl; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientReportVo.ReportName> queryDoctorReports(PatientReportDto.Doctor param, HtDoctor doctor, Long userId) { |
|
|
|
//判断被查询医生是否为下属
|
|
|
|
//查询下属职务
|
|
|
|
List<Long> lowerPositionIds = htPositionDao.queryAllLowerPosition(doctor.getPositionId()); |
|
|
|
log.info("下属职务:{}", lowerPositionIds); |
|
|
|
if (CollectionUtils.isEmpty(lowerPositionIds)) { |
|
|
|
throw new BaseException(CodeEnum.AUTHORITY_ERROR); |
|
|
|
} |
|
|
|
HtDoctor queryDoctor = htDoctorDao.selectByPrimaryKey(param.getId()); |
|
|
|
log.info("被查询医生信息:{}", queryDoctor); |
|
|
|
if (queryDoctor == null){ |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
if (!lowerPositionIds.contains(queryDoctor.getPositionId())) { |
|
|
|
log.info("被查询医生不是当前医生的下属"); |
|
|
|
throw new BaseException(CodeEnum.AUTHORITY_ERROR); |
|
|
|
} |
|
|
|
// 查询该医生报告单
|
|
|
|
PageHelper.startPage(param.getPageNum(), param.getPageSize()); |
|
|
|
HtPatientReportExample reportExample = new HtPatientReportExample(); |
|
|
|
reportExample.createCriteria().andDoctorIdEqualTo(param.getId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY); |
|
|
|
reportExample.setOrderByClause("create_time desc"); |
|
|
|
List<PatientReportVo.ReportName> reports = htPatientReportDao.queryReportName(param.getId(), null); |
|
|
|
if (CollectionUtils.isEmpty(reports)) { |
|
|
|
log.info("未查询到报告单"); |
|
|
|
return new PageInfo<>(reports); |
|
|
|
} |
|
|
|
reports.forEach(report -> { |
|
|
|
report.setAuthority((byte)1); |
|
|
|
}); |
|
|
|
return new PageInfo<>(reports); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PatientReportVo.ReportName> queryAllReports(PatientReportDto.AdminQueryReport adminQueryReport, Long userId) { |
|
|
|
PageHelper.startPage(adminQueryReport.getPageNum(), adminQueryReport.getPageSize()); |
|
|
|
List<PatientReportVo.ReportName> reportNames = htPatientReportDao.queryAllReports(adminQueryReport); |
|
|
|
return new PageInfo<>(reportNames); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public List<PatientReportVo.ClinicalDiagnosis> countByClinicalDiagnosis(PatientReportDto.ClinicalDiagnosis param, Long userId) { |
|
|
|
return htPatientReportDao.countByClinicalDiagnosis(param); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<PatientReportVo.AgeAndSexGroup> countBySexAndAge(PatientReportDto.AgeAndSex param, Long userId) { |
|
|
|
List<PatientReportVo.AgeAndSex> list = htPatientReportDao.countBySexAndAge(param); |
|
|
|
List<PatientReportVo.AgeAndSexGroup> groups = new ArrayList<>(); |
|
|
|
List<Byte> ages = new ArrayList<>(); |
|
|
|
list.forEach(ageAndSex -> { |
|
|
|
if (ages.isEmpty()) { |
|
|
|
// 添加空白行
|
|
|
|
byte ageLevel = ageAndSex.getAgeLevel(); |
|
|
|
if (ageAndSex.getAgeLevel() > 0) { |
|
|
|
fillBlankRow(groups, ageLevel, 0); |
|
|
|
} |
|
|
|
PatientReportVo.AgeAndSexGroup group = new PatientReportVo.AgeAndSexGroup(); |
|
|
|
group.setAgeLevel(ageLevel + "-" + (ageLevel + 10)); |
|
|
|
fillBySex(ageAndSex, group); |
|
|
|
ages.add(ageAndSex.getAgeLevel()); |
|
|
|
groups.add(group); |
|
|
|
return; |
|
|
|
} |
|
|
|
byte prevAge = ages.get(ages.size() - 1); |
|
|
|
PatientReportVo.AgeAndSexGroup prevGroup = groups.get(groups.size()-1); |
|
|
|
byte nowAge = ageAndSex.getAgeLevel().byteValue(); |
|
|
|
if (prevAge == nowAge) { |
|
|
|
fillBySex(ageAndSex, prevGroup); |
|
|
|
} else { |
|
|
|
// 判断和上一个年龄相比,是否有空白段
|
|
|
|
if (nowAge - prevAge > 10) { |
|
|
|
fillBlankRow(groups, nowAge, prevAge + 10); |
|
|
|
} |
|
|
|
//添加新的
|
|
|
|
PatientReportVo.AgeAndSexGroup group = new PatientReportVo.AgeAndSexGroup(); |
|
|
|
group.setAgeLevel(nowAge + "-" + (nowAge + 10)); |
|
|
|
fillBySex(ageAndSex, group); |
|
|
|
|
|
|
|
ages.add(ageAndSex.getAgeLevel()); |
|
|
|
groups.add(group); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
return groups; |
|
|
|
} |
|
|
|
|
|
|
|
private void fillBlankRow(List<PatientReportVo.AgeAndSexGroup> groups, byte nowAge, int prevAge) { |
|
|
|
int level = 10; |
|
|
|
for (int i = prevAge; i < nowAge; i += level) { |
|
|
|
PatientReportVo.AgeAndSexGroup group = new PatientReportVo.AgeAndSexGroup(); |
|
|
|
group.setAgeLevel(i + "-" + (i + 10)); |
|
|
|
groups.add(group); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void fillBySex(PatientReportVo.AgeAndSex ageAndSex, PatientReportVo.AgeAndSexGroup group) { |
|
|
|
if (ageAndSex.getAgeLevel() == null) { |
|
|
|
log.info("性别不确定"); |
|
|
|
return; |
|
|
|
} else if (ageAndSex.getAgeLevel().byteValue() == Constant.Ht.SEX_MAN) { |
|
|
|
group.setMan(ageAndSex); |
|
|
|
} else { |
|
|
|
group.setWoman(ageAndSex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<PatientReportVo.Day> countByDay(PatientReportDto.Day param, Long userId) { |
|
|
|
return htPatientReportDao.countByDay(param); |
|
|
|
} |
|
|
|
} |
|
|
|