fix: 健康管理系统,健康总览接口开发。

This commit is contained in:
tianyongbao
2024-12-18 16:11:17 +08:00
parent 49ba22aab4
commit c63515d274
7 changed files with 365 additions and 140 deletions

View File

@@ -69,6 +69,18 @@ public class HealthPerson extends BaseEntity
@Excel(name = "排序")
private int ranking;
/** 性别 */
@ApiModelProperty(value="性别)")
@NotNull(message="性别不能为空")
@Excel(name = "性别")
private String sex;
/** 身份证 */
@ApiModelProperty(value="身份证)")
@Excel(name = "身份证")
private String identityCard;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -86,6 +98,8 @@ public class HealthPerson extends BaseEntity
.append("height", getHeight())
.append("weight", getWeight())
.append("ranking", getRanking())
.append("sex", getSex())
.append("identityCard", getIdentityCard())
.toString();
}
}

View File

@@ -39,4 +39,8 @@ public class HealthMarRecordVo extends HealthMarRecord
@ApiModelProperty(value="用药天数")
private Integer useDays;
/** 单位名称 */
@ApiModelProperty(value="日期)")
private String dosingTimeStr;
}

View File

@@ -0,0 +1,39 @@
package com.ruoyi.health.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* 成员管理Vo对象 health_person
*
* @author tianyongbao
* @date 2024-09-19
*/
@ApiModel("成员管理Vo对象")
@Data
public class HealthStaticPersonVo
{
private String personName;
private String healthRecordCount;
private String hospitalCount;
private String doctorTotalCount;
private String doctorCount;
private String doctorCost;
private String marDayCount;
private String marCount;
private String feverDayCount;
private String marTypeCount;
}

View File

@@ -4,6 +4,7 @@ import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.health.domain.dto.HealthMarRecordDto;
import com.ruoyi.health.domain.dto.HealthRecordDto;
import com.ruoyi.health.domain.vo.HealthMarRecordVo;
import com.ruoyi.health.domain.vo.HealthStaticPersonVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -44,4 +45,48 @@ public interface StatisticAnalysisMapper {
@DataScope(businessAlias = "hmr")
public int selectDistinctMedicalCount(HealthRecordDto dto);
/**
* 查询用药记录
*
* @param healthMarRecordDto
* @return 收支集合
*/
@DataScope(businessAlias = "hmr")
public List<HealthMarRecordVo> selectMarTypeList(HealthMarRecordDto healthMarRecordDto);
/**
* 查询用药记录
*
* @param healthMarRecordDto
* @return 收支集合
*/
@DataScope(businessAlias = "hmr")
public List<HealthMarRecordVo> selectMarDayCountList(HealthMarRecordDto healthMarRecordDto);
/**
* 查询用药记录
*
* @return 收支集合
*/
@DataScope(businessAlias = "hmr")
public int selectMarDayCount(HealthRecordDto dto);
/**
* 查询用药记录
*
* @return 收支集合
*/
@DataScope(businessAlias = "hmr")
public int selectFeverDayCount(HealthRecordDto dto);
/**
* 查询用药记录
*
* @return 收支集合
*/
@DataScope(businessAlias = "hp")
public List<HealthStaticPersonVo> selectStaticPersonList (HealthRecordDto dto);
}

View File

