Files
pasd_java/pasd-healthcare/target/classes/com/ruoyi/os/mapper/OsStatisticsMapper.xml

313 lines
16 KiB
XML
Raw Normal View History

2025-07-28 14:58:32 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.os.mapper.OsStatisticsMapper">
<!-- 复用 -->
<resultMap type="PatientMedicalRecordsVO" id="PatientMedicalRecordsVOResult">
<!-- 患者信息 -->
<!-- 患者 类型 ( 显示 ) -->
<result property="patientTypeLabel" column="opi_st_patient_type" />
<!-- 学号/工号 -->
<result property="studentId" column="opi_student_id" />
<!-- 姓名 -->
<result property="name" column="opi_name" />
<!-- 性别 ( 显示 ) -->
<result property="genderLabel" column="opi_st_gender" />
<!-- 年龄 -->
<result property="age" column="opi_age" />
<!-- 专业 -->
<result property="major" column="opi_major" />
<!-- 班级 -->
<result property="classInfo" column="opi_class_info" />
<!-- 电话 -->
<result property="phone" column="opi_phone" />
<!-- 辅导员 -->
<result property="counselor" column="opi_counselor" />
<!-- 部门 -->
<result property="department" column="opi_department" />
<!-- 以下为患者诊断信息 -->
<!-- 诊断id -->
<result property="patientDiagnosisId" column="ho_pd_id" />
<!-- 患者 id -->
<result property="patientId" column="ho_pd_patient_id" />
<!-- 诊断类型 -->
<result property="diagnosisType" column="ho_pd_diagnosis_type" />
<!-- 是否医保 ( 显示 ) -->
<result property="isInsuredLabel" column="ho_pd_st_is_insured" />
<!-- 数值 -->
<result property="value" column="ho_pd_value" />
<!-- 主诉 -->
<result property="chiefComplaint" column="ho_pd_chief_complaint" />
<!-- 现病史 -->
<result property="presentIllness" column="ho_pd_present_illness" />
<!-- 既往史 -->
<result property="pastHistory" column="ho_pd_past_history" />
<!-- 诊断 -->
<result property="diagnosis" column="ho_pd_diagnosis" />
<!-- 医嘱事项 -->
<result property="medicalAdvice" column="ho_pd_medical_advice" />
<!-- 医生名字 -->
<result property="doctorName" column="ho_pd_doctor_name" />
<!-- 状态 ( 显示 ) -->
<result property="statusLabel" column="ho_pd_st_status" />
<!-- 就诊时间 -->
<result property="outpatientTime" column="ho_pd_outpatient_time" />
<!-- 总价钱 -->
<result property="totalPrice" column="opi_st_total_price" />
<result property="idCard" column="ho_pd_id_card" />
</resultMap>
<!--导出-->
<resultMap type="PatientMedicalRecordsYesVO" id="PatientMedicalRecordsYesVOResult">
<!-- 患者信息 -->
<!-- 学号/工号 -->
<result property="studentId" column="opi_student_id" />
<!-- 姓名 -->
<result property="name" column="opi_name" />
<!-- 性别 ( 显示 ) -->
<result property="genderLabel" column="opi_st_gender" />
<!-- 年龄 -->
<result property="age" column="opi_age" />
<!-- 班级 -->
<result property="classInfo" column="opi_class_info" />
<!-- 是否医保 ( 显示 ) -->
<result property="isInsuredLabel" column="ho_pd_st_is_insured" />
<!-- 就诊时间 -->
<result property="outpatientTime" column="ho_pd_outpatient_time" />
<!-- 总价钱 -->
<result property="totalPrice" column="opi_st_total_price" />
<!-- 数值 -->
<result property="value" column="ho_pd_value" />
<result property="idCard" column="ho_pd_id_card" />
</resultMap>
<!-- 患者信息 -->
<sql id="selectOsPatientInfoVo">
healthcare_os_patient_info.id AS opi_id,
healthcare_os_patient_info.patient_type AS opi_patient_type,
healthcare_os_patient_info.student_id AS opi_student_id,
healthcare_os_patient_info.name AS opi_name,
healthcare_os_patient_info.gender AS opi_gender,
healthcare_os_patient_info.age AS opi_age,
healthcare_os_patient_info.major AS opi_major,
healthcare_os_patient_info.class_info AS opi_class_info,
healthcare_os_patient_info.phone AS opi_phone,
healthcare_os_patient_info.counselor AS opi_counselor,
healthcare_os_patient_info.department AS opi_department,
healthcare_os_patient_info.create_by AS opi_create_by,
healthcare_os_patient_info.create_time AS opi_create_time,
healthcare_os_patient_info.update_by AS opi_update_by,
healthcare_os_patient_info.update_time AS opi_update_time
</sql>
<!-- 诊断药品 -->
<sql id="selectHealthcareOsPrescriptionDetailsVo">
healthcare_os_prescription_details.id AS opd_id,
healthcare_os_prescription_details.patient_diagnosis_id AS opd_patient_diagnosis_id,
healthcare_os_prescription_details.singular AS opd_singular,
healthcare_os_prescription_details.medicine_id AS opd_medicine_id,
healthcare_os_prescription_details.medicine_name AS opd_medicine_name,
healthcare_os_prescription_details.specification AS opd_specification,
healthcare_os_prescription_details.usage_value AS opd_usage_value,
healthcare_os_prescription_details.dosage_value AS opd_dosage_value,
healthcare_os_prescription_details.frequency AS opd_frequency,
healthcare_os_prescription_details.eating_time AS opd_eating_time,
healthcare_os_prescription_details.eating_days AS opd_eating_days,
healthcare_os_prescription_details.split_unit AS opd_split_unit,
healthcare_os_prescription_details.total_quantity AS opd_total_quantity,
healthcare_os_prescription_details.unit_price AS opd_unit_price,
healthcare_os_prescription_details.total_price AS opd_total_price,
healthcare_os_prescription_details.is_split AS opd_is_split,
healthcare_os_prescription_details.unit_quantity AS opd_unit_quantity,
healthcare_os_prescription_details.package_unit AS opd_package_unit,
healthcare_os_prescription_details.remarks AS opd_remarks,
healthcare_os_prescription_details.create_by AS opd_create_by,
healthcare_os_prescription_details.create_time AS opd_create_time,
healthcare_os_prescription_details.update_by AS opd_update_by,
healthcare_os_prescription_details.update_time AS opd_update_time
</sql>
<!-- 诊断 -->
<sql id="selectHealthcareOsPatientDiagnosisVo">
healthcare_os_patient_diagnosis.id AS ho_pd_id,
healthcare_os_patient_diagnosis.patient_id AS ho_pd_patient_id,
healthcare_os_patient_diagnosis.diagnosis_type AS ho_pd_diagnosis_type,
healthcare_os_patient_diagnosis.is_insured AS ho_pd_is_insured,
healthcare_os_patient_diagnosis.value AS ho_pd_value,
healthcare_os_patient_diagnosis.student_id AS ho_pd_student_id,
healthcare_os_patient_diagnosis.name AS ho_pd_name,
healthcare_os_patient_diagnosis.patient_type AS ho_pd_patient_type,
healthcare_os_patient_diagnosis.chief_complaint AS ho_pd_chief_complaint,
healthcare_os_patient_diagnosis.present_illness AS ho_pd_present_illness,
healthcare_os_patient_diagnosis.past_history AS ho_pd_past_history,
healthcare_os_patient_diagnosis.diagnosis AS ho_pd_diagnosis,
healthcare_os_patient_diagnosis.medical_advice AS ho_pd_medical_advice,
healthcare_os_patient_diagnosis.doctor_name AS ho_pd_doctor_name,
healthcare_os_patient_diagnosis.status AS ho_pd_status,
healthcare_os_patient_diagnosis.outpatient_time AS ho_pd_outpatient_time,
healthcare_os_patient_diagnosis.create_by AS ho_pd_create_by,
healthcare_os_patient_diagnosis.create_time AS ho_pd_create_time,
healthcare_os_patient_diagnosis.update_by AS ho_pd_update_by,
healthcare_os_patient_diagnosis.update_time AS ho_pd_update_time,
healthcare_os_patient_diagnosis.id_card AS ho_pd_id_card
</sql>
<!-- 获取 患者 诊断 列表 信息 没有 药品 进行 xml 官场 dictionariesNamePatientType -->
<select id="obtainPatientDiagnosisList" parameterType="PatientMedicalRecordsVO" resultMap="PatientMedicalRecordsVOResult">
select
<include refid="selectOsPatientInfoVo"/>
,
<include refid="selectHealthcareOsPatientDiagnosisVo"/>
,
<if test="dictionariesNamePatientType != null and dictionariesNamePatientType != ''" >
(select dict_label from sys_dict_data
where sys_dict_data.dict_type = #{dictionariesNamePatientType} and
sys_dict_data.dict_value = healthcare_os_patient_info.patient_type )
AS opi_st_patient_type ,
</if>
<if test="dictionariesNameGender != null and dictionariesNameGender != ''">
(select dict_label from sys_dict_data
where sys_dict_data.dict_type = #{dictionariesNameGender} and
sys_dict_data.dict_value = healthcare_os_patient_info.gender
) AS opi_st_gender,
</if>
<if test="dictionariesNameIsInsured != null and dictionariesNameIsInsured != ''">
(select dict_label from sys_dict_data
where sys_dict_data.dict_type = #{dictionariesNameIsInsured} and
sys_dict_data.dict_value = healthcare_os_patient_diagnosis.is_insured
) AS ho_pd_st_is_insured ,
</if>
<if test="dictionariesNameStatus != null and dictionariesNameStatus != ''">
(select dict_label from sys_dict_data
where sys_dict_data.dict_type = #{dictionariesNameStatus} and
sys_dict_data.dict_value = healthcare_os_patient_diagnosis.status
) AS ho_pd_st_status,
</if>
(select sum(total_price) from healthcare_os_prescription_details
where healthcare_os_prescription_details.patient_diagnosis_id =
healthcare_os_patient_diagnosis.id ) AS opi_st_total_price
from healthcare_os_patient_diagnosis
left join healthcare_os_patient_info
on healthcare_os_patient_diagnosis.patient_id = healthcare_os_patient_info.id
<where>
<if test="status != null"> and healthcare_os_patient_diagnosis.status = #{status}</if>
<if test="name != null"> and healthcare_os_patient_diagnosis.name = #{name}</if>
<if test="diagnosis != null"> and healthcare_os_patient_diagnosis.diagnosis = #{diagnosis}</if>
<if test="studentId != null"> and healthcare_os_patient_diagnosis.student_id = #{studentId}</if>
<if test="doctorName != null"> and healthcare_os_patient_diagnosis.doctor_name = #{doctorName}</if>
<if test="isInsured != null "> and is_insured = #{isInsured}</if>
<if test="studentId != null and studentId != ''"> and student_id like concat('%', #{studentId}, '%')</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="doctorName != null and doctorName != ''"> and doctor_name like concat('%', #{doctorName}, '%')</if>
<if test="diagnosis != null and diagnosis != ''"> and diagnosis = #{diagnosis}</if>
<if test="startTime != null and endTime != null">
AND healthcare_os_patient_diagnosis.outpatient_time BETWEEN #{startTime} AND #{endTime}
</if>
</where>
</select>
<!-- CountDiagnosisVO -->
<resultMap type="CountDiagnosisVO" id="CountDiagnosisVOResult">
<!-- -->
<result property="symptomName" column="value" />
<!-- -->
<result property="number" column="number" />
</resultMap>
<!-- 导出(接诊医保列表) -->
<!-- 获取 患者 诊断 列表 信息 没有 药品 进行 xml 官场 dictionariesNamePatientType -->
<select id="obtainPatientDiagnosisYesList" parameterType="PatientMedicalRecordsVO" resultMap="PatientMedicalRecordsYesVOResult">
select
<include refid="selectOsPatientInfoVo"/>
,
<include refid="selectHealthcareOsPatientDiagnosisVo"/>
,
<if test="dictionariesNameGender != null and dictionariesNameGender != ''">
(select dict_label from sys_dict_data
where sys_dict_data.dict_type = #{dictionariesNameGender} and
sys_dict_data.dict_value = healthcare_os_patient_info.gender
) AS opi_st_gender,
</if>
<if test="dictionariesNameIsInsured != null and dictionariesNameIsInsured != ''">
(select dict_label from sys_dict_data
where sys_dict_data.dict_type = #{dictionariesNameIsInsured} and
sys_dict_data.dict_value = healthcare_os_patient_diagnosis.is_insured
) AS ho_pd_st_is_insured ,
</if>
(select sum(total_price) from healthcare_os_prescription_details
where healthcare_os_prescription_details.patient_diagnosis_id =
healthcare_os_patient_diagnosis.id ) AS opi_st_total_price
from healthcare_os_patient_diagnosis
left join healthcare_os_patient_info
on healthcare_os_patient_diagnosis.patient_id = healthcare_os_patient_info.id
<where>
<if test="isInsured != null "> is_insured = #{isInsured} and</if>
<if test="startTime != null and endTime != null">
healthcare_os_patient_diagnosis.outpatient_time BETWEEN #{startTime} AND #{endTime} AND
</if>
healthcare_os_patient_diagnosis.status = 1
</where>
</select>
<!-- 获取 每个 症状 的 诊断 数量 obtain symptom corresponding number 234415 params -->
<!-- startTime -> 开始时间 , endTime -> 结束时间 -->
<!-- 知无涯修改 -->
<select id="obtainSymptomCorrespondingNumber" parameterType="CountDiagnosisVO" resultMap="CountDiagnosisVOResult">
SELECT
ho_cv.value as value,
COUNT(ho_pd.id) as number
FROM
healthcare_os_conventional_value as ho_cv
LEFT JOIN
healthcare_os_patient_diagnosis as ho_pd ON
ho_pd.diagnosis LIKE CONCAT('%', ho_cv.value, '%')
<if test="params.startTime != null and params.endTime != null">
AND ho_pd.create_time BETWEEN #{params.startTime} AND #{params.endTime}
</if>
WHERE
ho_cv.parent_id = (SELECT id FROM healthcare_os_conventional_value WHERE parent_id = 0 AND dict_name = #{dictionariesNameSymptom})
<if test="symptomName != null and symptomName != ''">
AND ho_cv.value = #{symptomName}
</if>
GROUP BY
ho_cv.value
ORDER BY
number DESC
</select>
<!-- 获取 症状 数量 单独 -->
<!-- 知无涯修改 -->
<select id="obtainSymptomNumber" parameterType="CountDiagnosisVO" resultMap="CountDiagnosisVOResult">
SELECT
ho_cv.value as value,
COUNT(ho_pd.id) as number
FROM
healthcare_os_conventional_value as ho_cv
LEFT JOIN
healthcare_os_patient_diagnosis as ho_pd ON
ho_pd.diagnosis LIKE CONCAT('%', ho_cv.value, '%')
WHERE
ho_cv.parent_id = (
SELECT id
FROM healthcare_os_conventional_value
WHERE parent_id = 0 AND dict_name = #{dictionariesNameSymptom}
)
<if test="symptomName != null and symptomName != ''">
AND ho_cv.value = #{symptomName}
</if>
GROUP BY
ho_cv.value
</select>
<select id="obtainPatientDiagnosisList_COUNT"
parameterType="PatientMedicalRecordsVO"
resultType="java.lang.Integer">
SELECT COUNT(1)
FROM healthcare_os_patient_diagnosis
LEFT JOIN healthcare_os_patient_info ON healthcare_os_patient_diagnosis.patient_id = healthcare_os_patient_info.id
<where>
<!-- 保持与主查询相同的条件 -->
<if test="status != null">AND healthcare_os_patient_diagnosis.status = #{status}</if>
</where>
</select>
</mapper>