ElderlyInfoMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.biz.ElderlyInfoMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO" id="BaseResultMap">
  6. <id column="id" jdbcType="BIGINT" property="id"/>
  7. <result column="elder_image" jdbcType="VARCHAR" property="elderImage"/>
  8. <result column="elder_cover" jdbcType="VARCHAR" property="elderCover"/>
  9. <result column="elder_name" jdbcType="VARCHAR" property="elderName"/>
  10. <result column="elder_sex" jdbcType="INTEGER" property="elderSex"/>
  11. <result column="elder_age" jdbcType="INTEGER" property="elderAge"/>
  12. <result column="elder_height" jdbcType="DECIMAL" property="elderHeight"/>
  13. <result column="elder_weight" jdbcType="DECIMAL" property="elderWeight"/>
  14. <result column="elder_blood" jdbcType="VARCHAR" property="elderBlood"/>
  15. <result column="region" jdbcType="VARCHAR" property="region"/>
  16. <result column="address" jdbcType="VARCHAR" property="address"/>
  17. <result column="sales_user_id" jdbcType="BIGINT" property="salesUserId"/>
  18. <result column="user_sign" jdbcType="VARCHAR" property="userSign"/>
  19. <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
  20. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  21. <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
  22. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  23. <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/>
  24. <result column="census_register" jdbcType="VARCHAR" property="censusRegister"/>
  25. <result column="id_card" jdbcType="VARCHAR" property="idCard"/>
  26. <result column="blood_type" jdbcType="VARCHAR" property="bloodType"/>
  27. <result column="nation_id" jdbcType="VARCHAR" property="nationId"/>
  28. <result column="political" jdbcType="VARCHAR" property="political"/>
  29. <result column="birthday" jdbcType="DATE" property="birthday"/>
  30. <result column="tel_phone" jdbcType="VARCHAR" property="telPhone"/>
  31. <result column="economy_source" jdbcType="VARCHAR" property="economySource"/>
  32. <result column="religious_belief" jdbcType="VARCHAR" property="religiousBelief"/>
  33. <result column="home_tel" jdbcType="VARCHAR" property="homeTel"/>
  34. <result column="media_channels" jdbcType="VARCHAR" property="mediaChannels"/>
  35. <result column="business_type" jdbcType="VARCHAR" property="businessType"/>
  36. <result column="medical_insurance" jdbcType="VARCHAR" property="medicalInsurance"/>
  37. <result column="degree_education" jdbcType="INTEGER" property="degreeEducation"/>
  38. <result column="marital_status" jdbcType="INTEGER" property="maritalStatus"/>
  39. <result column="elder_type" jdbcType="INTEGER" property="elderType"/>
  40. <result column="form_supply" jdbcType="INTEGER" property="formSupply"/>
  41. <result column="retirement_unit" jdbcType="VARCHAR" property="retirementUnit"/>
  42. <result column="payment_method" jdbcType="INTEGER" property="paymentMethod"/>
  43. <result column="referee_name" jdbcType="VARCHAR" property="refereeName"/>
  44. <result column="referee_id" jdbcType="BIGINT" property="refereeId"/>
  45. <result column="referee_pay" jdbcType="DECIMAL" property="refereePay"/>
  46. <result column="allergic_drug" jdbcType="VARCHAR" property="allergicDrug"/>
  47. <result column="check_in_time" jdbcType="TIMESTAMP" property="checkInTime"/>
  48. <result column="in_status" jdbcType="INTEGER" property="inStatus"/>
  49. <result column="nurse_level_id" jdbcType="BIGINT" property="nurseLevelId"/>
  50. <result column="nurse_level_name" jdbcType="VARCHAR" property="nurseLevelName"/>
  51. <result column="nurse_group_id" jdbcType="BIGINT" property="nurseGroupId"/>
  52. <result column="nurse_group_name" jdbcType="VARCHAR" property="nurseGroupName"/>
  53. <result column="build_id" jdbcType="BIGINT" property="buildId"/>
  54. <result column="build_name" jdbcType="VARCHAR" property="buildName"/>
  55. <result column="floor_id" jdbcType="BIGINT" property="floorId"/>
  56. <result column="floor_name" jdbcType="VARCHAR" property="floorName"/>
  57. <result column="room_id" jdbcType="BIGINT" property="roomId"/>
  58. <result column="room_name" jdbcType="VARCHAR" property="roomName"/>
  59. <result column="bed_id" jdbcType="BIGINT" property="bedId"/>
  60. <result column="bed_name" jdbcType="VARCHAR" property="bedName"/>
  61. <result column="in_deposit" jdbcType="DECIMAL" property="inDeposit"/>
  62. <result column="machine_ids" jdbcType="VARCHAR" property="machineIds"/>
  63. <result column="disability" jdbcType="VARCHAR" property="disability"/>
  64. <result column="drug_allergy" jdbcType="VARCHAR" property="drugAllergy"/>
  65. <result column="settle_date" jdbcType="TIMESTAMP" property="settleDate"/>
  66. <result column="ocac" jdbcType="VARCHAR" property="ocac"/>
  67. <result column="file_number" jdbcType="VARCHAR" property="fileNumber"/>
  68. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  69. <result column="in_status_type" jdbcType="INTEGER" property="inStatusType"/>
  70. <result column="registered_residence_address" jdbcType="VARCHAR" property="registeredResidenceAddress"/>
  71. </resultMap>
  72. <select id="findPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  73. select ei.*, ec.contract_number as contractNumber
  74. from elderly_info ei
  75. LEFT JOIN elderly_contract ec ON ec.elder_id = ei.id AND ec.status = 1
  76. where 1 = 1 and ei.deleted = 0
  77. <if test="pageVO.elderName != null and pageVO.elderName != '' ">
  78. and ei.elder_name like concat('%', #{pageVO.elderName}, '%')
  79. </if>
  80. <if test="pageVO.elderSex != null and pageVO.elderSex != '' ">
  81. and ei.elder_sex = #{pageVO.elderSex}
  82. </if>
  83. <if test="pageVO.inStatus != null">
  84. and ei.in_status = #{pageVO.inStatus}
  85. </if>
  86. <if test="pageVO.buildId != null">
  87. and ei.build_id = #{pageVO.buildId}
  88. </if>
  89. <if test="pageVO.floorId != null">
  90. and ei.floor_id = #{pageVO.floorId}
  91. </if>
  92. <if test="pageVO.bedId != null">
  93. and ei.bed_id = #{pageVO.bedId}
  94. </if>
  95. <if test="pageVO.roomName != null and pageVO.roomName != '' ">
  96. and ei.room_name like concat('%', #{pageVO.roomName}, '%')
  97. </if>
  98. <if test="pageVO.nurseLevelId != null">
  99. and ei.nurse_level_id = #{pageVO.nurseLevelId}
  100. </if>
  101. <if test="pageVO.careType != null">
  102. and ei.care_type = #{pageVO.careType}
  103. </if>
  104. <if test="pageVO.hasExtra != null and pageVO.hasExtra == 1">
  105. and ei.hasExtra is not null and ei.hasExtra != ''
  106. </if>
  107. <if test="pageVO.hasExtra != null and pageVO.hasExtra == 0">
  108. and ei.hasExtra is null and ei.hasExtra == ''
  109. </if>
  110. <if test="pageVO.checkInTime != null">
  111. and ei.create_time between #{pageVO.checkInTime[0]} and #{pageVO.checkInTime[1]}
  112. </if>
  113. <if test="pageVO.orgType != null">
  114. and ei.org_type = #{pageVO.orgType}
  115. </if>
  116. <if test="pageVO.tenantIds != null">
  117. and ei.tenant_id in
  118. <foreach item="id" collection="pageVO.tenantIds" open="(" separator="," close=")">
  119. #{id}
  120. </foreach>
  121. </if>
  122. <if test="pageVO.orderByClause != null and pageVO.orderByClause != ''">
  123. ORDER BY ${pageVO.orderByClause}
  124. </if>
  125. </select>
  126. <select id="findBpmPage" resultType="cn.iocoder.yudao.module.system.api.bpm.vo.ElderlyCheckinInfoRespVO">
  127. SELECT
  128. ei.*,
  129. bbf.`status` AS "bpmStatus",
  130. bbf.process_instance_id,
  131. st.name as tenantName
  132. FROM
  133. elderly_info ei
  134. INNER JOIN elderly_retreat_record err ON ei.id = err.elderly_id AND apply_type = 0
  135. INNER JOIN bpm_business_form bbf ON bbf.business_id = err.id AND type = 1
  136. LEFT JOIN system_tenant st ON st.id = ei.tenant_id
  137. where err.current_flag = 0 AND err.deleted = 0
  138. <if test="pageVO.elderName != null and pageVO.elderName != '' ">
  139. and ei.elder_name like concat('%', #{pageVO.elderName}, '%')
  140. </if>
  141. <if test="pageVO.elderSex != null and pageVO.elderSex != '' ">
  142. and ei.elder_sex = #{pageVO.elderSex}
  143. </if>
  144. <if test="pageVO.inStatus != null">
  145. and ei.in_status = #{pageVO.inStatus}
  146. </if>
  147. <if test="pageVO.checkInTime != null">
  148. and ei.create_time between #{pageVO.checkInTime[0]} and #{pageVO.checkInTime[1]}
  149. </if>
  150. <if test="pageVO.orgType != null">
  151. and ei.org_type = #{pageVO.orgType}
  152. </if>
  153. <if test="pageVO.tenantIds != null">
  154. and ei.tenant_id in
  155. <foreach item="id" collection="pageVO.tenantIds" open="(" separator="," close=")">
  156. #{id}
  157. </foreach>
  158. </if>
  159. <if test="pageVO.orgType"></if>
  160. order by ei.update_time desc
  161. </select>
  162. <select id="elderlyCheckInRecordPage"
  163. resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyCheckInRecordDO">
  164. select t1.*,t2.elder_name,t2.elder_sex,t2.in_status_type,t2.nurse_level_name from elderly_check_in_record t1
  165. inner join elderly_info t2 on t1.elder_id = t2.id
  166. where 1 = 1
  167. <if test="params.elderName != null and params.elderName != '' ">
  168. and t2.elder_name like concat('%',#{params.elderName} ,'%')
  169. </if>
  170. <if test="params.status != null">
  171. and t1.status = #{params.status}
  172. </if>
  173. <if test="params.inStatusType != null">
  174. and t2.in_status_type = #{params.inStatusType}
  175. </if>
  176. <if test="params.checkInTime != null">
  177. and t1.check_in_time between #{params.checkInTime[0]} and #{params.checkInTime[1]}
  178. </if>
  179. <if test="params.orgType != null">
  180. and t2.org_type = #{params.orgType}
  181. </if>
  182. <if test="params.tenantIds != null">
  183. and t2.tenant_id in
  184. <foreach item="id" collection="params.tenantIds" open="(" separator="," close=")">
  185. #{id}
  186. </foreach>
  187. </if>
  188. order by t1.created_time desc,t1.status asc
  189. </select>
  190. <select id="getElderListByBuild" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  191. select * from elderly_info
  192. <where>
  193. 1 = 1
  194. <if test="buildId != null">
  195. and build_id = #{buildId}
  196. </if>
  197. <if test="floorId != null">
  198. and floor_id = #{floorId}
  199. </if>
  200. <if test="roomId != null">
  201. and room_id = #{roomId}
  202. </if>
  203. <if test="tenantIds != null">
  204. and tenant_id in
  205. <foreach item="id" collection="tenantIds" open="(" separator="," close=")">
  206. #{id}
  207. </foreach>
  208. </if>
  209. </where>
  210. </select>
  211. <select id="getElderlyMedicationExecutionPage"
  212. resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.ElderlyMedicationExecutionRespVO">
  213. select ei.id as elderId,ei.elder_name,ei.elder_sex,ebr.execute_status from elderly_info ei inner join elderly_byod_registration ebr on ebr.elder_id = ei.id
  214. <where>
  215. 1 = 1
  216. <if test="params.elderName != null and params.elderName != ''">
  217. and ei.elder_name like concat('%',#{params.elderName} ,'%')
  218. </if>
  219. <if test="params.bedId != null">
  220. and ei.bed_id = #{params.bedId}
  221. </if>
  222. <if test="params.executeStatus != null">
  223. and ebr.execute_status = #{params.executeStatus}
  224. </if>
  225. <if test="params.orgType != null">
  226. and ei.org_type = #{params.orgType}
  227. </if>
  228. <if test="params.tenantId != null">
  229. and ei.tenant_id = #{params.tenantId}
  230. </if>
  231. </where>
  232. order by ei.id desc
  233. </select>
  234. <select id="getCheckInDetail" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.CheckInRecordDetailRespVO">
  235. SELECT
  236. ecir.*,
  237. ei.elder_name,
  238. ei.id AS elder_id,
  239. ei.elder_sex,
  240. ei.elder_age,
  241. ei.in_status_type,
  242. ei.nurse_level_name,
  243. ei.id_card,
  244. ei.bed_id,
  245. ei.tenant_id,
  246. bbf.status AS bpmStatus,
  247. bbf.process_instance_id,
  248. bbf.type,
  249. cia.contract_json,
  250. cia.monthly_expenses_json,
  251. cia.one_time_expenses_json,
  252. cia.stage_expenses_json,
  253. cia.total_amount,
  254. cia.remark,
  255. cia.check_in_time,
  256. cia.check_in_deadline_time,
  257. cia.nurse_level_id,
  258. cia.is_private_room,
  259. cia.special_care_notes
  260. FROM
  261. elderly_check_in_record ecir
  262. INNER JOIN elderly_info ei ON ecir.elder_id = ei.id
  263. INNER JOIN bpm_business_form bbf ON ecir.id = bbf.business_id AND bbf.type = 9
  264. INNER JOIN check_in_apply cia ON ecir.associate_id = cia.id
  265. WHERE ecir.id = #{id}
  266. </select>
  267. <select id="selectCountByParam" resultType="java.lang.Integer">
  268. SELECT COUNT(1) FROM elderly_info
  269. <where>
  270. 1 = 1
  271. <if test="inStatus != null">
  272. and in_status = #{inStatus}
  273. </if>
  274. <if test="checkInTime != null and checkOutFlag == 0">
  275. and DATE_FORMAT(check_in_time, '%Y-%m') <![CDATA[ = ]]> #{checkInTime}
  276. </if>
  277. <if test="checkInTime != null and checkOutFlag == 1">
  278. and DATE_FORMAT(check_in_time, '%Y-%m') <![CDATA[ <= ]]> #{checkInTime}
  279. </if>
  280. <if test="checkOutTime != null and checkOutFlag == 0">
  281. and DATE_FORMAT(check_out_time, '%Y-%m') = #{checkOutTime}
  282. </if>
  283. <if test="checkOutTime != null and checkOutFlag == 1">
  284. and (DATE_FORMAT(check_out_time, '%Y-%m') <![CDATA[ < ]]> #{checkOutTime} or check_out_time is NULL)
  285. </if>
  286. <if test="tenantId != null">
  287. and tenant_id = #{tenantId}
  288. </if>
  289. </where>
  290. </select>
  291. <select id="selectTryStayCount" resultType="java.lang.Integer">
  292. SELECT
  293. COUNT(*)
  294. FROM
  295. elderly_info
  296. WHERE
  297. in_status_type = 2
  298. <if test="reqVO.currentDate != null">
  299. AND DATE_FORMAT(check_in_time, '%Y-%m') = DATE_FORMAT(#{reqVO.currentDate}, '%Y-%m')
  300. </if>
  301. <if test="reqVO.tenantIds != null">
  302. AND tenant_id IN
  303. <foreach item="id" collection="reqVO.tenantIds" open="(" separator="," close=")">
  304. #{id}
  305. </foreach>
  306. </if>
  307. </select>
  308. <select id="selectGoOutCount" resultType="java.lang.Integer">
  309. SELECT
  310. COUNT(*)
  311. FROM
  312. elderly_ask_leave
  313. WHERE
  314. status = 0
  315. <if test="reqVO.currentDate != null">
  316. AND DATE_FORMAT(out_date, '%Y-%m') = DATE_FORMAT(#{reqVO.currentDate}, '%Y-%m')
  317. </if>
  318. <if test="reqVO.tenantIds != null">
  319. AND tenant_id IN
  320. <foreach item="id" collection="reqVO.tenantIds" open="(" separator="," close=")">
  321. #{id}
  322. </foreach>
  323. </if>
  324. </select>
  325. <select id="selectCurrentCheckInCount" resultType="java.lang.Integer">
  326. SELECT
  327. COUNT(*)
  328. FROM
  329. elderly_info
  330. WHERE
  331. in_status = 1
  332. <if test="reqVO.currentDate != null">
  333. AND DATE_FORMAT(check_in_time, '%Y-%m') = DATE_FORMAT(#{reqVO.currentDate}, '%Y-%m')
  334. </if>
  335. <if test="reqVO.tenantIds != null">
  336. AND tenant_id IN
  337. <foreach item="id" collection="reqVO.tenantIds" open="(" separator="," close=")">
  338. #{id}
  339. </foreach>
  340. </if>
  341. </select>
  342. <select id="selectVitalSignsList" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.ElderlyVitalSignsStatisticsRespVO">
  343. SELECT
  344. ei.id AS elderId,
  345. ei.elder_name,
  346. ei.elder_age,
  347. ei.elder_sex,
  348. eei.item_name,
  349. ei.tenant_id
  350. FROM
  351. elderly_info ei
  352. INNER JOIN elderly_expense ee ON ei.id = ee.elder_id
  353. AND ei.tenant_id = ee.tenant_id
  354. INNER JOIN elderly_expense_item eei ON eei.expense_id = ee.id
  355. AND ei.tenant_id = eei.tenant_id
  356. INNER JOIN sys_charge_category scc ON scc.id = eei.item_category_id
  357. AND ei.tenant_id = scc.tenant_id
  358. WHERE
  359. ei.in_status = 1
  360. AND ee.created_time = ( SELECT MAX( ee2.created_time ) FROM elderly_expense ee2 WHERE ee2.elder_id = ei.id )
  361. AND scc.identification = 2
  362. AND ei.tenant_id IN
  363. <foreach item="id" collection="pageReqVO.tenantIds" open="(" separator="," close=")">
  364. #{id}
  365. </foreach>
  366. </select>
  367. <select id="selectVitalSignsTodayList" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.ElderlyVitalSignsStatisticsTodayRespVO">
  368. SELECT
  369. ei.id AS elderId,
  370. ei.elder_name,
  371. ei.elder_age,
  372. ei.elder_sex,
  373. ei.tenant_id,
  374. evs.measuring_time,
  375. evs.systolic_pressure,
  376. evs.diastolic_pressure
  377. FROM
  378. elderly_vital_signs evs
  379. INNER JOIN elderly_info ei ON evs.elder_id = ei.id AND evs.tenant_id = ei.tenant_id
  380. WHERE
  381. DATE_FORMAT(evs.measuring_time, '%Y-%m-%d') = DATE_FORMAT(#{pageReqVO.currentDate}, '%Y-%m-%d')
  382. <if test="pageReqVO.buildId">
  383. AND ei.build_id = #{pageReqVO.buildId}
  384. </if>
  385. <if test="pageReqVO.floorId">
  386. AND ei.floor_id = #{pageReqVO.floorId}
  387. </if>
  388. AND ei.tenant_id IN
  389. <foreach item="id" collection="pageReqVO.tenantIds" open="(" separator="," close=")">
  390. #{id}
  391. </foreach>
  392. AND (evs.systolic_pressure <![CDATA[ < ]]> #{pageReqVO.systolicPressureMin} OR evs.systolic_pressure <![CDATA[ > ]]> #{pageReqVO.systolicPressureMax})
  393. OR (evs.diastolic_pressure <![CDATA[ < ]]> #{pageReqVO.diastolicPressureMin} OR evs.diastolic_pressure <![CDATA[ > ]]> #{pageReqVO.diastolicPressureMax})
  394. ORDER BY evs.measuring_date,evs.measuring_time DESC
  395. </select>
  396. <select id="selectExportListWithBedInfo" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  397. SELECT
  398. ei.id,
  399. ei.elder_name AS elderName,
  400. ob.build_name AS buildName,
  401. obf.floor_name AS floorName,
  402. obr.room_name AS roomName,
  403. CONCAT_WS('-', ob.build_name, obf.floor_name, obr.room_name, obb.bed_name) AS bedName,
  404. ei.bed_id AS bedId,
  405. ei.tenant_id AS tenantId
  406. FROM elderly_info ei
  407. LEFT JOIN org_build_bed obb ON obb.id = ei.bed_id AND obb.tenant_id = ei.tenant_id
  408. LEFT JOIN org_build_room obr ON obr.id = obb.room_id AND obr.tenant_id = obb.tenant_id
  409. LEFT JOIN org_build_floor obf ON obf.id = obr.floor_id AND obf.tenant_id = obr.tenant_id
  410. LEFT JOIN org_build ob ON ob.id = obf.build_id AND ob.tenant_id = obf.tenant_id
  411. WHERE ei.tenant_id = #{tenantId}
  412. AND ei.deleted = 0
  413. AND ei.in_status = 1
  414. AND ei.bed_id IS NOT NULL
  415. ORDER BY ob.build_name, obf.floor_name, obr.room_name, obb.bed_name, ei.elder_name
  416. </select>
  417. <select id="selectByIdIgnoreDeleted" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  418. SELECT *
  419. FROM elderly_info
  420. WHERE id = #{id}
  421. </select>
  422. </mapper>