PatientService.xml 30.1 KB
   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
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
<?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.lyms.platform.permission.dao.master.PatientServiceMapper">

<resultMap id="PatientServiceResultMap" type="com.lyms.platform.permission.model.PatientService">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="parentid" property="parentid" jdbcType="VARCHAR"/>
<result column="pid" property="pid" jdbcType="VARCHAR"/>
<result column="ser_type" property="serType" jdbcType="INTEGER"/>
<result column="ser_doct" property="serDoct" jdbcType="VARCHAR"/>
<result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
<result column="create_user_name" property="createUserName" jdbcType="VARCHAR"/>
<result column="create_user" property="createUser" jdbcType="VARCHAR"/>
<result column="ser_status" property="serStatus" jdbcType="INTEGER"/>
<result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
<result column="update_user_name" property="updateUserName" jdbcType="VARCHAR"/>
<result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
<result column="hospital_id" property="hospitalId" jdbcType="VARCHAR"/>
<result column="ser_code" property="serCode" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="receive_date" property="receiveDate" jdbcType="TIMESTAMP"/>
<result column="receive_user" property="receiveUser" jdbcType="VARCHAR"/>
<result column="back_date" property="backDate" jdbcType="TIMESTAMP"/>
<result column="back_user" property="backUser" jdbcType="VARCHAR"/>
<result column="order_id" property="orderId" jdbcType="VARCHAR"/>
<result column="syn_status" property="synStatus" jdbcType="INTEGER"/>
<result column="is_old" property="isOld" jdbcType="INTEGER"/>
<result column="per_type" property="perType" jdbcType="INTEGER"/>
<result column="renew" property="renew" jdbcType="INTEGER"/>

<result column="device" property="device" jdbcType="INTEGER"/>
<result column="deviceCon" property="deviceCon" jdbcType="INTEGER"/>
<result column="doctorWeek" property="doctorWeek" jdbcType="INTEGER"/>
<result column="serviceWeek" property="serviceWeek" jdbcType="INTEGER"/>

<result column="serStartWeek" property="serStartWeek" jdbcType="INTEGER"/>
<result column="serEndWeek" property="serEndWeek" jdbcType="INTEGER"/>

<result column="serStartTime" property="serStartTime" jdbcType="TIMESTAMP"/>
<result column="serEndTime" property="serEndTime" jdbcType="TIMESTAMP"/>
<result column="docStartWeek" property="docStartWeek" jdbcType="INTEGER"/>
<result column="docEndWeek" property="docEndWeek" jdbcType="INTEGER"/>
<result column="docStartTime" property="docStartTime" jdbcType="TIMESTAMP"/>
<result column="docEndTime" property="docEndTime" jdbcType="TIMESTAMP"/>
</resultMap>


<insert id="addPatientService" parameterType="com.lyms.platform.permission.model.PatientService">
insert into patient_service (id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,
update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id,syn_status,is_old,per_type
,device,deviceCon,doctorWeek,serviceWeek,serStartWeek,serEndWeek,serStartTime,serEndTime,docStartWeek,docEndWeek,docStartTime,docEndTime
) values (#{id},#{parentid},#{pid},#{serType},#{serDoct},#{createDate},#{createUserName},#{createUser},#{serStatus},#{updateDate},
#{updateUserName},#{updateUser},#{hospitalId},#{serCode},#{status},#{receiveDate},#{receiveUser},#{backDate},#{backUser},#{orderId},#{synStatus},#{isOld},#{perType}
,#{device},#{deviceCon},#{doctorWeek},#{serviceWeek},#{serStartWeek},#{serEndWeek},#{serStartTime},#{serEndTime},#{docStartWeek},#{docEndWeek},#{docStartTime},#{docEndTime}
)
</insert>

