zhaowenxuan
4 天以前 2b2763c83e352f8ffd2ac0b5c46b60c49ee78439
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<?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.ltkj.hosp.mapper.TjAskMedicalHistoryMapper">
 
    <resultMap type="TjAskMedicalHistory" id="TjAskMedicalHistoryResult">
        <result property="askId" column="ask_id"/>
        <result property="cusId" column="cus_id"/>
        <result property="cusName" column="cus_name"/>
        <result property="openId" column="open_id"/>
        <result property="work" column="work"/>
        <result property="workStatus" column="work_status"/>
        <result property="medicalHistory" column="medical_history"/>
        <result property="chuchao" column="chuchao"/>
        <result property="jingqi" column="jingqi"/>
        <result property="zhouqi" column="zhouqi"/>
        <result property="mociage" column="mociage"/>
        <result property="zinv" column="zinv"/>
        <result property="liuchan" column="liuchan"/>
        <result property="zaochan" column="zaochan"/>
        <result property="sichan" column="sichan"/>
        <result property="yichangtai" column="yichangtai"/>
        <result property="xiyan" column="xiyan"/>
        <result property="xiyanpinlv" column="xiyanpinlv"/>
        <result property="xiyanyear" column="xiyanyear"/>
        <result property="yinjiu" column="yinjiu"/>
        <result property="yinjiupinlv" column="yinjiupinlv"/>
        <result property="yinjiuyear" column="yinjiuyear"/>
        <result property="qita" column="qita"/>
        <result property="remark" column="remark"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleted" column="deleted"/>
        <result property="fromBy" column="from_by"/>
        <result property="zzsjj" column="zzsjj" typeHandler="com.ltkj.common.mybatis.JsonStringArrayTypeHandler"/>
        <result property="contactPoison" column="contact_poison"/>
        <result property="gongZhong" column="gong_zhong"/>
        <result property="gongLing" column="gong_ling"/>
        <result property="jhgl" column="jhgl"/>
        <result property="medicalHistoryIds" column="medical_history_ids"/>
        <result property="medicalHistoryOther" column="medical_history_other"/>
        <result property="dwmc" column="dwmc"/>
        <result property="ygdw" column="ygdw"/>
    </resultMap>
 
    <resultMap id="TjAskMedicalHistoryTjAskHistorysResult" type="TjAskMedicalHistory"
               extends="TjAskMedicalHistoryResult">
        <collection property="tjAskHistorysList" notNullColumn="sub_disease_id"
                    javaType="java.util.List" resultMap="TjAskHistorysResult"/>
    </resultMap>
 
    <resultMap type="TjAskHistorys" id="TjAskHistorysResult">
        <result property="diseaseId" column="sub_disease_id"/>
        <result property="askId" column="sub_ask_id"/>
        <result property="diseaseName" column="sub_disease_name"/>
        <result property="diseaseData" column="sub_disease_data"/>
        <result property="diseaseCompany" column="sub_disease_company"/>
        <result property="isOk" column="sub_is_ok"/>
        <result property="remark" column="sub_remark"/>
        <result property="createBy" column="sub_create_by"/>
        <result property="createTime" column="sub_create_time"/>
        <result property="updateBy" column="sub_update_by"/>
        <result property="updateTime" column="sub_update_time"/>
        <result property="deleted" column="sub_deleted"/>
    </resultMap>
 
    <sql id="selectTjAskMedicalHistoryVo">
        select ask_id,
               cus_id,
               cus_name,
               work,
               work_status,
               medical_history_ids,
               medical_history,
               medical_history_other,
               chuchao,
               jingqi,
               zhouqi,
               mociage,
               zinv,
               liuchan,
               zaochan,
               sichan,
               yichangtai,
               xiyan,
               xiyanpinlv,
               xiyanyear,
               yinjiu,
               yinjiupinlv,
               yinjiuyear,
               qita,
               remark,
               create_by,
               create_time,
               update_by,
               update_time,
               deleted,
               from_by,
               zzsjj,
               contact_poison,
               gong_zhong,
               gong_ling,
               jhgl,
               dwmc,
               ygdw
        from tj_ask_medical_history
    </sql>
 
    <select id="selectTjAskMedicalHistoryList" parameterType="TjAskMedicalHistory"
            resultMap="TjAskMedicalHistoryResult">
        <include refid="selectTjAskMedicalHistoryVo"/>
        <where>
            <if test="cusName != null  and cusName != ''">
                and cus_name like concat('%', #{cusName}, '%')
            </if>
        </where>
    </select>
 
    <select id="selectTjAskMedicalHistoryByAskId" parameterType="Long"
            resultMap="TjAskMedicalHistoryTjAskHistorysResult">
        select a.ask_id,
               a.cus_id,
               a.cus_name,
               a.work,
               a.work_status,
               a.medical_history_ids,
               a.medical_history,
               a.medical_history_other,
               a.chuchao,
               a.jingqi,
               a.zhouqi,
               a.mociage,
               a.zinv,
               a.liuchan,
               a.zaochan,
               a.sichan,
               a.yichangtai,
               a.xiyan,
               a.xiyanpinlv,
               a.xiyanyear,
               a.yinjiu,
               a.yinjiupinlv,
               a.yinjiuyear,
               a.qita,
               a.remark,
               a.create_by,
               a.create_time,
               a.update_by,
               a.update_time,
               a.deleted,
               a.from_by,
               b.disease_id      as
                   sub_disease_id,
               b.ask_id          as
                   sub_ask_id,
               b.disease_name    as
                   sub_disease_name,
               b.disease_data    as
                   sub_disease_data,
               b.disease_company as
                   sub_disease_company,
               b.is_ok           as
                   sub_is_ok,
               b.remark          as
                   sub_remark,
               b.create_by       as
                   sub_create_by,
               b.create_time     as
                   sub_create_time,
               b.update_by       as
                   sub_update_by,
               b.update_time     as
                   sub_update_time,
               b.deleted         as
                   sub_deleted,
            a.dwmc,
            a.ygdw
        from tj_ask_medical_history a
                 left join tj_ask_historys b on b.ask_id = a.ask_id
        where a.ask_id = #{askId}
    </select>
 
    <insert id="insertTjAskMedicalHistory" parameterType="TjAskMedicalHistory" useGeneratedKeys="true"
            keyProperty="askId">
        insert into tj_ask_medical_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cusId != null">cus_id,
            </if>
            <if test="cusName != null">cus_name,
            </if>
            <if test="work != null">work,
            </if>
            <if test="workStatus != null">work_status,
            </if>
            <if test="medicalHistoryIds != null">medical_history_ids,
            </if>
            <if test="medicalHistory != null">medical_history,
            </if>
            <if test="medicalHistoryOther != null">medical_history_other,
            </if>
            <if test="chuchao != null">chuchao,
            </if>
            <if test="jingqi != null">jingqi,
            </if>
            <if test="zhouqi != null">zhouqi,
            </if>
            <if test="mociage != null">mociage,
            </if>
            <if test="zinv != null">zinv,
            </if>
            <if test="liuchan != null">liuchan,
            </if>
            <if test="zaochan != null">zaochan,
            </if>
            <if test="sichan != null">sichan,
            </if>
            <if test="yichangtai != null">yichangtai,
            </if>
            <if test="xiyan != null">xiyan,
            </if>
            <if test="xiyanpinlv != null">xiyanpinlv,
            </if>
            <if test="xiyanyear != null">xiyanyear,
            </if>
            <if test="yinjiu != null">yinjiu,
            </if>
            <if test="yinjiupinlv != null">yinjiupinlv,
            </if>
            <if test="yinjiuyear != null">yinjiuyear,
            </if>
            <if test="qita != null">qita,
            </if>
            <if test="remark != null">remark,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="deleted != null">deleted,
            </if>
            <if test="fromBy != null">from_by,
            </if>
            <if test="dwmc != null">dwmc,
            </if>
            <if test="ygdw != null">ygdw,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cusId != null">#{cusId},
            </if>
            <if test="cusName != null">#{cusName},
            </if>
            <if test="work != null">#{work},
            </if>
            <if test="workStatus != null">#{workStatus},
            </if>
            <if test="medicalHistoryIds != null">#{medicalHistoryIds},
            </if>
            <if test="medicalHistory != null">#{medicalHistory},
            </if>
            <if test="medicalHistoryOther != null">#{medicalHistoryOther},
            </if>
            <if test="chuchao != null">#{chuchao},
            </if>
            <if test="jingqi != null">#{jingqi},
            </if>
            <if test="zhouqi != null">#{zhouqi},
            </if>
            <if test="mociage != null">#{mociage},
            </if>
            <if test="zinv != null">#{zinv},
            </if>
            <if test="liuchan != null">#{liuchan},
            </if>
            <if test="zaochan != null">#{zaochan},
            </if>
            <if test="sichan != null">#{sichan},
            </if>
            <if test="yichangtai != null">#{yichangtai},
            </if>
            <if test="xiyan != null">#{xiyan},
            </if>
            <if test="xiyanpinlv != null">#{xiyanpinlv},
            </if>
            <if test="xiyanyear != null">#{xiyanyear},
            </if>
            <if test="yinjiu != null">#{yinjiu},
            </if>
            <if test="yinjiupinlv != null">#{yinjiupinlv},
            </if>
            <if test="yinjiuyear != null">#{yinjiuyear},
            </if>
            <if test="qita != null">#{qita},
            </if>
            <if test="remark != null">#{remark},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="deleted != null">#{deleted},
            </if>
            <if test="fromBy != null">#{fromBy},
            </if>
            <if test="dwmc != null">#{dwmc},
            </if>
            <if test="ygdw != null">#{ygdw},
            </if>
        </trim>
    </insert>
 
    <update id="updateTjAskMedicalHistory" parameterType="TjAskMedicalHistory">
        update tj_ask_medical_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="cusId != null">cus_id =
                #{cusId},
            </if>
            <if test="cusName != null">cus_name =
                #{cusName},
            </if>
            <if test="work != null">work =
                #{work},
            </if>
            <if test="workStatus != null">work_status =
                #{workStatus},
            </if>
            <if test="medicalHistoryIds != null">medical_history_ids =
                #{medicalHistoryIds},
            </if>
            <if test="medicalHistory != null">medical_history =
                #{medicalHistory},
            </if>
            <if test="medicalHistoryOther != null">medical_history_other =
                #{medicalHistoryOther},
            </if>
            <if test="chuchao != null">chuchao =
                #{chuchao},
            </if>
            <if test="jingqi != null">jingqi =
                #{jingqi},
            </if>
            <if test="zhouqi != null">zhouqi =
                #{zhouqi},
            </if>
            <if test="mociage != null">mociage =
                #{mociage},
            </if>
            <if test="zinv != null">zinv =
                #{zinv},
            </if>
            <if test="liuchan != null">liuchan =
                #{liuchan},
            </if>
            <if test="zaochan != null">zaochan =
                #{zaochan},
            </if>
            <if test="sichan != null">sichan =
                #{sichan},
            </if>
            <if test="yichangtai != null">yichangtai =
                #{yichangtai},
            </if>
            <if test="xiyan != null">xiyan =
                #{xiyan},
            </if>
            <if test="xiyanpinlv != null">xiyanpinlv =
                #{xiyanpinlv},
            </if>
            <if test="xiyanyear != null">xiyanyear =
                #{xiyanyear},
            </if>
            <if test="yinjiu != null">yinjiu =
                #{yinjiu},
            </if>
            <if test="yinjiupinlv != null">yinjiupinlv =
                #{yinjiupinlv},
            </if>
            <if test="yinjiuyear != null">yinjiuyear =
                #{yinjiuyear},
            </if>
            <if test="qita != null">qita =
                #{qita},
            </if>
            <if test="remark != null">remark =
                #{remark},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="deleted != null">deleted =
                #{deleted},
            </if>
            <if test="fromBy != null">from_By =
                #{fromBy},
            </if>
            <if test="dwmc != null">dwmc =
                #{dwmc},
            </if>
            <if test="ygdw != null">ygdw =
                #{ygdw},
            </if>
        </trim>
        where ask_id = #{askId}
    </update>
 
    <delete id="deleteTjAskMedicalHistoryByAskId" parameterType="Long">
        delete
        from tj_ask_medical_history
        where ask_id = #{askId}
    </delete>
 
    <delete id="deleteTjAskMedicalHistoryByAskIds" parameterType="String">
        delete from tj_ask_medical_history where ask_id in
        <foreach item="askId" collection="array" open="(" separator="," close=")">
            #{askId}
        </foreach>
    </delete>
 
    <delete id="deleteTjAskHistorysByAskIds" parameterType="String">
        delete from tj_ask_historys where ask_id in
        <foreach item="askId" collection="array" open="(" separator="," close=")">
            #{askId}
        </foreach>
    </delete>
 
    <delete id="deleteTjAskHistorysByAskId" parameterType="Long">
        delete
        from tj_ask_historys
        where ask_id = #{askId}
    </delete>
 
    <insert id="batchTjAskHistorys">
        insert into tj_ask_historys
        ( disease_id , ask_id , disease_name , disease_data , disease_company , is_ok , remark , create_by , create_time
        , update_by , update_time , deleted) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.diseaseId
                }, #{item.askId
                }, #{item.diseaseName
                }, #{item.diseaseData
                }, #{item.diseaseCompany
                }, #{item.isOk
                }, #{item.remark
                }, #{item.createBy
                }, #{item.createTime
                }, #{item.updateBy
                }, #{item.updateTime
                }, #{item.deleted
                })
        </foreach>
    </insert>
 
 
    <select id="selectTjAskMedicalHistoryByTjNum" parameterType="String" resultMap="TjAskMedicalHistoryResult">
        <include refid="selectTjAskMedicalHistoryVo"/>
        where tj_num = #{tjNum}
        and deleted=0
    </select>
</mapper>