From e906ed826df720b878c3a101e6b057c1aa662c84 Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Tue, 8 Nov 2022 09:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=8A=E6=96=AD=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9B=E6=82=A3=E8=80=85=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/api/AppController.java | 40 ++++++++++++---- .../web/controller/api/MpController.java | 34 ++++++++++++++ .../system/domain/req/AppPatientRecord.java | 47 +++++++++++++++++++ 3 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientRecord.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index 5c6f5b5..cf63389 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -237,14 +237,7 @@ public class AppController extends BaseController if (Objects.nonNull(currentPatient)) { //患者信息已存在 新增诊断记录 - TRecord tRecord = new TRecord(); - tRecord.setHospitalId(appPatientReq.getHospitalId()); - tRecord.setPatientId(currentPatient.getId()); - tRecord.setDoctorId(appPatientReq.getDoctorId()); - tRecord.setStatus("0"); - tRecord.setCreateBy(getUsername()); - tRecordService.insertTRecord(tRecord); - return AjaxResult.success("手机号已注册"); + return insertRecord(appPatientReq, currentPatient); } tPatientService.insertTPatient(tPatient); Long identifier = 10000000L + tPatient.getId(); @@ -277,6 +270,35 @@ public class AppController extends BaseController return AjaxResult.success(); } + /** + * 插入记录 + * + * @param appPatientReq 应用病人要求事情 + * @param currentPatient 当前病人 + * @return {@code AjaxResult} + */ + private AjaxResult insertRecord(AppPatientReq appPatientReq, TPatient currentPatient) { + TRecord tRecord = new TRecord(); + tRecord.setHospitalId(appPatientReq.getHospitalId()); + tRecord.setPatientId(currentPatient.getId()); + tRecord.setDoctorId(appPatientReq.getDoctorId()); + tRecord.setCreateBy(getUsername()); + if (whetherRegistration(tRecord, "0") || whetherRegistration(tRecord, "2") || whetherRegistration(tRecord, "3")) { + AjaxResult ajaxResult = AjaxResult.error(); + ajaxResult.put("msg", "当前患者已登记过信息!"); + return ajaxResult; + } + tRecord.setStatus("0"); + tRecordService.insertTRecord(tRecord); + return AjaxResult.success("手机号已注册"); + } + + private Boolean whetherRegistration(TRecord tRecord, String status) { + tRecord.setStatus(status); + List tRecords = tRecordService.selectTRecordList(tRecord); + return !CollectionUtils.isEmpty(tRecords); + } + /** * 修改患者 * @@ -451,7 +473,7 @@ public class AppController extends BaseController // AI接口异常,需要重置当前记录状态 updateRecordStatus(recordId, "0"); logger.error("AI result exception, msg is {}", e.getMessage()); - return AjaxResult.error("AI result exception, please try again!"); + return AjaxResult.error("AI result exception, message is {}", e.getMessage()); } if (StringUtils.isEmpty(result)) { // AI接口非正常返回,需要重置当前记录状态 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/MpController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/MpController.java index b4229f1..f6ea192 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/MpController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/MpController.java @@ -5,11 +5,14 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.domain.TPatient; import com.ruoyi.system.domain.TPatientHospitalDoctor; import com.ruoyi.system.domain.TRecord; +import com.ruoyi.system.domain.req.AppPatientRecord; import com.ruoyi.system.domain.req.AppletPatientHospitalDoctor; import com.ruoyi.system.domain.resp.PatientHistoryRecordResp; import com.ruoyi.system.service.ITPatientHospitalDoctorService; +import com.ruoyi.system.service.ITPatientService; import com.ruoyi.system.service.ITRecordHistoryService; import com.ruoyi.system.service.ITRecordService; import io.swagger.annotations.Api; @@ -23,8 +26,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.Comparator; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Api("mp接口") @RestController @@ -39,6 +44,9 @@ public class MpController extends BaseController { @Resource private ITPatientHospitalDoctorService itPatientHospitalDoctorService; + @Resource + private ITPatientService patientService; + @ApiOperation("患者诊断记录") @GetMapping("/patient/history/record") @@ -124,4 +132,30 @@ public class MpController extends BaseController { List tRecords = tRecordService.selectTRecordList(tRecord); return !CollectionUtils.isEmpty(tRecords); } + + @ApiOperation("APP查询记录状态") + @Log(title = "APP查询记录状态", businessType = BusinessType.OTHER) + @GetMapping("/record/status") + public AjaxResult queryRecordState(AppPatientRecord appPatientHospitalDoctor){ + AjaxResult ajaxResult = AjaxResult.success(); + TPatient tPatient = new TPatient(); + tPatient.setName(appPatientHospitalDoctor.getName()); + tPatient.setPhone(appPatientHospitalDoctor.getPhone()); + List tPatients = patientService.selectTPatientList(tPatient); + if (tPatients.isEmpty()) { + ajaxResult.put("status", null); + } + // 查询该患者当天是否有预约记录 + TRecord tRecord = new TRecord(); + tRecord.setPatientId(tPatients.get(0).getId()); + tRecord.setHospitalId(appPatientHospitalDoctor.getHospitalId()); + tRecord.setDoctorId(appPatientHospitalDoctor.getDoctorId()); + tRecord.setAppointmentTime(DateUtils.dateTime(new Date())); + List tRecords = tRecordService.selectTRecordList(tRecord); + tRecords = tRecords.stream() + .sorted(Comparator.comparing(TRecord::getUploadTime, Comparator.nullsLast(Date::compareTo)).reversed()) + .collect(Collectors.toList()); + ajaxResult.put("status", tRecords.get(0).getStatus()); + return ajaxResult; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientRecord.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientRecord.java new file mode 100644 index 0000000..9464db9 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientRecord.java @@ -0,0 +1,47 @@ +package com.ruoyi.system.domain.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotNull; + +/** + * 患者新增时查询记录入参实体 + * + * @author gongzhenkun + * @date 2022/11/7 16:50 + */ +@ApiModel(value = "AppPatientRecord", description = "患者新增时查询记录入参实体") +public class AppPatientRecord extends AppPatientHospitalDoctor{ + + /** + * 患者名称 + */ + @NotNull(message = "患者名称不为空") + @ApiModelProperty("患者名称") + private String name; + + + /** + * 手机号 + */ + @NotNull(message = "手机号不为空") + @ApiModelProperty("手机号") + private String phone; + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}