@@ -3,9 +3,7 @@ package com.ruoyi.health.service.impl;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.DictUtils;
import com.ruoyi.health.domain.dto.*;
import com.ruoyi.health.domain.vo.HealthMarRecordVo;
import com.ruoyi.health.domain.vo.HealthStaticAnalysisVo;
import com.ruoyi.health.domain.vo.HealthTemperatureRecordVo;
import com.ruoyi.health.domain.vo.*;
import com.ruoyi.health.mapper.*;
import com.ruoyi.health.service.IStatisticAnalysisService;
import org.springframework.stereotype.Service;
@@ -91,29 +89,86 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
dto.setStartTime(analysisDto.getStartTime());
dto.setPersonId(analysisDto.getId());
dto.setHealthRecordId(analysisDto.getRecordId());
List<HealthMarRecordVo> marRecordVoList=marRecordMapper.selectHealthMarRecordList(dto);
//用药总次数
map.put("marCount",marRecordVoList.size());
//退烧用药
map.put("tuishao",marRecordVoList.stream().filter(mar -> mar.getType().equals("1")).count());
//抗菌消炎
map.put("kangjun",marRecordVoList.stream().filter(mar -> mar.getType().equals("2")).count());
//止咳平喘化痰
map.put("zhike",marRecordVoList.stream().filter(mar -> mar.getType().equals("3")).count());
//抗病毒
map.put("kangbingdu",marRecordVoList.stream().filter(mar -> mar.getType().equals("4")).count());
//抗过敏
map.put("kangguomin",marRecordVoList.stream().filter(mar -> mar.getType().equals("6")).count());
//雾化消炎
map.put("wuhua",marRecordVoList.stream().filter(mar -> mar.getType().equals("9")).count());
//清热解毒
map.put("qingre",marRecordVoList.stream().filter(mar -> mar.getType().equals("10")).count());
//肠道消化
map.put("changdao",marRecordVoList.stream().filter(mar -> mar.getType().equals("7")).count());
//鼻炎腺样体
map.put("biyan",marRecordVoList.stream().filter(mar -> mar.getType().equals("12")).count());
//增强体质调节免疫力
map.put("mianyili",marRecordVoList.stream().filter(mar -> mar.getType().equals("13")).count());
int marCount=0;
List<HealthMarRecordVo> marTypeList=statisticAnalysisMapper.selectMarTypeList(dto);
for (HealthMarRecordVo vo:marTypeList
){
if (null != vo.getType()) {
vo.setName(DictUtils.getDictLabel("mar_type", vo.getType().toString()));
}else{
vo.setName("未分类");
}
marCount+=vo.getCount();
}
//用药总次数
map.put("marCount",marCount);
if(marTypeList.size()>0){
map.put("top1Name",marTypeList.get(0).getName());
map.put("top1",marTypeList.get(0).getCount());
}
if(marTypeList.size()>1){
map.put("top2Name",marTypeList.get(1).getName());
map.put("top2",marTypeList.get(1).getCount());
}
if(marTypeList.size()>2){
map.put("top3Name",marTypeList.get(2).getName());
map.put("top3",marTypeList.get(2).getCount());
}
if(marTypeList.size()>3){
map.put("top4Name",marTypeList.get(3).getName());
map.put("top4",marTypeList.get(3).getCount());
}
if(marTypeList.size()>4){
map.put("top5Name",marTypeList.get(4).getName());
map.put("top5",marTypeList.get(4).getCount());
}
if(marTypeList.size()>5){
map.put("top6Name",marTypeList.get(5).getName());
map.put("top6",marTypeList.get(5).getCount());
}
if(marTypeList.size()>6){
map.put("top7Name",marTypeList.get(6).getName());
map.put("top7",marTypeList.get(6).getCount());
}
if(marTypeList.size()>7){
map.put("top8Name",marTypeList.get(7).getName());
map.put("top8",marTypeList.get(7).getCount());
}
if(marTypeList.size()>8){
map.put("top9Name",marTypeList.get(8).getName());
map.put("top9",marTypeList.get(8).getCount());
}
if(marTypeList.size()>9){
map.put("top10Name",marTypeList.get(9).getName());
map.put("top10",marTypeList.get(9).getCount());
}
if(marTypeList.size()>10){
map.put("top11Name",marTypeList.get(10).getName());
map.put("top11",marTypeList.get(10).getCount());
}
if(marTypeList.size()>11){
map.put("top12Name",marTypeList.get(11).getName());
map.put("top12",marTypeList.get(11).getCount());
}
if(marTypeList.size()>12){
map.put("top13Name",marTypeList.get(12).getName());
map.put("top13",marTypeList.get(12).getCount());
}
if(marTypeList.size()>13){
map.put("top14Name",marTypeList.get(13).getName());
map.put("top14",marTypeList.get(13).getCount());
}
if(marTypeList.size()>14){
map.put("top15Name",marTypeList.get(14).getName());
map.put("top15",marTypeList.get(14).getCount());
}
if(marTypeList.size()>15){
map.put("top16Name",marTypeList.get(15).getName());
map.put("top16",marTypeList.get(15).getCount());
}
//按药品统计
List<HealthMarRecordVo> marClassList=statisticAnalysisMapper.selectMarRecordList(dto);
@@ -141,123 +196,19 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
//列表
map.put("marMapList",marMapList);
List<HealthMarRecordVo> queryList =new ArrayList<>();
if("1".equals(analysisDto.getType())){
//日列表
List <String> staticsTimeList=new ArrayList<>();
for (HealthMarRecordVo vo:marRecordVoList
) {
if (null != vo.getUnit()) {
vo.setUnitName(DictUtils.getDictLabel("medical_unit", vo.getUnit().toString()));
}
String dayString=dateFormat.format(vo.getDosingTime());
if(!staticsTimeList.contains(dayString)){
staticsTimeList.add(dayString);
}
}
//用药天数
map.put("marDays",staticsTimeList.size());
for (String staticsTime :staticsTimeList
) {
double count=0;
String details="";
for (HealthMarRecordVo vo:marRecordVoList
) {
String dayString=dateFormat.format(vo.getDosingTime());
if(staticsTime.equals(dayString)){
count++;
details+=vo.getPersonName()+""+dateFormatSecond.format(vo.getDosingTime())+"用药【"+vo.getName()+""+vo.getDosage()+vo.getUnitName()+"<br/>";
}
}
HealthMarRecordVo healthMarRecordVo=new HealthMarRecordVo();
healthMarRecordVo.setContent(count);
healthMarRecordVo.setRemark(staticsTime);
healthMarRecordVo.setName(details);
queryList.add(healthMarRecordVo);
}
//年查询
}
else if("2".equals(analysisDto.getType())){
//月列表
List <String> staticsTimeList=new ArrayList<>();
for (HealthMarRecordVo vo:marRecordVoList
) {
String monthString=dateFormat.format(vo.getDosingTime()).substring(0,7);
if(!staticsTimeList.contains(monthString)){
staticsTimeList.add(monthString);
}
}
for (String staticsTime :staticsTimeList
) {
double actualCreditBillMonth=0;
for (HealthMarRecordVo vo:marRecordVoList
) {
String monthString=dateFormat.format(vo.getDosingTime()).substring(0,7);
if(staticsTime.equals(monthString)){
actualCreditBillMonth++;
}
}
HealthMarRecordVo analysisVo=new HealthMarRecordVo();
analysisVo.setContent(actualCreditBillMonth);
analysisVo.setRemark(staticsTime);
queryList.add(analysisVo);
}
//年查询
}else if("3".equals(analysisDto.getType())){
List <String> staticsTimeList=new ArrayList<>();
for (HealthMarRecordVo vo:marRecordVoList
) {
String yearString=dateFormat.format(vo.getDosingTime()).substring(0,4);
if(!staticsTimeList.contains(yearString)){
staticsTimeList.add(yearString);
}
}
for (String staticsTime :staticsTimeList
) {
double actualCreditBillYear=0;
for (HealthMarRecordVo vo:marRecordVoList
) {
String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4);
if(staticsTime.equals(yearString)){
actualCreditBillYear++;
}
}
HealthMarRecordVo analysisVo=new HealthMarRecordVo();
analysisVo.setContent(actualCreditBillYear);
analysisVo.setRemark(staticsTime);
queryList.add(analysisVo);
}
}
List<HealthMarRecordVo> marRecordVoList=statisticAnalysisMapper.selectMarDayCountList(dto);
map.put("marDays",marRecordVoList.size());
ArrayList<Map<String, Object>> marList = new ArrayList<>();
ArrayList<Map<String, Object>> tableMarList = new ArrayList<>();
for (HealthMarRecordVo vo:queryList
for (HealthMarRecordVo vo:marRecordVoList
) {
Map<String, Object> datamap = new HashMap<>();
datamap.put("time", vo.getRemark());
datamap.put("value", decimalFormat.format(vo.getContent()));
datamap.put("detail", vo.getName());
tableMarList.add(datamap);
}
Collections.reverse(queryList);
for (HealthMarRecordVo vo:queryList
) {
Map<String, Object> datamap = new HashMap<>();
datamap.put("time", vo.getRemark());
datamap.put("value", decimalFormat.format(vo.getContent()));
datamap.put("time", vo.getDosingTimeStr());
datamap.put("value", vo.getCount());
marList.add(datamap);
}
//列表
map.put("marList",marList);
map.put("tableMarList",tableMarList);
return map;
}
@@ -429,15 +380,20 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
//健康档案总数
map.put("healthRecordCount",healthRecordMapper.selectHealthRecordList(new HealthRecordDto()).size());
//活动总数
map.put("activityCount",healthActivityMapper.selectHealthActivityList(new HealthActivityDto()).size());
List<HealthActivityVo> activityVoList= healthActivityMapper.selectHealthActivityList(new HealthActivityDto());
map.put("activityCount",activityVoList.size());
map.put("activityCost",activityVoList.stream().mapToDouble(HealthActivityVo::getTotalCost).sum());
//就医总数
map.put("doctorCount",healthDoctorRecordMapper.selectHealthDoctorRecordList(new HealthDoctorRecordDto()).size());
List<HealthDoctorRecordVo> healthDoctorRecordList=healthDoctorRecordMapper.selectHealthDoctorRecordList(new HealthDoctorRecordDto());
map.put("doctorCount",healthDoctorRecordList.size());
map.put("doctorCost",healthDoctorRecordList.stream().mapToDouble(HealthDoctorRecordVo::getTotalCost).sum());
//医院总数
map.put("hospitalCount",statisticAnalysisMapper.selectHospitalCount(new HealthRecordDto()));
//医生总数
map.put("doctorTotalCount",statisticAnalysisMapper.selectDoctorCount(new HealthRecordDto()));
//用药天数
map.put("marDayCount",statisticAnalysisMapper.selectMarDayCount(new HealthRecordDto()));
//用药次数
map.put("marCount",marRecordMapper.selectHealthMarRecordList(new HealthMarRecordDto()).size());
//用药类别
@@ -446,6 +402,11 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
List<HealthTemperatureRecordVo> temperatureRecordVoList=temperatureRecordMapper.selectHealthTemperatureRecordList(new HealthTemperatureRecordDto());
//测量体温次数
map.put("temperatureTotalCount",temperatureRecordVoList.size());
//发烧天数
map.put("feverDayCount",statisticAnalysisMapper.selectFeverDayCount(new HealthRecordDto()));
//成员列表展示
map.put("personList",statisticAnalysisMapper.selectStaticPersonList(new HealthRecordDto()));
//低烧次数
int lowerTempCount=0;
//中烧次数

