ElderlyInfoMapper.xml 18 KB

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