feat: 健康档案功能大屏新增。

This commit is contained in:
tianyongbao
2026-06-20 22:06:25 +08:00
parent 55d55f70a6
commit 09719cbc46
29 changed files with 3412 additions and 105 deletions

View File

@@ -54,12 +54,13 @@
health_mar_record hmr
left join health_medicine_basic hmb on
hmb.id = hmr.medicine_id
left join health_person hp on
hp.id = hmr.person_id
inner join health_person hp on
hp.id = hmr.person_id and hp.del_flag = '0'
left join health_record hr on
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.dosing_time, 'yyyy-MM-dd')
</if>
@@ -92,6 +93,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -112,6 +114,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -133,6 +136,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -155,6 +159,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -180,6 +185,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -204,6 +210,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -225,6 +232,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0' and hmr.temperature>=37
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -241,89 +249,340 @@
<select id="selectStaticPersonList" parameterType="HealthRecordDto" resultType="com.intc.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
coalesce(hr.healthRecordCount, 0) as healthRecordCount,
coalesce(hdr.hospitalCount, 0) as hospitalCount,
coalesce(hdr.doctorTotalCount, 0) as doctorTotalCount,
coalesce(hdr.doctorCount, 0) as doctorCount,
coalesce(hdr.doctorCost, 0) as doctorCost,
coalesce(hmr.marDayCount, 0) as marDayCount,
coalesce(hmr.marCount, 0) as marCount,
coalesce(hmr.marTypeCount, 0) as marTypeCount,
coalesce(htr.feverDayCount, 0) as feverDayCount
from
health_person hp
where 1=1
left join (
select
person_id,
count(*) as healthRecordCount
from health_record
where del_flag = '0'
group by person_id
) hr on hr.person_id = hp.id
left join (
select
person_id,
count(distinct hospital_name) as hospitalCount,
count(distinct doctor) as doctorTotalCount,
count(*) as doctorCount,
coalesce(sum(total_cost), 0) as doctorCost
from health_doctor_record
where del_flag = '0'
group by person_id
) hdr on hdr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(dosing_time, 'yyyy-MM-dd')) as marDayCount,
count(*) as marCount,
count(distinct medicine_id) as marTypeCount
from health_mar_record
where del_flag = '0'
group by person_id
) hmr on hmr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(measure_time, 'yyyy-MM-dd')) as feverDayCount
from health_temperature_record
where del_flag = '0'
and temperature >= 37
group by person_id
) htr on htr.person_id = hp.id
where hp.del_flag = '0'
<if test="personId != null "> and hp.id = #{personId}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by hp.ranking
</select>
<select id="selectHealthScreenDoctorSummary" parameterType="HealthDoctorRecordDto" resultType="java.util.HashMap">
select
count(*) as "doctorCount",
coalesce(sum(a.total_cost), 0) as "doctorCost",
count(distinct a.hospital_name) as "hospitalCount",
count(distinct a.doctor) as "doctorTotalCount"
from health_doctor_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.visiting_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.visiting_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenPersonRankList" parameterType="HealthRecordDto" resultType="com.intc.health.domain.vo.HealthStaticPersonVo">
select
hp."name" as personName,
coalesce(hr.healthRecordCount, 0) as healthRecordCount,
coalesce(hdr.hospitalCount, 0) as hospitalCount,
coalesce(hdr.doctorTotalCount, 0) as doctorTotalCount,
coalesce(hdr.doctorCount, 0) as doctorCount,
coalesce(hdr.doctorCost, 0) as doctorCost,
coalesce(hmr.marDayCount, 0) as marDayCount,
coalesce(hmr.marCount, 0) as marCount,
coalesce(hmr.marTypeCount, 0) as marTypeCount,
coalesce(htr.feverDayCount, 0) as feverDayCount
from health_person hp
left join (
select person_id, count(*) as healthRecordCount
from health_record
where del_flag = '0'
group by person_id
) hr on hr.person_id = hp.id
left join (
select
person_id,
count(distinct hospital_name) as hospitalCount,
count(distinct doctor) as doctorTotalCount,
count(*) as doctorCount,
coalesce(sum(total_cost), 0) as doctorCost
from health_doctor_record
where del_flag = '0'
group by person_id
) hdr on hdr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(dosing_time, 'yyyy-MM-dd')) as marDayCount,
count(*) as marCount,
count(distinct medicine_id) as marTypeCount
from health_mar_record
where del_flag = '0'
group by person_id
) hmr on hmr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(measure_time, 'yyyy-MM-dd')) as feverDayCount
from health_temperature_record
where del_flag = '0'
and temperature >= 37
group by person_id
) htr on htr.person_id = hp.id
where hp.del_flag = '0'
<if test="personId != null "> and hp.id = #{personId}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by
(
least(round(coalesce(htr.feverDayCount, 0) * 1.2), 35)
+ least(round(coalesce(hdr.doctorCount, 0) * 2.5), 30)
+ least(round(coalesce(hmr.marCount, 0) * 0.15), 12)
+ least(coalesce(hr.healthRecordCount, 0) * 2, 10)
+ least(round(coalesce(hdr.doctorCost, 0) / 1000), 13)
) desc,
hp.ranking
limit 12
</select>
<select id="selectHealthScreenMedicineSummary" parameterType="HealthMarRecordDto" resultType="java.util.HashMap">
select
count(*) as "marCount",
count(distinct a.medicine_id) as "medicalTypeCount",
count(distinct to_char(a.dosing_time, 'yyyy-MM-dd')) as "marDayCount"
from health_mar_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.dosing_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.dosing_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null and healthRecordId != ''"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenTemperatureSummary" parameterType="HealthTemperatureRecordDto" resultType="java.util.HashMap">
select
count(*) as "temperatureTotalCount",
count(case when a.temperature &lt; 36.9 then 1 end) as "normalTempCount",
count(case when a.temperature &gt;= 36.9 and a.temperature &lt;= 37.5 then 1 end) as "lowerTempCount",
count(case when a.temperature &gt; 37.5 and a.temperature &lt; 38.5 then 1 end) as "middleTempCount",
count(case when a.temperature &gt;= 38.5 then 1 end) as "higherTempCount",
count(distinct case when a.temperature &gt;= 37 then to_char(a.measure_time, 'yyyy-MM-dd') end) as "feverDayCount"
from health_temperature_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.measure_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.measure_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null "> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenActivitySummary" parameterType="HealthActivityDto" resultType="java.util.HashMap">
select
count(*) as "activityCount",
coalesce(sum(a.total_cost), 0) as "activityCost"
from health_activity a
<where>
a.del_flag = '0'
<if test="endTime != null "> and a.start_time &lt;= #{endTime}</if>
<if test="startTime != null "> and a.start_time &gt;= #{startTime}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenActivityList" parameterType="HealthActivityDto" resultType="com.intc.health.domain.vo.HealthActivityVo">
select
a.id,
a.name,
a.type,
a.place,
a.activity_volume as activityVolume,
a.exercise_time as exerciseTime,
a.start_time as startTime,
a.end_time as endTime,
a.harvest,
a.foods,
a.total_cost as totalCost,
a.partner,
a.cost_detail as costDetail
from health_activity a
<where>
a.del_flag = '0'
<if test="endTime != null "> and a.start_time &lt;= #{endTime}</if>
<if test="startTime != null "> and a.start_time &gt;= #{startTime}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.start_time desc
limit 50
</select>
<select id="selectHealthScreenDoctorList" parameterType="HealthDoctorRecordDto" resultType="com.intc.health.domain.vo.HealthDoctorRecordVo">
select
a.id,
a.hospital_name as hospitalName,
a.departments,
a.doctor,
a.type,
a.health_record_id as healthRecordId,
a.visiting_time as visitingTime,
a.prescribe,
a.diagnosis,
a.person_id as personId,
a.total_cost as totalCost,
hp."name" as personName,
hr."name" as healthRecordName
from health_doctor_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on hr.id = a.health_record_id
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.visiting_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.visiting_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.visiting_time desc
limit 50
</select>
<select id="selectHealthScreenMedicineList" parameterType="HealthMarRecordDto" resultType="com.intc.health.domain.vo.HealthMarRecordVo">
select
a.id,
a.type,
a.health_record_id as healthRecordId,
a.dosing_time as dosingTime,
a.dosage,
a.person_id as personId,
a.resource,
a.place,
a.medicine_id as medicineId,
a.unit,
a.content,
a.content_unit as contentUnit,
hp."name" as personName,
hr."name" as healthRecordName,
hmb.short_name || '-' || hmb.brand || '(' || hmb.packaging || ')' as name
from health_mar_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on hr.id = a.health_record_id
left join health_medicine_basic hmb on hmb.id = a.medicine_id
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.dosing_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.dosing_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null and healthRecordId != ''"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.dosing_time desc
limit 50
</select>
<select id="selectHealthScreenTemperatureList" parameterType="HealthTemperatureRecordDto" resultType="com.intc.health.domain.vo.HealthTemperatureRecordVo">
select
a.id,
a.health_record_id as healthRecordId,
a.measure_time as measureTime,
a.temperature,
a.person_id as personId,
hp."name" as personName,
hr."name" as healthRecordName
from health_temperature_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on hr.id = a.health_record_id
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.measure_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.measure_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null "> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.measure_time desc
limit 1000
</select>
<select id="selectHealthRecordCostList" parameterType="HealthRecordDto" resultType="com.intc.health.domain.vo.HealthRecordVo">
select
(
@@ -344,6 +603,7 @@
health_record hr
<where>
hr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -445,6 +705,7 @@
<where>
hr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -469,6 +730,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -490,6 +752,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -511,6 +774,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -534,6 +798,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.visiting_time, 'yyyy-MM-dd')
</if>
@@ -560,6 +825,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.visiting_time, 'yyyy-MM-dd')
</if>
@@ -585,6 +851,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.visiting_time, 'yyyy-MM-dd')
</if>
@@ -804,6 +1071,7 @@
from
health_milk_powder_record hmpr
where hmpr.del_flag ='0'
and exists (select 1 from health_person hp where hp.id = hmpr.person_id and hp.del_flag = '0')
<if test="personId != null "> and hmpr.person_id = #{personId}</if>
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmpr.suckles_time, 'yyyy-MM-dd')
@@ -820,4 +1088,4 @@
to_char(hmpr.suckles_time,
'yyyy-MM-dd') desc
</select>
</mapper>
</mapper>