<insert id="addPatientServiceAll" parameterType="java.util.List">
INSERT INTO patient_service
(id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,
update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id,syn_status,is_old,per_type
,device,deviceCon,doctorWeek,serviceWeek,serStartWeek,serEndWeek,serStartTime,serEndTime,docStartWeek,docEndWeek,docStartTime,docEndTime
)
VALUES
<foreach collection ="serviceList" item="patientService" separator =",">
(#{patientService.id},#{patientService.parentid},#{patientService.pid},#{patientService.serType},#{patientService.serDoct},#{patientService.createDate},#{patientService.createUserName},#{patientService.createUser},#{patientService.serStatus},#{patientService.updateDate},
#{patientService.updateUserName},#{patientService.updateUser},#{patientService.hospitalId},#{patientService.serCode},#{patientService.status},#{patientService.receiveDate},#{patientService.receiveUser},#{patientService.backDate},#{patientService.backUser},#{patientService.orderId},#{patientService.synStatus},#{patientService.isOld},#{patientService.perType}
,#{patientService.device},#{patientService.deviceCon},#{patientService.doctorWeek},#{patientService.serviceWeek},#{patientService.serStartWeek},#{patientService.serEndWeek},#{patientService.serStartTime},#{patientService.serEndTime},#{patientService.docStartWeek},#{patientService.docEndWeek},#{patientService.docStartTime},#{patientService.docEndTime}
)
</foreach >
</insert>

<update id="updatePatientService" parameterType="com.lyms.platform.permission.model.PatientService">
update patient_service
<set>
<if test="serDoct != null and serDoct != ''">
ser_doct = #{serDoct,jdbcType=VARCHAR},
</if>

<if test="createUser != null and createUser != ''">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="updateUser != null and updateUser != ''">
update_user = #{updateUser,jdbcType=VARCHAR},
</if>

<if test="parentid != null and parentid != ''">
parentid = #{parentid,jdbcType=VARCHAR},
</if>
<if test="pid != null and pid != ''">
pid = #{pid,jdbcType=VARCHAR},
</if>
<if test="serType != null and serType >= 0">
ser_type = #{serType,jdbcType=INTEGER},
</if>

<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="createUserName != null and createUserName != ''">
create_user_name = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="serStatus != null and serStatus >= 0">
ser_status = #{serStatus,jdbcType=INTEGER},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="updateUserName != null and updateUserName != ''">
update_user_name = #{updateUserName,jdbcType=VARCHAR},
</if>
<if test="hospitalId != null and hospitalId != ''">
hospital_id = #{hospitalId,jdbcType=VARCHAR},
</if>
<if test="serCode != null and serCode != ''">
ser_code = #{serCode,jdbcType=VARCHAR},
</if>
<if test="status != null and status >= 0">
status = #{status,jdbcType=INTEGER},
</if>
<if test="receiveDate != null">
receive_date = #{receiveDate,jdbcType=TIMESTAMP},
</if>
<if test="receiveUser != null and receiveUser != ''">
receive_user = #{receiveUser,jdbcType=VARCHAR},
</if>
<if test="backDate != null">
back_date = #{backDate,jdbcType=TIMESTAMP},
</if>
<if test="backUser != null and backUser != ''">
back_user = #{backUser,jdbcType=VARCHAR},
</if>
<if test="orderId != null and orderId != ''">
order_id = #{orderId,jdbcType=VARCHAR},
</if>
<if test="synStatus != null and synStatus != ''">
syn_status = #{synStatus,jdbcType=INTEGER},
</if>
<if test="isOld != null and isOld != ''">
is_old = #{isOld,jdbcType=INTEGER},
</if>
<if test="perType != null and perType != ''">
per_type = #{perType,jdbcType=INTEGER},
</if>

<if test="device != null and device >= 0">
device = #{device,jdbcType=INTEGER},
</if>
<if test="deviceCon != null and deviceCon >= 0">
deviceCon = #{deviceCon,jdbcType=INTEGER},
</if>
<if test="doctorWeek != null and doctorWeek >= 0">
doctorWeek = #{doctorWeek,jdbcType=INTEGER},
</if>
<if test="serviceWeek != null and serviceWeek >= 0">
serviceWeek = #{serviceWeek,jdbcType=INTEGER},
</if>
<if test="serStartWeek != null and serStartWeek >= 0">
serStartWeek = #{serStartWeek,jdbcType=INTEGER},
</if>
<if test="serEndWeek != null and serEndWeek >= 0">
serEndWeek = #{serEndWeek,jdbcType=INTEGER},
</if>
<if test="docStartWeek != null and docStartWeek >= 0">
docStartWeek = #{docStartWeek,jdbcType=INTEGER},
</if>
<if test="docEndWeek != null and docEndWeek >= 0">
docEndWeek = #{docEndWeek,jdbcType=INTEGER},
</if>

