更新体检日期
This commit is contained in:
parent
f7b9115929
commit
11ee7c5b9f
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
|
||||
@ -77,6 +78,11 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@Tag(name = "管理后台 - 患者信息")
|
||||
@RestController
|
||||
@RequestMapping("/inspect/patient")
|
||||
@ -1361,22 +1367,71 @@ public class InspectPatientController {
|
||||
}
|
||||
@GetMapping("/getReportUrl")
|
||||
@Operation(summary = "获取患者体检报告URL")
|
||||
public CommonResult<String> getReportUrl(@RequestParam("cardId") String cardId) {
|
||||
public CommonResult<Map<String, Object>> getReportUrl(@RequestParam("cardId") String cardId) {
|
||||
try {
|
||||
// 根据身份证查询患者信息
|
||||
InspectPatientDO patientDO = patientService.getPatientByCardId(cardId);
|
||||
|
||||
// 如果找不到患者记录或者pdfurl为空,返回暂无报告
|
||||
if (patientDO == null || patientDO.getPdfurl() == null || patientDO.getPdfurl().trim().isEmpty()) {
|
||||
// 返回null作为data,并设置msg为"暂无报告"
|
||||
return success(null, "暂无报告");
|
||||
if (patientDO == null) {
|
||||
return CommonResult.error(404, "未找到患者记录");
|
||||
}
|
||||
|
||||
// 返回PDF报告URL到data字段
|
||||
return success(patientDO.getPdfurl(), "成功");
|
||||
if (patientDO.getPdfurl() == null || patientDO.getPdfurl().trim().isEmpty()) {
|
||||
return CommonResult.error(404, "暂无报告");
|
||||
}
|
||||
|
||||
// 提取体检编号的日期部分
|
||||
String pdfUrl = patientDO.getPdfurl();
|
||||
String reportDate = "";
|
||||
String medicalSn = patientDO.getMedicalSn();
|
||||
|
||||
if (medicalSn != null && medicalSn.length() >= 8) {
|
||||
// 提取前8位作为日期
|
||||
reportDate = medicalSn.substring(0, 8);
|
||||
// 转换为yyyy-MM-dd格式
|
||||
if (reportDate.length() == 8) {
|
||||
reportDate = reportDate.substring(0, 4) + "-" + reportDate.substring(4, 6) + "-" + reportDate.substring(6, 8);
|
||||
}
|
||||
} else {
|
||||
// 尝试从URL中提取体检编号
|
||||
int lastSlashIndex = pdfUrl.lastIndexOf('/');
|
||||
if (lastSlashIndex != -1) {
|
||||
String fileName = pdfUrl.substring(lastSlashIndex + 1);
|
||||
int dashIndex = fileName.indexOf('-');
|
||||
if (dashIndex != -1) {
|
||||
String examNo = fileName.substring(0, dashIndex);
|
||||
if (examNo.length() >= 8) {
|
||||
reportDate = examNo.substring(0, 8);
|
||||
// 转换为yyyy-MM-dd格式
|
||||
if (reportDate.length() == 8) {
|
||||
reportDate = reportDate.substring(0, 4) + "-" + reportDate.substring(4, 6) + "-" + reportDate.substring(6, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 构建返回的数据
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("url", pdfUrl);
|
||||
resultMap.put("date", reportDate);
|
||||
resultMap.put("medicalSn", medicalSn);
|
||||
|
||||
// 返回结果
|
||||
return CommonResult.success(resultMap, "成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return success(null, "查询异常:" + e.getMessage());
|
||||
return CommonResult.error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), "查询异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
@PutMapping("/updateMedicalDateTime")
|
||||
@Operation(summary = "更新体检日期")
|
||||
public CommonResult<Boolean> updateMedicalDateTime(@RequestParam("medicalSn") String medicalSn,
|
||||
@RequestParam(value = "medicalDateTime", required = false)
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date medicalDateTime)
|
||||
{
|
||||
patientService.updateMedicalDateTime(medicalSn, medicalDateTime);
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
@ -123,4 +123,13 @@ public interface InspectPatientService {
|
||||
|
||||
//根据身份证号获取患者信息
|
||||
InspectPatientDO getPatientByCardId(String cardId);
|
||||
|
||||
/**
|
||||
* 根据体检编号更新体检日期
|
||||
*
|
||||
* @param medicalSn 体检编号
|
||||
* @param medicalDateTime 体检日期时间
|
||||
*/
|
||||
|
||||
void updateMedicalDateTime(String medicalSn, Date medicalDateTime);
|
||||
}
|
||||
@ -713,4 +713,19 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
queryWrapper.eq(InspectPatientDO::getCardId, cardId);
|
||||
return patientMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMedicalDateTime(String medicalSn, Date medicalDateTime) {
|
||||
// 构建更新条件
|
||||
LambdaUpdateWrapper<InspectPatientDO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(InspectPatientDO::getMedicalSn, medicalSn);
|
||||
|
||||
// 如果medicalDateTime不为null,则设置体检日期
|
||||
if (medicalDateTime != null) {
|
||||
updateWrapper.set(InspectPatientDO::getMedicalDateTime, medicalDateTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
}
|
||||
|
||||
patientMapper.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user