diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/controller/HealthMedicationPlanController.java b/intc-modules/intc-health/src/main/java/com/intc/health/controller/HealthMedicationPlanController.java new file mode 100644 index 0000000..bea6b88 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/controller/HealthMedicationPlanController.java @@ -0,0 +1,145 @@ +package com.intc.health.controller; + +import com.intc.common.core.utils.poi.ExcelUtil; +import com.intc.common.core.web.controller.BaseController; +import com.intc.common.core.web.domain.AjaxResult; +import com.intc.common.core.web.page.TableDataInfo; +import com.intc.common.log.annotation.Log; +import com.intc.common.log.enums.BusinessType; +import com.intc.common.security.annotation.RequiresPermissions; +import com.intc.health.domain.HealthMedicationPlan; +import com.intc.health.domain.dto.HealthMedicationPlanDto; +import com.intc.health.domain.vo.HealthMedicationPlanVo; +import com.intc.health.service.IHealthMedicationPlanService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 用药计划Controller + * + * @author intc + * @date 2025-03-18 + */ +@Api(tags = "用药计划") +@RestController +@RequestMapping("/medicationPlan") +public class HealthMedicationPlanController extends BaseController +{ + @Resource + private IHealthMedicationPlanService healthMedicationPlanService; + + /** + * 查询用药计划列表 + */ + @ApiOperation(value = "查询用药计划列表", response = HealthMedicationPlanVo.class) + @RequiresPermissions("health:medicationPlan:list") + @GetMapping("/list") + public TableDataInfo list(HealthMedicationPlanDto dto) + { + startPage(); + List list = healthMedicationPlanService.selectHealthMedicationPlanList(dto); + return getDataTable(list); + } + + /** + * 导出用药计划列表 + */ + @ApiOperation(value = "导出用药计划列表") + @RequiresPermissions("health:medicationPlan:export") + @Log(title = "用药计划", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, HealthMedicationPlanDto dto) + { + List list = healthMedicationPlanService.selectHealthMedicationPlanList(dto); + ExcelUtil util = new ExcelUtil(HealthMedicationPlanVo.class); + util.exportExcel(response, list, "用药计划数据"); + } + + /** + * 获取用药计划详细信息 + */ + @ApiOperation(value = "获取用药计划详细信息") + @RequiresPermissions("health:medicationPlan:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(healthMedicationPlanService.selectHealthMedicationPlanById(id)); + } + + /** + * 新增用药计划 + */ + @ApiOperation(value = "新增用药计划") + @RequiresPermissions("health:medicationPlan:add") + @Log(title = "用药计划", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody HealthMedicationPlan plan) + { + return toAjax(healthMedicationPlanService.insertHealthMedicationPlan(plan)); + } + + /** + * 修改用药计划 + */ + @ApiOperation(value = "修改用药计划") + @RequiresPermissions("health:medicationPlan:edit") + @Log(title = "用药计划", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody HealthMedicationPlan plan) + { + return toAjax(healthMedicationPlanService.updateHealthMedicationPlan(plan)); + } + + /** + * 删除用药计划 + */ + @ApiOperation(value = "删除用药计划") + @RequiresPermissions("health:medicationPlan:remove") + @Log(title = "用药计划", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(healthMedicationPlanService.deleteHealthMedicationPlanByIds(ids)); + } + + /** + * 暂停用药计划 + */ + @ApiOperation(value = "暂停用药计划") + @RequiresPermissions("health:medicationPlan:edit") + @Log(title = "用药计划", businessType = BusinessType.UPDATE) + @PutMapping("/pause/{id}") + public AjaxResult pause(@PathVariable Long id) + { + return toAjax(healthMedicationPlanService.pauseHealthMedicationPlan(id)); + } + + /** + * 恢复用药计划 + */ + @ApiOperation(value = "恢复用药计划") + @RequiresPermissions("health:medicationPlan:edit") + @Log(title = "用药计划", businessType = BusinessType.UPDATE) + @PutMapping("/resume/{id}") + public AjaxResult resume(@PathVariable Long id) + { + return toAjax(healthMedicationPlanService.resumeHealthMedicationPlan(id)); + } + + /** + * 结束用药计划 + */ + @ApiOperation(value = "结束用药计划") + @RequiresPermissions("health:medicationPlan:edit") + @Log(title = "用药计划", businessType = BusinessType.UPDATE) + @PutMapping("/end/{id}") + public AjaxResult end(@PathVariable Long id) + { + return toAjax(healthMedicationPlanService.endHealthMedicationPlan(id)); + } +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/controller/HealthMedicationRecordController.java b/intc-modules/intc-health/src/main/java/com/intc/health/controller/HealthMedicationRecordController.java new file mode 100644 index 0000000..6392cd8 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/controller/HealthMedicationRecordController.java @@ -0,0 +1,160 @@ +package com.intc.health.controller; + +import com.intc.common.core.utils.poi.ExcelUtil; +import com.intc.common.core.web.controller.BaseController; +import com.intc.common.core.web.domain.AjaxResult; +import com.intc.common.core.web.page.TableDataInfo; +import com.intc.common.log.annotation.Log; +import com.intc.common.log.enums.BusinessType; +import com.intc.common.security.annotation.RequiresPermissions; +import com.intc.health.domain.HealthMedicationRecord; +import com.intc.health.domain.dto.HealthMedicationRecordDto; +import com.intc.health.domain.vo.HealthMedicationRecordVo; +import com.intc.health.service.IHealthMedicationRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 用药记录Controller + * + * @author intc + * @date 2025-03-18 + */ +@Api(tags = "用药记录") +@RestController +@RequestMapping("/medicationRecord") +public class HealthMedicationRecordController extends BaseController +{ + @Resource + private IHealthMedicationRecordService healthMedicationRecordService; + + /** + * 查询用药记录列表 + */ + @ApiOperation(value = "查询用药记录列表", response = HealthMedicationRecordVo.class) + @RequiresPermissions("health:medicationRecord:list") + @GetMapping("/list") + public TableDataInfo list(HealthMedicationRecordDto dto) + { + startPage(); + List list = healthMedicationRecordService.selectHealthMedicationRecordList(dto); + return getDataTable(list); + } + + /** + * 查询今日用药记录 + */ + @ApiOperation(value = "查询今日用药记录") + @RequiresPermissions("health:medicationRecord:list") + @GetMapping("/today") + public AjaxResult today(@RequestParam(required = false) Long personId) + { + List list = healthMedicationRecordService.getTodayRecords(personId); + return success(list); + } + + /** + * 查询某计划某天的用药记录 + */ + @ApiOperation(value = "查询某计划某天的用药记录") + @RequiresPermissions("health:medicationRecord:list") + @GetMapping("/plan/{planId}/date/{date}") + public AjaxResult getByPlanAndDate(@PathVariable Long planId, @PathVariable String date) + { + List list = healthMedicationRecordService.selectRecordByPlanAndDate(planId, date); + return success(list); + } + + /** + * 导出用药记录列表 + */ + @ApiOperation(value = "导出用药记录列表") + @RequiresPermissions("health:medicationRecord:export") + @Log(title = "用药记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, HealthMedicationRecordDto dto) + { + List list = healthMedicationRecordService.selectHealthMedicationRecordList(dto); + ExcelUtil util = new ExcelUtil(HealthMedicationRecordVo.class); + util.exportExcel(response, list, "用药记录数据"); + } + + /** + * 获取用药记录详细信息 + */ + @ApiOperation(value = "获取用药记录详细信息") + @RequiresPermissions("health:medicationRecord:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(healthMedicationRecordService.selectHealthMedicationRecordById(id)); + } + + /** + * 新增用药记录(手动记录补服) + */ + @ApiOperation(value = "新增用药记录") + @RequiresPermissions("health:medicationRecord:add") + @Log(title = "用药记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody HealthMedicationRecord record) + { + return toAjax(healthMedicationRecordService.insertHealthMedicationRecord(record)); + } + + /** + * 修改用药记录 + */ + @ApiOperation(value = "修改用药记录") + @RequiresPermissions("health:medicationRecord:edit") + @Log(title = "用药记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody HealthMedicationRecord record) + { + return toAjax(healthMedicationRecordService.updateHealthMedicationRecord(record)); + } + + /** + * 删除用药记录 + */ + @ApiOperation(value = "删除用药记录") + @RequiresPermissions("health:medicationRecord:remove") + @Log(title = "用药记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(healthMedicationRecordService.deleteHealthMedicationRecordByIds(ids)); + } + + /** + * 服药(标记为已服用) + */ + @ApiOperation(value = "服药(标记为已服用)") + @RequiresPermissions("health:medicationRecord:edit") + @Log(title = "用药记录", businessType = BusinessType.UPDATE) + @PutMapping("/take/{id}") + public AjaxResult take(@PathVariable Long id, + @RequestParam(required = false) Double dosage, + @RequestParam(required = false) String remark) + { + return toAjax(healthMedicationRecordService.takeMedication(id, dosage, remark)); + } + + /** + * 跳过服药 + */ + @ApiOperation(value = "跳过服药") + @RequiresPermissions("health:medicationRecord:edit") + @Log(title = "用药记录", businessType = BusinessType.UPDATE) + @PutMapping("/skip/{id}") + public AjaxResult skip(@PathVariable Long id, + @RequestParam(required = false) String remark) + { + return toAjax(healthMedicationRecordService.skipMedication(id, remark)); + } +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/domain/HealthMedicationPlan.java b/intc-modules/intc-health/src/main/java/com/intc/health/domain/HealthMedicationPlan.java new file mode 100644 index 0000000..f0cf9af --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/domain/HealthMedicationPlan.java @@ -0,0 +1,139 @@ +package com.intc.health.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.intc.common.core.annotation.Excel; +import com.intc.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * 用药计划对象 health_medication_plan + * + * @author intc + * @date 2025-03-18 + */ +@ApiModel("用药计划对象") +@Data +public class HealthMedicationPlan extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 人员ID */ + @ApiModelProperty(value="人员ID") + @NotNull(message="人员ID不能为空") + @Excel(name = "人员ID") + private Long personId; + + /** 药品ID */ + @ApiModelProperty(value="药品ID") + @NotNull(message="药品ID不能为空") + @Excel(name = "药品ID") + private Long medicineId; + + /** 入库ID(用于扣减库存) */ + @ApiModelProperty(value="入库ID") + private Long stockInId; + + /** 计划名称 */ + @ApiModelProperty(value="计划名称") + @Excel(name = "计划名称") + private String planName; + + /** 每次剂量 */ + @ApiModelProperty(value="每次剂量") + @NotNull(message="剂量不能为空") + @Excel(name = "每次剂量") + private Double dosage; + + /** 剂量单位 */ + @ApiModelProperty(value="剂量单位") + @Excel(name = "剂量单位") + private String dosageUnit; + + /** 服药频率(每日次数) */ + @ApiModelProperty(value="服药频率") + @NotNull(message="服药频率不能为空") + @Excel(name = "服药频率") + private Integer frequency; + + /** 频率类型(1-每日 2-隔日 3-每周 4-自定义) */ + @ApiModelProperty(value="频率类型") + @Excel(name = "频率类型", readConverterExp = "1=每日,2=隔日,3=每周,4=自定义") + private String frequencyType; + + /** 服药时间点(JSON格式) */ + @ApiModelProperty(value="服药时间点") + private String timePoints; + + /** 周几服药(频率类型为每周时使用,JSON格式如[1,3,5]表示周一三五) */ + @ApiModelProperty(value="周几服药") + private String weekDays; + + /** 开始日期 */ + @ApiModelProperty(value="开始日期") + @NotNull(message="开始日期不能为空") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date startDate; + + /** 结束日期 */ + @ApiModelProperty(value="结束日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date endDate; + + /** 是否启用提醒(0-否 1-是) */ + @ApiModelProperty(value="是否启用提醒") + @Excel(name = "是否启用提醒", readConverterExp = "0=否,1=是") + private String reminderEnabled; + + /** 提前提醒时间(分钟) */ + @ApiModelProperty(value="提前提醒时间") + @Excel(name = "提前提醒时间(分钟)") + private Integer reminderMinutes; + + /** 状态(1-进行中 2-已结束 3-已暂停) */ + @ApiModelProperty(value="状态") + @Excel(name = "状态", readConverterExp = "1=进行中,2=已结束,3=已暂停") + private String status; + + /** 删除标志(0代表存在 1代表删除) */ + private String delFlag; + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("personId", getPersonId()) + .append("medicineId", getMedicineId()) + .append("stockInId", getStockInId()) + .append("planName", getPlanName()) + .append("dosage", getDosage()) + .append("dosageUnit", getDosageUnit()) + .append("frequency", getFrequency()) + .append("frequencyType", getFrequencyType()) + .append("timePoints", getTimePoints()) + .append("weekDays", getWeekDays()) + .append("startDate", getStartDate()) + .append("endDate", getEndDate()) + .append("reminderEnabled", getReminderEnabled()) + .append("reminderMinutes", getReminderMinutes()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("delFlag", getDelFlag()) + .append("remark", getRemark()) + .toString(); + } +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/domain/HealthMedicationRecord.java b/intc-modules/intc-health/src/main/java/com/intc/health/domain/HealthMedicationRecord.java new file mode 100644 index 0000000..190036e --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/domain/HealthMedicationRecord.java @@ -0,0 +1,99 @@ +package com.intc.health.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.intc.common.core.annotation.Excel; +import com.intc.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * 用药记录对象 health_medication_record + * + * @author intc + * @date 2025-03-18 + */ +@ApiModel("用药记录对象") +@Data +public class HealthMedicationRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 计划ID */ + @ApiModelProperty(value="计划ID") + @NotNull(message="计划ID不能为空") + @Excel(name = "计划ID") + private Long planId; + + /** 人员ID */ + @ApiModelProperty(value="人员ID") + @NotNull(message="人员ID不能为空") + @Excel(name = "人员ID") + private Long personId; + + /** 药品ID */ + @ApiModelProperty(value="药品ID") + @NotNull(message="药品ID不能为空") + @Excel(name = "药品ID") + private Long medicineId; + + /** 计划服药时间 */ + @ApiModelProperty(value="计划服药时间") + @NotNull(message="计划服药时间不能为空") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "计划服药时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date scheduledTime; + + /** 实际服药时间 */ + @ApiModelProperty(value="实际服药时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "实际服药时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date actualTime; + + /** 服用剂量 */ + @ApiModelProperty(value="服用剂量") + @Excel(name = "服用剂量") + private Double dosage; + + /** 剂量单位 */ + @ApiModelProperty(value="剂量单位") + @Excel(name = "剂量单位") + private String dosageUnit; + + /** 状态(1-待服用 2-已服用 3-已跳过 4-已过期) */ + @ApiModelProperty(value="状态") + @Excel(name = "状态", readConverterExp = "1=待服用,2=已服用,3=已跳过,4=已过期") + private String status; + + /** 删除标志(0代表存在 1代表删除) */ + private String delFlag; + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("planId", getPlanId()) + .append("personId", getPersonId()) + .append("medicineId", getMedicineId()) + .append("scheduledTime", getScheduledTime()) + .append("actualTime", getActualTime()) + .append("dosage", getDosage()) + .append("dosageUnit", getDosageUnit()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("delFlag", getDelFlag()) + .append("remark", getRemark()) + .toString(); + } +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/domain/dto/HealthMedicationPlanDto.java b/intc-modules/intc-health/src/main/java/com/intc/health/domain/dto/HealthMedicationPlanDto.java new file mode 100644 index 0000000..d9ba52e --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/domain/dto/HealthMedicationPlanDto.java @@ -0,0 +1,69 @@ +package com.intc.health.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 用药计划DTO对象 health_medication_plan + * + * @author intc + * @date 2025-03-18 + */ +@ApiModel("用药计划DTO对象") +@Data +public class HealthMedicationPlanDto +{ + /** 主键 */ + private Long id; + + /** 人员ID */ + @ApiModelProperty(value="人员ID") + private Long personId; + + /** 人员姓名(模糊查询) */ + @ApiModelProperty(value="人员姓名") + private String personName; + + /** 药品ID */ + @ApiModelProperty(value="药品ID") + private Long medicineId; + + /** 计划名称 */ + @ApiModelProperty(value="计划名称") + private String planName; + + /** 频率类型 */ + @ApiModelProperty(value="频率类型") + private String frequencyType; + + /** 状态 */ + @ApiModelProperty(value="状态") + private String status; + + /** 开始日期-起 */ + @ApiModelProperty(value="开始日期-起") + private Date startDateBegin; + + /** 开始日期-止 */ + @ApiModelProperty(value="开始日期-止") + private Date startDateEnd; + + /** 结束日期-起 */ + @ApiModelProperty(value="结束日期-起") + private Date endDateBegin; + + /** 结束日期-止 */ + @ApiModelProperty(value="结束日期-止") + private Date endDateEnd; + + /** 关键字(计划名称、药品名称) */ + @ApiModelProperty(value="关键字") + private String keys; + + /** 分页参数 */ + private Integer pageNum; + private Integer pageSize; +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/domain/dto/HealthMedicationRecordDto.java b/intc-modules/intc-health/src/main/java/com/intc/health/domain/dto/HealthMedicationRecordDto.java new file mode 100644 index 0000000..ed4706c --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/domain/dto/HealthMedicationRecordDto.java @@ -0,0 +1,65 @@ +package com.intc.health.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 用药记录DTO对象 health_medication_record + * + * @author intc + * @date 2025-03-18 + */ +@ApiModel("用药记录DTO对象") +@Data +public class HealthMedicationRecordDto +{ + /** 主键 */ + private Long id; + + /** 计划ID */ + @ApiModelProperty(value="计划ID") + private Long planId; + + /** 人员ID */ + @ApiModelProperty(value="人员ID") + private Long personId; + + /** 人员姓名 */ + @ApiModelProperty(value="人员姓名") + private String personName; + + /** 药品ID */ + @ApiModelProperty(value="药品ID") + private Long medicineId; + + /** 状态 */ + @ApiModelProperty(value="状态") + private String status; + + /** 计划服药时间-起 */ + @ApiModelProperty(value="计划服药时间-起") + private Date scheduledTimeBegin; + + /** 计划服药时间-止 */ + @ApiModelProperty(value="计划服药时间-止") + private Date scheduledTimeEnd; + + /** 实际服药时间-起 */ + @ApiModelProperty(value="实际服药时间-起") + private Date actualTimeBegin; + + /** 实际服药时间-止 */ + @ApiModelProperty(value="实际服药时间-止") + private Date actualTimeEnd; + + /** 日期(按日期查询某天所有记录) */ + @ApiModelProperty(value="日期") + private Date queryDate; + + /** 分页参数 */ + private Integer pageNum; + private Integer pageSize; +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/domain/vo/HealthMedicationPlanVo.java b/intc-modules/intc-health/src/main/java/com/intc/health/domain/vo/HealthMedicationPlanVo.java new file mode 100644 index 0000000..b3fd978 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/domain/vo/HealthMedicationPlanVo.java @@ -0,0 +1,118 @@ +package com.intc.health.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.intc.common.core.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 用药计划VO对象 health_medication_plan + * + * @author intc + * @date 2025-03-18 + */ +@ApiModel("用药计划VO对象") +@Data +public class HealthMedicationPlanVo +{ + /** 主键 */ + private Long id; + + /** 人员ID */ + @Excel(name = "人员ID") + private Long personId; + + /** 人员姓名 */ + @Excel(name = "人员姓名") + private String personName; + + /** 药品ID */ + @Excel(name = "药品ID") + private Long medicineId; + + /** 药品名称 */ + @Excel(name = "药品名称") + private String medicineName; + + /** 药品简称 */ + private String shortName; + + /** 品牌 */ + private String brand; + + /** 包装 */ + private String packaging; + + /** 入库ID */ + private Long stockInId; + + /** 计划名称 */ + @Excel(name = "计划名称") + private String planName; + + /** 每次剂量 */ + @Excel(name = "每次剂量") + private Double dosage; + + /** 剂量单位 */ + @Excel(name = "剂量单位") + private String dosageUnit; + + /** 服药频率 */ + @Excel(name = "服药频率") + private Integer frequency; + + /** 频率类型 */ + @Excel(name = "频率类型") + private String frequencyType; + + /** 服药时间点 */ + private String timePoints; + + /** 周几服药 */ + private String weekDays; + + /** 开始日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date startDate; + + /** 结束日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date endDate; + + /** 是否启用提醒 */ + @Excel(name = "是否启用提醒") + private String reminderEnabled; + + /** 提前提醒时间 */ + @Excel(name = "提前提醒时间(分钟)") + private Integer reminderMinutes; + + /** 状态 */ + @Excel(name = "状态") + private String status; + + /** 备注 */ + private String remark; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 药品简称-品牌(组合显示) */ + private String medicineDisplayName; + + /** 今日已服药次数 */ + private Integer todayTakenCount; + + /** 今日应服药次数 */ + private Integer todayTotalCount; + + /** 剩余库存 */ + private Double stockLeft; +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/domain/vo/HealthMedicationRecordVo.java b/intc-modules/intc-health/src/main/java/com/intc/health/domain/vo/HealthMedicationRecordVo.java new file mode 100644 index 0000000..5fddc71 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/domain/vo/HealthMedicationRecordVo.java @@ -0,0 +1,87 @@ +package com.intc.health.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.intc.common.core.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 用药记录VO对象 health_medication_record + * + * @author intc + * @date 2025-03-18 + */ +@ApiModel("用药记录VO对象") +@Data +public class HealthMedicationRecordVo +{ + /** 主键 */ + private Long id; + + /** 计划ID */ + @Excel(name = "计划ID") + private Long planId; + + /** 人员ID */ + @Excel(name = "人员ID") + private Long personId; + + /** 人员姓名 */ + @Excel(name = "人员姓名") + private String personName; + + /** 药品ID */ + @Excel(name = "药品ID") + private Long medicineId; + + /** 药品名称 */ + @Excel(name = "药品名称") + private String medicineName; + + /** 药品简称 */ + private String shortName; + + /** 品牌 */ + private String brand; + + /** 包装 */ + private String packaging; + + /** 计划服药时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "计划服药时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date scheduledTime; + + /** 实际服药时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "实际服药时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date actualTime; + + /** 服用剂量 */ + @Excel(name = "服用剂量") + private Double dosage; + + /** 剂量单位 */ + @Excel(name = "剂量单位") + private String dosageUnit; + + /** 状态 */ + @Excel(name = "状态") + private String status; + + /** 备注 */ + private String remark; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 药品简称-品牌(组合显示) */ + private String medicineDisplayName; + + /** 计划名称 */ + private String planName; +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/mapper/HealthMedicationPlanMapper.java b/intc-modules/intc-health/src/main/java/com/intc/health/mapper/HealthMedicationPlanMapper.java new file mode 100644 index 0000000..aea7726 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/mapper/HealthMedicationPlanMapper.java @@ -0,0 +1,86 @@ +package com.intc.health.mapper; + +import java.util.List; +import com.intc.health.domain.HealthMedicationPlan; +import com.intc.health.domain.dto.HealthMedicationPlanDto; +import com.intc.health.domain.vo.HealthMedicationPlanVo; + +/** + * 用药计划Mapper接口 + * + * @author intc + * @date 2025-03-18 + */ +public interface HealthMedicationPlanMapper +{ + /** + * 查询用药计划 + * + * @param id 用药计划主键 + * @return 用药计划 + */ + public HealthMedicationPlanVo selectHealthMedicationPlanById(Long id); + + /** + * 查询用药计划列表 + * + * @param dto 用药计划 + * @return 用药计划集合 + */ + public List selectHealthMedicationPlanList(HealthMedicationPlanDto dto); + + /** + * 查询进行中的用药计划列表(用于生成用药记录) + * + * @return 用药计划集合 + */ + public List selectActivePlanList(); + + /** + * 新增用药计划 + * + * @param healthMedicationPlan 用药计划 + * @return 结果 + */ + public int insertHealthMedicationPlan(HealthMedicationPlan healthMedicationPlan); + + /** + * 修改用药计划 + * + * @param healthMedicationPlan 用药计划 + * @return 结果 + */ + public int updateHealthMedicationPlan(HealthMedicationPlan healthMedicationPlan); + + /** + * 删除用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + public int deleteHealthMedicationPlanById(Long id); + + /** + * 批量删除用药计划 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteHealthMedicationPlanByIds(Long[] ids); + + /** + * 逻辑删除用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + public int removeHealthMedicationPlanById(Long id); + + /** + * 批量逻辑删除用药计划 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int removeHealthMedicationPlanByIds(Long[] ids); +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/mapper/HealthMedicationRecordMapper.java b/intc-modules/intc-health/src/main/java/com/intc/health/mapper/HealthMedicationRecordMapper.java new file mode 100644 index 0000000..61042c8 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/mapper/HealthMedicationRecordMapper.java @@ -0,0 +1,106 @@ +package com.intc.health.mapper; + +import java.util.List; +import com.intc.health.domain.HealthMedicationRecord; +import com.intc.health.domain.dto.HealthMedicationRecordDto; +import com.intc.health.domain.vo.HealthMedicationRecordVo; +import org.apache.ibatis.annotations.Param; + +/** + * 用药记录Mapper接口 + * + * @author intc + * @date 2025-03-18 + */ +public interface HealthMedicationRecordMapper +{ + /** + * 查询用药记录 + * + * @param id 用药记录主键 + * @return 用药记录 + */ + public HealthMedicationRecordVo selectHealthMedicationRecordById(Long id); + + /** + * 查询用药记录列表 + * + * @param dto 用药记录 + * @return 用药记录集合 + */ + public List selectHealthMedicationRecordList(HealthMedicationRecordDto dto); + + /** + * 查询某计划某天的用药记录 + * + * @param planId 计划ID + * @param date 日期 + * @return 用药记录集合 + */ + public List selectRecordByPlanAndDate(@Param("planId") Long planId, @Param("date") String date); + + /** + * 统计某计划某天已服药次数 + * + * @param planId 计划ID + * @param date 日期 + * @return 次数 + */ + public int countTakenByPlanAndDate(@Param("planId") Long planId, @Param("date") String date); + + /** + * 新增用药记录 + * + * @param record 用药记录 + * @return 结果 + */ + public int insertHealthMedicationRecord(HealthMedicationRecord record); + + /** + * 批量新增用药记录 + * + * @param records 用药记录列表 + * @return 结果 + */ + public int batchInsertHealthMedicationRecord(List records); + + /** + * 修改用药记录 + * + * @param record 用药记录 + * @return 结果 + */ + public int updateHealthMedicationRecord(HealthMedicationRecord record); + + /** + * 删除用药记录 + * + * @param id 用药记录主键 + * @return 结果 + */ + public int deleteHealthMedicationRecordById(Long id); + + /** + * 批量删除用药记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteHealthMedicationRecordByIds(Long[] ids); + + /** + * 逻辑删除用药记录 + * + * @param id 用药记录主键 + * @return 结果 + */ + public int removeHealthMedicationRecordById(Long id); + + /** + * 批量逻辑删除用药记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int removeHealthMedicationRecordByIds(Long[] ids); +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/service/IHealthMedicationPlanService.java b/intc-modules/intc-health/src/main/java/com/intc/health/service/IHealthMedicationPlanService.java new file mode 100644 index 0000000..7c6aef3 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/service/IHealthMedicationPlanService.java @@ -0,0 +1,87 @@ +package com.intc.health.service; + +import java.util.List; +import com.intc.health.domain.HealthMedicationPlan; +import com.intc.health.domain.dto.HealthMedicationPlanDto; +import com.intc.health.domain.vo.HealthMedicationPlanVo; + +/** + * 用药计划Service接口 + * + * @author intc + * @date 2025-03-18 + */ +public interface IHealthMedicationPlanService +{ + /** + * 查询用药计划 + * + * @param id 用药计划主键 + * @return 用药计划 + */ + public HealthMedicationPlanVo selectHealthMedicationPlanById(Long id); + + /** + * 查询用药计划列表 + * + * @param dto 用药计划 + * @return 用药计划集合 + */ + public List selectHealthMedicationPlanList(HealthMedicationPlanDto dto); + + /** + * 新增用药计划 + * + * @param plan 用药计划 + * @return 结果 + */ + public int insertHealthMedicationPlan(HealthMedicationPlan plan); + + /** + * 修改用药计划 + * + * @param plan 用药计划 + * @return 结果 + */ + public int updateHealthMedicationPlan(HealthMedicationPlan plan); + + /** + * 批量删除用药计划 + * + * @param ids 需要删除的用药计划主键集合 + * @return 结果 + */ + public int deleteHealthMedicationPlanByIds(Long[] ids); + + /** + * 删除用药计划信息 + * + * @param id 用药计划主键 + * @return 结果 + */ + public int deleteHealthMedicationPlanById(Long id); + + /** + * 暂停用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + public int pauseHealthMedicationPlan(Long id); + + /** + * 恢复用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + public int resumeHealthMedicationPlan(Long id); + + /** + * 结束用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + public int endHealthMedicationPlan(Long id); +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/service/IHealthMedicationRecordService.java b/intc-modules/intc-health/src/main/java/com/intc/health/service/IHealthMedicationRecordService.java new file mode 100644 index 0000000..85eff4d --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/service/IHealthMedicationRecordService.java @@ -0,0 +1,108 @@ +package com.intc.health.service; + +import java.util.List; +import com.intc.health.domain.HealthMedicationRecord; +import com.intc.health.domain.dto.HealthMedicationRecordDto; +import com.intc.health.domain.vo.HealthMedicationRecordVo; + +/** + * 用药记录Service接口 + * + * @author intc + * @date 2025-03-18 + */ +public interface IHealthMedicationRecordService +{ + /** + * 查询用药记录 + * + * @param id 用药记录主键 + * @return 用药记录 + */ + public HealthMedicationRecordVo selectHealthMedicationRecordById(Long id); + + /** + * 查询用药记录列表 + * + * @param dto 用药记录 + * @return 用药记录集合 + */ + public List selectHealthMedicationRecordList(HealthMedicationRecordDto dto); + + /** + * 查询某计划某天的用药记录 + * + * @param planId 计划ID + * @param date 日期(yyyy-MM-dd) + * @return 用药记录集合 + */ + public List selectRecordByPlanAndDate(Long planId, String date); + + /** + * 新增用药记录 + * + * @param record 用药记录 + * @return 结果 + */ + public int insertHealthMedicationRecord(HealthMedicationRecord record); + + /** + * 修改用药记录 + * + * @param record 用药记录 + * @return 结果 + */ + public int updateHealthMedicationRecord(HealthMedicationRecord record); + + /** + * 批量删除用药记录 + * + * @param ids 需要删除的用药记录主键集合 + * @return 结果 + */ + public int deleteHealthMedicationRecordByIds(Long[] ids); + + /** + * 删除用药记录信息 + * + * @param id 用药记录主键 + * @return 结果 + */ + public int deleteHealthMedicationRecordById(Long id); + + /** + * 服药(标记为已服用) + * + * @param id 记录ID + * @param dosage 实际服用剂量 + * @param remark 备注 + * @return 结果 + */ + public int takeMedication(Long id, Double dosage, String remark); + + /** + * 跳过服药 + * + * @param id 记录ID + * @param remark 原因 + * @return 结果 + */ + public int skipMedication(Long id, String remark); + + /** + * 获取今日用药记录 + * + * @param personId 人员ID(可选) + * @return 用药记录集合 + */ + public List getTodayRecords(Long personId); + + /** + * 统计某计划某天已服药次数 + * + * @param planId 计划ID + * @param date 日期(yyyy-MM-dd) + * @return 次数 + */ + public int countTakenByPlanAndDate(Long planId, String date); +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/service/impl/HealthMedicationPlanServiceImpl.java b/intc-modules/intc-health/src/main/java/com/intc/health/service/impl/HealthMedicationPlanServiceImpl.java new file mode 100644 index 0000000..f09c5b3 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/service/impl/HealthMedicationPlanServiceImpl.java @@ -0,0 +1,188 @@ +package com.intc.health.service.impl; + +import com.intc.common.core.utils.DateUtils; +import com.intc.common.core.utils.IdWorker; +import com.intc.common.security.utils.SecurityUtils; +import com.intc.health.domain.HealthMedicationPlan; +import com.intc.health.domain.dto.HealthMedicationPlanDto; +import com.intc.health.domain.vo.HealthMedicationPlanVo; +import com.intc.health.mapper.HealthMedicationPlanMapper; +import com.intc.health.mapper.HealthMedicationRecordMapper; +import com.intc.health.service.IHealthMedicationPlanService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.List; + +/** + * 用药计划Service业务层处理 + * + * @author intc + * @date 2025-03-18 + */ +@Service +public class HealthMedicationPlanServiceImpl implements IHealthMedicationPlanService +{ + @Resource + private HealthMedicationPlanMapper healthMedicationPlanMapper; + + @Resource + private HealthMedicationRecordMapper healthMedicationRecordMapper; + + /** + * 查询用药计划 + * + * @param id 用药计划主键 + * @return 用药计划 + */ + @Override + public HealthMedicationPlanVo selectHealthMedicationPlanById(Long id) + { + HealthMedicationPlanVo vo = healthMedicationPlanMapper.selectHealthMedicationPlanById(id); + if (vo != null) { + // 设置药品显示名称 + vo.setMedicineDisplayName(vo.getShortName() + "-" + vo.getBrand() + "(" + vo.getPackaging() + ")"); + // 统计今日服药情况 + String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + int takenCount = healthMedicationRecordMapper.countTakenByPlanAndDate(id, today); + vo.setTodayTakenCount(takenCount); + vo.setTodayTotalCount(vo.getFrequency()); + } + return vo; + } + + /** + * 查询用药计划列表 + * + * @param dto 用药计划 + * @return 用药计划 + */ + @Override + public List selectHealthMedicationPlanList(HealthMedicationPlanDto dto) + { + List list = healthMedicationPlanMapper.selectHealthMedicationPlanList(dto); + String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + for (HealthMedicationPlanVo vo : list) { + // 设置药品显示名称 + vo.setMedicineDisplayName(vo.getShortName() + "-" + vo.getBrand() + "(" + vo.getPackaging() + ")"); + // 统计今日服药情况 + if ("1".equals(vo.getStatus())) { + int takenCount = healthMedicationRecordMapper.countTakenByPlanAndDate(vo.getId(), today); + vo.setTodayTakenCount(takenCount); + vo.setTodayTotalCount(vo.getFrequency()); + } + } + return list; + } + + /** + * 新增用药计划 + * + * @param plan 用药计划 + * @return 结果 + */ + @Override + public int insertHealthMedicationPlan(HealthMedicationPlan plan) + { + plan.setId(IdWorker.getId()); + plan.setCreateBy(SecurityUtils.getUsername()); + plan.setCreateTime(DateUtils.getNowDate()); + plan.setDelFlag("0"); + // 默认状态为进行中 + if (plan.getStatus() == null) { + plan.setStatus("1"); + } + return healthMedicationPlanMapper.insertHealthMedicationPlan(plan); + } + + /** + * 修改用药计划 + * + * @param plan 用药计划 + * @return 结果 + */ + @Override + public int updateHealthMedicationPlan(HealthMedicationPlan plan) + { + plan.setUpdateBy(SecurityUtils.getUsername()); + plan.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationPlanMapper.updateHealthMedicationPlan(plan); + } + + /** + * 批量删除用药计划 + * + * @param ids 需要删除的用药计划主键 + * @return 结果 + */ + @Override + public int deleteHealthMedicationPlanByIds(Long[] ids) + { + return healthMedicationPlanMapper.removeHealthMedicationPlanByIds(ids); + } + + /** + * 删除用药计划信息 + * + * @param id 用药计划主键 + * @return 结果 + */ + @Override + public int deleteHealthMedicationPlanById(Long id) + { + return healthMedicationPlanMapper.removeHealthMedicationPlanById(id); + } + + /** + * 暂停用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + @Override + public int pauseHealthMedicationPlan(Long id) + { + HealthMedicationPlan plan = new HealthMedicationPlan(); + plan.setId(id); + plan.setStatus("3"); // 已暂停 + plan.setUpdateBy(SecurityUtils.getUsername()); + plan.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationPlanMapper.updateHealthMedicationPlan(plan); + } + + /** + * 恢复用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + @Override + public int resumeHealthMedicationPlan(Long id) + { + HealthMedicationPlan plan = new HealthMedicationPlan(); + plan.setId(id); + plan.setStatus("1"); // 进行中 + plan.setUpdateBy(SecurityUtils.getUsername()); + plan.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationPlanMapper.updateHealthMedicationPlan(plan); + } + + /** + * 结束用药计划 + * + * @param id 用药计划主键 + * @return 结果 + */ + @Override + public int endHealthMedicationPlan(Long id) + { + HealthMedicationPlan plan = new HealthMedicationPlan(); + plan.setId(id); + plan.setStatus("2"); // 已结束 + plan.setUpdateBy(SecurityUtils.getUsername()); + plan.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationPlanMapper.updateHealthMedicationPlan(plan); + } +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/java/com/intc/health/service/impl/HealthMedicationRecordServiceImpl.java b/intc-modules/intc-health/src/main/java/com/intc/health/service/impl/HealthMedicationRecordServiceImpl.java new file mode 100644 index 0000000..0e7e713 --- /dev/null +++ b/intc-modules/intc-health/src/main/java/com/intc/health/service/impl/HealthMedicationRecordServiceImpl.java @@ -0,0 +1,214 @@ +package com.intc.health.service.impl; + +import com.intc.common.core.utils.DateUtils; +import com.intc.common.core.utils.IdWorker; +import com.intc.common.security.utils.SecurityUtils; +import com.intc.health.domain.HealthMedicationRecord; +import com.intc.health.domain.dto.HealthMedicationRecordDto; +import com.intc.health.domain.vo.HealthMedicationRecordVo; +import com.intc.health.mapper.HealthMedicationRecordMapper; +import com.intc.health.service.IHealthMedicationRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.List; + +/** + * 用药记录Service业务层处理 + * + * @author intc + * @date 2025-03-18 + */ +@Service +public class HealthMedicationRecordServiceImpl implements IHealthMedicationRecordService +{ + @Resource + private HealthMedicationRecordMapper healthMedicationRecordMapper; + + /** + * 查询用药记录 + * + * @param id 用药记录主键 + * @return 用药记录 + */ + @Override + public HealthMedicationRecordVo selectHealthMedicationRecordById(Long id) + { + HealthMedicationRecordVo vo = healthMedicationRecordMapper.selectHealthMedicationRecordById(id); + if (vo != null) { + vo.setMedicineDisplayName(vo.getShortName() + "-" + vo.getBrand() + "(" + vo.getPackaging() + ")"); + } + return vo; + } + + /** + * 查询用药记录列表 + * + * @param dto 用药记录 + * @return 用药记录 + */ + @Override + public List selectHealthMedicationRecordList(HealthMedicationRecordDto dto) + { + List list = healthMedicationRecordMapper.selectHealthMedicationRecordList(dto); + for (HealthMedicationRecordVo vo : list) { + vo.setMedicineDisplayName(vo.getShortName() + "-" + vo.getBrand() + "(" + vo.getPackaging() + ")"); + } + return list; + } + + /** + * 查询某计划某天的用药记录 + * + * @param planId 计划ID + * @param date 日期(yyyy-MM-dd) + * @return 用药记录集合 + */ + @Override + public List selectRecordByPlanAndDate(Long planId, String date) + { + List list = healthMedicationRecordMapper.selectRecordByPlanAndDate(planId, date); + for (HealthMedicationRecordVo vo : list) { + vo.setMedicineDisplayName(vo.getShortName() + "-" + vo.getBrand() + "(" + vo.getPackaging() + ")"); + } + return list; + } + + /** + * 新增用药记录 + * + * @param record 用药记录 + * @return 结果 + */ + @Override + public int insertHealthMedicationRecord(HealthMedicationRecord record) + { + record.setId(IdWorker.getId()); + record.setCreateBy(SecurityUtils.getUsername()); + record.setCreateTime(DateUtils.getNowDate()); + record.setDelFlag("0"); + // 默认状态为待服用 + if (record.getStatus() == null) { + record.setStatus("1"); + } + return healthMedicationRecordMapper.insertHealthMedicationRecord(record); + } + + /** + * 修改用药记录 + * + * @param record 用药记录 + * @return 结果 + */ + @Override + public int updateHealthMedicationRecord(HealthMedicationRecord record) + { + record.setUpdateBy(SecurityUtils.getUsername()); + record.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationRecordMapper.updateHealthMedicationRecord(record); + } + + /** + * 批量删除用药记录 + * + * @param ids 需要删除的用药记录主键 + * @return 结果 + */ + @Override + public int deleteHealthMedicationRecordByIds(Long[] ids) + { + return healthMedicationRecordMapper.removeHealthMedicationRecordByIds(ids); + } + + /** + * 删除用药记录信息 + * + * @param id 用药记录主键 + * @return 结果 + */ + @Override + public int deleteHealthMedicationRecordById(Long id) + { + return healthMedicationRecordMapper.removeHealthMedicationRecordById(id); + } + + /** + * 服药(标记为已服用) + * + * @param id 记录ID + * @param dosage 实际服用剂量 + * @param remark 备注 + * @return 结果 + */ + @Override + public int takeMedication(Long id, Double dosage, String remark) + { + HealthMedicationRecord record = new HealthMedicationRecord(); + record.setId(id); + record.setStatus("2"); // 已服用 + record.setActualTime(new Date()); + if (dosage != null) { + record.setDosage(dosage); + } + if (remark != null) { + record.setRemark(remark); + } + record.setUpdateBy(SecurityUtils.getUsername()); + record.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationRecordMapper.updateHealthMedicationRecord(record); + } + + /** + * 跳过服药 + * + * @param id 记录ID + * @param remark 原因 + * @return 结果 + */ + @Override + public int skipMedication(Long id, String remark) + { + HealthMedicationRecord record = new HealthMedicationRecord(); + record.setId(id); + record.setStatus("3"); // 已跳过 + if (remark != null) { + record.setRemark(remark); + } + record.setUpdateBy(SecurityUtils.getUsername()); + record.setUpdateTime(DateUtils.getNowDate()); + return healthMedicationRecordMapper.updateHealthMedicationRecord(record); + } + + /** + * 获取今日用药记录 + * + * @param personId 人员ID(可选) + * @return 用药记录集合 + */ + @Override + public List getTodayRecords(Long personId) + { + HealthMedicationRecordDto dto = new HealthMedicationRecordDto(); + dto.setQueryDate(new Date()); + if (personId != null) { + dto.setPersonId(personId); + } + return selectHealthMedicationRecordList(dto); + } + + /** + * 统计某计划某天已服药次数 + * + * @param planId 计划ID + * @param date 日期(yyyy-MM-dd) + * @return 次数 + */ + @Override + public int countTakenByPlanAndDate(Long planId, String date) + { + return healthMedicationRecordMapper.countTakenByPlanAndDate(planId, date); + } +} \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/resources/mapper/health/HealthMedicationPlanMapper.xml b/intc-modules/intc-health/src/main/resources/mapper/health/HealthMedicationPlanMapper.xml new file mode 100644 index 0000000..ed091c4 --- /dev/null +++ b/intc-modules/intc-health/src/main/resources/mapper/health/HealthMedicationPlanMapper.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + a.id, + a.person_id, + p.name as person_name, + a.medicine_id, + m.name as medicine_name, + m.short_name, + m.brand, + m.packaging, + a.stock_in_id, + a.plan_name, + a.dosage, + a.dosage_unit, + a.frequency, + a.frequency_type, + a.time_points, + a.week_days, + a.start_date, + a.end_date, + a.reminder_enabled, + a.reminder_minutes, + a.status, + a.remark, + a.create_time + from + health_medication_plan a + left join health_person p on a.person_id = p.id + left join health_medicine_basic m on a.medicine_id = m.id + + + + + + + + + + insert into health_medication_plan + + id, + person_id, + medicine_id, + stock_in_id, + plan_name, + dosage, + dosage_unit, + frequency, + frequency_type, + time_points, + week_days, + start_date, + end_date, + reminder_enabled, + reminder_minutes, + status, + create_by, + create_time, + del_flag, + remark, + + + #{id}, + #{personId}, + #{medicineId}, + #{stockInId}, + #{planName}, + #{dosage}, + #{dosageUnit}, + #{frequency}, + #{frequencyType}, + #{timePoints}, + #{weekDays}, + #{startDate}, + #{endDate}, + #{reminderEnabled}, + #{reminderMinutes}, + #{status}, + #{createBy}, + #{createTime}, + #{delFlag}, + #{remark}, + + + + + update health_medication_plan + + person_id = #{personId}, + medicine_id = #{medicineId}, + stock_in_id = #{stockInId}, + plan_name = #{planName}, + dosage = #{dosage}, + dosage_unit = #{dosageUnit}, + frequency = #{frequency}, + frequency_type = #{frequencyType}, + time_points = #{timePoints}, + week_days = #{weekDays}, + start_date = #{startDate}, + end_date = #{endDate}, + reminder_enabled = #{reminderEnabled}, + reminder_minutes = #{reminderMinutes}, + status = #{status}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + remark = #{remark}, + + where id = #{id} + + + + delete from health_medication_plan where id = #{id} + + + + delete from health_medication_plan where id in + + #{id} + + + + + update health_medication_plan set del_flag='1' where id = #{id} + + + + update health_medication_plan set del_flag='1' where id in + + #{id} + + + \ No newline at end of file diff --git a/intc-modules/intc-health/src/main/resources/mapper/health/HealthMedicationRecordMapper.xml b/intc-modules/intc-health/src/main/resources/mapper/health/HealthMedicationRecordMapper.xml new file mode 100644 index 0000000..89b6b6f --- /dev/null +++ b/intc-modules/intc-health/src/main/resources/mapper/health/HealthMedicationRecordMapper.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select + a.id, + a.plan_id, + a.person_id, + p.name as person_name, + a.medicine_id, + m.name as medicine_name, + m.short_name, + m.brand, + m.packaging, + a.scheduled_time, + a.actual_time, + a.dosage, + a.dosage_unit, + a.status, + a.remark, + a.create_time, + pl.plan_name + from + health_medication_record a + left join health_person p on a.person_id = p.id + left join health_medicine_basic m on a.medicine_id = m.id + left join health_medication_plan pl on a.plan_id = pl.id + + + + + + + + + + + + insert into health_medication_record + + id, + plan_id, + person_id, + medicine_id, + scheduled_time, + actual_time, + dosage, + dosage_unit, + status, + create_by, + create_time, + del_flag, + remark, + + + #{id}, + #{planId}, + #{personId}, + #{medicineId}, + #{scheduledTime}, + #{actualTime}, + #{dosage}, + #{dosageUnit}, + #{status}, + #{createBy}, + #{createTime}, + #{delFlag}, + #{remark}, + + + + + insert into health_medication_record (id, plan_id, person_id, medicine_id, scheduled_time, dosage, dosage_unit, status, create_time, del_flag) + values + + (#{item.id}, #{item.planId}, #{item.personId}, #{item.medicineId}, #{item.scheduledTime}, #{item.dosage}, #{item.dosageUnit}, #{item.status}, #{item.createTime}, '0') + + + + + update health_medication_record + + plan_id = #{planId}, + person_id = #{personId}, + medicine_id = #{medicineId}, + scheduled_time = #{scheduledTime}, + actual_time = #{actualTime}, + dosage = #{dosage}, + dosage_unit = #{dosageUnit}, + status = #{status}, + update_by = #{updateBy}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + remark = #{remark}, + + where id = #{id} + + + + delete from health_medication_record where id = #{id} + + + + delete from health_medication_record where id in + + #{id} + + + + + update health_medication_record set del_flag='1' where id = #{id} + + + + update health_medication_record set del_flag='1' where id in + + #{id} + + + \ No newline at end of file diff --git a/sql/medication.sql b/sql/medication.sql new file mode 100644 index 0000000..896f87c --- /dev/null +++ b/sql/medication.sql @@ -0,0 +1,128 @@ +-- ---------------------------- +-- 用药计划表 +-- ---------------------------- +DROP TABLE IF EXISTS health_medication_plan; +CREATE TABLE health_medication_plan ( + id BIGINT NOT NULL, + person_id BIGINT NOT NULL, + medicine_id BIGINT NOT NULL, + stock_in_id BIGINT NULL, + plan_name VARCHAR(200) NULL, + dosage DECIMAL(10,2) NOT NULL, + dosage_unit VARCHAR(20) NULL, + frequency INT NOT NULL, + frequency_type CHAR(1) DEFAULT '1', + time_points VARCHAR(500) NULL, + week_days VARCHAR(50) NULL, + start_date DATE NOT NULL, + end_date DATE NULL, + reminder_enabled CHAR(1) DEFAULT '0', + reminder_minutes INT DEFAULT 15, + status CHAR(1) DEFAULT '1', + del_flag CHAR(1) DEFAULT '0', + create_by VARCHAR(64) DEFAULT '', + create_time DATETIME NULL, + update_by VARCHAR(64) DEFAULT '', + update_time DATETIME NULL, + remark VARCHAR(500) NULL, + PRIMARY KEY (id) +) ENGINE=InnoDB COMMENT='用药计划表'; + +CREATE INDEX idx_person_id ON health_medication_plan(person_id); +CREATE INDEX idx_medicine_id ON health_medication_plan(medicine_id); +CREATE INDEX idx_status ON health_medication_plan(status); +CREATE INDEX idx_start_date ON health_medication_plan(start_date); + +-- ---------------------------- +-- 用药记录表 +-- ---------------------------- +DROP TABLE IF EXISTS health_medication_record; +CREATE TABLE health_medication_record ( + id BIGINT NOT NULL, + plan_id BIGINT NOT NULL, + person_id BIGINT NOT NULL, + medicine_id BIGINT NOT NULL, + scheduled_time DATETIME NOT NULL, + actual_time DATETIME NULL, + dosage DECIMAL(10,2) NULL, + dosage_unit VARCHAR(20) NULL, + status CHAR(1) DEFAULT '1', + del_flag CHAR(1) DEFAULT '0', + create_by VARCHAR(64) DEFAULT '', + create_time DATETIME NULL, + update_by VARCHAR(64) DEFAULT '', + update_time DATETIME NULL, + remark VARCHAR(500) NULL, + PRIMARY KEY (id) +) ENGINE=InnoDB COMMENT='用药记录表'; + +CREATE INDEX idx_plan_id ON health_medication_record(plan_id); +CREATE INDEX idx_person_id ON health_medication_record(person_id); +CREATE INDEX idx_scheduled_time ON health_medication_record(scheduled_time); +CREATE INDEX idx_status ON health_medication_record(status); + +-- ---------------------------- +-- 字典数据 +-- ---------------------------- +INSERT INTO sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, remark) +VALUES +(nextval('seq_sys_dict_type'), '用药频率类型', 'medication_frequency_type', '0', 'admin', NOW(), '用药频率类型字典'), +(nextval('seq_sys_dict_type'), '用药计划状态', 'medication_plan_status', '0', 'admin', NOW(), '用药计划状态字典'), +(nextval('seq_sys_dict_type'), '用药记录状态', 'medication_record_status', '0', 'admin', NOW(), '用药记录状态字典'); + +INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) +VALUES +(nextval('seq_sys_dict_data'), 1, '每日', '1', 'medication_frequency_type', '', 'primary', 'Y', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 2, '隔日', '2', 'medication_frequency_type', '', 'success', 'N', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 3, '每周', '3', 'medication_frequency_type', '', 'info', 'N', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 4, '自定义', '4', 'medication_frequency_type', '', 'warning', 'N', '0', 'admin', NOW(), NULL); + +INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) +VALUES +(nextval('seq_sys_dict_data'), 1, '进行中', '1', 'medication_plan_status', '', 'primary', 'Y', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 2, '已结束', '2', 'medication_plan_status', '', 'info', 'N', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 3, '已暂停', '3', 'medication_plan_status', '', 'warning', 'N', '0', 'admin', NOW(), NULL); + +INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) +VALUES +(nextval('seq_sys_dict_data'), 1, '待服用', '1', 'medication_record_status', '', 'warning', 'Y', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 2, '已服用', '2', 'medication_record_status', '', 'success', 'N', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 3, '已跳过', '3', 'medication_record_status', '', 'info', 'N', '0', 'admin', NOW(), NULL), +(nextval('seq_sys_dict_data'), 4, '已过期', '4', 'medication_record_status', '', 'danger', 'N', '0', 'admin', NOW(), NULL); + +-- ---------------------------- +-- 菜单权限 +-- ---------------------------- +-- 用药计划菜单 +INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) +VALUES +(nextval('seq_sys_menu'), '用药计划', (SELECT menu_id FROM sys_menu WHERE menu_name = '健康管理' LIMIT 1), 10, 'medicationPlan', 'health/medicationPlan/index', NULL, 1, 0, 'C', '0', '0', 'health:medicationPlan:list', 'calendar', 'admin', NOW(), '用药计划菜单'); + +-- 用药计划按钮权限 +INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) +SELECT nextval('seq_sys_menu'), '用药计划查询', m.menu_id, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationPlan:query', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationPlan:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药计划新增', m.menu_id, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationPlan:add', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationPlan:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药计划修改', m.menu_id, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationPlan:edit', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationPlan:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药计划删除', m.menu_id, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationPlan:remove', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationPlan:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药计划导出', m.menu_id, 5, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationPlan:export', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationPlan:list'; + +-- 用药记录菜单 +INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) +VALUES +(nextval('seq_sys_menu'), '用药记录', (SELECT menu_id FROM sys_menu WHERE menu_name = '健康管理' LIMIT 1), 11, 'medicationRecord', 'health/medicationRecord/index', NULL, 1, 0, 'C', '0', '0', 'health:medicationRecord:list', 'log', 'admin', NOW(), '用药记录菜单'); + +-- 用药记录按钮权限 +INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) +SELECT nextval('seq_sys_menu'), '用药记录查询', m.menu_id, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationRecord:query', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationRecord:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药记录新增', m.menu_id, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationRecord:add', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationRecord:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药记录修改', m.menu_id, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationRecord:edit', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationRecord:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药记录删除', m.menu_id, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationRecord:remove', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationRecord:list' +UNION ALL +SELECT nextval('seq_sys_menu'), '用药记录导出', m.menu_id, 5, '', NULL, NULL, 1, 0, 'F', '0', '0', 'health:medicationRecord:export', '#', 'admin', NOW(), '' FROM sys_menu m WHERE m.perms = 'health:medicationRecord:list'; \ No newline at end of file