<if test="serStartTime != null">
serStartTime = #{serStartTime,jdbcType=TIMESTAMP},
</if>

<if test="serEndTime != null">
serEndTime = #{serEndTime,jdbcType=TIMESTAMP},
</if>

<if test="docStartTime != null">
docStartTime = #{docStartTime,jdbcType=TIMESTAMP},
</if>

<if test="docEndTime != null">
docEndTime = #{docEndTime,jdbcType=TIMESTAMP},
</if>
<if test="renew !=null">
renew=#{renew,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>


<delete id="deletePatientService" parameterType="java.lang.String">
delete from patient_service where id = #{id,jdbcType=VARCHAR}
</delete>

<delete id="deletePatientServiceByPatientId" parameterType="java.lang.String">
delete from patient_service where parentid = #{parentId,jdbcType=VARCHAR}
</delete>

<select id="getPatientService" resultMap="PatientServiceResultMap" parameterType="java.lang.String">
select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,
update_date,update_user_name,update_user,hospital_id,ser_code,
status,receive_date,receive_user,back_date,back_user,order_id,syn_status,is_old,per_type,
doctorWeek,serviceWeek,renew
from patient_service where id = #{id,jdbcType=VARCHAR}
</select>


<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>

<sql id="PatientServiceCondition">
<where>
1 = 1
<if test="id != null and id != ''">
and id = #{id,jdbcType=VARCHAR}
</if>
<if test="parentid != null and parentid != ''">
and parentid = #{parentid,jdbcType=VARCHAR}
</if>
<if test="parentIds!=null">
and parentid in (
<foreach item="parentid" collection="parentIds" separator=",">
#{parentid}
</foreach>
)
</if>
<if test="pid != null and pid != ''">
and pid = #{pid,jdbcType=VARCHAR}
</if>
<if test="serType != null and serType >= 0">
and ser_type = #{serType,jdbcType=INTEGER}
</if>

