zhs
2025-04-16 3c46b264b86bb38984370f685c6866c5f7784808
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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.smartor.mapper.MedicalHistoryMapper">
 
    <resultMap type="com.smartor.domain.MedicalHistory" id="MedicalHistoryResult">
        <result property="id"    column="id"    />
        <result property="pastIllnesses"    column="past_illnesses"    />
        <result property="drugAllergy"    column="drug_allergy"    />
        <result property="familyHistory"    column="family_history"    />
        <result property="surgicalHistory"    column="surgical_history"    />
        <result property="reproductiveHistory"    column="reproductive_history"    />
        <result property="menstrualHistory"    column="menstrual_history"    />
        <result property="smoking"    column="smoking"    />
        <result property="drink"    column="drink"    />
        <result property="motion"    column="motion"    />
        <result property="diet"    column="diet"    />
        <result property="psychology"    column="psychology"    />
        <result property="pid"    column="pid"    />
        <result property="guid"    column="guid"    />
        <result property="orgid"    column="orgid"    />
    </resultMap>
 
    <sql id="selectMedicalHistoryVo">
        select id, past_illnesses, guid,  drug_allergy, family_history, surgical_history, reproductive_history, orgid,menstrual_history, smoking, drink, motion, diet, psychology, pid from medical_history
    </sql>
 
    <select id="selectMedicalHistoryList" parameterType="com.smartor.domain.MedicalHistory" resultMap="MedicalHistoryResult">
        <include refid="selectMedicalHistoryVo"/>
        <where>
            <if test="pastIllnesses != null  and pastIllnesses != ''"> and past_illnesses = #{pastIllnesses}</if>
            <if test="drugAllergy != null  and drugAllergy != ''"> and drug_allergy = #{drugAllergy}</if>
            <if test="familyHistory != null  and familyHistory != ''"> and family_history = #{familyHistory}</if>
            <if test="surgicalHistory != null  and surgicalHistory != ''"> and surgical_history = #{surgicalHistory}</if>
            <if test="reproductiveHistory != null  and reproductiveHistory != ''"> and reproductive_history = #{reproductiveHistory}</if>
            <if test="menstrualHistory != null  and menstrualHistory != ''"> and menstrual_history = #{menstrualHistory}</if>
            <if test="smoking != null  and smoking != ''"> and smoking = #{smoking}</if>
            <if test="drink != null  and drink != ''"> and drink = #{drink}</if>
            <if test="motion != null  and motion != ''"> and motion = #{motion}</if>
            <if test="diet != null  and diet != ''"> and diet = #{diet}</if>
            <if test="psychology != null  and psychology != ''"> and psychology = #{psychology}</if>
            <if test="pid != null "> and pid = #{pid}</if>
            <if test="orgid != null "> and orgid = #{orgid}</if>
        </where>
    </select>
 
    <select id="selectMedicalHistoryById" parameterType="Long" resultMap="MedicalHistoryResult">
        <include refid="selectMedicalHistoryVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertMedicalHistory" parameterType="com.smartor.domain.MedicalHistory" useGeneratedKeys="true" keyProperty="id">
        insert into medical_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pastIllnesses != null">past_illnesses,</if>
            <if test="drugAllergy != null">drug_allergy,</if>
            <if test="familyHistory != null">family_history,</if>
            <if test="surgicalHistory != null">surgical_history,</if>
            <if test="reproductiveHistory != null">reproductive_history,</if>
            <if test="menstrualHistory != null">menstrual_history,</if>
            <if test="smoking != null">smoking,</if>
            <if test="drink != null">drink,</if>
            <if test="motion != null">motion,</if>
            <if test="diet != null">diet,</if>
            <if test="psychology != null">psychology,</if>
            <if test="pid != null">pid,</if>
            <if test="guid != null">guid,</if>
            <if test="orgid != null">orgid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pastIllnesses != null">#{pastIllnesses},</if>
            <if test="drugAllergy != null">#{drugAllergy},</if>
            <if test="familyHistory != null">#{familyHistory},</if>
            <if test="surgicalHistory != null">#{surgicalHistory},</if>
            <if test="reproductiveHistory != null">#{reproductiveHistory},</if>
            <if test="menstrualHistory != null">#{menstrualHistory},</if>
            <if test="smoking != null">#{smoking},</if>
            <if test="drink != null">#{drink},</if>
            <if test="motion != null">#{motion},</if>
            <if test="diet != null">#{diet},</if>
            <if test="psychology != null">#{psychology},</if>
            <if test="pid != null">#{pid},</if>
            <if test="guid != null">#{guid},</if>
            <if test="orgid != null">#{orgid},</if>
         </trim>
    </insert>
 
    <update id="updateMedicalHistory" parameterType="com.smartor.domain.MedicalHistory">
        update medical_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="pastIllnesses != null">past_illnesses = #{pastIllnesses},</if>
            <if test="drugAllergy != null">drug_allergy = #{drugAllergy},</if>
            <if test="familyHistory != null">family_history = #{familyHistory},</if>
            <if test="surgicalHistory != null">surgical_history = #{surgicalHistory},</if>
            <if test="reproductiveHistory != null">reproductive_history = #{reproductiveHistory},</if>
            <if test="menstrualHistory != null">menstrual_history = #{menstrualHistory},</if>
            <if test="smoking != null">smoking = #{smoking},</if>
            <if test="drink != null">drink = #{drink},</if>
            <if test="motion != null">motion = #{motion},</if>
            <if test="diet != null">diet = #{diet},</if>
            <if test="psychology != null">psychology = #{psychology},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="guid != null">guid = #{guid},</if>
            <if test="orgid != null">orgid = #{orgid},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteMedicalHistoryById" parameterType="Long">
        delete from medical_history where id = #{id}
    </delete>
 
    <delete id="deleteMedicalHistoryByIds" parameterType="String">
        delete from medical_history where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>