From 3d9a6059301441d7bb0efcfdfc685597ae7e005b Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Fri, 23 Sep 2022 16:56:49 +0800 Subject: [PATCH] =?UTF-8?q?APP=E6=96=B0=E5=A2=9E=E6=82=A3=E8=80=85?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/api/MpController.java | 62 +++++++++++++++--- .../domain/req/AppPatientHospitalDoctor.java | 2 +- .../req/AppletPatientHospitalDoctor.java | 63 +++++++++++++++++++ 3 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppletPatientHospitalDoctor.java 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 ba234aa..4488124 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 @@ -3,26 +3,28 @@ package com.ruoyi.web.controller.api; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.DateUtils; import com.ruoyi.system.domain.TPatientHospitalDoctor; import com.ruoyi.system.domain.TRecord; +import com.ruoyi.system.domain.req.AppletPatientHospitalDoctor; import com.ruoyi.system.domain.resp.PatientHistoryRecordResp; -import com.ruoyi.system.domain.resp.TRecordResp; -import com.ruoyi.system.service.ITImageHistoryService; +import com.ruoyi.system.service.ITPatientHospitalDoctorService; import com.ruoyi.system.service.ITRecordHistoryService; import com.ruoyi.system.service.ITRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Comparator; +import javax.annotation.Resource; +import java.util.Date; import java.util.List; -import java.util.stream.Collectors; @Api("mp接口") @RestController @@ -30,10 +32,12 @@ import java.util.stream.Collectors; public class MpController extends BaseController { @Autowired private ITRecordService tRecordService; + @Autowired private ITRecordHistoryService recordHistoryService; - @Autowired - private ITImageHistoryService imageHistoryService; + + @Resource + private ITPatientHospitalDoctorService itPatientHospitalDoctorService; @ApiOperation("患者诊断记录") @@ -72,4 +76,48 @@ public class MpController extends BaseController { success.put("recordId", tRecord.getId()); return success; } + + /** + * 病人预约 + * + * @param appPatientHospitalDoctor 应用病人医院医生 + * @return {@code AjaxResult} + */ + @ApiOperation("APP患者预约") + @Log(title = "APP患者预约", businessType = BusinessType.INSERT) + @GetMapping("/patient/makeAnAppointment") + public AjaxResult patientsToMakeAnAppointment(AppletPatientHospitalDoctor appPatientHospitalDoctor) + { + // 查询该患者当天是否有预约记录 + TRecord tRecord = new TRecord(); + tRecord.setPatientId(appPatientHospitalDoctor.getPatientId()); + tRecord.setHospitalId(appPatientHospitalDoctor.getHospitalId()); + tRecord.setStatus("0"); + tRecord.setDoctorId(appPatientHospitalDoctor.getDoctorId()); + tRecord.setAppointmentTime(DateUtils.dateTime(new Date())); + List tRecords = tRecordService.selectTRecordList(tRecord); + if (!CollectionUtils.isEmpty(tRecords)) { + AjaxResult ajaxResult = AjaxResult.error(); + ajaxResult.put("msg", "当前患者已登记过信息!"); + return ajaxResult; + } + + // 患者预约,新增t_record中的一条记录;判断关联表是否存在当前关系 + TPatientHospitalDoctor tPatientHospitalDoctor = new TPatientHospitalDoctor(); + BeanUtils.copyProperties(appPatientHospitalDoctor, tPatientHospitalDoctor); + tRecord.setCreateBy(getUsername()); + tRecordService.insertTRecord(tRecord); + List tPHDs = itPatientHospitalDoctorService.selectTPatientHospitalDoctorList(tPatientHospitalDoctor); + if (tPHDs.isEmpty()) + { + itPatientHospitalDoctorService.insertTPatientHospitalDoctor(tPatientHospitalDoctor); + } + TRecord queryRecord = new TRecord(); + queryRecord.setId(tRecord.getId()); + List resp = tRecordService.queryPatientHistoryRecord(queryRecord); + AjaxResult ajaxResult = AjaxResult.success(); + ajaxResult.put("record", CollectionUtils.isEmpty(resp) ? null : resp.get(0)); + ajaxResult.put("msg", "登记成功"); + return ajaxResult; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientHospitalDoctor.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientHospitalDoctor.java index 94f43c7..ea346b5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientHospitalDoctor.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppPatientHospitalDoctor.java @@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; /** - * App端患者预约入参实体 + * 小程序端患者预约入参实体 * * @author gongzhenkun * @date 2022/8/9 14:48 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppletPatientHospitalDoctor.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppletPatientHospitalDoctor.java new file mode 100644 index 0000000..18eb07d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AppletPatientHospitalDoctor.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.domain.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * App端患者预约入参实体 + * + * @author gongzhenkun + * @date 2022/8/9 14:48 + */ +@ApiModel(value = "AppletPatientHospitalDoctor", description = "App端患者预约入参实体") +public class AppletPatientHospitalDoctor implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 医院ID + */ + @NotNull(message = "hospitalId不为空") + @ApiModelProperty("hospitalId") + private Long hospitalId; + + /** + * 医生ID + */ + @NotNull(message = "doctorId不为空") + @ApiModelProperty("doctorId") + private Long doctorId; + + /** + * 患者ID + */ + @NotNull(message = "patientId不为空") + @ApiModelProperty("patientId") + private Long patientId; + + public Long getHospitalId() { + return hospitalId; + } + + public void setHospitalId(Long hospitalId) { + this.hospitalId = hospitalId; + } + + public Long getDoctorId() { + return doctorId; + } + + public void setDoctorId(Long doctorId) { + this.doctorId = doctorId; + } + + public Long getPatientId() { + return patientId; + } + + public void setPatientId(Long patientId) { + this.patientId = patientId; + } +}