<if test="serDoct != null and serDoct != ''">
and ser_doct = #{serDoct,jdbcType=VARCHAR}
</if>
<if test="createDate != null">
and create_date = #{createDate,jdbcType=TIMESTAMP}
</if>
<if test="createStartDate != null">
AND
<![CDATA[
DATEDIFF(#{createStartDate},create_date)<=0
]]>
</if>
<if test="createEndDate != null">
AND
<![CDATA[
DATEDIFF(#{createEndDate},create_date)>=0
]]>
</if>
<if test="createUserName != null and createUserName != ''">
and create_user_name = #{createUserName,jdbcType=VARCHAR}
</if>
<if test="createUser != null and createUser != ''">
and create_user = #{createUser,jdbcType=VARCHAR}
</if>
<if test="serStatus != null and serStatus >= 0">
and ser_status = #{serStatus,jdbcType=INTEGER}
</if>
<if test="updateDate != null">
and update_date = #{updateDate,jdbcType=TIMESTAMP}
</if>
<if test="updateUserName != null and updateUserName != ''">
and update_user_name = #{updateUserName,jdbcType=VARCHAR}
</if>
<if test="updateUser != null and updateUser != ''">
and update_user = #{updateUser,jdbcType=VARCHAR}
</if>
<if test="hospitalId != null and hospitalId != ''">
and hospital_id = #{hospitalId,jdbcType=VARCHAR}
</if>
<if test="serTypes!=null">
and ser_type in (
<foreach item="serType" collection="serTypes" separator=",">
#{serType}
</foreach>
)
</if>
<if test="serCode != null and serCode != ''">
and ser_code = #{serCode,jdbcType=VARCHAR}
</if>
<if test="status != null and status >= 0">
and status = #{status,jdbcType=INTEGER}
</if>
<if test="receiveDate != null">
and receive_date = #{receiveDate,jdbcType=TIMESTAMP}
</if>
<if test="receiveUser != null and receiveUser != ''">
and receive_user = #{receiveUser,jdbcType=VARCHAR}
</if>
<if test="backDate != null">
and back_date = #{backDate,jdbcType=TIMESTAMP}
</if>
<if test="backUser != null and backUser != ''">
and back_user = #{backUser,jdbcType=VARCHAR}
</if>
<if test="orderId != null and orderId != ''">
and order_id = #{orderId,jdbcType=VARCHAR}
</if>
<if test="synStatus != null and synStatus != ''">
and syn_status = #{synStatus,jdbcType=INTEGER}
</if>
<if test="isOld != null and isOld != ''">
and is_old = #{isOld,jdbcType=INTEGER}
</if>
<if test="perType != null and perType != ''">
and per_type = #{perType,jdbcType=INTEGER}
</if>

<if test="device != null and device >= 0">
and device = #{device,jdbcType=INTEGER}
</if>
<if test="deviceCon != null and deviceCon >= 0">
and deviceCon = #{deviceCon,jdbcType=INTEGER}
</if>
<if test="doctorWeek != null and doctorWeek >= 0">
and doctorWeek = #{doctorWeek,jdbcType=INTEGER}
</if>
<if test="serviceWeek != null and serviceWeek >= 0">
and serviceWeek = #{serviceWeek,jdbcType=INTEGER}
</if>
<if test="serStartWeek != null and serStartWeek >= 0">
and serStartWeek = #{serStartWeek,jdbcType=INTEGER}
</if>
<if test="serEndWeek != null and serEndWeek >= 0">
and serEndWeek = #{serEndWeek,jdbcType=INTEGER}
</if>
<if test="docStartWeek != null and docStartWeek >= 0">
and docStartWeek = #{docStartWeek,jdbcType=INTEGER}
</if>
<if test="docEndWeek != null and docEndWeek >= 0">
and docEndWeek = #{docEndWeek,jdbcType=INTEGER}
</if>

<if test="serStartTime != null">
and serStartTime = #{serStartTime,jdbcType=TIMESTAMP}
</if>

<if test="serEndTime != null">
AND
<![CDATA[
DATEDIFF(#{serEndTime},serEndTime)>=0
]]>
</if>

<if test="serEndStartTime != null">
AND
<![CDATA[
serEndTime>=#{serEndStartTime}
and serEndTime<=#{serEndCheckTime}
]]>
</if>


<if test="docStartTime != null">
and docStartTime = #{docStartTime,jdbcType=TIMESTAMP}
</if>
<if test="docEndTime != null">
AND
<![CDATA[
DATEDIFF(#{docEndTime},docEndTime)>=0
]]>
</if>
<if test="updateStartDate !=null">
AND
<![CDATA[
update_date>= #{updateStartDate}
]]>
</if>
<if test="updateEndDate !=null">
AND
<![CDATA[
update_date<= #{updateEndDate}
]]>
</if>
<if test="renew !=null">
and renew=#{renew}
</if>

<if test="sql != null and sql != ''">
${sql}
</if>
</where>
</sql>

<select id="queryPatientService" resultMap="PatientServiceResultMap"
parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
select
id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,renew,
hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id,syn_status,is_old,per_type,
device,deviceCon,doctorWeek,serviceWeek,serStartWeek,serEndWeek,serStartTime,serEndTime,docStartWeek,docEndWeek,docStartTime,docEndTime
from patient_service
<include refid="PatientServiceCondition"/>
<include refid="orderAndLimit"/>
</select>

<!--查询只开通了标准服务的数据 -->
<select id="selectOnlyBzService" resultType="java.util.HashMap"
parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
SELECT * from (SELECT parentid,id,ser_type,create_date from patient_service where ser_status=1
<if test="perType != null and perType != ''">
and per_type = #{perType,jdbcType=INTEGER}
</if>

and ser_type in (1,6,10,11)

GROUP BY parentid HAVING count(parentid)=1 )as b
<if test="perType == 1">
where b.ser_type=6
</if>
<if test="perType == 2">
where b.ser_type=11
</if>
<include refid="orderAndLimit"/>
</select>


<!--查询只开通了标准服务的数据 -->
<select id="selectOnlyBzServiceCount" resultType="int"
parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
SELECT count(1) from ( SELECT count(1) from (SELECT parentid,id,ser_type from patient_service where ser_status=1
<if test="perType != null and perType != ''">
and per_type = #{perType,jdbcType=INTEGER}
</if>

and ser_type in (1,6,10,11)

GROUP BY parentid HAVING count(parentid)=1) as b
<if test="perType == 1">
where b.ser_type=6
</if>
<if test="perType == 2">
where b.ser_type=11
</if>
) as c
</select>
<select id="getPatientServices" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
t.id as "id",
t.parentid as "parentId",
t.pid as "pId",
t.ser_type as "serType"
FROM
patient_service t
WHERE
t.per_type = #{map.perType}
<if test="map.serStatus != -1">
AND t.ser_status = #{map.serStatus}
</if>
<if test="map.parentId != null and map.parentId != ''">
AND t.parentid = #{map.parentId}
</if>
<if test="map.serType != null and map.serType != ''">
AND t.ser_type = #{map.serType}
</if>

</select>
<select id="queryPatientServiceCount" resultType="int"
parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
select count(1) from patient_service
<include refid="PatientServiceCondition"/>
</select>
<select id="getServiceList" resultType="java.util.Map">
SELECT
o.name as "name",
o.province_id as "provinceId",
o.city_id as "cityId",
o.area_id as "areaId",
o.id as "hospitalId"
FROM patient_service ps
JOIN organization o
ON o.id = ps.hospital_id
WHERE ps.hospital_id = #{id}
<if test="query.startTime != null ">
AND ps.create_date &gt;= #{query.startTime}
</if>
<if test="query.endTime != null ">
AND ps.create_date &lt;= #{query.endTime}
</if>
<if test="query.serType != null and query.serType != '' ">
AND ps.ser_type = #{query.serType}
</if>
<if test="query.createUser != null and query.createUser != '' ">
AND ps.create_user = #{query.createUser}
</if>
<if test="query.operator != null and query.operator != '' ">
AND ps.update_user = #{query.operator}
</if>
<if test="query.serDoct != null and query.serDoct != '' ">
AND ps.ser_doct = #{query.serDoct}
</if>
<if test="query.provinceId != null and query.provinceId != '' ">
and o.province_id = #{query.provinceId}
</if>
<if test="query.cityId != null and query.cityId != ''">
and o.city_id = #{query.cityId}
</if>
<if test="query.areaId != null and query.areaId != ''">
and o.area_id = #{query.areaId}
</if>
GROUP BY o.name,o.province_id,
o.city_id,
o.area_id
</select>
<select id="countStatusInfo" resultType="int">
select count(1)
from patient_service ps
join organization o on o.id = ps.hospital_id
where 1=1
and ps.create_date &gt;= #{param.startTime}
AND ps.create_date &lt;= #{param.endTime}
and ps.ser_status = #{serStatus}
<if test="param.provinceId != null and param.provinceId != ''">
and o.province_id = #{param.provinceId}
</if>
<if test="param.cityId != null and param.cityId != ''">
and o.city_id = #{param.cityId}
</if>
<if test="param.areaId != null and param.areaId != ''">
and o.area_id = #{param.areaId}
</if>
<if test="ids.size() > 0">
and ps.hospital_id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="param.serType != null and param.serType != ''">
AND ps.ser_type = #{param.serType}
</if>
<if test="param.createUser != null and param.createUser != '' ">
AND ps.create_user = #{param.createUser}
</if>
<if test="param.operator != null and param.operator != '' ">
AND ps.update_user = #{param.operator}
</if>
<if test="param.serDoct != null and param.serDoct != '' ">
AND ps.ser_doct = #{param.serDoct}
</if>
</select>
<select id="getServeDetailList" parameterType="com.lyms.platform.permission.model.ServiceListQuery"
resultType="java.util.Map">
SELECT
ps.create_date as "createDate",
ps.parentid as "parentId",
ps.per_type as "perType", -- 1-孕妇、2-儿童
IFNULL(ps.serviceWeek, 24) as "serviceWeek",
ps.ser_type as "serType",
ps.ser_doct as "serDoct",
ps.create_user as "createUser",
ps.update_user as "updateUser",
CASE ps.ser_status
WHEN 1 THEN
'开通中'
WHEN 2 THEN
'退订'
WHEN 3 THEN
'过期'
WHEN 4 THEN
'暂停'
END AS "serStatus"
FROM
patient_service ps
JOIN organization o ON o.id = ps.hospital_id
WHERE 1=1
<if test="param.startTime != null">
and ps.create_date &gt;= #{param.startTime}
</if>
<if test="param.endTime != null ">
AND ps.create_date &lt;= #{param.endTime}
</if>
<if test="param.hospitalId != null and param.hospitalId != ''">
and o.id = #{param.hospitalId}
</if>
<if test="param.provinceId != null and param.provinceId != ''">
AND o.province_id = #{param.provinceId}
</if>
<if test="param.cityId != null and param.cityId != ''">
AND o.city_id = #{param.cityId}
</if>
<if test="param.areaId != null and param.areaId != ''">
AND o.area_id = #{param.areaId}
</if>
<if test="param.serStatus != null and param.serStatus != ''">
AND ps.ser_status = #{param.serStatus}
</if>
<if test="param.serType != null and param.serType != ''">
AND ps.ser_type = #{param.serType}
</if>
<if test="param.createUser != null and param.createUser != '' ">
AND ps.create_user = #{param.createUser}
</if>
<if test="param.operator != null and param.operator != '' ">
AND ps.update_user = #{param.operator}
</if>
<if test="param.serDoct != null and param.serDoct != '' ">
AND ps.ser_doct = #{param.serDoct}
</if>
order by ps.create_date desc
<if test="param.need != null">
limit #{param.offset, jdbcType=INTEGER} , #{param.limit, jdbcType=INTEGER}
</if>
</select>
<select id="getServeDetailListCount" parameterType="com.lyms.platform.permission.model.ServiceListQuery"
resultType="int">
SELECT
count(1)
FROM
patient_service ps
JOIN organization o ON o.id = ps.hospital_id
WHERE 1=1
<if test="param.hospitalId != null and param.hospitalId != ''">
and o.id = #{param.hospitalId}
</if>
<if test="param.provinceId != null and param.provinceId != ''">
AND o.province_id = #{param.provinceId}
</if>
<if test="param.cityId != null and param.cityId != ''">
AND o.city_id = #{param.cityId}
</if>
<if test="param.areaId != null and param.areaId != ''">
AND o.area_id = #{param.areaId}
</if>
<if test="param.serStatus != null and param.serStatus != ''">
AND ps.ser_status = #{param.serStatus}
</if>
<if test="param.serType != null and param.serType != ''">
AND ps.ser_type = #{param.serType}
</if>
<if test="param.createUser != null and param.createUser != '' ">
AND ps.create_user = #{param.createUser}
</if>
<if test="param.operator != null and param.operator != '' ">
AND ps.update_user = #{param.operator}
</if>
<if test="param.serDoct != null and param.serDoct != '' ">
AND ps.ser_doct = #{param.serDoct}
</if>
and ps.create_date &gt;= #{param.startTime}
AND ps.create_date &lt;= #{param.endTime}
</select>
<select id="getHospitalIds" resultType="string">
select
o.id as "hospitalId"
from organization o
join (select ps.hospital_id from patient_service ps
where ps.create_date &gt;= #{param.startTime} and ps.create_date &lt;= #{param.endTime}
<if test="param.serType != null and param.serType != ''">and ps.ser_type = #{param.serType}</if>
<if test="param.createUser != null and param.createUser != ''">and ps.create_user = #{param.createUser}</if>
<if test="param.operator != null and param.operator != ''">and ps.update_user = #{param.operator}</if>
<if test="param.serDoct != null and param.serDoct != ''">and ps.ser_doct = #{param.serDoct}</if>
group by ps.hospital_id)
t on t.hospital_id = o.id
where t.hospital_id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="param.provinceId != null and param.provinceId != ''">
and o.province_id = #{param.provinceId}
</if>
<if test="param.cityId != null and param.cityId != ''">
and o.city_id = #{param.cityId}
</if>
<if test="param.areaId != null and param.areaId != ''">
and o.area_id = #{param.areaId}
</if>

</select>
<select id="getServiceListByParentId" resultType="com.lyms.platform.permission.model.PatientService">
SELECT
id as id,
parentid as parentid,
ser_type as serType
FROM
patient_service
where parentid = #{patientsId} and ser_status = 1 and per_type = #{patientType}
</select>

<select id="selectServiceByHospital" resultType="java.util.HashMap">
SELECT
hso.ser_type as serType,hds.doct_id as doctId
FROM
`hospital_service_content` hso
INNER JOIN hospital_doct_service hds
on hso.id=hds.hosp_service_id
where hso.hospital_id=#{hospitalId} and hso.ser_type in (1,3,4,6)
</select>

</mapper>