View File

@@ -19,10 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="height" column="height" />
<result property="weight" column="weight" />
<result property="ranking" column="ranking" />
<result property="sex" column="sex" />
<result property="identityCard" column="identity_card" />
</resultMap>
<sql id="selectHealthPersonVo">
select a.id, a.name, a.type, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark, a.birthday, a.nick_name, a.height, a.weight, a.ranking from health_person a
select a.id, a.name,a.sex,a.identity_card, a.type, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark, a.birthday, a.nick_name, a.height, a.weight, a.ranking from health_person a
</sql>
<select id="selectHealthPersonList" parameterType="HealthPersonDto" resultMap="HealthPersonResult">
@@ -60,6 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="height != null">height,</if>
<if test="weight != null">weight,</if>
<if test="ranking != null">ranking,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="identityCard != null and identityCard != ''">identity_card,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -76,6 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="height != null">#{height},</if>
<if test="weight != null">#{weight},</if>
<if test="ranking != null">#{ranking},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="identityCard != null and identityCard != ''">#{identityCard},</if>
</trim>
</insert>
@@ -95,6 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="height != null">height = #{height},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="ranking != null">ranking = #{ranking},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="identityCard != null and identityCard != ''">identity_card = #{identityCard},</if>
</trim>
where id = #{id}
</update>

