MedKids.xml 6.9 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
<?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.lymsh.yimiao.main.data.dao.MedKidsMapper">

<resultMap id="MedKidsResultMap" type="com.lymsh.yimiao.main.data.model.MedKids">
<result column="ki_id" property="id" jdbcType="VARCHAR" />
<result column="ki_name" property="name" jdbcType="VARCHAR" />
<result column="ki_sex" property="sex" jdbcType="VARCHAR" />
<result column="ki_birthday" property="birthday" jdbcType="VARCHAR" />
<result column="ki_guardianid" property="guardianId" jdbcType="VARCHAR" />
<result column="ki_currentOrganizationid" property="currentOrganizationId" jdbcType="VARCHAR" />
<result column="ki_barCode" property="barCode" jdbcType="VARCHAR" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="ki_buildoper" property="buildOPer" jdbcType="VARCHAR" />
<result column="ki_buildtime" property="buildTime" jdbcType="VARCHAR" />
<result column="isdelete" property="isDelete" jdbcType="VARCHAR" />
</resultMap>

<select id="getMedKids" resultMap="MedKidsResultMap" parameterType="java.lang.String">
select ki_id,ki_name,ki_sex,ki_birthday,ki_guardianid,ki_currentOrganizationid,ki_barCode,phone,ki_buildoper, ki_buildtime,isdelete,fathername,mothername
from med_kids
WHERE ki_id = #{id,jdbcType=VARCHAR}
</select>


<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>



