|  |  | 
 |  |  |         b.futypecode, | 
 |  |  |         b.futypedesc, | 
 |  |  |         b.fuadvice, | 
 |  |  |         b.fuspecialadvice | 
 |  |  |         b.fuspecialadvice, | 
 |  |  |         a.idcardno | 
 |  |  |         FROM | 
 |  |  |         pat_med_inhosp b | 
 |  |  |         JOIN | 
 |  |  | 
 |  |  |             FROM pat_med_outhosp | 
 |  |  |             <where> | 
 |  |  |                 del_flag=0 | 
 |  |  |                 <if test="deptcodeList != null"> | 
 |  |  |                 <if test="deptcodeList != null   and deptcodeList.size() > 0"> | 
 |  |  |                     and deptcode in | 
 |  |  |                     <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> | 
 |  |  |                         #{deptcode} | 
 |  |  | 
 |  |  |             <where> | 
 |  |  |                 del_flag=0 | 
 |  |  |                 and inhospstate=0 | 
 |  |  |                 <if test="deptcodeList != null"> | 
 |  |  |                 <if test="deptcodeList != null   and deptcodeList.size() > 0"> | 
 |  |  |                     and deptcode in | 
 |  |  |                     <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> | 
 |  |  |                         #{deptcode} | 
 |  |  | 
 |  |  |             <where> | 
 |  |  |                 del_flag=0 | 
 |  |  |                 and inhospstate=1 | 
 |  |  |                 <if test="deptcodeList != null"> | 
 |  |  |                 <if test="deptcodeList != null   and deptcodeList.size() > 0"> | 
 |  |  |                     and deptcode in | 
 |  |  |                     <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> | 
 |  |  |                         #{deptcode} | 
 |  |  | 
 |  |  |             <where> | 
 |  |  |                 del_flag=0 | 
 |  |  |                 and inhospstate=1 | 
 |  |  |                 <if test="deptcodeList != null"> | 
 |  |  |                 <if test="deptcodeList != null   and deptcodeList.size() > 0"> | 
 |  |  |                     and deptcode in | 
 |  |  |                     <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> | 
 |  |  |                         #{deptcode} | 
 |  |  | 
 |  |  |         </if> | 
 |  |  |         ) AS combined | 
 |  |  |         GROUP BY deptname; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     </select> | 
 |  |  |     <select id="selectPatMedInhospCount" parameterType="com.smartor.domain.PatMedReq" | 
 |  |  |             resultType="com.smartor.domain.PatMedRes"> | 
 |  |  | 
 |  |  |                 and date_format(endtime,'%y%m%d') >= date_format(#{startDate},'%y%m%d') | 
 |  |  |                 and date_format(endtime,'%y%m%d') <= date_format(#{endDate},'%y%m%d') | 
 |  |  |             </if> | 
 |  |  |             <if test="deptcodeList != null"> | 
 |  |  |             <if test="deptcodeList != null   and deptcodeList.size() > 0"> | 
 |  |  |                 and deptcode in | 
 |  |  |                 <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> | 
 |  |  |                     #{deptcode} |