patientMemo.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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="com.lemon.lifecenter.mapper.PatientMemoMapper">
  4. <insert id="insertMemo" parameterType="PatientMemoDTO" useGeneratedKeys="true">
  5. <![CDATA[
  6. INSERT INTO patient_memo (patient_idx, contents, recorded_by_name, recorded_by_id, recorded_date, update_date, create_date)
  7. VALUE (#{patientIdx}, #{contents}, #{recordedByName}, #{recordedById}
  8. ]]>
  9. <choose>
  10. <when test='recordedDate != null and recordedDate != ""'>
  11. <![CDATA[
  12. , #{recordedDate}, NOW(), NOW())
  13. ]]>
  14. </when>
  15. <otherwise>
  16. <![CDATA[
  17. , NOW(), NOW(), NOW())
  18. ]]>
  19. </otherwise>
  20. </choose>
  21. </insert>
  22. <select id="selectMemoCount" parameterType="PatientMemoDTO" resultType="int">
  23. <![CDATA[
  24. SELECT count(*) AS total
  25. FROM patient_memo
  26. WHERE patient_idx = #{patientIdx}
  27. ]]>
  28. </select>
  29. <select id="selectMemoList" parameterType="PatientMemoDTO" resultType="PatientMemoDTO">
  30. <![CDATA[
  31. SELECT idx,
  32. update_date AS updateDate,
  33. create_date AS createDate,
  34. contents AS contents,
  35. recorded_by_id AS recordedById,
  36. recorded_by_name AS recordedByName,
  37. recorded_date AS recordedDate
  38. FROM patient_memo
  39. WHERE
  40. patient_idx = #{patientIdx}
  41. ORDER BY recorded_date DESC, idx DESC
  42. ]]>
  43. </select>
  44. <update id="updateMemo" parameterType="PatientMemoDTO">
  45. <![CDATA[
  46. UPDATE patient_memo
  47. SET contents = #{contents},
  48. update_date = NOW(),
  49. ]]>
  50. <choose>
  51. <when test='recordedDate != null and recordedDate != ""'>
  52. <![CDATA[
  53. recorded_date = #{recordedDate}
  54. ]]>
  55. </when>
  56. <otherwise>
  57. <![CDATA[
  58. recorded_date = NOW()
  59. ]]>
  60. </otherwise>
  61. </choose>
  62. <![CDATA[
  63. WHERE idx = #{idx}
  64. ]]>
  65. </update>
  66. <delete id="deleteMemo" parameterType="PatientMemoDTO">
  67. <![CDATA[
  68. DELETE
  69. FROM patient_memo
  70. WHERE idx = #{idx}
  71. ]]>
  72. </delete>
  73. </mapper>