View File

@@ -26,7 +26,8 @@
<result property="personName" column="person_name" />
<result property="healthRecordName" column="health_record_name" />
<result property="useDays" column="useDays" />
<result property="count" column="count" />
<result property="dosingTimeStr" column="dosingTimeStr" />
</resultMap>
<select id="selectMarRecordList" parameterType="HealthMarRecordDto" resultMap="HealthMarRecordResult">
select
@@ -112,4 +113,157 @@
${params.dataScope}
</select>
<select id="selectMarTypeList" parameterType="HealthMarRecordDto" resultMap="HealthMarRecordResult">
select
hmr."type" ,
count(hmr."type" ) as count
from
health_mar_record hmr
<where>
hmr.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.dosing_time, 'yyyy-MM-dd')
</if>
<if test="startTime!=null and startTime !=''">
and to_char(hmr.dosing_time, 'yyyy-MM-dd')>=#{startTime}
</if>
<if test="healthRecordId != null and healthRecordId != ''"> and hmr.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and hmr.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
group by
hmr."type"
order by count(hmr."type" ) desc
</select>
<select id="selectMarDayCountList" parameterType="HealthMarRecordDto" resultMap="HealthMarRecordResult">
select
to_char(hmr.dosing_time, 'yyyy-MM-dd') as dosingTimeStr,
count(to_char(hmr.dosing_time, 'yyyy-MM-dd')) as count
from
health_mar_record hmr
<where>
hmr.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.dosing_time, 'yyyy-MM-dd')
</if>
<if test="startTime!=null and startTime !=''">
and to_char(hmr.dosing_time, 'yyyy-MM-dd')>=#{startTime}
</if>
<if test="healthRecordId != null and healthRecordId != ''"> and hmr.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and hmr.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
group by
to_char(hmr.dosing_time, 'yyyy-MM-dd')
order by to_char(hmr.dosing_time, 'yyyy-MM-dd')
</select>
<select id="selectMarDayCount" parameterType="HealthRecordDto" resultType="int">
select
count(distinct to_char(hmr.dosing_time, 'yyyy-MM-dd') )
from
health_mar_record hmr
where 1=1
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectFeverDayCount" parameterType="HealthRecordDto" resultType="int">
select
count(distinct to_char(hmr.measure_time, 'yyyy-MM-dd') )
from
health_temperature_record hmr
where hmr.temperature>=37
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectStaticPersonList" parameterType="HealthRecordDto" resultType="com.ruoyi.health.domain.vo.HealthStaticPersonVo">
select
hp."name" as personName,
(
select
count(*)
from
health_record hr
where
hr.person_id = hp.id
and hr.del_flag = '0') as healthRecordCount,
(
select
count(distinct hdr.hospital_name)
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as hospitalCount,
(
select
count(distinct hdr.doctor)
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as doctorTotalCount,
(
select
count(*)
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as doctorCount,
(
select
case when sum(hdr.total_cost) is null then 0
else sum(hdr.total_cost)
end
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as doctorCost,
(
select
count(distinct to_char(hmr.dosing_time, 'yyyy-MM-dd') )
from
health_mar_record hmr
where
hmr.person_id = hp.id
and hmr.del_flag = '0') as marDayCount,
(
select
count(*)
from
health_mar_record hmr
where
hmr.person_id = hp.id
and hmr.del_flag = '0') as marCount,
(
select
count(distinct hmr."medicine_id")
from
health_mar_record hmr
where
hmr.person_id = hp.id
and hmr.del_flag = '0') as marTypeCount,
(
select
count(distinct to_char(hmr.measure_time, 'yyyy-MM-dd') )
from
health_temperature_record hmr
where
hmr.person_id = hp.id
and hmr.temperature >= 37) as feverDayCount
from
health_person hp
where 1=1
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
</mapper>