LymsXljcRecordMapper.xml 9.31 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
<?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.talkonlineweb.mapper.LymsXljcRecordMapper">

<resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsXljcRecord">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="archId" column="arch_id" jdbcType="INTEGER"/>
<result property="formCode" column="form_code" jdbcType="VARCHAR"/>
<result property="formVersion" column="form_version" jdbcType="VARCHAR"/>
<result property="examineTime" column="examine_time" jdbcType="TIMESTAMP"/>
<result property="examineDoctor" column="examine_doctor" jdbcType="INTEGER"/>
<result property="examineHid" column="examine_hid" jdbcType="INTEGER"/>
<result property="examineDpid" column="examine_dpid" jdbcType="INTEGER"/>

<result property="uploadStatus" column="upload_status" jdbcType="INTEGER"/>
<result property="uploadTime" column="upload_time" jdbcType="TIMESTAMP"/>
<result property="yn" column="yn" jdbcType="INTEGER"/>

<result property="createdby" column="createdby" jdbcType="INTEGER"/>
<result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
<result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
<result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="queryHisExamineRecords" parameterType="com.lyms.talkonlineweb.domain.LymsXljcRecord"
resultType="com.lyms.talkonlineweb.result.HisExamineRecord">
select
r.id as rid,
DATE_FORMAT(r.examine_time,'%Y/%m/%d') as examineTime,
f.form_type as formType,
f.form_code as formCode,
f.form_name as formName
from
lyms_xljc_record r,
lyms_xljc_form f
where r.arch_id = #{archId}
and r.examine_hid = #{examineHid}
and r.form_code = f.form_code
and r.form_version = f.form_version
order by r.examine_time desc

</select>

