BehospitalInfoMapper.xml 167 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  7. <id column="behospital_code" property="behospitalCode"/>
  8. <result column="hospital_id" property="hospitalId"/>
  9. <result column="name" property="name"/>
  10. <result column="sex" property="sex"/>
  11. <result column="birthday" property="birthday"/>
  12. <result column="file_code" property="fileCode"/>
  13. <result column="qc_type_id" property="qcTypeId"/>
  14. <result column="ward_code" property="wardCode"/>
  15. <result column="ward_name" property="wardName"/>
  16. <result column="beh_dept_id" property="behDeptId"/>
  17. <result column="beh_dept_name" property="behDeptName"/>
  18. <result column="bed_code" property="bedCode"/>
  19. <result column="bed_name" property="bedName"/>
  20. <result column="insurance_name" property="insuranceName"/>
  21. <result column="job_type" property="jobType"/>
  22. <result column="behospital_date" property="behospitalDate"/>
  23. <result column="leave_hospital_date" property="leaveHospitalDate"/>
  24. <result column="diagnose_icd" property="diagnoseIcd"/>
  25. <result column="diagnose" property="diagnose"/>
  26. <result column="beh_doctor_id" property="behDoctorId"/>
  27. <result column="beh_doctor_name" property="behDoctorName"/>
  28. <result column="doctor_id" property="doctorId"/>
  29. <result column="doctor_name" property="doctorName"/>
  30. <result column="director_doctor_id" property="directorDoctorId"/>
  31. <result column="director_doctor_name" property="directorDoctorName"/>
  32. <result column="is_placefile" property="isPlacefile"/>
  33. <result column="placefile_date" property="placefileDate"/>
  34. <result column="is_deleted" property="isDeleted"/>
  35. <result column="gmt_create" property="gmtCreate"/>
  36. <result column="gmt_modified" property="gmtModified"/>
  37. <result column="creator" property="creator"/>
  38. <result column="modifier" property="modifier"/>
  39. </resultMap>
  40. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  41. SELECT * FROM (
  42. select t.*,
  43. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END checkStatus
  44. from (
  45. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  46. grade_time, c.age from med_behospital_info a
  47. LEFT JOIN med_qcresult_info b
  48. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  49. left join med_home_page c
  50. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  51. ) t
  52. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N') g
  53. ON t.behospital_code = g.behospital_code
  54. AND t.hospital_id = g.hospital_id
  55. where t.is_deleted = 'N'
  56. <if test="deptId != null and deptId != ''">
  57. and t.beh_dept_id = #{deptId}
  58. </if>
  59. <if test="doctorName != null and doctorName != ''">
  60. and CONCAT(
  61. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  62. like CONCAT('%',#{doctorName},'%')
  63. </if>
  64. <if test="name != null and name != ''">
  65. and t.name like CONCAT('%',#{name},'%')
  66. </if>
  67. <if test="doctorCode != null and doctorCode != ''">
  68. and (t.doctor_id = #{doctorCode}
  69. or t.beh_doctor_id = #{doctorCode}
  70. or t.director_doctor_id = #{doctorCode})
  71. </if>
  72. <if test="fileCode != null and fileCode != ''">
  73. and t.file_code like CONCAT('%',#{fileCode},'%')
  74. </if>
  75. <if test="hospitalId != null">
  76. and t.hospital_id = #{hospitalId}
  77. </if>
  78. <if test="behospitalCode != null and behospitalCode != ''">
  79. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  80. </if>
  81. <if test="behosDateStart != null">
  82. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  83. </if>
  84. <if test="behosDateEnd != null">
  85. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  86. </if>
  87. <if test="leaveHosDateStart != null">
  88. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  89. </if>
  90. <if test="leaveHosDateEnd != null">
  91. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  92. </if>
  93. <if test="level != null and level != ''">
  94. and t.level = #{level}
  95. </if>
  96. <if test="isPlacefile != null and isPlacefile != ''">
  97. and t.is_placefile = #{isPlacefile}
  98. </if>
  99. and t.qc_type_id != 0
  100. and t.is_placefile = 1) p
  101. where p.is_deleted="N"
  102. <if test="checkStatus != null ">
  103. and p.checkStatus = #{checkStatus}
  104. </if>
  105. </select>
  106. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  107. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  108. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
  109. c.opt_type, c.grade_type, c.gmt_create, c.gmt_modified
  110. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  111. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  112. and a.id = c.cases_entry_id
  113. and a.mode_id = b.id
  114. AND c.cases_id = d.cases_id
  115. and c.hospital_id = d.hospital_id
  116. and c.hospital_id = #{hospitalId}
  117. and c.behospital_code = #{behospitalCode}
  118. order by b.order_no, c.grade_type desc, a.order_no
  119. </select>
  120. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  121. SELECT b.id model_id,b.`name` model_name,
  122. d.score,d.msg,d.cases_entry_id,d.is_reject,
  123. a.cases_id cases_id, a.name standard_msg,a.code
  124. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  125. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  126. and a.mode_id = b.id
  127. and a.id = d.cases_entry_id
  128. and d.is_used = 1
  129. and d.hospital_id = #{hospitalId}
  130. and a.code in
  131. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  132. #{item}
  133. </foreach>
  134. <if test="modeId != null">
  135. and a.mode_id = #{modeId}
  136. </if>
  137. order by b.order_no, a.order_no;
  138. </select>
  139. <!-- 各科室缺陷占比-全院-首页 -->
  140. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  141. resultType="com.diagbot.dto.NumDTO">
  142. SELECT
  143. a.beh_dept_id as id,
  144. a.beh_dept_name as name,
  145. count(*) AS num
  146. FROM
  147. med_behospital_info a,
  148. med_qcresult_info c,
  149. med_qcresult_detail d
  150. WHERE
  151. a.behospital_code = c.behospital_code
  152. AND a.hospital_id = c.hospital_id
  153. AND a.behospital_code = d.behospital_code
  154. AND a.hospital_id = d.hospital_id
  155. AND a.is_deleted = 'N'
  156. AND c.is_deleted = 'N'
  157. AND d.is_deleted = 'N'
  158. AND a.is_placefile = '1'
  159. <![CDATA[AND a.qc_type_id <>0 ]]>
  160. <if test="hospitalId != null and hospitalId != ''">
  161. AND a.hospital_id = #{hospitalId}
  162. </if>
  163. <if test="startDate != null and startDate != ''">
  164. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  165. </if>
  166. <if test="endDate != null and endDate != ''">
  167. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  168. </if>
  169. GROUP BY
  170. a.beh_dept_id,
  171. a.beh_dept_name
  172. ORDER BY
  173. count(*) DESC
  174. </select>
  175. <!-- 质控结果缺陷总数查询-->
  176. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  177. SELECT
  178. count(*) AS totle
  179. FROM
  180. med_behospital_info a,
  181. med_qcresult_info c,
  182. med_qcresult_detail d
  183. WHERE
  184. a.behospital_code = c.behospital_code
  185. AND a.hospital_id = c.hospital_id
  186. AND a.behospital_code = d.behospital_code
  187. AND a.hospital_id = d.hospital_id
  188. AND a.is_deleted = 'N'
  189. AND c.is_deleted = 'N'
  190. AND d.is_deleted = 'N'
  191. AND a.is_placefile = '1'
  192. <![CDATA[AND a.qc_type_id <>0 ]]>
  193. <if test="hospitalId != null and hospitalId != ''">
  194. AND a.hospital_id = #{hospitalId}
  195. </if>
  196. <if test="startDate != null and startDate != ''">
  197. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  198. </if>
  199. <if test="endDate != null and endDate != ''">
  200. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  201. </if>
  202. </select>
  203. <!--获取病历-->
  204. <select id="getNoGrade" resultMap="BaseResultMap">
  205. select * from med_behospital_info a
  206. where a.is_deleted = 'N'
  207. and a.qc_type_id != 0
  208. and a.is_placefile = 1
  209. <if test="filterFlag != null and filterFlag == 0">
  210. and
  211. not EXISTS (
  212. SELECT
  213. 1
  214. FROM
  215. med_qcresult_info b
  216. WHERE
  217. b.is_deleted = 'N'
  218. AND a.hospital_id = b.hospital_id
  219. AND a.behospital_code = b.behospital_code
  220. )
  221. </if>
  222. <if test="leaveDate != null">
  223. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  224. </if>
  225. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  226. and a.hospital_id in
  227. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  228. #{item}
  229. </foreach>
  230. </if>
  231. <if test="individuation != null and individuation.contains(1)">
  232. union
  233. select * from med_behospital_info b
  234. where b.is_deleted = 'N'
  235. and b.qc_type_id != 0
  236. and b.is_placefile = 1
  237. <if test="startLeaveDate != null">
  238. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  239. </if>
  240. <if test="endLeaveDate != null">
  241. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  242. </if>
  243. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  244. and b.hospital_id in
  245. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  246. #{item}
  247. </foreach>
  248. </if>
  249. </if>
  250. </select>
  251. <!--质控评分(科室)分页-->
  252. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  253. SELECT * from (
  254. SELECT
  255. t.*,
  256. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END checkStatus
  257. FROM
  258. ( SELECT
  259. a.*,
  260. IFNULL(b.level, '未评分') AS `level`,
  261. b.grade_type,
  262. b.score_res,
  263. b.gmt_create AS grade_time,
  264. c.age
  265. FROM
  266. med_behospital_info a
  267. JOIN sys_user_dept d
  268. ON a.hospital_id = d.hospital_id
  269. AND a.beh_dept_id = d.dept_id
  270. LEFT JOIN med_qcresult_info b
  271. ON a.behospital_code = b.behospital_code
  272. AND b.is_deleted = 'N'
  273. LEFT JOIN med_home_page c
  274. ON a.behospital_code = c.behospital_code
  275. AND c.is_deleted = 'N'
  276. WHERE d.is_deleted = 'N'
  277. AND d.user_id = #{userId}
  278. ) t
  279. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N') g
  280. ON t.behospital_code = g.behospital_code
  281. AND t.hospital_id = g.hospital_id
  282. where t.is_deleted = 'N'
  283. <if test="deptId != null and deptId != ''">
  284. and t.beh_dept_id = #{deptId}
  285. </if>
  286. <if test="doctorName != null and doctorName != ''">
  287. and CONCAT(
  288. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  289. like CONCAT('%',#{doctorName},'%')
  290. </if>
  291. <if test="doctorCode != null and doctorCode != ''">
  292. and (t.doctor_id = #{doctorCode}
  293. or t.beh_doctor_id = #{doctorCode}
  294. or t.director_doctor_id = #{doctorCode})
  295. </if>
  296. <if test="name != null and name != ''">
  297. and t.name like CONCAT('%',#{name},'%')
  298. </if>
  299. <if test="fileCode != null and fileCode != ''">
  300. and t.file_code like CONCAT('%',#{fileCode},'%')
  301. </if>
  302. <if test="hospitalId != null">
  303. and t.hospital_id = #{hospitalId}
  304. </if>
  305. <if test="behospitalCode != null and behospitalCode != ''">
  306. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  307. </if>
  308. <if test="behosDateStart != null">
  309. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  310. </if>
  311. <if test="behosDateEnd != null">
  312. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  313. </if>
  314. <if test="leaveHosDateStart != null">
  315. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  316. </if>
  317. <if test="leaveHosDateEnd != null">
  318. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  319. </if>
  320. <if test="level != null and level != ''">
  321. and t.level = #{level}
  322. </if>
  323. <if test="isPlacefile != null and isPlacefile != ''">
  324. and t.is_placefile = #{isPlacefile}
  325. </if>
  326. and t.qc_type_id != 0
  327. and t.is_placefile = 1) p
  328. where p.is_deleted="N"
  329. <if test="checkStatus != null ">
  330. and p.checkStatus = #{checkStatus}
  331. </if>
  332. </select>
  333. <!--质控评分(个人)分页-->
  334. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  335. Select * from (
  336. select t.*,
  337. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END checkStatus
  338. from (SELECT
  339. a.*,
  340. IFNULL(b.level, '未评分') AS `level`,
  341. b.grade_type,
  342. b.score_res,
  343. b.gmt_create AS grade_time,
  344. c.age
  345. FROM
  346. med_behospital_info a
  347. JOIN
  348. (SELECT
  349. u.id,
  350. u.linkman AS linkman,
  351. uh.hospital_id
  352. FROM
  353. sys_user u
  354. JOIN sys_user_hospital uh
  355. ON u.id = uh.user_id
  356. WHERE u.is_deleted = "N"
  357. AND u.id = #{userId}
  358. AND uh.hospital_id = #{hospitalId}) u1
  359. ON a.hospital_id = u1.hospital_id
  360. LEFT JOIN med_qcresult_info b
  361. ON a.behospital_code = b.behospital_code
  362. AND b.is_deleted = 'N'
  363. LEFT JOIN med_home_page c
  364. ON a.behospital_code = c.behospital_code
  365. AND c.is_deleted = 'N'
  366. WHERE CONCAT(
  367. IFNULL(a.doctor_name, ''),
  368. IFNULL(a.beh_doctor_name, ''),
  369. IFNULL(a.director_doctor_name, '')
  370. ) LIKE CONCAT('%', u1.linkman, '%')
  371. ) t
  372. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N') g
  373. ON t.behospital_code = g.behospital_code
  374. AND t.hospital_id = g.hospital_id
  375. WHERE t.is_deleted = 'N'
  376. <if test="deptId != null and deptId != ''">
  377. and t.beh_dept_id = #{deptId}
  378. </if>
  379. <if test="name != null and name != ''">
  380. and t.name like CONCAT('%',#{name},'%')
  381. </if>
  382. <if test="fileCode != null and fileCode != ''">
  383. and t.file_code like CONCAT('%',#{fileCode},'%')
  384. </if>
  385. <if test="behospitalCode != null and behospitalCode != ''">
  386. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  387. </if>
  388. <if test="behosDateStart != null">
  389. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  390. </if>
  391. <if test="behosDateEnd != null">
  392. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  393. </if>
  394. <if test="leaveHosDateStart != null">
  395. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  396. </if>
  397. <if test="leaveHosDateEnd != null">
  398. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  399. </if>
  400. <if test="level != null and level != ''">
  401. and t.level = #{level}
  402. </if>
  403. <if test="isPlacefile != null and isPlacefile != ''">
  404. and t.is_placefile = #{isPlacefile}
  405. </if>
  406. and t.qc_type_id != 0
  407. and t.is_placefile = 1) p
  408. where p.is_deleted="N"
  409. <if test="checkStatus != null ">
  410. and p.checkStatus = #{checkStatus}
  411. </if>
  412. </select>
  413. <!--质控评分(医疗组)分页-->
  414. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  415. select * from (
  416. select t.*,
  417. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END checkStatus
  418. from (
  419. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  420. grade_time, c.age from med_behospital_info a
  421. LEFT JOIN med_qcresult_info b
  422. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  423. left join med_home_page c
  424. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  425. ) t
  426. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N') g
  427. ON t.behospital_code = g.behospital_code
  428. AND t.hospital_id = g.hospital_id
  429. WHERE t.is_deleted = 'N'
  430. and
  431. t.doctor_id in (
  432. SELECT doctor_id FROM `bas_doctor_info`
  433. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  434. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  435. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  436. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  437. and c1.username = c3.doctor_id
  438. and c2.hospital_id = #{hospitalId}
  439. and c1.id = #{userId}
  440. )
  441. )
  442. <if test="deptId != null and deptId != ''">
  443. and t.beh_dept_id = #{deptId}
  444. </if>
  445. <if test="doctorName != null and doctorName != ''">
  446. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  447. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  448. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  449. </if>
  450. <if test="name != null and name != ''">
  451. and t.name like CONCAT('%',#{name},'%')
  452. </if>
  453. <if test="doctorCode != null and doctorCode != ''">
  454. and (t.doctor_id = #{doctorCode}
  455. or t.beh_doctor_id = #{doctorCode}
  456. or t.director_doctor_id = #{doctorCode})
  457. </if>
  458. <if test="fileCode != null and fileCode != ''">
  459. and t.file_code like CONCAT('%',#{fileCode},'%')
  460. </if>
  461. <if test="hospitalId != null">
  462. and t.hospital_id = #{hospitalId}
  463. </if>
  464. <if test="behospitalCode != null and behospitalCode != ''">
  465. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  466. </if>
  467. <if test="behosDateStart != null">
  468. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  469. </if>
  470. <if test="behosDateEnd != null">
  471. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  472. </if>
  473. <if test="leaveHosDateStart != null">
  474. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  475. </if>
  476. <if test="leaveHosDateEnd != null">
  477. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  478. </if>
  479. <if test="level != null and level != ''">
  480. and t.level = #{level}
  481. </if>
  482. <if test="isPlacefile != null and isPlacefile != ''">
  483. and t.is_placefile = #{isPlacefile}
  484. </if>
  485. and t.qc_type_id != 0
  486. and t.is_placefile = 1) p
  487. where p.is_deleted="N"
  488. <if test="checkStatus != null ">
  489. and p.checkStatus = #{checkStatus}
  490. </if>
  491. </select>
  492. <!-- 出院总人数统计-全院-首页 -->
  493. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  494. SELECT
  495. COUNT(*)
  496. FROM
  497. med_behospital_info a
  498. WHERE
  499. a.is_deleted = 'N'
  500. AND a.is_placefile = '1'
  501. <if test="hospitalId != null and hospitalId != ''">
  502. AND a.hospital_id = #{hospitalId}
  503. </if>
  504. <if test="startDate != null and startDate != ''">
  505. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  506. </if>
  507. <if test="endDate != null and endDate != ''">
  508. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  509. </if>
  510. </select>
  511. <!-- 新生儿出院人数统计-全院-首页 -->
  512. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  513. SELECT
  514. COUNT(*)
  515. FROM
  516. med_behospital_info a,
  517. med_home_page b
  518. WHERE
  519. a.is_deleted = 'N'
  520. AND b.is_deleted = 'N'
  521. AND a.hospital_id = b.hospital_id
  522. AND a.behospital_code = b.behospital_code
  523. AND a.is_placefile = '1'
  524. -- AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
  525. AND (
  526. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' )
  527. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' )
  528. )
  529. <![CDATA[AND a.qc_type_id <>0 ]]>
  530. <if test="hospitalId != null and hospitalId != ''">
  531. AND a.hospital_id = #{hospitalId}
  532. </if>
  533. <if test="startDate != null and startDate != ''">
  534. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  535. </if>
  536. <if test="endDate != null and endDate != ''">
  537. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  538. </if>
  539. </select>
  540. <!-- 死亡人数统计-全院-首页 -->
  541. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  542. SELECT
  543. COUNT(*)
  544. FROM
  545. med_behospital_info a,
  546. med_home_page b
  547. WHERE
  548. a.is_deleted = 'N'
  549. AND b.is_deleted = 'N'
  550. AND a.hospital_id = b.hospital_id
  551. AND a.behospital_code = b.behospital_code
  552. AND b.return_to_type = '死亡'
  553. AND a.is_placefile = '1'
  554. <![CDATA[AND a.qc_type_id <>0 ]]>
  555. <if test="hospitalId != null and hospitalId != ''">
  556. AND a.hospital_id = #{hospitalId}
  557. </if>
  558. <if test="startDate != null and startDate != ''">
  559. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  560. </if>
  561. <if test="endDate != null and endDate != ''">
  562. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  563. </if>
  564. </select>
  565. <!-- 手术人数统计-全院-首页 -->
  566. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  567. SELECT
  568. COUNT( DISTINCT a.behospital_code )
  569. FROM
  570. med_behospital_info a,
  571. med_medical_record c,
  572. qc_mode d
  573. WHERE
  574. a.is_deleted = 'N'
  575. AND c.is_deleted = 'N'
  576. AND d.is_deleted = 'N'
  577. AND a.hospital_id = c.hospital_id
  578. AND a.behospital_code = c.behospital_code
  579. AND c.mode_id = d.id
  580. AND a.is_placefile = '1'
  581. AND d.`name` = '手术记录'
  582. <![CDATA[AND a.qc_type_id <>0 ]]>
  583. <if test="hospitalId != null and hospitalId != ''">
  584. AND a.hospital_id = #{hospitalId}
  585. </if>
  586. <if test="startDate != null and startDate != ''">
  587. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  588. </if>
  589. <if test="endDate != null and endDate != ''">
  590. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  591. </if>
  592. </select>
  593. <!-- 出院总人数统计-科室-首页 -->
  594. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  595. resultType="com.diagbot.dto.NumDTO">
  596. SELECT
  597. a.beh_dept_id AS id,
  598. a.beh_dept_name AS NAME,
  599. COUNT(*) AS num
  600. FROM
  601. med_behospital_info a,
  602. sys_user_dept c
  603. WHERE
  604. a.is_deleted = 'N'
  605. AND c.is_deleted = 'N'
  606. AND a.hospital_id = c.hospital_id
  607. AND a.beh_dept_id = c.dept_id
  608. AND a.is_placefile = '1'
  609. <if test="userId!=null">
  610. AND c.user_id = #{userId}
  611. </if>
  612. <if test="hospitalId != null and hospitalId != ''">
  613. AND a.hospital_id = #{hospitalId}
  614. </if>
  615. <if test="startDate != null and startDate != ''">
  616. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  617. </if>
  618. <if test="endDate != null and endDate != ''">
  619. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  620. </if>
  621. GROUP BY
  622. a.beh_dept_id,
  623. a.beh_dept_name
  624. </select>
  625. <!-- 新生儿出院人数统计-科室-首页 -->
  626. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  627. resultType="com.diagbot.dto.NumDTO">
  628. SELECT
  629. a.beh_dept_id AS id,
  630. a.beh_dept_name AS NAME,
  631. COUNT(*) AS num
  632. FROM
  633. med_behospital_info a,
  634. med_home_page b,
  635. sys_user_dept c
  636. WHERE
  637. a.is_deleted = 'N'
  638. AND b.is_deleted = 'N'
  639. AND c.is_deleted = 'N'
  640. AND a.hospital_id = b.hospital_id
  641. AND a.hospital_id = c.hospital_id
  642. AND a.behospital_code = b.behospital_code
  643. AND a.beh_dept_id = c.dept_id
  644. -- AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
  645. AND (
  646. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' )
  647. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' )
  648. )
  649. AND a.is_placefile = '1'
  650. <![CDATA[AND a.qc_type_id <>0 ]]>
  651. <if test="userId!=null">
  652. AND c.user_id = #{userId}
  653. </if>
  654. <if test="hospitalId != null and hospitalId != ''">
  655. AND a.hospital_id = #{hospitalId}
  656. </if>
  657. <if test="startDate != null and startDate != ''">
  658. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  659. </if>
  660. <if test="endDate != null and endDate != ''">
  661. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  662. </if>
  663. GROUP BY
  664. a.beh_dept_id,
  665. a.beh_dept_name
  666. </select>
  667. <!-- 死亡人数统计-科室-首页 -->
  668. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  669. resultType="com.diagbot.dto.NumDTO">
  670. SELECT
  671. a.beh_dept_id AS id,
  672. a.beh_dept_name AS NAME,
  673. COUNT(*) AS num
  674. FROM
  675. med_behospital_info a,
  676. med_home_page b,
  677. sys_user_dept c
  678. WHERE
  679. a.is_deleted = 'N'
  680. AND b.is_deleted = 'N'
  681. AND c.is_deleted = 'N'
  682. AND a.hospital_id = b.hospital_id
  683. AND a.hospital_id = c.hospital_id
  684. AND a.behospital_code = b.behospital_code
  685. AND a.beh_dept_id = c.dept_id
  686. AND b.return_to_type = '死亡'
  687. AND a.is_placefile = '1'
  688. <![CDATA[AND a.qc_type_id <>0 ]]>
  689. <if test="userId!=null">
  690. AND c.user_id = #{userId}
  691. </if>
  692. <if test="hospitalId != null and hospitalId != ''">
  693. AND a.hospital_id = #{hospitalId}
  694. </if>
  695. <if test="startDate != null and startDate != ''">
  696. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  697. </if>
  698. <if test="endDate != null and endDate != ''">
  699. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  700. </if>
  701. GROUP BY
  702. a.beh_dept_id,
  703. a.beh_dept_name
  704. </select>
  705. <!-- 手术人数统计-科室-首页 -->
  706. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  707. resultType="com.diagbot.dto.NumDTO">
  708. SELECT
  709. a.beh_dept_id AS id,
  710. a.beh_dept_name AS NAME,
  711. COUNT( DISTINCT a.behospital_code ) AS num
  712. FROM
  713. med_behospital_info a,
  714. sys_user_dept c,
  715. med_medical_record d,
  716. qc_mode e
  717. WHERE
  718. a.is_deleted = 'N'
  719. AND c.is_deleted = 'N'
  720. AND d.is_deleted = 'N'
  721. AND e.is_deleted = 'N'
  722. AND a.hospital_id = c.hospital_id
  723. AND a.hospital_id = d.hospital_id
  724. AND a.behospital_code = d.behospital_code
  725. AND a.beh_dept_id = c.dept_id
  726. AND d.mode_id = e.id
  727. AND e.`name` = '手术记录'
  728. AND a.is_placefile = '1'
  729. <![CDATA[AND a.qc_type_id <>0 ]]>
  730. <if test="userId!=null">
  731. AND c.user_id = #{userId}
  732. </if>
  733. <if test="hospitalId != null and hospitalId != ''">
  734. AND a.hospital_id = #{hospitalId}
  735. </if>
  736. <if test="startDate != null and startDate != ''">
  737. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  738. </if>
  739. <if test="endDate != null and endDate != ''">
  740. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  741. </if>
  742. GROUP BY
  743. a.beh_dept_id,
  744. a.beh_dept_name
  745. </select>
  746. <!-- 各科室缺陷占比排行(分页) -->
  747. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  748. SELECT t.*
  749. FROM
  750. (SELECT
  751. t1.beh_dept_name AS NAME,
  752. t1.num AS num,
  753. t2.totle AS totleNum,
  754. round( t1.num / t2.totle, 4 ) AS percent,
  755. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  756. FROM
  757. (
  758. SELECT
  759. a.beh_dept_id,
  760. a.beh_dept_name,
  761. count(*) AS num
  762. FROM
  763. med_behospital_info a,
  764. med_qcresult_info c,
  765. med_qcresult_detail d
  766. WHERE
  767. a.behospital_code = c.behospital_code
  768. AND a.hospital_id = c.hospital_id
  769. AND a.behospital_code = d.behospital_code
  770. AND a.hospital_id = d.hospital_id
  771. AND a.is_deleted = 'N'
  772. AND c.is_deleted = 'N'
  773. AND d.is_deleted = 'N'
  774. AND a.is_placefile = '1'
  775. <![CDATA[AND a.qc_type_id <>0 ]]>
  776. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  777. AND a.hospital_id = #{filterPageVO.hospitalId}
  778. </if>
  779. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  780. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  781. </if>
  782. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  783. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  784. </if>
  785. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  786. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  787. </if>
  788. GROUP BY
  789. a.beh_dept_id,
  790. a.beh_dept_name
  791. ORDER BY
  792. count(*) DESC
  793. ) t1,
  794. (
  795. SELECT
  796. count(*) AS totle
  797. FROM
  798. med_behospital_info a,
  799. med_qcresult_info c,
  800. med_qcresult_detail d
  801. WHERE
  802. a.behospital_code = c.behospital_code
  803. AND a.hospital_id = c.hospital_id
  804. AND a.behospital_code = d.behospital_code
  805. AND a.hospital_id = d.hospital_id
  806. AND a.is_deleted = 'N'
  807. AND c.is_deleted = 'N'
  808. AND d.is_deleted = 'N'
  809. AND a.is_placefile = '1'
  810. <![CDATA[AND a.qc_type_id <>0 ]]>
  811. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  812. AND a.hospital_id = #{filterPageVO.hospitalId}
  813. </if>
  814. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  815. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  816. </if>
  817. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  818. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  819. </if>
  820. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  821. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  822. </if>
  823. ) t2
  824. )t
  825. </select>
  826. <!-- 科室缺陷占比(主任医生) -->
  827. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  828. SELECT
  829. t.*
  830. FROM
  831. (
  832. SELECT
  833. t1.NAME,
  834. t1.num AS num,
  835. t2.totle AS totleNum,
  836. round( t1.num / t2.totle, 4 ) AS percent,
  837. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  838. FROM
  839. (
  840. SELECT
  841. d.msg as name,
  842. count(*) AS num
  843. FROM
  844. med_behospital_info a,
  845. med_qcresult_info c,
  846. med_qcresult_detail d,
  847. sys_user_dept e
  848. WHERE
  849. a.behospital_code = c.behospital_code
  850. AND a.hospital_id = c.hospital_id
  851. AND a.behospital_code = d.behospital_code
  852. AND a.hospital_id = d.hospital_id
  853. AND a.is_deleted = 'N'
  854. AND c.is_deleted = 'N'
  855. AND d.is_deleted = 'N'
  856. AND e.is_deleted = 'N'
  857. AND a.beh_dept_id = e.dept_id
  858. AND a.is_placefile = '1'
  859. <![CDATA[AND a.qc_type_id <>0 ]]>
  860. <if test="filterPageByDeptVO.userId!=null">
  861. AND e.user_id = #{filterPageByDeptVO.userId}
  862. </if>
  863. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  864. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  865. </if>
  866. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  867. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  868. </if>
  869. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  870. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  871. </if>
  872. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  873. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  874. </if>
  875. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  876. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  877. </if>
  878. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  879. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  880. </if>
  881. GROUP BY
  882. d.msg
  883. ORDER BY
  884. count(*) DESC
  885. ) t1,
  886. (
  887. SELECT
  888. count(*) AS totle
  889. FROM
  890. med_behospital_info a,
  891. med_qcresult_info c,
  892. med_qcresult_detail d,
  893. sys_user_dept e
  894. WHERE
  895. a.behospital_code = c.behospital_code
  896. AND a.hospital_id = c.hospital_id
  897. AND a.behospital_code = d.behospital_code
  898. AND a.hospital_id = d.hospital_id
  899. AND a.is_deleted = 'N'
  900. AND c.is_deleted = 'N'
  901. AND d.is_deleted = 'N'
  902. AND e.is_deleted = 'N'
  903. AND a.beh_dept_id = e.dept_id
  904. AND a.is_placefile = '1'
  905. <![CDATA[AND a.qc_type_id <>0 ]]>
  906. <if test="filterPageByDeptVO.userId!=null">
  907. AND e.user_id = #{filterPageByDeptVO.userId}
  908. </if>
  909. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  910. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  911. </if>
  912. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  913. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  914. </if>
  915. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  916. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  917. </if>
  918. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  919. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  920. </if>
  921. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  922. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  923. </if>
  924. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  925. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  926. </if>
  927. ) t2
  928. )t
  929. </select>
  930. <!-- 各科室缺陷占比(组合)-全院 -->
  931. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  932. resultType="com.diagbot.dto.LevelStatisticsDTO">
  933. SELECT
  934. t1.deptId,
  935. t1.deptName,
  936. t2.entryNum,
  937. t1.mrNum,
  938. t1.totleValue,
  939. t1.averageValue,
  940. t1.firstLevelNum,
  941. t1.secondLevelNum,
  942. t1.thirdLevelNum,
  943. t1.firstLevelPercent,
  944. t1.secondLevelPercent,
  945. t1.thirdLevelPercent,
  946. t1.firstLevelPercentStr,
  947. t1.secondLevelPercentStr,
  948. t1.thirdLevelPercentStr
  949. FROM
  950. (
  951. SELECT
  952. a.beh_dept_id AS deptId,
  953. a.beh_dept_name AS deptName,
  954. count(*) AS mrNum,
  955. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  956. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  957. SUM( c.`level` = '甲' ) AS firstLevelNum,
  958. SUM( c.`level` = '乙' ) AS secondLevelNum,
  959. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  960. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  961. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  962. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  963. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  964. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  965. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  966. FROM
  967. med_behospital_info a,
  968. med_qcresult_info c
  969. WHERE
  970. a.is_deleted = 'N'
  971. AND c.is_deleted = 'N'
  972. AND a.hospital_id = c.hospital_id
  973. AND a.behospital_code = c.behospital_code
  974. AND a.is_placefile = '1'
  975. AND a.qc_type_id != 0
  976. <if test="hospitalId != null and hospitalId != ''">
  977. AND a.hospital_id = #{hospitalId}
  978. </if>
  979. <if test="startDate != null and startDate != ''">
  980. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  981. </if>
  982. <if test="endDate != null and endDate != ''">
  983. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  984. </if>
  985. <if test="level != null and level != ''">
  986. and c.level = #{level}
  987. </if>
  988. <if test="name != null and name != ''">
  989. and a.beh_dept_name like CONCAT('%',#{name},'%')
  990. </if>
  991. GROUP BY
  992. a.beh_dept_id,
  993. a.beh_dept_name
  994. ) t1,
  995. (
  996. SELECT
  997. a.beh_dept_id AS deptId,
  998. a.beh_dept_name AS deptName,
  999. count( * ) AS entryNum
  1000. FROM
  1001. med_behospital_info a,
  1002. med_qcresult_info c,
  1003. med_qcresult_detail d,
  1004. qc_cases_entry e
  1005. WHERE
  1006. a.is_deleted = 'N'
  1007. AND c.is_deleted = 'N'
  1008. AND d.is_deleted = 'N'
  1009. AND e.is_deleted = 'N'
  1010. AND a.hospital_id = c.hospital_id
  1011. AND a.hospital_id = d.hospital_id
  1012. AND a.behospital_code = c.behospital_code
  1013. AND a.behospital_code = d.behospital_code
  1014. AND d.cases_id = e.cases_id
  1015. AND d.cases_entry_id = e.id
  1016. AND a.is_placefile = '1'
  1017. AND a.qc_type_id != 0
  1018. <if test="hospitalId != null and hospitalId != ''">
  1019. AND a.hospital_id = #{hospitalId}
  1020. </if>
  1021. <if test="startDate != null and startDate != ''">
  1022. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1023. </if>
  1024. <if test="endDate != null and endDate != ''">
  1025. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1026. </if>
  1027. <if test="level != null and level != ''">
  1028. and c.level = #{level}
  1029. </if>
  1030. <if test="name != null and name != ''">
  1031. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1032. </if>
  1033. GROUP BY
  1034. a.beh_dept_id,
  1035. a.beh_dept_name
  1036. ) t2
  1037. WHERE
  1038. t1.deptId = t2.deptId
  1039. AND t1.deptName = t2.deptName
  1040. <if test="asc != null and asc !=''">
  1041. order by
  1042. <choose>
  1043. <when test='asc=="deptId"'>deptId asc</when>
  1044. <when test='asc=="deptName"'>deptName asc</when>
  1045. <when test='asc=="entryNum"'>entryNum asc</when>
  1046. <when test='asc=="mrNum"'>mrNum asc</when>
  1047. <when test='asc=="totleValue"'>totleValue asc</when>
  1048. <when test='asc=="averageValue"'>averageValue asc</when>
  1049. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1050. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1051. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1052. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1053. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1054. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1055. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1056. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1057. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1058. <otherwise>deptName asc</otherwise>
  1059. </choose>
  1060. </if>
  1061. <if test="desc != null and desc!=''">
  1062. order by
  1063. <choose>
  1064. <when test='desc=="deptId"'>deptId desc</when>
  1065. <when test='desc=="deptName"'>deptName desc</when>
  1066. <when test='desc=="entryNum"'>entryNum desc</when>
  1067. <when test='desc=="mrNum"'>mrNum desc</when>
  1068. <when test='desc=="totleValue"'>totleValue desc</when>
  1069. <when test='desc=="averageValue"'>averageValue desc</when>
  1070. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1071. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1072. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1073. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1074. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1075. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1076. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1077. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1078. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1079. <otherwise>deptName desc</otherwise>
  1080. </choose>
  1081. </if>
  1082. </select>
  1083. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  1084. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  1085. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1086. SELECT
  1087. t1.deptId,
  1088. t1.deptName,
  1089. t1.deptClassId,
  1090. t1.deptClass,
  1091. t2.entryNum,
  1092. t1.mrNum,
  1093. t1.totleValue,
  1094. t1.averageValue,
  1095. t1.firstLevelNum,
  1096. t1.secondLevelNum,
  1097. t1.thirdLevelNum,
  1098. t1.firstLevelPercent,
  1099. t1.secondLevelPercent,
  1100. t1.thirdLevelPercent,
  1101. t1.firstLevelPercentStr,
  1102. t1.secondLevelPercentStr,
  1103. t1.thirdLevelPercentStr
  1104. FROM
  1105. (
  1106. SELECT
  1107. a.beh_dept_id AS deptId,
  1108. a.beh_dept_name AS deptName,
  1109. e.dept_id AS deptClassId,
  1110. e.dept_name AS deptClass,
  1111. count( DISTINCT c.id ) AS mrNum,
  1112. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1113. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1114. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  1115. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  1116. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  1117. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  1118. ) AS firstLevelPercent,
  1119. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1120. ) AS secondLevelPercent,
  1121. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1122. ) AS thirdLevelPercent,
  1123. concat(
  1124. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  1125. 100, 2 ),
  1126. '%'
  1127. ) AS firstLevelPercentStr,
  1128. concat(
  1129. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  1130. 100, 2 ),
  1131. '%'
  1132. ) AS secondLevelPercentStr,
  1133. concat(
  1134. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  1135. 100, 2 ),
  1136. '%'
  1137. ) AS thirdLevelPercentStr
  1138. FROM
  1139. med_behospital_info a,
  1140. med_qcresult_info c,
  1141. bas_dept_info d,
  1142. bas_dept_info e
  1143. WHERE
  1144. a.is_deleted = 'N'
  1145. AND c.is_deleted = 'N'
  1146. AND d.is_deleted = 'N'
  1147. AND e.is_deleted = 'N'
  1148. AND a.hospital_id = c.hospital_id
  1149. AND a.hospital_id = d.hospital_id
  1150. AND a.hospital_id = e.hospital_id
  1151. AND a.behospital_code = c.behospital_code
  1152. AND a.beh_dept_id = d.dept_id
  1153. AND d.parent_dept_id = e.dept_id
  1154. AND a.is_placefile = '1'
  1155. <![CDATA[AND a.qc_type_id <>0 ]]>
  1156. <if test="hospitalId != null and hospitalId != ''">
  1157. AND a.hospital_id = #{hospitalId}
  1158. </if>
  1159. <if test="startDate != null and startDate != ''">
  1160. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1161. </if>
  1162. <if test="endDate != null and endDate != ''">
  1163. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1164. </if>
  1165. <if test="level != null and level != ''">
  1166. and c.level = #{level}
  1167. </if>
  1168. <if test="name != null and name != ''">
  1169. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1170. </if>
  1171. <if test="deptClass != null and deptClass != ''">
  1172. and e.dept_name = #{deptClass}
  1173. </if>
  1174. GROUP BY
  1175. a.beh_dept_id,
  1176. a.beh_dept_name,
  1177. e.dept_id,
  1178. e.dept_name
  1179. ) t1,
  1180. (
  1181. SELECT
  1182. a.beh_dept_id AS deptId,
  1183. a.beh_dept_name AS deptName,
  1184. g.dept_id AS deptClassId,
  1185. g.dept_name AS deptClass,
  1186. count( * ) AS entryNum
  1187. FROM
  1188. med_behospital_info a,
  1189. med_qcresult_info c,
  1190. med_qcresult_detail d,
  1191. qc_cases_entry e,
  1192. bas_dept_info f,
  1193. bas_dept_info g
  1194. WHERE
  1195. a.is_deleted = 'N'
  1196. AND c.is_deleted = 'N'
  1197. AND d.is_deleted = 'N'
  1198. AND e.is_deleted = 'N'
  1199. AND f.is_deleted = 'N'
  1200. AND g.is_deleted = 'N'
  1201. AND a.hospital_id = c.hospital_id
  1202. AND a.hospital_id = d.hospital_id
  1203. AND a.hospital_id = f.hospital_id
  1204. AND a.hospital_id = g.hospital_id
  1205. AND a.behospital_code = c.behospital_code
  1206. AND a.behospital_code = d.behospital_code
  1207. AND d.cases_id = e.cases_id
  1208. AND d.cases_entry_id = e.id
  1209. AND a.beh_dept_id = f.dept_id
  1210. AND f.parent_dept_id = g.dept_id
  1211. AND a.is_placefile = '1'
  1212. <![CDATA[AND a.qc_type_id <>0 ]]>
  1213. <if test="hospitalId != null and hospitalId != ''">
  1214. AND a.hospital_id = #{hospitalId}
  1215. </if>
  1216. <if test="startDate != null and startDate != ''">
  1217. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1218. </if>
  1219. <if test="endDate != null and endDate != ''">
  1220. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1221. </if>
  1222. <if test="level != null and level != ''">
  1223. and c.level = #{level}
  1224. </if>
  1225. <if test="name != null and name != ''">
  1226. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1227. </if>
  1228. <if test="deptClass != null and deptClass != ''">
  1229. and g.dept_name = #{deptClass}
  1230. </if>
  1231. GROUP BY
  1232. a.beh_dept_id,
  1233. a.beh_dept_name,
  1234. g.dept_id,
  1235. g.dept_name
  1236. ) t2
  1237. WHERE
  1238. t1.deptId = t2.deptId
  1239. AND t1.deptName = t2.deptName
  1240. AND t1.deptClassId = t2.deptClassId
  1241. AND t1.deptClass = t2.deptClass
  1242. <if test="asc != null and asc !=''">
  1243. order by
  1244. <choose>
  1245. <when test='asc=="deptId"'>deptId asc</when>
  1246. <when test='asc=="deptName"'>deptName asc</when>
  1247. <when test='asc=="deptClassId"'>deptClassId asc</when>
  1248. <when test='asc=="deptClass"'>deptClass asc</when>
  1249. <when test='asc=="entryNum"'>entryNum asc</when>
  1250. <when test='asc=="mrNum"'>mrNum asc</when>
  1251. <when test='asc=="totleValue"'>totleValue asc</when>
  1252. <when test='asc=="averageValue"'>averageValue asc</when>
  1253. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1254. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1255. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1256. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1257. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1258. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1259. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1260. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1261. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1262. <otherwise>deptName asc</otherwise>
  1263. </choose>
  1264. </if>
  1265. <if test="desc != null and desc!=''">
  1266. order by
  1267. <choose>
  1268. <when test='desc=="deptId"'>deptId desc</when>
  1269. <when test='desc=="deptName"'>deptName desc</when>
  1270. <when test='desc=="deptClassId"'>deptClassId desc</when>
  1271. <when test='desc=="deptClass"'>deptClass desc</when>
  1272. <when test='desc=="entryNum"'>entryNum desc</when>
  1273. <when test='desc=="mrNum"'>mrNum desc</when>
  1274. <when test='desc=="totleValue"'>totleValue desc</when>
  1275. <when test='desc=="averageValue"'>averageValue desc</when>
  1276. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1277. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1278. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1279. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1280. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1281. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1282. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1283. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1284. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1285. <otherwise>deptName desc</otherwise>
  1286. </choose>
  1287. </if>
  1288. </select>
  1289. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  1290. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1291. SELECT
  1292. t1.deptId,
  1293. t1.deptName,
  1294. t1.deptClassId,
  1295. t1.deptClass,
  1296. t2.entryNum,
  1297. t1.mrNum,
  1298. t1.totleValue,
  1299. t1.averageValue,
  1300. t1.firstLevelNum,
  1301. t1.secondLevelNum,
  1302. t1.thirdLevelNum,
  1303. t1.firstLevelPercent,
  1304. t1.secondLevelPercent,
  1305. t1.thirdLevelPercent,
  1306. t1.firstLevelPercentStr,
  1307. t1.secondLevelPercentStr,
  1308. t1.thirdLevelPercentStr
  1309. FROM
  1310. (
  1311. SELECT
  1312. tt1.deptId,
  1313. tt1.deptName,
  1314. e.dept_id AS deptClassId,
  1315. e.dept_name AS deptClass,
  1316. count(*) AS mrNum,
  1317. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1318. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1319. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  1320. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  1321. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  1322. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  1323. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  1324. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  1325. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1326. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1327. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1328. FROM
  1329. (
  1330. SELECT
  1331. a.beh_dept_id AS deptId,
  1332. a.beh_dept_name AS deptName,
  1333. d.parent_dept_id AS parentDeptId,
  1334. a.hospital_id AS hospitalId,
  1335. a.behospital_code AS behospitalCode,
  1336. c.score_res AS score,
  1337. c.LEVEL
  1338. FROM
  1339. med_behospital_info a,
  1340. med_qcresult_info c,
  1341. bas_dept_info d
  1342. WHERE
  1343. a.is_deleted = 'N'
  1344. AND c.is_deleted = 'N'
  1345. AND d.is_deleted = 'N'
  1346. AND a.hospital_id = c.hospital_id
  1347. AND a.hospital_id = d.hospital_id
  1348. AND a.behospital_code = c.behospital_code
  1349. AND a.beh_dept_id = d.dept_id
  1350. AND a.is_placefile = '1'
  1351. AND a.is_placefile = '1'
  1352. AND a.qc_type_id != 0
  1353. <if test="hospitalId != null and hospitalId != ''">
  1354. AND a.hospital_id = #{hospitalId}
  1355. </if>
  1356. <if test="startDate != null and startDate != ''">
  1357. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1358. </if>
  1359. <if test="endDate != null and endDate != ''">
  1360. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1361. </if>
  1362. <if test="level != null and level != ''">
  1363. and c.level = #{level}
  1364. </if>
  1365. <if test="name != null and name != ''">
  1366. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1367. </if>
  1368. ) tt1
  1369. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  1370. AND e.is_deleted = 'N'
  1371. AND tt1.hospitalId = e.hospital_id
  1372. <if test="deptClass != null and deptClass != ''">
  1373. WHERE e.dept_name = #{deptClass}
  1374. </if>
  1375. GROUP BY
  1376. tt1.deptId,
  1377. tt1.deptName,
  1378. e.dept_id,
  1379. e.dept_name
  1380. ) t1,
  1381. (
  1382. SELECT
  1383. tt2.deptId,
  1384. tt2.deptName,
  1385. g.dept_id AS deptClassId,
  1386. g.dept_name AS deptClass,
  1387. count( * ) AS entryNum
  1388. FROM
  1389. (
  1390. SELECT
  1391. a.beh_dept_id AS deptId,
  1392. a.beh_dept_name AS deptName,
  1393. f.parent_dept_id AS parentDeptId,
  1394. a.hospital_id AS hospitalId,
  1395. a.behospital_code AS behospitalCode
  1396. FROM
  1397. med_behospital_info a,
  1398. med_qcresult_info c,
  1399. med_qcresult_detail d,
  1400. qc_cases_entry e,
  1401. bas_dept_info f
  1402. WHERE
  1403. a.is_deleted = 'N'
  1404. AND c.is_deleted = 'N'
  1405. AND d.is_deleted = 'N'
  1406. AND e.is_deleted = 'N'
  1407. AND f.is_deleted = 'N'
  1408. AND a.hospital_id = c.hospital_id
  1409. AND a.hospital_id = d.hospital_id
  1410. AND a.hospital_id = f.hospital_id
  1411. AND a.behospital_code = c.behospital_code
  1412. AND a.behospital_code = d.behospital_code
  1413. AND d.cases_id = e.cases_id
  1414. AND d.cases_entry_id = e.id
  1415. AND a.beh_dept_id = f.dept_id
  1416. AND a.is_placefile = '1'
  1417. AND a.is_placefile = '1'
  1418. AND a.qc_type_id != 0
  1419. <if test="hospitalId != null and hospitalId != ''">
  1420. AND a.hospital_id = #{hospitalId}
  1421. </if>
  1422. <if test="startDate != null and startDate != ''">
  1423. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1424. </if>
  1425. <if test="endDate != null and endDate != ''">
  1426. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1427. </if>
  1428. <if test="level != null and level != ''">
  1429. and c.level = #{level}
  1430. </if>
  1431. <if test="name != null and name != ''">
  1432. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1433. </if>
  1434. ) tt2
  1435. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  1436. AND g.is_deleted = 'N'
  1437. AND tt2.hospitalId = g.hospital_id
  1438. <if test="deptClass != null and deptClass != ''">
  1439. WHERE g.dept_name = #{deptClass}
  1440. </if>
  1441. GROUP BY
  1442. tt2.deptId,
  1443. tt2.deptName,
  1444. g.dept_id,
  1445. g.dept_name
  1446. ) t2
  1447. WHERE
  1448. t1.deptId = t2.deptId
  1449. AND t1.deptName = t2.deptName
  1450. <if test="asc != null and asc !=''">
  1451. order by
  1452. <choose>
  1453. <when test='asc=="deptId"'>deptId asc</when>
  1454. <when test='asc=="deptName"'>deptName asc</when>
  1455. <when test='asc=="deptClassId"'>deptClassId asc</when>
  1456. <when test='asc=="deptClass"'>deptClass asc</when>
  1457. <when test='asc=="entryNum"'>entryNum asc</when>
  1458. <when test='asc=="mrNum"'>mrNum asc</when>
  1459. <when test='asc=="totleValue"'>totleValue asc</when>
  1460. <when test='asc=="averageValue"'>averageValue asc</when>
  1461. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1462. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1463. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1464. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1465. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1466. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1467. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1468. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1469. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1470. <otherwise>deptName asc</otherwise>
  1471. </choose>
  1472. </if>
  1473. <if test="desc != null and desc!=''">
  1474. order by
  1475. <choose>
  1476. <when test='desc=="deptId"'>deptId desc</when>
  1477. <when test='desc=="deptName"'>deptName desc</when>
  1478. <when test='desc=="deptClassId"'>deptClassId desc</when>
  1479. <when test='desc=="deptClass"'>deptClass desc</when>
  1480. <when test='desc=="entryNum"'>entryNum desc</when>
  1481. <when test='desc=="mrNum"'>mrNum desc</when>
  1482. <when test='desc=="totleValue"'>totleValue desc</when>
  1483. <when test='desc=="averageValue"'>averageValue desc</when>
  1484. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1485. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1486. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1487. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1488. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1489. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1490. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1491. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1492. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1493. <otherwise>deptName desc</otherwise>
  1494. </choose>
  1495. </if>
  1496. </select>
  1497. <!-- 病案首页合格率占比 -全院-->
  1498. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  1499. resultType="com.diagbot.dto.HomePageNumDTO">
  1500. SELECT
  1501. t1.deptId,
  1502. t1.deptName,
  1503. t2.entryNum,
  1504. t1.mrNum,
  1505. t1.totleValue,
  1506. t1.averageValue,
  1507. t1.firstLevelNum,
  1508. t1.secondLevelNum,
  1509. t1.firstLevelPercent,
  1510. t1.secondLevelPercent,
  1511. t1.firstLevelPercentStr,
  1512. t1.secondLevelPercentStr,
  1513. t3.emptyNum,
  1514. t3.errorNum,
  1515. t3.entryTotleNum,
  1516. t3.emptyPercent,
  1517. t3.errorPercent,
  1518. t3.emptyPercentStr,
  1519. t3.errorPercentStr
  1520. FROM
  1521. (
  1522. SELECT
  1523. a.beh_dept_id AS deptId,
  1524. a.beh_dept_name AS deptName,
  1525. count( * ) AS mrNum,
  1526. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1527. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1528. SUM( c.`level` = '合格' ) AS firstLevelNum,
  1529. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  1530. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  1531. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  1532. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  1533. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  1534. FROM
  1535. med_behospital_info a,
  1536. med_qcresult_cases c
  1537. WHERE
  1538. a.is_deleted = 'N'
  1539. AND c.is_deleted = 'N'
  1540. AND a.hospital_id = c.hospital_id
  1541. AND a.behospital_code = c.behospital_code
  1542. AND c.cases_id = 243
  1543. AND a.is_placefile = '1'
  1544. AND a.qc_type_id != 0
  1545. <if test="hospitalId != null and hospitalId != ''">
  1546. AND a.hospital_id = #{hospitalId}
  1547. </if>
  1548. <if test="startDate != null and startDate != ''">
  1549. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1550. </if>
  1551. <if test="endDate != null and endDate != ''">
  1552. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1553. </if>
  1554. <if test="level != null and level != ''">
  1555. and c.level = #{level}
  1556. </if>
  1557. <if test="name != null and name != ''">
  1558. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1559. </if>
  1560. GROUP BY
  1561. a.beh_dept_id,
  1562. a.beh_dept_name
  1563. ) t1,
  1564. (
  1565. SELECT
  1566. a.beh_dept_id AS deptId,
  1567. a.beh_dept_name AS deptName,
  1568. count( * ) AS entryNum
  1569. FROM
  1570. med_behospital_info a,
  1571. med_qcresult_cases c,
  1572. med_qcresult_detail d,
  1573. qc_cases_entry e
  1574. WHERE
  1575. a.is_deleted = 'N'
  1576. AND c.is_deleted = 'N'
  1577. AND d.is_deleted = 'N'
  1578. AND e.is_deleted = 'N'
  1579. AND a.hospital_id = c.hospital_id
  1580. AND a.hospital_id = d.hospital_id
  1581. AND a.behospital_code = c.behospital_code
  1582. AND a.behospital_code = d.behospital_code
  1583. AND c.cases_id = d.cases_id
  1584. AND d.cases_id = e.cases_id
  1585. AND d.cases_entry_id = e.id
  1586. AND d.cases_id = 243
  1587. AND a.is_placefile = '1'
  1588. AND a.qc_type_id != 0
  1589. <if test="hospitalId != null and hospitalId != ''">
  1590. AND a.hospital_id = #{hospitalId}
  1591. </if>
  1592. <if test="startDate != null and startDate != ''">
  1593. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1594. </if>
  1595. <if test="endDate != null and endDate != ''">
  1596. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1597. </if>
  1598. <if test="level != null and level != ''">
  1599. and c.level = #{level}
  1600. </if>
  1601. <if test="name != null and name != ''">
  1602. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1603. </if>
  1604. GROUP BY
  1605. a.beh_dept_id,
  1606. a.beh_dept_name
  1607. ) t2,(
  1608. SELECT
  1609. h1.deptId,
  1610. h1.deptName,
  1611. h1.emptyNum,
  1612. h1.errorNum,
  1613. h1.mrNum,
  1614. h2.entryNum,
  1615. h1.mrNum * h2.entryNum AS entryTotleNum,
  1616. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  1617. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  1618. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  1619. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  1620. FROM
  1621. (
  1622. SELECT
  1623. a.beh_dept_id AS deptId,
  1624. a.beh_dept_name AS deptName,
  1625. sum( d.rule_type = 1 ) AS emptyNum,
  1626. sum( d.rule_type = 2 ) AS errorNum,
  1627. count( DISTINCT a.behospital_code ) AS mrNum
  1628. FROM
  1629. med_behospital_info a,
  1630. med_qcresult_cases b,
  1631. med_qcresult_detail c,
  1632. qc_cases_entry d
  1633. WHERE
  1634. a.is_deleted = 'N'
  1635. AND b.is_deleted = 'N'
  1636. AND c.is_deleted = 'N'
  1637. AND d.is_deleted = 'N'
  1638. AND a.hospital_id = b.hospital_id
  1639. AND a.hospital_id = c.hospital_id
  1640. AND a.behospital_code = b.behospital_code
  1641. AND a.behospital_code = c.behospital_code
  1642. AND b.cases_id = c.cases_id
  1643. AND c.cases_id = d.cases_id
  1644. AND c.cases_entry_id = d.id
  1645. AND a.is_placefile = '1'
  1646. AND d.cases_id = 243
  1647. AND a.qc_type_id != 0
  1648. <if test="hospitalId != null and hospitalId != ''">
  1649. AND a.hospital_id = #{hospitalId}
  1650. </if>
  1651. <if test="startDate != null and startDate != ''">
  1652. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1653. </if>
  1654. <if test="endDate != null and endDate != ''">
  1655. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1656. </if>
  1657. <if test="level != null and level != ''">
  1658. and b.level = #{level}
  1659. </if>
  1660. <if test="name != null and name != ''">
  1661. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1662. </if>
  1663. GROUP BY
  1664. a.beh_dept_id,
  1665. a.beh_dept_name
  1666. ) h1,(
  1667. SELECT
  1668. count(*) AS entryNum
  1669. FROM
  1670. qc_cases_entry
  1671. WHERE
  1672. is_deleted = 'N'
  1673. AND cases_id = 243
  1674. ) h2
  1675. ) t3
  1676. WHERE
  1677. t1.deptId = t2.deptId
  1678. AND t1.deptId = t3.deptId
  1679. AND t1.deptName = t2.deptName
  1680. AND t1.deptName = t3.deptName
  1681. <if test="asc != null and asc !=''">
  1682. order by
  1683. <choose>
  1684. <when test='asc=="deptId"'>deptId asc</when>
  1685. <when test='asc=="deptName"'>deptName asc</when>
  1686. <when test='asc=="entryNum"'>entryNum asc</when>
  1687. <when test='asc=="mrNum"'>mrNum asc</when>
  1688. <when test='asc=="totleValue"'>totleValue asc</when>
  1689. <when test='asc=="averageValue"'>averageValue asc</when>
  1690. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1691. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1692. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1693. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1694. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1695. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1696. <when test='asc=="emptyNum"'>emptyNum asc</when>
  1697. <when test='asc=="errorNum"'>errorNum asc</when>
  1698. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  1699. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  1700. <when test='asc=="errorPercent"'>errorPercent asc</when>
  1701. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  1702. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  1703. <otherwise>deptName asc</otherwise>
  1704. </choose>
  1705. </if>
  1706. <if test="desc != null and desc!=''">
  1707. order by
  1708. <choose>
  1709. <when test='desc=="deptId"'>deptId desc</when>
  1710. <when test='desc=="deptName"'>deptName desc</when>
  1711. <when test='desc=="entryNum"'>entryNum desc</when>
  1712. <when test='desc=="mrNum"'>mrNum desc</when>
  1713. <when test='desc=="totleValue"'>totleValue desc</when>
  1714. <when test='desc=="averageValue"'>averageValue desc</when>
  1715. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1716. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1717. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1718. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1719. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1720. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1721. <when test='desc=="emptyNum"'>emptyNum desc</when>
  1722. <when test='desc=="errorNum"'>errorNum desc</when>
  1723. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  1724. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  1725. <when test='desc=="errorPercent"'>errorPercent desc</when>
  1726. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  1727. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  1728. <otherwise>deptName desc</otherwise>
  1729. </choose>
  1730. </if>
  1731. </select>
  1732. <!-- 各科室缺陷占比-科室 -->
  1733. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  1734. resultType="com.diagbot.dto.LevelStatisticsDTO">
  1735. SELECT
  1736. t1.doctorId,
  1737. t1.doctorName,
  1738. t2.entryNum,
  1739. t1.mrNum,
  1740. t1.totleValue,
  1741. t1.averageValue,
  1742. t1.firstLevelNum,
  1743. t1.secondLevelNum,
  1744. t1.thirdLevelNum,
  1745. t1.firstLevelPercent,
  1746. t1.secondLevelPercent,
  1747. t1.thirdLevelPercent,
  1748. t1.firstLevelPercentStr,
  1749. t1.secondLevelPercentStr,
  1750. t1.thirdLevelPercentStr
  1751. FROM
  1752. (
  1753. SELECT
  1754. a.doctor_id AS doctorId,
  1755. a.doctor_name AS doctorName,
  1756. count(*) AS mrNum,
  1757. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1758. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1759. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1760. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1761. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1762. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1763. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1764. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1765. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1766. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1767. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1768. FROM
  1769. med_behospital_info a,
  1770. med_qcresult_info c,
  1771. sys_user_dept e
  1772. WHERE
  1773. a.is_deleted = 'N'
  1774. AND c.is_deleted = 'N'
  1775. AND e.is_deleted = 'N'
  1776. AND a.hospital_id = c.hospital_id
  1777. AND a.behospital_code = c.behospital_code
  1778. AND a.beh_dept_id = e.dept_id
  1779. AND a.is_placefile = '1'
  1780. <![CDATA[AND a.qc_type_id <>0 ]]>
  1781. <if test="hospitalId != null and hospitalId != ''">
  1782. AND a.hospital_id = #{hospitalId}
  1783. </if>
  1784. <if test="startDate != null and startDate != ''">
  1785. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1786. </if>
  1787. <if test="endDate != null and endDate != ''">
  1788. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1789. </if>
  1790. <if test="level != null and level != ''">
  1791. and c.level = #{level}
  1792. </if>
  1793. <if test="name != null and name != ''">
  1794. and a.doctor_name like CONCAT('%',#{name},'%')
  1795. </if>
  1796. <if test="userId!=null and userId !=''">
  1797. AND e.user_id = #{userId}
  1798. </if>
  1799. <if test="deptName!=null and deptName !=''">
  1800. AND a.beh_dept_name = #{deptName}
  1801. </if>
  1802. GROUP BY
  1803. a.doctor_id,
  1804. a.doctor_name
  1805. ) t1,
  1806. (
  1807. SELECT
  1808. a.doctor_id AS doctorId,
  1809. a.doctor_name AS doctorName,
  1810. count( * ) AS entryNum
  1811. FROM
  1812. med_behospital_info a,
  1813. med_qcresult_info c,
  1814. med_qcresult_detail d,
  1815. qc_cases_entry e,
  1816. sys_user_dept f
  1817. WHERE
  1818. a.is_deleted = 'N'
  1819. AND c.is_deleted = 'N'
  1820. AND d.is_deleted = 'N'
  1821. AND e.is_deleted = 'N'
  1822. AND f.is_deleted = 'N'
  1823. AND a.hospital_id = c.hospital_id
  1824. AND a.hospital_id = d.hospital_id
  1825. AND a.behospital_code = c.behospital_code
  1826. AND a.behospital_code = d.behospital_code
  1827. AND d.cases_id = e.cases_id
  1828. AND d.cases_entry_id = e.id
  1829. AND a.beh_dept_id = f.dept_id
  1830. AND a.is_placefile = '1'
  1831. <![CDATA[AND a.qc_type_id <>0 ]]>
  1832. <if test="hospitalId != null and hospitalId != ''">
  1833. AND a.hospital_id = #{hospitalId}
  1834. </if>
  1835. <if test="startDate != null and startDate != ''">
  1836. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1837. </if>
  1838. <if test="endDate != null and endDate != ''">
  1839. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1840. </if>
  1841. <if test="level != null and level != ''">
  1842. and c.level = #{level}
  1843. </if>
  1844. <if test="name != null and name != ''">
  1845. and a.doctor_name like CONCAT('%',#{name},'%')
  1846. </if>
  1847. <if test="userId!=null and userId !=''">
  1848. AND f.user_id = #{userId}
  1849. </if>
  1850. <if test="deptName!=null and deptName !=''">
  1851. AND a.beh_dept_name = #{deptName}
  1852. </if>
  1853. GROUP BY
  1854. a.doctor_id,
  1855. a.doctor_name
  1856. ) t2
  1857. WHERE
  1858. t1.doctorId = t2.doctorId
  1859. AND t1.doctorName = t2.doctorName
  1860. <if test="asc != null and asc !=''">
  1861. order by
  1862. <choose>
  1863. <when test='asc=="doctorId"'>doctorId asc</when>
  1864. <when test='asc=="doctorName"'>doctorName asc</when>
  1865. <when test='asc=="entryNum"'>entryNum asc</when>
  1866. <when test='asc=="mrNum"'>mrNum asc</when>
  1867. <when test='asc=="totleValue"'>totleValue asc</when>
  1868. <when test='asc=="averageValue"'>averageValue asc</when>
  1869. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1870. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1871. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1872. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1873. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1874. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1875. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1876. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1877. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1878. <otherwise>doctorName asc</otherwise>
  1879. </choose>
  1880. </if>
  1881. <if test="desc != null and desc!=''">
  1882. order by
  1883. <choose>
  1884. <when test='desc=="doctorId"'>doctorId desc</when>
  1885. <when test='desc=="doctorName"'>doctorName desc</when>
  1886. <when test='desc=="entryNum"'>entryNum desc</when>
  1887. <when test='desc=="mrNum"'>mrNum desc</when>
  1888. <when test='desc=="totleValue"'>totleValue desc</when>
  1889. <when test='desc=="averageValue"'>averageValue desc</when>
  1890. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1891. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1892. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1893. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1894. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1895. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1896. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1897. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1898. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1899. <otherwise>doctorName desc</otherwise>
  1900. </choose>
  1901. </if>
  1902. </select>
  1903. <!-- 病案首页合格率占比-科室 -->
  1904. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  1905. resultType="com.diagbot.dto.HomePageNumDTO">
  1906. SELECT
  1907. t1.doctorId,
  1908. t1.doctorName,
  1909. t2.entryNum,
  1910. t1.mrNum,
  1911. t1.totleValue,
  1912. t1.averageValue,
  1913. t1.firstLevelNum,
  1914. t1.secondLevelNum,
  1915. t1.firstLevelPercent,
  1916. t1.secondLevelPercent,
  1917. t1.firstLevelPercentStr,
  1918. t1.secondLevelPercentStr,
  1919. t3.emptyNum,
  1920. t3.errorNum,
  1921. t3.entryTotleNum,
  1922. t3.emptyPercent,
  1923. t3.errorPercent,
  1924. t3.emptyPercentStr,
  1925. t3.errorPercentStr
  1926. FROM
  1927. (
  1928. SELECT
  1929. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  1930. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  1931. count( * ) AS mrNum,
  1932. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1933. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1934. sum( c.`level` = '合格' ) AS firstLevelNum,
  1935. sum( c.`level` = '不合格' ) AS secondLevelNum,
  1936. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  1937. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  1938. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1939. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  1940. FROM
  1941. med_behospital_info a,
  1942. med_qcresult_cases c,
  1943. sys_user_dept f
  1944. WHERE
  1945. a.is_deleted = 'N'
  1946. AND c.is_deleted = 'N'
  1947. AND f.is_deleted = 'N'
  1948. AND a.hospital_id = c.hospital_id
  1949. AND a.behospital_code = c.behospital_code
  1950. AND a.beh_dept_id = f.dept_id
  1951. AND c.cases_id = 243
  1952. AND a.is_placefile = '1'
  1953. <![CDATA[AND a.qc_type_id <>0 ]]>
  1954. <if test="hospitalId != null and hospitalId != ''">
  1955. AND a.hospital_id = #{hospitalId}
  1956. </if>
  1957. <if test="startDate != null and startDate != ''">
  1958. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1959. </if>
  1960. <if test="endDate != null and endDate != ''">
  1961. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1962. </if>
  1963. <if test="level != null and level != ''">
  1964. and c.level = #{level}
  1965. </if>
  1966. <if test="name != null and name != ''">
  1967. <if test="name == '未知'">
  1968. and (a.doctor_name is null or a.doctor_name='')
  1969. </if>
  1970. <if test="name != '未知'">
  1971. and a.doctor_name like CONCAT('%',#{name},'%')
  1972. </if>
  1973. </if>
  1974. <if test="userId!=null and userId !=''">
  1975. AND f.user_id = #{userId}
  1976. </if>
  1977. <if test="deptName!=null and deptName !=''">
  1978. AND a.beh_dept_name = #{deptName}
  1979. </if>
  1980. GROUP BY
  1981. a.doctor_id,
  1982. a.doctor_name
  1983. ) t1,
  1984. (
  1985. SELECT
  1986. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  1987. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  1988. count( * ) AS entryNum
  1989. FROM
  1990. med_behospital_info a,
  1991. med_qcresult_cases c,
  1992. med_qcresult_detail d,
  1993. qc_cases_entry e,
  1994. sys_user_dept f
  1995. WHERE
  1996. a.is_deleted = 'N'
  1997. AND c.is_deleted = 'N'
  1998. AND d.is_deleted = 'N'
  1999. AND e.is_deleted = 'N'
  2000. AND f.is_deleted = 'N'
  2001. AND a.hospital_id = c.hospital_id
  2002. AND a.hospital_id = d.hospital_id
  2003. AND a.behospital_code = c.behospital_code
  2004. AND a.behospital_code = d.behospital_code
  2005. AND a.beh_dept_id = f.dept_id
  2006. AND c.cases_id = d.cases_id
  2007. AND d.cases_id = e.cases_id
  2008. AND d.cases_entry_id = e.id
  2009. AND c.cases_id = 243
  2010. AND a.is_placefile = '1'
  2011. <![CDATA[AND a.qc_type_id <>0 ]]>
  2012. <if test="hospitalId != null and hospitalId != ''">
  2013. AND a.hospital_id = #{hospitalId}
  2014. </if>
  2015. <if test="startDate != null and startDate != ''">
  2016. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  2017. </if>
  2018. <if test="endDate != null and endDate != ''">
  2019. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  2020. </if>
  2021. <if test="level != null and level != ''">
  2022. and c.level = #{level}
  2023. </if>
  2024. <if test="name != null and name != ''">
  2025. <if test="name == '未知'">
  2026. and (a.doctor_name is null or a.doctor_name='')
  2027. </if>
  2028. <if test="name != '未知'">
  2029. and a.doctor_name like CONCAT('%',#{name},'%')
  2030. </if>
  2031. </if>
  2032. <if test="userId!=null and userId !=''">
  2033. AND f.user_id = #{userId}
  2034. </if>
  2035. <if test="deptName!=null and deptName !=''">
  2036. AND a.beh_dept_name = #{deptName}
  2037. </if>
  2038. GROUP BY
  2039. a.doctor_id,
  2040. a.doctor_name
  2041. ) t2,(
  2042. SELECT
  2043. h1.doctorId,
  2044. h1.doctorName,
  2045. h1.emptyNum,
  2046. h1.errorNum,
  2047. h1.mrNum,
  2048. h2.entryNum,
  2049. h1.mrNum * h2.entryNum AS entryTotleNum,
  2050. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  2051. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  2052. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  2053. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  2054. FROM
  2055. (
  2056. SELECT
  2057. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  2058. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  2059. sum( d.rule_type = 1 ) AS emptyNum,
  2060. sum( d.rule_type = 2 ) AS errorNum,
  2061. count( DISTINCT a.behospital_code ) AS mrNum
  2062. FROM
  2063. med_behospital_info a,
  2064. med_qcresult_cases b,
  2065. med_qcresult_detail c,
  2066. qc_cases_entry d,
  2067. sys_user_dept e
  2068. WHERE
  2069. a.is_deleted = 'N'
  2070. AND b.is_deleted = 'N'
  2071. AND c.is_deleted = 'N'
  2072. AND d.is_deleted = 'N'
  2073. AND e.is_deleted = 'N'
  2074. AND a.hospital_id = b.hospital_id
  2075. AND a.hospital_id = c.hospital_id
  2076. AND a.hospital_id = e.hospital_id
  2077. AND a.behospital_code = b.behospital_code
  2078. AND a.behospital_code = c.behospital_code
  2079. AND b.cases_id = c.cases_id
  2080. AND c.cases_id = d.cases_id
  2081. AND c.cases_entry_id = d.id
  2082. AND a.beh_dept_id = e.dept_id
  2083. AND a.is_placefile = '1'
  2084. AND d.cases_id = 243
  2085. <![CDATA[AND a.qc_type_id <>0 ]]>
  2086. <if test="hospitalId != null and hospitalId != ''">
  2087. AND a.hospital_id = #{hospitalId}
  2088. </if>
  2089. <if test="startDate != null and startDate != ''">
  2090. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  2091. </if>
  2092. <if test="endDate != null and endDate != ''">
  2093. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  2094. </if>
  2095. <if test="level != null and level != ''">
  2096. and b.level = #{level}
  2097. </if>
  2098. <if test="name != null and name != ''">
  2099. <if test="name == '未知'">
  2100. and (a.doctor_name is null or a.doctor_name='')
  2101. </if>
  2102. <if test="name != '未知'">
  2103. and a.doctor_name like CONCAT('%',#{name},'%')
  2104. </if>
  2105. </if>
  2106. <if test="userId!=null and userId !=''">
  2107. AND e.user_id = #{userId}
  2108. </if>
  2109. <if test="deptName!=null and deptName !=''">
  2110. AND a.beh_dept_name = #{deptName}
  2111. </if>
  2112. GROUP BY
  2113. a.doctor_id,
  2114. a.doctor_name
  2115. ) h1,(
  2116. SELECT
  2117. count(*) AS entryNum
  2118. FROM
  2119. qc_cases_entry
  2120. WHERE
  2121. is_deleted = 'N'
  2122. AND cases_id = 243
  2123. ) h2
  2124. ) t3
  2125. WHERE
  2126. t1.doctorId = t2.doctorId
  2127. AND t1.doctorId = t3.doctorId
  2128. AND t1.doctorName = t2.doctorName
  2129. AND t1.doctorName = t3.doctorName
  2130. <if test="asc != null and asc !=''">
  2131. order by
  2132. <choose>
  2133. <when test='asc=="doctorId"'>doctorId asc</when>
  2134. <when test='asc=="doctorName"'>doctorName asc</when>
  2135. <when test='asc=="entryNum"'>entryNum asc</when>
  2136. <when test='asc=="mrNum"'>mrNum asc</when>
  2137. <when test='asc=="totleValue"'>totleValue asc</when>
  2138. <when test='asc=="averageValue"'>averageValue asc</when>
  2139. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2140. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2141. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2142. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2143. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2144. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2145. <when test='asc=="emptyNum"'>emptyNum asc</when>
  2146. <when test='asc=="errorNum"'>errorNum asc</when>
  2147. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  2148. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  2149. <when test='asc=="errorPercent"'>errorPercent asc</when>
  2150. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  2151. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  2152. <otherwise>doctorName asc</otherwise>
  2153. </choose>
  2154. </if>
  2155. <if test="desc != null and desc!=''">
  2156. order by
  2157. <choose>
  2158. <when test='desc=="doctorId"'>doctorId desc</when>
  2159. <when test='desc=="doctorName"'>doctorName desc</when>
  2160. <when test='desc=="entryNum"'>entryNum desc</when>
  2161. <when test='desc=="mrNum"'>mrNum desc</when>
  2162. <when test='desc=="totleValue"'>totleValue desc</when>
  2163. <when test='desc=="averageValue"'>averageValue desc</when>
  2164. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2165. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2166. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2167. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2168. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2169. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2170. <when test='desc=="emptyNum"'>emptyNum desc</when>
  2171. <when test='desc=="errorNum"'>errorNum desc</when>
  2172. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  2173. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  2174. <when test='desc=="errorPercent"'>errorPercent desc</when>
  2175. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  2176. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  2177. <otherwise>doctorName desc</otherwise>
  2178. </choose>
  2179. </if>
  2180. </select>
  2181. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  2182. <result column="behDeptName" property="behDeptName"/>
  2183. <result column="avgScore" property="avgScore"/>
  2184. <collection property="excelBehospitalDTOS"
  2185. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  2186. <result column="behDoctorName" property="behDoctorName"/>
  2187. <result column="patName" property="patName"/>
  2188. <result column="behospitalCode" property="behospitalCode"/>
  2189. <result column="behospitalDate" property="behospitalDate"/>
  2190. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  2191. <result column="score" property="score"/>
  2192. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  2193. <result column="caseName" property="caseName"/>
  2194. <collection property="exportExcelMsgDTOS"
  2195. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  2196. <result column="msg" property="msg"/>
  2197. </collection>
  2198. </collection>
  2199. </collection>
  2200. </resultMap>
  2201. <select id="exportExcel" resultMap="ExportExcelMap">
  2202. SELECT DISTINCT
  2203. t1.beh_dept_name AS behDeptName,
  2204. t1.beh_doctor_name AS behDoctorName,
  2205. t1.`name` AS patName,
  2206. t1.behospital_code AS behospitalCode,
  2207. t1.behospital_date AS behospitalDate,
  2208. t1.leave_hospital_date AS leaveHospitalDate,
  2209. t2.score_res AS score,
  2210. "1" AS avgScore,
  2211. t4.`name` AS caseName,
  2212. t3.msg AS msg
  2213. FROM
  2214. med_behospital_info t1,
  2215. med_qcresult_info t2,
  2216. med_qcresult_detail t3,
  2217. qc_cases t4
  2218. WHERE
  2219. t1.is_deleted = 'N'
  2220. AND t2.is_deleted = 'N'
  2221. AND t3.is_deleted = 'N'
  2222. AND t4.is_deleted = 'N'
  2223. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  2224. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  2225. AND t1.hospital_id = t2.hospital_id
  2226. AND t1.behospital_code = t2.behospital_code
  2227. AND t1.hospital_id = t3.hospital_id
  2228. AND t1.behospital_code = t3.behospital_code
  2229. AND t3.cases_id = t4.id
  2230. ORDER BY
  2231. t1.beh_dept_id ASC,
  2232. t1.leave_hospital_date DESC,
  2233. t1.behospital_code ASC,
  2234. t4.`name` ASC
  2235. </select>
  2236. <!-- 质控评分导出到excel-->
  2237. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2238. SELECT
  2239. t1.behDeptId,
  2240. t1.behDeptName,
  2241. t1.behDoctorName,
  2242. t1.patName,
  2243. t1.behospitalCode,
  2244. t1.behospitalDate,
  2245. t1.leaveHospitalDate,
  2246. t1.score,
  2247. t2.avgScore,
  2248. t1.msg,
  2249. t1.caseName
  2250. FROM
  2251. (
  2252. SELECT
  2253. CONCAT(
  2254. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  2255. a.doctor_name
  2256. ) AS behDoctorName,
  2257. a.`name` AS patName,
  2258. a.behospital_code AS behospitalCode,
  2259. a.behospital_date AS behospitalDate,
  2260. a.leave_hospital_date AS leaveHospitalDate,
  2261. b.score_res AS score,
  2262. c.msg AS msg,
  2263. d.NAME AS caseName,
  2264. a.beh_dept_id AS behDeptId,
  2265. a.beh_dept_name AS behDeptName
  2266. FROM
  2267. med_behospital_info a,
  2268. med_qcresult_info b,
  2269. med_qcresult_detail c,
  2270. qc_cases d
  2271. WHERE
  2272. a.is_deleted = 'N'
  2273. AND b.is_deleted = 'N'
  2274. AND c.is_deleted = 'N'
  2275. AND d.is_deleted = 'N'
  2276. AND a.hospital_id = b.hospital_id
  2277. AND a.hospital_id = c.hospital_id
  2278. AND a.behospital_code = b.behospital_code
  2279. AND a.behospital_code = c.behospital_code
  2280. AND c.cases_id = d.id
  2281. AND a.is_placefile = '1'
  2282. <![CDATA[AND a.qc_type_id <>0 ]]>
  2283. <if test="hospitalId != null and hospitalId != ''">
  2284. AND a.hospital_id = #{hospitalId}
  2285. </if>
  2286. <if test="leaveHosDateStart != null ">
  2287. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2288. </if>
  2289. <if test="leaveHosDateEnd != null ">
  2290. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2291. </if>
  2292. <if test="behospitalCode != null and behospitalCode != ''">
  2293. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2294. </if>
  2295. <if test="level != null and level != ''">
  2296. AND b.level = #{level}
  2297. </if>
  2298. <if test="doctorName != null and doctorName != ''">
  2299. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2300. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2301. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2302. </if>
  2303. <if test="doctorCode != null and doctorCode != ''">
  2304. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2305. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2306. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2307. </if>
  2308. <if test="deptId != null and deptId != ''">
  2309. AND a.beh_dept_id = #{deptId}
  2310. </if>
  2311. <if test="name != null and name != ''">
  2312. AND a.name like CONCAT('%',#{name},'%')
  2313. </if>
  2314. ) t1,
  2315. (
  2316. SELECT
  2317. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2318. a.beh_dept_id AS behDeptId,
  2319. a.beh_dept_name AS behDeptName
  2320. FROM
  2321. med_behospital_info a,
  2322. med_qcresult_info b
  2323. WHERE
  2324. a.is_deleted = 'N'
  2325. AND b.is_deleted = 'N'
  2326. AND a.hospital_id = b.hospital_id
  2327. AND a.behospital_code = b.behospital_code
  2328. AND a.is_placefile = '1'
  2329. <![CDATA[AND a.qc_type_id <>0 ]]>
  2330. <if test="hospitalId != null and hospitalId != ''">
  2331. AND a.hospital_id = #{hospitalId}
  2332. </if>
  2333. <if test="leaveHosDateStart != null ">
  2334. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2335. </if>
  2336. <if test="leaveHosDateEnd != null ">
  2337. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2338. </if>
  2339. <if test="behospitalCode != null and behospitalCode != ''">
  2340. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2341. </if>
  2342. <if test="level != null and level != ''">
  2343. AND b.level = #{level}
  2344. </if>
  2345. <if test="doctorName != null and doctorName != ''">
  2346. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2347. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2348. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2349. </if>
  2350. <if test="doctorCode != null and doctorCode != ''">
  2351. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2352. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2353. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2354. </if>
  2355. <if test="deptId != null and deptId != ''">
  2356. AND a.beh_dept_id = #{deptId}
  2357. </if>
  2358. <if test="name != null and name != ''">
  2359. AND a.name like CONCAT('%',#{name},'%')
  2360. </if>
  2361. GROUP BY
  2362. a.beh_dept_id,
  2363. a.beh_dept_name
  2364. ) t2
  2365. WHERE
  2366. t1.behDeptId = t2.behDeptId
  2367. AND t1.behDeptName = t2.behDeptName
  2368. ORDER BY
  2369. t1.behDeptName,
  2370. t1.behDoctorName,
  2371. t1.patName,
  2372. t1.behospitalCode,
  2373. t1.caseName
  2374. </select>
  2375. <!-- 科室质控评分导出到excel-->
  2376. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2377. SELECT
  2378. t1.behDeptId,
  2379. t1.behDeptName,
  2380. t1.behDoctorName,
  2381. t1.patName,
  2382. t1.behospitalCode,
  2383. t1.behospitalDate,
  2384. t1.leaveHospitalDate,
  2385. t1.score,
  2386. t2.avgScore,
  2387. t1.msg,
  2388. t1.caseName
  2389. FROM
  2390. (
  2391. SELECT
  2392. CONCAT(
  2393. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  2394. a.doctor_name
  2395. ) AS behDoctorName,
  2396. a.`name` AS patName,
  2397. a.behospital_code AS behospitalCode,
  2398. a.behospital_date AS behospitalDate,
  2399. a.leave_hospital_date AS leaveHospitalDate,
  2400. b.score_res AS score,
  2401. c.msg AS msg,
  2402. d.NAME AS caseName,
  2403. a.beh_dept_id AS behDeptId,
  2404. a.beh_dept_name AS behDeptName
  2405. FROM
  2406. med_behospital_info a,
  2407. med_qcresult_info b,
  2408. med_qcresult_detail c,
  2409. qc_cases d,
  2410. sys_user_dept e
  2411. WHERE
  2412. a.is_deleted = 'N'
  2413. AND b.is_deleted = 'N'
  2414. AND c.is_deleted = 'N'
  2415. AND d.is_deleted = 'N'
  2416. AND e.is_deleted = 'N'
  2417. AND a.hospital_id = b.hospital_id
  2418. AND a.hospital_id = c.hospital_id
  2419. AND a.hospital_id = e.hospital_id
  2420. AND a.behospital_code = b.behospital_code
  2421. AND a.behospital_code = c.behospital_code
  2422. AND c.cases_id = d.id
  2423. AND a.beh_dept_id = e.dept_id
  2424. AND a.is_placefile = '1'
  2425. <![CDATA[AND a.qc_type_id <>0 ]]>
  2426. <if test="hospitalId != null and hospitalId != ''">
  2427. AND a.hospital_id = #{hospitalId}
  2428. </if>
  2429. <if test="userId != null ">
  2430. AND e.user_id = #{userId}
  2431. </if>
  2432. <if test="leaveHosDateStart != null ">
  2433. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2434. </if>
  2435. <if test="leaveHosDateEnd != null ">
  2436. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2437. </if>
  2438. <if test="behospitalCode != null and behospitalCode != ''">
  2439. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2440. </if>
  2441. <if test="level != null and level != ''">
  2442. AND b.level = #{level}
  2443. </if>
  2444. <if test="doctorName != null and doctorName != ''">
  2445. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2446. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2447. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2448. </if>
  2449. <if test="doctorCode != null and doctorCode != ''">
  2450. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2451. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2452. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2453. </if>
  2454. <if test="deptId != null and deptId != ''">
  2455. AND a.beh_dept_id = #{deptId}
  2456. </if>
  2457. <if test="name != null and name != ''">
  2458. AND a.name like CONCAT('%',#{name},'%')
  2459. </if>
  2460. ) t1,
  2461. (
  2462. SELECT
  2463. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2464. a.beh_dept_id AS behDeptId,
  2465. a.beh_dept_name AS behDeptName
  2466. FROM
  2467. med_behospital_info a,
  2468. med_qcresult_info b,
  2469. sys_user_dept c
  2470. WHERE
  2471. a.is_deleted = 'N'
  2472. AND b.is_deleted = 'N'
  2473. AND c.is_deleted = 'N'
  2474. AND a.hospital_id = b.hospital_id
  2475. AND a.hospital_id = c.hospital_id
  2476. AND a.behospital_code = b.behospital_code
  2477. AND a.beh_dept_id = c.dept_id
  2478. AND a.is_placefile = '1'
  2479. <![CDATA[AND a.qc_type_id <>0 ]]>
  2480. <if test="hospitalId != null and hospitalId != ''">
  2481. AND a.hospital_id = #{hospitalId}
  2482. </if>
  2483. <if test="userId != null ">
  2484. AND c.user_id = #{userId}
  2485. </if>
  2486. <if test="leaveHosDateStart != null ">
  2487. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2488. </if>
  2489. <if test="leaveHosDateEnd != null ">
  2490. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2491. </if>
  2492. <if test="behospitalCode != null and behospitalCode != ''">
  2493. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2494. </if>
  2495. <if test="level != null and level != ''">
  2496. AND b.level = #{level}
  2497. </if>
  2498. <if test="doctorName != null and doctorName != ''">
  2499. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2500. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2501. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2502. </if>
  2503. <if test="doctorCode != null and doctorCode != ''">
  2504. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2505. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2506. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2507. </if>
  2508. <if test="deptId != null and deptId != ''">
  2509. AND a.beh_dept_id = #{deptId}
  2510. </if>
  2511. <if test="name != null and name != ''">
  2512. AND a.name like CONCAT('%',#{name},'%')
  2513. </if>
  2514. GROUP BY
  2515. a.beh_dept_id,
  2516. a.beh_dept_name
  2517. ) t2
  2518. WHERE
  2519. t1.behDeptId = t2.behDeptId
  2520. AND t1.behDeptName = t2.behDeptName
  2521. ORDER BY
  2522. t1.behDeptName,
  2523. t1.behDoctorName,
  2524. t1.patName,
  2525. t1.behospitalCode,
  2526. t1.caseName
  2527. </select>
  2528. <!-- 医疗组质控评分导出到excel-->
  2529. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2530. SELECT
  2531. t1.behDeptId,
  2532. t1.behDeptName,
  2533. t1.behDoctorName,
  2534. t1.patName,
  2535. t1.behospitalCode,
  2536. t1.behospitalDate,
  2537. t1.leaveHospitalDate,
  2538. t1.score,
  2539. t2.avgScore,
  2540. t1.msg,
  2541. t1.caseName
  2542. FROM
  2543. (
  2544. SELECT
  2545. CONCAT(
  2546. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  2547. a.doctor_name
  2548. ) AS behDoctorName,
  2549. a.`name` AS patName,
  2550. a.behospital_code AS behospitalCode,
  2551. a.behospital_date AS behospitalDate,
  2552. a.leave_hospital_date AS leaveHospitalDate,
  2553. b.score_res AS score,
  2554. c.msg AS msg,
  2555. d.NAME AS caseName,
  2556. a.beh_dept_id AS behDeptId,
  2557. a.beh_dept_name AS behDeptName
  2558. FROM
  2559. med_behospital_info a,
  2560. med_qcresult_info b,
  2561. med_qcresult_detail c,
  2562. qc_cases d
  2563. WHERE
  2564. a.is_deleted = 'N'
  2565. AND b.is_deleted = 'N'
  2566. AND c.is_deleted = 'N'
  2567. AND d.is_deleted = 'N'
  2568. AND a.hospital_id = b.hospital_id
  2569. AND a.hospital_id = c.hospital_id
  2570. AND a.behospital_code = b.behospital_code
  2571. AND a.behospital_code = c.behospital_code
  2572. AND c.cases_id = d.id
  2573. AND a.is_placefile = '1'
  2574. AND a.doctor_id in
  2575. (SELECT doctor_id FROM `bas_doctor_info`
  2576. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  2577. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  2578. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  2579. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  2580. and c1.username = c3.doctor_id
  2581. and c2.hospital_id = #{hospitalId}
  2582. and c1.id = #{userId}
  2583. ))
  2584. <![CDATA[AND a.qc_type_id <>0 ]]>
  2585. <if test="hospitalId != null and hospitalId != ''">
  2586. AND a.hospital_id = #{hospitalId}
  2587. </if>
  2588. <if test="leaveHosDateStart != null ">
  2589. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2590. </if>
  2591. <if test="leaveHosDateEnd != null ">
  2592. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2593. </if>
  2594. <if test="behospitalCode != null and behospitalCode != ''">
  2595. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2596. </if>
  2597. <if test="level != null and level != ''">
  2598. AND b.level = #{level}
  2599. </if>
  2600. <if test="doctorName != null and doctorName != ''">
  2601. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2602. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2603. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2604. </if>
  2605. <if test="doctorCode != null and doctorCode != ''">
  2606. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2607. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2608. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2609. </if>
  2610. <if test="deptId != null and deptId != ''">
  2611. AND a.beh_dept_id = #{deptId}
  2612. </if>
  2613. <if test="name != null and name != ''">
  2614. AND a.name like CONCAT('%',#{name},'%')
  2615. </if>
  2616. ) t1,
  2617. (
  2618. SELECT
  2619. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2620. a.beh_dept_id AS behDeptId,
  2621. a.beh_dept_name AS behDeptName
  2622. FROM
  2623. med_behospital_info a,
  2624. med_qcresult_info b
  2625. WHERE
  2626. a.is_deleted = 'N'
  2627. AND a.doctor_id in
  2628. (SELECT doctor_id FROM `bas_doctor_info`
  2629. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  2630. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  2631. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  2632. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  2633. and c1.username = c3.doctor_id
  2634. and c2.hospital_id = #{hospitalId}
  2635. and c1.id = #{userId}
  2636. ))
  2637. AND b.is_deleted = 'N'
  2638. AND a.hospital_id = b.hospital_id
  2639. AND a.behospital_code = b.behospital_code
  2640. AND a.is_placefile = '1'
  2641. <![CDATA[AND a.qc_type_id <>0 ]]>
  2642. <if test="hospitalId != null and hospitalId != ''">
  2643. AND a.hospital_id = #{hospitalId}
  2644. </if>
  2645. <if test="leaveHosDateStart != null ">
  2646. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2647. </if>
  2648. <if test="leaveHosDateEnd != null ">
  2649. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2650. </if>
  2651. <if test="behospitalCode != null and behospitalCode != ''">
  2652. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2653. </if>
  2654. <if test="level != null and level != ''">
  2655. AND b.level = #{level}
  2656. </if>
  2657. <if test="doctorName != null and doctorName != ''">
  2658. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2659. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2660. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2661. </if>
  2662. <if test="doctorCode != null and doctorCode != ''">
  2663. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2664. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2665. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2666. </if>
  2667. <if test="deptId != null and deptId != ''">
  2668. AND a.beh_dept_id = #{deptId}
  2669. </if>
  2670. <if test="name != null and name != ''">
  2671. AND a.name like CONCAT('%',#{name},'%')
  2672. </if>
  2673. GROUP BY
  2674. a.beh_dept_id,
  2675. a.beh_dept_name
  2676. ) t2
  2677. WHERE
  2678. t1.behDeptId = t2.behDeptId
  2679. AND t1.behDeptName = t2.behDeptName
  2680. ORDER BY
  2681. t1.behDeptName,
  2682. t1.behDoctorName,
  2683. t1.patName,
  2684. t1.behospitalCode,
  2685. t1.caseName
  2686. </select>
  2687. <!-- 条目缺陷质控评分页(内页)-->
  2688. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  2689. SELECT t.*
  2690. FROM
  2691. (SELECT DISTINCT
  2692. t1.hospital_id AS hospitalId,
  2693. t1.behospital_code AS behospitalCode,
  2694. t1.bed_code AS bedCode,
  2695. t1.LEVEL AS LEVEL,
  2696. t1.grade_type AS gradeType,
  2697. t1.score_res AS scoreRes,
  2698. t1.NAME AS NAME,
  2699. t1.sex AS sex,
  2700. t1.beh_dept_id AS behDeptId,
  2701. t1.beh_dept_name AS behDeptName,
  2702. t1.doctor_id AS doctorId,
  2703. t1.doctor_name AS doctorName,
  2704. t1.beh_doctor_id AS behDoctorId,
  2705. t1.beh_doctor_name AS behDoctorName,
  2706. t1.director_doctor_id AS directorDoctorId,
  2707. t1.director_doctor_name AS directorDoctorName,
  2708. t1.birthday AS birthday,
  2709. t1.behospital_date AS behospitalDate,
  2710. t1.leave_hospital_date AS leaveHospitalDate,
  2711. t1.placefile_date AS placefileDate,
  2712. t1.gmt_create AS gradeTime,
  2713. t1.diagnose,
  2714. t1.ward_name AS wardName,
  2715. t2.age,
  2716. t1.file_code AS fileCode,
  2717. t1.checkStatus
  2718. FROM
  2719. (
  2720. SELECT DISTINCT
  2721. tt1.*
  2722. FROM
  2723. (SELECT
  2724. be.*,
  2725. mci.status AS checkStatus
  2726. FROM
  2727. (
  2728. SELECT DISTINCT
  2729. a.hospital_id,
  2730. a.behospital_code,
  2731. a.bed_code,
  2732. a.file_code,
  2733. b.LEVEL,
  2734. b.grade_type,
  2735. b.score_res,
  2736. a.NAME,
  2737. a.sex,
  2738. a.beh_dept_id,
  2739. a.beh_dept_name,
  2740. a.birthday,
  2741. a.behospital_date,
  2742. a.leave_hospital_date,
  2743. a.doctor_id,
  2744. a.doctor_name,
  2745. a.beh_doctor_id,
  2746. a.beh_doctor_name,
  2747. a.director_doctor_id,
  2748. a.director_doctor_name,
  2749. a.diagnose,
  2750. a.placefile_date,
  2751. a.ward_name,
  2752. b.gmt_create
  2753. FROM
  2754. med_behospital_info a,
  2755. med_qcresult_info b,
  2756. med_qcresult_detail c,
  2757. qc_cases_entry d
  2758. WHERE
  2759. a.is_deleted = 'N'
  2760. AND b.is_deleted = 'N'
  2761. AND c.is_deleted = 'N'
  2762. AND d.is_deleted = 'N'
  2763. AND a.hospital_id = b.hospital_id
  2764. AND a.hospital_id = c.hospital_id
  2765. AND a.behospital_code = b.behospital_code
  2766. AND a.behospital_code = c.behospital_code
  2767. AND c.cases_id = d.cases_id
  2768. AND c.cases_entry_id = d.id
  2769. AND a.qc_type_id != 0
  2770. AND a.is_placefile = 1
  2771. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  2772. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  2773. </if>
  2774. <if test="qcResultShortPageVO.startDate != null">
  2775. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  2776. </if>
  2777. <if test="qcResultShortPageVO.endDate != null ">
  2778. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  2779. </if>
  2780. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  2781. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  2782. </if>
  2783. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  2784. AND b.`level` = #{qcResultShortPageVO.level}
  2785. </if>
  2786. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  2787. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  2788. </if>
  2789. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  2790. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  2791. </if>
  2792. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  2793. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  2794. </if>
  2795. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  2796. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2797. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2798. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  2799. </if>
  2800. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  2801. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2802. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2803. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  2804. </if>
  2805. <if test="qcResultShortPageVO.casesEntryId != null ">
  2806. AND d.id = #{qcResultShortPageVO.casesEntryId}
  2807. </if>
  2808. <if test="qcResultShortPageVO.isReject != null">
  2809. AND c.is_reject = #{qcResultShortPageVO.isReject}
  2810. </if>
  2811. <if test="qcResultShortPageVO.ruleType != null">
  2812. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  2813. </if>
  2814. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  2815. AND TIMESTAMPDIFF(
  2816. DAY,
  2817. DATE( a.behospital_date ),
  2818. DATE( a.leave_hospital_date ))> 30
  2819. </if>
  2820. )be
  2821. left join med_check_info mci
  2822. on mci.is_deleted='N'
  2823. and be.hospital_id=mci.hospital_id
  2824. and be.behospital_code=mci.behospital_code
  2825. )tt1
  2826. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  2827. ,med_medical_record tt2
  2828. WHERE
  2829. tt2.is_deleted = 'N'
  2830. AND tt1.hospital_id = tt2.hospital_id
  2831. AND tt1.behospital_code = tt2.behospital_code
  2832. AND tt2.mode_id = 30
  2833. </if>
  2834. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  2835. ,med_crisis_info tt2
  2836. WHERE
  2837. tt2.is_deleted = 'N'
  2838. AND tt1.hospital_id = tt2.hospital_id
  2839. AND tt1.behospital_code = tt2.behospital_code
  2840. </if>
  2841. ) t1
  2842. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  2843. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  2844. AND t1.behospital_code = t2.behospital_code
  2845. AND t2.is_deleted = 'N'
  2846. </if>
  2847. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  2848. , med_home_page t2
  2849. , med_home_operation_info t3
  2850. WHERE t1.hospital_id = t2.hospital_id
  2851. AND t1.behospital_code = t2.behospital_code
  2852. AND t2.home_page_id = t3.home_page_id
  2853. AND t2.is_deleted = 'N'
  2854. AND t3.is_deleted = 'N'
  2855. </if>
  2856. ) t
  2857. where 1=1
  2858. <if test="qcResultShortPageVO.checkStatus != null">
  2859. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  2860. </if>
  2861. </select>
  2862. <!-- 条目缺陷质控评分页-科室(内页)-->
  2863. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  2864. SELECT DISTINCT
  2865. t1.hospital_id AS hospitalId,
  2866. t1.behospital_code AS behospitalCode,
  2867. t1.bed_code AS bedCode,
  2868. t1.LEVEL AS LEVEL,
  2869. t1.grade_type AS gradeType,
  2870. t1.score_res AS scoreRes,
  2871. t1.NAME AS NAME,
  2872. t1.sex AS sex,
  2873. t1.beh_dept_id AS behDeptId,
  2874. t1.beh_dept_name AS behDeptName,
  2875. t1.doctor_id AS doctorId,
  2876. t1.doctor_name AS doctorName,
  2877. t1.beh_doctor_id AS behDoctorId,
  2878. t1.beh_doctor_name AS behDoctorName,
  2879. t1.director_doctor_id AS directorDoctorId,
  2880. t1.director_doctor_name AS directorDoctorName,
  2881. t1.birthday AS birthday,
  2882. t1.behospital_date AS behospitalDate,
  2883. t1.leave_hospital_date AS leaveHospitalDate,
  2884. t1.placefile_date AS placefileDate,
  2885. t1.gmt_create AS gradeTime,
  2886. t1.diagnose,
  2887. t1.ward_name AS wardName,
  2888. t2.age,
  2889. t1.file_code AS fileCode
  2890. FROM
  2891. (
  2892. SELECT DISTINCT
  2893. a.hospital_id,
  2894. a.behospital_code,
  2895. a.bed_code,
  2896. a.file_code,
  2897. b.LEVEL,
  2898. b.grade_type,
  2899. b.score_res,
  2900. a.NAME,
  2901. a.sex,
  2902. a.beh_dept_id,
  2903. a.beh_dept_name,
  2904. a.birthday,
  2905. a.behospital_date,
  2906. a.leave_hospital_date,
  2907. a.doctor_id,
  2908. a.doctor_name,
  2909. a.beh_doctor_id,
  2910. a.beh_doctor_name,
  2911. a.director_doctor_id,
  2912. a.director_doctor_name,
  2913. a.diagnose,
  2914. a.placefile_date,
  2915. a.ward_name,
  2916. b.gmt_create
  2917. FROM
  2918. med_behospital_info a,
  2919. med_qcresult_info b,
  2920. med_qcresult_detail c,
  2921. qc_cases_entry d,
  2922. sys_user_dept e
  2923. WHERE
  2924. a.is_deleted = 'N'
  2925. AND b.is_deleted = 'N'
  2926. AND c.is_deleted = 'N'
  2927. AND d.is_deleted = 'N'
  2928. AND e.is_deleted = 'N'
  2929. AND a.hospital_id = b.hospital_id
  2930. AND a.hospital_id = c.hospital_id
  2931. AND a.hospital_id = e.hospital_id
  2932. AND a.behospital_code = b.behospital_code
  2933. AND a.behospital_code = c.behospital_code
  2934. AND a.beh_dept_id = e.dept_id
  2935. AND c.cases_id = d.cases_id
  2936. AND c.cases_entry_id = d.id
  2937. AND a.qc_type_id != 0
  2938. AND a.is_placefile = 1
  2939. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  2940. AND e.user_id = #{qcResultShortPageVO.userId}
  2941. </if>
  2942. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  2943. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  2944. </if>
  2945. <if test="qcResultShortPageVO.startDate != null">
  2946. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  2947. </if>
  2948. <if test="qcResultShortPageVO.endDate != null ">
  2949. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  2950. </if>
  2951. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  2952. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  2953. </if>
  2954. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  2955. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  2956. </if>
  2957. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  2958. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2959. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2960. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  2961. </if>
  2962. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  2963. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2964. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2965. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  2966. </if>
  2967. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  2968. AND b.`level` = #{qcResultShortPageVO.level}
  2969. </if>
  2970. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  2971. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  2972. </if>
  2973. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  2974. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  2975. </if>
  2976. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  2977. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  2978. </if>
  2979. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  2980. AND d.id = #{qcResultShortPageVO.casesEntryId}
  2981. </if>
  2982. <if test="qcResultShortPageVO.isReject != null">
  2983. AND c.is_reject = #{qcResultShortPageVO.isReject}
  2984. </if>
  2985. <if test="qcResultShortPageVO.ruleType != null">
  2986. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  2987. </if>
  2988. ) t1
  2989. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  2990. AND t1.behospital_code = t2.behospital_code
  2991. AND t2.is_deleted = 'N'
  2992. </select>
  2993. <update id="updateBatchByKey">
  2994. <foreach collection="list" item="item" separator=";">
  2995. update med_behospital_info
  2996. <set>
  2997. <if test="item.name != null">
  2998. name = #{item.name},
  2999. </if>
  3000. <if test="item.sex != null">
  3001. sex = #{item.sex},
  3002. </if>
  3003. <if test="item.birthday != null">
  3004. birthday = #{item.birthday},
  3005. </if>
  3006. <if test="item.fileCode != null">
  3007. file_code = #{item.fileCode},
  3008. </if>
  3009. <if test="item.qcTypeId != null">
  3010. qc_type_id = #{item.qcTypeId},
  3011. </if>
  3012. <if test="item.wardCode != null">
  3013. ward_code = #{item.wardCode},
  3014. </if>
  3015. <if test="item.wardName != null">
  3016. ward_name = #{item.wardName},
  3017. </if>
  3018. <if test="item.behDeptId != null">
  3019. beh_dept_id = #{item.behDeptId},
  3020. </if>
  3021. <if test="item.behDeptName != null">
  3022. beh_dept_name = #{item.behDeptName},
  3023. </if>
  3024. <if test="item.bedCode != null">
  3025. bed_code = #{item.bedCode},
  3026. </if>
  3027. <if test="item.bedName != null">
  3028. bed_name = #{item.bedName},
  3029. </if>
  3030. <if test="item.insuranceName != null">
  3031. insurance_name = #{item.insuranceName},
  3032. </if>
  3033. <if test="item.jobType != null">
  3034. job_type = #{item.jobType},
  3035. </if>
  3036. <if test="item.behospitalDate != null">
  3037. behospital_date = #{item.behospitalDate},
  3038. </if>
  3039. <if test="item.leaveHospitalDate != null">
  3040. leave_hospital_date = #{item.leaveHospitalDate},
  3041. </if>
  3042. <if test="item.diagnoseIcd != null">
  3043. diagnose_icd = #{item.diagnoseIcd},
  3044. </if>
  3045. <if test="item.diagnose != null">
  3046. diagnose = #{item.diagnose},
  3047. </if>
  3048. <if test="item.behDoctorId != null">
  3049. beh_doctor_id = #{item.behDoctorId},
  3050. </if>
  3051. <if test="item.behDoctorName != null">
  3052. beh_doctor_name = #{item.behDoctorName},
  3053. </if>
  3054. <if test="item.doctorId != null">
  3055. doctor_id = #{item.doctorId},
  3056. </if>
  3057. <if test="item.doctorName != null">
  3058. doctor_name = #{item.doctorName},
  3059. </if>
  3060. <if test="item.directorDoctorId != null">
  3061. director_doctor_id = #{item.directorDoctorId},
  3062. </if>
  3063. <if test="item.directorDoctorName != null">
  3064. director_doctor_name = #{item.directorDoctorName},
  3065. </if>
  3066. <if test="item.placefileDate != null">
  3067. placefile_date = #{item.placefileDate},
  3068. </if>
  3069. <if test="item.isPlacefile != null">
  3070. is_placefile = #{item.isPlacefile},
  3071. </if>
  3072. <if test="item.gmtModified != null">
  3073. gmt_modified = #{item.gmtModified},
  3074. </if>
  3075. <if test="item.modifier != null">
  3076. modifier = #{item.modifier},
  3077. </if>
  3078. </set>
  3079. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  3080. </foreach>
  3081. </update>
  3082. <!-- 关键条目缺陷统计报表-->
  3083. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  3084. SELECT
  3085. deptId,
  3086. deptName,
  3087. consultationMRNum,
  3088. consultationNum,
  3089. 2511 AS consultationEntryId,
  3090. '普通会诊未在24小时内完成' AS consultationEntryName,
  3091. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  3092. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  3093. operationMRNum,
  3094. 2594 AS operationNameEntryId,
  3095. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  3096. operationNameNum,
  3097. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  3098. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  3099. 2973 AS operationTimeEntryId,
  3100. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  3101. operationTimeNum,
  3102. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  3103. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  3104. 2930 AS operation15MinuteEntryId,
  3105. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  3106. operation15MinuteNum,
  3107. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  3108. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  3109. 2419 AS crisisEntryId,
  3110. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  3111. crisisMRNum,
  3112. crisisNum,
  3113. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  3114. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  3115. 2495 AS stageSummaryEntryId,
  3116. '无阶段小结' AS stageSummaryEntryName,
  3117. stageSummaryMRNum,
  3118. stageSummaryNum,
  3119. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  3120. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr
  3121. FROM
  3122. (
  3123. SELECT
  3124. tt.deptId,
  3125. tt.deptName,
  3126. sum( tt.consultationNum ) AS consultationNum,
  3127. sum( tt.consultationMRNum ) AS consultationMRNum,
  3128. sum( tt.operationNameNum ) AS operationNameNum,
  3129. sum( tt.operationTimeNum ) AS operationTimeNum,
  3130. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  3131. sum( tt.operationMRNum ) AS operationMRNum,
  3132. sum( tt.crisisNum ) AS crisisNum,
  3133. sum( tt.crisisMRNum ) AS crisisMRNum,
  3134. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  3135. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum
  3136. FROM
  3137. (
  3138. (
  3139. SELECT
  3140. c.beh_dept_id AS deptId,
  3141. c.beh_dept_name AS deptName,
  3142. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  3143. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  3144. 0 AS operationNameNum,
  3145. 0 AS operationTimeNum,
  3146. 0 AS operation15MinuteNum,
  3147. 0 AS operationMRNum,
  3148. 0 AS crisisNum,
  3149. 0 AS crisisMRNum,
  3150. 0 AS stageSummaryNum,
  3151. 0 AS stageSummaryMRNum
  3152. FROM
  3153. (
  3154. SELECT DISTINCT
  3155. a.hospital_id,
  3156. a.behospital_code,
  3157. a.beh_dept_name,
  3158. a.beh_dept_id
  3159. FROM
  3160. med_behospital_info a,
  3161. med_medical_record b
  3162. WHERE
  3163. a.is_deleted = 'N'
  3164. AND b.is_deleted = 'N'
  3165. AND a.hospital_id = b.hospital_id
  3166. AND a.behospital_code = b.behospital_code
  3167. AND b.mode_id = 30
  3168. AND a.is_placefile = '1'
  3169. AND a.qc_type_id != 0
  3170. <if test="hospitalId != null and hospitalId != ''">
  3171. AND a.hospital_id = #{hospitalId}
  3172. </if>
  3173. <if test="startDate != null">
  3174. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3175. </if>
  3176. <if test="endDate != null">
  3177. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3178. </if>
  3179. <if test="deptName != null and deptName != ''">
  3180. AND a.beh_dept_name = #{deptName}
  3181. </if>
  3182. ) c
  3183. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  3184. AND c.hospital_id = d.hospital_id
  3185. AND c.behospital_code = d.behospital_code
  3186. GROUP BY
  3187. c.beh_dept_id,
  3188. c.beh_dept_name
  3189. ) UNION
  3190. (
  3191. SELECT
  3192. d.beh_dept_id AS deptId,
  3193. d.beh_dept_name AS deptName,
  3194. 0 AS consultationNum,
  3195. 0 AS consultationMRNum,
  3196. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  3197. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  3198. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  3199. count( DISTINCT d.behospital_code ) AS operationMRNum,
  3200. 0 AS crisisNum,
  3201. 0 AS crisisMRNum,
  3202. 0 AS stageSummaryNum,
  3203. 0 AS stageSummaryMRNum
  3204. FROM
  3205. (
  3206. SELECT DISTINCT
  3207. a.hospital_id,
  3208. a.behospital_code,
  3209. a.beh_dept_name,
  3210. a.beh_dept_id
  3211. FROM
  3212. med_behospital_info a,
  3213. med_home_page b,
  3214. med_home_operation_info c
  3215. WHERE
  3216. a.is_deleted = 'N'
  3217. AND b.is_deleted = 'N'
  3218. AND c.is_deleted = 'N'
  3219. AND a.hospital_id = b.hospital_id
  3220. AND a.hospital_id = c.hospital_id
  3221. AND a.behospital_code = b.behospital_code
  3222. AND b.home_page_id = c.home_page_id
  3223. AND a.is_placefile = '1'
  3224. AND a.qc_type_id != 0
  3225. <if test="hospitalId != null and hospitalId != ''">
  3226. AND a.hospital_id = #{hospitalId}
  3227. </if>
  3228. <if test="startDate != null">
  3229. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3230. </if>
  3231. <if test="endDate != null">
  3232. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3233. </if>
  3234. <if test="deptName != null and deptName != ''">
  3235. AND a.beh_dept_name = #{deptName}
  3236. </if>
  3237. ) d
  3238. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  3239. AND d.hospital_id = e.hospital_id
  3240. AND d.behospital_code = e.behospital_code
  3241. GROUP BY
  3242. d.beh_dept_id,
  3243. d.beh_dept_name
  3244. ) UNION
  3245. (
  3246. SELECT
  3247. c.beh_dept_id AS deptId,
  3248. c.beh_dept_name AS deptName,
  3249. 0 AS consultationNum,
  3250. 0 AS consultationMRNum,
  3251. 0 AS operationNameNum,
  3252. 0 AS operationTimeNum,
  3253. 0 AS operation15MinuteNum,
  3254. 0 AS operationMRNum,
  3255. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  3256. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  3257. 0 AS stageSummaryNum,
  3258. 0 AS stageSummaryMRNum
  3259. FROM
  3260. (
  3261. SELECT DISTINCT
  3262. a.hospital_id,
  3263. a.behospital_code,
  3264. a.beh_dept_name,
  3265. a.beh_dept_id
  3266. FROM
  3267. med_behospital_info a,
  3268. med_crisis_info b
  3269. WHERE
  3270. a.is_deleted = 'N'
  3271. AND b.is_deleted = 'N'
  3272. AND a.hospital_id = b.hospital_id
  3273. AND a.behospital_code = b.behospital_code
  3274. AND a.is_placefile = '1'
  3275. AND a.qc_type_id != 0
  3276. <if test="hospitalId != null and hospitalId != ''">
  3277. AND a.hospital_id = #{hospitalId}
  3278. </if>
  3279. <if test="startDate != null">
  3280. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3281. </if>
  3282. <if test="endDate != null">
  3283. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3284. </if>
  3285. <if test="deptName != null and deptName != ''">
  3286. AND a.beh_dept_name = #{deptName}
  3287. </if>
  3288. ) c
  3289. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  3290. AND c.hospital_id = d.hospital_id
  3291. AND c.behospital_code = d.behospital_code
  3292. GROUP BY
  3293. c.beh_dept_id,
  3294. c.beh_dept_name
  3295. ) UNION
  3296. (
  3297. SELECT
  3298. b.beh_dept_id AS deptId,
  3299. b.beh_dept_name AS deptName,
  3300. 0 AS consultationNum,
  3301. 0 AS consultationMRNum,
  3302. 0 AS operationNameNum,
  3303. 0 AS operationTimeNum,
  3304. 0 AS operation15MinuteNum,
  3305. 0 AS operationMRNum,
  3306. 0 AS crisisNum,
  3307. 0 AS crisisMRNum,
  3308. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  3309. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum
  3310. FROM
  3311. (
  3312. SELECT DISTINCT
  3313. a.hospital_id,
  3314. a.behospital_code,
  3315. a.beh_dept_name,
  3316. a.beh_dept_id
  3317. FROM
  3318. med_behospital_info a
  3319. WHERE
  3320. a.is_deleted = 'N'
  3321. AND TIMESTAMPDIFF(
  3322. DAY,
  3323. DATE( behospital_date ),
  3324. DATE( leave_hospital_date ))> 30
  3325. AND a.is_placefile = '1'
  3326. AND a.qc_type_id != 0
  3327. <if test="hospitalId != null and hospitalId != ''">
  3328. AND a.hospital_id = #{hospitalId}
  3329. </if>
  3330. <if test="startDate != null">
  3331. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3332. </if>
  3333. <if test="endDate != null">
  3334. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3335. </if>
  3336. <if test="deptName != null and deptName != ''">
  3337. AND a.beh_dept_name = #{deptName}
  3338. </if>
  3339. ) b
  3340. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  3341. AND b.hospital_id = c.hospital_id
  3342. AND b.behospital_code = c.behospital_code
  3343. GROUP BY
  3344. b.beh_dept_id,
  3345. b.beh_dept_name
  3346. )
  3347. ) tt
  3348. GROUP BY
  3349. tt.deptId,
  3350. tt.deptName
  3351. ) t
  3352. <if test="asc != null and asc !=''">
  3353. order by
  3354. <choose>
  3355. <when test='asc=="deptId"'>deptId asc</when>
  3356. <when test='asc=="deptName"'>deptName asc</when>
  3357. <when test='asc=="consultationNum"'>consultationNum asc</when>
  3358. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  3359. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  3360. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  3361. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  3362. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  3363. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  3364. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  3365. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  3366. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  3367. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  3368. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  3369. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  3370. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  3371. <when test='asc=="crisisNum"'>crisisNum asc</when>
  3372. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  3373. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  3374. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  3375. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  3376. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  3377. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  3378. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  3379. <otherwise>deptName asc</otherwise>
  3380. </choose>
  3381. </if>
  3382. <if test="desc != null and desc!=''">
  3383. order by
  3384. <choose>
  3385. <when test='desc=="deptId"'>deptId desc</when>
  3386. <when test='desc=="deptName"'>deptName desc</when>
  3387. <when test='desc=="consultationNum"'>consultationNum desc</when>
  3388. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  3389. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  3390. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  3391. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  3392. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  3393. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  3394. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  3395. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  3396. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  3397. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  3398. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  3399. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  3400. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  3401. <when test='desc=="crisisNum"'>crisisNum desc</when>
  3402. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  3403. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  3404. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  3405. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  3406. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  3407. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  3408. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  3409. <otherwise>deptName desc</otherwise>
  3410. </choose>
  3411. </if>
  3412. </select>
  3413. <!-- 非医嘱离院病人记录-->
  3414. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  3415. SELECT
  3416. count(*)
  3417. FROM
  3418. med_behospital_info a,
  3419. med_home_page b
  3420. WHERE
  3421. a.is_deleted = 'N'
  3422. AND b.is_deleted = 'N'
  3423. AND a.hospital_id = b.hospital_id
  3424. AND a.behospital_code = b.behospital_code
  3425. AND b.leave_hospital_type = '非医嘱离院'
  3426. AND a.is_placefile = '1'
  3427. AND a.qc_type_id != 0
  3428. <if test="hospitalId != null and hospitalId != ''">
  3429. AND a.hospital_id = #{hospitalId}
  3430. </if>
  3431. <if test="startDate != null">
  3432. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3433. </if>
  3434. <if test="endDate != null">
  3435. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3436. </if>
  3437. </select>
  3438. <!-- 31天内再入院记录-->
  3439. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  3440. SELECT
  3441. count(*)
  3442. FROM
  3443. (
  3444. SELECT
  3445. bc1.file_code,
  3446. bc1.diagnose,
  3447. bc1.behospitalCode,
  3448. bc1.behospitalDate,
  3449. bc1.leaveHospitalDate
  3450. FROM
  3451. (
  3452. SELECT
  3453. t1.file_code,
  3454. t1.diagnose,
  3455. t1.behospital_code AS behospitalCode,
  3456. t1.leave_hospital_date AS leaveHospitalDate,
  3457. t2.behospital_code AS lastBehospitalCode,
  3458. t2.behospital_date AS lastBehospitalDate,
  3459. t1.behospital_date AS behospitalDate,
  3460. t2.leave_hospital_date AS lastLeaveHospitalDate
  3461. FROM
  3462. (
  3463. SELECT
  3464. tt1.file_code,
  3465. tt1.diagnose,
  3466. tt2.behospital_code,
  3467. tt2.behospital_date,
  3468. tt2.leave_hospital_date
  3469. FROM
  3470. (
  3471. SELECT
  3472. a.file_code,
  3473. a.diagnose
  3474. FROM
  3475. med_behospital_info a
  3476. WHERE
  3477. a.is_deleted = 'N'
  3478. AND a.is_placefile = '1'
  3479. AND a.qc_type_id != 0
  3480. <if test="hospitalId != null and hospitalId != ''">
  3481. AND a.hospital_id = #{hospitalId}
  3482. </if>
  3483. <if test="startDate != null">
  3484. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3485. </if>
  3486. <if test="endDate != null">
  3487. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3488. </if>
  3489. AND IFNULL( a.diagnose, '' )!= ''
  3490. GROUP BY
  3491. a.file_code,
  3492. a.diagnose
  3493. HAVING
  3494. count(*)> 1
  3495. ) tt1,
  3496. med_behospital_info tt2
  3497. WHERE
  3498. tt2.is_deleted = 'N'
  3499. AND tt2.is_placefile = 1
  3500. AND tt2.qc_type_id != 0
  3501. AND tt1.file_code = tt2.file_code
  3502. AND tt1.diagnose = tt2.diagnose
  3503. <if test="hospitalId != null and hospitalId != ''">
  3504. AND tt2.hospital_id = #{hospitalId}
  3505. </if>
  3506. <if test="startDate != null">
  3507. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3508. </if>
  3509. <if test="endDate != null">
  3510. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3511. </if>
  3512. ORDER BY
  3513. tt1.file_code,
  3514. tt1.diagnose,
  3515. tt2.behospital_date DESC
  3516. ) t1,
  3517. (
  3518. SELECT
  3519. tt1.file_code,
  3520. tt1.diagnose,
  3521. tt2.behospital_code,
  3522. tt2.behospital_date,
  3523. tt2.leave_hospital_date
  3524. FROM
  3525. (
  3526. SELECT
  3527. a.file_code,
  3528. a.diagnose
  3529. FROM
  3530. med_behospital_info a
  3531. WHERE
  3532. a.is_deleted = 'N'
  3533. AND a.is_placefile = 1
  3534. AND a.qc_type_id != 0
  3535. AND a.hospital_id = 1
  3536. AND IFNULL( a.diagnose, '' )!= ''
  3537. GROUP BY
  3538. a.file_code,
  3539. a.diagnose
  3540. HAVING
  3541. count(*)> 1
  3542. ) tt1,
  3543. med_behospital_info tt2
  3544. WHERE
  3545. tt2.is_deleted = 'N'
  3546. AND tt2.is_placefile = 1
  3547. AND tt2.qc_type_id != 0
  3548. AND tt1.file_code = tt2.file_code
  3549. AND tt1.diagnose = tt2.diagnose
  3550. <if test="hospitalId != null and hospitalId != ''">
  3551. AND tt2.hospital_id = #{hospitalId}
  3552. </if>
  3553. <if test="startDate != null">
  3554. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3555. </if>
  3556. <if test="endDate != null">
  3557. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3558. </if>
  3559. ORDER BY
  3560. tt1.file_code,
  3561. tt1.diagnose,
  3562. tt2.behospital_date DESC
  3563. ) t2
  3564. WHERE
  3565. t1.file_code = t2.file_code
  3566. AND t1.diagnose = t2.diagnose
  3567. AND t1.behospital_code != t2.behospital_code
  3568. AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
  3569. SELECT
  3570. bc2.file_code,
  3571. bc2.diagnose,
  3572. bc2.lastBehospitalCode,
  3573. bc2.lastBehospitalDate,
  3574. bc2.lastLeaveHospitalDate
  3575. FROM
  3576. (
  3577. SELECT
  3578. t1.file_code,
  3579. t1.diagnose,
  3580. t1.behospital_code AS behospitalCode,
  3581. t1.leave_hospital_date AS leaveHospitalDate,
  3582. t2.behospital_code AS lastBehospitalCode,
  3583. t2.behospital_date AS lastBehospitalDate,
  3584. t1.behospital_date AS behospitalDate,
  3585. t2.leave_hospital_date AS lastLeaveHospitalDate
  3586. FROM
  3587. (
  3588. SELECT
  3589. tt1.file_code,
  3590. tt1.diagnose,
  3591. tt2.behospital_code,
  3592. tt2.behospital_date,
  3593. tt2.leave_hospital_date
  3594. FROM
  3595. (
  3596. SELECT
  3597. a.file_code,
  3598. a.diagnose
  3599. FROM
  3600. med_behospital_info a
  3601. WHERE
  3602. a.is_deleted = 'N'
  3603. AND a.is_placefile = '1'
  3604. AND a.qc_type_id != 0
  3605. <if test="hospitalId != null and hospitalId != ''">
  3606. AND a.hospital_id = #{hospitalId}
  3607. </if>
  3608. <if test="startDate != null">
  3609. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3610. </if>
  3611. <if test="endDate != null">
  3612. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3613. </if>
  3614. AND IFNULL( a.diagnose, '' )!= ''
  3615. GROUP BY
  3616. a.file_code,
  3617. a.diagnose
  3618. HAVING
  3619. count(*)> 1
  3620. ) tt1,
  3621. med_behospital_info tt2
  3622. WHERE
  3623. tt2.is_deleted = 'N'
  3624. AND tt2.is_placefile = 1
  3625. AND tt2.qc_type_id != 0
  3626. AND tt1.file_code = tt2.file_code
  3627. AND tt1.diagnose = tt2.diagnose
  3628. <if test="hospitalId != null and hospitalId != ''">
  3629. AND tt2.hospital_id = #{hospitalId}
  3630. </if>
  3631. <if test="startDate != null">
  3632. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3633. </if>
  3634. <if test="endDate != null">
  3635. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3636. </if>
  3637. ORDER BY
  3638. tt1.file_code,
  3639. tt1.diagnose,
  3640. tt2.behospital_date DESC
  3641. ) t1,
  3642. (
  3643. SELECT
  3644. tt1.file_code,
  3645. tt1.diagnose,
  3646. tt2.behospital_code,
  3647. tt2.behospital_date,
  3648. tt2.leave_hospital_date
  3649. FROM
  3650. (
  3651. SELECT
  3652. a.file_code,
  3653. a.diagnose
  3654. FROM
  3655. med_behospital_info a
  3656. WHERE
  3657. a.is_deleted = 'N'
  3658. AND a.is_placefile = 1
  3659. AND a.qc_type_id != 0
  3660. AND a.hospital_id = 1
  3661. AND IFNULL( a.diagnose, '' )!= ''
  3662. GROUP BY
  3663. a.file_code,
  3664. a.diagnose
  3665. HAVING
  3666. count(*)> 1
  3667. ) tt1,
  3668. med_behospital_info tt2
  3669. WHERE
  3670. tt2.is_deleted = 'N'
  3671. AND tt2.is_placefile = 1
  3672. AND tt2.qc_type_id != 0
  3673. AND tt1.file_code = tt2.file_code
  3674. AND tt1.diagnose = tt2.diagnose
  3675. <if test="hospitalId != null and hospitalId != ''">
  3676. AND tt2.hospital_id = #{hospitalId}
  3677. </if>
  3678. <if test="startDate != null">
  3679. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3680. </if>
  3681. <if test="endDate != null">
  3682. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3683. </if>
  3684. ORDER BY
  3685. tt1.file_code,
  3686. tt1.diagnose,
  3687. tt2.behospital_date DESC
  3688. ) t2
  3689. WHERE
  3690. t1.file_code = t2.file_code
  3691. AND t1.diagnose = t2.diagnose
  3692. AND t1.behospital_code != t2.behospital_code
  3693. AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
  3694. ) t
  3695. </select>
  3696. <!-- 病案首页质控病历数统计-全院(首页)-->
  3697. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  3698. SELECT
  3699. count( * ) AS mrNum,
  3700. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3701. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3702. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3703. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3704. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3705. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3706. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3707. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3708. FROM
  3709. med_behospital_info a,
  3710. med_qcresult_cases c
  3711. WHERE
  3712. a.is_deleted = 'N'
  3713. AND c.is_deleted = 'N'
  3714. AND a.hospital_id = c.hospital_id
  3715. AND a.behospital_code = c.behospital_code
  3716. AND c.cases_id = 243
  3717. AND a.is_placefile = '1'
  3718. AND a.qc_type_id != 0
  3719. <if test="hospitalId != null and hospitalId != ''">
  3720. AND a.hospital_id = #{hospitalId}
  3721. </if>
  3722. <if test="startDate != null">
  3723. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3724. </if>
  3725. <if test="endDate != null">
  3726. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3727. </if>
  3728. </select>
  3729. <!-- 病案首页完整率统计-全院(首页)-->
  3730. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  3731. SELECT
  3732. h1.emptyNum,
  3733. h1.mrNum,
  3734. h2.entryNum,
  3735. h1.mrNum * h2.entryNum AS entryTotleNum,
  3736. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3737. CONCAT(
  3738. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  3739. '%'
  3740. ) AS emptyPercentStr
  3741. FROM
  3742. (
  3743. SELECT
  3744. sum( d.rule_type = 1 ) AS emptyNum,
  3745. count( DISTINCT a.behospital_code ) AS mrNum
  3746. FROM
  3747. med_behospital_info a,
  3748. med_qcresult_cases b,
  3749. med_qcresult_detail c,
  3750. qc_cases_entry d
  3751. WHERE
  3752. a.is_deleted = 'N'
  3753. AND b.is_deleted = 'N'
  3754. AND c.is_deleted = 'N'
  3755. AND d.is_deleted = 'N'
  3756. AND a.hospital_id = b.hospital_id
  3757. AND a.hospital_id = c.hospital_id
  3758. AND a.behospital_code = b.behospital_code
  3759. AND a.behospital_code = c.behospital_code
  3760. AND b.cases_id = c.cases_id
  3761. AND c.cases_id = d.cases_id
  3762. AND c.cases_entry_id = d.id
  3763. AND a.is_placefile = '1'
  3764. AND d.cases_id = 243
  3765. AND a.qc_type_id != 0
  3766. <if test="hospitalId != null and hospitalId != ''">
  3767. AND a.hospital_id = #{hospitalId}
  3768. </if>
  3769. <if test="startDate != null">
  3770. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3771. </if>
  3772. <if test="endDate != null">
  3773. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3774. </if>
  3775. ) h1,(
  3776. SELECT
  3777. count(*) AS entryNum
  3778. FROM
  3779. qc_cases_entry
  3780. WHERE
  3781. is_deleted = 'N'
  3782. AND cases_id = 243
  3783. ) h2
  3784. </select>
  3785. <!-- 离院病人评分详情页-->
  3786. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  3787. SELECT DISTINCT
  3788. t1.hospital_id AS hospitalId,
  3789. t1.behospital_code AS behospitalCode,
  3790. t1.bed_code AS bedCode,
  3791. t1.LEVEL AS LEVEL,
  3792. t1.grade_type AS gradeType,
  3793. t1.score_res AS scoreRes,
  3794. t1.NAME AS NAME,
  3795. t1.sex AS sex,
  3796. t1.beh_dept_id AS behDeptId,
  3797. t1.beh_dept_name AS behDeptName,
  3798. t1.doctor_id AS doctorId,
  3799. t1.doctor_name AS doctorName,
  3800. t1.beh_doctor_id AS behDoctorId,
  3801. t1.beh_doctor_name AS behDoctorName,
  3802. t1.director_doctor_id AS directorDoctorId,
  3803. t1.director_doctor_name AS directorDoctorName,
  3804. t1.birthday AS birthday,
  3805. t1.behospital_date AS behospitalDate,
  3806. t1.leave_hospital_date AS leaveHospitalDate,
  3807. t1.placefile_date AS placefileDate,
  3808. t1.gmt_create AS gradeTime,
  3809. t1.diagnose,
  3810. t1.ward_name AS wardName,
  3811. t1.status AS checkStatus,
  3812. t2.age,
  3813. t2.file_code AS fileCode
  3814. FROM
  3815. (
  3816. SELECT be.*,mci.status
  3817. FROM
  3818. (
  3819. SELECT DISTINCT
  3820. tt1.*
  3821. FROM
  3822. (
  3823. SELECT
  3824. b.*,
  3825. c.LEVEL,
  3826. c.grade_type,
  3827. c.score_res,
  3828. c.gmt_create
  3829. FROM
  3830. (
  3831. SELECT DISTINCT
  3832. a.hospital_id,
  3833. a.behospital_code,
  3834. a.bed_code,
  3835. a.NAME,
  3836. a.sex,
  3837. a.beh_dept_id,
  3838. a.beh_dept_name,
  3839. a.birthday,
  3840. a.behospital_date,
  3841. a.leave_hospital_date,
  3842. a.doctor_id,
  3843. a.doctor_name,
  3844. a.beh_doctor_id,
  3845. a.beh_doctor_name,
  3846. a.director_doctor_id,
  3847. a.director_doctor_name,
  3848. a.diagnose,
  3849. a.placefile_date,
  3850. a.ward_name
  3851. FROM
  3852. med_behospital_info a
  3853. WHERE
  3854. a.is_deleted = 'N'
  3855. AND a.qc_type_id != 0
  3856. AND a.is_placefile = 1
  3857. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3858. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3859. </if>
  3860. <if test="qcResultShortPageVO.startDate != null">
  3861. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  3862. </if>
  3863. <if test="qcResultShortPageVO.endDate != null ">
  3864. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  3865. </if>
  3866. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  3867. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  3868. </if>
  3869. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3870. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3871. </if>
  3872. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3873. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3874. </if>
  3875. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3876. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3877. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3878. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3879. </if>
  3880. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3881. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3882. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3883. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3884. </if>
  3885. ) b
  3886. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  3887. AND b.hospital_id = c.hospital_id
  3888. AND b.behospital_code = c.behospital_code
  3889. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  3890. AND c.`level` = #{qcResultShortPageVO.level}
  3891. </if>
  3892. ) tt1
  3893. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  3894. ,med_medical_record tt2,
  3895. qc_mode tt3
  3896. WHERE
  3897. tt2.is_deleted = 'N'
  3898. AND tt3.is_deleted = 'N'
  3899. AND tt1.hospital_id = tt2.hospital_id
  3900. AND tt1.behospital_code = tt2.behospital_code
  3901. AND tt2.mode_id = tt3.id
  3902. AND tt3.`name` = '手术记录'
  3903. </if>
  3904. ) be
  3905. <if test="qcResultShortPageVO.checkStatus != null">
  3906. ,med_check_info mci
  3907. WHERE
  3908. mci.is_deleted = 'N'
  3909. AND be.hospital_id = mci.hospital_id
  3910. AND be.behospital_code = mci.behospital_code
  3911. AND mci.status = #{qcResultShortPageVO.checkStatus}
  3912. </if>
  3913. <if test="qcResultShortPageVO.checkStatus == null">
  3914. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  3915. AND be.hospital_id = mci.hospital_id
  3916. AND be.behospital_code = mci.behospital_code
  3917. </if>
  3918. )t1
  3919. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  3920. ,med_home_page t2
  3921. WHERE
  3922. t2.is_deleted = 'N'
  3923. AND t1.hospital_id = t2.hospital_id
  3924. AND t1.behospital_code = t2.behospital_code
  3925. AND (
  3926. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' )
  3927. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' )
  3928. )
  3929. </if>
  3930. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  3931. ,med_home_page t2
  3932. WHERE
  3933. t2.is_deleted = 'N'
  3934. AND t1.hospital_id = t2.hospital_id
  3935. AND t1.behospital_code = t2.behospital_code
  3936. AND t2.return_to_type = '死亡'
  3937. </if>
  3938. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  3939. ,med_home_page t2
  3940. WHERE
  3941. t2.is_deleted = 'N'
  3942. AND t1.hospital_id = t2.hospital_id
  3943. AND t1.behospital_code = t2.behospital_code
  3944. AND t2.leave_hospital_type = '非医嘱离院'
  3945. </if>
  3946. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  3947. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  3948. AND t1.hospital_id = t2.hospital_id
  3949. AND t1.behospital_code = t2.behospital_code
  3950. </if>
  3951. </select>
  3952. <!-- 病案首页改善率统计(首页)-->
  3953. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  3954. SELECT
  3955. t2.homePageMRNum,
  3956. t1.improveNum,
  3957. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  3958. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  3959. t1.improveToPassNum,
  3960. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  3961. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  3962. t1.improveToFullNum,
  3963. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  3964. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  3965. FROM
  3966. (
  3967. SELECT
  3968. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  3969. sum( d.score_res = 20 ) AS improveToFullNum,
  3970. count(*) AS improveNum
  3971. FROM
  3972. med_behospital_info a,
  3973. med_home_page b,
  3974. med_qcresult_info c,
  3975. med_qcresult_cases d,
  3976. (
  3977. SELECT
  3978. m4.*
  3979. FROM
  3980. med_behospital_info m1,
  3981. med_home_page m2,
  3982. med_qcresult_info m3,
  3983. med_qcresult_cases m4
  3984. WHERE
  3985. m1.is_deleted = 'N'
  3986. AND m2.is_deleted = 'N'
  3987. AND m3.is_deleted = 'Y'
  3988. AND m4.is_deleted = 'Y'
  3989. AND m1.hospital_id = m2.hospital_id
  3990. AND m1.hospital_id = m3.hospital_id
  3991. AND m1.hospital_id = m4.hospital_id
  3992. AND m1.behospital_code = m2.behospital_code
  3993. AND m1.behospital_code = m3.behospital_code
  3994. AND m1.behospital_code = m4.behospital_code
  3995. AND m3.have_home_page = 1
  3996. AND m4.cases_id = 243
  3997. AND m1.is_placefile = '1'
  3998. AND m1.qc_type_id != 0
  3999. <if test="hospitalId != null and hospitalId != ''">
  4000. AND m1.hospital_id = #{hospitalId}
  4001. </if>
  4002. <if test="startDate != null">
  4003. <![CDATA[ AND m1.leave_hospital_date >= DATE(#{startDate})]]>
  4004. </if>
  4005. <if test="endDate != null">
  4006. <![CDATA[AND m1.leave_hospital_date < DATE(#{endDate})]]>
  4007. </if>
  4008. GROUP BY
  4009. m1.behospital_code
  4010. ORDER BY
  4011. m1.behospital_code,
  4012. m4.gmt_create
  4013. ) e
  4014. WHERE
  4015. a.is_deleted = 'N'
  4016. AND b.is_deleted = 'N'
  4017. AND c.is_deleted = 'N'
  4018. AND d.is_deleted = 'N'
  4019. AND a.hospital_id = b.hospital_id
  4020. AND a.hospital_id = c.hospital_id
  4021. AND a.hospital_id = d.hospital_id
  4022. AND a.hospital_id = e.hospital_id
  4023. AND a.behospital_code = b.behospital_code
  4024. AND a.behospital_code = c.behospital_code
  4025. AND a.behospital_code = d.behospital_code
  4026. AND a.behospital_code = e.behospital_code
  4027. AND d.cases_id = 243
  4028. AND d.score_res > e.score_res
  4029. AND a.is_placefile = '1'
  4030. AND a.qc_type_id != 0
  4031. <if test="hospitalId != null and hospitalId != ''">
  4032. AND a.hospital_id = #{hospitalId}
  4033. </if>
  4034. <if test="startDate != null">
  4035. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4036. </if>
  4037. <if test="endDate != null">
  4038. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4039. </if>
  4040. ) t1,
  4041. (
  4042. SELECT
  4043. count( DISTINCT a.behospital_code ) AS homePageMRNum
  4044. FROM
  4045. med_behospital_info a,
  4046. med_home_page b,
  4047. med_qcresult_info c
  4048. WHERE
  4049. a.is_deleted = 'N'
  4050. AND b.is_deleted = 'N'
  4051. AND a.hospital_id = b.hospital_id
  4052. AND a.hospital_id = c.hospital_id
  4053. AND a.behospital_code = b.behospital_code
  4054. AND a.behospital_code = c.behospital_code
  4055. AND a.qc_type_id != 0
  4056. AND a.is_placefile = '1'
  4057. <if test="hospitalId != null and hospitalId != ''">
  4058. AND a.hospital_id = #{hospitalId}
  4059. </if>
  4060. <if test="startDate != null">
  4061. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4062. </if>
  4063. <if test="endDate != null">
  4064. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4065. </if>
  4066. ) t2
  4067. </select>
  4068. <!-- 质控核查统计(内页)-->
  4069. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterQcCheckVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  4070. SELECT
  4071. mr.beh_dept_id AS deptId,
  4072. mr.beh_dept_name AS deptName,
  4073. IFNULL( mr.mrNum, 0 ) AS mrNum,
  4074. ck.checkedNum AS checkedNum,
  4075. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  4076. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  4077. hmmr_t.homePageMRNum,
  4078. improve_t.improveNum,
  4079. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  4080. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  4081. improve_t.improveToPassNum,
  4082. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  4083. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  4084. improve_t.improveToFullNum,
  4085. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  4086. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  4087. FROM
  4088. (
  4089. SELECT
  4090. a.beh_dept_id,
  4091. a.beh_dept_name,
  4092. count(*) AS mrNum
  4093. FROM
  4094. med_behospital_info a,
  4095. med_qcresult_info b
  4096. WHERE
  4097. a.is_deleted = 'N'
  4098. AND b.is_deleted = 'N'
  4099. AND a.hospital_id = b.hospital_id
  4100. AND a.behospital_code = b.behospital_code
  4101. AND a.qc_type_id != 0
  4102. AND a.is_placefile = '1'
  4103. <if test="hospitalId != null and hospitalId != ''">
  4104. AND a.hospital_id = #{hospitalId}
  4105. </if>
  4106. <if test="startDate != null">
  4107. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4108. </if>
  4109. <if test="endDate != null">
  4110. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4111. </if>
  4112. <if test="deptName != null and deptName != ''">
  4113. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4114. </if>
  4115. GROUP BY
  4116. a.beh_dept_id,
  4117. a.beh_dept_name
  4118. ) mr
  4119. LEFT JOIN (
  4120. SELECT
  4121. a.beh_dept_id,
  4122. a.beh_dept_name,
  4123. count(*) AS checkedNum
  4124. FROM
  4125. med_behospital_info a,
  4126. med_qcresult_info b,
  4127. med_check_info c
  4128. WHERE
  4129. a.is_deleted = 'N'
  4130. AND b.is_deleted = 'N'
  4131. AND c.is_deleted = 'N'
  4132. AND a.hospital_id = b.hospital_id
  4133. AND a.hospital_id = c.hospital_id
  4134. AND a.behospital_code = b.behospital_code
  4135. AND a.behospital_code = c.behospital_code
  4136. AND a.qc_type_id != 0
  4137. AND a.is_placefile = '1'
  4138. AND c.`status` = 1
  4139. <if test="hospitalId != null and hospitalId != ''">
  4140. AND a.hospital_id = #{hospitalId}
  4141. </if>
  4142. <if test="startDate != null">
  4143. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4144. </if>
  4145. <if test="endDate != null">
  4146. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4147. </if>
  4148. <if test="deptName != null and deptName != ''">
  4149. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4150. </if>
  4151. GROUP BY
  4152. a.beh_dept_id,
  4153. a.beh_dept_name
  4154. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  4155. AND mr.beh_dept_name = ck.beh_dept_name
  4156. LEFT JOIN (
  4157. SELECT
  4158. a.beh_dept_id,
  4159. a.beh_dept_name,
  4160. count( DISTINCT a.behospital_code ) AS homePageMRNum
  4161. FROM
  4162. med_behospital_info a,
  4163. med_home_page b,
  4164. med_qcresult_info c
  4165. WHERE
  4166. a.is_deleted = 'N'
  4167. AND b.is_deleted = 'N'
  4168. AND a.hospital_id = b.hospital_id
  4169. AND a.hospital_id = c.hospital_id
  4170. AND a.behospital_code = b.behospital_code
  4171. AND a.behospital_code = c.behospital_code
  4172. AND a.qc_type_id != 0
  4173. AND a.is_placefile = '1'
  4174. AND c.have_home_page = '1'
  4175. <if test="hospitalId != null and hospitalId != ''">
  4176. AND a.hospital_id = #{hospitalId}
  4177. </if>
  4178. <if test="startDate != null">
  4179. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4180. </if>
  4181. <if test="endDate != null">
  4182. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4183. </if>
  4184. <if test="deptName != null and deptName != ''">
  4185. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4186. </if>
  4187. GROUP BY
  4188. a.beh_dept_id,
  4189. a.beh_dept_name
  4190. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  4191. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  4192. LEFT JOIN (
  4193. SELECT
  4194. a.beh_dept_id,
  4195. a.beh_dept_name,
  4196. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  4197. sum( d.score_res = 20 ) AS improveToFullNum,
  4198. count(*) AS improveNum
  4199. FROM
  4200. med_behospital_info a,
  4201. med_home_page b,
  4202. med_qcresult_info c,
  4203. med_qcresult_cases d,
  4204. (
  4205. SELECT
  4206. m4.*
  4207. FROM
  4208. med_behospital_info m1,
  4209. med_home_page m2,
  4210. med_qcresult_info m3,
  4211. med_qcresult_cases m4
  4212. WHERE
  4213. m1.is_deleted = 'N'
  4214. AND m2.is_deleted = 'N'
  4215. AND m3.is_deleted = 'Y'
  4216. AND m4.is_deleted = 'Y'
  4217. AND m1.hospital_id = m2.hospital_id
  4218. AND m1.hospital_id = m3.hospital_id
  4219. AND m1.hospital_id = m4.hospital_id
  4220. AND m1.behospital_code = m2.behospital_code
  4221. AND m1.behospital_code = m3.behospital_code
  4222. AND m1.behospital_code = m4.behospital_code
  4223. AND m3.have_home_page = 1
  4224. AND m4.cases_id = 243
  4225. <if test="hospitalId != null and hospitalId != ''">
  4226. AND m1.hospital_id = #{hospitalId}
  4227. </if>
  4228. <if test="startDate != null">
  4229. <![CDATA[ AND m1.leave_hospital_date >= DATE(#{startDate})]]>
  4230. </if>
  4231. <if test="endDate != null">
  4232. <![CDATA[AND m1.leave_hospital_date < DATE(#{endDate})]]>
  4233. </if>
  4234. <if test="deptName != null and deptName != ''">
  4235. AND m1.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4236. </if>
  4237. GROUP BY
  4238. m1.behospital_code
  4239. ORDER BY
  4240. m1.behospital_code,
  4241. m4.gmt_create
  4242. ) e
  4243. WHERE
  4244. a.is_deleted = 'N'
  4245. AND b.is_deleted = 'N'
  4246. AND c.is_deleted = 'N'
  4247. AND d.is_deleted = 'N'
  4248. AND a.hospital_id = b.hospital_id
  4249. AND a.hospital_id = c.hospital_id
  4250. AND a.hospital_id = d.hospital_id
  4251. AND a.hospital_id = e.hospital_id
  4252. AND a.behospital_code = b.behospital_code
  4253. AND a.behospital_code = c.behospital_code
  4254. AND a.behospital_code = d.behospital_code
  4255. AND a.behospital_code = e.behospital_code
  4256. AND d.cases_id = 243
  4257. AND d.score_res > e.score_res
  4258. <if test="hospitalId != null and hospitalId != ''">
  4259. AND a.hospital_id = #{hospitalId}
  4260. </if>
  4261. <if test="startDate != null">
  4262. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4263. </if>
  4264. <if test="endDate != null">
  4265. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4266. </if>
  4267. <if test="deptName != null and deptName != ''">
  4268. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4269. </if>
  4270. GROUP BY
  4271. a.beh_dept_id,
  4272. a.beh_dept_name
  4273. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  4274. AND mr.beh_dept_name = improve_t.beh_dept_name
  4275. </select>
  4276. </mapper>