<sql id="MedKidsCondition">
<where>
1 = 1
<if test="id != null and id != ''">
and ki_id in (#{id,jdbcType=VARCHAR})
</if>
<if test="name != null and name != ''">
and ki_name = #{name,jdbcType=VARCHAR}
</if>
<if test="sex != null and sex != ''">
and ki_sex = #{sex,jdbcType=VARCHAR}
</if>
<if test="birthday != null and birthday != ''">
and ki_birthday = #{birthday,jdbcType=VARCHAR}
</if>
<if test="guardianId != null and guardianId != ''">
and ki_guardianid = #{guardianId,jdbcType=VARCHAR}
</if>
<if test="currentOrganizationId != null and currentOrganizationId != ''">
and ki_currentOrganizationid = #{currentOrganizationId,jdbcType=VARCHAR}
</if>
<if test="barCode != null and barCode != ''">
and ki_barCode = #{barCode,jdbcType=VARCHAR}
</if>
<if test="phone != null and barCode != ''">
and phone = #{phone,jdbcType=VARCHAR}
</if>
<if test="buildOPer != null and buildOPer != ''">
and ki_buildoper = #{buildOPer,jdbcType=VARCHAR}
</if>
<if test="buildTime != null and buildTime != ''">
and ki_buildtime = #{buildTime,jdbcType=VARCHAR}
</if>
<if test="isDelete != null and isDelete != ''">
and isdelete = #{isDelete,jdbcType=VARCHAR}
</if>
<if test="ids != null ">
and ki_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
</where>
</sql>



<select id="queryMedKids" resultMap="MedKidsResultMap" parameterType="com.lymsh.yimiao.main.data.model.MedKidsQuery">
select ki_name,ki_id,ki_sex,ki_birthday,ki_guardianid,ki_currentOrganizationid,ki_barCode,phone,ki_buildoper, ki_buildtime,isdelete,fathername,mothername
from med_kids
<include refid="MedKidsCondition" />
<include refid="orderAndLimit" />
</select>



<select id="queryMedKidsCount" resultType="int" parameterType="com.lymsh.yimiao.main.data.model.MedKidsQuery">
select count(1) from med_kids
<include refid="MedKidsCondition" />
</select>


<resultMap id="KidInoculationRecordMap" type="com.lymsh.yimiao.main.data.model.KidInoculationRecords">
<result column="KI_BIRTHDAY" property="birthday" jdbcType="VARCHAR" />
<result column="IC_KIDID" property="recordKidId" jdbcType="VARCHAR" />
<result column="IC_ID" property="recordId" jdbcType="VARCHAR" />
<result column="IC_VACCINEID" property="vaccineInfoId" jdbcType="VARCHAR" />
<result column="IC_INOCULATETIME" property="inoculateTime" jdbcType="VARCHAR" />
<result column="MONTH_AGE" property="monthAge" jdbcType="VARCHAR" />
<result column="IC_JICI" property="jiCi" jdbcType="VARCHAR" />
<result column="VI_NAME" property="vaccineInfoName" jdbcType="VARCHAR" />
<result column="VN_NAME" property="vaccineNameTitle" jdbcType="VARCHAR" />
<result column="VN_VACCINETYPE" property="vaccineType" jdbcType="VARCHAR" />
<result column="CNT" property="cnt" jdbcType="INTEGER" />
<result column="VN_ID" property="vaccineNameId" jdbcType="VARCHAR" />
</resultMap>

<select id="queryInoculationRecord" resultMap="KidInoculationRecordMap" parameterType="java.lang.String">
SELECT D.KI_NAME,
TO_DATE(D.KI_BIRTHDAY,'YYYY/MM/DD') AS KI_BIRTHDAY,
B.IC_KIDID,
B.IC_ID,
B.IC_VACCINEID,
TO_DATE(B.IC_INOCULATETIME,'YYYY/MM/DD') AS IC_INOCULATETIME,
TRUNC(MONTHS_BETWEEN(TO_DATE(B.IC_INOCULATETIME,'YYYY/MM/DD'),TO_DATE(D.KI_BIRTHDAY,'YYYY/MM/DD'))) AS MONTH_AGE,
B.IC_JICI,
C.VI_NAME,
A.VN_NAME,
A.VN_ID,
A.VN_VACCINETYPE,
CCC.CNT
FROM med_InoculateRecord B
INNER JOIN med_Vaccineinfo C ON B.IC_VACCINEID=C.VI_ID AND C.ISDELETE=1
INNER JOIN med_VaccineName A ON C.VI_VACCINENAMEID=A.VN_ID AND A.ISDELETE=1
INNER JOIN MED_KIDS D ON B.IC_KIDID=D.KI_ID
INNER JOIN (SELECT AA.VN_NAME,COUNT(DISTINCT b.column_value) AS CNT
FROM med_VaccineName AA, table(splitstr(AA.VN_MONTHAGE, ',')) b
WHERE AA.VN_MONTHAGE IS NOT NULL
AND AA.ISDELETE = 1
GROUP BY AA.VN_NAME) CCC ON A.VN_NAME=CCC.VN_NAME
WHERE B.IC_DELETE = 1
AND B.IC_KIDID= #{recordKidId,jdbcType=VARCHAR}
ORDER BY IC_INOCULATETIME DESC
</select>


<select id="queryInoculationRecords" resultMap="KidInoculationRecordMap" parameterType="com.lymsh.yimiao.main.data.model.MedInoculateRecordQuery">
SELECT D.KI_NAME,
TO_DATE(D.KI_BIRTHDAY,'YYYY/MM/DD') AS KI_BIRTHDAY,
B.IC_KIDID,
B.IC_ID,
B.IC_VACCINEID,
TO_DATE(B.IC_INOCULATETIME,'YYYY/MM/DD') AS IC_INOCULATETIME,
TRUNC(MONTHS_BETWEEN(TO_DATE(B.IC_INOCULATETIME,'YYYY/MM/DD'),TO_DATE(D.KI_BIRTHDAY,'YYYY/MM/DD'))) AS MONTH_AGE,
B.IC_JICI,
C.VI_NAME,
A.VN_NAME,
A.VN_ID,
A.VN_VACCINETYPE,
CCC.CNT
FROM med_InoculateRecord B
INNER JOIN med_Vaccineinfo C ON B.IC_VACCINEID=C.VI_ID AND C.ISDELETE=1
INNER JOIN med_VaccineName A ON C.VI_VACCINENAMEID=A.VN_ID AND A.ISDELETE=1 AND A.VN_ISINPLAN = 1
INNER JOIN MED_KIDS D ON B.IC_KIDID=D.KI_ID
INNER JOIN (SELECT AA.VN_NAME,COUNT(DISTINCT b.column_value) AS CNT
FROM med_VaccineName AA, table(splitstr(AA.VN_MONTHAGE, ',')) b
WHERE AA.VN_MONTHAGE IS NOT NULL
AND AA.ISDELETE = 1
GROUP BY AA.VN_NAME) CCC ON A.VN_NAME=CCC.VN_NAME
WHERE B.IC_DELETE = 1
AND B.IC_KIDID= #{recordKidId,jdbcType=VARCHAR}
<include refid="orderAndLimit" />
</select>

</mapper>