<select id="selectHisExamineRecord" parameterType="com.lyms.talkonlineweb.request.ExamineRecordListRequest"
resultType="com.lyms.talkonlineweb.result.HisExamineRecord">
select
r.id as rid,
f.form_type as formType,
f.form_code as formCode,
f.form_name as formName,
a.pname,
a.idno,
a.tel,
a.age,
a.sex,
a.birth,
DATE_FORMAT(r.examine_time,'%Y/%m/%d') as examineTime,
r.examine_doctor as examineDoctor,
d.dname as examineDoctorName
from
lyms_xljc_archive a,
lyms_xljc_record r,
lyms_xljc_form f,
lyms_doctor d
where
a.id = r.arch_id
and r.examine_doctor = d.did
and r.form_code = f.form_code
and r.form_version = f.form_version
<if test="recordListRequest.examineHid != null ">
and r.examine_hid = #{recordListRequest.examineHid}
</if>
<if test="recordListRequest.examineTimeStart != null and recordListRequest.examineTimeStart != '' ">
and r.examine_time > #{recordListRequest.examineTimeStart}
</if>
<if test="recordListRequest.examineTimeEnd != null and recordListRequest.examineTimeEnd != '' ">
and r.examine_time &lt; #{recordListRequest.examineTimeEnd}
</if>
<if test="recordListRequest.formType != null and recordListRequest.formType != ''">
and f.form_type = #{recordListRequest.formType}
</if>
<if test="recordListRequest.formCode != null and recordListRequest.formCode != ''">
and f.form_code = #{recordListRequest.formCode}
</if>
<if test="recordListRequest.key != null and recordListRequest.key != '' ">
and (a.pname = #{recordListRequest.key} or a.idno = #{recordListRequest.key} or a.tel = #{recordListRequest.key})
</if>
<if test="recordListRequest.doctorId != null">
and r.examine_doctor = #{recordListRequest.doctorId}
</if>

order by r.examine_time desc

</select>
<!--
<select id="selectHisExamineRecordNoPage" parameterType="com.lyms.talkonlineweb.request.ExamineRecordListRequest"
resultType="com.lyms.talkonlineweb.result.HisExamineRecord">
select
r.id as rid,
f.form_type as formType,
f.form_code as formCode,
f.form_name as formName,
a.pname,
a.idno,
a.tel,
a.age,
a.sex,
DATE_FORMAT(r.examine_time,'%Y/%m/%d') as examineTime,
r.examine_doctor as examineDoctor,
d.dname as examineDoctorName
from
lyms_xljc_archive a,
lyms_xljc_record r,
lyms_xljc_form f,
lyms_doctor d
where
a.id = r.arch_id
and r.examine_hid = #{recordListRequest.examineHid}
and r.examine_doctor = d.did
and r.form_code = f.form_code
and r.form_version = f.form_version
<if test="recordListRequest.examineHid != null ">
and r.examine_hid = #{recordListRequest.examineHid}
</if>
<if test="recordListRequest.examineTimeStart != null and recordListRequest.examineTimeStart != '' ">
and r.examine_time > #{recordListRequest.examineTimeStart}
</if>
<if test="recordListRequest.examineTimeEnd != null and recordListRequest.examineTimeEnd != '' ">
and r.examine_time &lt; #{recordListRequest.examineTimeEnd}
</if>
<if test="recordListRequest.formType != null and recordListRequest.formType != ''">
and f.form_type = #{recordListRequest.formType}
</if>
<if test="recordListRequest.formCode != null and recordListRequest.formCode != ''">
and f.form_code = #{recordListRequest.formCode}
</if>
<if test="recordListRequest.key != null and recordListRequest.key != '' ">
and (a.pname = #{recordListRequest.key} or a.idno = #{recordListRequest.key} or a.tel = #{recordListRequest.key})
</if>
<if test="recordListRequest.doctorId != null">
and r.examine_doctor = #{recordListRequest.doctorId}
</if>

order by r.examine_time desc

</select>-->

<select id="countExamineRecordGroupByFormType" parameterType="com.lyms.talkonlineweb.request.ExamineRecordListRequest"
resultType="com.lyms.talkonlineweb.result.ExamineRecordCount">
SELECT
r.examine_hid as examineHid,
h.hname,
sum(case when f.form_type = 'A' then 1 else 0 end ) a,
sum(case when f.form_type = 'B' then 1 else 0 end ) b,
sum(case when f.form_type = 'C' then 1 else 0 end) c

FROM
lyms_xljc_record r,
lyms_xljc_form f ,
lyms_hospital h
WHERE

r.examine_hid = h.hid
AND r.form_code = f.form_code
AND r.form_version = f.form_version
<if test = "request.examineHid != null">
and r.examine_hid = #{request.examineHid}
</if>
<if test="request.examineTimeStart != null and request.examineTimeStart != '' ">
and r.examine_time > #{request.examineTimeStart}
</if>
<if test="request.examineTimeEnd != null and request.examineTimeEnd != '' ">
and r.examine_time &lt; #{request.examineTimeEnd}
</if>

GROUP BY r.examine_hid,h.hname
</select>

<select id="queryPatientList" parameterType="com.lyms.talkonlineweb.request.XljcPatientRequest"
resultType="com.lyms.talkonlineweb.result.XljcPatientResult">

select
r.id as rid,
CONCAT('lyms',a.tel) as patientNo,
a.pname,
a.idno,
a.tel,
a.age,
a.sex,
a.birth,
case when r.upload_status = 0 then '未上传' else '已上传' end uploadStatusText,
r.upload_time uploadTime,
r.examine_time examineTime,
result.diagnosis,
a.bookbuil_doctor_name as bookbuilDoctorName,
h.hname,
hdepart.dname as dpName
from
lyms_xljc_archive a,
lyms_xljc_record r,
lyms_xljc_record_result result,
lyms_hospital h,
lyms_hdepart hdepart
where
a.id = r.arch_id
and r.id = result.rid
and a.hid = h.hid
and a.dpid = hdepart.did
and r.yn = 1
<if test="request.uploadStatus != null ">
and r.upload_status = #{request.uploadStatus}
</if>
<if test="request.examineTimeStart != null and request.examineTimeStart != '' ">
and r.examine_time > #{request.examineTimeStart}
</if>
<if test="request.examineTimeEnd != null and request.examineTimeEnd != '' ">
and r.examine_time &lt; #{request.examineTimeEnd}
</if>
<if test="request.key != null and request.key != '' ">
and (a.pname = #{request.key} or a.idno = #{request.key} or a.tel = #{request.key})
</if>
<if test="request.hid != null">
and a.hid = #{request.hid}
</if>
<if test="request.dpid != null">
and a.dpid = #{request.dpid}
</if>
<if test="request.doctorId != null">
and a.bookbuil_doctor = #{request.doctorId}
</if>
order by a.bookbuil_date desc

</select>



</mapper>