ElderlyInfoMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. LEFT JOIN elderly_refund_settlement_order efso ON efso.elder_id = ei.id
  77. where 1 = 1 and ei.deleted = 0 AND (efso.`status` != 1 OR efso.`status` is null)
  78. <if test="pageVO.elderName != null and pageVO.elderName != '' ">
  79. and ei.elder_name like concat('%', #{pageVO.elderName}, '%')
  80. </if>
  81. <if test="pageVO.elderSex != null and pageVO.elderSex != '' ">
  82. and ei.elder_sex = #{pageVO.elderSex}
  83. </if>
  84. <if test="pageVO.inStatus != null">
  85. and ei.in_status = #{pageVO.inStatus}
  86. </if>
  87. <if test="pageVO.buildId != null">
  88. and ei.build_id = #{pageVO.buildId}
  89. </if>
  90. <if test="pageVO.floorId != null">
  91. and ei.floor_id = #{pageVO.floorId}
  92. </if>
  93. <if test="pageVO.bedId != null">
  94. and ei.bed_id = #{pageVO.bedId}
  95. </if>
  96. <if test="pageVO.roomName != null and pageVO.roomName != '' ">
  97. and ei.room_name like concat('%', #{pageVO.roomName}, '%')
  98. </if>
  99. <if test="pageVO.nurseLevelId != null">
  100. and ei.nurse_level_id = #{pageVO.nurseLevelId}
  101. </if>
  102. <if test="pageVO.careType != null">
  103. and ei.care_type = #{pageVO.careType}
  104. </if>
  105. <if test="pageVO.hasExtra != null and pageVO.hasExtra == 1">
  106. and ei.hasExtra is not null and ei.hasExtra != ''
  107. </if>
  108. <if test="pageVO.hasExtra != null and pageVO.hasExtra == 0">
  109. and ei.hasExtra is null and ei.hasExtra == ''
  110. </if>
  111. <if test="pageVO.checkInTime != null">
  112. and ei.create_time between #{pageVO.checkInTime[0]} and #{pageVO.checkInTime[1]}
  113. </if>
  114. <if test="pageVO.orgType != null">
  115. and ei.org_type = #{pageVO.orgType}
  116. </if>
  117. <if test="pageVO.tenantIds != null">
  118. and ei.tenant_id in
  119. <foreach item="id" collection="pageVO.tenantIds" open="(" separator="," close=")">
  120. #{id}
  121. </foreach>
  122. </if>
  123. <if test="pageVO.orderByClause != null and pageVO.orderByClause != ''">
  124. ORDER BY ${pageVO.orderByClause}
  125. </if>
  126. </select>
  127. <select id="findBpmPage" resultType="cn.iocoder.yudao.module.system.api.bpm.vo.ElderlyCheckinInfoRespVO">
  128. SELECT
  129. ei.*,
  130. bbf.`status` AS "bpmStatus",
  131. bbf.process_instance_id,
  132. st.name as tenantName
  133. FROM
  134. elderly_info ei
  135. INNER JOIN elderly_retreat_record err ON ei.id = err.elderly_id AND apply_type = 0
  136. INNER JOIN bpm_business_form bbf ON bbf.business_id = err.id AND type = 1
  137. LEFT JOIN system_tenant st ON st.id = ei.tenant_id
  138. where err.current_flag = 0 AND err.deleted = 0
  139. <if test="pageVO.elderName != null and pageVO.elderName != '' ">
  140. and ei.elder_name like concat('%', #{pageVO.elderName}, '%')
  141. </if>
  142. <if test="pageVO.elderSex != null and pageVO.elderSex != '' ">
  143. and ei.elder_sex = #{pageVO.elderSex}
  144. </if>
  145. <if test="pageVO.inStatus != null">
  146. and ei.in_status = #{pageVO.inStatus}
  147. </if>
  148. <if test="pageVO.checkInTime != null">
  149. and ei.create_time between #{pageVO.checkInTime[0]} and #{pageVO.checkInTime[1]}
  150. </if>
  151. <if test="pageVO.orgType != null">
  152. and ei.org_type = #{pageVO.orgType}
  153. </if>
  154. <if test="pageVO.tenantIds != null">
  155. and ei.tenant_id in
  156. <foreach item="id" collection="pageVO.tenantIds" open="(" separator="," close=")">
  157. #{id}
  158. </foreach>
  159. </if>
  160. <if test="pageVO.orgType"></if>
  161. order by ei.update_time desc
  162. </select>
  163. <select id="elderlyCheckInRecordPage"
  164. resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyCheckInRecordDO">
  165. select t1.*,t2.elder_name,t2.elder_sex,t2.in_status_type,t2.nurse_level_name from elderly_check_in_record t1
  166. inner join elderly_info t2 on t1.elder_id = t2.id
  167. where 1 = 1
  168. <if test="params.elderName != null and params.elderName != '' ">
  169. and t2.elder_name like concat('%',#{params.elderName} ,'%')
  170. </if>
  171. <if test="params.status != null">
  172. and t1.status = #{params.status}
  173. </if>
  174. <if test="params.inStatusType != null">
  175. and t2.in_status_type = #{params.inStatusType}
  176. </if>
  177. <if test="params.checkInTime != null">
  178. and t1.check_in_time between #{params.checkInTime[0]} and #{params.checkInTime[1]}
  179. </if>
  180. <if test="params.orgType != null">
  181. and t2.org_type = #{params.orgType}
  182. </if>
  183. <if test="params.tenantIds != null">
  184. and t2.tenant_id in
  185. <foreach item="id" collection="params.tenantIds" open="(" separator="," close=")">
  186. #{id}
  187. </foreach>
  188. </if>
  189. order by t1.created_time desc,t1.status asc
  190. </select>
  191. <select id="getElderListByBuild" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  192. select * from elderly_info
  193. <where>
  194. 1 = 1
  195. <if test="buildId != null">
  196. and build_id = #{buildId}
  197. </if>
  198. <if test="floorId != null">
  199. and floor_id = #{floorId}
  200. </if>
  201. <if test="roomId != null">
  202. and room_id = #{roomId}
  203. </if>
  204. <if test="tenantIds != null">
  205. and tenant_id in
  206. <foreach item="id" collection="tenantIds" open="(" separator="," close=")">
  207. #{id}
  208. </foreach>
  209. </if>
  210. </where>
  211. </select>
  212. <select id="getElderlyMedicationExecutionPage"
  213. resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.ElderlyMedicationExecutionRespVO">
  214. 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
  215. <where>
  216. 1 = 1
  217. <if test="params.elderName != null and params.elderName != ''">
  218. and ei.elder_name like concat('%',#{params.elderName} ,'%')
  219. </if>
  220. <if test="params.bedId != null">
  221. and ei.bed_id = #{params.bedId}
  222. </if>
  223. <if test="params.executeStatus != null">
  224. and ebr.execute_status = #{params.executeStatus}
  225. </if>
  226. <if test="params.orgType != null">
  227. and ei.org_type = #{params.orgType}
  228. </if>
  229. <if test="params.tenantId != null">
  230. and ei.tenant_id = #{params.tenantId}
  231. </if>
  232. </where>
  233. order by ei.id desc
  234. </select>
  235. <select id="getCheckInDetail" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.CheckInRecordDetailRespVO">
  236. SELECT
  237. ecir.*,
  238. ei.elder_name,
  239. ei.id AS elder_id,
  240. ei.elder_sex,
  241. ei.elder_age,
  242. ei.in_status_type,
  243. ei.nurse_level_name,
  244. ei.id_card,
  245. ei.bed_id,
  246. ei.tenant_id,
  247. bbf.status AS bpmStatus,
  248. bbf.process_instance_id,
  249. bbf.type,
  250. cia.contract_json,
  251. cia.monthly_expenses_json,
  252. cia.one_time_expenses_json,
  253. cia.stage_expenses_json,
  254. cia.total_amount,
  255. cia.remark,
  256. cia.check_in_time,
  257. cia.check_in_deadline_time,
  258. cia.nurse_level_id,
  259. cia.is_private_room,
  260. cia.special_care_notes
  261. FROM
  262. elderly_check_in_record ecir
  263. INNER JOIN elderly_info ei ON ecir.elder_id = ei.id
  264. INNER JOIN bpm_business_form bbf ON ecir.id = bbf.business_id AND bbf.type = 9
  265. INNER JOIN check_in_apply cia ON ecir.associate_id = cia.id
  266. WHERE ecir.id = #{id}
  267. </select>
  268. <select id="selectCountByParam" resultType="java.lang.Integer">
  269. SELECT COUNT(1) FROM elderly_info
  270. <where>
  271. 1 = 1
  272. <if test="inStatus != null">
  273. and in_status = #{inStatus}
  274. </if>
  275. <if test="checkInTime != null and checkOutFlag == 0">
  276. and DATE_FORMAT(check_in_time, '%Y-%m') <![CDATA[ = ]]> #{checkInTime}
  277. </if>
  278. <if test="checkInTime != null and checkOutFlag == 1">
  279. and DATE_FORMAT(check_in_time, '%Y-%m') <![CDATA[ <= ]]> #{checkInTime}
  280. </if>
  281. <if test="checkOutTime != null and checkOutFlag == 0">
  282. and DATE_FORMAT(check_out_time, '%Y-%m') = #{checkOutTime}
  283. </if>
  284. <if test="checkOutTime != null and checkOutFlag == 1">
  285. and (DATE_FORMAT(check_out_time, '%Y-%m') <![CDATA[ < ]]> #{checkOutTime} or check_out_time is NULL)
  286. </if>
  287. <if test="tenantId != null">
  288. and tenant_id = #{tenantId}
  289. </if>
  290. </where>
  291. </select>
  292. <select id="selectTryStayCount" resultType="java.lang.Integer">
  293. SELECT
  294. COUNT(*)
  295. FROM
  296. elderly_info
  297. WHERE
  298. in_status_type = 2
  299. <if test="reqVO.currentDate != null">
  300. AND DATE_FORMAT(check_in_time, '%Y-%m') = DATE_FORMAT(#{reqVO.currentDate}, '%Y-%m')
  301. </if>
  302. <if test="reqVO.tenantIds != null">
  303. AND tenant_id IN
  304. <foreach item="id" collection="reqVO.tenantIds" open="(" separator="," close=")">
  305. #{id}
  306. </foreach>
  307. </if>
  308. </select>
  309. <select id="selectGoOutCount" resultType="java.lang.Integer">
  310. SELECT
  311. COUNT(*)
  312. FROM
  313. elderly_ask_leave
  314. WHERE
  315. status = 0
  316. <if test="reqVO.currentDate != null">
  317. AND DATE_FORMAT(out_date, '%Y-%m') = DATE_FORMAT(#{reqVO.currentDate}, '%Y-%m')
  318. </if>
  319. <if test="reqVO.tenantIds != null">
  320. AND tenant_id IN
  321. <foreach item="id" collection="reqVO.tenantIds" open="(" separator="," close=")">
  322. #{id}
  323. </foreach>
  324. </if>
  325. </select>
  326. <select id="selectCurrentCheckInCount" resultType="java.lang.Integer">
  327. SELECT
  328. COUNT(*)
  329. FROM
  330. elderly_info
  331. WHERE
  332. in_status = 1
  333. <if test="reqVO.currentDate != null">
  334. AND DATE_FORMAT(check_in_time, '%Y-%m') = DATE_FORMAT(#{reqVO.currentDate}, '%Y-%m')
  335. </if>
  336. <if test="reqVO.tenantIds != null">
  337. AND tenant_id IN
  338. <foreach item="id" collection="reqVO.tenantIds" open="(" separator="," close=")">
  339. #{id}
  340. </foreach>
  341. </if>
  342. </select>
  343. <select id="selectVitalSignsList" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.ElderlyVitalSignsStatisticsRespVO">
  344. SELECT
  345. ei.id AS elderId,
  346. ei.elder_name,
  347. ei.elder_age,
  348. ei.elder_sex,
  349. eei.item_name,
  350. ei.tenant_id
  351. FROM
  352. elderly_info ei
  353. INNER JOIN elderly_expense ee ON ei.id = ee.elder_id
  354. AND ei.tenant_id = ee.tenant_id
  355. INNER JOIN elderly_expense_item eei ON eei.expense_id = ee.id
  356. AND ei.tenant_id = eei.tenant_id
  357. INNER JOIN sys_charge_category scc ON scc.id = eei.item_category_id
  358. AND ei.tenant_id = scc.tenant_id
  359. WHERE
  360. ei.in_status = 1
  361. AND ee.created_time = ( SELECT MAX( ee2.created_time ) FROM elderly_expense ee2 WHERE ee2.elder_id = ei.id )
  362. AND scc.identification = 2
  363. AND ei.tenant_id IN
  364. <foreach item="id" collection="pageReqVO.tenantIds" open="(" separator="," close=")">
  365. #{id}
  366. </foreach>
  367. </select>
  368. <select id="selectVitalSignsTodayList" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.ElderlyVitalSignsStatisticsTodayRespVO">
  369. SELECT
  370. ei.id AS elderId,
  371. ei.elder_name,
  372. ei.elder_age,
  373. ei.elder_sex,
  374. ei.tenant_id,
  375. evs.measuring_time,
  376. evs.systolic_pressure,
  377. evs.diastolic_pressure
  378. FROM
  379. elderly_vital_signs evs
  380. INNER JOIN elderly_info ei ON evs.elder_id = ei.id AND evs.tenant_id = ei.tenant_id
  381. WHERE
  382. DATE_FORMAT(evs.measuring_time, '%Y-%m-%d') = DATE_FORMAT(#{pageReqVO.currentDate}, '%Y-%m-%d')
  383. <if test="pageReqVO.buildId">
  384. AND ei.build_id = #{pageReqVO.buildId}
  385. </if>
  386. <if test="pageReqVO.floorId">
  387. AND ei.floor_id = #{pageReqVO.floorId}
  388. </if>
  389. AND ei.tenant_id IN
  390. <foreach item="id" collection="pageReqVO.tenantIds" open="(" separator="," close=")">
  391. #{id}
  392. </foreach>
  393. AND (evs.systolic_pressure <![CDATA[ < ]]> #{pageReqVO.systolicPressureMin} OR evs.systolic_pressure <![CDATA[ > ]]> #{pageReqVO.systolicPressureMax})
  394. OR (evs.diastolic_pressure <![CDATA[ < ]]> #{pageReqVO.diastolicPressureMin} OR evs.diastolic_pressure <![CDATA[ > ]]> #{pageReqVO.diastolicPressureMax})
  395. ORDER BY evs.measuring_date,evs.measuring_time DESC
  396. </select>
  397. <select id="selectExportListWithBedInfo" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  398. SELECT
  399. ei.id,
  400. ei.elder_name AS elderName,
  401. ob.build_name AS buildName,
  402. obf.floor_name AS floorName,
  403. obr.room_name AS roomName,
  404. CONCAT_WS('-', ob.build_name, obf.floor_name, obr.room_name, obb.bed_name) AS bedName,
  405. ei.bed_id AS bedId,
  406. ei.tenant_id AS tenantId
  407. FROM elderly_info ei
  408. LEFT JOIN org_build_bed obb ON obb.id = ei.bed_id AND obb.tenant_id = ei.tenant_id
  409. LEFT JOIN org_build_room obr ON obr.id = obb.room_id AND obr.tenant_id = obb.tenant_id
  410. LEFT JOIN org_build_floor obf ON obf.id = obr.floor_id AND obf.tenant_id = obr.tenant_id
  411. LEFT JOIN org_build ob ON ob.id = obf.build_id AND ob.tenant_id = obf.tenant_id
  412. WHERE ei.tenant_id = #{tenantId}
  413. AND ei.deleted = 0
  414. AND ei.in_status = 1
  415. AND ei.bed_id IS NOT NULL
  416. ORDER BY ob.build_name, obf.floor_name, obr.room_name, obb.bed_name, ei.elder_name
  417. </select>
  418. <select id="selectByIdIgnoreDeleted" resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyInfoDO">
  419. SELECT *
  420. FROM elderly_info
  421. WHERE id = #{id}
  422. </select>
  423. </mapper>