BehospitalInfoMapper.xml 187 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708
  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 DISTINCT
  2690. t1.hospital_id AS hospitalId,
  2691. t1.behospital_code AS behospitalCode,
  2692. t1.bed_code AS bedCode,
  2693. t1.LEVEL AS LEVEL,
  2694. t1.grade_type AS gradeType,
  2695. t1.score_res AS scoreRes,
  2696. t1.NAME AS NAME,
  2697. t1.sex AS sex,
  2698. t1.beh_dept_id AS behDeptId,
  2699. t1.beh_dept_name AS behDeptName,
  2700. t1.doctor_id AS doctorId,
  2701. t1.doctor_name AS doctorName,
  2702. t1.beh_doctor_id AS behDoctorId,
  2703. t1.beh_doctor_name AS behDoctorName,
  2704. t1.director_doctor_id AS directorDoctorId,
  2705. t1.director_doctor_name AS directorDoctorName,
  2706. t1.birthday AS birthday,
  2707. t1.behospital_date AS behospitalDate,
  2708. t1.leave_hospital_date AS leaveHospitalDate,
  2709. t1.placefile_date AS placefileDate,
  2710. t1.gmt_create AS gradeTime,
  2711. t1.diagnose,
  2712. t1.ward_name AS wardName,
  2713. t2.age,
  2714. t1.file_code AS fileCode
  2715. FROM
  2716. (
  2717. SELECT DISTINCT
  2718. tt1.*
  2719. FROM
  2720. (
  2721. SELECT DISTINCT
  2722. a.hospital_id,
  2723. a.behospital_code,
  2724. a.bed_code,
  2725. a.file_code,
  2726. b.LEVEL,
  2727. b.grade_type,
  2728. b.score_res,
  2729. a.NAME,
  2730. a.sex,
  2731. a.beh_dept_id,
  2732. a.beh_dept_name,
  2733. a.birthday,
  2734. a.behospital_date,
  2735. a.leave_hospital_date,
  2736. a.doctor_id,
  2737. a.doctor_name,
  2738. a.beh_doctor_id,
  2739. a.beh_doctor_name,
  2740. a.director_doctor_id,
  2741. a.director_doctor_name,
  2742. a.diagnose,
  2743. a.placefile_date,
  2744. a.ward_name,
  2745. b.gmt_create
  2746. FROM
  2747. med_behospital_info a,
  2748. med_qcresult_info b,
  2749. med_qcresult_detail c,
  2750. qc_cases_entry d
  2751. WHERE
  2752. a.is_deleted = 'N'
  2753. AND b.is_deleted = 'N'
  2754. AND c.is_deleted = 'N'
  2755. AND d.is_deleted = 'N'
  2756. AND a.hospital_id = b.hospital_id
  2757. AND a.hospital_id = c.hospital_id
  2758. AND a.behospital_code = b.behospital_code
  2759. AND a.behospital_code = c.behospital_code
  2760. AND c.cases_id = d.cases_id
  2761. AND c.cases_entry_id = d.id
  2762. AND a.qc_type_id != 0
  2763. AND a.is_placefile = 1
  2764. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  2765. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  2766. </if>
  2767. <if test="qcResultShortPageVO.startDate != null">
  2768. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  2769. </if>
  2770. <if test="qcResultShortPageVO.endDate != null ">
  2771. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  2772. </if>
  2773. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  2774. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  2775. </if>
  2776. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  2777. AND b.`level` = #{qcResultShortPageVO.level}
  2778. </if>
  2779. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  2780. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  2781. </if>
  2782. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  2783. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  2784. </if>
  2785. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  2786. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  2787. </if>
  2788. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  2789. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2790. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2791. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  2792. </if>
  2793. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  2794. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2795. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2796. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  2797. </if>
  2798. <if test="qcResultShortPageVO.casesEntryId != null ">
  2799. AND d.id = #{qcResultShortPageVO.casesEntryId}
  2800. </if>
  2801. <if test="qcResultShortPageVO.isReject != null">
  2802. AND c.is_reject = #{qcResultShortPageVO.isReject}
  2803. </if>
  2804. <if test="qcResultShortPageVO.ruleType != null">
  2805. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  2806. </if>
  2807. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  2808. AND TIMESTAMPDIFF(
  2809. DAY,
  2810. DATE( a.behospital_date ),
  2811. DATE( a.leave_hospital_date ))> 30
  2812. </if>
  2813. ) tt1
  2814. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  2815. ,med_medical_record tt2
  2816. WHERE
  2817. tt2.is_deleted = 'N'
  2818. AND tt1.hospital_id = tt2.hospital_id
  2819. AND tt1.behospital_code = tt2.behospital_code
  2820. AND tt2.mode_id = 30
  2821. </if>
  2822. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  2823. ,med_crisis_info tt2
  2824. WHERE
  2825. tt2.is_deleted = 'N'
  2826. AND tt1.hospital_id = tt2.hospital_id
  2827. AND tt1.behospital_code = tt2.behospital_code
  2828. </if>
  2829. ) t1
  2830. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  2831. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  2832. AND t1.behospital_code = t2.behospital_code
  2833. AND t2.is_deleted = 'N'
  2834. </if>
  2835. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  2836. , med_home_page t2
  2837. , med_home_operation_info t3
  2838. WHERE t1.hospital_id = t2.hospital_id
  2839. AND t1.behospital_code = t2.behospital_code
  2840. AND t2.home_page_id = t3.home_page_id
  2841. AND t2.is_deleted = 'N'
  2842. AND t3.is_deleted = 'N'
  2843. </if>
  2844. </select>
  2845. <!-- 条目缺陷质控评分页-科室(内页)-->
  2846. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  2847. SELECT DISTINCT
  2848. t1.hospital_id AS hospitalId,
  2849. t1.behospital_code AS behospitalCode,
  2850. t1.bed_code AS bedCode,
  2851. t1.LEVEL AS LEVEL,
  2852. t1.grade_type AS gradeType,
  2853. t1.score_res AS scoreRes,
  2854. t1.NAME AS NAME,
  2855. t1.sex AS sex,
  2856. t1.beh_dept_id AS behDeptId,
  2857. t1.beh_dept_name AS behDeptName,
  2858. t1.doctor_id AS doctorId,
  2859. t1.doctor_name AS doctorName,
  2860. t1.beh_doctor_id AS behDoctorId,
  2861. t1.beh_doctor_name AS behDoctorName,
  2862. t1.director_doctor_id AS directorDoctorId,
  2863. t1.director_doctor_name AS directorDoctorName,
  2864. t1.birthday AS birthday,
  2865. t1.behospital_date AS behospitalDate,
  2866. t1.leave_hospital_date AS leaveHospitalDate,
  2867. t1.placefile_date AS placefileDate,
  2868. t1.gmt_create AS gradeTime,
  2869. t1.diagnose,
  2870. t1.ward_name AS wardName,
  2871. t2.age,
  2872. t1.file_code AS fileCode
  2873. FROM
  2874. (
  2875. SELECT DISTINCT
  2876. a.hospital_id,
  2877. a.behospital_code,
  2878. a.bed_code,
  2879. a.file_code,
  2880. b.LEVEL,
  2881. b.grade_type,
  2882. b.score_res,
  2883. a.NAME,
  2884. a.sex,
  2885. a.beh_dept_id,
  2886. a.beh_dept_name,
  2887. a.birthday,
  2888. a.behospital_date,
  2889. a.leave_hospital_date,
  2890. a.doctor_id,
  2891. a.doctor_name,
  2892. a.beh_doctor_id,
  2893. a.beh_doctor_name,
  2894. a.director_doctor_id,
  2895. a.director_doctor_name,
  2896. a.diagnose,
  2897. a.placefile_date,
  2898. a.ward_name,
  2899. b.gmt_create
  2900. FROM
  2901. med_behospital_info a,
  2902. med_qcresult_info b,
  2903. med_qcresult_detail c,
  2904. qc_cases_entry d,
  2905. sys_user_dept e
  2906. WHERE
  2907. a.is_deleted = 'N'
  2908. AND b.is_deleted = 'N'
  2909. AND c.is_deleted = 'N'
  2910. AND d.is_deleted = 'N'
  2911. AND e.is_deleted = 'N'
  2912. AND a.hospital_id = b.hospital_id
  2913. AND a.hospital_id = c.hospital_id
  2914. AND a.hospital_id = e.hospital_id
  2915. AND a.behospital_code = b.behospital_code
  2916. AND a.behospital_code = c.behospital_code
  2917. AND a.beh_dept_id = e.dept_id
  2918. AND c.cases_id = d.cases_id
  2919. AND c.cases_entry_id = d.id
  2920. AND a.qc_type_id != 0
  2921. AND a.is_placefile = 1
  2922. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  2923. AND e.user_id = #{qcResultShortPageVO.userId}
  2924. </if>
  2925. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  2926. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  2927. </if>
  2928. <if test="qcResultShortPageVO.startDate != null">
  2929. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  2930. </if>
  2931. <if test="qcResultShortPageVO.endDate != null ">
  2932. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  2933. </if>
  2934. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  2935. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  2936. </if>
  2937. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  2938. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  2939. </if>
  2940. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  2941. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2942. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  2943. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  2944. </if>
  2945. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  2946. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2947. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  2948. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  2949. </if>
  2950. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  2951. AND b.`level` = #{qcResultShortPageVO.level}
  2952. </if>
  2953. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  2954. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  2955. </if>
  2956. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  2957. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  2958. </if>
  2959. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  2960. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  2961. </if>
  2962. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  2963. AND d.id = #{qcResultShortPageVO.casesEntryId}
  2964. </if>
  2965. <if test="qcResultShortPageVO.isReject != null">
  2966. AND c.is_reject = #{qcResultShortPageVO.isReject}
  2967. </if>
  2968. <if test="qcResultShortPageVO.ruleType != null">
  2969. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  2970. </if>
  2971. ) t1
  2972. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  2973. AND t1.behospital_code = t2.behospital_code
  2974. AND t2.is_deleted = 'N'
  2975. </select>
  2976. <update id="updateBatchByKey">
  2977. <foreach collection="list" item="item" separator=";">
  2978. update med_behospital_info
  2979. <set>
  2980. <if test="item.name != null">
  2981. name = #{item.name},
  2982. </if>
  2983. <if test="item.sex != null">
  2984. sex = #{item.sex},
  2985. </if>
  2986. <if test="item.birthday != null">
  2987. birthday = #{item.birthday},
  2988. </if>
  2989. <if test="item.fileCode != null">
  2990. file_code = #{item.fileCode},
  2991. </if>
  2992. <if test="item.qcTypeId != null">
  2993. qc_type_id = #{item.qcTypeId},
  2994. </if>
  2995. <if test="item.wardCode != null">
  2996. ward_code = #{item.wardCode},
  2997. </if>
  2998. <if test="item.wardName != null">
  2999. ward_name = #{item.wardName},
  3000. </if>
  3001. <if test="item.behDeptId != null">
  3002. beh_dept_id = #{item.behDeptId},
  3003. </if>
  3004. <if test="item.behDeptName != null">
  3005. beh_dept_name = #{item.behDeptName},
  3006. </if>
  3007. <if test="item.bedCode != null">
  3008. bed_code = #{item.bedCode},
  3009. </if>
  3010. <if test="item.bedName != null">
  3011. bed_name = #{item.bedName},
  3012. </if>
  3013. <if test="item.insuranceName != null">
  3014. insurance_name = #{item.insuranceName},
  3015. </if>
  3016. <if test="item.jobType != null">
  3017. job_type = #{item.jobType},
  3018. </if>
  3019. <if test="item.behospitalDate != null">
  3020. behospital_date = #{item.behospitalDate},
  3021. </if>
  3022. <if test="item.leaveHospitalDate != null">
  3023. leave_hospital_date = #{item.leaveHospitalDate},
  3024. </if>
  3025. <if test="item.diagnoseIcd != null">
  3026. diagnose_icd = #{item.diagnoseIcd},
  3027. </if>
  3028. <if test="item.diagnose != null">
  3029. diagnose = #{item.diagnose},
  3030. </if>
  3031. <if test="item.behDoctorId != null">
  3032. beh_doctor_id = #{item.behDoctorId},
  3033. </if>
  3034. <if test="item.behDoctorName != null">
  3035. beh_doctor_name = #{item.behDoctorName},
  3036. </if>
  3037. <if test="item.doctorId != null">
  3038. doctor_id = #{item.doctorId},
  3039. </if>
  3040. <if test="item.doctorName != null">
  3041. doctor_name = #{item.doctorName},
  3042. </if>
  3043. <if test="item.directorDoctorId != null">
  3044. director_doctor_id = #{item.directorDoctorId},
  3045. </if>
  3046. <if test="item.directorDoctorName != null">
  3047. director_doctor_name = #{item.directorDoctorName},
  3048. </if>
  3049. <if test="item.placefileDate != null">
  3050. placefile_date = #{item.placefileDate},
  3051. </if>
  3052. <if test="item.isPlacefile != null">
  3053. is_placefile = #{item.isPlacefile},
  3054. </if>
  3055. <if test="item.gmtModified != null">
  3056. gmt_modified = #{item.gmtModified},
  3057. </if>
  3058. <if test="item.modifier != null">
  3059. modifier = #{item.modifier},
  3060. </if>
  3061. </set>
  3062. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  3063. </foreach>
  3064. </update>
  3065. <!-- 关键条目缺陷统计报表-->
  3066. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  3067. SELECT
  3068. deptId,
  3069. deptName,
  3070. consultationMRNum,
  3071. consultationNum,
  3072. 2511 AS consultationEntryId,
  3073. '普通会诊未在24小时内完成' AS consultationEntryName,
  3074. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  3075. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  3076. operationMRNum,
  3077. 2594 AS operationNameEntryId,
  3078. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  3079. operationNameNum,
  3080. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  3081. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  3082. 2973 AS operationTimeEntryId,
  3083. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  3084. operationTimeNum,
  3085. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  3086. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  3087. 2930 AS operation15MinuteEntryId,
  3088. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  3089. operation15MinuteNum,
  3090. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  3091. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  3092. 2419 AS crisisEntryId,
  3093. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  3094. crisisMRNum,
  3095. crisisNum,
  3096. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  3097. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  3098. 2495 AS stageSummaryEntryId,
  3099. '无阶段小结' AS stageSummaryEntryName,
  3100. stageSummaryMRNum,
  3101. stageSummaryNum,
  3102. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  3103. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr
  3104. FROM
  3105. (
  3106. SELECT
  3107. tt.deptId,
  3108. tt.deptName,
  3109. sum( tt.consultationNum ) AS consultationNum,
  3110. sum( tt.consultationMRNum ) AS consultationMRNum,
  3111. sum( tt.operationNameNum ) AS operationNameNum,
  3112. sum( tt.operationTimeNum ) AS operationTimeNum,
  3113. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  3114. sum( tt.operationMRNum ) AS operationMRNum,
  3115. sum( tt.crisisNum ) AS crisisNum,
  3116. sum( tt.crisisMRNum ) AS crisisMRNum,
  3117. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  3118. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum
  3119. FROM
  3120. (
  3121. (
  3122. SELECT
  3123. c.beh_dept_id AS deptId,
  3124. c.beh_dept_name AS deptName,
  3125. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  3126. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  3127. 0 AS operationNameNum,
  3128. 0 AS operationTimeNum,
  3129. 0 AS operation15MinuteNum,
  3130. 0 AS operationMRNum,
  3131. 0 AS crisisNum,
  3132. 0 AS crisisMRNum,
  3133. 0 AS stageSummaryNum,
  3134. 0 AS stageSummaryMRNum
  3135. FROM
  3136. (
  3137. SELECT DISTINCT
  3138. a.hospital_id,
  3139. a.behospital_code,
  3140. a.beh_dept_name,
  3141. a.beh_dept_id
  3142. FROM
  3143. med_behospital_info a,
  3144. med_medical_record b
  3145. WHERE
  3146. a.is_deleted = 'N'
  3147. AND b.is_deleted = 'N'
  3148. AND a.hospital_id = b.hospital_id
  3149. AND a.behospital_code = b.behospital_code
  3150. AND b.mode_id = 30
  3151. AND a.is_placefile = '1'
  3152. AND a.qc_type_id != 0
  3153. <if test="hospitalId != null and hospitalId != ''">
  3154. AND a.hospital_id = #{hospitalId}
  3155. </if>
  3156. <if test="startDate != null">
  3157. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3158. </if>
  3159. <if test="endDate != null">
  3160. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3161. </if>
  3162. <if test="deptName != null and deptName != ''">
  3163. AND a.beh_dept_name = #{deptName}
  3164. </if>
  3165. ) c
  3166. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  3167. AND c.hospital_id = d.hospital_id
  3168. AND c.behospital_code = d.behospital_code
  3169. GROUP BY
  3170. c.beh_dept_id,
  3171. c.beh_dept_name
  3172. ) UNION
  3173. (
  3174. SELECT
  3175. d.beh_dept_id AS deptId,
  3176. d.beh_dept_name AS deptName,
  3177. 0 AS consultationNum,
  3178. 0 AS consultationMRNum,
  3179. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  3180. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  3181. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  3182. count( DISTINCT d.behospital_code ) AS operationMRNum,
  3183. 0 AS crisisNum,
  3184. 0 AS crisisMRNum,
  3185. 0 AS stageSummaryNum,
  3186. 0 AS stageSummaryMRNum
  3187. FROM
  3188. (
  3189. SELECT DISTINCT
  3190. a.hospital_id,
  3191. a.behospital_code,
  3192. a.beh_dept_name,
  3193. a.beh_dept_id
  3194. FROM
  3195. med_behospital_info a,
  3196. med_home_page b,
  3197. med_home_operation_info c
  3198. WHERE
  3199. a.is_deleted = 'N'
  3200. AND b.is_deleted = 'N'
  3201. AND c.is_deleted = 'N'
  3202. AND a.hospital_id = b.hospital_id
  3203. AND a.hospital_id = c.hospital_id
  3204. AND a.behospital_code = b.behospital_code
  3205. AND b.home_page_id = c.home_page_id
  3206. AND a.is_placefile = '1'
  3207. AND a.qc_type_id != 0
  3208. <if test="hospitalId != null and hospitalId != ''">
  3209. AND a.hospital_id = #{hospitalId}
  3210. </if>
  3211. <if test="startDate != null">
  3212. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3213. </if>
  3214. <if test="endDate != null">
  3215. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3216. </if>
  3217. <if test="deptName != null and deptName != ''">
  3218. AND a.beh_dept_name = #{deptName}
  3219. </if>
  3220. ) d
  3221. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  3222. AND d.hospital_id = e.hospital_id
  3223. AND d.behospital_code = e.behospital_code
  3224. GROUP BY
  3225. d.beh_dept_id,
  3226. d.beh_dept_name
  3227. ) UNION
  3228. (
  3229. SELECT
  3230. c.beh_dept_id AS deptId,
  3231. c.beh_dept_name AS deptName,
  3232. 0 AS consultationNum,
  3233. 0 AS consultationMRNum,
  3234. 0 AS operationNameNum,
  3235. 0 AS operationTimeNum,
  3236. 0 AS operation15MinuteNum,
  3237. 0 AS operationMRNum,
  3238. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  3239. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  3240. 0 AS stageSummaryNum,
  3241. 0 AS stageSummaryMRNum
  3242. FROM
  3243. (
  3244. SELECT DISTINCT
  3245. a.hospital_id,
  3246. a.behospital_code,
  3247. a.beh_dept_name,
  3248. a.beh_dept_id
  3249. FROM
  3250. med_behospital_info a,
  3251. med_crisis_info b
  3252. WHERE
  3253. a.is_deleted = 'N'
  3254. AND b.is_deleted = 'N'
  3255. AND a.hospital_id = b.hospital_id
  3256. AND a.behospital_code = b.behospital_code
  3257. AND a.is_placefile = '1'
  3258. AND a.qc_type_id != 0
  3259. <if test="hospitalId != null and hospitalId != ''">
  3260. AND a.hospital_id = #{hospitalId}
  3261. </if>
  3262. <if test="startDate != null">
  3263. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3264. </if>
  3265. <if test="endDate != null">
  3266. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3267. </if>
  3268. <if test="deptName != null and deptName != ''">
  3269. AND a.beh_dept_name = #{deptName}
  3270. </if>
  3271. ) c
  3272. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  3273. AND c.hospital_id = d.hospital_id
  3274. AND c.behospital_code = d.behospital_code
  3275. GROUP BY
  3276. c.beh_dept_id,
  3277. c.beh_dept_name
  3278. ) UNION
  3279. (
  3280. SELECT
  3281. b.beh_dept_id AS deptId,
  3282. b.beh_dept_name AS deptName,
  3283. 0 AS consultationNum,
  3284. 0 AS consultationMRNum,
  3285. 0 AS operationNameNum,
  3286. 0 AS operationTimeNum,
  3287. 0 AS operation15MinuteNum,
  3288. 0 AS operationMRNum,
  3289. 0 AS crisisNum,
  3290. 0 AS crisisMRNum,
  3291. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  3292. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum
  3293. FROM
  3294. (
  3295. SELECT DISTINCT
  3296. a.hospital_id,
  3297. a.behospital_code,
  3298. a.beh_dept_name,
  3299. a.beh_dept_id
  3300. FROM
  3301. med_behospital_info a
  3302. WHERE
  3303. a.is_deleted = 'N'
  3304. AND TIMESTAMPDIFF(
  3305. DAY,
  3306. DATE( behospital_date ),
  3307. DATE( leave_hospital_date ))> 30
  3308. AND a.is_placefile = '1'
  3309. AND a.qc_type_id != 0
  3310. <if test="hospitalId != null and hospitalId != ''">
  3311. AND a.hospital_id = #{hospitalId}
  3312. </if>
  3313. <if test="startDate != null">
  3314. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3315. </if>
  3316. <if test="endDate != null">
  3317. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3318. </if>
  3319. <if test="deptName != null and deptName != ''">
  3320. AND a.beh_dept_name = #{deptName}
  3321. </if>
  3322. ) b
  3323. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  3324. AND b.hospital_id = c.hospital_id
  3325. AND b.behospital_code = c.behospital_code
  3326. GROUP BY
  3327. b.beh_dept_id,
  3328. b.beh_dept_name
  3329. )
  3330. ) tt
  3331. GROUP BY
  3332. tt.deptId,
  3333. tt.deptName
  3334. ) t
  3335. <if test="asc != null and asc !=''">
  3336. order by
  3337. <choose>
  3338. <when test='asc=="deptId"'>deptId asc</when>
  3339. <when test='asc=="deptName"'>deptName asc</when>
  3340. <when test='asc=="consultationNum"'>consultationNum asc</when>
  3341. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  3342. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  3343. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  3344. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  3345. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  3346. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  3347. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  3348. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  3349. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  3350. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  3351. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  3352. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  3353. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  3354. <when test='asc=="crisisNum"'>crisisNum asc</when>
  3355. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  3356. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  3357. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  3358. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  3359. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  3360. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  3361. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  3362. <otherwise>deptName asc</otherwise>
  3363. </choose>
  3364. </if>
  3365. <if test="desc != null and desc!=''">
  3366. order by
  3367. <choose>
  3368. <when test='desc=="deptId"'>deptId desc</when>
  3369. <when test='desc=="deptName"'>deptName desc</when>
  3370. <when test='desc=="consultationNum"'>consultationNum desc</when>
  3371. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  3372. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  3373. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  3374. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  3375. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  3376. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  3377. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  3378. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  3379. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  3380. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  3381. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  3382. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  3383. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  3384. <when test='desc=="crisisNum"'>crisisNum desc</when>
  3385. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  3386. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  3387. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  3388. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  3389. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  3390. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  3391. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  3392. <otherwise>deptName desc</otherwise>
  3393. </choose>
  3394. </if>
  3395. </select>
  3396. <!-- 非医嘱离院病人记录-->
  3397. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  3398. SELECT
  3399. count(*)
  3400. FROM
  3401. med_behospital_info a,
  3402. med_home_page b
  3403. WHERE
  3404. a.is_deleted = 'N'
  3405. AND b.is_deleted = 'N'
  3406. AND a.hospital_id = b.hospital_id
  3407. AND a.behospital_code = b.behospital_code
  3408. AND b.leave_hospital_type = '非医嘱离院'
  3409. AND a.is_placefile = '1'
  3410. AND a.qc_type_id != 0
  3411. <if test="hospitalId != null and hospitalId != ''">
  3412. AND a.hospital_id = #{hospitalId}
  3413. </if>
  3414. <if test="startDate != null">
  3415. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3416. </if>
  3417. <if test="endDate != null">
  3418. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3419. </if>
  3420. </select>
  3421. <!-- 31天内再入院记录-->
  3422. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  3423. SELECT
  3424. count(*)
  3425. FROM
  3426. (
  3427. SELECT
  3428. bc1.file_code,
  3429. bc1.diagnose,
  3430. bc1.behospitalCode,
  3431. bc1.behospitalDate,
  3432. bc1.leaveHospitalDate
  3433. FROM
  3434. (
  3435. SELECT
  3436. t1.file_code,
  3437. t1.diagnose,
  3438. t1.behospital_code AS behospitalCode,
  3439. t1.leave_hospital_date AS leaveHospitalDate,
  3440. t2.behospital_code AS lastBehospitalCode,
  3441. t2.behospital_date AS lastBehospitalDate,
  3442. t1.behospital_date AS behospitalDate,
  3443. t2.leave_hospital_date AS lastLeaveHospitalDate
  3444. FROM
  3445. (
  3446. SELECT
  3447. tt1.file_code,
  3448. tt1.diagnose,
  3449. tt2.behospital_code,
  3450. tt2.behospital_date,
  3451. tt2.leave_hospital_date
  3452. FROM
  3453. (
  3454. SELECT
  3455. a.file_code,
  3456. a.diagnose
  3457. FROM
  3458. med_behospital_info a
  3459. WHERE
  3460. a.is_deleted = 'N'
  3461. AND a.is_placefile = '1'
  3462. AND a.qc_type_id != 0
  3463. <if test="hospitalId != null and hospitalId != ''">
  3464. AND a.hospital_id = #{hospitalId}
  3465. </if>
  3466. <if test="startDate != null">
  3467. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3468. </if>
  3469. <if test="endDate != null">
  3470. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3471. </if>
  3472. AND IFNULL( a.diagnose, '' )!= ''
  3473. GROUP BY
  3474. a.file_code,
  3475. a.diagnose
  3476. HAVING
  3477. count(*)> 1
  3478. ) tt1,
  3479. med_behospital_info tt2
  3480. WHERE
  3481. tt2.is_deleted = 'N'
  3482. AND tt2.is_placefile = 1
  3483. AND tt2.qc_type_id != 0
  3484. AND tt1.file_code = tt2.file_code
  3485. AND tt1.diagnose = tt2.diagnose
  3486. <if test="hospitalId != null and hospitalId != ''">
  3487. AND tt2.hospital_id = #{hospitalId}
  3488. </if>
  3489. <if test="startDate != null">
  3490. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3491. </if>
  3492. <if test="endDate != null">
  3493. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3494. </if>
  3495. ORDER BY
  3496. tt1.file_code,
  3497. tt1.diagnose,
  3498. tt2.behospital_date DESC
  3499. ) t1,
  3500. (
  3501. SELECT
  3502. tt1.file_code,
  3503. tt1.diagnose,
  3504. tt2.behospital_code,
  3505. tt2.behospital_date,
  3506. tt2.leave_hospital_date
  3507. FROM
  3508. (
  3509. SELECT
  3510. a.file_code,
  3511. a.diagnose
  3512. FROM
  3513. med_behospital_info a
  3514. WHERE
  3515. a.is_deleted = 'N'
  3516. AND a.is_placefile = 1
  3517. AND a.qc_type_id != 0
  3518. AND a.hospital_id = 1
  3519. AND IFNULL( a.diagnose, '' )!= ''
  3520. GROUP BY
  3521. a.file_code,
  3522. a.diagnose
  3523. HAVING
  3524. count(*)> 1
  3525. ) tt1,
  3526. med_behospital_info tt2
  3527. WHERE
  3528. tt2.is_deleted = 'N'
  3529. AND tt2.is_placefile = 1
  3530. AND tt2.qc_type_id != 0
  3531. AND tt1.file_code = tt2.file_code
  3532. AND tt1.diagnose = tt2.diagnose
  3533. <if test="hospitalId != null and hospitalId != ''">
  3534. AND tt2.hospital_id = #{hospitalId}
  3535. </if>
  3536. <if test="startDate != null">
  3537. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3538. </if>
  3539. <if test="endDate != null">
  3540. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3541. </if>
  3542. ORDER BY
  3543. tt1.file_code,
  3544. tt1.diagnose,
  3545. tt2.behospital_date DESC
  3546. ) t2
  3547. WHERE
  3548. t1.file_code = t2.file_code
  3549. AND t1.diagnose = t2.diagnose
  3550. AND t1.behospital_code != t2.behospital_code
  3551. AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
  3552. SELECT
  3553. bc2.file_code,
  3554. bc2.diagnose,
  3555. bc2.lastBehospitalCode,
  3556. bc2.lastBehospitalDate,
  3557. bc2.lastLeaveHospitalDate
  3558. FROM
  3559. (
  3560. SELECT
  3561. t1.file_code,
  3562. t1.diagnose,
  3563. t1.behospital_code AS behospitalCode,
  3564. t1.leave_hospital_date AS leaveHospitalDate,
  3565. t2.behospital_code AS lastBehospitalCode,
  3566. t2.behospital_date AS lastBehospitalDate,
  3567. t1.behospital_date AS behospitalDate,
  3568. t2.leave_hospital_date AS lastLeaveHospitalDate
  3569. FROM
  3570. (
  3571. SELECT
  3572. tt1.file_code,
  3573. tt1.diagnose,
  3574. tt2.behospital_code,
  3575. tt2.behospital_date,
  3576. tt2.leave_hospital_date
  3577. FROM
  3578. (
  3579. SELECT
  3580. a.file_code,
  3581. a.diagnose
  3582. FROM
  3583. med_behospital_info a
  3584. WHERE
  3585. a.is_deleted = 'N'
  3586. AND a.is_placefile = '1'
  3587. AND a.qc_type_id != 0
  3588. <if test="hospitalId != null and hospitalId != ''">
  3589. AND a.hospital_id = #{hospitalId}
  3590. </if>
  3591. <if test="startDate != null">
  3592. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3593. </if>
  3594. <if test="endDate != null">
  3595. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3596. </if>
  3597. AND IFNULL( a.diagnose, '' )!= ''
  3598. GROUP BY
  3599. a.file_code,
  3600. a.diagnose
  3601. HAVING
  3602. count(*)> 1
  3603. ) tt1,
  3604. med_behospital_info tt2
  3605. WHERE
  3606. tt2.is_deleted = 'N'
  3607. AND tt2.is_placefile = 1
  3608. AND tt2.qc_type_id != 0
  3609. AND tt1.file_code = tt2.file_code
  3610. AND tt1.diagnose = tt2.diagnose
  3611. <if test="hospitalId != null and hospitalId != ''">
  3612. AND tt2.hospital_id = #{hospitalId}
  3613. </if>
  3614. <if test="startDate != null">
  3615. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3616. </if>
  3617. <if test="endDate != null">
  3618. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3619. </if>
  3620. ORDER BY
  3621. tt1.file_code,
  3622. tt1.diagnose,
  3623. tt2.behospital_date DESC
  3624. ) t1,
  3625. (
  3626. SELECT
  3627. tt1.file_code,
  3628. tt1.diagnose,
  3629. tt2.behospital_code,
  3630. tt2.behospital_date,
  3631. tt2.leave_hospital_date
  3632. FROM
  3633. (
  3634. SELECT
  3635. a.file_code,
  3636. a.diagnose
  3637. FROM
  3638. med_behospital_info a
  3639. WHERE
  3640. a.is_deleted = 'N'
  3641. AND a.is_placefile = 1
  3642. AND a.qc_type_id != 0
  3643. AND a.hospital_id = 1
  3644. AND IFNULL( a.diagnose, '' )!= ''
  3645. GROUP BY
  3646. a.file_code,
  3647. a.diagnose
  3648. HAVING
  3649. count(*)> 1
  3650. ) tt1,
  3651. med_behospital_info tt2
  3652. WHERE
  3653. tt2.is_deleted = 'N'
  3654. AND tt2.is_placefile = 1
  3655. AND tt2.qc_type_id != 0
  3656. AND tt1.file_code = tt2.file_code
  3657. AND tt1.diagnose = tt2.diagnose
  3658. <if test="hospitalId != null and hospitalId != ''">
  3659. AND tt2.hospital_id = #{hospitalId}
  3660. </if>
  3661. <if test="startDate != null">
  3662. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
  3663. </if>
  3664. <if test="endDate != null">
  3665. <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
  3666. </if>
  3667. ORDER BY
  3668. tt1.file_code,
  3669. tt1.diagnose,
  3670. tt2.behospital_date DESC
  3671. ) t2
  3672. WHERE
  3673. t1.file_code = t2.file_code
  3674. AND t1.diagnose = t2.diagnose
  3675. AND t1.behospital_code != t2.behospital_code
  3676. AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
  3677. ) t
  3678. </select>
  3679. <!-- 病案首页质控病历数统计-全院(首页)-->
  3680. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  3681. SELECT
  3682. count( * ) AS mrNum,
  3683. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3684. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3685. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3686. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3687. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3688. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3689. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3690. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3691. FROM
  3692. med_behospital_info a,
  3693. med_qcresult_cases c
  3694. WHERE
  3695. a.is_deleted = 'N'
  3696. AND c.is_deleted = 'N'
  3697. AND a.hospital_id = c.hospital_id
  3698. AND a.behospital_code = c.behospital_code
  3699. AND c.cases_id = 243
  3700. AND a.is_placefile = '1'
  3701. AND a.qc_type_id != 0
  3702. <if test="hospitalId != null and hospitalId != ''">
  3703. AND a.hospital_id = #{hospitalId}
  3704. </if>
  3705. <if test="startDate != null">
  3706. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3707. </if>
  3708. <if test="endDate != null">
  3709. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3710. </if>
  3711. </select>
  3712. <!-- 病案首页完整率统计-全院(首页)-->
  3713. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  3714. SELECT
  3715. h1.emptyNum,
  3716. h1.mrNum,
  3717. h2.entryNum,
  3718. h1.mrNum * h2.entryNum AS entryTotleNum,
  3719. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3720. CONCAT(
  3721. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  3722. '%'
  3723. ) AS emptyPercentStr
  3724. FROM
  3725. (
  3726. SELECT
  3727. sum( d.rule_type = 1 ) AS emptyNum,
  3728. count( DISTINCT a.behospital_code ) AS mrNum
  3729. FROM
  3730. med_behospital_info a,
  3731. med_qcresult_cases b,
  3732. med_qcresult_detail c,
  3733. qc_cases_entry d
  3734. WHERE
  3735. a.is_deleted = 'N'
  3736. AND b.is_deleted = 'N'
  3737. AND c.is_deleted = 'N'
  3738. AND d.is_deleted = 'N'
  3739. AND a.hospital_id = b.hospital_id
  3740. AND a.hospital_id = c.hospital_id
  3741. AND a.behospital_code = b.behospital_code
  3742. AND a.behospital_code = c.behospital_code
  3743. AND b.cases_id = c.cases_id
  3744. AND c.cases_id = d.cases_id
  3745. AND c.cases_entry_id = d.id
  3746. AND a.is_placefile = '1'
  3747. AND d.cases_id = 243
  3748. AND a.qc_type_id != 0
  3749. <if test="hospitalId != null and hospitalId != ''">
  3750. AND a.hospital_id = #{hospitalId}
  3751. </if>
  3752. <if test="startDate != null">
  3753. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  3754. </if>
  3755. <if test="endDate != null">
  3756. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  3757. </if>
  3758. ) h1,(
  3759. SELECT
  3760. count(*) AS entryNum
  3761. FROM
  3762. qc_cases_entry
  3763. WHERE
  3764. is_deleted = 'N'
  3765. AND cases_id = 243
  3766. ) h2
  3767. </select>
  3768. <!-- 离院病人评分详情页-->
  3769. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  3770. SELECT DISTINCT
  3771. t1.hospital_id AS hospitalId,
  3772. t1.behospital_code AS behospitalCode,
  3773. t1.bed_code AS bedCode,
  3774. t1.LEVEL AS LEVEL,
  3775. t1.grade_type AS gradeType,
  3776. t1.score_res AS scoreRes,
  3777. t1.NAME AS NAME,
  3778. t1.sex AS sex,
  3779. t1.beh_dept_id AS behDeptId,
  3780. t1.beh_dept_name AS behDeptName,
  3781. t1.doctor_id AS doctorId,
  3782. t1.doctor_name AS doctorName,
  3783. t1.beh_doctor_id AS behDoctorId,
  3784. t1.beh_doctor_name AS behDoctorName,
  3785. t1.director_doctor_id AS directorDoctorId,
  3786. t1.director_doctor_name AS directorDoctorName,
  3787. t1.birthday AS birthday,
  3788. t1.behospital_date AS behospitalDate,
  3789. t1.leave_hospital_date AS leaveHospitalDate,
  3790. t1.placefile_date AS placefileDate,
  3791. t1.gmt_create AS gradeTime,
  3792. t1.diagnose,
  3793. t1.ward_name AS wardName,
  3794. t2.age,
  3795. t2.file_code AS fileCode
  3796. FROM
  3797. (
  3798. SELECT DISTINCT
  3799. tt1.*
  3800. FROM
  3801. (
  3802. SELECT
  3803. b.*,
  3804. c.LEVEL,
  3805. c.grade_type,
  3806. c.score_res,
  3807. c.gmt_create
  3808. FROM
  3809. (
  3810. SELECT DISTINCT
  3811. a.hospital_id,
  3812. a.behospital_code,
  3813. a.bed_code,
  3814. a.NAME,
  3815. a.sex,
  3816. a.beh_dept_id,
  3817. a.beh_dept_name,
  3818. a.birthday,
  3819. a.behospital_date,
  3820. a.leave_hospital_date,
  3821. a.doctor_id,
  3822. a.doctor_name,
  3823. a.beh_doctor_id,
  3824. a.beh_doctor_name,
  3825. a.director_doctor_id,
  3826. a.director_doctor_name,
  3827. a.diagnose,
  3828. a.placefile_date,
  3829. a.ward_name
  3830. FROM
  3831. med_behospital_info a
  3832. WHERE
  3833. a.is_deleted = 'N'
  3834. AND a.qc_type_id != 0
  3835. AND a.is_placefile = 1
  3836. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3837. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3838. </if>
  3839. <if test="qcResultShortPageVO.startDate != null">
  3840. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  3841. </if>
  3842. <if test="qcResultShortPageVO.endDate != null ">
  3843. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  3844. </if>
  3845. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  3846. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  3847. </if>
  3848. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3849. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3850. </if>
  3851. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3852. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3853. </if>
  3854. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3855. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3856. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3857. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3858. </if>
  3859. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3860. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3861. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3862. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3863. </if>
  3864. ) b
  3865. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  3866. AND b.hospital_id = c.hospital_id
  3867. AND b.behospital_code = c.behospital_code
  3868. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  3869. AND c.`level` = #{qcResultShortPageVO.level}
  3870. </if>
  3871. ) tt1
  3872. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  3873. ,med_medical_record tt2,
  3874. qc_mode tt3
  3875. WHERE
  3876. tt2.is_deleted = 'N'
  3877. AND tt3.is_deleted = 'N'
  3878. AND tt1.hospital_id = tt2.hospital_id
  3879. AND tt1.behospital_code = tt2.behospital_code
  3880. AND tt2.mode_id = tt3.id
  3881. AND tt3.`name` = '手术记录'
  3882. </if>
  3883. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==5">
  3884. ,(
  3885. SELECT
  3886. bc1.file_code,
  3887. bc1.diagnose,
  3888. bc1.behospitalCode,
  3889. bc1.behospitalDate,
  3890. bc1.leaveHospitalDate
  3891. FROM
  3892. (
  3893. SELECT
  3894. t1.file_code,
  3895. t1.diagnose,
  3896. t1.behospital_code AS behospitalCode,
  3897. t1.leave_hospital_date AS leaveHospitalDate,
  3898. t2.behospital_code AS lastBehospitalCode,
  3899. t2.behospital_date AS lastBehospitalDate,
  3900. t1.behospital_date AS behospitalDate,
  3901. t2.leave_hospital_date AS lastLeaveHospitalDate
  3902. FROM
  3903. (
  3904. SELECT
  3905. tt1.file_code,
  3906. tt1.diagnose,
  3907. tt2.behospital_code,
  3908. tt2.behospital_date,
  3909. tt2.leave_hospital_date
  3910. FROM
  3911. (
  3912. SELECT
  3913. a.file_code,
  3914. a.diagnose
  3915. FROM
  3916. med_behospital_info a
  3917. WHERE
  3918. a.is_deleted = 'N'
  3919. AND a.is_placefile = 1
  3920. AND a.qc_type_id != 0
  3921. AND IFNULL( a.diagnose, '' )!= ''
  3922. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3923. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3924. </if>
  3925. <if test="qcResultShortPageVO.startDate != null">
  3926. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  3927. </if>
  3928. <if test="qcResultShortPageVO.endDate != null ">
  3929. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  3930. </if>
  3931. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  3932. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  3933. </if>
  3934. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3935. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3936. </if>
  3937. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3938. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3939. </if>
  3940. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3941. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3942. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3943. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3944. </if>
  3945. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3946. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3947. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3948. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3949. </if>
  3950. GROUP BY
  3951. a.file_code,
  3952. a.diagnose
  3953. HAVING
  3954. count(*)> 1
  3955. ) tt1,
  3956. med_behospital_info tt2
  3957. WHERE
  3958. tt2.is_deleted = 'N'
  3959. AND tt2.is_placefile = 1
  3960. AND tt2.qc_type_id != 0
  3961. AND tt1.file_code = tt2.file_code
  3962. AND tt1.diagnose = tt2.diagnose
  3963. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3964. AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
  3965. </if>
  3966. <if test="qcResultShortPageVO.startDate != null">
  3967. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  3968. </if>
  3969. <if test="qcResultShortPageVO.endDate != null ">
  3970. <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  3971. </if>
  3972. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  3973. AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  3974. </if>
  3975. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3976. AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3977. </if>
  3978. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3979. AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3980. </if>
  3981. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3982. AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3983. OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3984. OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3985. </if>
  3986. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3987. AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3988. OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3989. OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3990. </if>
  3991. ORDER BY
  3992. tt1.file_code,
  3993. tt1.diagnose,
  3994. tt2.behospital_date DESC
  3995. ) t1,
  3996. (
  3997. SELECT
  3998. tt1.file_code,
  3999. tt1.diagnose,
  4000. tt2.behospital_code,
  4001. tt2.behospital_date,
  4002. tt2.leave_hospital_date
  4003. FROM
  4004. (
  4005. SELECT
  4006. a.file_code,
  4007. a.diagnose
  4008. FROM
  4009. med_behospital_info a
  4010. WHERE
  4011. a.is_deleted = 'N'
  4012. AND a.is_placefile = 1
  4013. AND a.qc_type_id != 0
  4014. AND IFNULL( a.diagnose, '' )!= ''
  4015. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4016. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4017. </if>
  4018. <if test="qcResultShortPageVO.startDate != null">
  4019. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  4020. </if>
  4021. <if test="qcResultShortPageVO.endDate != null ">
  4022. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  4023. </if>
  4024. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4025. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4026. </if>
  4027. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4028. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4029. </if>
  4030. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4031. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4032. </if>
  4033. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4034. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4035. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4036. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4037. </if>
  4038. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4039. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4040. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4041. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4042. </if>
  4043. GROUP BY
  4044. a.file_code,
  4045. a.diagnose
  4046. HAVING
  4047. count(*)> 1
  4048. ) tt1,
  4049. med_behospital_info tt2
  4050. WHERE
  4051. tt2.is_deleted = 'N'
  4052. AND tt2.is_placefile = 1
  4053. AND tt2.qc_type_id != 0
  4054. AND tt1.file_code = tt2.file_code
  4055. AND tt1.diagnose = tt2.diagnose
  4056. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4057. AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
  4058. </if>
  4059. <if test="qcResultShortPageVO.startDate != null">
  4060. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  4061. </if>
  4062. <if test="qcResultShortPageVO.endDate != null ">
  4063. <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  4064. </if>
  4065. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4066. AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4067. </if>
  4068. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4069. AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4070. </if>
  4071. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4072. AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4073. </if>
  4074. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4075. AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4076. OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4077. OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4078. </if>
  4079. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4080. AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4081. OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4082. OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4083. </if>
  4084. ORDER BY
  4085. tt1.file_code,
  4086. tt1.diagnose,
  4087. tt2.behospital_date DESC
  4088. ) t2
  4089. WHERE
  4090. t1.file_code = t2.file_code
  4091. AND t1.diagnose = t2.diagnose
  4092. AND t1.behospital_code != t2.behospital_code
  4093. AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
  4094. SELECT
  4095. bc2.file_code,
  4096. bc2.diagnose,
  4097. bc2.lastBehospitalCode,
  4098. bc2.lastBehospitalDate,
  4099. bc2.lastLeaveHospitalDate
  4100. FROM
  4101. (
  4102. SELECT
  4103. t1.file_code,
  4104. t1.diagnose,
  4105. t1.behospital_code AS behospitalCode,
  4106. t1.leave_hospital_date AS leaveHospitalDate,
  4107. t2.behospital_code AS lastBehospitalCode,
  4108. t2.behospital_date AS lastBehospitalDate,
  4109. t1.behospital_date AS behospitalDate,
  4110. t2.leave_hospital_date AS lastLeaveHospitalDate
  4111. FROM
  4112. (
  4113. SELECT
  4114. tt1.file_code,
  4115. tt1.diagnose,
  4116. tt2.behospital_code,
  4117. tt2.behospital_date,
  4118. tt2.leave_hospital_date
  4119. FROM
  4120. (
  4121. SELECT
  4122. a.file_code,
  4123. a.diagnose
  4124. FROM
  4125. med_behospital_info a
  4126. WHERE
  4127. a.is_deleted = 'N'
  4128. AND a.is_placefile = 1
  4129. AND a.qc_type_id != 0
  4130. AND IFNULL( a.diagnose, '' )!= ''
  4131. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4132. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4133. </if>
  4134. <if test="qcResultShortPageVO.startDate != null">
  4135. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  4136. </if>
  4137. <if test="qcResultShortPageVO.endDate != null ">
  4138. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  4139. </if>
  4140. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4141. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4142. </if>
  4143. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4144. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4145. </if>
  4146. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4147. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4148. </if>
  4149. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4150. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4151. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4152. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4153. </if>
  4154. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4155. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4156. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4157. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4158. </if>
  4159. GROUP BY
  4160. a.file_code,
  4161. a.diagnose
  4162. HAVING
  4163. count(*)> 1
  4164. ) tt1,
  4165. med_behospital_info tt2
  4166. WHERE
  4167. tt2.is_deleted = 'N'
  4168. AND tt2.is_placefile = 1
  4169. AND tt2.qc_type_id != 0
  4170. AND tt1.file_code = tt2.file_code
  4171. AND tt1.diagnose = tt2.diagnose
  4172. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4173. AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
  4174. </if>
  4175. <if test="qcResultShortPageVO.startDate != null">
  4176. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  4177. </if>
  4178. <if test="qcResultShortPageVO.endDate != null ">
  4179. <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  4180. </if>
  4181. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4182. AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4183. </if>
  4184. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4185. AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4186. </if>
  4187. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4188. AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4189. </if>
  4190. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4191. AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4192. OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4193. OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4194. </if>
  4195. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4196. AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4197. OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4198. OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4199. </if>
  4200. ORDER BY
  4201. tt1.file_code,
  4202. tt1.diagnose,
  4203. tt2.behospital_date DESC
  4204. ) t1,
  4205. (
  4206. SELECT
  4207. tt1.file_code,
  4208. tt1.diagnose,
  4209. tt2.behospital_code,
  4210. tt2.behospital_date,
  4211. tt2.leave_hospital_date
  4212. FROM
  4213. (
  4214. SELECT
  4215. a.file_code,
  4216. a.diagnose
  4217. FROM
  4218. med_behospital_info a
  4219. WHERE
  4220. a.is_deleted = 'N'
  4221. AND a.is_placefile = 1
  4222. AND a.qc_type_id != 0
  4223. AND IFNULL( a.diagnose, '' )!= ''
  4224. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4225. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4226. </if>
  4227. <if test="qcResultShortPageVO.startDate != null">
  4228. <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  4229. </if>
  4230. <if test="qcResultShortPageVO.endDate != null ">
  4231. <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  4232. </if>
  4233. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4234. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4235. </if>
  4236. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4237. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4238. </if>
  4239. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4240. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4241. </if>
  4242. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4243. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4244. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4245. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4246. </if>
  4247. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4248. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4249. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4250. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4251. </if>
  4252. GROUP BY
  4253. a.file_code,
  4254. a.diagnose
  4255. HAVING
  4256. count(*)> 1
  4257. ) tt1,
  4258. med_behospital_info tt2
  4259. WHERE
  4260. tt2.is_deleted = 'N'
  4261. AND tt2.is_placefile = 1
  4262. AND tt2.qc_type_id != 0
  4263. AND tt1.file_code = tt2.file_code
  4264. AND tt1.diagnose = tt2.diagnose
  4265. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4266. AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
  4267. </if>
  4268. <if test="qcResultShortPageVO.startDate != null">
  4269. <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
  4270. </if>
  4271. <if test="qcResultShortPageVO.endDate != null ">
  4272. <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
  4273. </if>
  4274. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4275. AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4276. </if>
  4277. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4278. AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4279. </if>
  4280. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4281. AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4282. </if>
  4283. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4284. AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4285. OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4286. OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4287. </if>
  4288. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4289. AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4290. OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4291. OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4292. </if>
  4293. ORDER BY
  4294. tt1.file_code,
  4295. tt1.diagnose,
  4296. tt2.behospital_date DESC
  4297. ) t2
  4298. WHERE
  4299. t1.file_code = t2.file_code
  4300. AND t1.diagnose = t2.diagnose
  4301. AND t1.behospital_code != t2.behospital_code
  4302. AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
  4303. ) tt2
  4304. WHERE
  4305. tt1.behospital_code = tt2.behospitalCode
  4306. </if>
  4307. ) t1
  4308. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  4309. ,med_home_page t2
  4310. WHERE
  4311. t2.is_deleted = 'N'
  4312. AND t1.hospital_id = t2.hospital_id
  4313. AND t1.behospital_code = t2.behospital_code
  4314. AND (
  4315. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' )
  4316. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' )
  4317. )
  4318. </if>
  4319. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  4320. ,med_home_page t2
  4321. WHERE
  4322. t2.is_deleted = 'N'
  4323. AND t1.hospital_id = t2.hospital_id
  4324. AND t1.behospital_code = t2.behospital_code
  4325. AND t2.return_to_type = '死亡'
  4326. </if>
  4327. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  4328. ,med_home_page t2
  4329. WHERE
  4330. t2.is_deleted = 'N'
  4331. AND t1.hospital_id = t2.hospital_id
  4332. AND t1.behospital_code = t2.behospital_code
  4333. AND t2.leave_hospital_type = '非医嘱离院'
  4334. </if>
  4335. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3 or qcResultShortPageVO.leaveHosType == 5">
  4336. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  4337. AND t1.hospital_id = t2.hospital_id
  4338. AND t1.behospital_code = t2.behospital_code
  4339. </if>
  4340. </select>
  4341. <!-- 病案首页改善率统计(首页)-->
  4342. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  4343. SELECT
  4344. t2.homePageMRNum,
  4345. t1.improveNum,
  4346. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  4347. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  4348. t1.improveToPassNum,
  4349. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  4350. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  4351. t1.improveToFullNum,
  4352. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  4353. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  4354. FROM
  4355. (
  4356. SELECT
  4357. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  4358. sum( d.score_res = 20 ) AS improveToFullNum,
  4359. count(*) AS improveNum
  4360. FROM
  4361. med_behospital_info a,
  4362. med_home_page b,
  4363. med_qcresult_info c,
  4364. med_qcresult_cases d,
  4365. (
  4366. SELECT
  4367. m4.*
  4368. FROM
  4369. med_behospital_info m1,
  4370. med_home_page m2,
  4371. med_qcresult_info m3,
  4372. med_qcresult_cases m4
  4373. WHERE
  4374. m1.is_deleted = 'N'
  4375. AND m2.is_deleted = 'N'
  4376. AND m3.is_deleted = 'Y'
  4377. AND m4.is_deleted = 'Y'
  4378. AND m1.hospital_id = m2.hospital_id
  4379. AND m1.hospital_id = m3.hospital_id
  4380. AND m1.hospital_id = m4.hospital_id
  4381. AND m1.behospital_code = m2.behospital_code
  4382. AND m1.behospital_code = m3.behospital_code
  4383. AND m1.behospital_code = m4.behospital_code
  4384. AND m3.have_home_page = 1
  4385. AND m4.cases_id = 243
  4386. AND m1.is_placefile = '1'
  4387. AND m1.qc_type_id != 0
  4388. <if test="hospitalId != null and hospitalId != ''">
  4389. AND m1.hospital_id = #{hospitalId}
  4390. </if>
  4391. <if test="startDate != null">
  4392. <![CDATA[ AND m1.leave_hospital_date >= DATE(#{startDate})]]>
  4393. </if>
  4394. <if test="endDate != null">
  4395. <![CDATA[AND m1.leave_hospital_date < DATE(#{endDate})]]>
  4396. </if>
  4397. GROUP BY
  4398. m1.behospital_code
  4399. ORDER BY
  4400. m1.behospital_code,
  4401. m4.gmt_create
  4402. ) e
  4403. WHERE
  4404. a.is_deleted = 'N'
  4405. AND b.is_deleted = 'N'
  4406. AND c.is_deleted = 'N'
  4407. AND d.is_deleted = 'N'
  4408. AND a.hospital_id = b.hospital_id
  4409. AND a.hospital_id = c.hospital_id
  4410. AND a.hospital_id = d.hospital_id
  4411. AND a.hospital_id = e.hospital_id
  4412. AND a.behospital_code = b.behospital_code
  4413. AND a.behospital_code = c.behospital_code
  4414. AND a.behospital_code = d.behospital_code
  4415. AND a.behospital_code = e.behospital_code
  4416. AND d.cases_id = 243
  4417. AND d.score_res > e.score_res
  4418. AND a.is_placefile = '1'
  4419. AND a.qc_type_id != 0
  4420. <if test="hospitalId != null and hospitalId != ''">
  4421. AND a.hospital_id = #{hospitalId}
  4422. </if>
  4423. <if test="startDate != null">
  4424. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4425. </if>
  4426. <if test="endDate != null">
  4427. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4428. </if>
  4429. ) t1,
  4430. (
  4431. SELECT
  4432. count( DISTINCT a.behospital_code ) AS homePageMRNum
  4433. FROM
  4434. med_behospital_info a,
  4435. med_home_page b,
  4436. med_qcresult_info c
  4437. WHERE
  4438. a.is_deleted = 'N'
  4439. AND b.is_deleted = 'N'
  4440. AND a.hospital_id = b.hospital_id
  4441. AND a.hospital_id = c.hospital_id
  4442. AND a.behospital_code = b.behospital_code
  4443. AND a.behospital_code = c.behospital_code
  4444. AND a.qc_type_id != 0
  4445. AND a.is_placefile = '1'
  4446. <if test="hospitalId != null and hospitalId != ''">
  4447. AND a.hospital_id = #{hospitalId}
  4448. </if>
  4449. <if test="startDate != null">
  4450. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4451. </if>
  4452. <if test="endDate != null">
  4453. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4454. </if>
  4455. ) t2
  4456. </select>
  4457. <!-- 质控核查统计(内页)-->
  4458. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterQcCheckVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  4459. SELECT
  4460. mr.beh_dept_id AS deptId,
  4461. mr.beh_dept_name AS deptName,
  4462. IFNULL( mr.mrNum, 0 ) AS mrNum,
  4463. ck.checkedNum AS checkedNum,
  4464. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  4465. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  4466. hmmr_t.homePageMRNum,
  4467. improve_t.improveNum,
  4468. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  4469. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  4470. improve_t.improveToPassNum,
  4471. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  4472. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  4473. improve_t.improveToFullNum,
  4474. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  4475. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  4476. FROM
  4477. (
  4478. SELECT
  4479. a.beh_dept_id,
  4480. a.beh_dept_name,
  4481. count(*) AS mrNum
  4482. FROM
  4483. med_behospital_info a,
  4484. med_qcresult_info b
  4485. WHERE
  4486. a.is_deleted = 'N'
  4487. AND b.is_deleted = 'N'
  4488. AND a.hospital_id = b.hospital_id
  4489. AND a.behospital_code = b.behospital_code
  4490. AND a.qc_type_id != 0
  4491. AND a.is_placefile = '1'
  4492. <if test="hospitalId != null and hospitalId != ''">
  4493. AND a.hospital_id = #{hospitalId}
  4494. </if>
  4495. <if test="startDate != null">
  4496. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4497. </if>
  4498. <if test="endDate != null">
  4499. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4500. </if>
  4501. <if test="deptName != null and deptName != ''">
  4502. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4503. </if>
  4504. GROUP BY
  4505. a.beh_dept_id,
  4506. a.beh_dept_name
  4507. ) mr
  4508. LEFT JOIN (
  4509. SELECT
  4510. a.beh_dept_id,
  4511. a.beh_dept_name,
  4512. count(*) AS checkedNum
  4513. FROM
  4514. med_behospital_info a,
  4515. med_qcresult_info b,
  4516. med_check_info c
  4517. WHERE
  4518. a.is_deleted = 'N'
  4519. AND b.is_deleted = 'N'
  4520. AND c.is_deleted = 'N'
  4521. AND a.hospital_id = b.hospital_id
  4522. AND a.hospital_id = c.hospital_id
  4523. AND a.behospital_code = b.behospital_code
  4524. AND a.behospital_code = c.behospital_code
  4525. AND a.qc_type_id != 0
  4526. AND a.is_placefile = '1'
  4527. AND c.`status` = 1
  4528. <if test="hospitalId != null and hospitalId != ''">
  4529. AND a.hospital_id = #{hospitalId}
  4530. </if>
  4531. <if test="startDate != null">
  4532. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4533. </if>
  4534. <if test="endDate != null">
  4535. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4536. </if>
  4537. <if test="deptName != null and deptName != ''">
  4538. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4539. </if>
  4540. GROUP BY
  4541. a.beh_dept_id,
  4542. a.beh_dept_name
  4543. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  4544. AND mr.beh_dept_name = ck.beh_dept_name
  4545. LEFT JOIN (
  4546. SELECT
  4547. a.beh_dept_id,
  4548. a.beh_dept_name,
  4549. count( DISTINCT a.behospital_code ) AS homePageMRNum
  4550. FROM
  4551. med_behospital_info a,
  4552. med_home_page b,
  4553. med_qcresult_info c
  4554. WHERE
  4555. a.is_deleted = 'N'
  4556. AND b.is_deleted = 'N'
  4557. AND a.hospital_id = b.hospital_id
  4558. AND a.hospital_id = c.hospital_id
  4559. AND a.behospital_code = b.behospital_code
  4560. AND a.behospital_code = c.behospital_code
  4561. AND a.qc_type_id != 0
  4562. AND a.is_placefile = '1'
  4563. AND c.have_home_page = '1'
  4564. <if test="hospitalId != null and hospitalId != ''">
  4565. AND a.hospital_id = #{hospitalId}
  4566. </if>
  4567. <if test="startDate != null">
  4568. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4569. </if>
  4570. <if test="endDate != null">
  4571. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4572. </if>
  4573. <if test="deptName != null and deptName != ''">
  4574. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4575. </if>
  4576. GROUP BY
  4577. a.beh_dept_id,
  4578. a.beh_dept_name
  4579. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  4580. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  4581. LEFT JOIN (
  4582. SELECT
  4583. a.beh_dept_id,
  4584. a.beh_dept_name,
  4585. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  4586. sum( d.score_res = 20 ) AS improveToFullNum,
  4587. count(*) AS improveNum
  4588. FROM
  4589. med_behospital_info a,
  4590. med_home_page b,
  4591. med_qcresult_info c,
  4592. med_qcresult_cases d,
  4593. (
  4594. SELECT
  4595. m4.*
  4596. FROM
  4597. med_behospital_info m1,
  4598. med_home_page m2,
  4599. med_qcresult_info m3,
  4600. med_qcresult_cases m4
  4601. WHERE
  4602. m1.is_deleted = 'N'
  4603. AND m2.is_deleted = 'N'
  4604. AND m3.is_deleted = 'Y'
  4605. AND m4.is_deleted = 'Y'
  4606. AND m1.hospital_id = m2.hospital_id
  4607. AND m1.hospital_id = m3.hospital_id
  4608. AND m1.hospital_id = m4.hospital_id
  4609. AND m1.behospital_code = m2.behospital_code
  4610. AND m1.behospital_code = m3.behospital_code
  4611. AND m1.behospital_code = m4.behospital_code
  4612. AND m3.have_home_page = 1
  4613. AND m4.cases_id = 243
  4614. <if test="hospitalId != null and hospitalId != ''">
  4615. AND m1.hospital_id = #{hospitalId}
  4616. </if>
  4617. <if test="startDate != null">
  4618. <![CDATA[ AND m1.leave_hospital_date >= DATE(#{startDate})]]>
  4619. </if>
  4620. <if test="endDate != null">
  4621. <![CDATA[AND m1.leave_hospital_date < DATE(#{endDate})]]>
  4622. </if>
  4623. <if test="deptName != null and deptName != ''">
  4624. AND m1.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4625. </if>
  4626. GROUP BY
  4627. m1.behospital_code
  4628. ORDER BY
  4629. m1.behospital_code,
  4630. m4.gmt_create
  4631. ) e
  4632. WHERE
  4633. a.is_deleted = 'N'
  4634. AND b.is_deleted = 'N'
  4635. AND c.is_deleted = 'N'
  4636. AND d.is_deleted = 'N'
  4637. AND a.hospital_id = b.hospital_id
  4638. AND a.hospital_id = c.hospital_id
  4639. AND a.hospital_id = d.hospital_id
  4640. AND a.hospital_id = e.hospital_id
  4641. AND a.behospital_code = b.behospital_code
  4642. AND a.behospital_code = c.behospital_code
  4643. AND a.behospital_code = d.behospital_code
  4644. AND a.behospital_code = e.behospital_code
  4645. AND d.cases_id = 243
  4646. AND d.score_res > e.score_res
  4647. <if test="hospitalId != null and hospitalId != ''">
  4648. AND a.hospital_id = #{hospitalId}
  4649. </if>
  4650. <if test="startDate != null">
  4651. <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
  4652. </if>
  4653. <if test="endDate != null">
  4654. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  4655. </if>
  4656. <if test="deptName != null and deptName != ''">
  4657. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  4658. </if>
  4659. GROUP BY
  4660. a.beh_dept_id,
  4661. a.beh_dept_name
  4662. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  4663. AND mr.beh_dept_name = improve_t.beh_dept_name
  4664. </select>
  4665. </mapper>