liusheng
2025-04-10 1967693c5d760ade002f8a5fbea10b51aef5693f
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?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.PatArchiveOutMapper">
 
    <resultMap type="com.smartor.domain.PatArchiveOut" id="PatArchiveOutResult">
        <result property="patid" column="patid"/>
        <result property="patientno" column="patientno"/>
        <result property="pattype" column="pattype"/>
        <result property="name" column="name"/>
        <result property="sex" column="sex"/>
        <result property="nation" column="nation"/>
        <result property="nativePlace" column="native_place"/>
        <result property="placeOfResidence" column="place_of_residence"/>
        <result property="birthplace" column="birthplace"/>
        <result property="idcardno" column="idcardno"/>
        <result property="birthdate" column="birthdate"/>
        <result property="age" column="age"/>
        <result property="archivetime" column="archivetime"/>
        <result property="archiveby" column="archiveby"/>
        <result property="telcode" column="telcode"/>
        <result property="relativetelcode" column="relativetelcode"/>
        <result property="idcardtype" column="idcardtype"/>
        <result property="orgid" column="orgid"/>
        <result property="openid" column="openid"/>
        <result property="dduserid" column="dduserid"/>
        <result property="delFlag" column="del_flag"/>
        <result property="source" column="source"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="isupload" column="isupload"/>
        <result property="uploadTime" column="upload_time"/>
        <result property="pid" column="pid"/>
        <result property="guid" column="guid"/>
        <result property="membertype" column="membertype"/>
    </resultMap>
 
    <sql id="selectPatArchiveOutVo">
        select patid,
               patientno,
               pattype,
               name,
               sex,
               nation,
               native_place,
               place_of_residence,
               birthplace,
               idcardno,
               birthdate,
               age,
               archivetime,
               archiveby,
               telcode,
               relativetelcode,
               idcardtype,
               orgid,
               openid,
               dduserid,
               del_flag,
               source,
               update_by,
               update_time,
               create_by,
               create_time,
               isupload,
               upload_time,
               pid,
               guid,
               membertype
        from pat_archive_out
    </sql>
 
    <select id="selectPatArchiveOutList" parameterType="com.smartor.domain.PatArchiveOut"
            resultMap="PatArchiveOutResult">
        <include refid="selectPatArchiveOutVo"/>
        <where>
            <if test="patientno != null  and patientno != ''">and patientno = #{patientno}</if>
            <if test="pattype != null  and pattype != ''">and pattype = #{pattype}</if>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="sex != null ">and sex = #{sex}</if>
            <if test="nation != null  and nation != ''">and nation = #{nation}</if>
            <if test="nativePlace != null  and nativePlace != ''">and native_place = #{nativePlace}</if>
            <if test="placeOfResidence != null  and placeOfResidence != ''">and place_of_residence =
                #{placeOfResidence}
            </if>
            <if test="birthplace != null  and birthplace != ''">and birthplace = #{birthplace}</if>
            <if test="idcardno != null  and idcardno != ''">and idcardno = #{idcardno}</if>
            <if test="birthdate != null ">and birthdate = #{birthdate}</if>
            <if test="age != null ">and age = #{age}</if>
            <if test="archivetime != null ">and archivetime = #{archivetime}</if>
            <if test="archiveby != null  and archiveby != ''">and archiveby = #{archiveby}</if>
            <if test="telcode != null  and telcode != ''">and telcode = #{telcode}</if>
            <if test="relativetelcode != null  and relativetelcode != ''">and relativetelcode = #{relativetelcode}</if>
            <if test="idcardtype != null  and idcardtype != ''">and idcardtype = #{idcardtype}</if>
            <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
            <if test="openid != null  and openid != ''">and openid = #{openid}</if>
            <if test="dduserid != null  and dduserid != ''">and dduserid = #{dduserid}</if>
            <if test="source != null ">and source = #{source}</if>
            <if test="isupload != null ">and isupload = #{isupload}</if>
            <if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
            <if test="pid != null ">and pid = #{pid}</if>
            <if test="guid != null  and guid != ''">and guid = #{guid}</if>
            <if test="membertype != null  and membertype != ''">and membertype = #{membertype}</if>
        </where>
    </select>
 
    <select id="selectPatArchiveOutByPatid" parameterType="Long" resultMap="PatArchiveOutResult">
        <include refid="selectPatArchiveOutVo"/>
        where patid = #{patid}
    </select>
 
    <select id="selectPatArchiveCount" parameterType="Long" resultType="com.smartor.domain.PerSonWorkbenchDto">
        select aa.name1 as name, aa.count as count
        from (
        SELECT "住院" as name1, count(1) as count FROM `pat_med_inhosp`
        <where>
            del_flag = 0 and endtime = null
            <if test="deptIds != null ">and deptId in
                <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
            <if test="drCodes != null ">and drcode in
                <foreach collection="drCodes" item="drCode" open="(" separator="," close=")">
                    #{drCode}
                </foreach>
            </if>
        </where>
        union
        select "出院" name1, count(1) as count FROM `pat_med_inhosp`
        <where>
            del_flag=0 and endtime != null
            <if test="deptIds != null ">and deptId in
                <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
            <if test="drCodes != null ">and drcode in
                <foreach collection="drCodes" item="drCode" open="(" separator="," close=")">
                    #{drCode}
                </foreach>
            </if>
        </where>
        union
        select "门诊" name1, count(1) as count FROM `pat_med_outhosp`
        where del_flag=0
        ) aa
 
    </select>
 
    <insert id="insertPatArchiveOut" parameterType="com.smartor.domain.PatArchiveOut" useGeneratedKeys="true"
            keyProperty="patid">
        insert into pat_archive_out
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patientno != null">patientno,</if>
            <if test="pattype != null">pattype,</if>
            <if test="name != null">name,</if>
            <if test="sex != null">sex,</if>
            <if test="nation != null">nation,</if>
            <if test="nativePlace != null">native_place,</if>
            <if test="placeOfResidence != null">place_of_residence,</if>
            <if test="birthplace != null">birthplace,</if>
            <if test="idcardno != null">idcardno,</if>
            <if test="birthdate != null">birthdate,</if>
            <if test="age != null">age,</if>
            <if test="archivetime != null">archivetime,</if>
            <if test="archiveby != null">archiveby,</if>
            <if test="telcode != null">telcode,</if>
            <if test="relativetelcode != null">relativetelcode,</if>
            <if test="idcardtype != null">idcardtype,</if>
            <if test="orgid != null">orgid,</if>
            <if test="openid != null">openid,</if>
            <if test="dduserid != null">dduserid,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="source != null">source,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isupload != null">isupload,</if>
            <if test="uploadTime != null">upload_time,</if>
            <if test="pid != null">pid,</if>
            <if test="guid != null">guid,</if>
            <if test="membertype != null">membertype,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patientno != null">#{patientno},</if>
            <if test="pattype != null">#{pattype},</if>
            <if test="name != null">#{name},</if>
            <if test="sex != null">#{sex},</if>
            <if test="nation != null">#{nation},</if>
            <if test="nativePlace != null">#{nativePlace},</if>
            <if test="placeOfResidence != null">#{placeOfResidence},</if>
            <if test="birthplace != null">#{birthplace},</if>
            <if test="idcardno != null">#{idcardno},</if>
            <if test="birthdate != null">#{birthdate},</if>
            <if test="age != null">#{age},</if>
            <if test="archivetime != null">#{archivetime},</if>
            <if test="archiveby != null">#{archiveby},</if>
            <if test="telcode != null">#{telcode},</if>
            <if test="relativetelcode != null">#{relativetelcode},</if>
            <if test="idcardtype != null">#{idcardtype},</if>
            <if test="orgid != null">#{orgid},</if>
            <if test="openid != null">#{openid},</if>
            <if test="dduserid != null">#{dduserid},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="source != null">#{source},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="isupload != null">#{isupload},</if>
            <if test="uploadTime != null">#{uploadTime},</if>
            <if test="pid != null">#{pid},</if>
            <if test="guid != null">#{guid},</if>
            <if test="membertype != null">#{membertype},</if>
        </trim>
    </insert>
 
    <update id="updatePatArchiveOut" parameterType="com.smartor.domain.PatArchiveOut">
        update pat_archive_out
        <trim prefix="SET" suffixOverrides=",">
            <if test="patientno != null">patientno = #{patientno},</if>
            <if test="pattype != null">pattype = #{pattype},</if>
            <if test="name != null">name = #{name},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="nation != null">nation = #{nation},</if>
            <if test="nativePlace != null">native_place = #{nativePlace},</if>
            <if test="placeOfResidence != null">place_of_residence = #{placeOfResidence},</if>
            <if test="birthplace != null">birthplace = #{birthplace},</if>
            <if test="idcardno != null">idcardno = #{idcardno},</if>
            <if test="birthdate != null">birthdate = #{birthdate},</if>
            <if test="age != null">age = #{age},</if>
            <if test="archivetime != null">archivetime = #{archivetime},</if>
            <if test="archiveby != null">archiveby = #{archiveby},</if>
            <if test="telcode != null">telcode = #{telcode},</if>
            <if test="relativetelcode != null">relativetelcode = #{relativetelcode},</if>
            <if test="idcardtype != null">idcardtype = #{idcardtype},</if>
            <if test="orgid != null">orgid = #{orgid},</if>
            <if test="openid != null">openid = #{openid},</if>
            <if test="dduserid != null">dduserid = #{dduserid},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="source != null">source = #{source},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="isupload != null">isupload = #{isupload},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="guid != null">guid = #{guid},</if>
            <if test="membertype != null">membertype = #{membertype},</if>
        </trim>
        where patid = #{patid}
    </update>
 
    <update id="deletePatArchiveOutByPatid" parameterType="Long">
        update pat_archive_out
        <trim prefix="SET" suffixOverrides=",">
            del_flag =1
        </trim>
        where patid = #{patid}
    </update>
 
 
</mapper>