BehospitalInfoMapper.xml 634 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806
  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 distinct a.*,
  43. ifnull(b.level,'未评分') as `level`,
  44. b.grade_type,
  45. b.score_res,
  46. b.gmt_create as grade_time,
  47. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age,
  48. e.score_res as score_bn,
  49. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  50. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  51. g.check_type AS ch_type,
  52. h.check_type AS mr_type,
  53. g.check_name AS ch_name,
  54. h.check_name AS mr_name,
  55. g.check_time AS ch_time,
  56. h.check_time AS mr_time
  57. from med_behospital_info a
  58. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  59. ON a.behospital_code = g.behospital_code
  60. AND a.hospital_id = g.hospital_id
  61. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  62. ON a.behospital_code = h.behospital_code
  63. AND a.hospital_id = h.hospital_id
  64. LEFT JOIN med_qcresult_info b
  65. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  66. left join med_home_page c
  67. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  68. LEFT JOIN med_qcresult_cases e
  69. on a.behospital_code = e.behospital_code
  70. AND e.is_deleted = 'N'
  71. and e.cases_id = 243
  72. where
  73. a.is_deleted = 'N'
  74. <if test="diagnose != null and diagnose != ''">
  75. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  76. </if>
  77. <if test="deptName != null and deptName != ''">
  78. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  79. </if>
  80. <if test="doctorName != null and doctorName != ''">
  81. and CONCAT(
  82. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  83. like CONCAT('%',#{doctorName},'%')
  84. </if>
  85. <if test="name != null and name != ''">
  86. and a.name like CONCAT('%',#{name},'%')
  87. </if>
  88. <if test="doctorCode != null and doctorCode != ''">
  89. and (a.doctor_id = #{doctorCode}
  90. or a.beh_doctor_id = #{doctorCode}
  91. or a.director_doctor_id = #{doctorCode})
  92. </if>
  93. <if test="fileCode != null and fileCode != ''">
  94. and a.file_code like CONCAT('%',#{fileCode},'%')
  95. </if>
  96. <if test="hospitalId != null">
  97. and a.hospital_id = #{hospitalId}
  98. </if>
  99. <if test="behospitalCode != null and behospitalCode != ''">
  100. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  101. </if>
  102. <if test="behosDateStart != null">
  103. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  104. </if>
  105. <if test="behosDateEnd != null">
  106. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  107. </if>
  108. <if test="leaveHosDateStart != null">
  109. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  110. </if>
  111. <if test="leaveHosDateEnd != null">
  112. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  113. </if>
  114. <if test="level != null and level != ''">
  115. and b.level = #{level}
  116. </if>
  117. <if test="isPlacefile != null and isPlacefile != ''">
  118. and a.is_placefile = #{isPlacefile}
  119. </if>
  120. and a.qc_type_id != 0) p
  121. where p.is_deleted="N"
  122. <if test="checkStatus != null ">
  123. and p.check_status = #{checkStatus}
  124. </if>
  125. <if test="mrStatus != null ">
  126. AND p.mr_status = #{mrStatus}
  127. </if>
  128. <if test="chName != null and chName !=''">
  129. AND p.ch_name like CONCAT('%',#{chName},'%')
  130. </if>
  131. <if test="mrName != null and mrName !=''">
  132. AND p.mr_name like CONCAT('%',#{mrName},'%')
  133. </if>
  134. <if test="chTimeStart != null">
  135. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  136. </if>
  137. <if test="chTimeEnd != null">
  138. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  139. </if>
  140. <if test="mrTimeStart != null">
  141. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  142. </if>
  143. <if test="mrTimeEnd != null">
  144. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  145. </if>
  146. </select>
  147. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  148. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  149. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
  150. c.opt_type, c.grade_type, c.gmt_create, c.gmt_modified,
  151. a.type, a.drgs
  152. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  153. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  154. and a.id = c.cases_entry_id
  155. and a.mode_id = b.id
  156. AND c.cases_id = d.cases_id
  157. and c.hospital_id = d.hospital_id
  158. and c.hospital_id = #{hospitalId}
  159. and c.behospital_code = #{behospitalCode}
  160. order by b.order_no, c.grade_type desc, a.order_no
  161. </select>
  162. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  163. SELECT b.id model_id,b.`name` model_name,
  164. d.score,d.msg,d.cases_entry_id,d.is_reject,
  165. a.cases_id cases_id, a.name standard_msg,a.code
  166. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  167. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  168. and a.mode_id = b.id
  169. and a.id = d.cases_entry_id
  170. and d.is_used = 1
  171. and d.hospital_id = #{hospitalId}
  172. and a.code in
  173. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  174. #{item}
  175. </foreach>
  176. <if test="modeId != null">
  177. and a.mode_id = #{modeId}
  178. </if>
  179. order by b.order_no, a.order_no;
  180. </select>
  181. <!-- 各科室缺陷占比-全院-首页 -->
  182. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  183. resultType="com.diagbot.dto.NumDTO">
  184. SELECT
  185. a.beh_dept_id as id,
  186. a.beh_dept_name as name,
  187. count(*) AS num
  188. FROM
  189. med_behospital_info a,
  190. med_qcresult_info c,
  191. med_qcresult_detail d
  192. WHERE
  193. a.behospital_code = c.behospital_code
  194. AND a.hospital_id = c.hospital_id
  195. AND a.behospital_code = d.behospital_code
  196. AND a.hospital_id = d.hospital_id
  197. AND a.is_deleted = 'N'
  198. AND c.is_deleted = 'N'
  199. AND d.is_deleted = 'N'
  200. <if test="isPlacefile != null and isPlacefile != ''">
  201. and a.is_placefile = #{isPlacefile}
  202. </if>
  203. <![CDATA[AND a.qc_type_id <>0 ]]>
  204. <if test="hospitalId != null and hospitalId != ''">
  205. AND a.hospital_id = #{hospitalId}
  206. </if>
  207. <if test="isPlacefile != null and isPlacefile == 0">
  208. <if test="startDate != null and startDate != ''">
  209. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  210. </if>
  211. <if test="endDate != null and endDate != ''">
  212. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  213. </if>
  214. </if>
  215. <if test="isPlacefile != null and isPlacefile == 1">
  216. <if test="startDate != null and startDate != ''">
  217. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  218. </if>
  219. <if test="endDate != null and endDate != ''">
  220. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  221. </if>
  222. </if>
  223. GROUP BY
  224. a.beh_dept_id,
  225. a.beh_dept_name
  226. ORDER BY
  227. count(*) DESC
  228. </select>
  229. <!-- 质控结果缺陷总数查询-->
  230. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  231. SELECT
  232. count(*) AS totle
  233. FROM
  234. med_behospital_info a,
  235. med_qcresult_info c,
  236. med_qcresult_detail d
  237. WHERE
  238. a.behospital_code = c.behospital_code
  239. AND a.hospital_id = c.hospital_id
  240. AND a.behospital_code = d.behospital_code
  241. AND a.hospital_id = d.hospital_id
  242. AND a.is_deleted = 'N'
  243. AND c.is_deleted = 'N'
  244. AND d.is_deleted = 'N'
  245. <if test="isPlacefile != null and isPlacefile != ''">
  246. and a.is_placefile = #{isPlacefile}
  247. </if>
  248. <![CDATA[AND a.qc_type_id <>0 ]]>
  249. <if test="hospitalId != null and hospitalId != ''">
  250. AND a.hospital_id = #{hospitalId}
  251. </if>
  252. <if test="isPlacefile != null and isPlacefile == 0">
  253. <if test="startDate != null and startDate != ''">
  254. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  255. </if>
  256. <if test="endDate != null and endDate != ''">
  257. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  258. </if>
  259. </if>
  260. <if test="isPlacefile != null and isPlacefile == 1">
  261. <if test="startDate != null and startDate != ''">
  262. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  263. </if>
  264. <if test="endDate != null and endDate != ''">
  265. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  266. </if>
  267. </if>
  268. </select>
  269. <!--获取病历-->
  270. <select id="getNoGrade" resultMap="BaseResultMap">
  271. select * from med_behospital_info a
  272. where a.is_deleted = 'N'
  273. and a.qc_type_id != 0
  274. <if test="isPlacefile != null and isPlacefile != ''">
  275. and a.is_placefile = #{isPlacefile}
  276. </if>
  277. <if test="filterFlag != null and filterFlag == 0">
  278. and
  279. not EXISTS (
  280. SELECT
  281. 1
  282. FROM
  283. med_qcresult_info b
  284. WHERE
  285. b.is_deleted = 'N'
  286. AND a.hospital_id = b.hospital_id
  287. AND a.behospital_code = b.behospital_code
  288. )
  289. </if>
  290. <if test="leaveDate != null">
  291. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  292. </if>
  293. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  294. and a.hospital_id in
  295. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  296. #{item}
  297. </foreach>
  298. </if>
  299. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  300. and a.behospital_code in
  301. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  302. #{item}
  303. </foreach>
  304. </if>
  305. <if test="individuation != null and individuation.contains(1)">
  306. union
  307. select * from med_behospital_info b
  308. where b.is_deleted = 'N'
  309. and b.qc_type_id != 0
  310. <if test="isPlacefile != null and isPlacefile != ''">
  311. and b.is_placefile = #{isPlacefile}
  312. </if>
  313. <if test="startLeaveDate != null">
  314. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  315. </if>
  316. <if test="endLeaveDate != null">
  317. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  318. </if>
  319. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  320. and b.hospital_id in
  321. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  322. #{item}
  323. </foreach>
  324. </if>
  325. </if>
  326. </select>
  327. <!--质控评分(科室)分页-->
  328. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  329. SELECT * from (
  330. SELECT
  331. t.*,
  332. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  333. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  334. g.check_type as ch_type,
  335. h.check_type AS mr_type,
  336. g.check_name as ch_name,
  337. h.check_name as mr_name,
  338. g.check_time as ch_time,
  339. h.check_time AS mr_time
  340. FROM
  341. ( SELECT
  342. a.*,
  343. IFNULL(b.level, '未评分') AS `level`,
  344. b.grade_type,
  345. b.score_res,
  346. e.score_res as score_bn,
  347. b.gmt_create AS grade_time,
  348. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  349. FROM
  350. med_behospital_info a
  351. JOIN sys_user_dept d
  352. ON a.hospital_id = d.hospital_id
  353. AND a.beh_dept_id = d.dept_id
  354. LEFT JOIN med_qcresult_info b
  355. ON a.behospital_code = b.behospital_code
  356. AND b.is_deleted = 'N'
  357. LEFT JOIN med_qcresult_cases e
  358. on a.behospital_code = e.behospital_code
  359. AND e.is_deleted = 'N'
  360. and e.cases_id = 243
  361. LEFT JOIN med_home_page c
  362. ON a.behospital_code = c.behospital_code
  363. AND c.is_deleted = 'N'
  364. WHERE d.is_deleted = 'N'
  365. AND d.user_id = #{userId}
  366. ) t
  367. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  368. ON t.behospital_code = g.behospital_code
  369. AND t.hospital_id = g.hospital_id
  370. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  371. ON t.behospital_code = h.behospital_code
  372. AND t.hospital_id = h.hospital_id
  373. where t.is_deleted = 'N'
  374. <if test="diagnose != null and diagnose != ''">
  375. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  376. </if>
  377. <if test="deptName != null and deptName != ''">
  378. and t.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  379. </if>
  380. <if test="doctorName != null and doctorName != ''">
  381. and CONCAT(
  382. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  383. like CONCAT('%',#{doctorName},'%')
  384. </if>
  385. <if test="doctorCode != null and doctorCode != ''">
  386. and (t.doctor_id = #{doctorCode}
  387. or t.beh_doctor_id = #{doctorCode}
  388. or t.director_doctor_id = #{doctorCode})
  389. </if>
  390. <if test="name != null and name != ''">
  391. and t.name like CONCAT('%',#{name},'%')
  392. </if>
  393. <if test="fileCode != null and fileCode != ''">
  394. and t.file_code like CONCAT('%',#{fileCode},'%')
  395. </if>
  396. <if test="hospitalId != null">
  397. and t.hospital_id = #{hospitalId}
  398. </if>
  399. <if test="behospitalCode != null and behospitalCode != ''">
  400. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  401. </if>
  402. <if test="behosDateStart != null">
  403. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  404. </if>
  405. <if test="behosDateEnd != null">
  406. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  407. </if>
  408. <if test="leaveHosDateStart != null">
  409. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  410. </if>
  411. <if test="leaveHosDateEnd != null">
  412. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  413. </if>
  414. <if test="level != null and level != ''">
  415. and t.level = #{level}
  416. </if>
  417. <if test="isPlacefile != null and isPlacefile != ''">
  418. and t.is_placefile = #{isPlacefile}
  419. </if>
  420. and t.qc_type_id != 0) p
  421. where p.is_deleted="N"
  422. <if test="checkStatus != null ">
  423. and p.check_status = #{checkStatus}
  424. </if>
  425. <if test="mrStatus != null ">
  426. AND p.mr_status = #{mrStatus}
  427. </if>
  428. <if test="chName != null and chName !=''">
  429. AND p.ch_name like CONCAT('%',#{chName},'%')
  430. </if>
  431. <if test="mrName != null and mrName !=''">
  432. AND p.mr_name like CONCAT('%',#{mrName},'%')
  433. </if>
  434. <if test="chTimeStart != null">
  435. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  436. </if>
  437. <if test="chTimeEnd != null">
  438. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  439. </if>
  440. <if test="mrTimeStart != null">
  441. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  442. </if>
  443. <if test="mrTimeEnd != null">
  444. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  445. </if>
  446. </select>
  447. <!--质控评分(个人)分页-->
  448. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  449. Select * from (
  450. select t.*,
  451. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  452. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  453. g.check_type as ch_type,
  454. h.check_type AS mr_type,
  455. g.check_name as ch_name,
  456. h.check_name as mr_name,
  457. g.check_time as ch_time,
  458. h.check_time AS mr_time
  459. from (SELECT
  460. a.*,
  461. IFNULL(b.level, '未评分') AS `level`,
  462. b.grade_type,
  463. b.score_res,
  464. e.score_res as score_bn,
  465. b.gmt_create AS grade_time,
  466. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  467. FROM
  468. med_behospital_info a
  469. JOIN
  470. (SELECT
  471. u.id,
  472. u.linkman AS linkman,
  473. uh.hospital_id
  474. FROM
  475. sys_user u
  476. JOIN sys_user_hospital uh
  477. ON u.id = uh.user_id
  478. WHERE u.is_deleted = "N"
  479. AND u.id = #{userId}
  480. AND uh.hospital_id = #{hospitalId}) u1
  481. ON a.hospital_id = u1.hospital_id
  482. LEFT JOIN med_qcresult_info b
  483. ON a.behospital_code = b.behospital_code
  484. AND b.is_deleted = 'N'
  485. LEFT JOIN med_qcresult_cases e
  486. on a.behospital_code = e.behospital_code
  487. AND e.is_deleted = 'N'
  488. and e.cases_id = 243
  489. LEFT JOIN med_home_page c
  490. ON a.behospital_code = c.behospital_code
  491. AND c.is_deleted = 'N'
  492. WHERE
  493. a.is_deleted = 'N'
  494. and a.doctor_name = u1.linkman
  495. or a.beh_doctor_name = u1.linkman
  496. or a.director_doctor_name = u1.linkman
  497. ) t
  498. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  499. ON t.behospital_code = g.behospital_code
  500. AND t.hospital_id = g.hospital_id
  501. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  502. ON t.behospital_code = h.behospital_code
  503. AND t.hospital_id = h.hospital_id
  504. WHERE t.is_deleted = 'N'
  505. <if test="diagnose != null and diagnose != ''">
  506. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  507. </if>
  508. <if test="deptName != null and deptName != ''">
  509. and t.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  510. </if>
  511. <if test="name != null and name != ''">
  512. and t.name like CONCAT('%',#{name},'%')
  513. </if>
  514. <if test="fileCode != null and fileCode != ''">
  515. and t.file_code like CONCAT('%',#{fileCode},'%')
  516. </if>
  517. <if test="behospitalCode != null and behospitalCode != ''">
  518. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  519. </if>
  520. <if test="behosDateStart != null">
  521. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  522. </if>
  523. <if test="behosDateEnd != null">
  524. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  525. </if>
  526. <if test="leaveHosDateStart != null">
  527. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  528. </if>
  529. <if test="leaveHosDateEnd != null">
  530. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  531. </if>
  532. <if test="level != null and level != ''">
  533. and t.level = #{level}
  534. </if>
  535. <if test="isPlacefile != null and isPlacefile != ''">
  536. and t.is_placefile = #{isPlacefile}
  537. </if>
  538. and t.qc_type_id != 0) p
  539. where p.is_deleted="N"
  540. <if test="checkStatus != null ">
  541. and p.check_status = #{checkStatus}
  542. </if>
  543. <if test="mrStatus != null ">
  544. AND p.mr_status = #{mrStatus}
  545. </if>
  546. <if test="chName != null and chName !=''">
  547. AND p.ch_name like CONCAT('%',#{chName},'%')
  548. </if>
  549. <if test="mrName != null and mrName !=''">
  550. AND p.mr_name like CONCAT('%',#{mrName},'%')
  551. </if>
  552. <if test="chTimeStart != null">
  553. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  554. </if>
  555. <if test="chTimeEnd != null">
  556. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  557. </if>
  558. <if test="mrTimeStart != null">
  559. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  560. </if>
  561. <if test="mrTimeEnd != null">
  562. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  563. </if>
  564. </select>
  565. <!--质控评分(医疗组)分页-->
  566. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  567. select * from (
  568. select t.*,
  569. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  570. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  571. g.check_type as ch_type,
  572. h.check_type AS mr_type,
  573. g.check_name as ch_name,
  574. h.check_name as mr_name,
  575. g.check_time as ch_time,
  576. h.check_time AS mr_time
  577. from (
  578. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  579. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  580. LEFT JOIN med_qcresult_info b
  581. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  582. LEFT JOIN med_qcresult_cases e
  583. on a.behospital_code = e.behospital_code
  584. AND e.is_deleted = 'N'
  585. and e.cases_id = 243
  586. left join med_home_page c
  587. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  588. ) t
  589. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  590. ON t.behospital_code = g.behospital_code
  591. AND t.hospital_id = g.hospital_id
  592. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  593. ON t.behospital_code = h.behospital_code
  594. AND t.hospital_id = h.hospital_id
  595. WHERE t.is_deleted = 'N'
  596. and
  597. t.doctor_id in (
  598. SELECT doctor_id FROM `bas_doctor_info`
  599. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  600. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  601. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  602. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  603. and c1.username = c3.doctor_id
  604. and c2.hospital_id = #{hospitalId}
  605. and c1.id = #{userId}
  606. )
  607. )
  608. <if test="diagnose != null and diagnose != ''">
  609. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  610. </if>
  611. <if test="doctorName != null and doctorName != ''">
  612. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  613. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  614. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  615. </if>
  616. <if test="name != null and name != ''">
  617. and t.name like CONCAT('%',#{name},'%')
  618. </if>
  619. <if test="doctorCode != null and doctorCode != ''">
  620. and (t.doctor_id = #{doctorCode}
  621. or t.beh_doctor_id = #{doctorCode}
  622. or t.director_doctor_id = #{doctorCode})
  623. </if>
  624. <if test="fileCode != null and fileCode != ''">
  625. and t.file_code like CONCAT('%',#{fileCode},'%')
  626. </if>
  627. <if test="hospitalId != null">
  628. and t.hospital_id = #{hospitalId}
  629. </if>
  630. <if test="behospitalCode != null and behospitalCode != ''">
  631. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  632. </if>
  633. <if test="behosDateStart != null">
  634. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  635. </if>
  636. <if test="behosDateEnd != null">
  637. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  638. </if>
  639. <if test="leaveHosDateStart != null">
  640. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  641. </if>
  642. <if test="leaveHosDateEnd != null">
  643. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  644. </if>
  645. <if test="level != null and level != ''">
  646. and t.level = #{level}
  647. </if>
  648. <if test="isPlacefile != null and isPlacefile != ''">
  649. and t.is_placefile = #{isPlacefile}
  650. </if>
  651. and t.qc_type_id != 0) p
  652. where p.is_deleted="N"
  653. <if test="checkStatus != null ">
  654. and p.check_status = #{checkStatus}
  655. </if>
  656. <if test="mrStatus != null ">
  657. AND p.mr_status = #{mrStatus}
  658. </if>
  659. <if test="chName != null and chName !=''">
  660. AND p.ch_name like CONCAT('%',#{chName},'%')
  661. </if>
  662. <if test="mrName != null and mrName !=''">
  663. AND p.mr_name like CONCAT('%',#{mrName},'%')
  664. </if>
  665. <if test="chTimeStart != null">
  666. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  667. </if>
  668. <if test="chTimeEnd != null">
  669. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  670. </if>
  671. <if test="mrTimeStart != null">
  672. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  673. </if>
  674. <if test="mrTimeEnd != null">
  675. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  676. </if>
  677. </select>
  678. <!-- 出院总人数统计-全院-首页 -->
  679. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  680. SELECT
  681. COUNT(*)
  682. FROM
  683. med_behospital_info a
  684. WHERE
  685. a.is_deleted = 'N'
  686. <if test="isPlacefile != null and isPlacefile != ''">
  687. and a.is_placefile = #{isPlacefile}
  688. </if>
  689. <if test="hospitalId != null and hospitalId != ''">
  690. AND a.hospital_id = #{hospitalId}
  691. </if>
  692. <if test="isPlacefile != null and isPlacefile == 0">
  693. <if test="startDate != null and startDate != ''">
  694. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  695. </if>
  696. <if test="endDate != null and endDate != ''">
  697. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  698. </if>
  699. </if>
  700. <if test="isPlacefile != null and isPlacefile == 1">
  701. <if test="startDate != null and startDate != ''">
  702. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  703. </if>
  704. <if test="endDate != null and endDate != ''">
  705. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  706. </if>
  707. </if>
  708. </select>
  709. <!-- 新生儿出院人数统计-全院-首页 -->
  710. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  711. SELECT
  712. COUNT(*)
  713. FROM
  714. med_behospital_info a,
  715. med_home_page b
  716. WHERE
  717. a.is_deleted = 'N'
  718. AND b.is_deleted = 'N'
  719. AND a.hospital_id = b.hospital_id
  720. AND a.behospital_code = b.behospital_code
  721. <if test="isPlacefile != null and isPlacefile != ''">
  722. and a.is_placefile = #{isPlacefile}
  723. </if>
  724. AND (
  725. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  726. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  727. )
  728. <![CDATA[AND a.qc_type_id <>0 ]]>
  729. <if test="hospitalId != null and hospitalId != ''">
  730. AND a.hospital_id = #{hospitalId}
  731. </if>
  732. <if test="isPlacefile != null and isPlacefile == 0">
  733. <if test="startDate != null and startDate != ''">
  734. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  735. </if>
  736. <if test="endDate != null and endDate != ''">
  737. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  738. </if>
  739. </if>
  740. <if test="isPlacefile != null and isPlacefile == 1">
  741. <if test="startDate != null and startDate != ''">
  742. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  743. </if>
  744. <if test="endDate != null and endDate != ''">
  745. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  746. </if>
  747. </if>
  748. </select>
  749. <!-- 死亡人数统计-全院-首页 -->
  750. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  751. select COUNT(*) from(
  752. SELECT distinct a.*
  753. FROM
  754. med_behospital_info a,
  755. med_medical_record b,
  756. med_medical_record_content c
  757. WHERE
  758. a.is_deleted = 'N'
  759. AND b.is_deleted = 'N'
  760. AND c.is_deleted = 'N'
  761. AND a.hospital_id = b.hospital_id
  762. AND a.hospital_id = c.hospital_id
  763. AND a.behospital_code = b.behospital_code
  764. AND b.rec_id = c.rec_id
  765. and b.mode_id = '24'
  766. <if test="isPlacefile != null and isPlacefile != ''">
  767. and a.is_placefile = #{isPlacefile}
  768. </if>
  769. <![CDATA[AND a.qc_type_id <>0 ]]>
  770. <if test="hospitalId != null and hospitalId != ''">
  771. AND a.hospital_id = #{hospitalId}
  772. </if>
  773. <if test="isPlacefile != null and isPlacefile == 0">
  774. <if test="startDate != null and startDate != ''">
  775. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  776. </if>
  777. <if test="endDate != null and endDate != ''">
  778. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  779. </if>
  780. </if>
  781. <if test="isPlacefile != null and isPlacefile == 1">
  782. <if test="startDate != null and startDate != ''">
  783. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  784. </if>
  785. <if test="endDate != null and endDate != ''">
  786. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  787. </if>
  788. </if>)m
  789. </select>
  790. <!-- 手术人数统计-全院-首页 -->
  791. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  792. SELECT
  793. COUNT( DISTINCT a.behospital_code )
  794. FROM
  795. med_behospital_info a,
  796. med_medical_record c,
  797. qc_mode d
  798. WHERE
  799. a.is_deleted = 'N'
  800. AND c.is_deleted = 'N'
  801. AND d.is_deleted = 'N'
  802. AND a.hospital_id = c.hospital_id
  803. AND a.behospital_code = c.behospital_code
  804. AND c.mode_id = d.id
  805. <if test="isPlacefile != null and isPlacefile != ''">
  806. and a.is_placefile = #{isPlacefile}
  807. </if>
  808. AND d.`name` = '手术记录'
  809. <![CDATA[AND a.qc_type_id <>0 ]]>
  810. <if test="hospitalId != null and hospitalId != ''">
  811. AND a.hospital_id = #{hospitalId}
  812. </if>
  813. <if test="isPlacefile != null and isPlacefile == 0">
  814. <if test="startDate != null and startDate != ''">
  815. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  816. </if>
  817. <if test="endDate != null and endDate != ''">
  818. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  819. </if>
  820. </if>
  821. <if test="isPlacefile != null and isPlacefile == 1">
  822. <if test="startDate != null and startDate != ''">
  823. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  824. </if>
  825. <if test="endDate != null and endDate != ''">
  826. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  827. </if>
  828. </if>
  829. </select>
  830. <!-- 入院人数统计-首页 -->
  831. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  832. resultType="com.diagbot.dto.NumDTO">
  833. SELECT
  834. a.beh_dept_id AS id,
  835. a.beh_dept_name AS NAME,
  836. COUNT(*) AS num
  837. FROM
  838. med_behospital_info a
  839. WHERE
  840. a.is_deleted = 'N'
  841. <if test="isPlacefile != null and isPlacefile != ''">
  842. and a.is_placefile = #{isPlacefile}
  843. </if>
  844. <if test="hospitalId != null and hospitalId != ''">
  845. AND a.hospital_id = #{hospitalId}
  846. </if>
  847. <if test="isPlacefile != null and isPlacefile == 0">
  848. <if test="startDate != null and startDate != ''">
  849. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  850. </if>
  851. <if test="endDate != null and endDate != ''">
  852. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  853. </if>
  854. </if>
  855. <if test="isPlacefile != null and isPlacefile == 1">
  856. <if test="startDate != null and startDate != ''">
  857. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  858. </if>
  859. <if test="endDate != null and endDate != ''">
  860. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  861. </if>
  862. </if>
  863. GROUP BY
  864. a.beh_dept_id,
  865. a.beh_dept_name
  866. </select>
  867. <!-- 出院总人数统计-科室-首页 -->
  868. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  869. resultType="com.diagbot.dto.NumDTO">
  870. SELECT
  871. a.beh_dept_id AS id,
  872. a.beh_dept_name AS NAME,
  873. COUNT(*) AS num
  874. FROM
  875. med_behospital_info a,
  876. sys_user_dept c
  877. WHERE
  878. a.is_deleted = 'N'
  879. AND c.is_deleted = 'N'
  880. AND a.hospital_id = c.hospital_id
  881. AND a.beh_dept_id = c.dept_id
  882. <if test="isPlacefile != null and isPlacefile != ''">
  883. and a.is_placefile = #{isPlacefile}
  884. </if>
  885. <if test="userId!=null">
  886. AND c.user_id = #{userId}
  887. </if>
  888. <if test="hospitalId != null and hospitalId != ''">
  889. AND a.hospital_id = #{hospitalId}
  890. </if>
  891. <if test="isPlacefile != null and isPlacefile == 0">
  892. <if test="startDate != null and startDate != ''">
  893. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  894. </if>
  895. <if test="endDate != null and endDate != ''">
  896. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  897. </if>
  898. </if>
  899. <if test="isPlacefile != null and isPlacefile == 1">
  900. <if test="startDate != null and startDate != ''">
  901. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  902. </if>
  903. <if test="endDate != null and endDate != ''">
  904. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  905. </if>
  906. </if>
  907. GROUP BY
  908. a.beh_dept_id,
  909. a.beh_dept_name
  910. </select>
  911. <!-- 入院总人数统计-科室-首页 -->
  912. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  913. resultType="com.diagbot.dto.AdmissionCountDTO">
  914. SELECT
  915. a.beh_dept_id as deptId,
  916. a.beh_dept_name as deptName,
  917. a.doctor_id as doctorId,
  918. a.doctor_name as doctorName,
  919. COUNT(*) AS num
  920. FROM
  921. med_behospital_info a,
  922. sys_user_dept c
  923. WHERE
  924. a.is_deleted = 'N'
  925. AND c.is_deleted = 'N'
  926. AND a.hospital_id = c.hospital_id
  927. AND a.beh_dept_id = c.dept_id
  928. <if test="isPlacefile != null and isPlacefile != ''">
  929. and a.is_placefile = #{isPlacefile}
  930. </if>
  931. <if test="userId!=null">
  932. AND c.user_id = #{userId}
  933. </if>
  934. <if test="hospitalId != null and hospitalId != ''">
  935. AND a.hospital_id = #{hospitalId}
  936. </if>
  937. <if test="isPlacefile != null and isPlacefile == 0">
  938. <if test="startDate != null and startDate != ''">
  939. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  940. </if>
  941. <if test="endDate != null and endDate != ''">
  942. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  943. </if>
  944. </if>
  945. <if test="isPlacefile != null and isPlacefile == 1">
  946. <if test="startDate != null and startDate != ''">
  947. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  948. </if>
  949. <if test="endDate != null and endDate != ''">
  950. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  951. </if>
  952. </if>
  953. GROUP BY
  954. a.beh_dept_id,
  955. a.beh_dept_name,
  956. a.doctor_id,
  957. a.doctor_name
  958. </select>
  959. <!-- 新生儿出院人数统计-科室-首页 -->
  960. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  961. resultType="com.diagbot.dto.NumDTO">
  962. SELECT
  963. a.beh_dept_id AS id,
  964. a.beh_dept_name AS NAME,
  965. COUNT(*) AS num
  966. FROM
  967. med_behospital_info a,
  968. med_home_page b,
  969. sys_user_dept c
  970. WHERE
  971. a.is_deleted = 'N'
  972. AND b.is_deleted = 'N'
  973. AND c.is_deleted = 'N'
  974. AND a.hospital_id = b.hospital_id
  975. AND a.hospital_id = c.hospital_id
  976. AND a.behospital_code = b.behospital_code
  977. AND a.beh_dept_id = c.dept_id
  978. AND (
  979. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  980. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  981. )
  982. <if test="isPlacefile != null and isPlacefile != ''">
  983. and a.is_placefile = #{isPlacefile}
  984. </if>
  985. <![CDATA[AND a.qc_type_id <>0 ]]>
  986. <if test="userId!=null">
  987. AND c.user_id = #{userId}
  988. </if>
  989. <if test="hospitalId != null and hospitalId != ''">
  990. AND a.hospital_id = #{hospitalId}
  991. </if>
  992. <if test="isPlacefile != null and isPlacefile == 0">
  993. <if test="startDate != null and startDate != ''">
  994. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  995. </if>
  996. <if test="endDate != null and endDate != ''">
  997. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  998. </if>
  999. </if>
  1000. <if test="isPlacefile != null and isPlacefile == 1">
  1001. <if test="startDate != null and startDate != ''">
  1002. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1003. </if>
  1004. <if test="endDate != null and endDate != ''">
  1005. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1006. </if>
  1007. </if>
  1008. GROUP BY
  1009. a.beh_dept_id,
  1010. a.beh_dept_name
  1011. </select>
  1012. <!-- 死亡人数统计-科室-首页 -->
  1013. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1014. resultType="com.diagbot.dto.NumDTO">
  1015. SELECT
  1016. a.beh_dept_id AS id,
  1017. a.beh_dept_name AS NAME,
  1018. COUNT(*) AS num
  1019. FROM
  1020. med_behospital_info a,
  1021. sys_user_dept c,
  1022. med_medical_record d,
  1023. med_medical_record_content e
  1024. WHERE
  1025. a.is_deleted = 'N'
  1026. AND c.is_deleted = 'N'
  1027. AND d.is_deleted = 'N'
  1028. AND e.is_deleted = 'N'
  1029. AND a.hospital_id = c.hospital_id
  1030. AND a.hospital_id = d.hospital_id
  1031. AND a.hospital_id = e.hospital_id
  1032. AND a.behospital_code = d.behospital_code
  1033. AND a.beh_dept_id = c.dept_id
  1034. AND d.rec_id = e.rec_id
  1035. AND d.mode_id = '24'
  1036. <if test="isPlacefile != null and isPlacefile != ''">
  1037. and a.is_placefile = #{isPlacefile}
  1038. </if>
  1039. <![CDATA[AND a.qc_type_id <>0 ]]>
  1040. <if test="userId!=null">
  1041. AND c.user_id = #{userId}
  1042. </if>
  1043. <if test="hospitalId != null and hospitalId != ''">
  1044. AND a.hospital_id = #{hospitalId}
  1045. </if>
  1046. <if test="isPlacefile != null and isPlacefile == 0">
  1047. <if test="startDate != null and startDate != ''">
  1048. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1049. </if>
  1050. <if test="endDate != null and endDate != ''">
  1051. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1052. </if>
  1053. </if>
  1054. <if test="isPlacefile != null and isPlacefile == 1">
  1055. <if test="startDate != null and startDate != ''">
  1056. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1057. </if>
  1058. <if test="endDate != null and endDate != ''">
  1059. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1060. </if>
  1061. </if>
  1062. GROUP BY
  1063. a.beh_dept_id,
  1064. a.beh_dept_name
  1065. </select>
  1066. <!-- 手术人数统计-科室-首页 -->
  1067. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1068. resultType="com.diagbot.dto.NumDTO">
  1069. SELECT
  1070. a.beh_dept_id AS id,
  1071. a.beh_dept_name AS NAME,
  1072. COUNT( DISTINCT a.behospital_code ) AS num
  1073. FROM
  1074. med_behospital_info a,
  1075. sys_user_dept c,
  1076. med_medical_record d,
  1077. qc_mode e
  1078. WHERE
  1079. a.is_deleted = 'N'
  1080. AND c.is_deleted = 'N'
  1081. AND d.is_deleted = 'N'
  1082. AND e.is_deleted = 'N'
  1083. AND a.hospital_id = c.hospital_id
  1084. AND a.hospital_id = d.hospital_id
  1085. AND a.behospital_code = d.behospital_code
  1086. AND a.beh_dept_id = c.dept_id
  1087. AND d.mode_id = e.id
  1088. AND e.`name` = '手术记录'
  1089. <if test="isPlacefile != null and isPlacefile != ''">
  1090. and a.is_placefile = #{isPlacefile}
  1091. </if>
  1092. <![CDATA[AND a.qc_type_id <>0 ]]>
  1093. <if test="userId!=null">
  1094. AND c.user_id = #{userId}
  1095. </if>
  1096. <if test="hospitalId != null and hospitalId != ''">
  1097. AND a.hospital_id = #{hospitalId}
  1098. </if>
  1099. <if test="isPlacefile != null and isPlacefile == 0">
  1100. <if test="startDate != null and startDate != ''">
  1101. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1102. </if>
  1103. <if test="endDate != null and endDate != ''">
  1104. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1105. </if>
  1106. </if>
  1107. <if test="isPlacefile != null and isPlacefile == 1">
  1108. <if test="startDate != null and startDate != ''">
  1109. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1110. </if>
  1111. <if test="endDate != null and endDate != ''">
  1112. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1113. </if>
  1114. </if>
  1115. GROUP BY
  1116. a.beh_dept_id,
  1117. a.beh_dept_name
  1118. </select>
  1119. <!-- 各科室缺陷占比排行(分页) -->
  1120. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1121. SELECT t.*
  1122. FROM
  1123. (SELECT
  1124. t1.beh_dept_name AS NAME,
  1125. t1.num AS num,
  1126. t2.totle AS totleNum,
  1127. round( t1.num / t2.totle, 4 ) AS percent,
  1128. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1129. FROM
  1130. (
  1131. SELECT
  1132. a.beh_dept_id,
  1133. a.beh_dept_name,
  1134. count(*) AS num
  1135. FROM
  1136. med_behospital_info a,
  1137. med_qcresult_info c,
  1138. med_qcresult_detail d
  1139. WHERE
  1140. a.behospital_code = c.behospital_code
  1141. AND a.hospital_id = c.hospital_id
  1142. AND a.behospital_code = d.behospital_code
  1143. AND a.hospital_id = d.hospital_id
  1144. AND a.is_deleted = 'N'
  1145. AND c.is_deleted = 'N'
  1146. AND d.is_deleted = 'N'
  1147. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1148. and a.is_placefile = #{filterPageVO.isPlacefile}
  1149. </if>
  1150. <![CDATA[AND a.qc_type_id <>0 ]]>
  1151. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1152. AND a.hospital_id = #{filterPageVO.hospitalId}
  1153. </if>
  1154. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1155. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1156. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1157. </if>
  1158. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1159. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1160. </if>
  1161. </if>
  1162. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1163. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1164. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1165. </if>
  1166. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1167. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1168. </if>
  1169. </if>
  1170. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1171. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1172. </if>
  1173. GROUP BY
  1174. a.beh_dept_id,
  1175. a.beh_dept_name
  1176. ORDER BY
  1177. count(*) DESC
  1178. ) t1,
  1179. (
  1180. SELECT
  1181. count(*) AS totle
  1182. FROM
  1183. med_behospital_info a,
  1184. med_qcresult_info c,
  1185. med_qcresult_detail d
  1186. WHERE
  1187. a.behospital_code = c.behospital_code
  1188. AND a.hospital_id = c.hospital_id
  1189. AND a.behospital_code = d.behospital_code
  1190. AND a.hospital_id = d.hospital_id
  1191. AND a.is_deleted = 'N'
  1192. AND c.is_deleted = 'N'
  1193. AND d.is_deleted = 'N'
  1194. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1195. and a.is_placefile = #{filterPageVO.isPlacefile}
  1196. </if>
  1197. <![CDATA[AND a.qc_type_id <>0 ]]>
  1198. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1199. AND a.hospital_id = #{filterPageVO.hospitalId}
  1200. </if>
  1201. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1202. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1203. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1204. </if>
  1205. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1206. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1207. </if>
  1208. </if>
  1209. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1210. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1211. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1212. </if>
  1213. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1214. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1215. </if>
  1216. </if>
  1217. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1218. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1219. </if>
  1220. ) t2
  1221. )t
  1222. </select>
  1223. <!-- 科室缺陷占比(主任医生) -->
  1224. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  1225. SELECT
  1226. t.*
  1227. FROM
  1228. (
  1229. SELECT
  1230. t1.NAME,
  1231. t1.num AS num,
  1232. t2.totle AS totleNum,
  1233. round( t1.num / t2.totle, 4 ) AS percent,
  1234. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1235. FROM
  1236. (
  1237. SELECT
  1238. d.msg as name,
  1239. count(*) AS num
  1240. FROM
  1241. med_behospital_info a,
  1242. med_qcresult_info c,
  1243. med_qcresult_detail d,
  1244. sys_user_dept e
  1245. WHERE
  1246. a.behospital_code = c.behospital_code
  1247. AND a.hospital_id = c.hospital_id
  1248. AND a.behospital_code = d.behospital_code
  1249. AND a.hospital_id = d.hospital_id
  1250. AND a.is_deleted = 'N'
  1251. AND c.is_deleted = 'N'
  1252. AND d.is_deleted = 'N'
  1253. AND e.is_deleted = 'N'
  1254. AND a.beh_dept_id = e.dept_id
  1255. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1256. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1257. </if>
  1258. <![CDATA[AND a.qc_type_id <>0 ]]>
  1259. <if test="filterPageByDeptVO.userId!=null">
  1260. AND e.user_id = #{filterPageByDeptVO.userId}
  1261. </if>
  1262. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1263. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1264. </if>
  1265. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1266. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1267. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1268. </if>
  1269. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1270. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1271. </if>
  1272. </if>
  1273. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1274. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1275. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1276. </if>
  1277. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1278. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1279. </if>
  1280. </if>
  1281. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1282. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1283. </if>
  1284. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1285. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1286. </if>
  1287. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1288. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1289. </if>
  1290. GROUP BY
  1291. d.msg
  1292. ORDER BY
  1293. count(*) DESC
  1294. ) t1,
  1295. (
  1296. SELECT
  1297. count(*) AS totle
  1298. FROM
  1299. med_behospital_info a,
  1300. med_qcresult_info c,
  1301. med_qcresult_detail d,
  1302. sys_user_dept e
  1303. WHERE
  1304. a.behospital_code = c.behospital_code
  1305. AND a.hospital_id = c.hospital_id
  1306. AND a.behospital_code = d.behospital_code
  1307. AND a.hospital_id = d.hospital_id
  1308. AND a.is_deleted = 'N'
  1309. AND c.is_deleted = 'N'
  1310. AND d.is_deleted = 'N'
  1311. AND e.is_deleted = 'N'
  1312. AND a.beh_dept_id = e.dept_id
  1313. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1314. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1315. </if>
  1316. <![CDATA[AND a.qc_type_id <>0 ]]>
  1317. <if test="filterPageByDeptVO.userId!=null">
  1318. AND e.user_id = #{filterPageByDeptVO.userId}
  1319. </if>
  1320. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1321. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1322. </if>
  1323. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1324. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1325. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1326. </if>
  1327. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1328. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1329. </if>
  1330. </if>
  1331. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1332. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1333. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1334. </if>
  1335. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1336. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1337. </if>
  1338. </if>
  1339. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1340. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1341. </if>
  1342. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1343. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1344. </if>
  1345. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1346. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1347. </if>
  1348. ) t2
  1349. )t
  1350. </select>
  1351. <!-- 各科室缺陷占比(组合)-全院 -->
  1352. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  1353. resultType="com.diagbot.dto.LevelStatisticsDTO">
  1354. SELECT
  1355. m1.deptId,
  1356. m1.deptName,
  1357. m1.entryNum,
  1358. m2.sameNum,
  1359. m1.mrNum,
  1360. m2.sameMrNum,
  1361. m1.totleValue,
  1362. m2.sameTotleValue,
  1363. m1.averageValue,
  1364. m2.sameAvgValue,
  1365. m1.firstLevelNum,
  1366. m2.sameFirstLevelNum,
  1367. m1.secondLevelNum,
  1368. m2.sameSecondLevelNum,
  1369. m1.thirdLevelNum,
  1370. m2.sameThirdLevelNum,
  1371. m1.firstLevelPercent,
  1372. m2.sameFirstLevelPercent,
  1373. m1.secondLevelPercent,
  1374. m2.sameSecondLevelPercent,
  1375. m1.thirdLevelPercent,
  1376. m2.sameThirdLevelPercent,
  1377. m1.firstLevelPercentStr,
  1378. m2.sameFirstLevelPercentStr,
  1379. m1.secondLevelPercentStr,
  1380. m2.sameSecondLevelPercentStr,
  1381. m1.thirdLevelPercentStr,
  1382. m2.sameThirdLevelPercentStr
  1383. FROM
  1384. (
  1385. SELECT
  1386. t1.deptId,
  1387. t1.deptName,
  1388. t2.entryNum,
  1389. t1.mrNum,
  1390. t1.totleValue,
  1391. t1.averageValue,
  1392. t1.firstLevelNum,
  1393. t1.secondLevelNum,
  1394. t1.thirdLevelNum,
  1395. t1.firstLevelPercent,
  1396. t1.secondLevelPercent,
  1397. t1.thirdLevelPercent,
  1398. t1.firstLevelPercentStr,
  1399. t1.secondLevelPercentStr,
  1400. t1.thirdLevelPercentStr
  1401. FROM
  1402. (
  1403. SELECT
  1404. a.beh_dept_id AS deptId,
  1405. a.beh_dept_name AS deptName,
  1406. count(*) AS mrNum,
  1407. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1408. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1409. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1410. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1411. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1412. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1413. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1414. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1415. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1416. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1417. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1418. FROM
  1419. med_behospital_info a,
  1420. med_qcresult_info c
  1421. WHERE
  1422. a.is_deleted = 'N'
  1423. AND c.is_deleted = 'N'
  1424. AND a.hospital_id = c.hospital_id
  1425. AND a.behospital_code = c.behospital_code
  1426. <if test="isPlacefile != null and isPlacefile != ''">
  1427. and a.is_placefile = #{isPlacefile}
  1428. </if>
  1429. AND a.qc_type_id != 0
  1430. <if test="hospitalId != null and hospitalId != ''">
  1431. AND a.hospital_id = #{hospitalId}
  1432. </if>
  1433. <if test="isPlacefile != null and isPlacefile == 0">
  1434. <if test="startDate != null and startDate != ''">
  1435. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1436. </if>
  1437. <if test="endDate != null and endDate != ''">
  1438. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1439. </if>
  1440. </if>
  1441. <if test="isPlacefile != null and isPlacefile == 1">
  1442. <if test="startDate != null and startDate != ''">
  1443. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1444. </if>
  1445. <if test="endDate != null and endDate != ''">
  1446. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1447. </if>
  1448. </if>
  1449. <if test="level != null and level != ''">
  1450. and c.level = #{level}
  1451. </if>
  1452. <if test="deptName != null and deptName != ''">
  1453. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1454. </if>
  1455. GROUP BY
  1456. a.beh_dept_id,
  1457. a.beh_dept_name
  1458. ) t1,
  1459. (
  1460. SELECT
  1461. a.beh_dept_id AS deptId,
  1462. a.beh_dept_name AS deptName,
  1463. count( * ) AS entryNum
  1464. FROM
  1465. med_behospital_info a,
  1466. med_qcresult_info c,
  1467. med_qcresult_detail d,
  1468. qc_cases_entry e
  1469. WHERE
  1470. a.is_deleted = 'N'
  1471. AND c.is_deleted = 'N'
  1472. AND d.is_deleted = 'N'
  1473. AND e.is_deleted = 'N'
  1474. AND a.hospital_id = c.hospital_id
  1475. AND a.hospital_id = d.hospital_id
  1476. AND a.behospital_code = c.behospital_code
  1477. AND a.behospital_code = d.behospital_code
  1478. AND d.cases_id = e.cases_id
  1479. AND d.cases_entry_id = e.id
  1480. <if test="isPlacefile != null and isPlacefile != ''">
  1481. and a.is_placefile = #{isPlacefile}
  1482. </if>
  1483. AND a.qc_type_id != 0
  1484. <if test="hospitalId != null and hospitalId != ''">
  1485. AND a.hospital_id = #{hospitalId}
  1486. </if>
  1487. <if test="isPlacefile != null and isPlacefile == 0">
  1488. <if test="startDate != null and startDate != ''">
  1489. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1490. </if>
  1491. <if test="endDate != null and endDate != ''">
  1492. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1493. </if>
  1494. </if>
  1495. <if test="isPlacefile != null and isPlacefile == 1">
  1496. <if test="startDate != null and startDate != ''">
  1497. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1498. </if>
  1499. <if test="endDate != null and endDate != ''">
  1500. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1501. </if>
  1502. </if>
  1503. <if test="level != null and level != ''">
  1504. and c.level = #{level}
  1505. </if>
  1506. <if test="deptName != null and deptName != ''">
  1507. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1508. </if>
  1509. GROUP BY
  1510. a.beh_dept_id,
  1511. a.beh_dept_name
  1512. ) t2
  1513. WHERE
  1514. t1.deptId = t2.deptId
  1515. AND t1.deptName = t2.deptName)m1 left join
  1516. ( SELECT
  1517. t1.deptId,
  1518. t1.deptName,
  1519. t2.entryNum as sameNum,
  1520. t1.mrNum as sameMrNum,
  1521. t1.totleValue as sameTotleValue,
  1522. t1.averageValue as sameAvgValue,
  1523. t1.firstLevelNum as sameFirstLevelNum,
  1524. t1.secondLevelNum as sameSecondLevelNum,
  1525. t1.thirdLevelNum as sameThirdLevelNum,
  1526. t1.firstLevelPercent as sameFirstLevelPercent,
  1527. t1.secondLevelPercent as sameSecondLevelPercent,
  1528. t1.thirdLevelPercent as sameThirdLevelPercent,
  1529. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  1530. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  1531. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  1532. FROM
  1533. (
  1534. SELECT
  1535. a.beh_dept_id AS deptId,
  1536. a.beh_dept_name AS deptName,
  1537. count(*) AS mrNum,
  1538. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1539. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1540. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1541. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1542. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1543. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1544. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1545. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1546. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1547. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1548. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1549. FROM
  1550. med_behospital_info a,
  1551. med_qcresult_info c
  1552. WHERE
  1553. a.is_deleted = 'N'
  1554. AND c.is_deleted = 'N'
  1555. AND a.hospital_id = c.hospital_id
  1556. AND a.behospital_code = c.behospital_code
  1557. <if test="isPlacefile != null and isPlacefile != ''">
  1558. and a.is_placefile = #{isPlacefile}
  1559. </if>
  1560. AND a.qc_type_id != 0
  1561. <if test="hospitalId != null and hospitalId != ''">
  1562. AND a.hospital_id = #{hospitalId}
  1563. </if>
  1564. <if test="isPlacefile != null and isPlacefile == 0">
  1565. <if test="lastStartDate != null and lastStartDate != ''">
  1566. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  1567. </if>
  1568. <if test="lastEndDate != null and lastEndDate != ''">
  1569. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  1570. </if>
  1571. </if>
  1572. <if test="isPlacefile != null and isPlacefile == 1">
  1573. <if test="lastStartDate != null and lastStartDate != ''">
  1574. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  1575. </if>
  1576. <if test="lastEndDate != null and lastEndDate != ''">
  1577. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  1578. </if>
  1579. </if>
  1580. <if test="level != null and level != ''">
  1581. and c.level = #{level}
  1582. </if>
  1583. <if test="deptName != null and deptName != ''">
  1584. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1585. </if>
  1586. GROUP BY
  1587. a.beh_dept_id,
  1588. a.beh_dept_name
  1589. ) t1,
  1590. (
  1591. SELECT
  1592. a.beh_dept_id AS deptId,
  1593. a.beh_dept_name AS deptName,
  1594. count( * ) AS entryNum
  1595. FROM
  1596. med_behospital_info a,
  1597. med_qcresult_info c,
  1598. med_qcresult_detail d,
  1599. qc_cases_entry e
  1600. WHERE
  1601. a.is_deleted = 'N'
  1602. AND c.is_deleted = 'N'
  1603. AND d.is_deleted = 'N'
  1604. AND e.is_deleted = 'N'
  1605. AND a.hospital_id = c.hospital_id
  1606. AND a.hospital_id = d.hospital_id
  1607. AND a.behospital_code = c.behospital_code
  1608. AND a.behospital_code = d.behospital_code
  1609. AND d.cases_id = e.cases_id
  1610. AND d.cases_entry_id = e.id
  1611. <if test="isPlacefile != null and isPlacefile != ''">
  1612. and a.is_placefile = #{isPlacefile}
  1613. </if>
  1614. AND a.qc_type_id != 0
  1615. <if test="hospitalId != null and hospitalId != ''">
  1616. AND a.hospital_id = #{hospitalId}
  1617. </if>
  1618. <if test="isPlacefile != null and isPlacefile == 0">
  1619. <if test="lastStartDate != null and lastStartDate != ''">
  1620. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  1621. </if>
  1622. <if test="lastEndDate != null and lastEndDate != ''">
  1623. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  1624. </if>
  1625. </if>
  1626. <if test="isPlacefile != null and isPlacefile == 1">
  1627. <if test="lastStartDate != null and lastStartDate != ''">
  1628. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  1629. </if>
  1630. <if test="lastEndDate != null and lastEndDate != ''">
  1631. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  1632. </if>
  1633. </if>
  1634. <if test="level != null and level != ''">
  1635. and c.level = #{level}
  1636. </if>
  1637. <if test="deptName != null and deptName != ''">
  1638. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1639. </if>
  1640. GROUP BY
  1641. a.beh_dept_id,
  1642. a.beh_dept_name
  1643. ) t2
  1644. WHERE
  1645. t1.deptId = t2.deptId
  1646. AND t1.deptName = t2.deptName)m2
  1647. on
  1648. m1.deptId = m2.deptId
  1649. AND m1.deptName = m2.deptName
  1650. <if test="asc != null and asc !=''">
  1651. order by
  1652. <choose>
  1653. <when test='asc=="deptId"'>m1.deptId asc</when>
  1654. <when test='asc=="deptName"'>m1.deptName asc</when>
  1655. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  1656. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  1657. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  1658. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  1659. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  1660. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  1661. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  1662. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  1663. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  1664. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  1665. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  1666. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  1667. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  1668. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  1669. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  1670. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  1671. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  1672. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  1673. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  1674. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  1675. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  1676. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  1677. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  1678. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  1679. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  1680. <otherwise>deptName asc</otherwise>
  1681. </choose>
  1682. </if>
  1683. <if test="desc != null and desc!=''">
  1684. order by
  1685. <choose>
  1686. <when test='desc=="deptId"'>m1.deptId desc</when>
  1687. <when test='desc=="deptName"'>m1.deptName desc</when>
  1688. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  1689. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  1690. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  1691. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  1692. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  1693. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  1694. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  1695. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  1696. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  1697. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  1698. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  1699. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  1700. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  1701. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  1702. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  1703. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  1704. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  1705. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  1706. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  1707. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  1708. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  1709. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  1710. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  1711. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  1712. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  1713. <otherwise>deptName desc</otherwise>
  1714. </choose>
  1715. </if>
  1716. </select>
  1717. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  1718. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  1719. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1720. SELECT
  1721. t1.deptId,
  1722. t1.deptName,
  1723. t1.deptClassId,
  1724. t1.deptClass,
  1725. t2.entryNum,
  1726. t1.mrNum,
  1727. t1.totleValue,
  1728. t1.averageValue,
  1729. t1.firstLevelNum,
  1730. t1.secondLevelNum,
  1731. t1.thirdLevelNum,
  1732. t1.firstLevelPercent,
  1733. t1.secondLevelPercent,
  1734. t1.thirdLevelPercent,
  1735. t1.firstLevelPercentStr,
  1736. t1.secondLevelPercentStr,
  1737. t1.thirdLevelPercentStr
  1738. FROM
  1739. (
  1740. SELECT
  1741. a.beh_dept_id AS deptId,
  1742. a.beh_dept_name AS deptName,
  1743. e.dept_id AS deptClassId,
  1744. e.dept_name AS deptClass,
  1745. count( DISTINCT c.id ) AS mrNum,
  1746. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1747. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1748. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  1749. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  1750. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  1751. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  1752. ) AS firstLevelPercent,
  1753. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1754. ) AS secondLevelPercent,
  1755. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1756. ) AS thirdLevelPercent,
  1757. concat(
  1758. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  1759. 100, 2 ),
  1760. '%'
  1761. ) AS firstLevelPercentStr,
  1762. concat(
  1763. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  1764. 100, 2 ),
  1765. '%'
  1766. ) AS secondLevelPercentStr,
  1767. concat(
  1768. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  1769. 100, 2 ),
  1770. '%'
  1771. ) AS thirdLevelPercentStr
  1772. FROM
  1773. med_behospital_info a,
  1774. med_qcresult_info c,
  1775. bas_dept_info d,
  1776. bas_dept_info e
  1777. WHERE
  1778. a.is_deleted = 'N'
  1779. AND c.is_deleted = 'N'
  1780. AND d.is_deleted = 'N'
  1781. AND e.is_deleted = 'N'
  1782. AND a.hospital_id = c.hospital_id
  1783. AND a.hospital_id = d.hospital_id
  1784. AND a.hospital_id = e.hospital_id
  1785. AND a.behospital_code = c.behospital_code
  1786. AND a.beh_dept_id = d.dept_id
  1787. AND d.parent_dept_id = e.dept_id
  1788. <if test="isPlacefile != null and isPlacefile != ''">
  1789. and a.is_placefile = #{isPlacefile}
  1790. </if>
  1791. <![CDATA[AND a.qc_type_id <>0 ]]>
  1792. <if test="hospitalId != null and hospitalId != ''">
  1793. AND a.hospital_id = #{hospitalId}
  1794. </if>
  1795. <if test="isPlacefile != null and isPlacefile == 0">
  1796. <if test="startDate != null and startDate != ''">
  1797. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1798. </if>
  1799. <if test="endDate != null and endDate != ''">
  1800. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1801. </if>
  1802. </if>
  1803. <if test="isPlacefile != null and isPlacefile == 1">
  1804. <if test="startDate != null and startDate != ''">
  1805. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1806. </if>
  1807. <if test="endDate != null and endDate != ''">
  1808. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1809. </if>
  1810. </if>
  1811. <if test="level != null and level != ''">
  1812. and c.level = #{level}
  1813. </if>
  1814. <if test="deptName != null and deptName != ''">
  1815. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1816. </if>
  1817. <if test="deptClass != null and deptClass != ''">
  1818. and e.dept_name = #{deptClass}
  1819. </if>
  1820. GROUP BY
  1821. a.beh_dept_id,
  1822. a.beh_dept_name,
  1823. e.dept_id,
  1824. e.dept_name
  1825. ) t1,
  1826. (
  1827. SELECT
  1828. a.beh_dept_id AS deptId,
  1829. a.beh_dept_name AS deptName,
  1830. g.dept_id AS deptClassId,
  1831. g.dept_name AS deptClass,
  1832. count( * ) AS entryNum
  1833. FROM
  1834. med_behospital_info a,
  1835. med_qcresult_info c,
  1836. med_qcresult_detail d,
  1837. qc_cases_entry e,
  1838. bas_dept_info f,
  1839. bas_dept_info g
  1840. WHERE
  1841. a.is_deleted = 'N'
  1842. AND c.is_deleted = 'N'
  1843. AND d.is_deleted = 'N'
  1844. AND e.is_deleted = 'N'
  1845. AND f.is_deleted = 'N'
  1846. AND g.is_deleted = 'N'
  1847. AND a.hospital_id = c.hospital_id
  1848. AND a.hospital_id = d.hospital_id
  1849. AND a.hospital_id = f.hospital_id
  1850. AND a.hospital_id = g.hospital_id
  1851. AND a.behospital_code = c.behospital_code
  1852. AND a.behospital_code = d.behospital_code
  1853. AND d.cases_id = e.cases_id
  1854. AND d.cases_entry_id = e.id
  1855. AND a.beh_dept_id = f.dept_id
  1856. AND f.parent_dept_id = g.dept_id
  1857. <if test="isPlacefile != null and isPlacefile != ''">
  1858. and a.is_placefile = #{isPlacefile}
  1859. </if>
  1860. <![CDATA[AND a.qc_type_id <>0 ]]>
  1861. <if test="hospitalId != null and hospitalId != ''">
  1862. AND a.hospital_id = #{hospitalId}
  1863. </if>
  1864. <if test="isPlacefile != null and isPlacefile == 0">
  1865. <if test="startDate != null and startDate != ''">
  1866. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1867. </if>
  1868. <if test="endDate != null and endDate != ''">
  1869. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1870. </if>
  1871. </if>
  1872. <if test="isPlacefile != null and isPlacefile == 1">
  1873. <if test="startDate != null and startDate != ''">
  1874. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1875. </if>
  1876. <if test="endDate != null and endDate != ''">
  1877. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1878. </if>
  1879. </if>
  1880. <if test="level != null and level != ''">
  1881. and c.level = #{level}
  1882. </if>
  1883. <if test="deptName != null and deptName != ''">
  1884. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1885. </if>
  1886. <if test="deptClass != null and deptClass != ''">
  1887. and g.dept_name = #{deptClass}
  1888. </if>
  1889. GROUP BY
  1890. a.beh_dept_id,
  1891. a.beh_dept_name,
  1892. g.dept_id,
  1893. g.dept_name
  1894. ) t2
  1895. WHERE
  1896. t1.deptId = t2.deptId
  1897. AND t1.deptName = t2.deptName
  1898. AND t1.deptClassId = t2.deptClassId
  1899. AND t1.deptClass = t2.deptClass
  1900. <if test="asc != null and asc !=''">
  1901. order by
  1902. <choose>
  1903. <when test='asc=="deptId"'>deptId asc</when>
  1904. <when test='asc=="deptName"'>deptName asc</when>
  1905. <when test='asc=="deptClassId"'>deptClassId asc</when>
  1906. <when test='asc=="deptClass"'>deptClass asc</when>
  1907. <when test='asc=="entryNum"'>entryNum asc</when>
  1908. <when test='asc=="mrNum"'>mrNum asc</when>
  1909. <when test='asc=="totleValue"'>totleValue asc</when>
  1910. <when test='asc=="averageValue"'>averageValue asc</when>
  1911. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1912. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1913. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1914. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1915. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1916. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1917. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1918. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1919. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1920. <otherwise>deptName asc</otherwise>
  1921. </choose>
  1922. </if>
  1923. <if test="desc != null and desc!=''">
  1924. order by
  1925. <choose>
  1926. <when test='desc=="deptId"'>deptId desc</when>
  1927. <when test='desc=="deptName"'>deptName desc</when>
  1928. <when test='desc=="deptClassId"'>deptClassId desc</when>
  1929. <when test='desc=="deptClass"'>deptClass desc</when>
  1930. <when test='desc=="entryNum"'>entryNum desc</when>
  1931. <when test='desc=="mrNum"'>mrNum desc</when>
  1932. <when test='desc=="totleValue"'>totleValue desc</when>
  1933. <when test='desc=="averageValue"'>averageValue desc</when>
  1934. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1935. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1936. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1937. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1938. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1939. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1940. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1941. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1942. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1943. <otherwise>deptName desc</otherwise>
  1944. </choose>
  1945. </if>
  1946. </select>
  1947. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  1948. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1949. select
  1950. m1.deptId,
  1951. m1.deptName,
  1952. m1.deptClassId,
  1953. m1.deptClass,
  1954. m1.entryNum,
  1955. m2.sameNum,
  1956. m1.mrNum,
  1957. m2.sameMrNum,
  1958. m1.totleValue,
  1959. m2.sameTotleValue,
  1960. m1.averageValue,
  1961. m2.sameAvgValue,
  1962. m1.firstLevelNum,
  1963. m2.sameFirstLevelNum,
  1964. m1.secondLevelNum,
  1965. m2.sameSecondLevelNum,
  1966. m1.thirdLevelNum,
  1967. m2.sameThirdLevelNum,
  1968. m1.firstLevelPercent,
  1969. m2.sameFirstLevelPercent,
  1970. m1.secondLevelPercent,
  1971. m2.sameSecondLevelPercent,
  1972. m1.thirdLevelPercent,
  1973. m2.sameThirdLevelPercent,
  1974. m1.firstLevelPercentStr,
  1975. m2.sameFirstLevelPercentStr,
  1976. m1.secondLevelPercentStr,
  1977. m2.sameSecondLevelPercentStr,
  1978. m1.thirdLevelPercentStr,
  1979. m2.sameThirdLevelPercentStr
  1980. from (
  1981. SELECT
  1982. t1.deptId,
  1983. t1.deptName,
  1984. t1.deptClassId,
  1985. t1.deptClass,
  1986. t2.entryNum,
  1987. t1.mrNum,
  1988. t1.totleValue,
  1989. t1.averageValue,
  1990. t1.firstLevelNum,
  1991. t1.secondLevelNum,
  1992. t1.thirdLevelNum,
  1993. t1.firstLevelPercent,
  1994. t1.secondLevelPercent,
  1995. t1.thirdLevelPercent,
  1996. t1.firstLevelPercentStr,
  1997. t1.secondLevelPercentStr,
  1998. t1.thirdLevelPercentStr
  1999. FROM
  2000. (
  2001. SELECT
  2002. tt1.deptId,
  2003. tt1.deptName,
  2004. e.dept_id AS deptClassId,
  2005. e.dept_name AS deptClass,
  2006. count(*) AS mrNum,
  2007. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2008. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2009. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2010. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2011. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2012. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2013. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2014. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2015. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2016. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2017. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2018. FROM
  2019. (
  2020. SELECT
  2021. a.beh_dept_id AS deptId,
  2022. a.beh_dept_name AS deptName,
  2023. d.parent_dept_id AS parentDeptId,
  2024. a.hospital_id AS hospitalId,
  2025. a.behospital_code AS behospitalCode,
  2026. c.score_res AS score,
  2027. c.LEVEL
  2028. FROM
  2029. med_behospital_info a,
  2030. med_qcresult_info c,
  2031. bas_dept_info d
  2032. WHERE
  2033. a.is_deleted = 'N'
  2034. AND c.is_deleted = 'N'
  2035. AND d.is_deleted = 'N'
  2036. AND a.hospital_id = c.hospital_id
  2037. AND a.hospital_id = d.hospital_id
  2038. AND a.behospital_code = c.behospital_code
  2039. AND a.beh_dept_id = d.dept_id
  2040. <if test="isPlacefile != null and isPlacefile != ''">
  2041. and a.is_placefile = #{isPlacefile}
  2042. </if>
  2043. AND a.qc_type_id != 0
  2044. <if test="hospitalId != null and hospitalId != ''">
  2045. AND a.hospital_id = #{hospitalId}
  2046. </if>
  2047. <if test="isPlacefile != null and isPlacefile == 0">
  2048. <if test="startDate != null and startDate != ''">
  2049. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2050. </if>
  2051. <if test="endDate != null and endDate != ''">
  2052. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2053. </if>
  2054. </if>
  2055. <if test="isPlacefile != null and isPlacefile == 1">
  2056. <if test="startDate != null and startDate != ''">
  2057. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2058. </if>
  2059. <if test="endDate != null and endDate != ''">
  2060. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2061. </if>
  2062. </if>
  2063. <if test="level != null and level != ''">
  2064. and c.level = #{level}
  2065. </if>
  2066. <if test="deptName != null and deptName != ''">
  2067. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2068. </if>
  2069. ) tt1
  2070. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2071. AND e.is_deleted = 'N'
  2072. AND tt1.hospitalId = e.hospital_id
  2073. <if test="deptClass != null and deptClass != ''">
  2074. WHERE e.dept_name = #{deptClass}
  2075. </if>
  2076. GROUP BY
  2077. tt1.deptId,
  2078. tt1.deptName,
  2079. e.dept_id,
  2080. e.dept_name
  2081. ) t1,
  2082. (
  2083. SELECT
  2084. tt2.deptId,
  2085. tt2.deptName,
  2086. g.dept_id AS deptClassId,
  2087. g.dept_name AS deptClass,
  2088. count( * ) AS entryNum
  2089. FROM
  2090. (
  2091. SELECT
  2092. a.beh_dept_id AS deptId,
  2093. a.beh_dept_name AS deptName,
  2094. f.parent_dept_id AS parentDeptId,
  2095. a.hospital_id AS hospitalId,
  2096. a.behospital_code AS behospitalCode
  2097. FROM
  2098. med_behospital_info a,
  2099. med_qcresult_info c,
  2100. med_qcresult_detail d,
  2101. qc_cases_entry e,
  2102. bas_dept_info f
  2103. WHERE
  2104. a.is_deleted = 'N'
  2105. AND c.is_deleted = 'N'
  2106. AND d.is_deleted = 'N'
  2107. AND e.is_deleted = 'N'
  2108. AND f.is_deleted = 'N'
  2109. AND a.hospital_id = c.hospital_id
  2110. AND a.hospital_id = d.hospital_id
  2111. AND a.hospital_id = f.hospital_id
  2112. AND a.behospital_code = c.behospital_code
  2113. AND a.behospital_code = d.behospital_code
  2114. AND d.cases_id = e.cases_id
  2115. AND d.cases_entry_id = e.id
  2116. AND a.beh_dept_id = f.dept_id
  2117. <if test="isPlacefile != null and isPlacefile != ''">
  2118. and a.is_placefile = #{isPlacefile}
  2119. </if>
  2120. AND a.qc_type_id != 0
  2121. <if test="hospitalId != null and hospitalId != ''">
  2122. AND a.hospital_id = #{hospitalId}
  2123. </if>
  2124. <if test="isPlacefile != null and isPlacefile == 0">
  2125. <if test="startDate != null and startDate != ''">
  2126. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2127. </if>
  2128. <if test="endDate != null and endDate != ''">
  2129. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2130. </if>
  2131. </if>
  2132. <if test="isPlacefile != null and isPlacefile == 1">
  2133. <if test="startDate != null and startDate != ''">
  2134. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2135. </if>
  2136. <if test="endDate != null and endDate != ''">
  2137. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2138. </if>
  2139. </if>
  2140. <if test="level != null and level != ''">
  2141. and c.level = #{level}
  2142. </if>
  2143. <if test="deptName != null and deptName != ''">
  2144. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2145. </if>
  2146. ) tt2
  2147. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2148. AND g.is_deleted = 'N'
  2149. AND tt2.hospitalId = g.hospital_id
  2150. <if test="deptClass != null and deptClass != ''">
  2151. WHERE g.dept_name = #{deptClass}
  2152. </if>
  2153. GROUP BY
  2154. tt2.deptId,
  2155. tt2.deptName,
  2156. g.dept_id,
  2157. g.dept_name
  2158. ) t2
  2159. WHERE
  2160. t1.deptId = t2.deptId
  2161. AND t1.deptName = t2.deptName)m1 left join
  2162. ( SELECT
  2163. t1.deptId,
  2164. t1.deptName,
  2165. t1.deptClassId,
  2166. t1.deptClass,
  2167. t2.entryNum as sameNum,
  2168. t1.mrNum as sameMrNum,
  2169. t1.totleValue as sameTotleValue,
  2170. t1.averageValue as sameAvgValue,
  2171. t1.firstLevelNum as sameFirstLevelNum,
  2172. t1.secondLevelNum as sameSecondLevelNum,
  2173. t1.thirdLevelNum as sameThirdLevelNum,
  2174. t1.firstLevelPercent as sameFirstLevelPercent,
  2175. t1.secondLevelPercent as sameSecondLevelPercent,
  2176. t1.thirdLevelPercent as sameThirdLevelPercent,
  2177. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2178. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2179. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2180. FROM
  2181. (
  2182. SELECT
  2183. tt1.deptId,
  2184. tt1.deptName,
  2185. e.dept_id AS deptClassId,
  2186. e.dept_name AS deptClass,
  2187. count(*) AS mrNum,
  2188. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2189. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2190. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2191. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2192. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2193. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2194. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2195. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2196. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2197. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2198. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2199. FROM
  2200. (
  2201. SELECT
  2202. a.beh_dept_id AS deptId,
  2203. a.beh_dept_name AS deptName,
  2204. d.parent_dept_id AS parentDeptId,
  2205. a.hospital_id AS hospitalId,
  2206. a.behospital_code AS behospitalCode,
  2207. c.score_res AS score,
  2208. c.LEVEL
  2209. FROM
  2210. med_behospital_info a,
  2211. med_qcresult_info c,
  2212. bas_dept_info d
  2213. WHERE
  2214. a.is_deleted = 'N'
  2215. AND c.is_deleted = 'N'
  2216. AND d.is_deleted = 'N'
  2217. AND a.hospital_id = c.hospital_id
  2218. AND a.hospital_id = d.hospital_id
  2219. AND a.behospital_code = c.behospital_code
  2220. AND a.beh_dept_id = d.dept_id
  2221. <if test="isPlacefile != null and isPlacefile != ''">
  2222. and a.is_placefile = #{isPlacefile}
  2223. </if>
  2224. AND a.qc_type_id != 0
  2225. <if test="hospitalId != null and hospitalId != ''">
  2226. AND a.hospital_id = #{hospitalId}
  2227. </if>
  2228. <if test="isPlacefile != null and isPlacefile == 0">
  2229. <if test="lastStartDate != null and lastStartDate != ''">
  2230. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2231. </if>
  2232. <if test="lastEndDate != null and lastEndDate != ''">
  2233. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2234. </if>
  2235. </if>
  2236. <if test="isPlacefile != null and isPlacefile == 1">
  2237. <if test="lastStartDate != null and lastStartDate != ''">
  2238. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2239. </if>
  2240. <if test="lastEndDate != null and lastEndDate != ''">
  2241. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2242. </if>
  2243. </if>
  2244. <if test="level != null and level != ''">
  2245. and c.level = #{level}
  2246. </if>
  2247. <if test="deptName != null and deptName != ''">
  2248. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2249. </if>
  2250. ) tt1
  2251. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2252. AND e.is_deleted = 'N'
  2253. AND tt1.hospitalId = e.hospital_id
  2254. <if test="deptClass != null and deptClass != ''">
  2255. WHERE e.dept_name = #{deptClass}
  2256. </if>
  2257. GROUP BY
  2258. tt1.deptId,
  2259. tt1.deptName,
  2260. e.dept_id,
  2261. e.dept_name
  2262. ) t1,
  2263. (
  2264. SELECT
  2265. tt2.deptId,
  2266. tt2.deptName,
  2267. g.dept_id AS deptClassId,
  2268. g.dept_name AS deptClass,
  2269. count( * ) AS entryNum
  2270. FROM
  2271. (
  2272. SELECT
  2273. a.beh_dept_id AS deptId,
  2274. a.beh_dept_name AS deptName,
  2275. f.parent_dept_id AS parentDeptId,
  2276. a.hospital_id AS hospitalId,
  2277. a.behospital_code AS behospitalCode
  2278. FROM
  2279. med_behospital_info a,
  2280. med_qcresult_info c,
  2281. med_qcresult_detail d,
  2282. qc_cases_entry e,
  2283. bas_dept_info f
  2284. WHERE
  2285. a.is_deleted = 'N'
  2286. AND c.is_deleted = 'N'
  2287. AND d.is_deleted = 'N'
  2288. AND e.is_deleted = 'N'
  2289. AND f.is_deleted = 'N'
  2290. AND a.hospital_id = c.hospital_id
  2291. AND a.hospital_id = d.hospital_id
  2292. AND a.hospital_id = f.hospital_id
  2293. AND a.behospital_code = c.behospital_code
  2294. AND a.behospital_code = d.behospital_code
  2295. AND d.cases_id = e.cases_id
  2296. AND d.cases_entry_id = e.id
  2297. AND a.beh_dept_id = f.dept_id
  2298. <if test="isPlacefile != null and isPlacefile != ''">
  2299. and a.is_placefile = #{isPlacefile}
  2300. </if>
  2301. AND a.qc_type_id != 0
  2302. <if test="hospitalId != null and hospitalId != ''">
  2303. AND a.hospital_id = #{hospitalId}
  2304. </if>
  2305. <if test="isPlacefile != null and isPlacefile == 0">
  2306. <if test="lastStartDate != null and lastStartDate != ''">
  2307. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2308. </if>
  2309. <if test="lastEndDate != null and lastEndDate != ''">
  2310. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2311. </if>
  2312. </if>
  2313. <if test="isPlacefile != null and isPlacefile == 1">
  2314. <if test="lastStartDate != null and lastStartDate != ''">
  2315. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2316. </if>
  2317. <if test="lastEndDate != null and lastEndDate != ''">
  2318. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2319. </if>
  2320. </if>
  2321. <if test="level != null and level != ''">
  2322. and c.level = #{level}
  2323. </if>
  2324. <if test="deptName != null and deptName != ''">
  2325. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2326. </if>
  2327. ) tt2
  2328. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2329. AND g.is_deleted = 'N'
  2330. AND tt2.hospitalId = g.hospital_id
  2331. <if test="deptClass != null and deptClass != ''">
  2332. WHERE g.dept_name = #{deptClass}
  2333. </if>
  2334. GROUP BY
  2335. tt2.deptId,
  2336. tt2.deptName,
  2337. g.dept_id,
  2338. g.dept_name
  2339. ) t2
  2340. WHERE
  2341. t1.deptId = t2.deptId
  2342. AND t1.deptName = t2.deptName)m2
  2343. on
  2344. m1.deptId = m2.deptId
  2345. and m1.deptName = m2.deptName
  2346. <if test="asc != null and asc !=''">
  2347. order by
  2348. <choose>
  2349. <when test='asc=="deptId"'>m1.deptId asc</when>
  2350. <when test='asc=="deptName"'>m1.deptName asc</when>
  2351. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  2352. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  2353. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2354. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2355. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2356. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2357. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2358. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2359. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2360. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2361. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2362. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2363. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2364. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2365. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2366. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2367. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2368. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2369. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2370. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2371. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2372. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2373. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2374. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2375. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2376. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2377. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2378. <otherwise>deptName asc</otherwise>
  2379. </choose>
  2380. </if>
  2381. <if test="desc != null and desc!=''">
  2382. order by
  2383. <choose>
  2384. <when test='desc=="deptId"'>m1.deptId desc</when>
  2385. <when test='desc=="deptName"'>m1.deptName desc</when>
  2386. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  2387. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  2388. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2389. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2390. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2391. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2392. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2393. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2394. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2395. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2396. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2397. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2398. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2399. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2400. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2401. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2402. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2403. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2404. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2405. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2406. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2407. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2408. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2409. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2410. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2411. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2412. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2413. <otherwise>deptName desc</otherwise>
  2414. </choose>
  2415. </if>
  2416. </select>
  2417. <!-- 病案首页合格率占比 -全院-->
  2418. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2419. resultType="com.diagbot.dto.HomePageNumDTO">
  2420. SELECT
  2421. t1.deptId,
  2422. t1.deptName,
  2423. t2.entryNum,
  2424. t1.mrNum,
  2425. t1.totleValue,
  2426. t1.averageValue,
  2427. t1.firstLevelNum,
  2428. t1.secondLevelNum,
  2429. t1.firstLevelPercent,
  2430. t1.secondLevelPercent,
  2431. t1.firstLevelPercentStr,
  2432. t1.secondLevelPercentStr,
  2433. t3.emptyNum,
  2434. t3.errorNum,
  2435. t3.entryTotleNum,
  2436. t3.emptyPercent,
  2437. t3.errorPercent,
  2438. t3.emptyPercentStr,
  2439. t3.errorPercentStr
  2440. FROM
  2441. (
  2442. SELECT
  2443. a.beh_dept_id AS deptId,
  2444. a.beh_dept_name AS deptName,
  2445. count( * ) AS mrNum,
  2446. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2447. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2448. SUM( c.`level` = '合格' ) AS firstLevelNum,
  2449. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  2450. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  2451. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  2452. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  2453. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  2454. FROM
  2455. med_behospital_info a,
  2456. med_qcresult_cases c
  2457. WHERE
  2458. a.is_deleted = 'N'
  2459. AND c.is_deleted = 'N'
  2460. AND a.hospital_id = c.hospital_id
  2461. AND a.behospital_code = c.behospital_code
  2462. AND c.cases_id = 243
  2463. <if test="isPlacefile != null and isPlacefile != ''">
  2464. and a.is_placefile = #{isPlacefile}
  2465. </if>
  2466. AND a.qc_type_id != 0
  2467. <if test="hospitalId != null and hospitalId != ''">
  2468. AND a.hospital_id = #{hospitalId}
  2469. </if>
  2470. <if test="isPlacefile != null and isPlacefile == 0">
  2471. <if test="startDate != null and startDate != ''">
  2472. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2473. </if>
  2474. <if test="endDate != null and endDate != ''">
  2475. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2476. </if>
  2477. </if>
  2478. <if test="isPlacefile != null and isPlacefile == 1">
  2479. <if test="startDate != null and startDate != ''">
  2480. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2481. </if>
  2482. <if test="endDate != null and endDate != ''">
  2483. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2484. </if>
  2485. </if>
  2486. <if test="level != null and level != ''">
  2487. and c.level = #{level}
  2488. </if>
  2489. <if test="deptName != null and deptName != ''">
  2490. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2491. </if>
  2492. GROUP BY
  2493. a.beh_dept_id,
  2494. a.beh_dept_name
  2495. ) t1,
  2496. (
  2497. SELECT
  2498. a.beh_dept_id AS deptId,
  2499. a.beh_dept_name AS deptName,
  2500. count( * ) AS entryNum
  2501. FROM
  2502. med_behospital_info a,
  2503. med_qcresult_cases c,
  2504. med_qcresult_detail d,
  2505. qc_cases_entry e
  2506. WHERE
  2507. a.is_deleted = 'N'
  2508. AND c.is_deleted = 'N'
  2509. AND d.is_deleted = 'N'
  2510. AND e.is_deleted = 'N'
  2511. AND a.hospital_id = c.hospital_id
  2512. AND a.hospital_id = d.hospital_id
  2513. AND a.behospital_code = c.behospital_code
  2514. AND a.behospital_code = d.behospital_code
  2515. AND c.cases_id = d.cases_id
  2516. AND d.cases_id = e.cases_id
  2517. AND d.cases_entry_id = e.id
  2518. AND d.cases_id = 243
  2519. <if test="isPlacefile != null and isPlacefile != ''">
  2520. and a.is_placefile = #{isPlacefile}
  2521. </if>
  2522. AND a.qc_type_id != 0
  2523. <if test="hospitalId != null and hospitalId != ''">
  2524. AND a.hospital_id = #{hospitalId}
  2525. </if>
  2526. <if test="isPlacefile != null and isPlacefile == 0">
  2527. <if test="startDate != null and startDate != ''">
  2528. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2529. </if>
  2530. <if test="endDate != null and endDate != ''">
  2531. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2532. </if>
  2533. </if>
  2534. <if test="isPlacefile != null and isPlacefile == 1">
  2535. <if test="startDate != null and startDate != ''">
  2536. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2537. </if>
  2538. <if test="endDate != null and endDate != ''">
  2539. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2540. </if>
  2541. </if>
  2542. <if test="level != null and level != ''">
  2543. and c.level = #{level}
  2544. </if>
  2545. <if test="deptName != null and deptName != ''">
  2546. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2547. </if>
  2548. GROUP BY
  2549. a.beh_dept_id,
  2550. a.beh_dept_name
  2551. ) t2,(
  2552. SELECT
  2553. h1.deptId,
  2554. h1.deptName,
  2555. h1.emptyNum,
  2556. h1.errorNum,
  2557. h1.mrNum,
  2558. h2.entryNum,
  2559. h1.mrNum * h2.entryNum AS entryTotleNum,
  2560. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  2561. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  2562. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  2563. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  2564. FROM
  2565. (
  2566. SELECT
  2567. a.beh_dept_id AS deptId,
  2568. a.beh_dept_name AS deptName,
  2569. sum( d.rule_type = 1 ) AS emptyNum,
  2570. sum( d.rule_type = 2 ) AS errorNum,
  2571. count( DISTINCT a.behospital_code ) AS mrNum
  2572. FROM
  2573. med_behospital_info a,
  2574. med_qcresult_cases b,
  2575. med_qcresult_detail c,
  2576. qc_cases_entry d
  2577. WHERE
  2578. a.is_deleted = 'N'
  2579. AND b.is_deleted = 'N'
  2580. AND c.is_deleted = 'N'
  2581. AND d.is_deleted = 'N'
  2582. AND a.hospital_id = b.hospital_id
  2583. AND a.hospital_id = c.hospital_id
  2584. AND a.behospital_code = b.behospital_code
  2585. AND a.behospital_code = c.behospital_code
  2586. AND b.cases_id = c.cases_id
  2587. AND c.cases_id = d.cases_id
  2588. AND c.cases_entry_id = d.id
  2589. <if test="isPlacefile != null and isPlacefile != ''">
  2590. and a.is_placefile = #{isPlacefile}
  2591. </if>
  2592. AND d.cases_id = 243
  2593. AND a.qc_type_id != 0
  2594. <if test="hospitalId != null and hospitalId != ''">
  2595. AND a.hospital_id = #{hospitalId}
  2596. </if>
  2597. <if test="isPlacefile != null and isPlacefile == 0">
  2598. <if test="startDate != null and startDate != ''">
  2599. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2600. </if>
  2601. <if test="endDate != null and endDate != ''">
  2602. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2603. </if>
  2604. </if>
  2605. <if test="isPlacefile != null and isPlacefile == 1">
  2606. <if test="startDate != null and startDate != ''">
  2607. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2608. </if>
  2609. <if test="endDate != null and endDate != ''">
  2610. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2611. </if>
  2612. </if>
  2613. <if test="level != null and level != ''">
  2614. and b.level = #{level}
  2615. </if>
  2616. <if test="deptName != null and deptName != ''">
  2617. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2618. </if>
  2619. GROUP BY
  2620. a.beh_dept_id,
  2621. a.beh_dept_name
  2622. ) h1,(
  2623. SELECT
  2624. count(*) AS entryNum
  2625. FROM
  2626. qc_cases_entry
  2627. WHERE
  2628. is_deleted = 'N'
  2629. AND cases_id = 243
  2630. ) h2
  2631. ) t3
  2632. WHERE
  2633. t1.deptId = t2.deptId
  2634. AND t1.deptId = t3.deptId
  2635. AND t1.deptName = t2.deptName
  2636. AND t1.deptName = t3.deptName
  2637. <if test="asc != null and asc !=''">
  2638. order by
  2639. <choose>
  2640. <when test='asc=="deptId"'>deptId asc</when>
  2641. <when test='asc=="deptName"'>deptName asc</when>
  2642. <when test='asc=="entryNum"'>entryNum asc</when>
  2643. <when test='asc=="mrNum"'>mrNum asc</when>
  2644. <when test='asc=="totleValue"'>totleValue asc</when>
  2645. <when test='asc=="averageValue"'>averageValue asc</when>
  2646. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2647. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2648. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2649. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2650. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2651. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2652. <when test='asc=="emptyNum"'>emptyNum asc</when>
  2653. <when test='asc=="errorNum"'>errorNum asc</when>
  2654. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  2655. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  2656. <when test='asc=="errorPercent"'>errorPercent asc</when>
  2657. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  2658. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  2659. <otherwise>deptName asc</otherwise>
  2660. </choose>
  2661. </if>
  2662. <if test="desc != null and desc!=''">
  2663. order by
  2664. <choose>
  2665. <when test='desc=="deptId"'>deptId desc</when>
  2666. <when test='desc=="deptName"'>deptName desc</when>
  2667. <when test='desc=="entryNum"'>entryNum desc</when>
  2668. <when test='desc=="mrNum"'>mrNum desc</when>
  2669. <when test='desc=="totleValue"'>totleValue desc</when>
  2670. <when test='desc=="averageValue"'>averageValue desc</when>
  2671. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2672. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2673. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2674. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2675. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2676. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2677. <when test='desc=="emptyNum"'>emptyNum desc</when>
  2678. <when test='desc=="errorNum"'>errorNum desc</when>
  2679. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  2680. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  2681. <when test='desc=="errorPercent"'>errorPercent desc</when>
  2682. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  2683. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  2684. <otherwise>deptName desc</otherwise>
  2685. </choose>
  2686. </if>
  2687. </select>
  2688. <!-- 各科室缺陷占比-科室 -->
  2689. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  2690. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  2691. SELECT
  2692. m1.doctorId,
  2693. m1.doctorName,
  2694. m1.entryNum,
  2695. m2.sameNum,
  2696. m1.mrNum,
  2697. m2.sameMrNum,
  2698. m1.totleValue,
  2699. m2.sameTotleValue,
  2700. m1.averageValue,
  2701. m2.sameAvgValue,
  2702. m1.firstLevelNum,
  2703. m2.sameFirstLevelNum,
  2704. m1.secondLevelNum,
  2705. m2.sameSecondLevelNum,
  2706. m1.thirdLevelNum,
  2707. m2.sameThirdLevelNum,
  2708. m1.firstLevelPercent,
  2709. m2.sameFirstLevelPercent,
  2710. m1.secondLevelPercent,
  2711. m2.sameSecondLevelPercent,
  2712. m1.thirdLevelPercent,
  2713. m2.sameThirdLevelPercent,
  2714. m1.firstLevelPercentStr,
  2715. m2.sameFirstLevelPercentStr,
  2716. m1.secondLevelPercentStr,
  2717. m2.sameSecondLevelPercentStr,
  2718. m1.thirdLevelPercentStr,
  2719. m2.sameThirdLevelPercentStr
  2720. FROM
  2721. (
  2722. SELECT
  2723. t1.doctorId,
  2724. t1.doctorName,
  2725. t2.entryNum,
  2726. t1.mrNum,
  2727. t1.totleValue,
  2728. t1.averageValue,
  2729. t1.firstLevelNum,
  2730. t1.secondLevelNum,
  2731. t1.thirdLevelNum,
  2732. t1.firstLevelPercent,
  2733. t1.secondLevelPercent,
  2734. t1.thirdLevelPercent,
  2735. t1.firstLevelPercentStr,
  2736. t1.secondLevelPercentStr,
  2737. t1.thirdLevelPercentStr
  2738. FROM
  2739. (
  2740. SELECT
  2741. a.doctor_id AS doctorId,
  2742. a.doctor_name AS doctorName,
  2743. count(*) AS mrNum,
  2744. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2745. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2746. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2747. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2748. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2749. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2750. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2751. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2752. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2753. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2754. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2755. FROM
  2756. med_behospital_info a,
  2757. med_qcresult_info c,
  2758. sys_user_dept e
  2759. WHERE
  2760. a.is_deleted = 'N'
  2761. AND c.is_deleted = 'N'
  2762. AND e.is_deleted = 'N'
  2763. AND a.hospital_id = c.hospital_id
  2764. AND a.behospital_code = c.behospital_code
  2765. AND a.beh_dept_id = e.dept_id
  2766. <if test="isPlacefile != null and isPlacefile != ''">
  2767. and a.is_placefile = #{isPlacefile}
  2768. </if>
  2769. AND a.qc_type_id != 0
  2770. <if test="hospitalId != null and hospitalId != ''">
  2771. AND a.hospital_id = #{hospitalId}
  2772. </if>
  2773. <if test="isPlacefile != null and isPlacefile == 0">
  2774. <if test="startDate != null and startDate != ''">
  2775. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2776. </if>
  2777. <if test="endDate != null and endDate != ''">
  2778. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2779. </if>
  2780. </if>
  2781. <if test="isPlacefile != null and isPlacefile == 1">
  2782. <if test="startDate != null and startDate != ''">
  2783. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2784. </if>
  2785. <if test="endDate != null and endDate != ''">
  2786. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2787. </if>
  2788. </if>
  2789. <if test="level != null and level != ''">
  2790. and c.level = #{level}
  2791. </if>
  2792. <if test="doctorName != null and doctorName != ''">
  2793. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2794. </if>
  2795. <if test="userId!=null and userId !=''">
  2796. AND e.user_id = #{userId}
  2797. </if>
  2798. <if test="deptName != null and deptName != ''">
  2799. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2800. </if>
  2801. GROUP BY
  2802. a.doctor_id,
  2803. a.doctor_name
  2804. ) t1,
  2805. (
  2806. SELECT
  2807. a.doctor_id AS doctorId,
  2808. a.doctor_name AS doctorName,
  2809. count( * ) AS entryNum
  2810. FROM
  2811. med_behospital_info a,
  2812. med_qcresult_info c,
  2813. med_qcresult_detail d,
  2814. qc_cases_entry e,
  2815. sys_user_dept f
  2816. WHERE
  2817. a.is_deleted = 'N'
  2818. AND c.is_deleted = 'N'
  2819. AND d.is_deleted = 'N'
  2820. AND e.is_deleted = 'N'
  2821. AND f.is_deleted = 'N'
  2822. AND a.hospital_id = c.hospital_id
  2823. AND a.hospital_id = d.hospital_id
  2824. AND a.behospital_code = c.behospital_code
  2825. AND a.behospital_code = d.behospital_code
  2826. AND d.cases_id = e.cases_id
  2827. AND d.cases_entry_id = e.id
  2828. AND a.beh_dept_id = f.dept_id
  2829. <if test="isPlacefile != null and isPlacefile != ''">
  2830. and a.is_placefile = #{isPlacefile}
  2831. </if>
  2832. AND a.qc_type_id != 0
  2833. <if test="hospitalId != null and hospitalId != ''">
  2834. AND a.hospital_id = #{hospitalId}
  2835. </if>
  2836. <if test="isPlacefile != null and isPlacefile == 0">
  2837. <if test="startDate != null and startDate != ''">
  2838. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2839. </if>
  2840. <if test="endDate != null and endDate != ''">
  2841. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2842. </if>
  2843. </if>
  2844. <if test="isPlacefile != null and isPlacefile == 1">
  2845. <if test="startDate != null and startDate != ''">
  2846. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2847. </if>
  2848. <if test="endDate != null and endDate != ''">
  2849. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2850. </if>
  2851. </if>
  2852. <if test="level != null and level != ''">
  2853. and c.level = #{level}
  2854. </if>
  2855. <if test="doctorName != null and doctorName != ''">
  2856. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2857. </if>
  2858. <if test="userId!=null and userId !=''">
  2859. AND f.user_id = #{userId}
  2860. </if>
  2861. <if test="deptName != null and deptName != ''">
  2862. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2863. </if>
  2864. GROUP BY
  2865. a.doctor_id,
  2866. a.doctor_name
  2867. ) t2
  2868. WHERE
  2869. t1.doctorId = t2.doctorId
  2870. AND t1.doctorName = t2.doctorName
  2871. )m1 left join
  2872. ( SELECT
  2873. t1.doctorId,
  2874. t1.doctorName,
  2875. t2.entryNum as sameNum,
  2876. t1.mrNum as sameMrNum,
  2877. t1.totleValue as sameTotleValue,
  2878. t1.averageValue as sameAvgValue,
  2879. t1.firstLevelNum as sameFirstLevelNum,
  2880. t1.secondLevelNum as sameSecondLevelNum,
  2881. t1.thirdLevelNum as sameThirdLevelNum,
  2882. t1.firstLevelPercent as sameFirstLevelPercent,
  2883. t1.secondLevelPercent as sameSecondLevelPercent,
  2884. t1.thirdLevelPercent as sameThirdLevelPercent,
  2885. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2886. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2887. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2888. FROM
  2889. (
  2890. SELECT
  2891. a.doctor_id AS doctorId,
  2892. a.doctor_name AS doctorName,
  2893. count(*) AS mrNum,
  2894. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2895. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2896. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2897. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2898. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2899. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2900. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2901. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2902. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2903. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2904. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2905. FROM
  2906. med_behospital_info a,
  2907. med_qcresult_info c,
  2908. sys_user_dept e
  2909. WHERE
  2910. a.is_deleted = 'N'
  2911. AND c.is_deleted = 'N'
  2912. AND e.is_deleted = 'N'
  2913. AND a.hospital_id = c.hospital_id
  2914. AND a.behospital_code = c.behospital_code
  2915. AND a.beh_dept_id = e.dept_id
  2916. <if test="isPlacefile != null and isPlacefile != ''">
  2917. and a.is_placefile = #{isPlacefile}
  2918. </if>
  2919. AND a.qc_type_id != 0
  2920. <if test="hospitalId != null and hospitalId != ''">
  2921. AND a.hospital_id = #{hospitalId}
  2922. </if>
  2923. <if test="isPlacefile != null and isPlacefile == 0">
  2924. <if test="lastStartDate != null and lastStartDate != ''">
  2925. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2926. </if>
  2927. <if test="lastEndDate != null and lastEndDate != ''">
  2928. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2929. </if>
  2930. </if>
  2931. <if test="isPlacefile != null and isPlacefile == 1">
  2932. <if test="lastStartDate != null and lastStartDate != ''">
  2933. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2934. </if>
  2935. <if test="lastEndDate != null and lastEndDate != ''">
  2936. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2937. </if>
  2938. </if>
  2939. <if test="level != null and level != ''">
  2940. and c.level = #{level}
  2941. </if>
  2942. <if test="doctorName != null and doctorName != ''">
  2943. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2944. </if>
  2945. <if test="userId!=null and userId !=''">
  2946. AND e.user_id = #{userId}
  2947. </if>
  2948. <if test="deptName != null and deptName != ''">
  2949. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2950. </if>
  2951. GROUP BY
  2952. a.doctor_id,
  2953. a.doctor_name
  2954. ) t1,
  2955. (
  2956. SELECT
  2957. a.doctor_id AS doctorId,
  2958. a.doctor_name AS doctorName,
  2959. count( * ) AS entryNum
  2960. FROM
  2961. med_behospital_info a,
  2962. med_qcresult_info c,
  2963. med_qcresult_detail d,
  2964. qc_cases_entry e,
  2965. sys_user_dept f
  2966. WHERE
  2967. a.is_deleted = 'N'
  2968. AND c.is_deleted = 'N'
  2969. AND d.is_deleted = 'N'
  2970. AND e.is_deleted = 'N'
  2971. AND f.is_deleted = 'N'
  2972. AND a.hospital_id = c.hospital_id
  2973. AND a.hospital_id = d.hospital_id
  2974. AND a.behospital_code = c.behospital_code
  2975. AND a.behospital_code = d.behospital_code
  2976. AND d.cases_id = e.cases_id
  2977. AND d.cases_entry_id = e.id
  2978. AND a.beh_dept_id = f.dept_id
  2979. <if test="isPlacefile != null and isPlacefile != ''">
  2980. and a.is_placefile = #{isPlacefile}
  2981. </if>
  2982. AND a.qc_type_id != 0
  2983. <if test="hospitalId != null and hospitalId != ''">
  2984. AND a.hospital_id = #{hospitalId}
  2985. </if>
  2986. <if test="isPlacefile != null and isPlacefile == 0">
  2987. <if test="lastStartDate != null and lastStartDate != ''">
  2988. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2989. </if>
  2990. <if test="lastEndDate != null and lastEndDate != ''">
  2991. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2992. </if>
  2993. </if>
  2994. <if test="isPlacefile != null and isPlacefile == 1">
  2995. <if test="lastStartDate != null and lastStartDate != ''">
  2996. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2997. </if>
  2998. <if test="lastEndDate != null and lastEndDate != ''">
  2999. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3000. </if>
  3001. </if>
  3002. <if test="level != null and level != ''">
  3003. and c.level = #{level}
  3004. </if>
  3005. <if test="doctorName != null and doctorName != ''">
  3006. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3007. </if>
  3008. <if test="userId!=null and userId !=''">
  3009. AND f.user_id = #{userId}
  3010. </if>
  3011. <if test="deptName != null and deptName != ''">
  3012. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3013. </if>
  3014. GROUP BY
  3015. a.doctor_id,
  3016. a.doctor_name
  3017. ) t2
  3018. WHERE
  3019. t1.doctorId = t2.doctorId
  3020. AND t1.doctorName = t2.doctorName
  3021. )m2
  3022. on
  3023. m1.doctorId = m2.doctorId
  3024. AND m1.doctorName = m2.doctorName
  3025. <if test="asc != null and asc !=''">
  3026. order by
  3027. <choose>
  3028. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3029. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3030. <when test='asc=="name"'>m1.doctorName asc</when>
  3031. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3032. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3033. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3034. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3035. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3036. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3037. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3038. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3039. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3040. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3041. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3042. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3043. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3044. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3045. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3046. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3047. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3048. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3049. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3050. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3051. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3052. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3053. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3054. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3055. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3056. <otherwise>doctorName asc</otherwise>
  3057. </choose>
  3058. </if>
  3059. <if test="desc != null and desc!=''">
  3060. order by
  3061. <choose>
  3062. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3063. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3064. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3065. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3066. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3067. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3068. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3069. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3070. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3071. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3072. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3073. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3074. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3075. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3076. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3077. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3078. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3079. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3080. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3081. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3082. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3083. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3084. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3085. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3086. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3087. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3088. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3089. <otherwise>doctorName desc</otherwise>
  3090. </choose>
  3091. </if>
  3092. </select>
  3093. <!-- 病案首页合格率占比-科室 -->
  3094. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3095. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3096. SELECT
  3097. t1.doctorId,
  3098. t1.doctorName,
  3099. t2.entryNum,
  3100. t1.mrNum,
  3101. t1.totleValue,
  3102. t1.averageValue,
  3103. t1.firstLevelNum,
  3104. t1.secondLevelNum,
  3105. t1.firstLevelPercent,
  3106. t1.secondLevelPercent,
  3107. t1.firstLevelPercentStr,
  3108. t1.secondLevelPercentStr,
  3109. t3.emptyNum,
  3110. t3.errorNum,
  3111. t3.entryTotleNum,
  3112. t3.emptyPercent,
  3113. t3.errorPercent,
  3114. t3.emptyPercentStr,
  3115. t3.errorPercentStr
  3116. FROM
  3117. (
  3118. SELECT
  3119. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3120. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3121. count( * ) AS mrNum,
  3122. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3123. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3124. sum( c.`level` = '合格' ) AS firstLevelNum,
  3125. sum( c.`level` = '不合格' ) AS secondLevelNum,
  3126. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  3127. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3128. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3129. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3130. FROM
  3131. med_behospital_info a,
  3132. med_qcresult_cases c,
  3133. sys_user_dept f
  3134. WHERE
  3135. a.is_deleted = 'N'
  3136. AND c.is_deleted = 'N'
  3137. AND f.is_deleted = 'N'
  3138. AND a.hospital_id = c.hospital_id
  3139. AND a.behospital_code = c.behospital_code
  3140. AND a.beh_dept_id = f.dept_id
  3141. AND c.cases_id = 243
  3142. <if test="isPlacefile != null and isPlacefile != ''">
  3143. and a.is_placefile = #{isPlacefile}
  3144. </if>
  3145. <![CDATA[AND a.qc_type_id <>0 ]]>
  3146. <if test="hospitalId != null and hospitalId != ''">
  3147. AND a.hospital_id = #{hospitalId}
  3148. </if>
  3149. <if test="isPlacefile != null and isPlacefile == 0">
  3150. <if test="startDate != null and startDate != ''">
  3151. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3152. </if>
  3153. <if test="endDate != null and endDate != ''">
  3154. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3155. </if>
  3156. </if>
  3157. <if test="isPlacefile != null and isPlacefile == 1">
  3158. <if test="startDate != null and startDate != ''">
  3159. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3160. </if>
  3161. <if test="endDate != null and endDate != ''">
  3162. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3163. </if>
  3164. </if>
  3165. <if test="level != null and level != ''">
  3166. and c.level = #{level}
  3167. </if>
  3168. <if test="name != null and name != ''">
  3169. <if test="name == '未知'">
  3170. and (a.doctor_name is null or a.doctor_name='')
  3171. </if>
  3172. <if test="name != '未知'">
  3173. and a.doctor_name like CONCAT('%',#{name},'%')
  3174. </if>
  3175. </if>
  3176. <if test="userId!=null and userId !=''">
  3177. AND f.user_id = #{userId}
  3178. </if>
  3179. <if test="deptName!=null and deptName !=''">
  3180. AND a.beh_dept_name = #{deptName}
  3181. </if>
  3182. GROUP BY
  3183. a.doctor_id,
  3184. a.doctor_name
  3185. ) t1,
  3186. (
  3187. SELECT
  3188. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3189. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3190. count( * ) AS entryNum
  3191. FROM
  3192. med_behospital_info a,
  3193. med_qcresult_cases c,
  3194. med_qcresult_detail d,
  3195. qc_cases_entry e,
  3196. sys_user_dept f
  3197. WHERE
  3198. a.is_deleted = 'N'
  3199. AND c.is_deleted = 'N'
  3200. AND d.is_deleted = 'N'
  3201. AND e.is_deleted = 'N'
  3202. AND f.is_deleted = 'N'
  3203. AND a.hospital_id = c.hospital_id
  3204. AND a.hospital_id = d.hospital_id
  3205. AND a.behospital_code = c.behospital_code
  3206. AND a.behospital_code = d.behospital_code
  3207. AND a.beh_dept_id = f.dept_id
  3208. AND c.cases_id = d.cases_id
  3209. AND d.cases_id = e.cases_id
  3210. AND d.cases_entry_id = e.id
  3211. AND c.cases_id = 243
  3212. <if test="isPlacefile != null and isPlacefile != ''">
  3213. and a.is_placefile = #{isPlacefile}
  3214. </if>
  3215. <![CDATA[AND a.qc_type_id <>0 ]]>
  3216. <if test="hospitalId != null and hospitalId != ''">
  3217. AND a.hospital_id = #{hospitalId}
  3218. </if>
  3219. <if test="isPlacefile != null and isPlacefile == 0">
  3220. <if test="startDate != null and startDate != ''">
  3221. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3222. </if>
  3223. <if test="endDate != null and endDate != ''">
  3224. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3225. </if>
  3226. </if>
  3227. <if test="isPlacefile != null and isPlacefile == 1">
  3228. <if test="startDate != null and startDate != ''">
  3229. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3230. </if>
  3231. <if test="endDate != null and endDate != ''">
  3232. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3233. </if>
  3234. </if>
  3235. <if test="level != null and level != ''">
  3236. and c.level = #{level}
  3237. </if>
  3238. <if test="name != null and name != ''">
  3239. <if test="name == '未知'">
  3240. and (a.doctor_name is null or a.doctor_name='')
  3241. </if>
  3242. <if test="name != '未知'">
  3243. and a.doctor_name like CONCAT('%',#{name},'%')
  3244. </if>
  3245. </if>
  3246. <if test="userId!=null and userId !=''">
  3247. AND f.user_id = #{userId}
  3248. </if>
  3249. <if test="deptName!=null and deptName !=''">
  3250. AND a.beh_dept_name = #{deptName}
  3251. </if>
  3252. GROUP BY
  3253. a.doctor_id,
  3254. a.doctor_name
  3255. ) t2,(
  3256. SELECT
  3257. h1.doctorId,
  3258. h1.doctorName,
  3259. h1.emptyNum,
  3260. h1.errorNum,
  3261. h1.mrNum,
  3262. h2.entryNum,
  3263. h1.mrNum * h2.entryNum AS entryTotleNum,
  3264. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3265. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3266. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3267. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3268. FROM
  3269. (
  3270. SELECT
  3271. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3272. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3273. sum( d.rule_type = 1 ) AS emptyNum,
  3274. sum( d.rule_type = 2 ) AS errorNum,
  3275. count( DISTINCT a.behospital_code ) AS mrNum
  3276. FROM
  3277. med_behospital_info a,
  3278. med_qcresult_cases b,
  3279. med_qcresult_detail c,
  3280. qc_cases_entry d,
  3281. sys_user_dept e
  3282. WHERE
  3283. a.is_deleted = 'N'
  3284. AND b.is_deleted = 'N'
  3285. AND c.is_deleted = 'N'
  3286. AND d.is_deleted = 'N'
  3287. AND e.is_deleted = 'N'
  3288. AND a.hospital_id = b.hospital_id
  3289. AND a.hospital_id = c.hospital_id
  3290. AND a.hospital_id = e.hospital_id
  3291. AND a.behospital_code = b.behospital_code
  3292. AND a.behospital_code = c.behospital_code
  3293. AND b.cases_id = c.cases_id
  3294. AND c.cases_id = d.cases_id
  3295. AND c.cases_entry_id = d.id
  3296. AND a.beh_dept_id = e.dept_id
  3297. <if test="isPlacefile != null and isPlacefile != ''">
  3298. and a.is_placefile = #{isPlacefile}
  3299. </if>
  3300. AND d.cases_id = 243
  3301. <![CDATA[AND a.qc_type_id <>0 ]]>
  3302. <if test="hospitalId != null and hospitalId != ''">
  3303. AND a.hospital_id = #{hospitalId}
  3304. </if>
  3305. <if test="isPlacefile != null and isPlacefile == 0">
  3306. <if test="startDate != null and startDate != ''">
  3307. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3308. </if>
  3309. <if test="endDate != null and endDate != ''">
  3310. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3311. </if>
  3312. </if>
  3313. <if test="isPlacefile != null and isPlacefile == 1">
  3314. <if test="startDate != null and startDate != ''">
  3315. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3316. </if>
  3317. <if test="endDate != null and endDate != ''">
  3318. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3319. </if>
  3320. </if>
  3321. <if test="level != null and level != ''">
  3322. and b.level = #{level}
  3323. </if>
  3324. <if test="name != null and name != ''">
  3325. <if test="name == '未知'">
  3326. and (a.doctor_name is null or a.doctor_name='')
  3327. </if>
  3328. <if test="name != '未知'">
  3329. and a.doctor_name like CONCAT('%',#{name},'%')
  3330. </if>
  3331. </if>
  3332. <if test="userId!=null and userId !=''">
  3333. AND e.user_id = #{userId}
  3334. </if>
  3335. <if test="deptName!=null and deptName !=''">
  3336. AND a.beh_dept_name = #{deptName}
  3337. </if>
  3338. GROUP BY
  3339. a.doctor_id,
  3340. a.doctor_name
  3341. ) h1,(
  3342. SELECT
  3343. count(*) AS entryNum
  3344. FROM
  3345. qc_cases_entry
  3346. WHERE
  3347. is_deleted = 'N'
  3348. AND cases_id = 243
  3349. ) h2
  3350. ) t3
  3351. WHERE
  3352. t1.doctorId = t2.doctorId
  3353. AND t1.doctorId = t3.doctorId
  3354. AND t1.doctorName = t2.doctorName
  3355. AND t1.doctorName = t3.doctorName
  3356. <if test="asc != null and asc !=''">
  3357. order by
  3358. <choose>
  3359. <when test='asc=="doctorId"'>doctorId asc</when>
  3360. <when test='asc=="doctorName"'>doctorName asc</when>
  3361. <when test='asc=="entryNum"'>entryNum asc</when>
  3362. <when test='asc=="mrNum"'>mrNum asc</when>
  3363. <when test='asc=="totleValue"'>totleValue asc</when>
  3364. <when test='asc=="averageValue"'>averageValue asc</when>
  3365. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3366. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3367. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3368. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3369. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3370. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3371. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3372. <when test='asc=="errorNum"'>errorNum asc</when>
  3373. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3374. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3375. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3376. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3377. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3378. <otherwise>doctorName asc</otherwise>
  3379. </choose>
  3380. </if>
  3381. <if test="desc != null and desc!=''">
  3382. order by
  3383. <choose>
  3384. <when test='desc=="doctorId"'>doctorId desc</when>
  3385. <when test='desc=="doctorName"'>doctorName desc</when>
  3386. <when test='desc=="entryNum"'>entryNum desc</when>
  3387. <when test='desc=="mrNum"'>mrNum desc</when>
  3388. <when test='desc=="totleValue"'>totleValue desc</when>
  3389. <when test='desc=="averageValue"'>averageValue desc</when>
  3390. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3391. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3392. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3393. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3394. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3395. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3396. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3397. <when test='desc=="errorNum"'>errorNum desc</when>
  3398. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3399. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3400. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3401. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3402. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3403. <otherwise>doctorName desc</otherwise>
  3404. </choose>
  3405. </if>
  3406. </select>
  3407. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  3408. <result column="behDeptName" property="behDeptName"/>
  3409. <result column="doctorName" property="doctorName"/>
  3410. <result column="avgScore" property="avgScore"/>
  3411. <collection property="excelBehospitalDTOS"
  3412. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  3413. <result column="patName" property="patName"/>
  3414. <result column="behospitalCode" property="behospitalCode"/>
  3415. <result column="behospitalDate" property="behospitalDate"/>
  3416. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  3417. <result column="score" property="score"/>
  3418. <result column="scoreBn" property="scoreBn"/>
  3419. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  3420. <result column="caseName" property="caseName"/>
  3421. <collection property="exportExcelMsgDTOS"
  3422. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  3423. <result column="msg" property="msg"/>
  3424. </collection>
  3425. </collection>
  3426. </collection>
  3427. </resultMap>
  3428. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  3429. <result column="behDeptName" property="behDeptName"/>
  3430. <result column="avgScore" property="avgScore"/>
  3431. <collection property="excelBehospitalDTOS"
  3432. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  3433. <result column="behDoctorName" property="behDoctorName"/>
  3434. <result column="patName" property="patName"/>
  3435. <result column="behospitalCode" property="behospitalCode"/>
  3436. <result column="behospitalDate" property="behospitalDate"/>
  3437. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  3438. <result column="score" property="score"/>
  3439. <result column="scoreBn" property="scoreBn"/>
  3440. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  3441. <result column="caseName" property="caseName"/>
  3442. <collection property="exportExcelMsgDTOS"
  3443. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  3444. <result column="msg" property="msg"/>
  3445. </collection>
  3446. </collection>
  3447. </collection>
  3448. </resultMap>
  3449. <select id="exportExcel" resultMap="ExportExcelMap">
  3450. SELECT DISTINCT
  3451. t1.beh_dept_name AS behDeptName,
  3452. t1.beh_doctor_name AS behDoctorName,
  3453. t1.`name` AS patName,
  3454. t1.behospital_code AS behospitalCode,
  3455. t1.behospital_date AS behospitalDate,
  3456. t1.leave_hospital_date AS leaveHospitalDate,
  3457. t2.score_res AS score,
  3458. "1" AS avgScore,
  3459. t4.`name` AS caseName,
  3460. t3.msg AS msg
  3461. FROM
  3462. med_behospital_info t1,
  3463. med_qcresult_info t2,
  3464. med_qcresult_detail t3,
  3465. qc_cases t4
  3466. WHERE
  3467. t1.is_deleted = 'N'
  3468. AND t2.is_deleted = 'N'
  3469. AND t3.is_deleted = 'N'
  3470. AND t4.is_deleted = 'N'
  3471. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  3472. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  3473. AND t1.hospital_id = t2.hospital_id
  3474. AND t1.behospital_code = t2.behospital_code
  3475. AND t1.hospital_id = t3.hospital_id
  3476. AND t1.behospital_code = t3.behospital_code
  3477. AND t3.cases_id = t4.id
  3478. ORDER BY
  3479. t1.beh_dept_id ASC,
  3480. t1.leave_hospital_date DESC,
  3481. t1.behospital_code ASC,
  3482. t4.`name` ASC
  3483. </select>
  3484. <!-- 质控评分导出到excel-->
  3485. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  3486. SELECT * FROM (
  3487. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  3488. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  3489. g.check_type AS ch_type,
  3490. h.check_type AS mr_type,
  3491. g.check_name AS ch_name,
  3492. h.check_name AS mr_name,
  3493. g.check_time AS ch_time,
  3494. h.check_time AS mr_time
  3495. FROM (
  3496. SELECT
  3497. t1.behDeptId,
  3498. t1.behDeptName,
  3499. t1.behDoctorName,
  3500. t1.patName,
  3501. t1.behospitalCode,
  3502. t1.hospitalId,
  3503. t1.behospitalDate,
  3504. t1.leaveHospitalDate,
  3505. t1.score,
  3506. <if test="radioCheck !=null and radioCheck == 1">
  3507. t1.msg,
  3508. t1.caseName,
  3509. </if>
  3510. t1.scoreBn,
  3511. t2.avgScore
  3512. FROM
  3513. (
  3514. SELECT
  3515. CONCAT(
  3516. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  3517. a.doctor_name
  3518. ) AS behDoctorName,
  3519. a.`name` AS patName,
  3520. a.behospital_code AS behospitalCode,
  3521. a.behospital_date AS behospitalDate,
  3522. a.leave_hospital_date AS leaveHospitalDate,
  3523. b.score_res AS score,
  3524. e.score_res as scoreBn,
  3525. <if test="radioCheck !=null and radioCheck == 1">
  3526. c.msg AS msg,
  3527. d.NAME AS caseName,
  3528. </if>
  3529. a.beh_dept_id AS behDeptId,
  3530. a.beh_dept_name AS behDeptName,
  3531. a.hospital_id AS hospitalId
  3532. FROM
  3533. med_behospital_info a
  3534. RIGHT JOIN
  3535. med_qcresult_info b
  3536. ON a.hospital_id = b.hospital_id
  3537. AND a.is_deleted = 'N'
  3538. AND b.is_deleted = 'N'
  3539. AND a.behospital_code = b.behospital_code
  3540. <if test="radioCheck !=null and radioCheck == 1">
  3541. LEFT JOIN
  3542. med_qcresult_detail c
  3543. ON c.is_deleted = 'N'
  3544. AND b.behospital_code = c.behospital_code
  3545. AND b.hospital_id = c.hospital_id
  3546. LEFT JOIN
  3547. qc_cases d
  3548. on d.is_deleted = 'N'
  3549. AND c.cases_id = d.id
  3550. </if>
  3551. LEFT JOIN med_qcresult_cases e
  3552. on b.behospital_code = e.behospital_code
  3553. and b.hospital_id = e.hospital_id
  3554. AND e.is_deleted = 'N'
  3555. and e.cases_id = 243
  3556. WHERE
  3557. 1=1
  3558. <if test="isPlacefile != null and isPlacefile != ''">
  3559. and a.is_placefile = #{isPlacefile}
  3560. </if>
  3561. <![CDATA[AND a.qc_type_id <>0 ]]>
  3562. <if test="hospitalId != null and hospitalId != ''">
  3563. AND a.hospital_id = #{hospitalId}
  3564. </if>
  3565. <if test="diagnose != null and diagnose != ''">
  3566. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  3567. </if>
  3568. <if test="behosDateStart != null">
  3569. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  3570. </if>
  3571. <if test="behosDateEnd != null">
  3572. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  3573. </if>
  3574. <if test="leaveHosDateStart != null ">
  3575. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  3576. </if>
  3577. <if test="leaveHosDateEnd != null ">
  3578. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  3579. </if>
  3580. <if test="behospitalCode != null and behospitalCode != ''">
  3581. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  3582. </if>
  3583. <if test="level != null and level != ''">
  3584. AND b.level = #{level}
  3585. </if>
  3586. <if test="doctorName != null and doctorName != ''">
  3587. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  3588. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  3589. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  3590. </if>
  3591. <if test="doctorCode != null and doctorCode != ''">
  3592. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  3593. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  3594. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  3595. </if>
  3596. <if test="deptName != null and deptName != ''">
  3597. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3598. </if>
  3599. <if test="name != null and name != ''">
  3600. AND a.name like CONCAT('%',#{name},'%')
  3601. </if>
  3602. ) t1,
  3603. (
  3604. SELECT
  3605. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  3606. a.beh_dept_id AS behDeptId,
  3607. a.beh_dept_name AS behDeptName
  3608. FROM
  3609. med_behospital_info a,
  3610. med_qcresult_info b
  3611. WHERE
  3612. a.is_deleted = 'N'
  3613. AND b.is_deleted = 'N'
  3614. AND a.hospital_id = b.hospital_id
  3615. AND a.behospital_code = b.behospital_code
  3616. <if test="isPlacefile != null and isPlacefile != ''">
  3617. and a.is_placefile = #{isPlacefile}
  3618. </if>
  3619. <![CDATA[AND a.qc_type_id <>0 ]]>
  3620. <if test="hospitalId != null and hospitalId != ''">
  3621. AND a.hospital_id = #{hospitalId}
  3622. </if>
  3623. <if test="diagnose != null and diagnose != ''">
  3624. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  3625. </if>
  3626. <if test="behosDateStart != null">
  3627. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  3628. </if>
  3629. <if test="behosDateEnd != null">
  3630. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  3631. </if>
  3632. <if test="leaveHosDateStart != null ">
  3633. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  3634. </if>
  3635. <if test="leaveHosDateEnd != null ">
  3636. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  3637. </if>
  3638. <if test="behospitalCode != null and behospitalCode != ''">
  3639. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  3640. </if>
  3641. <if test="level != null and level != ''">
  3642. AND b.level = #{level}
  3643. </if>
  3644. <if test="doctorName != null and doctorName != ''">
  3645. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  3646. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  3647. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  3648. </if>
  3649. <if test="doctorCode != null and doctorCode != ''">
  3650. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  3651. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  3652. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  3653. </if>
  3654. <if test="deptName != null and deptName != ''">
  3655. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3656. </if>
  3657. <if test="name != null and name != ''">
  3658. AND a.name like CONCAT('%',#{name},'%')
  3659. </if>
  3660. GROUP BY
  3661. a.beh_dept_id,
  3662. a.beh_dept_name
  3663. ) t2
  3664. WHERE
  3665. t1.behDeptId = t2.behDeptId
  3666. AND t1.behDeptName = t2.behDeptName
  3667. ORDER BY
  3668. t1.behDeptName,
  3669. t1.behDoctorName,
  3670. t1.patName,
  3671. <if test="radioCheck !=null and radioCheck == 1">
  3672. t1.caseName,
  3673. </if>
  3674. t1.behospitalCode
  3675. )tp
  3676. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  3677. ON tp.behospitalCode = g.behospital_code
  3678. AND tp.hospitalId = g.hospital_id
  3679. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  3680. ON tp.behospitalCode = h.behospital_code
  3681. AND tp.hospitalId = h.hospital_id
  3682. ) tu
  3683. WHERE tu.behospitalCode IS NOT NULL
  3684. <if test="checkStatus != null ">
  3685. and tu.check_status = #{checkStatus}
  3686. </if>
  3687. <if test="mrStatus != null ">
  3688. AND tu.mr_status = #{mrStatus}
  3689. </if>
  3690. <if test="chName != null and chName !=''">
  3691. AND tu.ch_name like CONCAT('%',#{chName},'%')
  3692. </if>
  3693. <if test="mrName != null and mrName !=''">
  3694. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  3695. </if>
  3696. <if test="chTimeStart != null">
  3697. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  3698. </if>
  3699. <if test="chTimeEnd != null">
  3700. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  3701. </if>
  3702. <if test="mrTimeStart != null">
  3703. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  3704. </if>
  3705. <if test="mrTimeEnd != null">
  3706. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  3707. </if>
  3708. </select>
  3709. <!-- 科室质控评分导出到excel-->
  3710. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  3711. SELECT * FROM (
  3712. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  3713. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  3714. g.check_type AS ch_type,
  3715. h.check_type AS mr_type,
  3716. g.check_name AS ch_name,
  3717. h.check_name AS mr_name,
  3718. g.check_time AS ch_time,
  3719. h.check_time AS mr_time
  3720. FROM (
  3721. SELECT
  3722. t1.behDeptId,
  3723. t1.behDeptName,
  3724. t1.behDoctorName,
  3725. t1.patName,
  3726. t1.behospitalCode,
  3727. t1.hospitalId,
  3728. t1.behospitalDate,
  3729. t1.leaveHospitalDate,
  3730. t1.score,
  3731. t2.avgScore,
  3732. <if test="radioCheck !=null and radioCheck == 1">
  3733. t1.msg,
  3734. t1.caseName,
  3735. </if>
  3736. e.score_res as scoreBn
  3737. FROM
  3738. (
  3739. SELECT
  3740. a.doctor_name AS behDoctorName,
  3741. a.`name` AS patName,
  3742. a.behospital_code AS behospitalCode,
  3743. a.hospital_id AS hospital_id,
  3744. a.behospital_date AS behospitalDate,
  3745. a.leave_hospital_date AS leaveHospitalDate,
  3746. b.score_res AS score,
  3747. <if test="radioCheck !=null and radioCheck == 1">
  3748. c.msg AS msg,
  3749. d.NAME AS caseName,
  3750. </if>
  3751. a.beh_dept_id AS behDeptId,
  3752. a.beh_dept_name AS behDeptName,
  3753. a.hospital_id AS hospitalId
  3754. FROM
  3755. med_behospital_info a,
  3756. med_qcresult_info b,
  3757. med_qcresult_detail c,
  3758. qc_cases d,
  3759. sys_user_dept e
  3760. WHERE
  3761. a.is_deleted = 'N'
  3762. AND b.is_deleted = 'N'
  3763. AND c.is_deleted = 'N'
  3764. AND d.is_deleted = 'N'
  3765. AND e.is_deleted = 'N'
  3766. AND a.hospital_id = b.hospital_id
  3767. AND a.hospital_id = c.hospital_id
  3768. AND a.hospital_id = e.hospital_id
  3769. AND a.behospital_code = b.behospital_code
  3770. AND a.behospital_code = c.behospital_code
  3771. AND c.cases_id = d.id
  3772. AND a.beh_dept_id = e.dept_id
  3773. <if test="diagnose != null and diagnose != ''">
  3774. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  3775. </if>
  3776. <if test="isPlacefile != null and isPlacefile != ''">
  3777. and a.is_placefile = #{isPlacefile}
  3778. </if>
  3779. <![CDATA[AND a.qc_type_id <>0 ]]>
  3780. <if test="hospitalId != null and hospitalId != ''">
  3781. AND a.hospital_id = #{hospitalId}
  3782. </if>
  3783. <if test="userId != null ">
  3784. AND e.user_id = #{userId}
  3785. </if>
  3786. <if test="behosDateStart != null">
  3787. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  3788. </if>
  3789. <if test="behosDateEnd != null">
  3790. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  3791. </if>
  3792. <if test="leaveHosDateStart != null ">
  3793. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  3794. </if>
  3795. <if test="leaveHosDateEnd != null ">
  3796. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  3797. </if>
  3798. <if test="behospitalCode != null and behospitalCode != ''">
  3799. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  3800. </if>
  3801. <if test="level != null and level != ''">
  3802. AND b.level = #{level}
  3803. </if>
  3804. <if test="doctorName != null and doctorName != ''">
  3805. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  3806. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  3807. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  3808. </if>
  3809. <if test="doctorCode != null and doctorCode != ''">
  3810. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  3811. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  3812. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  3813. </if>
  3814. <if test="deptName != null and deptName != ''">
  3815. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3816. </if>
  3817. <if test="name != null and name != ''">
  3818. AND a.name like CONCAT('%',#{name},'%')
  3819. </if>
  3820. ) t1
  3821. LEFT JOIN med_qcresult_cases e
  3822. on t1.behospitalCode = e.behospital_code
  3823. and t1.hospital_id = e.hospital_id
  3824. AND e.is_deleted = 'N'
  3825. and e.cases_id = 243,
  3826. (
  3827. SELECT
  3828. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  3829. a.beh_dept_id AS behDeptId,
  3830. a.beh_dept_name AS behDeptName
  3831. FROM
  3832. med_behospital_info a,
  3833. med_qcresult_info b,
  3834. sys_user_dept c
  3835. WHERE
  3836. a.is_deleted = 'N'
  3837. AND b.is_deleted = 'N'
  3838. AND c.is_deleted = 'N'
  3839. AND a.hospital_id = b.hospital_id
  3840. AND a.hospital_id = c.hospital_id
  3841. AND a.behospital_code = b.behospital_code
  3842. AND a.beh_dept_id = c.dept_id
  3843. <if test="diagnose != null and diagnose != ''">
  3844. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  3845. </if>
  3846. <if test="isPlacefile != null and isPlacefile != ''">
  3847. and a.is_placefile = #{isPlacefile}
  3848. </if>
  3849. <![CDATA[AND a.qc_type_id <>0 ]]>
  3850. <if test="hospitalId != null and hospitalId != ''">
  3851. AND a.hospital_id = #{hospitalId}
  3852. </if>
  3853. <if test="userId != null ">
  3854. AND c.user_id = #{userId}
  3855. </if>
  3856. <if test="behosDateStart != null">
  3857. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  3858. </if>
  3859. <if test="behosDateEnd != null">
  3860. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  3861. </if>
  3862. <if test="leaveHosDateStart != null ">
  3863. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  3864. </if>
  3865. <if test="leaveHosDateEnd != null ">
  3866. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  3867. </if>
  3868. <if test="behospitalCode != null and behospitalCode != ''">
  3869. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  3870. </if>
  3871. <if test="level != null and level != ''">
  3872. AND b.level = #{level}
  3873. </if>
  3874. <if test="doctorName != null and doctorName != ''">
  3875. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  3876. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  3877. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  3878. </if>
  3879. <if test="doctorCode != null and doctorCode != ''">
  3880. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  3881. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  3882. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  3883. </if>
  3884. <if test="deptName != null and deptName != ''">
  3885. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3886. </if>
  3887. <if test="name != null and name != ''">
  3888. AND a.name like CONCAT('%',#{name},'%')
  3889. </if>
  3890. GROUP BY
  3891. a.beh_dept_id,
  3892. a.beh_dept_name
  3893. ) t2
  3894. WHERE
  3895. t1.behDeptId = t2.behDeptId
  3896. AND t1.behDeptName = t2.behDeptName
  3897. ORDER BY
  3898. t1.behDeptName,
  3899. t1.behDoctorName,
  3900. t1.patName,
  3901. <if test="radioCheck !=null and radioCheck == 1">
  3902. t1.caseName,
  3903. </if>
  3904. t1.behospitalCode
  3905. )tp
  3906. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  3907. ON tp.behospitalCode = g.behospital_code
  3908. AND tp.hospitalId = g.hospital_id
  3909. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  3910. ON tp.behospitalCode = h.behospital_code
  3911. AND tp.hospitalId = h.hospital_id
  3912. ) tu
  3913. WHERE tu.behospitalCode IS NOT NULL
  3914. <if test="checkStatus != null ">
  3915. and tu.check_status = #{checkStatus}
  3916. </if>
  3917. <if test="mrStatus != null ">
  3918. AND tu.mr_status = #{mrStatus}
  3919. </if>
  3920. <if test="chName != null and chName !=''">
  3921. AND tu.ch_name like CONCAT('%',#{chName},'%')
  3922. </if>
  3923. <if test="mrName != null and mrName !=''">
  3924. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  3925. </if>
  3926. <if test="chTimeStart != null">
  3927. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  3928. </if>
  3929. <if test="chTimeEnd != null">
  3930. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  3931. </if>
  3932. <if test="mrTimeStart != null">
  3933. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  3934. </if>
  3935. <if test="mrTimeEnd != null">
  3936. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  3937. </if>
  3938. </select>
  3939. <!-- 个人质控评分导出到excel-->
  3940. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  3941. SELECT * FROM (
  3942. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  3943. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  3944. g.check_type AS ch_type,
  3945. h.check_type AS mr_type,
  3946. g.check_name AS ch_name,
  3947. h.check_name AS mr_name,
  3948. g.check_time AS ch_time,
  3949. h.check_time AS mr_time
  3950. FROM (
  3951. SELECT
  3952. t1.behDeptId,
  3953. t1.behDeptName,
  3954. t1.behDoctorName,
  3955. t1.patName,
  3956. t1.behospitalCode,
  3957. t1.hospitalId,
  3958. t1.behospitalDate,
  3959. t1.leaveHospitalDate,
  3960. t1.score,
  3961. t2.avgScore,
  3962. <if test="radioCheck !=null and radioCheck == 1">
  3963. t1.msg,
  3964. t1.caseName,
  3965. </if>
  3966. e.score_res as scoreBn
  3967. FROM
  3968. (
  3969. SELECT
  3970. a.doctor_name AS behDoctorName,
  3971. a.beh_doctor_name,
  3972. a.director_doctor_name,
  3973. a.`name` AS patName,
  3974. a.behospital_code AS behospitalCode,
  3975. a.behospital_date AS behospitalDate,
  3976. a.leave_hospital_date AS leaveHospitalDate,
  3977. b.score_res AS score,
  3978. <if test="radioCheck !=null and radioCheck == 1">
  3979. c.msg AS msg,
  3980. d.NAME AS caseName,
  3981. </if>
  3982. a.beh_dept_id AS behDeptId,
  3983. a.beh_dept_name AS behDeptName,
  3984. a.hospital_id AS hospitalId
  3985. FROM
  3986. med_behospital_info a,
  3987. med_qcresult_info b,
  3988. med_qcresult_detail c,
  3989. qc_cases d,
  3990. sys_user u,
  3991. sys_user_hospital uh
  3992. WHERE
  3993. a.is_deleted = 'N'
  3994. AND b.is_deleted = 'N'
  3995. AND c.is_deleted = 'N'
  3996. AND d.is_deleted = 'N'
  3997. AND u.is_deleted = 'N'
  3998. AND uh.is_deleted = 'N'
  3999. AND a.hospital_id = b.hospital_id
  4000. AND a.hospital_id = c.hospital_id
  4001. AND a.behospital_code = b.behospital_code
  4002. AND a.behospital_code = c.behospital_code
  4003. AND u.id = uh.user_id
  4004. AND a.hospital_id = uh.hospital_id
  4005. <if test="userId != null and userId != ''">
  4006. AND u.id = #{userId}
  4007. </if>
  4008. <if test="isPlacefile != null and isPlacefile != ''">
  4009. and a.is_placefile = #{isPlacefile}
  4010. </if>
  4011. <![CDATA[AND a.qc_type_id <>0 ]]>
  4012. <if test="hospitalId != null and hospitalId != ''">
  4013. AND a.hospital_id = #{hospitalId}
  4014. </if>
  4015. <if test="diagnose != null and diagnose != ''">
  4016. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4017. </if>
  4018. <if test="behosDateStart != null">
  4019. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4020. </if>
  4021. <if test="behosDateEnd != null">
  4022. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4023. </if>
  4024. <if test="leaveHosDateStart != null ">
  4025. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4026. </if>
  4027. <if test="leaveHosDateEnd != null ">
  4028. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4029. </if>
  4030. <if test="behospitalCode != null and behospitalCode != ''">
  4031. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4032. </if>
  4033. <if test="level != null and level != ''">
  4034. AND b.level = #{level}
  4035. </if>
  4036. <if test="doctorName != null and doctorName != ''">
  4037. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4038. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4039. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4040. </if>
  4041. <if test="doctorCode != null and doctorCode != ''">
  4042. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4043. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4044. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4045. </if>
  4046. <if test="deptId != null and deptId != ''">
  4047. AND a.beh_dept_id = #{deptId}
  4048. </if>
  4049. <if test="name != null and name != ''">
  4050. AND a.name like CONCAT('%',#{name},'%')
  4051. </if>
  4052. ) t1 LEFT JOIN med_qcresult_cases e
  4053. on t1.behospitalCode = e.behospital_code
  4054. and t1.hospitalId = e.hospital_id
  4055. AND e.is_deleted = 'N'
  4056. and e.cases_id = 243,
  4057. (
  4058. SELECT
  4059. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4060. a.beh_dept_id AS behDeptId,
  4061. a.beh_dept_name AS behDeptName
  4062. FROM
  4063. med_behospital_info a,
  4064. med_qcresult_info b,
  4065. sys_user u,
  4066. sys_user_hospital uh
  4067. WHERE
  4068. a.is_deleted = 'N'
  4069. AND b.is_deleted = 'N'
  4070. AND u.is_deleted = 'N'
  4071. AND uh.is_deleted = 'N'
  4072. AND a.hospital_id = b.hospital_id
  4073. AND a.behospital_code = b.behospital_code
  4074. AND u.id = uh.user_id
  4075. AND a.hospital_id = uh.hospital_id
  4076. and (a.doctor_name = u.linkman
  4077. or a.beh_doctor_name = u.linkman
  4078. or a.director_doctor_name = u.linkman)
  4079. <if test="userId != null and userId != ''">
  4080. AND u.id = #{userId}
  4081. </if>
  4082. <if test="diagnose != null and diagnose != ''">
  4083. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4084. </if>
  4085. <if test="isPlacefile != null and isPlacefile != ''">
  4086. and a.is_placefile = #{isPlacefile}
  4087. </if>
  4088. <![CDATA[AND a.qc_type_id <>0 ]]>
  4089. <if test="hospitalId != null and hospitalId != ''">
  4090. AND a.hospital_id = #{hospitalId}
  4091. </if>
  4092. <if test="behosDateStart != null">
  4093. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4094. </if>
  4095. <if test="behosDateEnd != null">
  4096. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4097. </if>
  4098. <if test="leaveHosDateStart != null ">
  4099. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4100. </if>
  4101. <if test="leaveHosDateEnd != null ">
  4102. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4103. </if>
  4104. <if test="behospitalCode != null and behospitalCode != ''">
  4105. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4106. </if>
  4107. <if test="level != null and level != ''">
  4108. AND b.level = #{level}
  4109. </if>
  4110. <if test="doctorName != null and doctorName != ''">
  4111. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4112. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4113. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4114. </if>
  4115. <if test="doctorCode != null and doctorCode != ''">
  4116. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4117. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4118. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4119. </if>
  4120. <if test="deptId != null and deptId != ''">
  4121. AND a.beh_dept_id = #{deptId}
  4122. </if>
  4123. <if test="name != null and name != ''">
  4124. AND a.name like CONCAT('%',#{name},'%')
  4125. </if>
  4126. ) t2
  4127. WHERE
  4128. t1.behDeptId = t2.behDeptId
  4129. AND t1.behDeptName = t2.behDeptName
  4130. ORDER BY
  4131. t1.behDeptName,
  4132. t1.behDoctorName,
  4133. t1.patName,
  4134. <if test="radioCheck !=null and radioCheck == 1">
  4135. t1.caseName,
  4136. </if>
  4137. t1.behospitalCode
  4138. )tp
  4139. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4140. ON tp.behospitalCode = g.behospital_code
  4141. AND tp.hospitalId = g.hospital_id
  4142. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4143. ON tp.behospitalCode = h.behospital_code
  4144. AND tp.hospitalId = h.hospital_id
  4145. ) tu
  4146. WHERE tu.behospitalCode IS NOT NULL
  4147. <if test="checkStatus != null ">
  4148. and tu.check_status = #{checkStatus}
  4149. </if>
  4150. <if test="mrStatus != null ">
  4151. AND tu.mr_status = #{mrStatus}
  4152. </if>
  4153. <if test="chName != null and chName !=''">
  4154. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4155. </if>
  4156. <if test="mrName != null and mrName !=''">
  4157. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4158. </if>
  4159. <if test="chTimeStart != null">
  4160. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4161. </if>
  4162. <if test="chTimeEnd != null">
  4163. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4164. </if>
  4165. <if test="mrTimeStart != null">
  4166. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4167. </if>
  4168. <if test="mrTimeEnd != null">
  4169. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4170. </if>
  4171. </select>
  4172. <!-- 医疗组质控评分导出到excel-->
  4173. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4174. SELECT * FROM (
  4175. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4176. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4177. g.check_type AS ch_type,
  4178. h.check_type AS mr_type,
  4179. g.check_name AS ch_name,
  4180. h.check_name AS mr_name,
  4181. g.check_time AS ch_time,
  4182. h.check_time AS mr_time
  4183. FROM (
  4184. SELECT
  4185. t1.behDeptId,
  4186. t1.behDeptName,
  4187. t1.behDoctorName,
  4188. t1.patName,
  4189. t1.behospitalCode,
  4190. t1.hospitalId,
  4191. t1.behospitalDate,
  4192. t1.leaveHospitalDate,
  4193. t1.score,
  4194. t2.avgScore,
  4195. <if test="radioCheck !=null and radioCheck == 1">
  4196. t1.msg,
  4197. t1.caseName,
  4198. </if>
  4199. e.score_res as scoreBn
  4200. FROM
  4201. (
  4202. SELECT
  4203. a.doctor_name AS behDoctorName,
  4204. a.`name` AS patName,
  4205. a.behospital_code AS behospitalCode,
  4206. a.behospital_date AS behospitalDate,
  4207. a.leave_hospital_date AS leaveHospitalDate,
  4208. b.score_res AS score,
  4209. <if test="radioCheck !=null and radioCheck == 1">
  4210. c.msg AS msg,
  4211. d.NAME AS caseName,
  4212. </if>
  4213. a.beh_dept_id AS behDeptId,
  4214. a.beh_dept_name AS behDeptName,
  4215. a.hospital_id AS hospitalId
  4216. FROM
  4217. med_behospital_info a,
  4218. med_qcresult_info b,
  4219. med_qcresult_detail c,
  4220. qc_cases d
  4221. WHERE
  4222. a.is_deleted = 'N'
  4223. AND b.is_deleted = 'N'
  4224. AND c.is_deleted = 'N'
  4225. AND d.is_deleted = 'N'
  4226. AND a.hospital_id = b.hospital_id
  4227. AND a.hospital_id = c.hospital_id
  4228. AND a.behospital_code = b.behospital_code
  4229. AND a.behospital_code = c.behospital_code
  4230. AND c.cases_id = d.id
  4231. <if test="isPlacefile != null and isPlacefile != ''">
  4232. and a.is_placefile = #{isPlacefile}
  4233. </if>
  4234. AND a.doctor_id in
  4235. (SELECT doctor_id FROM `bas_doctor_info`
  4236. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4237. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4238. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4239. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4240. and c1.username = c3.doctor_id
  4241. and c2.hospital_id = #{hospitalId}
  4242. and c1.id = #{userId}
  4243. ))
  4244. <![CDATA[AND a.qc_type_id <>0 ]]>
  4245. <if test="hospitalId != null and hospitalId != ''">
  4246. AND a.hospital_id = #{hospitalId}
  4247. </if>
  4248. <if test="diagnose != null and diagnose != ''">
  4249. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4250. </if>
  4251. <if test="behosDateStart != null">
  4252. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4253. </if>
  4254. <if test="behosDateEnd != null">
  4255. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4256. </if>
  4257. <if test="leaveHosDateStart != null ">
  4258. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4259. </if>
  4260. <if test="leaveHosDateEnd != null ">
  4261. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4262. </if>
  4263. <if test="behospitalCode != null and behospitalCode != ''">
  4264. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4265. </if>
  4266. <if test="level != null and level != ''">
  4267. AND b.level = #{level}
  4268. </if>
  4269. <if test="doctorName != null and doctorName != ''">
  4270. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4271. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4272. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4273. </if>
  4274. <if test="doctorCode != null and doctorCode != ''">
  4275. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4276. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4277. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4278. </if>
  4279. <if test="deptId != null and deptId != ''">
  4280. AND a.beh_dept_id = #{deptId}
  4281. </if>
  4282. <if test="name != null and name != ''">
  4283. AND a.name like CONCAT('%',#{name},'%')
  4284. </if>
  4285. ) t1 LEFT JOIN med_qcresult_cases e
  4286. on t1.behospitalCode = e.behospital_code
  4287. and t1.hospitalId = e.hospital_id
  4288. AND e.is_deleted = 'N'
  4289. and e.cases_id = 243,
  4290. (
  4291. SELECT
  4292. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4293. a.beh_dept_id AS behDeptId,
  4294. a.beh_dept_name AS behDeptName
  4295. FROM
  4296. med_behospital_info a,
  4297. med_qcresult_info b
  4298. WHERE
  4299. a.is_deleted = 'N'
  4300. AND a.doctor_id in
  4301. (SELECT doctor_id FROM `bas_doctor_info`
  4302. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4303. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4304. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4305. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4306. and c1.username = c3.doctor_id
  4307. and c2.hospital_id = #{hospitalId}
  4308. and c1.id = #{userId}
  4309. ))
  4310. AND b.is_deleted = 'N'
  4311. AND a.hospital_id = b.hospital_id
  4312. AND a.behospital_code = b.behospital_code
  4313. <if test="diagnose != null and diagnose != ''">
  4314. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4315. </if>
  4316. <if test="isPlacefile != null and isPlacefile != ''">
  4317. and a.is_placefile = #{isPlacefile}
  4318. </if>
  4319. <![CDATA[AND a.qc_type_id <>0 ]]>
  4320. <if test="hospitalId != null and hospitalId != ''">
  4321. AND a.hospital_id = #{hospitalId}
  4322. </if>
  4323. <if test="behosDateStart != null">
  4324. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4325. </if>
  4326. <if test="behosDateEnd != null">
  4327. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4328. </if>
  4329. <if test="leaveHosDateStart != null ">
  4330. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4331. </if>
  4332. <if test="leaveHosDateEnd != null ">
  4333. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4334. </if>
  4335. <if test="behospitalCode != null and behospitalCode != ''">
  4336. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4337. </if>
  4338. <if test="level != null and level != ''">
  4339. AND b.level = #{level}
  4340. </if>
  4341. <if test="doctorName != null and doctorName != ''">
  4342. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4343. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4344. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4345. </if>
  4346. <if test="doctorCode != null and doctorCode != ''">
  4347. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4348. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4349. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4350. </if>
  4351. <if test="deptId != null and deptId != ''">
  4352. AND a.beh_dept_id = #{deptId}
  4353. </if>
  4354. <if test="name != null and name != ''">
  4355. AND a.name like CONCAT('%',#{name},'%')
  4356. </if>
  4357. GROUP BY
  4358. a.beh_dept_id,
  4359. a.beh_dept_name
  4360. ) t2
  4361. WHERE
  4362. t1.behDeptId = t2.behDeptId
  4363. AND t1.behDeptName = t2.behDeptName
  4364. ORDER BY
  4365. t1.behDeptName,
  4366. t1.behDoctorName,
  4367. t1.patName,
  4368. <if test="radioCheck !=null and radioCheck == 1">
  4369. t1.caseName,
  4370. </if>
  4371. t1.behospitalCode
  4372. )tp
  4373. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4374. ON tp.behospitalCode = g.behospital_code
  4375. AND tp.hospitalId = g.hospital_id
  4376. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4377. ON tp.behospitalCode = h.behospital_code
  4378. AND tp.hospitalId = h.hospital_id
  4379. ) tu
  4380. WHERE tu.behospitalCode IS NOT NULL
  4381. <if test="checkStatus != null ">
  4382. and tu.check_status = #{checkStatus}
  4383. </if>
  4384. <if test="mrStatus != null ">
  4385. AND tu.mr_status = #{mrStatus}
  4386. </if>
  4387. <if test="chName != null and chName !=''">
  4388. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4389. </if>
  4390. <if test="mrName != null and mrName !=''">
  4391. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4392. </if>
  4393. <if test="chTimeStart != null">
  4394. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4395. </if>
  4396. <if test="chTimeEnd != null">
  4397. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4398. </if>
  4399. <if test="mrTimeStart != null">
  4400. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4401. </if>
  4402. <if test="mrTimeEnd != null">
  4403. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4404. </if>
  4405. </select>
  4406. <!-- 条目缺陷质控评分页(内页)-->
  4407. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  4408. SELECT t.*
  4409. FROM
  4410. (SELECT DISTINCT
  4411. t1.hospital_id AS hospitalId,
  4412. t1.behospital_code AS behospitalCode,
  4413. t1.bed_code AS bedCode,
  4414. t1.LEVEL AS LEVEL,
  4415. t1.grade_type AS gradeType,
  4416. t1.score_res AS scoreRes,
  4417. t1.scoreBn,
  4418. t1.NAME AS NAME,
  4419. t1.sex AS sex,
  4420. t1.beh_dept_id AS behDeptId,
  4421. t1.beh_dept_name AS behDeptName,
  4422. t1.doctor_id AS doctorId,
  4423. t1.doctor_name AS doctorName,
  4424. t1.beh_doctor_id AS behDoctorId,
  4425. t1.beh_doctor_name AS behDoctorName,
  4426. t1.director_doctor_id AS directorDoctorId,
  4427. t1.director_doctor_name AS directorDoctorName,
  4428. t1.birthday AS birthday,
  4429. t1.behospital_date AS behospitalDate,
  4430. t1.leave_hospital_date AS leaveHospitalDate,
  4431. t1.placefile_date AS placefileDate,
  4432. t1.gmt_create AS gradeTime,
  4433. t1.diagnose,
  4434. t1.ward_name AS wardName,
  4435. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  4436. t1.file_code AS fileCode,
  4437. t1.checkStatus,
  4438. t1.mrStatus,
  4439. t1.chName,
  4440. t1.mrName,
  4441. t1.chTime,
  4442. t1.mrTime
  4443. FROM
  4444. (
  4445. SELECT DISTINCT
  4446. tt1.*
  4447. FROM
  4448. (SELECT
  4449. be.*,
  4450. ifnull(mci.status,0) AS checkStatus,
  4451. ifnull(hm_mci.status,0) AS mrStatus,
  4452. mci.check_name as chName,
  4453. e.score_res as scoreBn,
  4454. hm_mci.check_name as mrName,
  4455. mci.gmt_create as chTime,
  4456. hm_mci.gmt_create as mrTime
  4457. FROM
  4458. (
  4459. SELECT DISTINCT
  4460. a.hospital_id,
  4461. a.behospital_code,
  4462. a.bed_code,
  4463. a.file_code,
  4464. b.LEVEL,
  4465. b.grade_type,
  4466. b.score_res,
  4467. a.NAME,
  4468. a.sex,
  4469. a.beh_dept_id,
  4470. a.beh_dept_name,
  4471. a.birthday,
  4472. a.behospital_date,
  4473. a.leave_hospital_date,
  4474. a.doctor_id,
  4475. a.doctor_name,
  4476. a.beh_doctor_id,
  4477. a.beh_doctor_name,
  4478. a.director_doctor_id,
  4479. a.director_doctor_name,
  4480. a.diagnose,
  4481. a.placefile_date,
  4482. a.ward_name,
  4483. b.gmt_create
  4484. FROM
  4485. med_behospital_info a,
  4486. med_qcresult_info b,
  4487. med_qcresult_detail c,
  4488. qc_cases_entry d
  4489. WHERE
  4490. a.is_deleted = 'N'
  4491. AND b.is_deleted = 'N'
  4492. AND c.is_deleted = 'N'
  4493. AND d.is_deleted = 'N'
  4494. AND a.hospital_id = b.hospital_id
  4495. AND a.hospital_id = c.hospital_id
  4496. AND a.behospital_code = b.behospital_code
  4497. AND a.behospital_code = c.behospital_code
  4498. AND c.cases_id = d.cases_id
  4499. AND c.cases_entry_id = d.id
  4500. AND a.qc_type_id != 0
  4501. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  4502. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  4503. </if>
  4504. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4505. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4506. </if>
  4507. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  4508. <if test="qcResultShortPageVO.startDate != null ">
  4509. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  4510. </if>
  4511. <if test="qcResultShortPageVO.endDate != null ">
  4512. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  4513. </if>
  4514. </if>
  4515. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  4516. <if test="qcResultShortPageVO.startDate != null ">
  4517. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  4518. </if>
  4519. <if test="qcResultShortPageVO.endDate != null">
  4520. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  4521. </if>
  4522. </if>
  4523. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  4524. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  4525. </if>
  4526. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  4527. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  4528. </if>
  4529. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  4530. AND b.`level` = #{qcResultShortPageVO.level}
  4531. </if>
  4532. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4533. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4534. </if>
  4535. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4536. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4537. </if>
  4538. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  4539. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  4540. </if>
  4541. <if test="qcResultShortPageVO.casesEntryId != null ">
  4542. AND d.id = #{qcResultShortPageVO.casesEntryId}
  4543. </if>
  4544. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  4545. AND d.cases_name = #{qcResultShortPageVO.casesName}
  4546. </if>
  4547. <if test="qcResultShortPageVO.casesId != null">
  4548. AND d.cases_id = #{qcResultShortPageVO.casesId}
  4549. </if>
  4550. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4551. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4552. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4553. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4554. </if>
  4555. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4556. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4557. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4558. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4559. </if>
  4560. <if test="qcResultShortPageVO.isReject != null">
  4561. AND c.is_reject = #{qcResultShortPageVO.isReject}
  4562. </if>
  4563. <if test="qcResultShortPageVO.ruleType != null">
  4564. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  4565. </if>
  4566. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  4567. AND TIMESTAMPDIFF(
  4568. DAY,
  4569. DATE( a.behospital_date ),
  4570. DATE( a.leave_hospital_date ))> 30
  4571. </if>
  4572. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  4573. AND TIMESTAMPDIFF(
  4574. DAY,
  4575. DATE( a.behospital_date ),
  4576. DATE( a.leave_hospital_date ))> 31
  4577. </if>
  4578. )be
  4579. left join med_check_info mci
  4580. on mci.is_deleted = 'N'
  4581. and mci.check_type = 0
  4582. and be.hospital_id = mci.hospital_id
  4583. and be.behospital_code = mci.behospital_code
  4584. left join med_check_info hm_mci
  4585. on hm_mci.is_deleted = 'N'
  4586. and hm_mci.check_type = 1
  4587. and be.hospital_id = hm_mci.hospital_id
  4588. and be.behospital_code = hm_mci.behospital_code
  4589. LEFT JOIN med_qcresult_cases e
  4590. on be.behospital_code = e.behospital_code
  4591. and be.hospital_id = e.hospital_id
  4592. AND e.is_deleted = 'N'
  4593. and e.cases_id = 243
  4594. )tt1
  4595. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  4596. ,med_medical_record tt2
  4597. WHERE
  4598. tt2.is_deleted = 'N'
  4599. AND tt1.hospital_id = tt2.hospital_id
  4600. AND tt1.behospital_code = tt2.behospital_code
  4601. AND tt2.mode_id = 30
  4602. </if>
  4603. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  4604. ,med_crisis_info tt2
  4605. WHERE
  4606. tt2.is_deleted = 'N'
  4607. AND tt1.hospital_id = tt2.hospital_id
  4608. AND tt1.behospital_code = tt2.behospital_code
  4609. </if>
  4610. ) t1
  4611. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  4612. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  4613. AND t1.behospital_code = t2.behospital_code
  4614. AND t2.is_deleted = 'N'
  4615. </if>
  4616. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  4617. , med_home_page t2
  4618. , med_home_operation_info t3
  4619. WHERE t1.hospital_id = t2.hospital_id
  4620. AND t1.behospital_code = t2.behospital_code
  4621. AND t2.home_page_id = t3.home_page_id
  4622. AND t2.is_deleted = 'N'
  4623. AND t3.is_deleted = 'N'
  4624. </if>
  4625. ) t
  4626. where 1=1
  4627. <if test="qcResultShortPageVO.checkStatus != null">
  4628. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  4629. </if>
  4630. <if test="qcResultShortPageVO.mrStatus != null">
  4631. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  4632. </if>
  4633. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  4634. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  4635. </if>
  4636. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  4637. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  4638. </if>
  4639. <if test="qcResultShortPageVO.chTimeStart != null ">
  4640. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  4641. </if>
  4642. <if test="qcResultShortPageVO.chTimeEnd != null ">
  4643. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  4644. </if>
  4645. <if test="qcResultShortPageVO.mrTimeStart != null ">
  4646. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  4647. </if>
  4648. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  4649. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  4650. </if>
  4651. </select>
  4652. <!-- 条目缺陷质控评分页-科室(内页)-->
  4653. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  4654. SELECT DISTINCT
  4655. t1.hospital_id AS hospitalId,
  4656. t1.behospital_code AS behospitalCode,
  4657. t1.bed_code AS bedCode,
  4658. t1.LEVEL AS LEVEL,
  4659. t1.grade_type AS gradeType,
  4660. t1.score_res AS scoreRes,
  4661. t1.NAME AS NAME,
  4662. t1.sex AS sex,
  4663. t1.beh_dept_id AS behDeptId,
  4664. t1.beh_dept_name AS behDeptName,
  4665. t1.doctor_id AS doctorId,
  4666. t1.doctor_name AS doctorName,
  4667. t1.beh_doctor_id AS behDoctorId,
  4668. t1.beh_doctor_name AS behDoctorName,
  4669. t1.director_doctor_id AS directorDoctorId,
  4670. t1.director_doctor_name AS directorDoctorName,
  4671. t1.birthday AS birthday,
  4672. t1.behospital_date AS behospitalDate,
  4673. t1.leave_hospital_date AS leaveHospitalDate,
  4674. t1.placefile_date AS placefileDate,
  4675. t1.gmt_create AS gradeTime,
  4676. t1.diagnose,
  4677. t1.ward_name AS wardName,
  4678. t2.age,
  4679. t1.file_code AS fileCode
  4680. FROM
  4681. (
  4682. SELECT DISTINCT
  4683. a.hospital_id,
  4684. a.behospital_code,
  4685. a.bed_code,
  4686. a.file_code,
  4687. b.LEVEL,
  4688. b.grade_type,
  4689. b.score_res,
  4690. a.NAME,
  4691. a.sex,
  4692. a.beh_dept_id,
  4693. a.beh_dept_name,
  4694. a.birthday,
  4695. a.behospital_date,
  4696. a.leave_hospital_date,
  4697. a.doctor_id,
  4698. a.doctor_name,
  4699. a.beh_doctor_id,
  4700. a.beh_doctor_name,
  4701. a.director_doctor_id,
  4702. a.director_doctor_name,
  4703. a.diagnose,
  4704. a.placefile_date,
  4705. a.ward_name,
  4706. b.gmt_create
  4707. FROM
  4708. med_behospital_info a,
  4709. med_qcresult_info b,
  4710. med_qcresult_detail c,
  4711. qc_cases_entry d,
  4712. sys_user_dept e
  4713. WHERE
  4714. a.is_deleted = 'N'
  4715. AND b.is_deleted = 'N'
  4716. AND c.is_deleted = 'N'
  4717. AND d.is_deleted = 'N'
  4718. AND e.is_deleted = 'N'
  4719. AND a.hospital_id = b.hospital_id
  4720. AND a.hospital_id = c.hospital_id
  4721. AND a.hospital_id = e.hospital_id
  4722. AND a.behospital_code = b.behospital_code
  4723. AND a.behospital_code = c.behospital_code
  4724. AND a.beh_dept_id = e.dept_id
  4725. AND c.cases_id = d.cases_id
  4726. AND c.cases_entry_id = d.id
  4727. AND a.qc_type_id != 0
  4728. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  4729. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  4730. </if>
  4731. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  4732. and a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  4733. </if>
  4734. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  4735. AND e.user_id = #{qcResultShortPageVO.userId}
  4736. </if>
  4737. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4738. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4739. </if>
  4740. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  4741. <if test="qcResultShortPageVO.startDate != null ">
  4742. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  4743. </if>
  4744. <if test="qcResultShortPageVO.endDate != null ">
  4745. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  4746. </if>
  4747. </if>
  4748. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  4749. <if test="qcResultShortPageVO.startDate != null ">
  4750. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  4751. </if>
  4752. <if test="qcResultShortPageVO.endDate != null">
  4753. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  4754. </if>
  4755. </if>
  4756. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  4757. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  4758. </if>
  4759. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4760. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  4761. </if>
  4762. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4763. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4764. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4765. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4766. </if>
  4767. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4768. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4769. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4770. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4771. </if>
  4772. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  4773. AND b.`level` = #{qcResultShortPageVO.level}
  4774. </if>
  4775. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4776. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4777. </if>
  4778. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4779. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4780. </if>
  4781. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  4782. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  4783. </if>
  4784. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  4785. AND d.id = #{qcResultShortPageVO.casesEntryId}
  4786. </if>
  4787. <if test="qcResultShortPageVO.isReject != null">
  4788. AND c.is_reject = #{qcResultShortPageVO.isReject}
  4789. </if>
  4790. <if test="qcResultShortPageVO.ruleType != null">
  4791. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  4792. </if>
  4793. ) t1
  4794. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  4795. AND t1.behospital_code = t2.behospital_code
  4796. AND t2.is_deleted = 'N'
  4797. </select>
  4798. <update id="updateBatchByKey">
  4799. <foreach collection="list" item="item" separator=";">
  4800. update med_behospital_info
  4801. <set>
  4802. <if test="item.name != null">
  4803. name = #{item.name},
  4804. </if>
  4805. <if test="item.sex != null">
  4806. sex = #{item.sex},
  4807. </if>
  4808. <if test="item.birthday != null">
  4809. birthday = #{item.birthday},
  4810. </if>
  4811. <if test="item.fileCode != null">
  4812. file_code = #{item.fileCode},
  4813. </if>
  4814. <if test="item.qcTypeId != null">
  4815. qc_type_id = #{item.qcTypeId},
  4816. </if>
  4817. <if test="item.wardCode != null">
  4818. ward_code = #{item.wardCode},
  4819. </if>
  4820. <if test="item.wardName != null">
  4821. ward_name = #{item.wardName},
  4822. </if>
  4823. <if test="item.behDeptId != null">
  4824. beh_dept_id = #{item.behDeptId},
  4825. </if>
  4826. <if test="item.behDeptName != null">
  4827. beh_dept_name = #{item.behDeptName},
  4828. </if>
  4829. <if test="item.bedCode != null">
  4830. bed_code = #{item.bedCode},
  4831. </if>
  4832. <if test="item.bedName != null">
  4833. bed_name = #{item.bedName},
  4834. </if>
  4835. <if test="item.insuranceName != null">
  4836. insurance_name = #{item.insuranceName},
  4837. </if>
  4838. <if test="item.jobType != null">
  4839. job_type = #{item.jobType},
  4840. </if>
  4841. <if test="item.behospitalDate != null">
  4842. behospital_date = #{item.behospitalDate},
  4843. </if>
  4844. <if test="item.leaveHospitalDate != null">
  4845. leave_hospital_date = #{item.leaveHospitalDate},
  4846. </if>
  4847. <if test="item.diagnoseIcd != null">
  4848. diagnose_icd = #{item.diagnoseIcd},
  4849. </if>
  4850. <if test="item.diagnose != null">
  4851. diagnose = #{item.diagnose},
  4852. </if>
  4853. <if test="item.behDoctorId != null">
  4854. beh_doctor_id = #{item.behDoctorId},
  4855. </if>
  4856. <if test="item.behDoctorName != null">
  4857. beh_doctor_name = #{item.behDoctorName},
  4858. </if>
  4859. <if test="item.doctorId != null">
  4860. doctor_id = #{item.doctorId},
  4861. </if>
  4862. <if test="item.doctorName != null">
  4863. doctor_name = #{item.doctorName},
  4864. </if>
  4865. <if test="item.directorDoctorId != null">
  4866. director_doctor_id = #{item.directorDoctorId},
  4867. </if>
  4868. <if test="item.directorDoctorName != null">
  4869. director_doctor_name = #{item.directorDoctorName},
  4870. </if>
  4871. <if test="item.placefileDate != null">
  4872. placefile_date = #{item.placefileDate},
  4873. </if>
  4874. <if test="item.isPlacefile != null">
  4875. is_placefile = #{item.isPlacefile},
  4876. </if>
  4877. <if test="item.gmtModified != null">
  4878. gmt_modified = #{item.gmtModified},
  4879. </if>
  4880. <if test="item.modifier != null">
  4881. modifier = #{item.modifier},
  4882. </if>
  4883. </set>
  4884. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  4885. </foreach>
  4886. </update>
  4887. <!-- 关键条目缺陷统计报表-->
  4888. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  4889. SELECT
  4890. deptId,
  4891. deptName,
  4892. consultationMRNum,
  4893. consultationNum,
  4894. 2511 AS consultationEntryId,
  4895. '普通会诊未在24小时内完成' AS consultationEntryName,
  4896. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  4897. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  4898. operationMRNum,
  4899. 2594 AS operationNameEntryId,
  4900. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  4901. operationNameNum,
  4902. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  4903. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  4904. 2973 AS operationTimeEntryId,
  4905. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  4906. operationTimeNum,
  4907. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  4908. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  4909. 2930 AS operation15MinuteEntryId,
  4910. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  4911. operation15MinuteNum,
  4912. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  4913. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  4914. 2419 AS crisisEntryId,
  4915. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  4916. crisisMRNum,
  4917. crisisNum,
  4918. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  4919. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  4920. 2495 AS stageSummaryEntryId,
  4921. '无阶段小结' AS stageSummaryEntryName,
  4922. stageSummaryMRNum,
  4923. stageSummaryNum,
  4924. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  4925. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  4926. beHosGT31DaysMRNum
  4927. FROM
  4928. (
  4929. SELECT
  4930. tt.deptId,
  4931. tt.deptName,
  4932. sum( tt.consultationNum ) AS consultationNum,
  4933. sum( tt.consultationMRNum ) AS consultationMRNum,
  4934. sum( tt.operationNameNum ) AS operationNameNum,
  4935. sum( tt.operationTimeNum ) AS operationTimeNum,
  4936. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  4937. sum( tt.operationMRNum ) AS operationMRNum,
  4938. sum( tt.crisisNum ) AS crisisNum,
  4939. sum( tt.crisisMRNum ) AS crisisMRNum,
  4940. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  4941. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  4942. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  4943. FROM
  4944. (
  4945. (
  4946. SELECT
  4947. c.beh_dept_id AS deptId,
  4948. c.beh_dept_name AS deptName,
  4949. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  4950. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  4951. 0 AS operationNameNum,
  4952. 0 AS operationTimeNum,
  4953. 0 AS operation15MinuteNum,
  4954. 0 AS operationMRNum,
  4955. 0 AS crisisNum,
  4956. 0 AS crisisMRNum,
  4957. 0 AS stageSummaryNum,
  4958. 0 AS stageSummaryMRNum,
  4959. 0 AS beHosGT31DaysMRNum
  4960. FROM
  4961. (
  4962. SELECT DISTINCT
  4963. a.hospital_id,
  4964. a.behospital_code,
  4965. a.beh_dept_name,
  4966. a.beh_dept_id
  4967. FROM
  4968. med_behospital_info a,
  4969. med_medical_record b
  4970. WHERE
  4971. a.is_deleted = 'N'
  4972. AND b.is_deleted = 'N'
  4973. AND a.hospital_id = b.hospital_id
  4974. AND a.behospital_code = b.behospital_code
  4975. AND b.mode_id = 30
  4976. <if test="isPlacefile != null and isPlacefile != ''">
  4977. and a.is_placefile = #{isPlacefile}
  4978. </if>
  4979. AND a.qc_type_id != 0
  4980. <if test="hospitalId != null and hospitalId != ''">
  4981. AND a.hospital_id = #{hospitalId}
  4982. </if>
  4983. <if test="isPlacefile != null and isPlacefile == 0">
  4984. <if test="startDate != null ">
  4985. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4986. </if>
  4987. <if test="endDate != null ">
  4988. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4989. </if>
  4990. </if>
  4991. <if test="isPlacefile != null and isPlacefile == 1">
  4992. <if test="startDate != null ">
  4993. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4994. </if>
  4995. <if test="endDate != null ">
  4996. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4997. </if>
  4998. </if>
  4999. <if test="deptName != null and deptName != ''">
  5000. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5001. </if>
  5002. ) c
  5003. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5004. AND c.hospital_id = d.hospital_id
  5005. AND c.behospital_code = d.behospital_code
  5006. GROUP BY
  5007. c.beh_dept_id,
  5008. c.beh_dept_name
  5009. ) UNION
  5010. (
  5011. SELECT
  5012. d.beh_dept_id AS deptId,
  5013. d.beh_dept_name AS deptName,
  5014. 0 AS consultationNum,
  5015. 0 AS consultationMRNum,
  5016. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  5017. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  5018. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  5019. count( DISTINCT d.behospital_code ) AS operationMRNum,
  5020. 0 AS crisisNum,
  5021. 0 AS crisisMRNum,
  5022. 0 AS stageSummaryNum,
  5023. 0 AS stageSummaryMRNum,
  5024. 0 AS beHosGT31DaysMRNum
  5025. FROM
  5026. (
  5027. SELECT DISTINCT
  5028. a.hospital_id,
  5029. a.behospital_code,
  5030. a.beh_dept_name,
  5031. a.beh_dept_id
  5032. FROM
  5033. med_behospital_info a,
  5034. med_home_page b,
  5035. med_home_operation_info c
  5036. WHERE
  5037. a.is_deleted = 'N'
  5038. AND b.is_deleted = 'N'
  5039. AND c.is_deleted = 'N'
  5040. AND a.hospital_id = b.hospital_id
  5041. AND a.hospital_id = c.hospital_id
  5042. AND a.behospital_code = b.behospital_code
  5043. AND b.home_page_id = c.home_page_id
  5044. <if test="isPlacefile != null and isPlacefile != ''">
  5045. and a.is_placefile = #{isPlacefile}
  5046. </if>
  5047. AND a.qc_type_id != 0
  5048. <if test="hospitalId != null and hospitalId != ''">
  5049. AND a.hospital_id = #{hospitalId}
  5050. </if>
  5051. <if test="isPlacefile != null and isPlacefile == 0">
  5052. <if test="startDate != null ">
  5053. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5054. </if>
  5055. <if test="endDate != null ">
  5056. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5057. </if>
  5058. </if>
  5059. <if test="isPlacefile != null and isPlacefile == 1">
  5060. <if test="startDate != null ">
  5061. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5062. </if>
  5063. <if test="endDate != null ">
  5064. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5065. </if>
  5066. </if>
  5067. <if test="deptName != null and deptName != ''">
  5068. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5069. </if>
  5070. ) d
  5071. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  5072. AND d.hospital_id = e.hospital_id
  5073. AND d.behospital_code = e.behospital_code
  5074. GROUP BY
  5075. d.beh_dept_id,
  5076. d.beh_dept_name
  5077. ) UNION
  5078. (
  5079. SELECT
  5080. c.beh_dept_id AS deptId,
  5081. c.beh_dept_name AS deptName,
  5082. 0 AS consultationNum,
  5083. 0 AS consultationMRNum,
  5084. 0 AS operationNameNum,
  5085. 0 AS operationTimeNum,
  5086. 0 AS operation15MinuteNum,
  5087. 0 AS operationMRNum,
  5088. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  5089. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  5090. 0 AS stageSummaryNum,
  5091. 0 AS stageSummaryMRNum,
  5092. 0 AS beHosGT31DaysMRNum
  5093. FROM
  5094. (
  5095. SELECT DISTINCT
  5096. a.hospital_id,
  5097. a.behospital_code,
  5098. a.beh_dept_name,
  5099. a.beh_dept_id
  5100. FROM
  5101. med_behospital_info a,
  5102. med_crisis_info b
  5103. WHERE
  5104. a.is_deleted = 'N'
  5105. AND b.is_deleted = 'N'
  5106. AND a.hospital_id = b.hospital_id
  5107. AND a.behospital_code = b.behospital_code
  5108. <if test="isPlacefile != null and isPlacefile != ''">
  5109. and a.is_placefile = #{isPlacefile}
  5110. </if>
  5111. AND a.qc_type_id != 0
  5112. <if test="hospitalId != null and hospitalId != ''">
  5113. AND a.hospital_id = #{hospitalId}
  5114. </if>
  5115. <if test="isPlacefile != null and isPlacefile == 0">
  5116. <if test="startDate != null ">
  5117. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5118. </if>
  5119. <if test="endDate != null ">
  5120. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5121. </if>
  5122. </if>
  5123. <if test="isPlacefile != null and isPlacefile == 1">
  5124. <if test="startDate != null ">
  5125. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5126. </if>
  5127. <if test="endDate != null ">
  5128. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5129. </if>
  5130. </if>
  5131. <if test="deptName != null and deptName != ''">
  5132. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5133. </if>
  5134. ) c
  5135. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5136. AND c.hospital_id = d.hospital_id
  5137. AND c.behospital_code = d.behospital_code
  5138. GROUP BY
  5139. c.beh_dept_id,
  5140. c.beh_dept_name
  5141. ) UNION
  5142. (
  5143. SELECT
  5144. b.beh_dept_id AS deptId,
  5145. b.beh_dept_name AS deptName,
  5146. 0 AS consultationNum,
  5147. 0 AS consultationMRNum,
  5148. 0 AS operationNameNum,
  5149. 0 AS operationTimeNum,
  5150. 0 AS operation15MinuteNum,
  5151. 0 AS operationMRNum,
  5152. 0 AS crisisNum,
  5153. 0 AS crisisMRNum,
  5154. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  5155. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  5156. 0 AS beHosGT31DaysMRNum
  5157. FROM
  5158. (
  5159. SELECT DISTINCT
  5160. a.hospital_id,
  5161. a.behospital_code,
  5162. a.beh_dept_name,
  5163. a.beh_dept_id
  5164. FROM
  5165. med_behospital_info a
  5166. WHERE
  5167. a.is_deleted = 'N'
  5168. AND TIMESTAMPDIFF(
  5169. DAY,
  5170. DATE( behospital_date ),
  5171. DATE( leave_hospital_date ))> 30
  5172. <if test="isPlacefile != null and isPlacefile != ''">
  5173. and a.is_placefile = #{isPlacefile}
  5174. </if>
  5175. AND a.qc_type_id != 0
  5176. <if test="hospitalId != null and hospitalId != ''">
  5177. AND a.hospital_id = #{hospitalId}
  5178. </if>
  5179. <if test="isPlacefile != null and isPlacefile == 0">
  5180. <if test="startDate != null ">
  5181. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5182. </if>
  5183. <if test="endDate != null ">
  5184. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5185. </if>
  5186. </if>
  5187. <if test="isPlacefile != null and isPlacefile == 1">
  5188. <if test="startDate != null ">
  5189. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5190. </if>
  5191. <if test="endDate != null ">
  5192. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5193. </if>
  5194. </if>
  5195. <if test="deptName != null and deptName != ''">
  5196. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5197. </if>
  5198. ) b
  5199. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  5200. AND b.hospital_id = c.hospital_id
  5201. AND b.behospital_code = c.behospital_code
  5202. GROUP BY
  5203. b.beh_dept_id,
  5204. b.beh_dept_name
  5205. ) UNION
  5206. (
  5207. SELECT
  5208. b.beh_dept_id AS deptId,
  5209. b.beh_dept_name AS deptName,
  5210. 0 AS consultationNum,
  5211. 0 AS consultationMRNum,
  5212. 0 AS operationNameNum,
  5213. 0 AS operationTimeNum,
  5214. 0 AS operation15MinuteNum,
  5215. 0 AS operationMRNum,
  5216. 0 AS crisisNum,
  5217. 0 AS crisisMRNum,
  5218. 0 AS stageSummaryNum,
  5219. 0 AS stageSummaryMRNum,
  5220. count(*) AS beHosGT31DaysMRNum
  5221. FROM
  5222. (
  5223. SELECT DISTINCT
  5224. a.hospital_id,
  5225. a.behospital_code,
  5226. a.beh_dept_name,
  5227. a.beh_dept_id
  5228. FROM
  5229. med_behospital_info a
  5230. WHERE
  5231. a.is_deleted = 'N'
  5232. AND TIMESTAMPDIFF(
  5233. DAY,
  5234. DATE( behospital_date ),
  5235. DATE( leave_hospital_date ))> 31
  5236. <if test="isPlacefile != null and isPlacefile != ''">
  5237. and a.is_placefile = #{isPlacefile}
  5238. </if>
  5239. AND a.qc_type_id != 0
  5240. <if test="hospitalId != null and hospitalId != ''">
  5241. AND a.hospital_id = #{hospitalId}
  5242. </if>
  5243. <if test="isPlacefile != null and isPlacefile == 0">
  5244. <if test="startDate != null ">
  5245. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5246. </if>
  5247. <if test="endDate != null ">
  5248. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5249. </if>
  5250. </if>
  5251. <if test="isPlacefile != null and isPlacefile == 1">
  5252. <if test="startDate != null ">
  5253. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5254. </if>
  5255. <if test="endDate != null ">
  5256. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5257. </if>
  5258. </if>
  5259. <if test="deptName != null and deptName != ''">
  5260. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5261. </if>
  5262. ) b
  5263. GROUP BY
  5264. b.beh_dept_id,
  5265. b.beh_dept_name
  5266. )
  5267. ) tt
  5268. GROUP BY
  5269. tt.deptId,
  5270. tt.deptName
  5271. ) t
  5272. <if test="asc != null and asc !=''">
  5273. order by
  5274. <choose>
  5275. <when test='asc=="deptId"'>deptId asc</when>
  5276. <when test='asc=="deptName"'>deptName asc</when>
  5277. <when test='asc=="consultationNum"'>consultationNum asc</when>
  5278. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  5279. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  5280. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  5281. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  5282. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  5283. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  5284. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  5285. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  5286. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  5287. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  5288. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  5289. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  5290. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  5291. <when test='asc=="crisisNum"'>crisisNum asc</when>
  5292. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  5293. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  5294. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  5295. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  5296. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  5297. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  5298. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  5299. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  5300. <otherwise>deptName asc</otherwise>
  5301. </choose>
  5302. </if>
  5303. <if test="desc != null and desc!=''">
  5304. order by
  5305. <choose>
  5306. <when test='desc=="deptId"'>deptId desc</when>
  5307. <when test='desc=="deptName"'>deptName desc</when>
  5308. <when test='desc=="consultationNum"'>consultationNum desc</when>
  5309. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  5310. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  5311. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  5312. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  5313. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  5314. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  5315. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  5316. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  5317. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  5318. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  5319. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  5320. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  5321. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  5322. <when test='desc=="crisisNum"'>crisisNum desc</when>
  5323. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  5324. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  5325. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  5326. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  5327. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  5328. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  5329. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  5330. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  5331. <otherwise>deptName desc</otherwise>
  5332. </choose>
  5333. </if>
  5334. </select>
  5335. <!-- 关键条目缺陷统计报表-科室-->
  5336. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  5337. SELECT
  5338. deptId,
  5339. deptName,
  5340. doctorName,
  5341. consultationMRNum,
  5342. consultationNum,
  5343. 2511 AS consultationEntryId,
  5344. '普通会诊未在24小时内完成' AS consultationEntryName,
  5345. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  5346. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  5347. operationMRNum,
  5348. 2594 AS operationNameEntryId,
  5349. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  5350. operationNameNum,
  5351. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  5352. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  5353. 2973 AS operationTimeEntryId,
  5354. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  5355. operationTimeNum,
  5356. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  5357. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  5358. 2930 AS operation15MinuteEntryId,
  5359. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  5360. operation15MinuteNum,
  5361. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  5362. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  5363. 2419 AS crisisEntryId,
  5364. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  5365. crisisMRNum,
  5366. crisisNum,
  5367. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  5368. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  5369. 2495 AS stageSummaryEntryId,
  5370. '无阶段小结' AS stageSummaryEntryName,
  5371. stageSummaryMRNum,
  5372. stageSummaryNum,
  5373. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  5374. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  5375. beHosGT31DaysMRNum
  5376. FROM
  5377. (
  5378. SELECT
  5379. tt.deptId,
  5380. tt.deptName,
  5381. tt.doctorId,
  5382. tt.doctorName,
  5383. sum( tt.consultationNum ) AS consultationNum,
  5384. sum( tt.consultationMRNum ) AS consultationMRNum,
  5385. sum( tt.operationNameNum ) AS operationNameNum,
  5386. sum( tt.operationTimeNum ) AS operationTimeNum,
  5387. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  5388. sum( tt.operationMRNum ) AS operationMRNum,
  5389. sum( tt.crisisNum ) AS crisisNum,
  5390. sum( tt.crisisMRNum ) AS crisisMRNum,
  5391. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  5392. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  5393. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  5394. FROM
  5395. (
  5396. (
  5397. SELECT
  5398. c.beh_dept_id AS deptId,
  5399. c.beh_dept_name AS deptName,
  5400. c.doctorId,
  5401. c.doctorName,
  5402. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  5403. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  5404. 0 AS operationNameNum,
  5405. 0 AS operationTimeNum,
  5406. 0 AS operation15MinuteNum,
  5407. 0 AS operationMRNum,
  5408. 0 AS crisisNum,
  5409. 0 AS crisisMRNum,
  5410. 0 AS stageSummaryNum,
  5411. 0 AS stageSummaryMRNum,
  5412. 0 AS beHosGT31DaysMRNum
  5413. FROM
  5414. (
  5415. SELECT DISTINCT
  5416. a.hospital_id,
  5417. a.behospital_code,
  5418. a.beh_dept_name,
  5419. a.beh_dept_id,
  5420. a.doctor_id as doctorId,
  5421. a.doctor_name as doctorName
  5422. FROM
  5423. med_behospital_info a,
  5424. med_medical_record b,
  5425. sys_user_dept c
  5426. WHERE
  5427. a.is_deleted = 'N'
  5428. AND b.is_deleted = 'N'
  5429. AND c.is_deleted = 'N'
  5430. AND a.hospital_id = b.hospital_id
  5431. AND a.hospital_id = c.hospital_id
  5432. AND a.behospital_code = b.behospital_code
  5433. AND a.beh_dept_id = c.dept_id
  5434. AND b.mode_id = 30
  5435. <if test="userId!=null">
  5436. AND c.user_id = #{userId}
  5437. </if>
  5438. <if test="isPlacefile != null and isPlacefile != ''">
  5439. and a.is_placefile = #{isPlacefile}
  5440. </if>
  5441. AND a.qc_type_id != 0
  5442. <if test="hospitalId != null and hospitalId != ''">
  5443. AND a.hospital_id = #{hospitalId}
  5444. </if>
  5445. <if test="isPlacefile != null and isPlacefile == 0">
  5446. <if test="startDate != null ">
  5447. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5448. </if>
  5449. <if test="endDate != null ">
  5450. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5451. </if>
  5452. </if>
  5453. <if test="isPlacefile != null and isPlacefile == 1">
  5454. <if test="startDate != null ">
  5455. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5456. </if>
  5457. <if test="endDate != null ">
  5458. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5459. </if>
  5460. </if>
  5461. <if test="deptName != null and deptName != ''">
  5462. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5463. </if>
  5464. ) c
  5465. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5466. AND c.hospital_id = d.hospital_id
  5467. AND c.behospital_code = d.behospital_code
  5468. GROUP BY
  5469. c.doctorId,
  5470. c.doctorName
  5471. ) UNION
  5472. (
  5473. SELECT
  5474. d.beh_dept_id AS deptId,
  5475. d.beh_dept_name AS deptName,
  5476. d.doctor_id as doctorId,
  5477. d.doctor_name as doctorName,
  5478. 0 AS consultationNum,
  5479. 0 AS consultationMRNum,
  5480. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  5481. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  5482. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  5483. count( DISTINCT d.behospital_code ) AS operationMRNum,
  5484. 0 AS crisisNum,
  5485. 0 AS crisisMRNum,
  5486. 0 AS stageSummaryNum,
  5487. 0 AS stageSummaryMRNum,
  5488. 0 AS beHosGT31DaysMRNum
  5489. FROM
  5490. (
  5491. SELECT DISTINCT
  5492. a.hospital_id,
  5493. a.behospital_code,
  5494. a.beh_dept_name,
  5495. a.beh_dept_id,
  5496. a.doctor_id,
  5497. a.doctor_name
  5498. FROM
  5499. med_behospital_info a,
  5500. med_home_page b,
  5501. med_home_operation_info c,
  5502. sys_user_dept d
  5503. WHERE
  5504. a.is_deleted = 'N'
  5505. AND b.is_deleted = 'N'
  5506. AND c.is_deleted = 'N'
  5507. AND d.is_deleted = 'N'
  5508. AND a.hospital_id = b.hospital_id
  5509. AND a.hospital_id = c.hospital_id
  5510. AND a.hospital_id = d.hospital_id
  5511. AND a.behospital_code = b.behospital_code
  5512. AND b.home_page_id = c.home_page_id
  5513. AND a.beh_dept_id = d.dept_id
  5514. <if test="userId!=null">
  5515. AND d.user_id = #{userId}
  5516. </if>
  5517. <if test="isPlacefile != null and isPlacefile != ''">
  5518. and a.is_placefile = #{isPlacefile}
  5519. </if>
  5520. AND a.qc_type_id != 0
  5521. <if test="hospitalId != null and hospitalId != ''">
  5522. AND a.hospital_id = #{hospitalId}
  5523. </if>
  5524. <if test="isPlacefile != null and isPlacefile == 0">
  5525. <if test="startDate != null ">
  5526. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5527. </if>
  5528. <if test="endDate != null ">
  5529. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5530. </if>
  5531. </if>
  5532. <if test="isPlacefile != null and isPlacefile == 1">
  5533. <if test="startDate != null ">
  5534. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5535. </if>
  5536. <if test="endDate != null ">
  5537. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5538. </if>
  5539. </if>
  5540. <if test="deptName != null and deptName != ''">
  5541. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5542. </if>
  5543. ) d
  5544. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  5545. AND d.hospital_id = e.hospital_id
  5546. AND d.behospital_code = e.behospital_code
  5547. GROUP BY
  5548. d.doctor_id,
  5549. d.doctor_name
  5550. ) UNION
  5551. (
  5552. SELECT
  5553. c.beh_dept_id AS deptId,
  5554. c.beh_dept_name AS deptName,
  5555. c.doctor_id as doctorId,
  5556. c.doctor_name as doctorName,
  5557. 0 AS consultationNum,
  5558. 0 AS consultationMRNum,
  5559. 0 AS operationNameNum,
  5560. 0 AS operationTimeNum,
  5561. 0 AS operation15MinuteNum,
  5562. 0 AS operationMRNum,
  5563. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  5564. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  5565. 0 AS stageSummaryNum,
  5566. 0 AS stageSummaryMRNum,
  5567. 0 AS beHosGT31DaysMRNum
  5568. FROM
  5569. (
  5570. SELECT DISTINCT
  5571. a.hospital_id,
  5572. a.behospital_code,
  5573. a.beh_dept_name,
  5574. a.beh_dept_id,
  5575. a.doctor_id,
  5576. a.doctor_name
  5577. FROM
  5578. med_behospital_info a,
  5579. med_crisis_info b,
  5580. sys_user_dept c
  5581. WHERE
  5582. a.is_deleted = 'N'
  5583. AND b.is_deleted = 'N'
  5584. AND c.is_deleted = 'N'
  5585. AND a.hospital_id = b.hospital_id
  5586. AND a.hospital_id = c.hospital_id
  5587. AND a.behospital_code = b.behospital_code
  5588. AND a.beh_dept_id = c.dept_id
  5589. <if test="userId!=null">
  5590. AND c.user_id = #{userId}
  5591. </if>
  5592. <if test="isPlacefile != null and isPlacefile != ''">
  5593. and a.is_placefile = #{isPlacefile}
  5594. </if>
  5595. AND a.qc_type_id != 0
  5596. <if test="hospitalId != null and hospitalId != ''">
  5597. AND a.hospital_id = #{hospitalId}
  5598. </if>
  5599. <if test="isPlacefile != null and isPlacefile == 0">
  5600. <if test="startDate != null ">
  5601. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5602. </if>
  5603. <if test="endDate != null ">
  5604. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5605. </if>
  5606. </if>
  5607. <if test="isPlacefile != null and isPlacefile == 1">
  5608. <if test="startDate != null ">
  5609. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5610. </if>
  5611. <if test="endDate != null ">
  5612. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5613. </if>
  5614. </if>
  5615. <if test="deptName != null and deptName != ''">
  5616. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5617. </if>
  5618. ) c
  5619. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5620. AND c.hospital_id = d.hospital_id
  5621. AND c.behospital_code = d.behospital_code
  5622. GROUP BY
  5623. c.doctor_id,
  5624. c.doctor_name
  5625. ) UNION
  5626. (
  5627. SELECT
  5628. b.beh_dept_id AS deptId,
  5629. b.beh_dept_name AS deptName,
  5630. b.doctor_id as doctorId,
  5631. b.doctor_name as doctorName,
  5632. 0 AS consultationNum,
  5633. 0 AS consultationMRNum,
  5634. 0 AS operationNameNum,
  5635. 0 AS operationTimeNum,
  5636. 0 AS operation15MinuteNum,
  5637. 0 AS operationMRNum,
  5638. 0 AS crisisNum,
  5639. 0 AS crisisMRNum,
  5640. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  5641. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  5642. 0 AS beHosGT31DaysMRNum
  5643. FROM
  5644. (
  5645. SELECT DISTINCT
  5646. a.hospital_id,
  5647. a.behospital_code,
  5648. a.beh_dept_name,
  5649. a.beh_dept_id,
  5650. a.doctor_id,
  5651. a.doctor_name
  5652. FROM
  5653. med_behospital_info a,
  5654. sys_user_dept b
  5655. WHERE
  5656. a.is_deleted = 'N'
  5657. AND b.is_deleted = 'N'
  5658. AND a.hospital_id = b.hospital_id
  5659. AND a.beh_dept_id = b.dept_id
  5660. AND TIMESTAMPDIFF(
  5661. DAY,
  5662. DATE( behospital_date ),
  5663. DATE( leave_hospital_date ))> 30
  5664. <if test="userId!=null">
  5665. AND b.user_id = #{userId}
  5666. </if>
  5667. <if test="isPlacefile != null and isPlacefile != ''">
  5668. and a.is_placefile = #{isPlacefile}
  5669. </if>
  5670. AND a.qc_type_id != 0
  5671. <if test="hospitalId != null and hospitalId != ''">
  5672. AND a.hospital_id = #{hospitalId}
  5673. </if>
  5674. <if test="isPlacefile != null and isPlacefile == 0">
  5675. <if test="startDate != null ">
  5676. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5677. </if>
  5678. <if test="endDate != null ">
  5679. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5680. </if>
  5681. </if>
  5682. <if test="isPlacefile != null and isPlacefile == 1">
  5683. <if test="startDate != null ">
  5684. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5685. </if>
  5686. <if test="endDate != null ">
  5687. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5688. </if>
  5689. </if>
  5690. <if test="deptName != null and deptName != ''">
  5691. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5692. </if>
  5693. ) b
  5694. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  5695. AND b.hospital_id = c.hospital_id
  5696. AND b.behospital_code = c.behospital_code
  5697. GROUP BY
  5698. b.doctor_id,
  5699. b.doctor_name
  5700. ) UNION
  5701. (
  5702. SELECT
  5703. b.beh_dept_id AS deptId,
  5704. b.beh_dept_name AS deptName,
  5705. b.doctor_id as doctorId,
  5706. b.doctor_name as doctorName,
  5707. 0 AS consultationNum,
  5708. 0 AS consultationMRNum,
  5709. 0 AS operationNameNum,
  5710. 0 AS operationTimeNum,
  5711. 0 AS operation15MinuteNum,
  5712. 0 AS operationMRNum,
  5713. 0 AS crisisNum,
  5714. 0 AS crisisMRNum,
  5715. 0 AS stageSummaryNum,
  5716. 0 AS stageSummaryMRNum,
  5717. count(*) AS beHosGT31DaysMRNum
  5718. FROM
  5719. (
  5720. SELECT DISTINCT
  5721. a.hospital_id,
  5722. a.behospital_code,
  5723. a.beh_dept_name,
  5724. a.beh_dept_id,
  5725. a.doctor_id,
  5726. a.doctor_name
  5727. FROM
  5728. med_behospital_info a,
  5729. sys_user_dept b
  5730. WHERE
  5731. a.is_deleted = 'N'
  5732. AND b.is_deleted = 'N'
  5733. AND a.hospital_id = b.hospital_id
  5734. AND a.beh_dept_id = b.dept_id
  5735. AND TIMESTAMPDIFF(
  5736. DAY,
  5737. DATE( behospital_date ),
  5738. DATE( leave_hospital_date ))> 31
  5739. <if test="userId!=null">
  5740. AND b.user_id = #{userId}
  5741. </if>
  5742. <if test="isPlacefile != null and isPlacefile != ''">
  5743. and a.is_placefile = #{isPlacefile}
  5744. </if>
  5745. AND a.qc_type_id != 0
  5746. <if test="hospitalId != null and hospitalId != ''">
  5747. AND a.hospital_id = #{hospitalId}
  5748. </if>
  5749. <if test="isPlacefile != null and isPlacefile == 0">
  5750. <if test="startDate != null ">
  5751. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5752. </if>
  5753. <if test="endDate != null ">
  5754. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5755. </if>
  5756. </if>
  5757. <if test="isPlacefile != null and isPlacefile == 1">
  5758. <if test="startDate != null ">
  5759. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5760. </if>
  5761. <if test="endDate != null ">
  5762. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5763. </if>
  5764. </if>
  5765. <if test="deptName != null and deptName != ''">
  5766. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5767. </if>
  5768. ) b
  5769. GROUP BY
  5770. b.doctor_id,
  5771. b.doctor_name
  5772. )
  5773. ) tt
  5774. GROUP BY
  5775. tt.doctorName
  5776. ) t
  5777. <if test="asc != null and asc !=''">
  5778. order by
  5779. <choose>
  5780. <when test='asc=="deptId"'>deptId asc</when>
  5781. <when test='asc=="deptName"'>deptName asc</when>
  5782. <when test='asc=="doctorName"'>doctorName asc</when>
  5783. <when test='asc=="consultationNum"'>consultationNum asc</when>
  5784. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  5785. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  5786. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  5787. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  5788. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  5789. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  5790. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  5791. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  5792. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  5793. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  5794. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  5795. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  5796. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  5797. <when test='asc=="crisisNum"'>crisisNum asc</when>
  5798. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  5799. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  5800. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  5801. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  5802. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  5803. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  5804. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  5805. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  5806. <otherwise>doctorName asc</otherwise>
  5807. </choose>
  5808. </if>
  5809. <if test="desc != null and desc!=''">
  5810. order by
  5811. <choose>
  5812. <when test='desc=="deptId"'>deptId desc</when>
  5813. <when test='desc=="doctorName"'>doctorName desc</when>
  5814. <when test='desc=="deptName"'>deptName desc</when>
  5815. <when test='desc=="consultationNum"'>consultationNum desc</when>
  5816. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  5817. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  5818. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  5819. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  5820. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  5821. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  5822. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  5823. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  5824. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  5825. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  5826. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  5827. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  5828. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  5829. <when test='desc=="crisisNum"'>crisisNum desc</when>
  5830. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  5831. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  5832. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  5833. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  5834. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  5835. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  5836. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  5837. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  5838. <otherwise>doctorName desc</otherwise>
  5839. </choose>
  5840. </if>
  5841. </select>
  5842. <!-- 非医嘱离院病人记录-->
  5843. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  5844. SELECT
  5845. count(*)
  5846. FROM
  5847. med_behospital_info a,
  5848. med_home_page b
  5849. WHERE
  5850. a.is_deleted = 'N'
  5851. AND b.is_deleted = 'N'
  5852. AND a.hospital_id = b.hospital_id
  5853. AND a.behospital_code = b.behospital_code
  5854. AND b.leave_hospital_type = '非医嘱离院'
  5855. <if test="isPlacefile != null and isPlacefile != ''">
  5856. and a.is_placefile = #{isPlacefile}
  5857. </if>
  5858. AND a.qc_type_id != 0
  5859. <if test="hospitalId != null and hospitalId != ''">
  5860. AND a.hospital_id = #{hospitalId}
  5861. </if>
  5862. <if test="isPlacefile != null and isPlacefile == 0">
  5863. <if test="startDate != null and startDate != ''">
  5864. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5865. </if>
  5866. <if test="endDate != null and endDate != ''">
  5867. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5868. </if>
  5869. </if>
  5870. <if test="isPlacefile != null and isPlacefile == 1">
  5871. <if test="startDate != null and startDate != ''">
  5872. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5873. </if>
  5874. <if test="endDate != null and endDate != ''">
  5875. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5876. </if>
  5877. </if>
  5878. </select>
  5879. <!-- 31天内再入院记录-->
  5880. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  5881. SELECT
  5882. count(*)
  5883. FROM
  5884. (
  5885. SELECT
  5886. r1.file_code,
  5887. r1.diagnose,
  5888. r1.behospital_code AS behospitalCode,
  5889. r1.behospital_date AS behospitalDate,
  5890. r1.leave_hospital_date AS leaveHospitalDate,
  5891. r2.behospital_code AS lastBehospitalCode,
  5892. r2.behospital_date AS lastBehospitalDate,
  5893. r2.leave_hospital_date AS lastLeaveHospitalDate,
  5894. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  5895. FROM
  5896. (
  5897. SELECT
  5898. ( @rownum := @rownum + 1 ) AS rownum,
  5899. t1.file_code,
  5900. t1.diagnose,
  5901. t1.behospital_code,
  5902. t1.behospital_date,
  5903. t1.leave_hospital_date
  5904. FROM
  5905. (
  5906. SELECT
  5907. tt1.file_code,
  5908. tt1.diagnose,
  5909. tt2.behospital_code,
  5910. tt2.behospital_date,
  5911. tt2.leave_hospital_date
  5912. FROM
  5913. (
  5914. SELECT
  5915. a.file_code,
  5916. a.diagnose
  5917. FROM
  5918. med_behospital_info a
  5919. WHERE
  5920. a.is_deleted = 'N'
  5921. <if test="isPlacefile != null and isPlacefile != ''">
  5922. and a.is_placefile = #{isPlacefile}
  5923. </if>
  5924. AND a.qc_type_id != 0
  5925. AND IFNULL( a.diagnose, '' )!= ''
  5926. AND IFNULL( a.file_code, '' )!= ''
  5927. <if test="hospitalId != null and hospitalId != ''">
  5928. AND a.hospital_id = #{hospitalId}
  5929. </if>
  5930. <if test="isPlacefile != null and isPlacefile == 0">
  5931. <if test="startDate != null and startDate != ''">
  5932. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5933. </if>
  5934. <if test="endDate != null and endDate != ''">
  5935. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5936. </if>
  5937. </if>
  5938. <if test="isPlacefile != null and isPlacefile == 1">
  5939. <if test="startDate != null and startDate != ''">
  5940. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5941. </if>
  5942. <if test="endDate != null and endDate != ''">
  5943. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5944. </if>
  5945. </if>
  5946. GROUP BY
  5947. a.file_code,
  5948. a.diagnose
  5949. HAVING
  5950. count(*)> 1
  5951. ) tt1,
  5952. med_behospital_info tt2
  5953. WHERE
  5954. tt2.is_deleted = 'N'
  5955. <if test="isPlacefile != null and isPlacefile != ''">
  5956. and tt2.is_placefile = #{isPlacefile}
  5957. </if>
  5958. AND tt2.qc_type_id != 0
  5959. AND tt1.file_code = tt2.file_code
  5960. AND tt1.diagnose = tt2.diagnose
  5961. <if test="hospitalId != null and hospitalId != ''">
  5962. AND tt2.hospital_id = #{hospitalId}
  5963. </if>
  5964. <if test="isPlacefile != null and isPlacefile == 0">
  5965. <if test="startDate != null and startDate != ''">
  5966. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  5967. </if>
  5968. <if test="endDate != null and endDate != ''">
  5969. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  5970. </if>
  5971. </if>
  5972. <if test="isPlacefile != null and isPlacefile == 1">
  5973. <if test="startDate != null and startDate != ''">
  5974. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  5975. </if>
  5976. <if test="endDate != null and endDate != ''">
  5977. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  5978. </if>
  5979. </if>
  5980. ORDER BY
  5981. tt1.file_code,
  5982. tt1.diagnose,
  5983. tt2.behospital_date DESC
  5984. ) t1,
  5985. ( SELECT @rownum := 0 ) r
  5986. ) r1
  5987. LEFT JOIN (
  5988. SELECT
  5989. ( @INDEX := @INDEX + 1 ) AS rownum,
  5990. t2.file_code,
  5991. t2.diagnose,
  5992. t2.behospital_code,
  5993. t2.behospital_date,
  5994. t2.leave_hospital_date
  5995. FROM
  5996. (
  5997. SELECT
  5998. tt1.file_code,
  5999. tt1.diagnose,
  6000. tt2.behospital_code,
  6001. tt2.behospital_date,
  6002. tt2.leave_hospital_date
  6003. FROM
  6004. (
  6005. SELECT
  6006. a.file_code,
  6007. a.diagnose
  6008. FROM
  6009. med_behospital_info a
  6010. WHERE
  6011. a.is_deleted = 'N'
  6012. <if test="isPlacefile != null and isPlacefile != ''">
  6013. and a.is_placefile = #{isPlacefile}
  6014. </if>
  6015. AND a.qc_type_id != 0
  6016. AND IFNULL( a.diagnose, '' )!= ''
  6017. AND IFNULL( a.file_code, '' )!= ''
  6018. <if test="hospitalId != null and hospitalId != ''">
  6019. AND a.hospital_id = #{hospitalId}
  6020. </if>
  6021. <if test="isPlacefile != null and isPlacefile == 0">
  6022. <if test="startDate != null and startDate != ''">
  6023. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6024. </if>
  6025. <if test="endDate != null and endDate != ''">
  6026. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6027. </if>
  6028. </if>
  6029. <if test="isPlacefile != null and isPlacefile == 1">
  6030. <if test="startDate != null and startDate != ''">
  6031. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6032. </if>
  6033. <if test="endDate != null and endDate != ''">
  6034. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6035. </if>
  6036. </if>
  6037. GROUP BY
  6038. a.file_code,
  6039. a.diagnose
  6040. HAVING
  6041. count(*)> 1
  6042. ) tt1,
  6043. med_behospital_info tt2
  6044. WHERE
  6045. tt2.is_deleted = 'N'
  6046. <if test="isPlacefile != null and isPlacefile != ''">
  6047. and tt2.is_placefile = #{isPlacefile}
  6048. </if>
  6049. AND tt2.qc_type_id != 0
  6050. AND tt1.file_code = tt2.file_code
  6051. AND tt1.diagnose = tt2.diagnose
  6052. <if test="hospitalId != null and hospitalId != ''">
  6053. AND tt2.hospital_id = #{hospitalId}
  6054. </if>
  6055. <if test="isPlacefile != null and isPlacefile == 0">
  6056. <if test="startDate != null and startDate != ''">
  6057. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6058. </if>
  6059. <if test="endDate != null and endDate != ''">
  6060. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6061. </if>
  6062. </if>
  6063. <if test="isPlacefile != null and isPlacefile == 1">
  6064. <if test="startDate != null and startDate != ''">
  6065. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6066. </if>
  6067. <if test="endDate != null and endDate != ''">
  6068. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6069. </if>
  6070. </if>
  6071. ORDER BY
  6072. tt1.file_code,
  6073. tt1.diagnose,
  6074. tt2.behospital_date DESC
  6075. ) t2,(
  6076. SELECT
  6077. @INDEX := 0
  6078. ) r
  6079. ) r2 ON r1.file_code = r2.file_code
  6080. AND r1.rownum = r2.rownum - 1
  6081. ) t
  6082. WHERE
  6083. t.diffDays IS NOT NULL
  6084. AND t.diffDays BETWEEN 0
  6085. AND 31
  6086. </select>
  6087. <!-- 病案首页质控病历数统计-全院(首页)-->
  6088. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  6089. SELECT
  6090. count( * ) AS mrNum,
  6091. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  6092. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  6093. SUM( c.`level` = '合格' ) AS firstLevelNum,
  6094. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  6095. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  6096. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  6097. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  6098. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  6099. FROM
  6100. med_behospital_info a,
  6101. med_qcresult_cases c
  6102. WHERE
  6103. a.is_deleted = 'N'
  6104. AND c.is_deleted = 'N'
  6105. AND a.hospital_id = c.hospital_id
  6106. AND a.behospital_code = c.behospital_code
  6107. AND c.cases_id = 243
  6108. <if test="isPlacefile != null and isPlacefile != ''">
  6109. and a.is_placefile = #{isPlacefile}
  6110. </if>
  6111. AND a.qc_type_id != 0
  6112. <if test="hospitalId != null and hospitalId != ''">
  6113. AND a.hospital_id = #{hospitalId}
  6114. </if>
  6115. <if test="isPlacefile != null and isPlacefile == 0">
  6116. <if test="startDate != null and startDate != ''">
  6117. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6118. </if>
  6119. <if test="endDate != null and endDate != ''">
  6120. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6121. </if>
  6122. </if>
  6123. <if test="isPlacefile != null and isPlacefile == 1">
  6124. <if test="startDate != null and startDate != ''">
  6125. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6126. </if>
  6127. <if test="endDate != null and endDate != ''">
  6128. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6129. </if>
  6130. </if>
  6131. </select>
  6132. <!-- 病案首页完整率统计-全院(首页)-->
  6133. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  6134. SELECT
  6135. h1.emptyNum,
  6136. h1.mrNum,
  6137. h2.entryNum,
  6138. h1.mrNum * h2.entryNum AS entryTotleNum,
  6139. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  6140. CONCAT(
  6141. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  6142. '%'
  6143. ) AS emptyPercentStr
  6144. FROM
  6145. (
  6146. SELECT
  6147. sum( d.rule_type = 1 ) AS emptyNum,
  6148. count( DISTINCT a.behospital_code ) AS mrNum
  6149. FROM
  6150. med_behospital_info a,
  6151. med_qcresult_cases b,
  6152. med_qcresult_detail c,
  6153. qc_cases_entry d
  6154. WHERE
  6155. a.is_deleted = 'N'
  6156. AND b.is_deleted = 'N'
  6157. AND c.is_deleted = 'N'
  6158. AND d.is_deleted = 'N'
  6159. AND a.hospital_id = b.hospital_id
  6160. AND a.hospital_id = c.hospital_id
  6161. AND a.behospital_code = b.behospital_code
  6162. AND a.behospital_code = c.behospital_code
  6163. AND b.cases_id = c.cases_id
  6164. AND c.cases_id = d.cases_id
  6165. AND c.cases_entry_id = d.id
  6166. <if test="isPlacefile != null and isPlacefile != ''">
  6167. and a.is_placefile = #{isPlacefile}
  6168. </if>
  6169. AND d.cases_id = 243
  6170. AND a.qc_type_id != 0
  6171. <if test="hospitalId != null and hospitalId != ''">
  6172. AND a.hospital_id = #{hospitalId}
  6173. </if>
  6174. <if test="isPlacefile != null and isPlacefile == 0">
  6175. <if test="startDate != null and startDate != ''">
  6176. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6177. </if>
  6178. <if test="endDate != null and endDate != ''">
  6179. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6180. </if>
  6181. </if>
  6182. <if test="isPlacefile != null and isPlacefile == 1">
  6183. <if test="startDate != null and startDate != ''">
  6184. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6185. </if>
  6186. <if test="endDate != null and endDate != ''">
  6187. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6188. </if>
  6189. </if>
  6190. ) h1,(
  6191. SELECT
  6192. count(*) AS entryNum
  6193. FROM
  6194. qc_cases_entry
  6195. WHERE
  6196. is_deleted = 'N'
  6197. AND cases_id = 243
  6198. ) h2
  6199. </select>
  6200. <!-- 离院病人评分详情页-->
  6201. <select id="getAge" resultType="java.util.Map">
  6202. SELECT
  6203. a.behospital_code as behospitalCode,
  6204. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  6205. FROM
  6206. med_home_page a
  6207. WHERE
  6208. a.is_deleted = 'N'
  6209. AND a.hospital_id = #{hospitalId}
  6210. AND a.behospital_code IN
  6211. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  6212. '${item}'
  6213. </foreach>
  6214. </select>
  6215. <!-- 离院病人评分详情页-->
  6216. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  6217. SELECT
  6218. t.*
  6219. FROM
  6220. (SELECT DISTINCT
  6221. t1.hospital_id AS hospitalId,
  6222. t1.behospital_code AS behospitalCode,
  6223. t1.bed_code AS bedCode,
  6224. t1.LEVEL AS LEVEL,
  6225. t1.grade_type AS gradeType,
  6226. t1.score_res AS scoreRes,
  6227. t1.scoreBn,
  6228. t1.NAME AS NAME,
  6229. t1.sex AS sex,
  6230. t1.beh_dept_id AS behDeptId,
  6231. t1.beh_dept_name AS behDeptName,
  6232. t1.doctor_id AS doctorId,
  6233. t1.doctor_name AS doctorName,
  6234. t1.beh_doctor_id AS behDoctorId,
  6235. t1.beh_doctor_name AS behDoctorName,
  6236. t1.director_doctor_id AS directorDoctorId,
  6237. t1.director_doctor_name AS directorDoctorName,
  6238. t1.birthday AS birthday,
  6239. t1.behospital_date AS behospitalDate,
  6240. t1.leave_hospital_date AS leaveHospitalDate,
  6241. t1.placefile_date AS placefileDate,
  6242. t1.gmt_create AS gradeTime,
  6243. t1.diagnose,
  6244. t1.ward_name AS wardName,
  6245. t1.checkStatus,
  6246. t1.mrStatus,
  6247. t1.chName,
  6248. t1.mrName,
  6249. t1.chTime,
  6250. t1.mrTime,
  6251. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  6252. t1.file_code AS fileCode
  6253. FROM
  6254. (
  6255. SELECT be.*,
  6256. ifnull(mci.status,0) AS checkStatus,
  6257. ifnull(hm_mci.status,0) AS mrStatus,
  6258. mci.check_name as chName,
  6259. e.score_res as scoreBn,
  6260. hm_mci.check_name as mrName,
  6261. mci.gmt_create as chTime,
  6262. hm_mci.gmt_create as mrTime
  6263. FROM
  6264. (
  6265. SELECT DISTINCT
  6266. tt1.*
  6267. FROM
  6268. (
  6269. SELECT
  6270. b.*,
  6271. ifnull(c.LEVEL,'未评分') as LEVEL ,
  6272. c.grade_type,
  6273. c.score_res,
  6274. c.gmt_create
  6275. FROM
  6276. (
  6277. SELECT DISTINCT
  6278. a.hospital_id,
  6279. a.behospital_code,
  6280. a.bed_code,
  6281. a.NAME,
  6282. a.sex,
  6283. a.beh_dept_id,
  6284. a.beh_dept_name,
  6285. a.birthday,
  6286. a.behospital_date,
  6287. a.leave_hospital_date,
  6288. a.doctor_id,
  6289. a.doctor_name,
  6290. a.beh_doctor_id,
  6291. a.beh_doctor_name,
  6292. a.director_doctor_id,
  6293. a.director_doctor_name,
  6294. a.diagnose,
  6295. a.placefile_date,
  6296. a.ward_name,
  6297. a.file_code
  6298. FROM
  6299. med_behospital_info a
  6300. WHERE
  6301. a.is_deleted = 'N'
  6302. AND a.qc_type_id != 0
  6303. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6304. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6305. </if>
  6306. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6307. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6308. </if>
  6309. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  6310. <if test="qcResultShortPageVO.startDate != null ">
  6311. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  6312. </if>
  6313. <if test="qcResultShortPageVO.endDate != null ">
  6314. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  6315. </if>
  6316. </if>
  6317. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  6318. <if test="qcResultShortPageVO.startDate != null ">
  6319. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6320. </if>
  6321. <if test="qcResultShortPageVO.endDate != null">
  6322. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6323. </if>
  6324. </if>
  6325. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  6326. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  6327. </if>
  6328. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  6329. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  6330. </if>
  6331. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6332. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6333. </if>
  6334. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6335. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6336. </if>
  6337. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6338. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6339. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6340. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  6341. </if>
  6342. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6343. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6344. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6345. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  6346. </if>
  6347. ) b
  6348. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  6349. AND b.hospital_id = c.hospital_id
  6350. AND b.behospital_code = c.behospital_code
  6351. ) tt1
  6352. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  6353. ,med_medical_record tt2,
  6354. qc_mode tt3
  6355. WHERE
  6356. tt2.is_deleted = 'N'
  6357. AND tt3.is_deleted = 'N'
  6358. AND tt1.hospital_id = tt2.hospital_id
  6359. AND tt1.behospital_code = tt2.behospital_code
  6360. AND tt2.mode_id = tt3.id
  6361. AND tt3.`name` = '手术记录'
  6362. </if>
  6363. ) be
  6364. left join med_check_info mci
  6365. on mci.is_deleted = 'N'
  6366. and mci.check_type = 0
  6367. and be.hospital_id = mci.hospital_id
  6368. and be.behospital_code = mci.behospital_code
  6369. left join med_check_info hm_mci
  6370. on hm_mci.is_deleted = 'N'
  6371. and hm_mci.check_type = 1
  6372. and be.hospital_id = hm_mci.hospital_id
  6373. and be.behospital_code = hm_mci.behospital_code
  6374. LEFT JOIN med_qcresult_cases e
  6375. on be.behospital_code = e.behospital_code
  6376. and be.hospital_id = e.hospital_id
  6377. AND e.is_deleted = 'N'
  6378. and e.cases_id = 243
  6379. )t1
  6380. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  6381. ,med_home_page t2
  6382. WHERE
  6383. t2.is_deleted = 'N'
  6384. AND t1.hospital_id = t2.hospital_id
  6385. AND t1.behospital_code = t2.behospital_code
  6386. AND (
  6387. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  6388. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  6389. )
  6390. </if>
  6391. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  6392. , med_medical_record b,
  6393. med_medical_record_content c,
  6394. med_home_page t2
  6395. WHERE
  6396. b.is_deleted = 'N'
  6397. and c.is_deleted = 'N'
  6398. and t2.is_deleted = 'N'
  6399. and t1.hospital_id = b.hospital_id
  6400. and t1.hospital_id = c.hospital_id
  6401. and t1.hospital_id = t2.hospital_id
  6402. AND t1.behospital_code = b.behospital_code
  6403. AND t1.behospital_code = t2.behospital_code
  6404. AND b.rec_id = c.rec_id
  6405. and b.mode_id = '24'
  6406. </if>
  6407. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  6408. ,med_home_page t2
  6409. WHERE
  6410. t2.is_deleted = 'N'
  6411. AND t1.hospital_id = t2.hospital_id
  6412. AND t1.behospital_code = t2.behospital_code
  6413. AND t2.leave_hospital_type = '非医嘱离院'
  6414. </if>
  6415. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  6416. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  6417. AND t1.hospital_id = t2.hospital_id
  6418. AND t1.behospital_code = t2.behospital_code
  6419. </if>
  6420. )t
  6421. where 1=1
  6422. <if test="qcResultShortPageVO.checkStatus != null">
  6423. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6424. </if>
  6425. <if test="qcResultShortPageVO.mrStatus != null">
  6426. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6427. </if>
  6428. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6429. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6430. </if>
  6431. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6432. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6433. </if>
  6434. <if test="qcResultShortPageVO.chTimeStart != null ">
  6435. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6436. </if>
  6437. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6438. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6439. </if>
  6440. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6441. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6442. </if>
  6443. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6444. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6445. </if>
  6446. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6447. AND t.`level` = #{qcResultShortPageVO.level}
  6448. </if>
  6449. </select>
  6450. <!-- 离院病人评分详情页-科室-->
  6451. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  6452. SELECT
  6453. t.*
  6454. FROM
  6455. (SELECT DISTINCT
  6456. t1.hospital_id AS hospitalId,
  6457. t1.behospital_code AS behospitalCode,
  6458. t1.bed_code AS bedCode,
  6459. t1.LEVEL AS LEVEL,
  6460. t1.grade_type AS gradeType,
  6461. t1.score_res AS scoreRes,
  6462. t1.scoreBn,
  6463. t1.NAME AS NAME,
  6464. t1.sex AS sex,
  6465. t1.beh_dept_id AS behDeptId,
  6466. t1.beh_dept_name AS behDeptName,
  6467. t1.doctor_id AS doctorId,
  6468. t1.doctor_name AS doctorName,
  6469. t1.beh_doctor_id AS behDoctorId,
  6470. t1.beh_doctor_name AS behDoctorName,
  6471. t1.director_doctor_id AS directorDoctorId,
  6472. t1.director_doctor_name AS directorDoctorName,
  6473. t1.birthday AS birthday,
  6474. t1.behospital_date AS behospitalDate,
  6475. t1.leave_hospital_date AS leaveHospitalDate,
  6476. t1.placefile_date AS placefileDate,
  6477. t1.gmt_create AS gradeTime,
  6478. t1.diagnose,
  6479. t1.ward_name AS wardName,
  6480. t1.checkStatus,
  6481. t1.mrStatus,
  6482. t1.chName,
  6483. t1.mrName,
  6484. t1.chTime,
  6485. t1.mrTime,
  6486. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  6487. t1.file_code AS fileCode
  6488. FROM
  6489. (
  6490. SELECT be.*,
  6491. ifnull(mci.status,0) AS checkStatus,
  6492. ifnull(hm_mci.status,0) AS mrStatus,
  6493. mci.check_name as chName,
  6494. e.score_res as scoreBn,
  6495. hm_mci.check_name as mrName,
  6496. mci.gmt_create as chTime,
  6497. hm_mci.gmt_create as mrTime
  6498. FROM
  6499. (
  6500. SELECT DISTINCT
  6501. tt1.*
  6502. FROM
  6503. (
  6504. SELECT
  6505. b.*,
  6506. ifnull(c.LEVEL,'未评分') as LEVEL ,
  6507. c.grade_type,
  6508. c.score_res,
  6509. c.gmt_create
  6510. FROM
  6511. (
  6512. SELECT DISTINCT
  6513. a.hospital_id,
  6514. a.behospital_code,
  6515. a.bed_code,
  6516. a.NAME,
  6517. a.sex,
  6518. a.beh_dept_id,
  6519. a.beh_dept_name,
  6520. a.birthday,
  6521. a.behospital_date,
  6522. a.leave_hospital_date,
  6523. a.doctor_id,
  6524. a.doctor_name,
  6525. a.beh_doctor_id,
  6526. a.beh_doctor_name,
  6527. a.director_doctor_id,
  6528. a.director_doctor_name,
  6529. a.diagnose,
  6530. a.placefile_date,
  6531. a.ward_name,
  6532. a.file_code
  6533. FROM
  6534. med_behospital_info a,
  6535. sys_user_dept b
  6536. WHERE
  6537. a.is_deleted = 'N'
  6538. AND b.is_deleted = 'N'
  6539. AND a.hospital_id = b.hospital_id
  6540. AND a.beh_dept_id = b.dept_id
  6541. AND a.qc_type_id != 0
  6542. <if test="qcResultShortPageVO.userId!=null">
  6543. AND b.user_id = #{qcResultShortPageVO.userId}
  6544. </if>
  6545. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6546. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6547. </if>
  6548. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6549. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6550. </if>
  6551. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  6552. <if test="qcResultShortPageVO.startDate != null ">
  6553. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  6554. </if>
  6555. <if test="qcResultShortPageVO.endDate != null ">
  6556. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  6557. </if>
  6558. </if>
  6559. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  6560. <if test="qcResultShortPageVO.startDate != null ">
  6561. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6562. </if>
  6563. <if test="qcResultShortPageVO.endDate != null">
  6564. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6565. </if>
  6566. </if>
  6567. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  6568. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  6569. </if>
  6570. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  6571. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  6572. </if>
  6573. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6574. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6575. </if>
  6576. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6577. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6578. </if>
  6579. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6580. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6581. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6582. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  6583. </if>
  6584. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6585. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6586. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6587. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  6588. </if>
  6589. ) b
  6590. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  6591. AND b.hospital_id = c.hospital_id
  6592. AND b.behospital_code = c.behospital_code
  6593. ) tt1
  6594. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  6595. ,med_medical_record tt2,
  6596. qc_mode tt3
  6597. WHERE
  6598. tt2.is_deleted = 'N'
  6599. AND tt3.is_deleted = 'N'
  6600. AND tt1.hospital_id = tt2.hospital_id
  6601. AND tt1.behospital_code = tt2.behospital_code
  6602. AND tt2.mode_id = tt3.id
  6603. AND tt3.`name` = '手术记录'
  6604. </if>
  6605. ) be
  6606. left join med_check_info mci
  6607. on mci.is_deleted = 'N'
  6608. and mci.check_type = 0
  6609. and be.hospital_id = mci.hospital_id
  6610. and be.behospital_code = mci.behospital_code
  6611. left join med_check_info hm_mci
  6612. on hm_mci.is_deleted = 'N'
  6613. and hm_mci.check_type = 1
  6614. and be.hospital_id = hm_mci.hospital_id
  6615. and be.behospital_code = hm_mci.behospital_code
  6616. LEFT JOIN med_qcresult_cases e
  6617. on be.behospital_code = e.behospital_code
  6618. and be.hospital_id = e.hospital_id
  6619. AND e.is_deleted = 'N'
  6620. and e.cases_id = 243
  6621. )t1
  6622. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  6623. ,med_home_page t2
  6624. WHERE
  6625. t2.is_deleted = 'N'
  6626. AND t1.hospital_id = t2.hospital_id
  6627. AND t1.behospital_code = t2.behospital_code
  6628. AND (
  6629. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  6630. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  6631. )
  6632. </if>
  6633. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  6634. , med_medical_record b,
  6635. med_medical_record_content c,
  6636. med_home_page t2
  6637. WHERE
  6638. b.is_deleted = 'N'
  6639. and c.is_deleted = 'N'
  6640. and t2.is_deleted = 'N'
  6641. and t1.hospital_id = b.hospital_id
  6642. and t1.hospital_id = c.hospital_id
  6643. and t1.hospital_id = t2.hospital_id
  6644. AND t1.behospital_code = b.behospital_code
  6645. AND t1.behospital_code = t2.behospital_code
  6646. AND b.rec_id = c.rec_id
  6647. and b.mode_id = '24'
  6648. </if>
  6649. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  6650. ,med_home_page t2
  6651. WHERE
  6652. t2.is_deleted = 'N'
  6653. AND t1.hospital_id = t2.hospital_id
  6654. AND t1.behospital_code = t2.behospital_code
  6655. AND t2.leave_hospital_type = '非医嘱离院'
  6656. </if>
  6657. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  6658. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  6659. AND t1.hospital_id = t2.hospital_id
  6660. AND t1.behospital_code = t2.behospital_code
  6661. </if>
  6662. )t
  6663. where 1=1
  6664. <if test="qcResultShortPageVO.checkStatus != null">
  6665. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6666. </if>
  6667. <if test="qcResultShortPageVO.mrStatus != null">
  6668. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6669. </if>
  6670. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6671. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6672. </if>
  6673. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6674. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6675. </if>
  6676. <if test="qcResultShortPageVO.chTimeStart != null ">
  6677. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6678. </if>
  6679. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6680. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6681. </if>
  6682. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6683. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6684. </if>
  6685. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6686. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6687. </if>
  6688. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6689. AND t.`level` = #{qcResultShortPageVO.level}
  6690. </if>
  6691. </select>
  6692. <!-- 病案首页改善率统计(首页)-->
  6693. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  6694. SELECT
  6695. t2.homePageMRNum,
  6696. t1.improveNum,
  6697. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  6698. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  6699. t1.improveToPassNum,
  6700. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  6701. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  6702. t1.improveToFullNum,
  6703. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  6704. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  6705. FROM
  6706. (
  6707. SELECT
  6708. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  6709. sum( d.score_res = 20 ) AS improveToFullNum,
  6710. count(*) AS improveNum
  6711. FROM
  6712. med_behospital_info a,
  6713. med_home_page b,
  6714. med_qcresult_info c,
  6715. med_qcresult_cases d,
  6716. (
  6717. SELECT
  6718. m4.*
  6719. FROM
  6720. med_behospital_info m1,
  6721. med_home_page m2,
  6722. med_qcresult_info m3,
  6723. med_qcresult_cases m4
  6724. WHERE
  6725. m1.is_deleted = 'N'
  6726. AND m2.is_deleted = 'N'
  6727. AND m3.is_deleted = 'Y'
  6728. AND m4.is_deleted = 'Y'
  6729. AND m1.hospital_id = m2.hospital_id
  6730. AND m1.hospital_id = m3.hospital_id
  6731. AND m1.hospital_id = m4.hospital_id
  6732. AND m1.behospital_code = m2.behospital_code
  6733. AND m1.behospital_code = m3.behospital_code
  6734. AND m1.behospital_code = m4.behospital_code
  6735. AND m3.gmt_create = m4.gmt_create
  6736. AND m3.have_home_page = 1
  6737. AND m4.cases_id = 243
  6738. <if test="isPlacefile != null and isPlacefile != ''">
  6739. and m1.is_placefile = #{isPlacefile}
  6740. </if>
  6741. AND m1.qc_type_id != 0
  6742. <if test="hospitalId != null and hospitalId != ''">
  6743. AND m1.hospital_id = #{hospitalId}
  6744. </if>
  6745. <if test="isPlacefile != null and isPlacefile == 0">
  6746. <if test="startDate != null and startDate != ''">
  6747. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  6748. </if>
  6749. <if test="endDate != null and endDate != ''">
  6750. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  6751. </if>
  6752. </if>
  6753. <if test="isPlacefile != null and isPlacefile == 1">
  6754. <if test="startDate != null and startDate != ''">
  6755. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  6756. </if>
  6757. <if test="endDate != null and endDate != ''">
  6758. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  6759. </if>
  6760. </if>
  6761. GROUP BY
  6762. m1.behospital_code
  6763. ORDER BY
  6764. m1.behospital_code,
  6765. m4.gmt_create
  6766. ) e
  6767. WHERE
  6768. a.is_deleted = 'N'
  6769. AND b.is_deleted = 'N'
  6770. AND c.is_deleted = 'N'
  6771. AND d.is_deleted = 'N'
  6772. AND a.hospital_id = b.hospital_id
  6773. AND a.hospital_id = c.hospital_id
  6774. AND a.hospital_id = d.hospital_id
  6775. AND a.hospital_id = e.hospital_id
  6776. AND a.behospital_code = b.behospital_code
  6777. AND a.behospital_code = c.behospital_code
  6778. AND a.behospital_code = d.behospital_code
  6779. AND a.behospital_code = e.behospital_code
  6780. AND d.cases_id = 243
  6781. AND d.score_res > e.score_res
  6782. <if test="isPlacefile != null and isPlacefile != ''">
  6783. and a.is_placefile = #{isPlacefile}
  6784. </if>
  6785. AND a.qc_type_id != 0
  6786. <if test="hospitalId != null and hospitalId != ''">
  6787. AND a.hospital_id = #{hospitalId}
  6788. </if>
  6789. <if test="isPlacefile != null and isPlacefile == 0">
  6790. <if test="startDate != null and startDate != ''">
  6791. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6792. </if>
  6793. <if test="endDate != null and endDate != ''">
  6794. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6795. </if>
  6796. </if>
  6797. <if test="isPlacefile != null and isPlacefile == 1">
  6798. <if test="startDate != null and startDate != ''">
  6799. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6800. </if>
  6801. <if test="endDate != null and endDate != ''">
  6802. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6803. </if>
  6804. </if>
  6805. ) t1,
  6806. (
  6807. SELECT
  6808. count( DISTINCT a.behospital_code ) AS homePageMRNum
  6809. FROM
  6810. med_behospital_info a,
  6811. med_home_page b,
  6812. med_qcresult_info c
  6813. WHERE
  6814. a.is_deleted = 'N'
  6815. AND b.is_deleted = 'N'
  6816. AND a.hospital_id = b.hospital_id
  6817. AND a.hospital_id = c.hospital_id
  6818. AND a.behospital_code = b.behospital_code
  6819. AND a.behospital_code = c.behospital_code
  6820. AND a.qc_type_id != 0
  6821. <if test="isPlacefile != null and isPlacefile != ''">
  6822. and a.is_placefile = #{isPlacefile}
  6823. </if>
  6824. <if test="hospitalId != null and hospitalId != ''">
  6825. AND a.hospital_id = #{hospitalId}
  6826. </if>
  6827. <if test="isPlacefile != null and isPlacefile == 0">
  6828. <if test="startDate != null and startDate != ''">
  6829. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6830. </if>
  6831. <if test="endDate != null and endDate != ''">
  6832. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6833. </if>
  6834. </if>
  6835. <if test="isPlacefile != null and isPlacefile == 1">
  6836. <if test="startDate != null and startDate != ''">
  6837. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6838. </if>
  6839. <if test="endDate != null and endDate != ''">
  6840. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6841. </if>
  6842. </if>
  6843. ) t2
  6844. </select>
  6845. <!-- 质控核查统计(内页)-->
  6846. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  6847. SELECT
  6848. t.*
  6849. FROM
  6850. (SELECT
  6851. mr.beh_dept_id AS deptId,
  6852. mr.beh_dept_name AS deptName,
  6853. IFNULL( mr.mrNum, 0 ) AS mrNum,
  6854. ck.checkedNum AS checkedNum,
  6855. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  6856. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  6857. hmmr_t.homePageMRNum,
  6858. improve_t.improveNum,
  6859. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  6860. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  6861. improve_t.improveToPassNum,
  6862. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  6863. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  6864. improve_t.improveToFullNum,
  6865. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  6866. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  6867. FROM
  6868. (
  6869. SELECT
  6870. a.beh_dept_id,
  6871. a.beh_dept_name,
  6872. count(*) AS mrNum
  6873. FROM
  6874. med_behospital_info a,
  6875. med_qcresult_info b
  6876. WHERE
  6877. a.is_deleted = 'N'
  6878. AND b.is_deleted = 'N'
  6879. AND a.hospital_id = b.hospital_id
  6880. AND a.behospital_code = b.behospital_code
  6881. AND a.qc_type_id != 0
  6882. <if test="isPlacefile != null and isPlacefile != ''">
  6883. and a.is_placefile = #{isPlacefile}
  6884. </if>
  6885. <if test="hospitalId != null and hospitalId != ''">
  6886. AND a.hospital_id = #{hospitalId}
  6887. </if>
  6888. <if test="isPlacefile != null and isPlacefile == 0">
  6889. <if test="startDate != null and startDate != ''">
  6890. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6891. </if>
  6892. <if test="endDate != null and endDate != ''">
  6893. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6894. </if>
  6895. </if>
  6896. <if test="isPlacefile != null and isPlacefile == 1">
  6897. <if test="startDate != null and startDate != ''">
  6898. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6899. </if>
  6900. <if test="endDate != null and endDate != ''">
  6901. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6902. </if>
  6903. </if>
  6904. <if test="deptName != null and deptName != ''">
  6905. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6906. </if>
  6907. GROUP BY
  6908. a.beh_dept_id,
  6909. a.beh_dept_name
  6910. ) mr
  6911. LEFT JOIN (
  6912. SELECT
  6913. a.beh_dept_id,
  6914. a.beh_dept_name,
  6915. count(*) AS checkedNum
  6916. FROM
  6917. med_behospital_info a,
  6918. med_qcresult_info b,
  6919. med_check_info c
  6920. WHERE
  6921. a.is_deleted = 'N'
  6922. AND b.is_deleted = 'N'
  6923. AND c.is_deleted = 'N'
  6924. AND a.hospital_id = b.hospital_id
  6925. AND a.hospital_id = c.hospital_id
  6926. AND a.behospital_code = b.behospital_code
  6927. AND a.behospital_code = c.behospital_code
  6928. AND a.qc_type_id != 0
  6929. AND ifnull(c.`status`,0) = 1
  6930. AND c.check_type = 0
  6931. <if test="isPlacefile != null and isPlacefile != ''">
  6932. and a.is_placefile = #{isPlacefile}
  6933. </if>
  6934. <if test="hospitalId != null and hospitalId != ''">
  6935. AND a.hospital_id = #{hospitalId}
  6936. </if>
  6937. <if test="isPlacefile != null and isPlacefile == 0">
  6938. <if test="startDate != null and startDate != ''">
  6939. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6940. </if>
  6941. <if test="endDate != null and endDate != ''">
  6942. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6943. </if>
  6944. </if>
  6945. <if test="isPlacefile != null and isPlacefile == 1">
  6946. <if test="startDate != null and startDate != ''">
  6947. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6948. </if>
  6949. <if test="endDate != null and endDate != ''">
  6950. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6951. </if>
  6952. </if>
  6953. <if test="deptName != null and deptName != ''">
  6954. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6955. </if>
  6956. GROUP BY
  6957. a.beh_dept_id,
  6958. a.beh_dept_name
  6959. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  6960. AND mr.beh_dept_name = ck.beh_dept_name
  6961. LEFT JOIN (
  6962. SELECT
  6963. a.beh_dept_id,
  6964. a.beh_dept_name,
  6965. count( DISTINCT a.behospital_code ) AS homePageMRNum
  6966. FROM
  6967. med_behospital_info a,
  6968. med_home_page b,
  6969. med_qcresult_info c
  6970. WHERE
  6971. a.is_deleted = 'N'
  6972. AND b.is_deleted = 'N'
  6973. AND a.hospital_id = b.hospital_id
  6974. AND a.hospital_id = c.hospital_id
  6975. AND a.behospital_code = b.behospital_code
  6976. AND a.behospital_code = c.behospital_code
  6977. AND a.qc_type_id != 0
  6978. <if test="isPlacefile != null and isPlacefile != ''">
  6979. and a.is_placefile = #{isPlacefile}
  6980. </if>
  6981. <if test="hospitalId != null and hospitalId != ''">
  6982. AND a.hospital_id = #{hospitalId}
  6983. </if>
  6984. <if test="isPlacefile != null and isPlacefile == 0">
  6985. <if test="startDate != null and startDate != ''">
  6986. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6987. </if>
  6988. <if test="endDate != null and endDate != ''">
  6989. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6990. </if>
  6991. </if>
  6992. <if test="isPlacefile != null and isPlacefile == 1">
  6993. <if test="startDate != null and startDate != ''">
  6994. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6995. </if>
  6996. <if test="endDate != null and endDate != ''">
  6997. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6998. </if>
  6999. </if>
  7000. <if test="deptName != null and deptName != ''">
  7001. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7002. </if>
  7003. GROUP BY
  7004. a.beh_dept_id,
  7005. a.beh_dept_name
  7006. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  7007. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  7008. LEFT JOIN (
  7009. SELECT
  7010. a.beh_dept_id,
  7011. a.beh_dept_name,
  7012. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7013. sum( d.score_res = 20 ) AS improveToFullNum,
  7014. count(*) AS improveNum
  7015. FROM
  7016. med_behospital_info a,
  7017. med_home_page b,
  7018. med_qcresult_info c,
  7019. med_qcresult_cases d,
  7020. (
  7021. SELECT
  7022. m4.*
  7023. FROM
  7024. med_behospital_info m1,
  7025. med_home_page m2,
  7026. med_qcresult_info m3,
  7027. med_qcresult_cases m4
  7028. WHERE
  7029. m1.is_deleted = 'N'
  7030. AND m2.is_deleted = 'N'
  7031. AND m3.is_deleted = 'Y'
  7032. AND m4.is_deleted = 'Y'
  7033. AND m1.hospital_id = m2.hospital_id
  7034. AND m1.hospital_id = m3.hospital_id
  7035. AND m1.hospital_id = m4.hospital_id
  7036. AND m1.behospital_code = m2.behospital_code
  7037. AND m1.behospital_code = m3.behospital_code
  7038. AND m1.behospital_code = m4.behospital_code
  7039. AND m3.gmt_create = m4.gmt_create
  7040. AND m3.have_home_page = 1
  7041. AND m4.cases_id = 243
  7042. <if test="isPlacefile != null and isPlacefile != ''">
  7043. and m1.is_placefile = #{isPlacefile}
  7044. </if>
  7045. AND m1.qc_type_id != 0
  7046. <if test="hospitalId != null and hospitalId != ''">
  7047. AND m1.hospital_id = #{hospitalId}
  7048. </if>
  7049. <if test="isPlacefile != null and isPlacefile == 0">
  7050. <if test="startDate != null and startDate != ''">
  7051. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7052. </if>
  7053. <if test="endDate != null and endDate != ''">
  7054. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7055. </if>
  7056. </if>
  7057. <if test="isPlacefile != null and isPlacefile == 1">
  7058. <if test="startDate != null and startDate != ''">
  7059. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7060. </if>
  7061. <if test="endDate != null and endDate != ''">
  7062. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7063. </if>
  7064. </if>
  7065. <if test="deptName != null and deptName != ''">
  7066. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7067. </if>
  7068. GROUP BY
  7069. m1.behospital_code
  7070. ORDER BY
  7071. m1.behospital_code,
  7072. m4.gmt_create
  7073. ) e
  7074. WHERE
  7075. a.is_deleted = 'N'
  7076. AND b.is_deleted = 'N'
  7077. AND c.is_deleted = 'N'
  7078. AND d.is_deleted = 'N'
  7079. AND a.hospital_id = b.hospital_id
  7080. AND a.hospital_id = c.hospital_id
  7081. AND a.hospital_id = d.hospital_id
  7082. AND a.hospital_id = e.hospital_id
  7083. AND a.behospital_code = b.behospital_code
  7084. AND a.behospital_code = c.behospital_code
  7085. AND a.behospital_code = d.behospital_code
  7086. AND a.behospital_code = e.behospital_code
  7087. AND d.cases_id = 243
  7088. AND d.score_res > e.score_res
  7089. <if test="hospitalId != null and hospitalId != ''">
  7090. AND a.hospital_id = #{hospitalId}
  7091. </if>
  7092. <if test="isPlacefile != null and isPlacefile == 0">
  7093. <if test="startDate != null and startDate != ''">
  7094. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7095. </if>
  7096. <if test="endDate != null and endDate != ''">
  7097. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7098. </if>
  7099. </if>
  7100. <if test="isPlacefile != null and isPlacefile == 1">
  7101. <if test="startDate != null and startDate != ''">
  7102. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7103. </if>
  7104. <if test="endDate != null and endDate != ''">
  7105. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7106. </if>
  7107. </if>
  7108. <if test="deptName != null and deptName != ''">
  7109. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7110. </if>
  7111. GROUP BY
  7112. a.beh_dept_id,
  7113. a.beh_dept_name
  7114. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  7115. AND mr.beh_dept_name = improve_t.beh_dept_name
  7116. ) t
  7117. <if test="asc != null and asc !=''">
  7118. order by
  7119. <choose>
  7120. <when test='asc=="deptId"'>deptId asc</when>
  7121. <when test='asc=="deptName"'>deptName asc</when>
  7122. <when test='asc=="mrNum"'>mrNum asc</when>
  7123. <when test='asc=="checkedNum"'>checkedNum asc</when>
  7124. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  7125. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  7126. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  7127. <when test='asc=="improveNum"'>improveNum asc</when>
  7128. <when test='asc=="improvePercent"'>improvePercent asc</when>
  7129. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  7130. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  7131. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  7132. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  7133. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  7134. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  7135. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  7136. <otherwise>deptName asc</otherwise>
  7137. </choose>
  7138. </if>
  7139. <if test="desc != null and desc!=''">
  7140. order by
  7141. <choose>
  7142. <when test='desc=="deptId"'>deptId desc</when>
  7143. <when test='desc=="deptName"'>deptName desc</when>
  7144. <when test='desc=="mrNum"'>mrNum desc</when>
  7145. <when test='desc=="checkedNum"'>checkedNum desc</when>
  7146. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  7147. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  7148. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  7149. <when test='desc=="improveNum"'>improveNum desc</when>
  7150. <when test='desc=="improvePercent"'>improvePercent desc</when>
  7151. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  7152. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  7153. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  7154. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  7155. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  7156. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  7157. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  7158. <otherwise>deptName desc</otherwise>
  7159. </choose>
  7160. </if>
  7161. </select>
  7162. <!-- 质控核查统计-科室(内页)-->
  7163. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  7164. SELECT
  7165. t.*
  7166. FROM
  7167. (SELECT
  7168. mr.beh_dept_id AS deptId,
  7169. mr.beh_dept_name AS deptName,
  7170. mr.doctorId,
  7171. mr.doctorName,
  7172. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7173. ck.checkedNum AS checkedNum,
  7174. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7175. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7176. hmmr_t.homePageMRNum,
  7177. improve_t.improveNum,
  7178. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7179. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7180. improve_t.improveToPassNum,
  7181. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7182. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7183. improve_t.improveToFullNum,
  7184. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7185. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7186. FROM
  7187. (
  7188. SELECT
  7189. a.beh_dept_id,
  7190. a.beh_dept_name,
  7191. a.doctor_id as doctorId,
  7192. a.doctor_name as doctorName,
  7193. count(*) AS mrNum
  7194. FROM
  7195. med_behospital_info a,
  7196. med_qcresult_info b,
  7197. sys_user_dept c
  7198. WHERE
  7199. a.is_deleted = 'N'
  7200. AND b.is_deleted = 'N'
  7201. AND c.is_deleted = 'N'
  7202. AND a.hospital_id = b.hospital_id
  7203. AND a.hospital_id = c.hospital_id
  7204. AND a.beh_dept_id = c.dept_id
  7205. AND a.behospital_code = b.behospital_code
  7206. AND a.qc_type_id != 0
  7207. <if test="userId!=null">
  7208. AND c.user_id = #{userId}
  7209. </if>
  7210. <if test="isPlacefile != null and isPlacefile != ''">
  7211. and a.is_placefile = #{isPlacefile}
  7212. </if>
  7213. <if test="hospitalId != null and hospitalId != ''">
  7214. AND a.hospital_id = #{hospitalId}
  7215. </if>
  7216. <if test="isPlacefile != null and isPlacefile == 0">
  7217. <if test="startDate != null and startDate != ''">
  7218. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7219. </if>
  7220. <if test="endDate != null and endDate != ''">
  7221. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7222. </if>
  7223. </if>
  7224. <if test="isPlacefile != null and isPlacefile == 1">
  7225. <if test="startDate != null and startDate != ''">
  7226. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7227. </if>
  7228. <if test="endDate != null and endDate != ''">
  7229. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7230. </if>
  7231. </if>
  7232. <if test="deptName != null and deptName != ''">
  7233. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7234. </if>
  7235. GROUP BY
  7236. a.doctor_id,
  7237. a.doctor_name
  7238. ) mr
  7239. LEFT JOIN (
  7240. SELECT
  7241. a.beh_dept_id,
  7242. a.beh_dept_name,
  7243. a.doctor_id as doctorId,
  7244. a.doctor_name as doctorName,
  7245. count(*) AS checkedNum
  7246. FROM
  7247. med_behospital_info a,
  7248. med_qcresult_info b,
  7249. med_check_info c,
  7250. sys_user_dept d
  7251. WHERE
  7252. a.is_deleted = 'N'
  7253. AND b.is_deleted = 'N'
  7254. AND c.is_deleted = 'N'
  7255. AND d.is_deleted = 'N'
  7256. AND a.hospital_id = b.hospital_id
  7257. AND a.hospital_id = c.hospital_id
  7258. AND a.hospital_id = d.hospital_id
  7259. AND a.behospital_code = b.behospital_code
  7260. AND a.behospital_code = c.behospital_code
  7261. AND a.beh_dept_id = d.dept_id
  7262. AND a.qc_type_id != 0
  7263. AND ifnull(c.`status`,0) = 1
  7264. AND c.check_type = 0
  7265. <if test="userId!=null">
  7266. AND d.user_id = #{userId}
  7267. </if>
  7268. <if test="isPlacefile != null and isPlacefile != ''">
  7269. and a.is_placefile = #{isPlacefile}
  7270. </if>
  7271. <if test="hospitalId != null and hospitalId != ''">
  7272. AND a.hospital_id = #{hospitalId}
  7273. </if>
  7274. <if test="isPlacefile != null and isPlacefile == 0">
  7275. <if test="startDate != null and startDate != ''">
  7276. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7277. </if>
  7278. <if test="endDate != null and endDate != ''">
  7279. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7280. </if>
  7281. </if>
  7282. <if test="isPlacefile != null and isPlacefile == 1">
  7283. <if test="startDate != null and startDate != ''">
  7284. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7285. </if>
  7286. <if test="endDate != null and endDate != ''">
  7287. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7288. </if>
  7289. </if>
  7290. <if test="deptName != null and deptName != ''">
  7291. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7292. </if>
  7293. GROUP BY
  7294. a.doctor_id,
  7295. a.doctor_name
  7296. ) ck ON mr.doctorId = ck.doctorId
  7297. AND mr.doctorName = ck.doctorName
  7298. LEFT JOIN (
  7299. SELECT
  7300. a.beh_dept_id,
  7301. a.beh_dept_name,
  7302. a.doctor_id as doctorId,
  7303. a.doctor_name as doctorName,
  7304. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7305. FROM
  7306. med_behospital_info a,
  7307. med_home_page b,
  7308. med_qcresult_info c,
  7309. sys_user_dept d
  7310. WHERE
  7311. a.is_deleted = 'N'
  7312. AND b.is_deleted = 'N'
  7313. AND c.is_deleted = 'N'
  7314. AND d.is_deleted = 'N'
  7315. AND a.hospital_id = b.hospital_id
  7316. AND a.hospital_id = c.hospital_id
  7317. AND a.hospital_id = d.hospital_id
  7318. AND a.behospital_code = b.behospital_code
  7319. AND a.behospital_code = c.behospital_code
  7320. AND a.beh_dept_id = d.dept_id
  7321. AND a.qc_type_id != 0
  7322. <if test="userId!=null">
  7323. AND d.user_id = #{userId}
  7324. </if>
  7325. <if test="isPlacefile != null and isPlacefile != ''">
  7326. and a.is_placefile = #{isPlacefile}
  7327. </if>
  7328. <if test="hospitalId != null and hospitalId != ''">
  7329. AND a.hospital_id = #{hospitalId}
  7330. </if>
  7331. <if test="isPlacefile != null and isPlacefile == 0">
  7332. <if test="startDate != null and startDate != ''">
  7333. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7334. </if>
  7335. <if test="endDate != null and endDate != ''">
  7336. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7337. </if>
  7338. </if>
  7339. <if test="isPlacefile != null and isPlacefile == 1">
  7340. <if test="startDate != null and startDate != ''">
  7341. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7342. </if>
  7343. <if test="endDate != null and endDate != ''">
  7344. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7345. </if>
  7346. </if>
  7347. <if test="deptName != null and deptName != ''">
  7348. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7349. </if>
  7350. GROUP BY
  7351. a.doctor_id,
  7352. a.doctor_name
  7353. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  7354. AND mr.doctorName = hmmr_t.doctorName
  7355. LEFT JOIN (
  7356. SELECT
  7357. a.beh_dept_id,
  7358. a.beh_dept_name,
  7359. a.doctor_id as doctorId,
  7360. a.doctor_name as doctorName,
  7361. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7362. sum( d.score_res = 20 ) AS improveToFullNum,
  7363. count(*) AS improveNum
  7364. FROM
  7365. med_behospital_info a,
  7366. med_home_page b,
  7367. med_qcresult_info c,
  7368. med_qcresult_cases d,
  7369. sys_user_dept f,
  7370. (
  7371. SELECT
  7372. m4.*
  7373. FROM
  7374. med_behospital_info m1,
  7375. med_home_page m2,
  7376. med_qcresult_info m3,
  7377. med_qcresult_cases m4
  7378. WHERE
  7379. m1.is_deleted = 'N'
  7380. AND m2.is_deleted = 'N'
  7381. AND m3.is_deleted = 'Y'
  7382. AND m4.is_deleted = 'Y'
  7383. AND m1.hospital_id = m2.hospital_id
  7384. AND m1.hospital_id = m3.hospital_id
  7385. AND m1.hospital_id = m4.hospital_id
  7386. AND m1.behospital_code = m2.behospital_code
  7387. AND m1.behospital_code = m3.behospital_code
  7388. AND m1.behospital_code = m4.behospital_code
  7389. AND m3.gmt_create = m4.gmt_create
  7390. AND m3.have_home_page = 1
  7391. AND m4.cases_id = 243
  7392. <if test="isPlacefile != null and isPlacefile != ''">
  7393. and m1.is_placefile = #{isPlacefile}
  7394. </if>
  7395. AND m1.qc_type_id != 0
  7396. <if test="hospitalId != null and hospitalId != ''">
  7397. AND m1.hospital_id = #{hospitalId}
  7398. </if>
  7399. <if test="isPlacefile != null and isPlacefile == 0">
  7400. <if test="startDate != null and startDate != ''">
  7401. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7402. </if>
  7403. <if test="endDate != null and endDate != ''">
  7404. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7405. </if>
  7406. </if>
  7407. <if test="isPlacefile != null and isPlacefile == 1">
  7408. <if test="startDate != null and startDate != ''">
  7409. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7410. </if>
  7411. <if test="endDate != null and endDate != ''">
  7412. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7413. </if>
  7414. </if>
  7415. <if test="deptName != null and deptName != ''">
  7416. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7417. </if>
  7418. GROUP BY
  7419. m1.behospital_code
  7420. ORDER BY
  7421. m1.behospital_code,
  7422. m4.gmt_create
  7423. ) e
  7424. WHERE
  7425. a.is_deleted = 'N'
  7426. AND b.is_deleted = 'N'
  7427. AND c.is_deleted = 'N'
  7428. AND d.is_deleted = 'N'
  7429. AND f.is_deleted = 'N'
  7430. AND a.hospital_id = b.hospital_id
  7431. AND a.hospital_id = c.hospital_id
  7432. AND a.hospital_id = d.hospital_id
  7433. AND a.hospital_id = e.hospital_id
  7434. AND a.hospital_id = f.hospital_id
  7435. AND a.behospital_code = b.behospital_code
  7436. AND a.behospital_code = c.behospital_code
  7437. AND a.behospital_code = d.behospital_code
  7438. AND a.behospital_code = e.behospital_code
  7439. AND a.beh_dept_id = f.dept_id
  7440. <if test="userId!=null">
  7441. AND f.user_id = #{userId}
  7442. </if>
  7443. AND d.cases_id = 243
  7444. AND d.score_res > e.score_res
  7445. <if test="hospitalId != null and hospitalId != ''">
  7446. AND a.hospital_id = #{hospitalId}
  7447. </if>
  7448. <if test="isPlacefile != null and isPlacefile == 0">
  7449. <if test="startDate != null and startDate != ''">
  7450. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7451. </if>
  7452. <if test="endDate != null and endDate != ''">
  7453. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7454. </if>
  7455. </if>
  7456. <if test="isPlacefile != null and isPlacefile == 1">
  7457. <if test="startDate != null and startDate != ''">
  7458. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7459. </if>
  7460. <if test="endDate != null and endDate != ''">
  7461. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7462. </if>
  7463. </if>
  7464. <if test="deptName != null and deptName != ''">
  7465. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7466. </if>
  7467. GROUP BY
  7468. a.doctor_id,
  7469. a.doctor_name
  7470. ) improve_t ON mr.doctorId = improve_t.doctorId
  7471. AND mr.doctorName = improve_t.doctorName
  7472. ) t
  7473. <if test="asc != null and asc !=''">
  7474. order by
  7475. <choose>
  7476. <when test='asc=="deptId"'>deptId asc</when>
  7477. <when test='asc=="deptName"'>deptName asc</when>
  7478. <when test='asc=="doctorName"'>doctorName asc</when>
  7479. <when test='asc=="mrNum"'>mrNum asc</when>
  7480. <when test='asc=="checkedNum"'>checkedNum asc</when>
  7481. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  7482. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  7483. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  7484. <when test='asc=="improveNum"'>improveNum asc</when>
  7485. <when test='asc=="improvePercent"'>improvePercent asc</when>
  7486. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  7487. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  7488. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  7489. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  7490. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  7491. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  7492. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  7493. <otherwise>doctorName asc</otherwise>
  7494. </choose>
  7495. </if>
  7496. <if test="desc != null and desc!=''">
  7497. order by
  7498. <choose>
  7499. <when test='desc=="deptId"'>deptId desc</when>
  7500. <when test='desc=="deptName"'>deptName desc</when>
  7501. <when test='desc=="doctorName"'>doctorName desc</when>
  7502. <when test='desc=="mrNum"'>mrNum desc</when>
  7503. <when test='desc=="checkedNum"'>checkedNum desc</when>
  7504. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  7505. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  7506. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  7507. <when test='desc=="improveNum"'>improveNum desc</when>
  7508. <when test='desc=="improvePercent"'>improvePercent desc</when>
  7509. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  7510. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  7511. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  7512. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  7513. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  7514. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  7515. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  7516. <otherwise>deptName desc</otherwise>
  7517. </choose>
  7518. </if>
  7519. </select>
  7520. <!-- 离院病人评分详情页导出-->
  7521. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  7522. SELECT
  7523. f1.behDeptId,
  7524. f1.behDeptName,
  7525. f1.behDoctorName,
  7526. f1.patName,
  7527. f1.behospitalCode,
  7528. f1.hospitalId,
  7529. f1.behospitalDate,
  7530. f1.leaveHospitalDate,
  7531. f1.score,
  7532. f2.avgScore,
  7533. f1.scoreBn,
  7534. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  7535. f1.msg,
  7536. f1.caseName,
  7537. </if>
  7538. f1.checkStatus,
  7539. f1.mrStatus,
  7540. f1.chName,
  7541. f1.mrName,
  7542. f1.chTime,
  7543. f1.mrTime
  7544. FROM
  7545. (SELECT
  7546. t.doctorName AS behDoctorName,
  7547. t.`name` AS patName,
  7548. t.behospitalCode AS behospitalCode,
  7549. t.behospitalDate AS behospitalDate,
  7550. t.leaveHospitalDate AS leaveHospitalDate,
  7551. qi.score_res AS score,
  7552. t.scoreBn,
  7553. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  7554. qd.msg AS msg,
  7555. qc.NAME AS caseName,
  7556. </if>
  7557. t.behDeptId,
  7558. t.behDeptName,
  7559. t.hospitalId,
  7560. t.checkStatus,
  7561. t.mrStatus,
  7562. t.chName,
  7563. t.mrName,
  7564. t.chTime,
  7565. t.mrTime
  7566. FROM
  7567. (SELECT DISTINCT
  7568. t1.hospital_id AS hospitalId,
  7569. t1.behospital_code AS behospitalCode,
  7570. t1.bed_code AS bedCode,
  7571. t1.LEVEL AS LEVEL,
  7572. t1.grade_type AS gradeType,
  7573. t1.score_res AS scoreRes,
  7574. t1.scoreBn,
  7575. t1.NAME AS NAME,
  7576. t1.sex AS sex,
  7577. t1.beh_dept_id AS behDeptId,
  7578. t1.beh_dept_name AS behDeptName,
  7579. t1.doctor_id AS doctorId,
  7580. t1.doctor_name AS doctorName,
  7581. t1.beh_doctor_id AS behDoctorId,
  7582. t1.beh_doctor_name AS behDoctorName,
  7583. t1.director_doctor_id AS directorDoctorId,
  7584. t1.director_doctor_name AS directorDoctorName,
  7585. t1.birthday AS birthday,
  7586. t1.behospital_date AS behospitalDate,
  7587. t1.leave_hospital_date AS leaveHospitalDate,
  7588. t1.placefile_date AS placefileDate,
  7589. t1.gmt_create AS gradeTime,
  7590. t1.diagnose,
  7591. t1.ward_name AS wardName,
  7592. t1.checkStatus,
  7593. t1.mrStatus,
  7594. t1.chName,
  7595. t1.mrName,
  7596. t1.chTime,
  7597. t1.mrTime,
  7598. t2.age,
  7599. t1.file_code AS fileCode
  7600. FROM
  7601. (
  7602. SELECT be.*,
  7603. ifnull(mci.status,0) AS checkStatus,
  7604. ifnull(hm_mci.status,0) AS mrStatus,
  7605. mci.check_name as chName,
  7606. e.score_res as scoreBn,
  7607. hm_mci.check_name as mrName,
  7608. mci.gmt_create as chTime,
  7609. hm_mci.gmt_create as mrTime
  7610. FROM
  7611. (
  7612. SELECT DISTINCT
  7613. tt1.*
  7614. FROM
  7615. (
  7616. SELECT
  7617. b.*,
  7618. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7619. c.grade_type,
  7620. c.score_res,
  7621. c.gmt_create
  7622. FROM
  7623. (
  7624. SELECT DISTINCT
  7625. a.hospital_id,
  7626. a.behospital_code,
  7627. a.bed_code,
  7628. a.NAME,
  7629. a.sex,
  7630. a.beh_dept_id,
  7631. a.beh_dept_name,
  7632. a.birthday,
  7633. a.behospital_date,
  7634. a.leave_hospital_date,
  7635. a.doctor_id,
  7636. a.doctor_name,
  7637. a.beh_doctor_id,
  7638. a.beh_doctor_name,
  7639. a.director_doctor_id,
  7640. a.director_doctor_name,
  7641. a.diagnose,
  7642. a.placefile_date,
  7643. a.ward_name,
  7644. a.file_code
  7645. FROM
  7646. med_behospital_info a
  7647. WHERE
  7648. a.is_deleted = 'N'
  7649. AND a.qc_type_id != 0
  7650. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7651. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7652. </if>
  7653. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7654. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7655. </if>
  7656. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7657. <if test="qcResultShortPageVO.startDate != null ">
  7658. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7659. </if>
  7660. <if test="qcResultShortPageVO.endDate != null ">
  7661. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7662. </if>
  7663. </if>
  7664. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7665. <if test="qcResultShortPageVO.startDate != null ">
  7666. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7667. </if>
  7668. <if test="qcResultShortPageVO.endDate != null">
  7669. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7670. </if>
  7671. </if>
  7672. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7673. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7674. </if>
  7675. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7676. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  7677. </if>
  7678. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7679. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7680. </if>
  7681. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7682. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7683. </if>
  7684. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7685. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7686. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7687. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7688. </if>
  7689. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7690. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7691. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7692. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7693. </if>
  7694. ) b
  7695. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7696. AND b.hospital_id = c.hospital_id
  7697. AND b.behospital_code = c.behospital_code
  7698. ) tt1
  7699. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7700. ,med_medical_record tt2,
  7701. qc_mode tt3
  7702. WHERE
  7703. tt2.is_deleted = 'N'
  7704. AND tt3.is_deleted = 'N'
  7705. AND tt1.hospital_id = tt2.hospital_id
  7706. AND tt1.behospital_code = tt2.behospital_code
  7707. AND tt2.mode_id = tt3.id
  7708. AND tt3.`name` = '手术记录'
  7709. </if>
  7710. ) be
  7711. left join med_check_info mci
  7712. on mci.is_deleted = 'N'
  7713. and mci.check_type = 0
  7714. and be.hospital_id = mci.hospital_id
  7715. and be.behospital_code = mci.behospital_code
  7716. left join med_check_info hm_mci
  7717. on hm_mci.is_deleted = 'N'
  7718. and hm_mci.check_type = 1
  7719. and be.hospital_id = hm_mci.hospital_id
  7720. and be.behospital_code = hm_mci.behospital_code
  7721. LEFT JOIN med_qcresult_cases e
  7722. on be.behospital_code = e.behospital_code
  7723. and be.hospital_id = e.hospital_id
  7724. AND e.is_deleted = 'N'
  7725. and e.cases_id = 243
  7726. )t1
  7727. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7728. ,med_home_page t2
  7729. WHERE
  7730. t2.is_deleted = 'N'
  7731. AND t1.hospital_id = t2.hospital_id
  7732. AND t1.behospital_code = t2.behospital_code
  7733. AND (
  7734. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  7735. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  7736. )
  7737. </if>
  7738. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7739. ,med_home_page t2
  7740. WHERE
  7741. t2.is_deleted = 'N'
  7742. AND t1.hospital_id = t2.hospital_id
  7743. AND t1.behospital_code = t2.behospital_code
  7744. AND t2.return_to_type = '死亡'
  7745. </if>
  7746. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7747. ,med_home_page t2
  7748. WHERE
  7749. t2.is_deleted = 'N'
  7750. AND t1.hospital_id = t2.hospital_id
  7751. AND t1.behospital_code = t2.behospital_code
  7752. AND t2.leave_hospital_type = '非医嘱离院'
  7753. </if>
  7754. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7755. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7756. AND t1.hospital_id = t2.hospital_id
  7757. AND t1.behospital_code = t2.behospital_code
  7758. </if>
  7759. )t
  7760. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  7761. AND t.hospitalId = qi.hospital_id
  7762. AND t.behospitalCode = qi.behospital_code
  7763. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  7764. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  7765. AND t.hospitalId = qd.hospital_id
  7766. AND t.behospitalCode = qd.behospital_code
  7767. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  7768. AND qd.cases_id = qc.id
  7769. </if>
  7770. where 1=1
  7771. <if test="qcResultShortPageVO.checkStatus != null">
  7772. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7773. </if>
  7774. <if test="qcResultShortPageVO.mrStatus != null">
  7775. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7776. </if>
  7777. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7778. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7779. </if>
  7780. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7781. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7782. </if>
  7783. <if test="qcResultShortPageVO.chTimeStart != null ">
  7784. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7785. </if>
  7786. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7787. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7788. </if>
  7789. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7790. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7791. </if>
  7792. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7793. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7794. </if>
  7795. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7796. AND t.`level` = #{qcResultShortPageVO.level}
  7797. </if>)f1,(SELECT
  7798. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  7799. t.behDeptId,
  7800. t.behDeptName
  7801. FROM
  7802. (SELECT DISTINCT
  7803. t1.hospital_id AS hospitalId,
  7804. t1.behospital_code AS behospitalCode,
  7805. t1.bed_code AS bedCode,
  7806. t1.LEVEL AS LEVEL,
  7807. t1.grade_type AS gradeType,
  7808. t1.score_res AS scoreRes,
  7809. t1.NAME AS NAME,
  7810. t1.sex AS sex,
  7811. t1.beh_dept_id AS behDeptId,
  7812. t1.beh_dept_name AS behDeptName,
  7813. t1.doctor_id AS doctorId,
  7814. t1.doctor_name AS doctorName,
  7815. t1.beh_doctor_id AS behDoctorId,
  7816. t1.beh_doctor_name AS behDoctorName,
  7817. t1.director_doctor_id AS directorDoctorId,
  7818. t1.director_doctor_name AS directorDoctorName,
  7819. t1.birthday AS birthday,
  7820. t1.behospital_date AS behospitalDate,
  7821. t1.leave_hospital_date AS leaveHospitalDate,
  7822. t1.placefile_date AS placefileDate,
  7823. t1.gmt_create AS gradeTime,
  7824. t1.diagnose,
  7825. t1.ward_name AS wardName,
  7826. t1.checkStatus,
  7827. t1.mrStatus,
  7828. t1.chName,
  7829. t1.mrName,
  7830. t1.chTime,
  7831. t1.mrTime,
  7832. t2.age,
  7833. t1.file_code AS fileCode
  7834. FROM
  7835. (
  7836. SELECT be.*,
  7837. ifnull(mci.status,0) AS checkStatus,
  7838. ifnull(hm_mci.status,0) AS mrStatus,
  7839. mci.check_name as chName,
  7840. hm_mci.check_name as mrName,
  7841. mci.gmt_create as chTime,
  7842. hm_mci.gmt_create as mrTime
  7843. FROM
  7844. (
  7845. SELECT DISTINCT
  7846. tt1.*
  7847. FROM
  7848. (
  7849. SELECT
  7850. b.*,
  7851. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7852. c.grade_type,
  7853. c.score_res,
  7854. c.gmt_create
  7855. FROM
  7856. (
  7857. SELECT DISTINCT
  7858. a.hospital_id,
  7859. a.behospital_code,
  7860. a.bed_code,
  7861. a.NAME,
  7862. a.sex,
  7863. a.beh_dept_id,
  7864. a.beh_dept_name,
  7865. a.birthday,
  7866. a.behospital_date,
  7867. a.leave_hospital_date,
  7868. a.doctor_id,
  7869. a.doctor_name,
  7870. a.beh_doctor_id,
  7871. a.beh_doctor_name,
  7872. a.director_doctor_id,
  7873. a.director_doctor_name,
  7874. a.diagnose,
  7875. a.placefile_date,
  7876. a.ward_name,
  7877. a.file_code
  7878. FROM
  7879. med_behospital_info a
  7880. WHERE
  7881. a.is_deleted = 'N'
  7882. AND a.qc_type_id != 0
  7883. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7884. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7885. </if>
  7886. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7887. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7888. </if>
  7889. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7890. <if test="qcResultShortPageVO.startDate != null ">
  7891. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7892. </if>
  7893. <if test="qcResultShortPageVO.endDate != null ">
  7894. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7895. </if>
  7896. </if>
  7897. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7898. <if test="qcResultShortPageVO.startDate != null ">
  7899. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7900. </if>
  7901. <if test="qcResultShortPageVO.endDate != null">
  7902. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7903. </if>
  7904. </if>
  7905. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7906. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7907. </if>
  7908. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7909. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  7910. </if>
  7911. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7912. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7913. </if>
  7914. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7915. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7916. </if>
  7917. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7918. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7919. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7920. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7921. </if>
  7922. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7923. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7924. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7925. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7926. </if>
  7927. ) b
  7928. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7929. AND b.hospital_id = c.hospital_id
  7930. AND b.behospital_code = c.behospital_code
  7931. ) tt1
  7932. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7933. ,med_medical_record tt2,
  7934. qc_mode tt3
  7935. WHERE
  7936. tt2.is_deleted = 'N'
  7937. AND tt3.is_deleted = 'N'
  7938. AND tt1.hospital_id = tt2.hospital_id
  7939. AND tt1.behospital_code = tt2.behospital_code
  7940. AND tt2.mode_id = tt3.id
  7941. AND tt3.`name` = '手术记录'
  7942. </if>
  7943. ) be
  7944. left join med_check_info mci
  7945. on mci.is_deleted = 'N'
  7946. and mci.check_type = 0
  7947. and be.hospital_id = mci.hospital_id
  7948. and be.behospital_code = mci.behospital_code
  7949. left join med_check_info hm_mci
  7950. on hm_mci.is_deleted = 'N'
  7951. and hm_mci.check_type = 1
  7952. and be.hospital_id = hm_mci.hospital_id
  7953. and be.behospital_code = hm_mci.behospital_code
  7954. )t1
  7955. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7956. ,med_home_page t2
  7957. WHERE
  7958. t2.is_deleted = 'N'
  7959. AND t1.hospital_id = t2.hospital_id
  7960. AND t1.behospital_code = t2.behospital_code
  7961. AND (
  7962. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  7963. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  7964. )
  7965. </if>
  7966. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7967. ,med_home_page t2
  7968. WHERE
  7969. t2.is_deleted = 'N'
  7970. AND t1.hospital_id = t2.hospital_id
  7971. AND t1.behospital_code = t2.behospital_code
  7972. AND t2.return_to_type = '死亡'
  7973. </if>
  7974. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7975. ,med_home_page t2
  7976. WHERE
  7977. t2.is_deleted = 'N'
  7978. AND t1.hospital_id = t2.hospital_id
  7979. AND t1.behospital_code = t2.behospital_code
  7980. AND t2.leave_hospital_type = '非医嘱离院'
  7981. </if>
  7982. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7983. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7984. AND t1.hospital_id = t2.hospital_id
  7985. AND t1.behospital_code = t2.behospital_code
  7986. </if>
  7987. )t
  7988. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  7989. AND t.hospitalId = qi.hospital_id
  7990. AND t.behospitalCode = qi.behospital_code
  7991. where 1=1
  7992. <if test="qcResultShortPageVO.checkStatus != null">
  7993. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7994. </if>
  7995. <if test="qcResultShortPageVO.mrStatus != null">
  7996. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7997. </if>
  7998. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7999. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8000. </if>
  8001. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8002. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8003. </if>
  8004. <if test="qcResultShortPageVO.chTimeStart != null ">
  8005. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8006. </if>
  8007. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8008. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8009. </if>
  8010. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8011. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8012. </if>
  8013. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8014. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8015. </if>
  8016. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8017. AND t.`level` = #{qcResultShortPageVO.level}
  8018. </if>
  8019. GROUP BY
  8020. t.behDeptId,
  8021. t.behDeptName
  8022. )f2
  8023. WHERE
  8024. f1.behDeptId = f2.behDeptId
  8025. AND f1.behDeptName = f2.behDeptName
  8026. </select>
  8027. <!-- 离院病人评分详情页导出-科室-->
  8028. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  8029. SELECT
  8030. f1.behDeptId,
  8031. f1.behDeptName,
  8032. f1.doctorName,
  8033. f1.patName,
  8034. f1.behospitalCode,
  8035. f1.hospitalId,
  8036. f1.behospitalDate,
  8037. f1.leaveHospitalDate,
  8038. f1.score,
  8039. f2.avgScore,
  8040. f1.scoreBn,
  8041. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8042. f1.msg,
  8043. f1.caseName,
  8044. </if>
  8045. f1.checkStatus,
  8046. f1.mrStatus,
  8047. f1.chName,
  8048. f1.mrName,
  8049. f1.chTime,
  8050. f1.mrTime
  8051. FROM
  8052. (SELECT
  8053. t.doctorName,
  8054. t.doctorId,
  8055. t.`name` AS patName,
  8056. t.behospitalCode AS behospitalCode,
  8057. t.behospitalDate AS behospitalDate,
  8058. t.leaveHospitalDate AS leaveHospitalDate,
  8059. qi.score_res AS score,
  8060. t.scoreBn,
  8061. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8062. qd.msg AS msg,
  8063. qc.NAME AS caseName,
  8064. </if>
  8065. t.behDeptId,
  8066. t.behDeptName,
  8067. t.hospitalId,
  8068. t.checkStatus,
  8069. t.mrStatus,
  8070. t.chName,
  8071. t.mrName,
  8072. t.chTime,
  8073. t.mrTime
  8074. FROM
  8075. (SELECT DISTINCT
  8076. t1.hospital_id AS hospitalId,
  8077. t1.behospital_code AS behospitalCode,
  8078. t1.bed_code AS bedCode,
  8079. t1.LEVEL AS LEVEL,
  8080. t1.grade_type AS gradeType,
  8081. t1.score_res AS scoreRes,
  8082. t1.scoreBn,
  8083. t1.NAME AS NAME,
  8084. t1.sex AS sex,
  8085. t1.beh_dept_id AS behDeptId,
  8086. t1.beh_dept_name AS behDeptName,
  8087. t1.doctor_id AS doctorId,
  8088. t1.doctor_name AS doctorName,
  8089. t1.beh_doctor_id AS behDoctorId,
  8090. t1.beh_doctor_name AS behDoctorName,
  8091. t1.director_doctor_id AS directorDoctorId,
  8092. t1.director_doctor_name AS directorDoctorName,
  8093. t1.birthday AS birthday,
  8094. t1.behospital_date AS behospitalDate,
  8095. t1.leave_hospital_date AS leaveHospitalDate,
  8096. t1.placefile_date AS placefileDate,
  8097. t1.gmt_create AS gradeTime,
  8098. t1.diagnose,
  8099. t1.ward_name AS wardName,
  8100. t1.checkStatus,
  8101. t1.mrStatus,
  8102. t1.chName,
  8103. t1.mrName,
  8104. t1.chTime,
  8105. t1.mrTime,
  8106. t2.age,
  8107. t1.file_code AS fileCode
  8108. FROM
  8109. (
  8110. SELECT be.*,
  8111. ifnull(mci.status,0) AS checkStatus,
  8112. ifnull(hm_mci.status,0) AS mrStatus,
  8113. mci.check_name as chName,
  8114. e.score_res as scoreBn,
  8115. hm_mci.check_name as mrName,
  8116. mci.gmt_create as chTime,
  8117. hm_mci.gmt_create as mrTime
  8118. FROM
  8119. (
  8120. SELECT DISTINCT
  8121. tt1.*
  8122. FROM
  8123. (
  8124. SELECT
  8125. b.*,
  8126. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8127. c.grade_type,
  8128. c.score_res,
  8129. c.gmt_create
  8130. FROM
  8131. (
  8132. SELECT DISTINCT
  8133. a.hospital_id,
  8134. a.behospital_code,
  8135. a.bed_code,
  8136. a.NAME,
  8137. a.sex,
  8138. a.beh_dept_id,
  8139. a.beh_dept_name,
  8140. a.birthday,
  8141. a.behospital_date,
  8142. a.leave_hospital_date,
  8143. a.doctor_id,
  8144. a.doctor_name,
  8145. a.beh_doctor_id,
  8146. a.beh_doctor_name,
  8147. a.director_doctor_id,
  8148. a.director_doctor_name,
  8149. a.diagnose,
  8150. a.placefile_date,
  8151. a.ward_name,
  8152. a.file_code
  8153. FROM
  8154. med_behospital_info a,
  8155. sys_user_dept b
  8156. WHERE
  8157. a.is_deleted = 'N'
  8158. AND b.is_deleted = 'N'
  8159. AND a.hospital_id = b.hospital_id
  8160. AND a.beh_dept_id = b.dept_id
  8161. AND a.qc_type_id != 0
  8162. <if test="qcResultShortPageVO.userId!=null">
  8163. AND c.user_id = #{qcResultShortPageVO.userId}
  8164. </if>
  8165. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8166. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8167. </if>
  8168. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8169. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8170. </if>
  8171. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8172. <if test="qcResultShortPageVO.startDate != null ">
  8173. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8174. </if>
  8175. <if test="qcResultShortPageVO.endDate != null ">
  8176. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8177. </if>
  8178. </if>
  8179. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8180. <if test="qcResultShortPageVO.startDate != null ">
  8181. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8182. </if>
  8183. <if test="qcResultShortPageVO.endDate != null">
  8184. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8185. </if>
  8186. </if>
  8187. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8188. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8189. </if>
  8190. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8191. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  8192. </if>
  8193. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8194. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8195. </if>
  8196. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8197. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8198. </if>
  8199. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8200. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8201. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8202. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8203. </if>
  8204. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8205. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8206. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8207. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8208. </if>
  8209. ) b
  8210. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8211. AND b.hospital_id = c.hospital_id
  8212. AND b.behospital_code = c.behospital_code
  8213. ) tt1
  8214. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8215. ,med_medical_record tt2,
  8216. qc_mode tt3
  8217. WHERE
  8218. tt2.is_deleted = 'N'
  8219. AND tt3.is_deleted = 'N'
  8220. AND tt1.hospital_id = tt2.hospital_id
  8221. AND tt1.behospital_code = tt2.behospital_code
  8222. AND tt2.mode_id = tt3.id
  8223. AND tt3.`name` = '手术记录'
  8224. </if>
  8225. ) be
  8226. left join med_check_info mci
  8227. on mci.is_deleted = 'N'
  8228. and mci.check_type = 0
  8229. and be.hospital_id = mci.hospital_id
  8230. and be.behospital_code = mci.behospital_code
  8231. left join med_check_info hm_mci
  8232. on hm_mci.is_deleted = 'N'
  8233. and hm_mci.check_type = 1
  8234. and be.hospital_id = hm_mci.hospital_id
  8235. and be.behospital_code = hm_mci.behospital_code
  8236. LEFT JOIN med_qcresult_cases e
  8237. on be.behospital_code = e.behospital_code
  8238. and be.hospital_id = e.hospital_id
  8239. AND e.is_deleted = 'N'
  8240. and e.cases_id = 243
  8241. )t1
  8242. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8243. ,med_home_page t2
  8244. WHERE
  8245. t2.is_deleted = 'N'
  8246. AND t1.hospital_id = t2.hospital_id
  8247. AND t1.behospital_code = t2.behospital_code
  8248. AND (
  8249. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  8250. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  8251. )
  8252. </if>
  8253. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8254. ,med_home_page t2
  8255. WHERE
  8256. t2.is_deleted = 'N'
  8257. AND t1.hospital_id = t2.hospital_id
  8258. AND t1.behospital_code = t2.behospital_code
  8259. AND t2.return_to_type = '死亡'
  8260. </if>
  8261. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8262. ,med_home_page t2
  8263. WHERE
  8264. t2.is_deleted = 'N'
  8265. AND t1.hospital_id = t2.hospital_id
  8266. AND t1.behospital_code = t2.behospital_code
  8267. AND t2.leave_hospital_type = '非医嘱离院'
  8268. </if>
  8269. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8270. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8271. AND t1.hospital_id = t2.hospital_id
  8272. AND t1.behospital_code = t2.behospital_code
  8273. </if>
  8274. )t
  8275. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8276. AND t.hospitalId = qi.hospital_id
  8277. AND t.behospitalCode = qi.behospital_code
  8278. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8279. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  8280. AND t.hospitalId = qd.hospital_id
  8281. AND t.behospitalCode = qd.behospital_code
  8282. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  8283. AND qd.cases_id = qc.id
  8284. </if>
  8285. where 1=1
  8286. <if test="qcResultShortPageVO.checkStatus != null">
  8287. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8288. </if>
  8289. <if test="qcResultShortPageVO.mrStatus != null">
  8290. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8291. </if>
  8292. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8293. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8294. </if>
  8295. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8296. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8297. </if>
  8298. <if test="qcResultShortPageVO.chTimeStart != null ">
  8299. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8300. </if>
  8301. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8302. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8303. </if>
  8304. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8305. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8306. </if>
  8307. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8308. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8309. </if>
  8310. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8311. AND t.`level` = #{qcResultShortPageVO.level}
  8312. </if>)f1,(SELECT
  8313. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8314. t.behDeptId,
  8315. t.behDeptName,
  8316. t.doctorId,
  8317. t.doctorName
  8318. FROM
  8319. (SELECT DISTINCT
  8320. t1.hospital_id AS hospitalId,
  8321. t1.behospital_code AS behospitalCode,
  8322. t1.bed_code AS bedCode,
  8323. t1.LEVEL AS LEVEL,
  8324. t1.grade_type AS gradeType,
  8325. t1.score_res AS scoreRes,
  8326. t1.NAME AS NAME,
  8327. t1.sex AS sex,
  8328. t1.beh_dept_id AS behDeptId,
  8329. t1.beh_dept_name AS behDeptName,
  8330. t1.doctor_id AS doctorId,
  8331. t1.doctor_name AS doctorName,
  8332. t1.beh_doctor_id AS behDoctorId,
  8333. t1.beh_doctor_name AS behDoctorName,
  8334. t1.director_doctor_id AS directorDoctorId,
  8335. t1.director_doctor_name AS directorDoctorName,
  8336. t1.birthday AS birthday,
  8337. t1.behospital_date AS behospitalDate,
  8338. t1.leave_hospital_date AS leaveHospitalDate,
  8339. t1.placefile_date AS placefileDate,
  8340. t1.gmt_create AS gradeTime,
  8341. t1.diagnose,
  8342. t1.ward_name AS wardName,
  8343. t1.checkStatus,
  8344. t1.mrStatus,
  8345. t1.chName,
  8346. t1.mrName,
  8347. t1.chTime,
  8348. t1.mrTime,
  8349. t2.age,
  8350. t1.file_code AS fileCode
  8351. FROM
  8352. (
  8353. SELECT be.*,
  8354. ifnull(mci.status,0) AS checkStatus,
  8355. ifnull(hm_mci.status,0) AS mrStatus,
  8356. mci.check_name as chName,
  8357. hm_mci.check_name as mrName,
  8358. mci.gmt_create as chTime,
  8359. hm_mci.gmt_create as mrTime
  8360. FROM
  8361. (
  8362. SELECT DISTINCT
  8363. tt1.*
  8364. FROM
  8365. (
  8366. SELECT
  8367. b.*,
  8368. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8369. c.grade_type,
  8370. c.score_res,
  8371. c.gmt_create
  8372. FROM
  8373. (
  8374. SELECT DISTINCT
  8375. a.hospital_id,
  8376. a.behospital_code,
  8377. a.bed_code,
  8378. a.NAME,
  8379. a.sex,
  8380. a.beh_dept_id,
  8381. a.beh_dept_name,
  8382. a.birthday,
  8383. a.behospital_date,
  8384. a.leave_hospital_date,
  8385. a.doctor_id,
  8386. a.doctor_name,
  8387. a.beh_doctor_id,
  8388. a.beh_doctor_name,
  8389. a.director_doctor_id,
  8390. a.director_doctor_name,
  8391. a.diagnose,
  8392. a.placefile_date,
  8393. a.ward_name,
  8394. a.file_code
  8395. FROM
  8396. med_behospital_info a,
  8397. sys_user_dept b
  8398. WHERE
  8399. a.is_deleted = 'N'
  8400. AND b.is_deleted = 'N'
  8401. AND a.hospital_id = b.hospital_id
  8402. AND a.beh_dept_id = b.dept_id
  8403. AND a.qc_type_id != 0
  8404. <if test="qcResultShortPageVO.userId!=null">
  8405. AND c.user_id = #{qcResultShortPageVO.userId}
  8406. </if>
  8407. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8408. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8409. </if>
  8410. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8411. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8412. </if>
  8413. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8414. <if test="qcResultShortPageVO.startDate != null ">
  8415. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8416. </if>
  8417. <if test="qcResultShortPageVO.endDate != null ">
  8418. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8419. </if>
  8420. </if>
  8421. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8422. <if test="qcResultShortPageVO.startDate != null ">
  8423. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8424. </if>
  8425. <if test="qcResultShortPageVO.endDate != null">
  8426. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8427. </if>
  8428. </if>
  8429. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8430. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8431. </if>
  8432. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8433. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  8434. </if>
  8435. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8436. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8437. </if>
  8438. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8439. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8440. </if>
  8441. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8442. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8443. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8444. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8445. </if>
  8446. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8447. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8448. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8449. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8450. </if>
  8451. ) b
  8452. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8453. AND b.hospital_id = c.hospital_id
  8454. AND b.behospital_code = c.behospital_code
  8455. ) tt1
  8456. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8457. ,med_medical_record tt2,
  8458. qc_mode tt3
  8459. WHERE
  8460. tt2.is_deleted = 'N'
  8461. AND tt3.is_deleted = 'N'
  8462. AND tt1.hospital_id = tt2.hospital_id
  8463. AND tt1.behospital_code = tt2.behospital_code
  8464. AND tt2.mode_id = tt3.id
  8465. AND tt3.`name` = '手术记录'
  8466. </if>
  8467. ) be
  8468. left join med_check_info mci
  8469. on mci.is_deleted = 'N'
  8470. and mci.check_type = 0
  8471. and be.hospital_id = mci.hospital_id
  8472. and be.behospital_code = mci.behospital_code
  8473. left join med_check_info hm_mci
  8474. on hm_mci.is_deleted = 'N'
  8475. and hm_mci.check_type = 1
  8476. and be.hospital_id = hm_mci.hospital_id
  8477. and be.behospital_code = hm_mci.behospital_code
  8478. )t1
  8479. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8480. ,med_home_page t2
  8481. WHERE
  8482. t2.is_deleted = 'N'
  8483. AND t1.hospital_id = t2.hospital_id
  8484. AND t1.behospital_code = t2.behospital_code
  8485. AND (
  8486. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  8487. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  8488. )
  8489. </if>
  8490. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8491. ,med_home_page t2
  8492. WHERE
  8493. t2.is_deleted = 'N'
  8494. AND t1.hospital_id = t2.hospital_id
  8495. AND t1.behospital_code = t2.behospital_code
  8496. AND t2.return_to_type = '死亡'
  8497. </if>
  8498. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8499. ,med_home_page t2
  8500. WHERE
  8501. t2.is_deleted = 'N'
  8502. AND t1.hospital_id = t2.hospital_id
  8503. AND t1.behospital_code = t2.behospital_code
  8504. AND t2.leave_hospital_type = '非医嘱离院'
  8505. </if>
  8506. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8507. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8508. AND t1.hospital_id = t2.hospital_id
  8509. AND t1.behospital_code = t2.behospital_code
  8510. </if>
  8511. )t
  8512. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8513. AND t.hospitalId = qi.hospital_id
  8514. AND t.behospitalCode = qi.behospital_code
  8515. where 1=1
  8516. <if test="qcResultShortPageVO.checkStatus != null">
  8517. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8518. </if>
  8519. <if test="qcResultShortPageVO.mrStatus != null">
  8520. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8521. </if>
  8522. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8523. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8524. </if>
  8525. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8526. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8527. </if>
  8528. <if test="qcResultShortPageVO.chTimeStart != null ">
  8529. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8530. </if>
  8531. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8532. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8533. </if>
  8534. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8535. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8536. </if>
  8537. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8538. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8539. </if>
  8540. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8541. AND t.`level` = #{qcResultShortPageVO.level}
  8542. </if>
  8543. GROUP BY
  8544. t.behDeptId,
  8545. t.behDeptName
  8546. )f2
  8547. WHERE
  8548. f1.doctorId = f2.doctorId
  8549. AND f1.doctorName = f2.doctorName
  8550. </select>
  8551. <!--缺陷详情质控评分页导出-科室-->
  8552. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  8553. SELECT * from(
  8554. SELECT
  8555. f1.*,
  8556. f2.avgScore
  8557. FROM
  8558. (SELECT
  8559. t.*,
  8560. qi.score_res AS score,
  8561. qd.msg AS msg,
  8562. qc.NAME AS caseName
  8563. FROM
  8564. (SELECT DISTINCT
  8565. t1.hospital_id AS hospitalId,
  8566. t1.behospital_code AS behospitalCode,
  8567. t1.bed_code AS bedCode,
  8568. t1.LEVEL AS LEVEL,
  8569. t1.grade_type AS gradeType,
  8570. t1.score_res AS scoreRes,
  8571. t1.scoreBn AS scoreBn,
  8572. t1.NAME AS patName,
  8573. t1.sex AS sex,
  8574. t1.beh_dept_id AS behDeptId,
  8575. t1.beh_dept_name AS behDeptName,
  8576. t1.doctor_id AS doctorId,
  8577. t1.doctor_name AS doctorName,
  8578. t1.beh_doctor_id AS behDoctorId,
  8579. t1.beh_doctor_name AS behDoctorName,
  8580. t1.director_doctor_id AS directorDoctorId,
  8581. t1.director_doctor_name AS directorDoctorName,
  8582. t1.birthday AS birthday,
  8583. t1.behospital_date AS behospitalDate,
  8584. t1.leave_hospital_date AS leaveHospitalDate,
  8585. t1.placefile_date AS placefileDate,
  8586. t1.gmt_create AS gradeTime,
  8587. t1.diagnose AS diagnose,
  8588. t1.ward_name AS wardName,
  8589. t1.file_code AS fileCode,
  8590. t1.checkStatus AS checkStatus,
  8591. t1.mrStatus AS mrStatus,
  8592. t1.chName AS chName,
  8593. t1.mrName AS mrName,
  8594. t1.chTime AS chTime,
  8595. t1.mrTime AS mrTime
  8596. FROM
  8597. (
  8598. SELECT DISTINCT
  8599. tt1.*
  8600. FROM
  8601. (SELECT
  8602. be.*,
  8603. ifnull(mci.status,0) AS checkStatus,
  8604. ifnull(hm_mci.status,0) AS mrStatus,
  8605. mci.check_name as chName,
  8606. hm_mci.check_name as mrName,
  8607. mci.gmt_create as chTime,
  8608. e.score_res as scoreBn,
  8609. hm_mci.gmt_create as mrTime
  8610. FROM
  8611. (
  8612. SELECT DISTINCT
  8613. a.hospital_id,
  8614. a.behospital_code,
  8615. a.bed_code,
  8616. a.file_code,
  8617. b.LEVEL,
  8618. b.grade_type,
  8619. b.score_res,
  8620. a.NAME,
  8621. a.sex,
  8622. a.beh_dept_id,
  8623. a.beh_dept_name,
  8624. a.birthday,
  8625. a.behospital_date,
  8626. a.leave_hospital_date,
  8627. a.doctor_id,
  8628. a.doctor_name,
  8629. a.beh_doctor_id,
  8630. a.beh_doctor_name,
  8631. a.director_doctor_id,
  8632. a.director_doctor_name,
  8633. a.diagnose,
  8634. a.placefile_date,
  8635. a.ward_name,
  8636. b.gmt_create
  8637. FROM
  8638. med_behospital_info a,
  8639. med_qcresult_info b,
  8640. med_qcresult_detail c,
  8641. qc_cases_entry d,
  8642. sys_user_dept e
  8643. WHERE
  8644. a.is_deleted = 'N'
  8645. AND b.is_deleted = 'N'
  8646. AND c.is_deleted = 'N'
  8647. AND d.is_deleted = 'N'
  8648. AND e.is_deleted = 'N'
  8649. AND a.hospital_id = b.hospital_id
  8650. AND a.hospital_id = c.hospital_id
  8651. AND a.hospital_id = e.hospital_id
  8652. AND a.behospital_code = b.behospital_code
  8653. AND a.behospital_code = c.behospital_code
  8654. AND a.beh_dept_id = e.dept_id
  8655. AND c.cases_id = d.cases_id
  8656. AND c.cases_entry_id = d.id
  8657. AND a.qc_type_id != 0
  8658. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8659. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8660. </if>
  8661. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  8662. AND e.user_id = #{qcResultShortPageVO.userId}
  8663. </if>
  8664. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8665. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8666. </if>
  8667. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8668. <if test="qcResultShortPageVO.startDate != null ">
  8669. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8670. </if>
  8671. <if test="qcResultShortPageVO.endDate != null ">
  8672. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8673. </if>
  8674. </if>
  8675. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8676. <if test="qcResultShortPageVO.startDate != null ">
  8677. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8678. </if>
  8679. <if test="qcResultShortPageVO.endDate != null">
  8680. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8681. </if>
  8682. </if>
  8683. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8684. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8685. </if>
  8686. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8687. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  8688. </if>
  8689. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8690. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  8691. </if>
  8692. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8693. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8694. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8695. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8696. </if>
  8697. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8698. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8699. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8700. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8701. </if>
  8702. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8703. AND b.`level` = #{qcResultShortPageVO.level}
  8704. </if>
  8705. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8706. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8707. </if>
  8708. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8709. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8710. </if>
  8711. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  8712. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  8713. </if>
  8714. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  8715. AND d.id = #{qcResultShortPageVO.casesEntryId}
  8716. </if>
  8717. <if test="qcResultShortPageVO.isReject != null">
  8718. AND c.is_reject = #{qcResultShortPageVO.isReject}
  8719. </if>
  8720. <if test="qcResultShortPageVO.ruleType != null">
  8721. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  8722. </if>
  8723. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  8724. AND TIMESTAMPDIFF(
  8725. DAY,
  8726. DATE( a.behospital_date ),
  8727. DATE( a.leave_hospital_date ))> 30
  8728. </if>
  8729. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  8730. AND TIMESTAMPDIFF(
  8731. DAY,
  8732. DATE( a.behospital_date ),
  8733. DATE( a.leave_hospital_date ))> 31
  8734. </if>
  8735. )be
  8736. left join med_check_info mci
  8737. on mci.is_deleted = 'N'
  8738. and mci.check_type = 0
  8739. and be.hospital_id = mci.hospital_id
  8740. and be.behospital_code = mci.behospital_code
  8741. left join med_check_info hm_mci
  8742. on hm_mci.is_deleted = 'N'
  8743. and hm_mci.check_type = 1
  8744. and be.hospital_id = hm_mci.hospital_id
  8745. and be.behospital_code = hm_mci.behospital_code
  8746. LEFT JOIN med_qcresult_cases e
  8747. on be.behospital_code = e.behospital_code
  8748. and be.hospital_id = e.hospital_id
  8749. AND e.is_deleted = 'N'
  8750. and e.cases_id = 243
  8751. )tt1
  8752. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  8753. ,med_medical_record tt2
  8754. WHERE
  8755. tt2.is_deleted = 'N'
  8756. AND tt1.hospital_id = tt2.hospital_id
  8757. AND tt1.behospital_code = tt2.behospital_code
  8758. AND tt2.mode_id = 30
  8759. </if>
  8760. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  8761. ,med_crisis_info tt2
  8762. WHERE
  8763. tt2.is_deleted = 'N'
  8764. AND tt1.hospital_id = tt2.hospital_id
  8765. AND tt1.behospital_code = tt2.behospital_code
  8766. </if>
  8767. ) t1
  8768. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  8769. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  8770. AND t1.behospital_code = t2.behospital_code
  8771. AND t2.is_deleted = 'N'
  8772. </if>
  8773. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  8774. , med_home_page t2
  8775. , med_home_operation_info t3
  8776. WHERE t1.hospital_id = t2.hospital_id
  8777. AND t1.behospital_code = t2.behospital_code
  8778. AND t2.home_page_id = t3.home_page_id
  8779. AND t2.is_deleted = 'N'
  8780. AND t3.is_deleted = 'N'
  8781. </if>
  8782. ) t
  8783. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8784. AND t.hospitalId = qi.hospital_id
  8785. AND t.behospitalCode = qi.behospital_code
  8786. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  8787. AND t.hospitalId = qd.hospital_id
  8788. AND t.behospitalCode = qd.behospital_code
  8789. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  8790. AND qd.cases_id = qc.id
  8791. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  8792. AND qd.cases_id = qce.cases_id
  8793. AND qd.cases_entry_id = qce.id
  8794. where 1=1
  8795. <if test="qcResultShortPageVO.checkStatus != null">
  8796. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8797. </if>
  8798. <if test="qcResultShortPageVO.mrStatus != null">
  8799. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8800. </if>
  8801. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8802. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8803. </if>
  8804. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8805. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8806. </if>
  8807. <if test="qcResultShortPageVO.chTimeStart != null ">
  8808. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8809. </if>
  8810. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8811. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8812. </if>
  8813. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8814. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8815. </if>
  8816. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8817. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8818. </if>
  8819. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  8820. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  8821. </if>
  8822. <if test="qcResultShortPageVO.casesEntryId != null ">
  8823. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  8824. </if>
  8825. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  8826. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  8827. </if>
  8828. <if test="qcResultShortPageVO.casesId != null">
  8829. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  8830. </if>
  8831. )f1,
  8832. (SELECT
  8833. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8834. t.behDeptId,
  8835. t.behDeptName,
  8836. t.doctorId,
  8837. t.doctorName
  8838. FROM
  8839. (SELECT DISTINCT
  8840. t1.hospital_id AS hospitalId,
  8841. t1.behospital_code AS behospitalCode,
  8842. t1.bed_code AS bedCode,
  8843. t1.LEVEL AS LEVEL,
  8844. t1.grade_type AS gradeType,
  8845. t1.score_res AS scoreRes,
  8846. t1.NAME AS NAME,
  8847. t1.sex AS sex,
  8848. t1.beh_dept_id AS behDeptId,
  8849. t1.beh_dept_name AS behDeptName,
  8850. t1.doctor_id AS doctorId,
  8851. t1.doctor_name AS doctorName,
  8852. t1.beh_doctor_id AS behDoctorId,
  8853. t1.beh_doctor_name AS behDoctorName,
  8854. t1.director_doctor_id AS directorDoctorId,
  8855. t1.director_doctor_name AS directorDoctorName,
  8856. t1.birthday AS birthday,
  8857. t1.behospital_date AS behospitalDate,
  8858. t1.leave_hospital_date AS leaveHospitalDate,
  8859. t1.placefile_date AS placefileDate,
  8860. t1.gmt_create AS gradeTime,
  8861. t1.diagnose,
  8862. t1.ward_name AS wardName,
  8863. t2.age,
  8864. t1.file_code AS fileCode,
  8865. t1.checkStatus,
  8866. t1.mrStatus,
  8867. t1.chName,
  8868. t1.mrName,
  8869. t1.chTime,
  8870. t1.mrTime
  8871. FROM
  8872. (
  8873. SELECT DISTINCT
  8874. tt1.*
  8875. FROM
  8876. (SELECT
  8877. be.*,
  8878. ifnull(mci.status,0) AS checkStatus,
  8879. ifnull(hm_mci.status,0) AS mrStatus,
  8880. mci.check_name as chName,
  8881. hm_mci.check_name as mrName,
  8882. mci.gmt_create as chTime,
  8883. hm_mci.gmt_create as mrTime
  8884. FROM
  8885. (
  8886. SELECT DISTINCT
  8887. a.hospital_id,
  8888. a.behospital_code,
  8889. a.bed_code,
  8890. a.file_code,
  8891. b.LEVEL,
  8892. b.grade_type,
  8893. b.score_res,
  8894. a.NAME,
  8895. a.sex,
  8896. a.beh_dept_id,
  8897. a.beh_dept_name,
  8898. a.birthday,
  8899. a.behospital_date,
  8900. a.leave_hospital_date,
  8901. a.doctor_id,
  8902. a.doctor_name,
  8903. a.beh_doctor_id,
  8904. a.beh_doctor_name,
  8905. a.director_doctor_id,
  8906. a.director_doctor_name,
  8907. a.diagnose,
  8908. a.placefile_date,
  8909. a.ward_name,
  8910. b.gmt_create
  8911. FROM
  8912. med_behospital_info a,
  8913. med_qcresult_info b,
  8914. med_qcresult_detail c,
  8915. qc_cases_entry d,
  8916. sys_user_dept e
  8917. WHERE
  8918. a.is_deleted = 'N'
  8919. AND b.is_deleted = 'N'
  8920. AND c.is_deleted = 'N'
  8921. AND d.is_deleted = 'N'
  8922. AND e.is_deleted = 'N'
  8923. AND a.hospital_id = b.hospital_id
  8924. AND a.hospital_id = c.hospital_id
  8925. AND a.hospital_id = e.hospital_id
  8926. AND a.behospital_code = b.behospital_code
  8927. AND a.behospital_code = c.behospital_code
  8928. AND a.beh_dept_id = e.dept_id
  8929. AND c.cases_id = d.cases_id
  8930. AND c.cases_entry_id = d.id
  8931. AND a.qc_type_id != 0
  8932. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8933. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8934. </if>
  8935. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8936. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8937. </if>
  8938. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8939. <if test="qcResultShortPageVO.startDate != null ">
  8940. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8941. </if>
  8942. <if test="qcResultShortPageVO.endDate != null ">
  8943. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8944. </if>
  8945. </if>
  8946. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8947. <if test="qcResultShortPageVO.startDate != null ">
  8948. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8949. </if>
  8950. <if test="qcResultShortPageVO.endDate != null">
  8951. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8952. </if>
  8953. </if>
  8954. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8955. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8956. </if>
  8957. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8958. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  8959. </if>
  8960. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8961. AND b.`level` = #{qcResultShortPageVO.level}
  8962. </if>
  8963. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8964. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8965. </if>
  8966. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8967. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8968. </if>
  8969. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  8970. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  8971. </if>
  8972. <if test="qcResultShortPageVO.casesEntryId != null ">
  8973. AND d.id = #{qcResultShortPageVO.casesEntryId}
  8974. </if>
  8975. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  8976. AND d.cases_name = #{qcResultShortPageVO.casesName}
  8977. </if>
  8978. <if test="qcResultShortPageVO.casesId != null">
  8979. AND d.cases_id = #{qcResultShortPageVO.casesId}
  8980. </if>
  8981. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8982. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8983. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8984. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8985. </if>
  8986. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8987. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8988. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8989. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8990. </if>
  8991. <if test="qcResultShortPageVO.isReject != null">
  8992. AND c.is_reject = #{qcResultShortPageVO.isReject}
  8993. </if>
  8994. <if test="qcResultShortPageVO.ruleType != null">
  8995. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  8996. </if>
  8997. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  8998. AND TIMESTAMPDIFF(
  8999. DAY,
  9000. DATE( a.behospital_date ),
  9001. DATE( a.leave_hospital_date ))> 30
  9002. </if>
  9003. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9004. AND TIMESTAMPDIFF(
  9005. DAY,
  9006. DATE( a.behospital_date ),
  9007. DATE( a.leave_hospital_date ))> 31
  9008. </if>
  9009. )be
  9010. left join med_check_info mci
  9011. on mci.is_deleted = 'N'
  9012. and mci.check_type = 0
  9013. and be.hospital_id = mci.hospital_id
  9014. and be.behospital_code = mci.behospital_code
  9015. left join med_check_info hm_mci
  9016. on hm_mci.is_deleted = 'N'
  9017. and hm_mci.check_type = 1
  9018. and be.hospital_id = hm_mci.hospital_id
  9019. and be.behospital_code = hm_mci.behospital_code
  9020. )tt1
  9021. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9022. ,med_medical_record tt2
  9023. WHERE
  9024. tt2.is_deleted = 'N'
  9025. AND tt1.hospital_id = tt2.hospital_id
  9026. AND tt1.behospital_code = tt2.behospital_code
  9027. AND tt2.mode_id = 30
  9028. </if>
  9029. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9030. ,med_crisis_info tt2
  9031. WHERE
  9032. tt2.is_deleted = 'N'
  9033. AND tt1.hospital_id = tt2.hospital_id
  9034. AND tt1.behospital_code = tt2.behospital_code
  9035. </if>
  9036. ) t1
  9037. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9038. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9039. AND t1.behospital_code = t2.behospital_code
  9040. AND t2.is_deleted = 'N'
  9041. </if>
  9042. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9043. , med_home_page t2
  9044. , med_home_operation_info t3
  9045. WHERE t1.hospital_id = t2.hospital_id
  9046. AND t1.behospital_code = t2.behospital_code
  9047. AND t2.home_page_id = t3.home_page_id
  9048. AND t2.is_deleted = 'N'
  9049. AND t3.is_deleted = 'N'
  9050. </if>
  9051. ) t
  9052. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9053. AND t.hospitalId = qi.hospital_id
  9054. AND t.behospitalCode = qi.behospital_code
  9055. where 1=1
  9056. <if test="qcResultShortPageVO.checkStatus != null">
  9057. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9058. </if>
  9059. <if test="qcResultShortPageVO.mrStatus != null">
  9060. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9061. </if>
  9062. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9063. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9064. </if>
  9065. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9066. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9067. </if>
  9068. <if test="qcResultShortPageVO.chTimeStart != null ">
  9069. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9070. </if>
  9071. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9072. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9073. </if>
  9074. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9075. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9076. </if>
  9077. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9078. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9079. </if>
  9080. GROUP BY
  9081. t.behDeptId,
  9082. t.behDeptName,
  9083. t.doctorId,
  9084. t.doctorName
  9085. )f2
  9086. WHERE
  9087. f1.doctorId = f2.doctorId
  9088. AND f1.doctorName = f2.doctorName
  9089. )m
  9090. </select>
  9091. <!-- 条目缺陷评分详情页导出-->
  9092. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  9093. SELECT * from(
  9094. SELECT
  9095. f1.*,
  9096. f2.avgScore
  9097. FROM
  9098. (SELECT
  9099. t.*,
  9100. qi.score_res AS score,
  9101. qd.msg AS msg,
  9102. qc.NAME AS caseName
  9103. FROM
  9104. (SELECT DISTINCT
  9105. t1.hospital_id AS hospitalId,
  9106. t1.behospital_code AS behospitalCode,
  9107. t1.bed_code AS bedCode,
  9108. t1.LEVEL AS LEVEL,
  9109. t1.grade_type AS gradeType,
  9110. t1.score_res AS scoreRes,
  9111. t1.scoreBn AS scoreBn,
  9112. t1.NAME AS patName,
  9113. t1.sex AS sex,
  9114. t1.beh_dept_id AS behDeptId,
  9115. t1.beh_dept_name AS behDeptName,
  9116. t1.doctor_id AS doctorId,
  9117. t1.doctor_name AS doctorName,
  9118. t1.beh_doctor_id AS behDoctorId,
  9119. t1.beh_doctor_name AS behDoctorName,
  9120. t1.director_doctor_id AS directorDoctorId,
  9121. t1.director_doctor_name AS directorDoctorName,
  9122. t1.birthday AS birthday,
  9123. t1.behospital_date AS behospitalDate,
  9124. t1.leave_hospital_date AS leaveHospitalDate,
  9125. t1.placefile_date AS placefileDate,
  9126. t1.gmt_create AS gradeTime,
  9127. t1.diagnose AS diagnose,
  9128. t1.ward_name AS wardName,
  9129. t1.file_code AS fileCode,
  9130. t1.checkStatus AS checkStatus,
  9131. t1.mrStatus AS mrStatus,
  9132. t1.chName AS chName,
  9133. t1.mrName AS mrName,
  9134. t1.chTime AS chTime,
  9135. t1.mrTime AS mrTime
  9136. FROM
  9137. (
  9138. SELECT DISTINCT
  9139. tt1.*
  9140. FROM
  9141. (SELECT
  9142. be.*,
  9143. ifnull(mci.status,0) AS checkStatus,
  9144. ifnull(hm_mci.status,0) AS mrStatus,
  9145. mci.check_name as chName,
  9146. hm_mci.check_name as mrName,
  9147. mci.gmt_create as chTime,
  9148. e.score_res as scoreBn,
  9149. hm_mci.gmt_create as mrTime
  9150. FROM
  9151. (
  9152. SELECT DISTINCT
  9153. a.hospital_id,
  9154. a.behospital_code,
  9155. a.bed_code,
  9156. a.file_code,
  9157. b.LEVEL,
  9158. b.grade_type,
  9159. b.score_res,
  9160. a.NAME,
  9161. a.sex,
  9162. a.beh_dept_id,
  9163. a.beh_dept_name,
  9164. a.birthday,
  9165. a.behospital_date,
  9166. a.leave_hospital_date,
  9167. a.doctor_id,
  9168. a.doctor_name,
  9169. a.beh_doctor_id,
  9170. a.beh_doctor_name,
  9171. a.director_doctor_id,
  9172. a.director_doctor_name,
  9173. a.diagnose,
  9174. a.placefile_date,
  9175. a.ward_name,
  9176. b.gmt_create
  9177. FROM
  9178. med_behospital_info a,
  9179. med_qcresult_info b,
  9180. med_qcresult_detail c,
  9181. qc_cases_entry d
  9182. WHERE
  9183. a.is_deleted = 'N'
  9184. AND b.is_deleted = 'N'
  9185. AND c.is_deleted = 'N'
  9186. AND d.is_deleted = 'N'
  9187. AND a.hospital_id = b.hospital_id
  9188. AND a.hospital_id = c.hospital_id
  9189. AND a.behospital_code = b.behospital_code
  9190. AND a.behospital_code = c.behospital_code
  9191. AND c.cases_id = d.cases_id
  9192. AND c.cases_entry_id = d.id
  9193. AND a.qc_type_id != 0
  9194. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9195. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9196. </if>
  9197. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9198. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9199. </if>
  9200. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9201. <if test="qcResultShortPageVO.startDate != null ">
  9202. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9203. </if>
  9204. <if test="qcResultShortPageVO.endDate != null ">
  9205. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9206. </if>
  9207. </if>
  9208. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9209. <if test="qcResultShortPageVO.startDate != null ">
  9210. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9211. </if>
  9212. <if test="qcResultShortPageVO.endDate != null">
  9213. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9214. </if>
  9215. </if>
  9216. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9217. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9218. </if>
  9219. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9220. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  9221. </if>
  9222. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9223. AND b.`level` = #{qcResultShortPageVO.level}
  9224. </if>
  9225. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9226. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9227. </if>
  9228. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9229. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9230. </if>
  9231. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9232. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9233. </if>
  9234. <if test="qcResultShortPageVO.casesEntryId != null ">
  9235. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9236. </if>
  9237. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9238. AND d.cases_name = #{qcResultShortPageVO.casesName}
  9239. </if>
  9240. <if test="qcResultShortPageVO.casesId != null">
  9241. AND d.cases_id = #{qcResultShortPageVO.casesId}
  9242. </if>
  9243. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9244. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9245. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9246. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9247. </if>
  9248. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9249. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9250. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9251. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9252. </if>
  9253. <if test="qcResultShortPageVO.isReject != null">
  9254. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9255. </if>
  9256. <if test="qcResultShortPageVO.ruleType != null">
  9257. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9258. </if>
  9259. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9260. AND TIMESTAMPDIFF(
  9261. DAY,
  9262. DATE( a.behospital_date ),
  9263. DATE( a.leave_hospital_date ))> 30
  9264. </if>
  9265. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9266. AND TIMESTAMPDIFF(
  9267. DAY,
  9268. DATE( a.behospital_date ),
  9269. DATE( a.leave_hospital_date ))> 31
  9270. </if>
  9271. )be
  9272. left join med_check_info mci
  9273. on mci.is_deleted = 'N'
  9274. and mci.check_type = 0
  9275. and be.hospital_id = mci.hospital_id
  9276. and be.behospital_code = mci.behospital_code
  9277. left join med_check_info hm_mci
  9278. on hm_mci.is_deleted = 'N'
  9279. and hm_mci.check_type = 1
  9280. and be.hospital_id = hm_mci.hospital_id
  9281. and be.behospital_code = hm_mci.behospital_code
  9282. LEFT JOIN med_qcresult_cases e
  9283. on be.behospital_code = e.behospital_code
  9284. and be.hospital_id = e.hospital_id
  9285. AND e.is_deleted = 'N'
  9286. and e.cases_id = 243
  9287. )tt1
  9288. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9289. ,med_medical_record tt2
  9290. WHERE
  9291. tt2.is_deleted = 'N'
  9292. AND tt1.hospital_id = tt2.hospital_id
  9293. AND tt1.behospital_code = tt2.behospital_code
  9294. AND tt2.mode_id = 30
  9295. </if>
  9296. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9297. ,med_crisis_info tt2
  9298. WHERE
  9299. tt2.is_deleted = 'N'
  9300. AND tt1.hospital_id = tt2.hospital_id
  9301. AND tt1.behospital_code = tt2.behospital_code
  9302. </if>
  9303. ) t1
  9304. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9305. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9306. AND t1.behospital_code = t2.behospital_code
  9307. AND t2.is_deleted = 'N'
  9308. </if>
  9309. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9310. , med_home_page t2
  9311. , med_home_operation_info t3
  9312. WHERE t1.hospital_id = t2.hospital_id
  9313. AND t1.behospital_code = t2.behospital_code
  9314. AND t2.home_page_id = t3.home_page_id
  9315. AND t2.is_deleted = 'N'
  9316. AND t3.is_deleted = 'N'
  9317. </if>
  9318. ) t
  9319. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9320. AND t.hospitalId = qi.hospital_id
  9321. AND t.behospitalCode = qi.behospital_code
  9322. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9323. AND t.hospitalId = qd.hospital_id
  9324. AND t.behospitalCode = qd.behospital_code
  9325. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9326. AND qd.cases_id = qc.id
  9327. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  9328. AND qd.cases_id = qce.cases_id
  9329. AND qd.cases_entry_id = qce.id
  9330. where 1=1
  9331. <if test="qcResultShortPageVO.checkStatus != null">
  9332. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9333. </if>
  9334. <if test="qcResultShortPageVO.mrStatus != null">
  9335. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9336. </if>
  9337. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9338. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9339. </if>
  9340. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9341. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9342. </if>
  9343. <if test="qcResultShortPageVO.chTimeStart != null ">
  9344. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9345. </if>
  9346. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9347. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9348. </if>
  9349. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9350. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9351. </if>
  9352. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9353. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9354. </if>
  9355. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9356. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  9357. </if>
  9358. <if test="qcResultShortPageVO.casesEntryId != null ">
  9359. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  9360. </if>
  9361. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9362. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  9363. </if>
  9364. <if test="qcResultShortPageVO.casesId != null">
  9365. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  9366. </if>
  9367. )f1,
  9368. (SELECT
  9369. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9370. t.behDeptId,
  9371. t.behDeptName
  9372. FROM
  9373. (SELECT DISTINCT
  9374. t1.hospital_id AS hospitalId,
  9375. t1.behospital_code AS behospitalCode,
  9376. t1.bed_code AS bedCode,
  9377. t1.LEVEL AS LEVEL,
  9378. t1.grade_type AS gradeType,
  9379. t1.score_res AS scoreRes,
  9380. t1.NAME AS NAME,
  9381. t1.sex AS sex,
  9382. t1.beh_dept_id AS behDeptId,
  9383. t1.beh_dept_name AS behDeptName,
  9384. t1.doctor_id AS doctorId,
  9385. t1.doctor_name AS doctorName,
  9386. t1.beh_doctor_id AS behDoctorId,
  9387. t1.beh_doctor_name AS behDoctorName,
  9388. t1.director_doctor_id AS directorDoctorId,
  9389. t1.director_doctor_name AS directorDoctorName,
  9390. t1.birthday AS birthday,
  9391. t1.behospital_date AS behospitalDate,
  9392. t1.leave_hospital_date AS leaveHospitalDate,
  9393. t1.placefile_date AS placefileDate,
  9394. t1.gmt_create AS gradeTime,
  9395. t1.diagnose,
  9396. t1.ward_name AS wardName,
  9397. t2.age,
  9398. t1.file_code AS fileCode,
  9399. t1.checkStatus,
  9400. t1.mrStatus,
  9401. t1.chName,
  9402. t1.mrName,
  9403. t1.chTime,
  9404. t1.mrTime
  9405. FROM
  9406. (
  9407. SELECT DISTINCT
  9408. tt1.*
  9409. FROM
  9410. (SELECT
  9411. be.*,
  9412. ifnull(mci.status,0) AS checkStatus,
  9413. ifnull(hm_mci.status,0) AS mrStatus,
  9414. mci.check_name as chName,
  9415. hm_mci.check_name as mrName,
  9416. mci.gmt_create as chTime,
  9417. hm_mci.gmt_create as mrTime
  9418. FROM
  9419. (
  9420. SELECT DISTINCT
  9421. a.hospital_id,
  9422. a.behospital_code,
  9423. a.bed_code,
  9424. a.file_code,
  9425. b.LEVEL,
  9426. b.grade_type,
  9427. b.score_res,
  9428. a.NAME,
  9429. a.sex,
  9430. a.beh_dept_id,
  9431. a.beh_dept_name,
  9432. a.birthday,
  9433. a.behospital_date,
  9434. a.leave_hospital_date,
  9435. a.doctor_id,
  9436. a.doctor_name,
  9437. a.beh_doctor_id,
  9438. a.beh_doctor_name,
  9439. a.director_doctor_id,
  9440. a.director_doctor_name,
  9441. a.diagnose,
  9442. a.placefile_date,
  9443. a.ward_name,
  9444. b.gmt_create
  9445. FROM
  9446. med_behospital_info a,
  9447. med_qcresult_info b,
  9448. med_qcresult_detail c,
  9449. qc_cases_entry d
  9450. WHERE
  9451. a.is_deleted = 'N'
  9452. AND b.is_deleted = 'N'
  9453. AND c.is_deleted = 'N'
  9454. AND d.is_deleted = 'N'
  9455. AND a.hospital_id = b.hospital_id
  9456. AND a.hospital_id = c.hospital_id
  9457. AND a.behospital_code = b.behospital_code
  9458. AND a.behospital_code = c.behospital_code
  9459. AND c.cases_id = d.cases_id
  9460. AND c.cases_entry_id = d.id
  9461. AND a.qc_type_id != 0
  9462. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9463. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9464. </if>
  9465. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9466. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9467. </if>
  9468. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9469. <if test="qcResultShortPageVO.startDate != null ">
  9470. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9471. </if>
  9472. <if test="qcResultShortPageVO.endDate != null ">
  9473. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9474. </if>
  9475. </if>
  9476. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9477. <if test="qcResultShortPageVO.startDate != null ">
  9478. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9479. </if>
  9480. <if test="qcResultShortPageVO.endDate != null">
  9481. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9482. </if>
  9483. </if>
  9484. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9485. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9486. </if>
  9487. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9488. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  9489. </if>
  9490. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9491. AND b.`level` = #{qcResultShortPageVO.level}
  9492. </if>
  9493. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9494. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9495. </if>
  9496. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9497. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9498. </if>
  9499. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9500. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9501. </if>
  9502. <if test="qcResultShortPageVO.casesEntryId != null ">
  9503. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9504. </if>
  9505. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9506. AND d.cases_name = #{qcResultShortPageVO.casesName}
  9507. </if>
  9508. <if test="qcResultShortPageVO.casesId != null">
  9509. AND d.cases_id = #{qcResultShortPageVO.casesId}
  9510. </if>
  9511. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9512. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9513. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9514. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9515. </if>
  9516. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9517. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9518. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9519. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9520. </if>
  9521. <if test="qcResultShortPageVO.isReject != null">
  9522. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9523. </if>
  9524. <if test="qcResultShortPageVO.ruleType != null">
  9525. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9526. </if>
  9527. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9528. AND TIMESTAMPDIFF(
  9529. DAY,
  9530. DATE( a.behospital_date ),
  9531. DATE( a.leave_hospital_date ))> 30
  9532. </if>
  9533. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9534. AND TIMESTAMPDIFF(
  9535. DAY,
  9536. DATE( a.behospital_date ),
  9537. DATE( a.leave_hospital_date ))> 31
  9538. </if>
  9539. )be
  9540. left join med_check_info mci
  9541. on mci.is_deleted = 'N'
  9542. and mci.check_type = 0
  9543. and be.hospital_id = mci.hospital_id
  9544. and be.behospital_code = mci.behospital_code
  9545. left join med_check_info hm_mci
  9546. on hm_mci.is_deleted = 'N'
  9547. and hm_mci.check_type = 1
  9548. and be.hospital_id = hm_mci.hospital_id
  9549. and be.behospital_code = hm_mci.behospital_code
  9550. )tt1
  9551. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9552. ,med_medical_record tt2
  9553. WHERE
  9554. tt2.is_deleted = 'N'
  9555. AND tt1.hospital_id = tt2.hospital_id
  9556. AND tt1.behospital_code = tt2.behospital_code
  9557. AND tt2.mode_id = 30
  9558. </if>
  9559. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9560. ,med_crisis_info tt2
  9561. WHERE
  9562. tt2.is_deleted = 'N'
  9563. AND tt1.hospital_id = tt2.hospital_id
  9564. AND tt1.behospital_code = tt2.behospital_code
  9565. </if>
  9566. ) t1
  9567. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9568. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9569. AND t1.behospital_code = t2.behospital_code
  9570. AND t2.is_deleted = 'N'
  9571. </if>
  9572. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9573. , med_home_page t2
  9574. , med_home_operation_info t3
  9575. WHERE t1.hospital_id = t2.hospital_id
  9576. AND t1.behospital_code = t2.behospital_code
  9577. AND t2.home_page_id = t3.home_page_id
  9578. AND t2.is_deleted = 'N'
  9579. AND t3.is_deleted = 'N'
  9580. </if>
  9581. ) t
  9582. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9583. AND t.hospitalId = qi.hospital_id
  9584. AND t.behospitalCode = qi.behospital_code
  9585. where 1=1
  9586. <if test="qcResultShortPageVO.checkStatus != null">
  9587. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9588. </if>
  9589. <if test="qcResultShortPageVO.mrStatus != null">
  9590. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9591. </if>
  9592. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9593. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9594. </if>
  9595. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9596. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9597. </if>
  9598. <if test="qcResultShortPageVO.chTimeStart != null ">
  9599. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9600. </if>
  9601. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9602. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9603. </if>
  9604. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9605. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9606. </if>
  9607. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9608. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9609. </if>
  9610. GROUP BY
  9611. t.behDeptId,
  9612. t.behDeptName
  9613. )f2
  9614. WHERE
  9615. f1.behDeptId = f2.behDeptId
  9616. AND f1.behDeptName = f2.behDeptName
  9617. )m
  9618. </select>
  9619. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  9620. <result column="deptName" property="deptName"/>
  9621. <result column="deptId" property="deptId"/>
  9622. <result column="doctorName" property="doctorName"/>
  9623. <result column="entry_2658_num" property="entry_2658_num"/>
  9624. <result column="entry_2686_num" property="entry_2686_num"/>
  9625. <result column="entry_2657_num" property="entry_2657_num"/>
  9626. <result column="entry_3010_num" property="entry_3010_num"/>
  9627. <result column="entry_2655_num" property="entry_2655_num"/>
  9628. <result column="entry_2654_num" property="entry_2654_num"/>
  9629. <result column="entry_2852_num" property="entry_2852_num"/>
  9630. <result column="entry_2287_num" property="entry_2287_num"/>
  9631. <result column="entry_3025_num" property="entry_3025_num"/>
  9632. <result column="entry_2170_num" property="entry_2170_num"/>
  9633. <result column="entry_2930_num" property="entry_2930_num"/>
  9634. <result column="entry_2900_num" property="entry_2900_num"/>
  9635. <result column="entry_2229_num" property="entry_2229_num"/>
  9636. <result column="entry_2217_num" property="entry_2217_num"/>
  9637. <result column="entry_2218_num" property="entry_2218_num"/>
  9638. <result column="entry_2220_num" property="entry_2220_num"/>
  9639. <result column="entry_2486_num" property="entry_2486_num"/>
  9640. <result column="entry_3063_num" property="entry_3063_num"/>
  9641. <result column="entry_3062_num" property="entry_3062_num"/>
  9642. <result column="entry_2495_num" property="entry_2495_num"/>
  9643. </resultMap>
  9644. <!-- 病历稽查表最新sql-->
  9645. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  9646. SELECT
  9647. a.beh_dept_id AS deptId,
  9648. a.beh_dept_name AS deptName,
  9649. a.doctor_name as doctorName,
  9650. sum(c.cases_entry_id = 2658) as entry_2658_num,
  9651. sum(c.cases_entry_id = 2686) as entry_2686_num,
  9652. sum(c.cases_entry_id = 2657) as entry_2657_num,
  9653. sum(c.cases_entry_id = 3010) as entry_3010_num,
  9654. sum(c.cases_entry_id = 2655) as entry_2655_num,
  9655. sum(c.cases_entry_id = 2654) as entry_2654_num,
  9656. sum(c.cases_entry_id = 2852) as entry_2852_num,
  9657. sum(c.cases_entry_id = 2287) as entry_2287_num,
  9658. sum(c.cases_entry_id = 3025) as entry_3025_num,
  9659. sum(c.cases_entry_id = 2170) as entry_2170_num,
  9660. sum(c.cases_entry_id = 2930) as entry_2930_num,
  9661. sum(c.cases_entry_id = 2900) as entry_2900_num,
  9662. sum(c.cases_entry_id = 2229) as entry_2229_num,
  9663. sum(c.cases_entry_id = 2217) as entry_2217_num,
  9664. sum(c.cases_entry_id = 2218) as entry_2218_num,
  9665. sum(c.cases_entry_id = 2220) as entry_2220_num,
  9666. sum(c.cases_entry_id = 2486) as entry_2486_num,
  9667. sum(c.cases_entry_id = 3063) as entry_3063_num,
  9668. sum(c.cases_entry_id = 3062) as entry_3062_num,
  9669. sum(c.cases_entry_id = 2495) as entry_2495_num
  9670. FROM
  9671. med_behospital_info a,
  9672. med_qcresult_info b,
  9673. med_qcresult_detail c,
  9674. qc_cases_entry d,
  9675. bas_doctor_info e
  9676. WHERE
  9677. a.is_deleted = 'N'
  9678. AND b.is_deleted = 'N'
  9679. AND c.is_deleted = 'N'
  9680. AND d.is_deleted = 'N'
  9681. AND e.is_deleted = 'N'
  9682. AND a.hospital_id = b.hospital_id
  9683. AND a.hospital_id = c.hospital_id
  9684. AND a.hospital_id = e.hospital_id
  9685. AND a.behospital_code = b.behospital_code
  9686. AND a.behospital_code = c.behospital_code
  9687. AND c.cases_entry_id = d.id
  9688. and a.doctor_id=e.doctor_id
  9689. and e.group_id is not NULL
  9690. AND LENGTH(e.group_id)>0
  9691. AND a.qc_type_id != 0
  9692. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  9693. and a.is_placefile = #{filterVO.isPlacefile}
  9694. </if>
  9695. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  9696. AND a.hospital_id = #{filterVO.hospitalId}
  9697. </if>
  9698. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  9699. <if test="filterVO.startDate != null ">
  9700. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  9701. </if>
  9702. <if test="filterVO.endDate != null ">
  9703. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  9704. </if>
  9705. </if>
  9706. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  9707. <if test="filterVO.startDate != null ">
  9708. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  9709. </if>
  9710. <if test="filterVO.endDate != null ">
  9711. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  9712. </if>
  9713. </if>
  9714. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  9715. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  9716. </if>
  9717. GROUP BY
  9718. a.beh_dept_id,
  9719. e.group_id,
  9720. a.doctor_id
  9721. </select>
  9722. <!-- 病历稽查表最新sql、id&&name-->
  9723. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  9724. SELECT
  9725. d.id,
  9726. d.name
  9727. from
  9728. qc_cases_entry d
  9729. where
  9730. 1=1
  9731. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  9732. and d.id in
  9733. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  9734. '${item}'
  9735. </foreach>
  9736. </if>
  9737. </select>
  9738. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  9739. <result column="deptName" property="deptName"/>
  9740. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  9741. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  9742. <result column="doctorName" property="doctorName"/>
  9743. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  9744. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  9745. <result column="RYJLW_24" property="ryjlw_24"/>
  9746. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  9747. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  9748. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  9749. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  9750. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  9751. <result column="QJJLW_6H" property="qjjlw_6h"/>
  9752. <result column="HZJLW_24H" property="hzjlw_24h"/>
  9753. <result column="SQTLXJW" property="sqtlxjw"/>
  9754. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  9755. <result column="XHSCW_30M" property="xhscw_30m"/>
  9756. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  9757. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  9758. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  9759. <result column="ZKJLW_24" property="zkjlw_24"/>
  9760. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  9761. <result column="SXHWJL" property="sxhwjl"/>
  9762. <result column="SXPJW_24" property="sxpjw_24"/>
  9763. <result column="WJZWJL" property="wjzwjl"/>
  9764. <result column="WYWWCXJ" property="wywwcxj"/>
  9765. </collection>
  9766. </collection>
  9767. </resultMap>
  9768. <!-- 病历稽查表最新导出-->
  9769. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  9770. SELECT
  9771. a.beh_dept_id AS deptId,
  9772. a.beh_dept_name AS deptName,
  9773. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  9774. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  9775. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  9776. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  9777. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  9778. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  9779. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  9780. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  9781. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  9782. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  9783. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  9784. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  9785. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  9786. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  9787. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  9788. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  9789. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  9790. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  9791. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  9792. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  9793. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  9794. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  9795. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  9796. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  9797. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  9798. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  9799. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  9800. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  9801. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  9802. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  9803. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  9804. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  9805. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  9806. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  9807. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  9808. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  9809. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  9810. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  9811. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  9812. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  9813. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  9814. FROM
  9815. med_behospital_info a,
  9816. med_qcresult_info b,
  9817. med_qcresult_detail c,
  9818. qc_cases_entry d,
  9819. bas_doctor_info e
  9820. WHERE
  9821. a.is_deleted = 'N'
  9822. AND b.is_deleted = 'N'
  9823. AND c.is_deleted = 'N'
  9824. AND d.is_deleted = 'N'
  9825. AND e.is_deleted = 'N'
  9826. AND a.hospital_id = b.hospital_id
  9827. AND a.hospital_id = c.hospital_id
  9828. AND a.hospital_id = e.hospital_id
  9829. AND a.behospital_code = b.behospital_code
  9830. AND a.behospital_code = c.behospital_code
  9831. AND c.cases_entry_id = d.id
  9832. and a.doctor_id=e.doctor_id
  9833. and e.group_id is not NULL
  9834. AND LENGTH(e.group_id)>0
  9835. AND a.qc_type_id != 0
  9836. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  9837. and a.is_placefile = #{filterVO.isPlacefile}
  9838. </if>
  9839. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  9840. AND a.hospital_id = #{filterVO.hospitalId}
  9841. </if>
  9842. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  9843. <if test="filterVO.startDate != null ">
  9844. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  9845. </if>
  9846. <if test="filterVO.endDate != null ">
  9847. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  9848. </if>
  9849. </if>
  9850. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  9851. <if test="filterVO.startDate != null ">
  9852. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  9853. </if>
  9854. <if test="filterVO.endDate != null ">
  9855. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  9856. </if>
  9857. </if>
  9858. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  9859. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  9860. </if>
  9861. GROUP BY
  9862. a.beh_dept_id,
  9863. e.group_id
  9864. </select>
  9865. <!-- 未整改病历统计-->
  9866. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  9867. SELECT
  9868. a.beh_dept_id AS deptId,
  9869. a.beh_dept_name AS deptName,
  9870. d.id AS casesEntryId,
  9871. d.NAME AS casesEntryName,
  9872. count(*) AS casesEntryNum
  9873. FROM
  9874. med_behospital_info a,
  9875. med_qcresult_info b,
  9876. med_qcresult_detail c,
  9877. qc_cases_entry d
  9878. WHERE
  9879. a.is_deleted = 'N'
  9880. AND b.is_deleted = 'N'
  9881. AND c.is_deleted = 'N'
  9882. AND d.is_deleted = 'N'
  9883. AND a.hospital_id = b.hospital_id
  9884. AND a.hospital_id = c.hospital_id
  9885. AND a.behospital_code = b.behospital_code
  9886. AND a.behospital_code = c.behospital_code
  9887. AND c.cases_entry_id = d.id
  9888. AND a.qc_type_id != 0
  9889. <if test="isPlacefile != null and isPlacefile != ''">
  9890. and a.is_placefile = #{isPlacefile}
  9891. </if>
  9892. <if test="hospitalId != null and hospitalId != ''">
  9893. AND a.hospital_id = #{hospitalId}
  9894. </if>
  9895. <if test="isPlacefile != null and isPlacefile == 0">
  9896. <if test="startDate != null ">
  9897. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  9898. </if>
  9899. <if test="endDate != null ">
  9900. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  9901. </if>
  9902. </if>
  9903. <if test="isPlacefile != null and isPlacefile == 1">
  9904. <if test="startDate != null ">
  9905. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  9906. </if>
  9907. <if test="endDate != null ">
  9908. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  9909. </if>
  9910. </if>
  9911. <if test="deptName != null and deptName != ''">
  9912. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  9913. </if>
  9914. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  9915. AND c.cases_entry_id IN
  9916. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  9917. #{item}
  9918. </foreach>
  9919. </if>
  9920. GROUP BY
  9921. a.beh_dept_id,
  9922. a.beh_dept_name,
  9923. c.cases_entry_id,
  9924. d.NAME
  9925. </select>
  9926. <!-- 未整改病历统计-科室-->
  9927. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  9928. SELECT
  9929. a.beh_dept_id AS deptId,
  9930. a.beh_dept_name AS deptName,
  9931. a.doctor_id as doctorId,
  9932. a.doctor_name as doctorName,
  9933. d.id AS casesEntryId,
  9934. d.NAME AS casesEntryName,
  9935. count(*) AS casesEntryNum
  9936. FROM
  9937. med_behospital_info a,
  9938. med_qcresult_info b,
  9939. med_qcresult_detail c,
  9940. qc_cases_entry d,
  9941. sys_user_dept f
  9942. WHERE
  9943. a.is_deleted = 'N'
  9944. AND b.is_deleted = 'N'
  9945. AND c.is_deleted = 'N'
  9946. AND d.is_deleted = 'N'
  9947. AND f.is_deleted = 'N'
  9948. AND a.hospital_id = b.hospital_id
  9949. AND a.hospital_id = c.hospital_id
  9950. AND a.hospital_id = f.hospital_id
  9951. AND a.behospital_code = b.behospital_code
  9952. AND a.behospital_code = c.behospital_code
  9953. AND a.beh_dept_id = f.dept_id
  9954. AND c.cases_entry_id = d.id
  9955. AND a.qc_type_id != 0
  9956. <if test="userId!=null">
  9957. AND f.user_id = #{userId}
  9958. </if>
  9959. <if test="isPlacefile != null and isPlacefile != ''">
  9960. and a.is_placefile = #{isPlacefile}
  9961. </if>
  9962. <if test="hospitalId != null and hospitalId != ''">
  9963. AND a.hospital_id = #{hospitalId}
  9964. </if>
  9965. <if test="isPlacefile != null and isPlacefile == 0">
  9966. <if test="startDate != null ">
  9967. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  9968. </if>
  9969. <if test="endDate != null ">
  9970. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  9971. </if>
  9972. </if>
  9973. <if test="isPlacefile != null and isPlacefile == 1">
  9974. <if test="startDate != null ">
  9975. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  9976. </if>
  9977. <if test="endDate != null ">
  9978. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  9979. </if>
  9980. </if>
  9981. <if test="deptName != null and deptName != ''">
  9982. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  9983. </if>
  9984. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  9985. AND c.cases_entry_id IN
  9986. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  9987. #{item}
  9988. </foreach>
  9989. </if>
  9990. GROUP BY
  9991. a.doctor_id,
  9992. a.doctor_name,
  9993. c.cases_entry_id,
  9994. d.NAME
  9995. </select>
  9996. <!-- 不合格/合格数病历号(内页)科室-->
  9997. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  9998. SELECT t.*
  9999. FROM
  10000. (SELECT DISTINCT
  10001. t1.hospital_id AS hospitalId,
  10002. t1.behospital_code AS behospitalCode,
  10003. t1.bed_code AS bedCode,
  10004. t1.LEVEL AS LEVEL,
  10005. t1.grade_type AS gradeType,
  10006. t1.score_res AS scoreRes,
  10007. t1.scoreBn,
  10008. t1.NAME AS NAME,
  10009. t1.sex AS sex,
  10010. t1.beh_dept_id AS behDeptId,
  10011. t1.beh_dept_name AS behDeptName,
  10012. t1.doctor_id AS doctorId,
  10013. t1.doctor_name AS doctorName,
  10014. t1.beh_doctor_id AS behDoctorId,
  10015. t1.beh_doctor_name AS behDoctorName,
  10016. t1.director_doctor_id AS directorDoctorId,
  10017. t1.director_doctor_name AS directorDoctorName,
  10018. t1.birthday AS birthday,
  10019. t1.behospital_date AS behospitalDate,
  10020. t1.leave_hospital_date AS leaveHospitalDate,
  10021. t1.placefile_date AS placefileDate,
  10022. t1.gmt_create AS gradeTime,
  10023. t1.diagnose,
  10024. t1.ward_name AS wardName,
  10025. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  10026. t1.file_code AS fileCode,
  10027. t1.checkStatus,
  10028. t1.mrStatus,
  10029. t1.chName,
  10030. t1.mrName,
  10031. t1.chTime,
  10032. t1.mrTime
  10033. FROM
  10034. (SELECT
  10035. be.*,
  10036. b.LEVEL,
  10037. b.grade_type,
  10038. b.score_res,
  10039. b.gmt_create,
  10040. ifnull(mci.status,0) AS checkStatus,
  10041. ifnull(hm_mci.status,0) AS mrStatus,
  10042. mci.check_name as chName,
  10043. hm_mci.check_name as mrName,
  10044. mci.gmt_create as chTime,
  10045. hm_mci.gmt_create as mrTime
  10046. FROM
  10047. (
  10048. SELECT DISTINCT
  10049. a.hospital_id,
  10050. a.behospital_code,
  10051. a.bed_code,
  10052. a.file_code,
  10053. e.score_res as scoreBn,
  10054. a.NAME,
  10055. a.sex,
  10056. a.beh_dept_id,
  10057. a.beh_dept_name,
  10058. a.birthday,
  10059. a.behospital_date,
  10060. a.leave_hospital_date,
  10061. a.doctor_id,
  10062. a.doctor_name,
  10063. a.beh_doctor_id,
  10064. a.beh_doctor_name,
  10065. a.director_doctor_id,
  10066. a.director_doctor_name,
  10067. a.diagnose,
  10068. a.placefile_date,
  10069. a.ward_name
  10070. FROM
  10071. med_behospital_info a,
  10072. sys_user_dept c,
  10073. med_qcresult_cases e
  10074. WHERE
  10075. a.is_deleted = 'N'
  10076. AND c.is_deleted = 'N'
  10077. AND e.is_deleted = 'N'
  10078. AND a.hospital_id = c.hospital_id
  10079. AND a.hospital_id = e.hospital_id
  10080. AND a.beh_dept_id = c.dept_id
  10081. AND a.behospital_code = e.behospital_code
  10082. AND a.qc_type_id != 0
  10083. AND e.cases_id = 243
  10084. <if test="userId!=null">
  10085. AND c.user_id = #{userId}
  10086. </if>
  10087. <if test="deptName != null and deptName != ''">
  10088. and a.beh_dept_name = #{deptName}
  10089. </if>
  10090. <if test="deptClass != null and deptClass != ''">
  10091. and a.beh_dept_id = #{deptClass}
  10092. </if>
  10093. <if test="titleName != null and titleName != '' ">
  10094. <if test="titleName == '不合格数'">
  10095. AND e.`level`='不合格'
  10096. </if>
  10097. <if test="titleName == '合格数'">
  10098. AND e.`level`='合格'
  10099. </if>
  10100. </if>
  10101. <if test="isPlacefile != null and isPlacefile != ''">
  10102. and a.is_placefile = #{isPlacefile}
  10103. </if>
  10104. <if test="hospitalId != null and hospitalId != ''">
  10105. AND a.hospital_id = #{hospitalId}
  10106. </if>
  10107. <if test="isPlacefile != null and isPlacefile == 0">
  10108. <if test="startDate != null ">
  10109. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  10110. </if>
  10111. <if test="endDate != null ">
  10112. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  10113. </if>
  10114. </if>
  10115. <if test="isPlacefile != null and isPlacefile == 1">
  10116. <if test="startDate != null ">
  10117. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  10118. </if>
  10119. <if test="endDate != null">
  10120. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  10121. </if>
  10122. </if>
  10123. <if test="diagnose != null and diagnose != ''">
  10124. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  10125. </if>
  10126. <if test="behospitalCode != null and behospitalCode != ''">
  10127. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  10128. </if>
  10129. <if test="patName != null and patName != ''">
  10130. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  10131. </if>
  10132. <if test="doctorId != null and doctorId != ''">
  10133. AND (a.doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  10134. OR a.beh_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  10135. OR a.director_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' ))
  10136. </if>
  10137. <if test="doctorName != null and doctorName != ''">
  10138. AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  10139. OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  10140. OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' ))
  10141. </if>
  10142. )be
  10143. left join med_check_info mci
  10144. on mci.is_deleted = 'N'
  10145. and mci.check_type = 0
  10146. and be.hospital_id = mci.hospital_id
  10147. and be.behospital_code = mci.behospital_code
  10148. left join med_check_info hm_mci
  10149. on hm_mci.is_deleted = 'N'
  10150. and hm_mci.check_type = 1
  10151. and be.hospital_id = hm_mci.hospital_id
  10152. and be.behospital_code = hm_mci.behospital_code
  10153. left join med_qcresult_info b
  10154. on b.is_deleted = 'N'
  10155. AND be.hospital_id = b.hospital_id
  10156. AND be.behospital_code = b.behospital_code
  10157. where
  10158. 1=1
  10159. <if test="level != null and level != ''">
  10160. AND b.`level` = #{level}
  10161. </if>
  10162. ) t1
  10163. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10164. AND t1.behospital_code = t2.behospital_code
  10165. AND t2.is_deleted = 'N'
  10166. ) t,
  10167. (
  10168. SELECT
  10169. a.doctor_id as doctorId,
  10170. a.doctor_name as doctorName
  10171. FROM
  10172. med_behospital_info a,
  10173. sys_user_dept b,
  10174. med_qcresult_cases c,
  10175. med_qcresult_detail d,
  10176. qc_cases_entry e
  10177. WHERE
  10178. a.is_deleted = 'N'
  10179. AND b.is_deleted = 'N'
  10180. AND c.is_deleted = 'N'
  10181. AND d.is_deleted = 'N'
  10182. AND e.is_deleted = 'N'
  10183. AND a.hospital_id = b.hospital_id
  10184. AND a.hospital_id = c.hospital_id
  10185. AND a.hospital_id = d.hospital_id
  10186. AND a.behospital_code = c.behospital_code
  10187. AND a.behospital_code = d.behospital_code
  10188. AND a.beh_dept_id = b.dept_id
  10189. AND c.cases_id = d.cases_id
  10190. AND d.cases_id = e.cases_id
  10191. AND d.cases_entry_id = e.id
  10192. AND d.cases_id = 243
  10193. AND a.qc_type_id != 0
  10194. <!-- <if test="titleName != null ">-->
  10195. <!-- <if test="titleName == '不合格数'">-->
  10196. <!-- AND c.`level`='不合格'-->
  10197. <!-- </if>-->
  10198. <!-- <if test="titleName == '合格数'">-->
  10199. <!-- AND c.`level`='合格'-->
  10200. <!-- </if>-->
  10201. <!-- </if>-->
  10202. <if test="userId!=null">
  10203. AND b.user_id = #{userId}
  10204. </if>
  10205. <if test="deptName != null and deptName != ''">
  10206. and a.beh_dept_name = #{deptName}
  10207. </if>
  10208. <if test="deptClass != null and deptClass != ''">
  10209. and a.beh_dept_id = #{deptClass}
  10210. </if>
  10211. <if test="isPlacefile != null and isPlacefile != ''">
  10212. and a.is_placefile = #{isPlacefile}
  10213. </if>
  10214. <if test="hospitalId != null and hospitalId != ''">
  10215. AND a.hospital_id = #{hospitalId}
  10216. </if>
  10217. <if test="isPlacefile != null and isPlacefile == 0">
  10218. <if test="startDate != null ">
  10219. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  10220. </if>
  10221. <if test="endDate != null ">
  10222. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  10223. </if>
  10224. </if>
  10225. <if test="isPlacefile != null and isPlacefile == 1">
  10226. <if test="startDate != null ">
  10227. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  10228. </if>
  10229. <if test="endDate != null">
  10230. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  10231. </if>
  10232. </if>
  10233. <if test="diagnose != null and diagnose != ''">
  10234. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  10235. </if>
  10236. <if test="behospitalCode != null and behospitalCode != ''">
  10237. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  10238. </if>
  10239. <if test="patName != null and patName != ''">
  10240. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  10241. </if>
  10242. <if test="doctorId != null and doctorId != ''">
  10243. AND (a.doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  10244. OR a.beh_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  10245. OR a.director_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' ))
  10246. </if>
  10247. <if test="doctorName != null and doctorName != ''">
  10248. AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  10249. OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  10250. OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' ))
  10251. </if>
  10252. GROUP BY
  10253. a.doctor_id,
  10254. a.doctor_name
  10255. ) t2
  10256. where
  10257. t.doctorId = t2.doctorId
  10258. AND t.doctorName = t2.doctorName
  10259. <if test="checkStatus != null">
  10260. AND t.checkStatus = #{checkStatus}
  10261. </if>
  10262. <if test="mrStatus != null">
  10263. AND t.mrStatus = #{mrStatus}
  10264. </if>
  10265. <if test="chName != null and chName!=''">
  10266. AND t.chName like concat('%', #{chName}, '%')
  10267. </if>
  10268. <if test="mrName != null and mrName!=''">
  10269. AND t.mrName like concat('%', #{mrName}, '%')
  10270. </if>
  10271. <if test="chTimeStart != null ">
  10272. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  10273. </if>
  10274. <if test="chTimeEnd != null ">
  10275. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  10276. </if>
  10277. <if test="mrTimeStart != null ">
  10278. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  10279. </if>
  10280. <if test="mrTimeEnd != null ">
  10281. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  10282. </if>
  10283. </select>
  10284. <!-- 不合格/合格数病历号(内页)全院-->
  10285. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  10286. SELECT t.*
  10287. FROM
  10288. (SELECT DISTINCT
  10289. t1.hospital_id AS hospitalId,
  10290. t1.behospital_code AS behospitalCode,
  10291. t1.bed_code AS bedCode,
  10292. t1.LEVEL AS LEVEL,
  10293. t1.grade_type AS gradeType,
  10294. t1.score_res AS scoreRes,
  10295. t1.scoreBn,
  10296. t1.NAME AS NAME,
  10297. t1.sex AS sex,
  10298. t1.beh_dept_id AS behDeptId,
  10299. t1.beh_dept_name AS behDeptName,
  10300. t1.doctor_id AS doctorId,
  10301. t1.doctor_name AS doctorName,
  10302. t1.beh_doctor_id AS behDoctorId,
  10303. t1.beh_doctor_name AS behDoctorName,
  10304. t1.director_doctor_id AS directorDoctorId,
  10305. t1.director_doctor_name AS directorDoctorName,
  10306. t1.birthday AS birthday,
  10307. t1.behospital_date AS behospitalDate,
  10308. t1.leave_hospital_date AS leaveHospitalDate,
  10309. t1.placefile_date AS placefileDate,
  10310. t1.gmt_create AS gradeTime,
  10311. t1.diagnose,
  10312. t1.ward_name AS wardName,
  10313. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  10314. t1.file_code AS fileCode,
  10315. t1.checkStatus,
  10316. t1.mrStatus,
  10317. t1.chName,
  10318. t1.mrName,
  10319. t1.chTime,
  10320. t1.mrTime
  10321. FROM
  10322. (SELECT
  10323. be.*,
  10324. b.LEVEL,
  10325. b.grade_type,
  10326. b.score_res,
  10327. b.gmt_create,
  10328. ifnull(mci.status,0) AS checkStatus,
  10329. ifnull(hm_mci.status,0) AS mrStatus,
  10330. mci.check_name as chName,
  10331. hm_mci.check_name as mrName,
  10332. mci.gmt_create as chTime,
  10333. hm_mci.gmt_create as mrTime
  10334. FROM
  10335. (
  10336. SELECT DISTINCT
  10337. a.hospital_id,
  10338. a.behospital_code,
  10339. a.bed_code,
  10340. a.file_code,
  10341. e.score_res as scoreBn,
  10342. a.NAME,
  10343. a.sex,
  10344. a.beh_dept_id,
  10345. a.beh_dept_name,
  10346. a.birthday,
  10347. a.behospital_date,
  10348. a.leave_hospital_date,
  10349. a.doctor_id,
  10350. a.doctor_name,
  10351. a.beh_doctor_id,
  10352. a.beh_doctor_name,
  10353. a.director_doctor_id,
  10354. a.director_doctor_name,
  10355. a.diagnose,
  10356. a.placefile_date,
  10357. a.ward_name
  10358. FROM
  10359. med_behospital_info a,
  10360. med_qcresult_cases e
  10361. WHERE
  10362. a.is_deleted = 'N'
  10363. AND e.is_deleted = 'N'
  10364. AND a.hospital_id = e.hospital_id
  10365. AND a.behospital_code = e.behospital_code
  10366. AND a.qc_type_id != 0
  10367. AND e.cases_id = 243
  10368. <if test="qcResultPageVO.titleName != null ">
  10369. <if test="qcResultPageVO.titleName == '不合格数'">
  10370. AND e.`level`='不合格'
  10371. </if>
  10372. <if test="qcResultPageVO.titleName == '合格数'">
  10373. AND e.`level`='合格'
  10374. </if>
  10375. </if>
  10376. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  10377. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  10378. </if>
  10379. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  10380. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  10381. </if>
  10382. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  10383. <if test="qcResultPageVO.startDate != null ">
  10384. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  10385. </if>
  10386. <if test="qcResultPageVO.endDate != null ">
  10387. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  10388. </if>
  10389. </if>
  10390. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  10391. <if test="qcResultPageVO.startDate != null ">
  10392. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  10393. </if>
  10394. <if test="qcResultPageVO.endDate != null">
  10395. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  10396. </if>
  10397. </if>
  10398. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  10399. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  10400. </if>
  10401. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  10402. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  10403. </if>
  10404. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  10405. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  10406. </if>
  10407. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  10408. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  10409. </if>
  10410. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  10411. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  10412. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  10413. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  10414. </if>
  10415. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  10416. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  10417. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  10418. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  10419. </if>
  10420. )be
  10421. left join med_check_info mci
  10422. on mci.is_deleted = 'N'
  10423. and mci.check_type = 0
  10424. and be.hospital_id = mci.hospital_id
  10425. and be.behospital_code = mci.behospital_code
  10426. left join med_check_info hm_mci
  10427. on hm_mci.is_deleted = 'N'
  10428. and hm_mci.check_type = 1
  10429. and be.hospital_id = hm_mci.hospital_id
  10430. and be.behospital_code = hm_mci.behospital_code
  10431. left join med_qcresult_info b
  10432. on b.is_deleted = 'N'
  10433. AND be.hospital_id = b.hospital_id
  10434. AND be.behospital_code = b.behospital_code
  10435. where
  10436. 1=1
  10437. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  10438. AND b.`level` = #{qcResultPageVO.level}
  10439. </if>
  10440. ) t1
  10441. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10442. AND t1.behospital_code = t2.behospital_code
  10443. AND t2.is_deleted = 'N'
  10444. ) t,
  10445. (
  10446. SELECT
  10447. a.beh_dept_id AS deptId,
  10448. a.beh_dept_name AS deptName
  10449. FROM
  10450. med_behospital_info a,
  10451. med_qcresult_cases c,
  10452. med_qcresult_detail d,
  10453. qc_cases_entry e
  10454. WHERE
  10455. a.is_deleted = 'N'
  10456. AND c.is_deleted = 'N'
  10457. AND d.is_deleted = 'N'
  10458. AND e.is_deleted = 'N'
  10459. AND a.hospital_id = c.hospital_id
  10460. AND a.hospital_id = d.hospital_id
  10461. AND a.behospital_code = c.behospital_code
  10462. AND a.behospital_code = d.behospital_code
  10463. AND c.cases_id = d.cases_id
  10464. AND d.cases_id = e.cases_id
  10465. AND d.cases_entry_id = e.id
  10466. AND d.cases_id = 243
  10467. AND a.qc_type_id != 0
  10468. <!-- <if test="qcResultPageVO.titleName != null ">-->
  10469. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  10470. <!-- AND c.`level`='不合格'-->
  10471. <!-- </if>-->
  10472. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  10473. <!-- AND c.`level`='合格'-->
  10474. <!-- </if>-->
  10475. <!-- </if>-->
  10476. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  10477. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  10478. </if>
  10479. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  10480. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  10481. </if>
  10482. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  10483. <if test="qcResultPageVO.startDate != null ">
  10484. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  10485. </if>
  10486. <if test="qcResultPageVO.endDate != null ">
  10487. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  10488. </if>
  10489. </if>
  10490. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  10491. <if test="qcResultPageVO.startDate != null ">
  10492. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  10493. </if>
  10494. <if test="qcResultPageVO.endDate != null">
  10495. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  10496. </if>
  10497. </if>
  10498. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  10499. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  10500. </if>
  10501. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  10502. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  10503. </if>
  10504. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  10505. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  10506. </if>
  10507. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  10508. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  10509. </if>
  10510. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  10511. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  10512. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  10513. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  10514. </if>
  10515. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  10516. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  10517. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  10518. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  10519. </if>
  10520. GROUP BY
  10521. a.beh_dept_id,
  10522. a.beh_dept_name
  10523. ) t2
  10524. where
  10525. t.behDeptId = t2.deptId
  10526. AND t.behDeptName = t2.deptName
  10527. <if test="qcResultPageVO.checkStatus != null">
  10528. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  10529. </if>
  10530. <if test="qcResultPageVO.mrStatus != null">
  10531. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  10532. </if>
  10533. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  10534. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  10535. </if>
  10536. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  10537. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  10538. </if>
  10539. <if test="qcResultPageVO.chTimeStart != null ">
  10540. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  10541. </if>
  10542. <if test="qcResultPageVO.chTimeEnd != null ">
  10543. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  10544. </if>
  10545. <if test="qcResultPageVO.mrTimeStart != null ">
  10546. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  10547. </if>
  10548. <if test="qcResultPageVO.mrTimeEnd != null ">
  10549. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  10550. </if>
  10551. </select>
  10552. <!-- 未整改病历质控评分页(内页)-->
  10553. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  10554. SELECT t.*
  10555. FROM
  10556. (SELECT DISTINCT
  10557. t1.hospital_id AS hospitalId,
  10558. t1.behospital_code AS behospitalCode,
  10559. t1.bed_code AS bedCode,
  10560. t1.LEVEL AS LEVEL,
  10561. t1.grade_type AS gradeType,
  10562. t1.score_res AS scoreRes,
  10563. t1.scoreBn,
  10564. t1.NAME AS NAME,
  10565. t1.sex AS sex,
  10566. t1.beh_dept_id AS behDeptId,
  10567. t1.beh_dept_name AS behDeptName,
  10568. t1.doctor_id AS doctorId,
  10569. t1.doctor_name AS doctorName,
  10570. t1.beh_doctor_id AS behDoctorId,
  10571. t1.beh_doctor_name AS behDoctorName,
  10572. t1.director_doctor_id AS directorDoctorId,
  10573. t1.director_doctor_name AS directorDoctorName,
  10574. t1.birthday AS birthday,
  10575. t1.behospital_date AS behospitalDate,
  10576. t1.leave_hospital_date AS leaveHospitalDate,
  10577. t1.placefile_date AS placefileDate,
  10578. t1.gmt_create AS gradeTime,
  10579. t1.diagnose,
  10580. t1.ward_name AS wardName,
  10581. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  10582. t1.file_code AS fileCode,
  10583. t1.checkStatus,
  10584. t1.mrStatus,
  10585. t1.chName,
  10586. t1.mrName,
  10587. t1.chTime,
  10588. t1.mrTime
  10589. FROM
  10590. (SELECT
  10591. be.*,
  10592. ifnull(mci.status,0) AS checkStatus,
  10593. ifnull(hm_mci.status,0) AS mrStatus,
  10594. mci.check_name as chName,
  10595. e.score_res as scoreBn,
  10596. hm_mci.check_name as mrName,
  10597. mci.gmt_create as chTime,
  10598. hm_mci.gmt_create as mrTime
  10599. FROM
  10600. (
  10601. SELECT DISTINCT
  10602. a.hospital_id,
  10603. a.behospital_code,
  10604. a.bed_code,
  10605. a.file_code,
  10606. b.LEVEL,
  10607. b.grade_type,
  10608. b.score_res,
  10609. a.NAME,
  10610. a.sex,
  10611. a.beh_dept_id,
  10612. a.beh_dept_name,
  10613. a.birthday,
  10614. a.behospital_date,
  10615. a.leave_hospital_date,
  10616. a.doctor_id,
  10617. a.doctor_name,
  10618. a.beh_doctor_id,
  10619. a.beh_doctor_name,
  10620. a.director_doctor_id,
  10621. a.director_doctor_name,
  10622. a.diagnose,
  10623. a.placefile_date,
  10624. a.ward_name,
  10625. b.gmt_create
  10626. FROM
  10627. med_behospital_info a,
  10628. med_qcresult_info b,
  10629. med_qcresult_detail c,
  10630. qc_cases_entry d
  10631. WHERE
  10632. a.is_deleted = 'N'
  10633. AND b.is_deleted = 'N'
  10634. AND c.is_deleted = 'N'
  10635. AND d.is_deleted = 'N'
  10636. AND a.hospital_id = b.hospital_id
  10637. AND a.hospital_id = c.hospital_id
  10638. AND a.behospital_code = b.behospital_code
  10639. AND a.behospital_code = c.behospital_code
  10640. AND c.cases_id = d.cases_id
  10641. AND c.cases_entry_id = d.id
  10642. AND a.qc_type_id != 0
  10643. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10644. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10645. </if>
  10646. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10647. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10648. </if>
  10649. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10650. <if test="qcResultShortPageVO.startDate != null ">
  10651. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10652. </if>
  10653. <if test="qcResultShortPageVO.endDate != null ">
  10654. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10655. </if>
  10656. </if>
  10657. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10658. <if test="qcResultShortPageVO.startDate != null ">
  10659. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10660. </if>
  10661. <if test="qcResultShortPageVO.endDate != null">
  10662. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10663. </if>
  10664. </if>
  10665. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10666. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10667. </if>
  10668. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10669. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  10670. </if>
  10671. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10672. AND b.`level` = #{qcResultShortPageVO.level}
  10673. </if>
  10674. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10675. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10676. </if>
  10677. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10678. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10679. </if>
  10680. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10681. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10682. </if>
  10683. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10684. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10685. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10686. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10687. </if>
  10688. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10689. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10690. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10691. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10692. </if>
  10693. <if test="qcResultShortPageVO.casesEntryId != null ">
  10694. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10695. </if>
  10696. <if test="qcResultShortPageVO.isReject != null">
  10697. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10698. </if>
  10699. <if test="qcResultShortPageVO.ruleType != null">
  10700. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10701. </if>
  10702. )be
  10703. left join med_check_info mci
  10704. on mci.is_deleted = 'N'
  10705. and mci.check_type = 0
  10706. and be.hospital_id = mci.hospital_id
  10707. and be.behospital_code = mci.behospital_code
  10708. left join med_check_info hm_mci
  10709. on hm_mci.is_deleted = 'N'
  10710. and hm_mci.check_type = 1
  10711. and be.hospital_id = hm_mci.hospital_id
  10712. and be.behospital_code = hm_mci.behospital_code
  10713. LEFT JOIN med_qcresult_cases e
  10714. on be.behospital_code = e.behospital_code
  10715. and be.hospital_id = e.hospital_id
  10716. AND e.is_deleted = 'N'
  10717. and e.cases_id = 243
  10718. ) t1
  10719. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10720. AND t1.behospital_code = t2.behospital_code
  10721. AND t2.is_deleted = 'N'
  10722. ) t
  10723. where 1=1
  10724. <if test="qcResultShortPageVO.checkStatus != null">
  10725. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10726. </if>
  10727. <if test="qcResultShortPageVO.mrStatus != null">
  10728. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10729. </if>
  10730. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10731. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10732. </if>
  10733. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10734. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10735. </if>
  10736. <if test="qcResultShortPageVO.chTimeStart != null ">
  10737. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10738. </if>
  10739. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10740. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10741. </if>
  10742. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10743. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10744. </if>
  10745. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10746. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10747. </if>
  10748. </select>
  10749. <!-- 病案首页不合格/合格数病历详情页导出-->
  10750. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  10751. SELECT
  10752. f1.behDeptId,
  10753. f1.behDeptName,
  10754. f1.behDoctorName,
  10755. f1.patName,
  10756. f1.behospitalCode,
  10757. f1.hospitalId,
  10758. f1.behospitalDate,
  10759. f1.leaveHospitalDate,
  10760. f1.score,
  10761. f1.scoreBn,
  10762. f2.avgScore,
  10763. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  10764. f1.msg,
  10765. f1.caseName,
  10766. </if>
  10767. f1.checkStatus,
  10768. f1.mrStatus,
  10769. f1.chName,
  10770. f1.mrName,
  10771. f1.chTime,
  10772. f1.mrTime
  10773. FROM
  10774. (SELECT
  10775. t.doctorName AS behDoctorName,
  10776. t.`name` AS patName,
  10777. t.behospitalCode AS behospitalCode,
  10778. t.behospitalDate AS behospitalDate,
  10779. t.leaveHospitalDate AS leaveHospitalDate,
  10780. qi.score_res AS score,
  10781. t.scoreBn,
  10782. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  10783. qd.msg AS msg,
  10784. qc.NAME AS caseName,
  10785. </if>
  10786. t.behDeptId,
  10787. t.behDeptName,
  10788. t.hospitalId,
  10789. t.checkStatus,
  10790. t.mrStatus,
  10791. t.chName,
  10792. t.mrName,
  10793. t.chTime,
  10794. t.mrTime
  10795. FROM
  10796. (SELECT DISTINCT
  10797. t1.hospital_id AS hospitalId,
  10798. t1.behospital_code AS behospitalCode,
  10799. t1.bed_code AS bedCode,
  10800. t1.LEVEL AS LEVEL,
  10801. t1.grade_type AS gradeType,
  10802. t1.score_res AS scoreRes,
  10803. t1.scoreBn,
  10804. t1.NAME AS NAME,
  10805. t1.sex AS sex,
  10806. t1.beh_dept_id AS behDeptId,
  10807. t1.beh_dept_name AS behDeptName,
  10808. t1.doctor_id AS doctorId,
  10809. t1.doctor_name AS doctorName,
  10810. t1.beh_doctor_id AS behDoctorId,
  10811. t1.beh_doctor_name AS behDoctorName,
  10812. t1.director_doctor_id AS directorDoctorId,
  10813. t1.director_doctor_name AS directorDoctorName,
  10814. t1.birthday AS birthday,
  10815. t1.behospital_date AS behospitalDate,
  10816. t1.leave_hospital_date AS leaveHospitalDate,
  10817. t1.placefile_date AS placefileDate,
  10818. t1.gmt_create AS gradeTime,
  10819. t1.diagnose,
  10820. t1.ward_name AS wardName,
  10821. t2.age,
  10822. t1.file_code AS fileCode,
  10823. t1.checkStatus,
  10824. t1.mrStatus,
  10825. t1.chName,
  10826. t1.mrName,
  10827. t1.chTime,
  10828. t1.mrTime
  10829. FROM
  10830. (SELECT
  10831. be.*,
  10832. b.LEVEL,
  10833. b.grade_type,
  10834. b.score_res,
  10835. b.gmt_create,
  10836. ifnull(mci.status,0) AS checkStatus,
  10837. ifnull(hm_mci.status,0) AS mrStatus,
  10838. mci.check_name as chName,
  10839. hm_mci.check_name as mrName,
  10840. mci.gmt_create as chTime,
  10841. hm_mci.gmt_create as mrTime
  10842. FROM
  10843. (
  10844. SELECT DISTINCT
  10845. a.hospital_id,
  10846. a.behospital_code,
  10847. a.bed_code,
  10848. a.file_code,
  10849. c.score_res as scoreBn,
  10850. c.cases_id,
  10851. a.NAME,
  10852. a.sex,
  10853. a.beh_dept_id,
  10854. a.beh_dept_name,
  10855. a.birthday,
  10856. a.behospital_date,
  10857. a.leave_hospital_date,
  10858. a.doctor_id,
  10859. a.doctor_name,
  10860. a.beh_doctor_id,
  10861. a.beh_doctor_name,
  10862. a.director_doctor_id,
  10863. a.director_doctor_name,
  10864. a.diagnose,
  10865. a.placefile_date,
  10866. a.ward_name
  10867. FROM
  10868. med_behospital_info a,
  10869. med_qcresult_cases c
  10870. WHERE
  10871. a.is_deleted = 'N'
  10872. AND c.is_deleted = 'N'
  10873. AND a.hospital_id = c.hospital_id
  10874. AND a.behospital_code = c.behospital_code
  10875. AND a.qc_type_id != 0
  10876. AND c.cases_id = 243
  10877. <if test="qcResultShortPageVO.titleName != null ">
  10878. <if test="qcResultShortPageVO.titleName == '不合格数'">
  10879. AND c.`level`='不合格'
  10880. </if>
  10881. <if test="qcResultShortPageVO.titleName == '合格数'">
  10882. AND c.`level`='合格'
  10883. </if>
  10884. </if>
  10885. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10886. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10887. </if>
  10888. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10889. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10890. </if>
  10891. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10892. <if test="qcResultShortPageVO.startDate != null ">
  10893. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10894. </if>
  10895. <if test="qcResultShortPageVO.endDate != null ">
  10896. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10897. </if>
  10898. </if>
  10899. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10900. <if test="qcResultShortPageVO.startDate != null ">
  10901. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10902. </if>
  10903. <if test="qcResultShortPageVO.endDate != null">
  10904. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10905. </if>
  10906. </if>
  10907. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10908. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10909. </if>
  10910. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10911. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  10912. </if>
  10913. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10914. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10915. </if>
  10916. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10917. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10918. </if>
  10919. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10920. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10921. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10922. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10923. </if>
  10924. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10925. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10926. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10927. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10928. </if>
  10929. )be
  10930. left join med_check_info mci
  10931. on mci.is_deleted = 'N'
  10932. and mci.check_type = 0
  10933. and be.hospital_id = mci.hospital_id
  10934. and be.behospital_code = mci.behospital_code
  10935. left join med_check_info hm_mci
  10936. on hm_mci.is_deleted = 'N'
  10937. and hm_mci.check_type = 1
  10938. and be.hospital_id = hm_mci.hospital_id
  10939. and be.behospital_code = hm_mci.behospital_code
  10940. left join med_qcresult_info b
  10941. on b.is_deleted = 'N'
  10942. AND be.hospital_id = b.hospital_id
  10943. AND be.behospital_code = b.behospital_code
  10944. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10945. AND b.`level` = #{qcResultPageVO.level}
  10946. </if>
  10947. left join qc_cases_entry d
  10948. on d.is_deleted = 'N'
  10949. AND be.cases_id = d.cases_id
  10950. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10951. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10952. </if>
  10953. <if test="qcResultShortPageVO.casesEntryId != null ">
  10954. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10955. </if>
  10956. <if test="qcResultShortPageVO.ruleType != null">
  10957. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10958. </if>
  10959. ) t1
  10960. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10961. AND t1.behospital_code = t2.behospital_code
  10962. AND t2.is_deleted = 'N'
  10963. ) t
  10964. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10965. AND t.hospitalId = qi.hospital_id
  10966. AND t.behospitalCode = qi.behospital_code
  10967. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  10968. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10969. AND t.hospitalId = qd.hospital_id
  10970. AND t.behospitalCode = qd.behospital_code
  10971. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10972. AND qd.cases_id = qc.id
  10973. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10974. AND qd.cases_id = qce.cases_id
  10975. AND qd.cases_entry_id = qce.id
  10976. </if>
  10977. where 1=1
  10978. <if test="qcResultShortPageVO.checkStatus != null">
  10979. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10980. </if>
  10981. <if test="qcResultShortPageVO.mrStatus != null">
  10982. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10983. </if>
  10984. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10985. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10986. </if>
  10987. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10988. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10989. </if>
  10990. <if test="qcResultShortPageVO.chTimeStart != null ">
  10991. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10992. </if>
  10993. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10994. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10995. </if>
  10996. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10997. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10998. </if>
  10999. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11000. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11001. </if>
  11002. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11003. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  11004. </if>
  11005. <if test="qcResultShortPageVO.casesEntryId != null ">
  11006. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  11007. </if>
  11008. )f1,
  11009. (SELECT
  11010. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  11011. t.behDeptId,
  11012. t.behDeptName
  11013. FROM
  11014. (SELECT DISTINCT
  11015. t1.hospital_id AS hospitalId,
  11016. t1.behospital_code AS behospitalCode,
  11017. t1.bed_code AS bedCode,
  11018. t1.LEVEL AS LEVEL,
  11019. t1.grade_type AS gradeType,
  11020. t1.score_res AS scoreRes,
  11021. t1.NAME AS NAME,
  11022. t1.sex AS sex,
  11023. t1.beh_dept_id AS behDeptId,
  11024. t1.beh_dept_name AS behDeptName,
  11025. t1.doctor_id AS doctorId,
  11026. t1.doctor_name AS doctorName,
  11027. t1.beh_doctor_id AS behDoctorId,
  11028. t1.beh_doctor_name AS behDoctorName,
  11029. t1.director_doctor_id AS directorDoctorId,
  11030. t1.director_doctor_name AS directorDoctorName,
  11031. t1.birthday AS birthday,
  11032. t1.behospital_date AS behospitalDate,
  11033. t1.leave_hospital_date AS leaveHospitalDate,
  11034. t1.placefile_date AS placefileDate,
  11035. t1.gmt_create AS gradeTime,
  11036. t1.diagnose,
  11037. t1.ward_name AS wardName,
  11038. t2.age,
  11039. t1.file_code AS fileCode,
  11040. t1.checkStatus,
  11041. t1.mrStatus,
  11042. t1.chName,
  11043. t1.mrName,
  11044. t1.chTime,
  11045. t1.mrTime
  11046. FROM
  11047. (SELECT
  11048. be.*,
  11049. b.grade_type,
  11050. b.score_res,
  11051. b.gmt_create,
  11052. b.LEVEL,
  11053. ifnull(mci.status,0) AS checkStatus,
  11054. ifnull(hm_mci.status,0) AS mrStatus,
  11055. mci.check_name as chName,
  11056. hm_mci.check_name as mrName,
  11057. mci.gmt_create as chTime,
  11058. hm_mci.gmt_create as mrTime
  11059. FROM
  11060. (
  11061. SELECT DISTINCT
  11062. a.hospital_id,
  11063. a.behospital_code,
  11064. a.bed_code,
  11065. a.file_code,
  11066. a.NAME,
  11067. a.sex,
  11068. a.beh_dept_id,
  11069. a.beh_dept_name,
  11070. a.birthday,
  11071. a.behospital_date,
  11072. a.leave_hospital_date,
  11073. a.doctor_id,
  11074. a.doctor_name,
  11075. a.beh_doctor_id,
  11076. a.beh_doctor_name,
  11077. a.director_doctor_id,
  11078. a.director_doctor_name,
  11079. a.diagnose,
  11080. a.placefile_date,
  11081. a.ward_name
  11082. FROM
  11083. med_behospital_info a,
  11084. med_qcresult_detail k,
  11085. med_qcresult_cases c,
  11086. qc_cases_entry d
  11087. WHERE
  11088. a.is_deleted = 'N'
  11089. AND c.is_deleted = 'N'
  11090. AND d.is_deleted = 'N'
  11091. AND a.hospital_id = c.hospital_id
  11092. AND a.behospital_code = c.behospital_code
  11093. AND c.cases_id = d.cases_id
  11094. AND a.hospital_id = k.hospital_id
  11095. AND a.behospital_code = k.behospital_code
  11096. AND c.cases_id = k.cases_id
  11097. AND k.cases_id = d.cases_id
  11098. AND k.cases_entry_id = d.id
  11099. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  11100. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  11101. <!-- AND c.`level`='不合格'-->
  11102. <!-- </if>-->
  11103. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  11104. <!-- AND c.`level`='合格'-->
  11105. <!-- </if>-->
  11106. <!-- </if>-->
  11107. AND a.qc_type_id != 0
  11108. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11109. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11110. </if>
  11111. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11112. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11113. </if>
  11114. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11115. <if test="qcResultShortPageVO.startDate != null ">
  11116. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11117. </if>
  11118. <if test="qcResultShortPageVO.endDate != null ">
  11119. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11120. </if>
  11121. </if>
  11122. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11123. <if test="qcResultShortPageVO.startDate != null ">
  11124. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11125. </if>
  11126. <if test="qcResultShortPageVO.endDate != null">
  11127. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11128. </if>
  11129. </if>
  11130. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11131. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11132. </if>
  11133. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11134. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  11135. </if>
  11136. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11137. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11138. </if>
  11139. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11140. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11141. </if>
  11142. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11143. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11144. </if>
  11145. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11146. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11147. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11148. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11149. </if>
  11150. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11151. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11152. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11153. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11154. </if>
  11155. <if test="qcResultShortPageVO.casesEntryId != null ">
  11156. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11157. </if>
  11158. <if test="qcResultShortPageVO.ruleType != null">
  11159. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11160. </if>
  11161. )be
  11162. left join med_check_info mci
  11163. on mci.is_deleted = 'N'
  11164. and mci.check_type = 0
  11165. and be.hospital_id = mci.hospital_id
  11166. and be.behospital_code = mci.behospital_code
  11167. left join med_check_info hm_mci
  11168. on hm_mci.is_deleted = 'N'
  11169. and hm_mci.check_type = 1
  11170. and be.hospital_id = hm_mci.hospital_id
  11171. and be.behospital_code = hm_mci.behospital_code
  11172. left join med_qcresult_info b
  11173. on b.is_deleted = 'N'
  11174. AND be.hospital_id = b.hospital_id
  11175. AND be.behospital_code = b.behospital_code
  11176. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11177. AND b.`level` = #{qcResultPageVO.level}
  11178. </if>
  11179. ) t1
  11180. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11181. AND t1.behospital_code = t2.behospital_code
  11182. AND t2.is_deleted = 'N'
  11183. ) t
  11184. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11185. AND t.hospitalId = qi.hospital_id
  11186. AND t.behospitalCode = qi.behospital_code
  11187. where 1=1
  11188. <if test="qcResultShortPageVO.checkStatus != null">
  11189. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11190. </if>
  11191. <if test="qcResultShortPageVO.mrStatus != null">
  11192. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11193. </if>
  11194. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11195. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11196. </if>
  11197. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11198. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11199. </if>
  11200. <if test="qcResultShortPageVO.chTimeStart != null ">
  11201. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11202. </if>
  11203. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11204. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11205. </if>
  11206. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11207. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11208. </if>
  11209. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11210. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11211. </if>
  11212. GROUP BY
  11213. t.behDeptId,
  11214. t.behDeptName
  11215. )f2
  11216. WHERE
  11217. f1.behDeptId = f2.behDeptId
  11218. AND f1.behDeptName = f2.behDeptName
  11219. </select>
  11220. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  11221. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  11222. SELECT
  11223. f1.behDeptId,
  11224. f1.behDeptName,
  11225. f1.doctorName,
  11226. f1.patName,
  11227. f1.behospitalCode,
  11228. f1.hospitalId,
  11229. f1.behospitalDate,
  11230. f1.leaveHospitalDate,
  11231. f1.score,
  11232. f1.scoreBn,
  11233. f2.avgScore,
  11234. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  11235. f1.msg,
  11236. f1.caseName,
  11237. </if>
  11238. f1.checkStatus,
  11239. f1.mrStatus,
  11240. f1.chName,
  11241. f1.mrName,
  11242. f1.chTime,
  11243. f1.mrTime
  11244. FROM
  11245. (SELECT
  11246. t.doctorName AS doctorName,
  11247. t.doctorId,
  11248. t.`name` AS patName,
  11249. t.behospitalCode AS behospitalCode,
  11250. t.behospitalDate AS behospitalDate,
  11251. t.leaveHospitalDate AS leaveHospitalDate,
  11252. qi.score_res AS score,
  11253. t.scoreBn,
  11254. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  11255. qd.msg AS msg,
  11256. qc.NAME AS caseName,
  11257. </if>
  11258. t.behDeptId,
  11259. t.behDeptName,
  11260. t.hospitalId,
  11261. t.checkStatus,
  11262. t.mrStatus,
  11263. t.chName,
  11264. t.mrName,
  11265. t.chTime,
  11266. t.mrTime
  11267. FROM
  11268. (SELECT DISTINCT
  11269. t1.hospital_id AS hospitalId,
  11270. t1.behospital_code AS behospitalCode,
  11271. t1.bed_code AS bedCode,
  11272. t1.LEVEL AS LEVEL,
  11273. t1.grade_type AS gradeType,
  11274. t1.score_res AS scoreRes,
  11275. t1.scoreBn,
  11276. t1.NAME AS NAME,
  11277. t1.sex AS sex,
  11278. t1.beh_dept_id AS behDeptId,
  11279. t1.beh_dept_name AS behDeptName,
  11280. t1.doctor_id AS doctorId,
  11281. t1.doctor_name AS doctorName,
  11282. t1.beh_doctor_id AS behDoctorId,
  11283. t1.beh_doctor_name AS behDoctorName,
  11284. t1.director_doctor_id AS directorDoctorId,
  11285. t1.director_doctor_name AS directorDoctorName,
  11286. t1.birthday AS birthday,
  11287. t1.behospital_date AS behospitalDate,
  11288. t1.leave_hospital_date AS leaveHospitalDate,
  11289. t1.placefile_date AS placefileDate,
  11290. t1.gmt_create AS gradeTime,
  11291. t1.diagnose,
  11292. t1.ward_name AS wardName,
  11293. t2.age,
  11294. t1.file_code AS fileCode,
  11295. t1.checkStatus,
  11296. t1.mrStatus,
  11297. t1.chName,
  11298. t1.mrName,
  11299. t1.chTime,
  11300. t1.mrTime
  11301. FROM
  11302. (SELECT
  11303. be.*,
  11304. b.LEVEL,
  11305. b.grade_type,
  11306. b.score_res,
  11307. b.gmt_create,
  11308. ifnull(mci.status,0) AS checkStatus,
  11309. ifnull(hm_mci.status,0) AS mrStatus,
  11310. mci.check_name as chName,
  11311. hm_mci.check_name as mrName,
  11312. mci.gmt_create as chTime,
  11313. hm_mci.gmt_create as mrTime
  11314. FROM
  11315. (
  11316. SELECT DISTINCT
  11317. a.hospital_id,
  11318. a.behospital_code,
  11319. a.bed_code,
  11320. a.file_code,
  11321. c.score_res as scoreBn,
  11322. c.cases_id,
  11323. a.NAME,
  11324. a.sex,
  11325. a.beh_dept_id,
  11326. a.beh_dept_name,
  11327. a.birthday,
  11328. a.behospital_date,
  11329. a.leave_hospital_date,
  11330. a.doctor_id,
  11331. a.doctor_name,
  11332. a.beh_doctor_id,
  11333. a.beh_doctor_name,
  11334. a.director_doctor_id,
  11335. a.director_doctor_name,
  11336. a.diagnose,
  11337. a.placefile_date,
  11338. a.ward_name
  11339. FROM
  11340. med_behospital_info a,
  11341. sys_user_dept b,
  11342. med_qcresult_cases c
  11343. WHERE
  11344. a.is_deleted = 'N'
  11345. AND b.is_deleted = 'N'
  11346. AND c.is_deleted = 'N'
  11347. AND a.hospital_id = b.hospital_id
  11348. AND a.beh_dept_id = b.dept_id
  11349. AND a.hospital_id = c.hospital_id
  11350. AND a.behospital_code = c.behospital_code
  11351. AND a.qc_type_id != 0
  11352. AND c.cases_id = 243
  11353. <if test="qcResultShortPageVO.userId!=null">
  11354. AND b.user_id = #{qcResultShortPageVO.userId}
  11355. </if>
  11356. <if test="qcResultShortPageVO.titleName != null ">
  11357. <if test="qcResultShortPageVO.titleName == '不合格数'">
  11358. AND c.`level`='不合格'
  11359. </if>
  11360. <if test="qcResultShortPageVO.titleName == '合格数'">
  11361. AND c.`level`='合格'
  11362. </if>
  11363. </if>
  11364. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11365. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11366. </if>
  11367. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11368. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11369. </if>
  11370. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11371. <if test="qcResultShortPageVO.startDate != null ">
  11372. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11373. </if>
  11374. <if test="qcResultShortPageVO.endDate != null ">
  11375. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11376. </if>
  11377. </if>
  11378. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11379. <if test="qcResultShortPageVO.startDate != null ">
  11380. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11381. </if>
  11382. <if test="qcResultShortPageVO.endDate != null">
  11383. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11384. </if>
  11385. </if>
  11386. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11387. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11388. </if>
  11389. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11390. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  11391. </if>
  11392. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11393. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11394. </if>
  11395. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11396. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11397. </if>
  11398. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11399. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11400. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11401. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11402. </if>
  11403. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11404. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11405. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11406. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11407. </if>
  11408. )be
  11409. left join med_check_info mci
  11410. on mci.is_deleted = 'N'
  11411. and mci.check_type = 0
  11412. and be.hospital_id = mci.hospital_id
  11413. and be.behospital_code = mci.behospital_code
  11414. left join med_check_info hm_mci
  11415. on hm_mci.is_deleted = 'N'
  11416. and hm_mci.check_type = 1
  11417. and be.hospital_id = hm_mci.hospital_id
  11418. and be.behospital_code = hm_mci.behospital_code
  11419. left join med_qcresult_info b
  11420. on b.is_deleted = 'N'
  11421. AND be.hospital_id = b.hospital_id
  11422. AND be.behospital_code = b.behospital_code
  11423. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11424. AND b.`level` = #{qcResultPageVO.level}
  11425. </if>
  11426. left join qc_cases_entry d
  11427. on d.is_deleted = 'N'
  11428. AND be.cases_id = d.cases_id
  11429. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11430. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11431. </if>
  11432. <if test="qcResultShortPageVO.casesEntryId != null ">
  11433. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11434. </if>
  11435. <if test="qcResultShortPageVO.ruleType != null">
  11436. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11437. </if>
  11438. ) t1
  11439. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11440. AND t1.behospital_code = t2.behospital_code
  11441. AND t2.is_deleted = 'N'
  11442. ) t
  11443. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11444. AND t.hospitalId = qi.hospital_id
  11445. AND t.behospitalCode = qi.behospital_code
  11446. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  11447. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  11448. AND t.hospitalId = qd.hospital_id
  11449. AND t.behospitalCode = qd.behospital_code
  11450. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  11451. AND qd.cases_id = qc.id
  11452. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  11453. AND qd.cases_id = qce.cases_id
  11454. AND qd.cases_entry_id = qce.id
  11455. </if>
  11456. where 1=1
  11457. <if test="qcResultShortPageVO.checkStatus != null">
  11458. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11459. </if>
  11460. <if test="qcResultShortPageVO.mrStatus != null">
  11461. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11462. </if>
  11463. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11464. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11465. </if>
  11466. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11467. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11468. </if>
  11469. <if test="qcResultShortPageVO.chTimeStart != null ">
  11470. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11471. </if>
  11472. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11473. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11474. </if>
  11475. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11476. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11477. </if>
  11478. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11479. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11480. </if>
  11481. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11482. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  11483. </if>
  11484. <if test="qcResultShortPageVO.casesEntryId != null ">
  11485. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  11486. </if>
  11487. )f1,
  11488. (SELECT
  11489. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  11490. t.doctorId,
  11491. t.doctorName
  11492. FROM
  11493. (SELECT DISTINCT
  11494. t1.hospital_id AS hospitalId,
  11495. t1.behospital_code AS behospitalCode,
  11496. t1.bed_code AS bedCode,
  11497. t1.LEVEL AS LEVEL,
  11498. t1.grade_type AS gradeType,
  11499. t1.score_res AS scoreRes,
  11500. t1.NAME AS NAME,
  11501. t1.sex AS sex,
  11502. t1.beh_dept_id AS behDeptId,
  11503. t1.beh_dept_name AS behDeptName,
  11504. t1.doctor_id AS doctorId,
  11505. t1.doctor_name AS doctorName,
  11506. t1.beh_doctor_id AS behDoctorId,
  11507. t1.beh_doctor_name AS behDoctorName,
  11508. t1.director_doctor_id AS directorDoctorId,
  11509. t1.director_doctor_name AS directorDoctorName,
  11510. t1.birthday AS birthday,
  11511. t1.behospital_date AS behospitalDate,
  11512. t1.leave_hospital_date AS leaveHospitalDate,
  11513. t1.placefile_date AS placefileDate,
  11514. t1.gmt_create AS gradeTime,
  11515. t1.diagnose,
  11516. t1.ward_name AS wardName,
  11517. t2.age,
  11518. t1.file_code AS fileCode,
  11519. t1.checkStatus,
  11520. t1.mrStatus,
  11521. t1.chName,
  11522. t1.mrName,
  11523. t1.chTime,
  11524. t1.mrTime
  11525. FROM
  11526. (SELECT
  11527. be.*,
  11528. b.grade_type,
  11529. b.score_res,
  11530. b.gmt_create,
  11531. b.LEVEL,
  11532. ifnull(mci.status,0) AS checkStatus,
  11533. ifnull(hm_mci.status,0) AS mrStatus,
  11534. mci.check_name as chName,
  11535. hm_mci.check_name as mrName,
  11536. mci.gmt_create as chTime,
  11537. hm_mci.gmt_create as mrTime
  11538. FROM
  11539. (
  11540. SELECT DISTINCT
  11541. a.hospital_id,
  11542. a.behospital_code,
  11543. a.bed_code,
  11544. a.file_code,
  11545. a.NAME,
  11546. a.sex,
  11547. a.beh_dept_id,
  11548. a.beh_dept_name,
  11549. a.birthday,
  11550. a.behospital_date,
  11551. a.leave_hospital_date,
  11552. a.doctor_id,
  11553. a.doctor_name,
  11554. a.beh_doctor_id,
  11555. a.beh_doctor_name,
  11556. a.director_doctor_id,
  11557. a.director_doctor_name,
  11558. a.diagnose,
  11559. a.placefile_date,
  11560. a.ward_name
  11561. FROM
  11562. med_behospital_info a,
  11563. med_qcresult_detail k,
  11564. sys_user_dept b,
  11565. med_qcresult_cases c,
  11566. qc_cases_entry d
  11567. WHERE
  11568. a.is_deleted = 'N'
  11569. AND b.is_deleted = 'N'
  11570. AND c.is_deleted = 'N'
  11571. AND d.is_deleted = 'N'
  11572. AND a.hospital_id = b.hospital_id
  11573. AND a.hospital_id = c.hospital_id
  11574. AND a.behospital_code = c.behospital_code
  11575. AND a.beh_dept_id = b.dept_id
  11576. AND c.cases_id = d.cases_id
  11577. AND a.hospital_id = k.hospital_id
  11578. AND a.behospital_code = k.behospital_code
  11579. AND c.cases_id = k.cases_id
  11580. AND k.cases_id = d.cases_id
  11581. AND k.cases_entry_id = d.id
  11582. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  11583. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  11584. <!-- AND c.`level`='不合格'-->
  11585. <!-- </if>-->
  11586. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  11587. <!-- AND c.`level`='合格'-->
  11588. <!-- </if>-->
  11589. <!-- </if>-->
  11590. AND a.qc_type_id != 0
  11591. <if test="qcResultShortPageVO.userId!=null">
  11592. AND b.user_id = #{qcResultShortPageVO.userId}
  11593. </if>
  11594. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11595. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11596. </if>
  11597. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11598. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11599. </if>
  11600. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11601. <if test="qcResultShortPageVO.startDate != null ">
  11602. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11603. </if>
  11604. <if test="qcResultShortPageVO.endDate != null ">
  11605. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11606. </if>
  11607. </if>
  11608. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11609. <if test="qcResultShortPageVO.startDate != null ">
  11610. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11611. </if>
  11612. <if test="qcResultShortPageVO.endDate != null">
  11613. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11614. </if>
  11615. </if>
  11616. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11617. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11618. </if>
  11619. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11620. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  11621. </if>
  11622. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11623. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11624. </if>
  11625. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11626. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11627. </if>
  11628. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11629. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11630. </if>
  11631. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11632. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11633. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11634. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11635. </if>
  11636. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11637. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11638. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11639. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11640. </if>
  11641. <if test="qcResultShortPageVO.casesEntryId != null ">
  11642. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11643. </if>
  11644. <if test="qcResultShortPageVO.ruleType != null">
  11645. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11646. </if>
  11647. )be
  11648. left join med_check_info mci
  11649. on mci.is_deleted = 'N'
  11650. and mci.check_type = 0
  11651. and be.hospital_id = mci.hospital_id
  11652. and be.behospital_code = mci.behospital_code
  11653. left join med_check_info hm_mci
  11654. on hm_mci.is_deleted = 'N'
  11655. and hm_mci.check_type = 1
  11656. and be.hospital_id = hm_mci.hospital_id
  11657. and be.behospital_code = hm_mci.behospital_code
  11658. left join med_qcresult_info b
  11659. on b.is_deleted = 'N'
  11660. AND be.hospital_id = b.hospital_id
  11661. AND be.behospital_code = b.behospital_code
  11662. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11663. AND b.`level` = #{qcResultPageVO.level}
  11664. </if>
  11665. ) t1
  11666. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11667. AND t1.behospital_code = t2.behospital_code
  11668. AND t2.is_deleted = 'N'
  11669. ) t
  11670. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11671. AND t.hospitalId = qi.hospital_id
  11672. AND t.behospitalCode = qi.behospital_code
  11673. where 1=1
  11674. <if test="qcResultShortPageVO.checkStatus != null">
  11675. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11676. </if>
  11677. <if test="qcResultShortPageVO.mrStatus != null">
  11678. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11679. </if>
  11680. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11681. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11682. </if>
  11683. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11684. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11685. </if>
  11686. <if test="qcResultShortPageVO.chTimeStart != null ">
  11687. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11688. </if>
  11689. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11690. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11691. </if>
  11692. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11693. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11694. </if>
  11695. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11696. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11697. </if>
  11698. GROUP BY
  11699. t.behDeptId,
  11700. t.behDeptName,
  11701. t.doctorId,
  11702. t.doctorName
  11703. )f2
  11704. WHERE
  11705. f1.doctorId = f2.doctorId
  11706. AND f1.doctorName = f2.doctorName
  11707. </select>
  11708. <!-- 未整改病历缺陷评分详情页导出-->
  11709. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  11710. SELECT
  11711. f1.behDeptId,
  11712. f1.behDeptName,
  11713. f1.behDoctorName,
  11714. f1.patName,
  11715. f1.behospitalCode,
  11716. f1.hospitalId,
  11717. f1.behospitalDate,
  11718. f1.leaveHospitalDate,
  11719. f1.score,
  11720. f1.scoreBn,
  11721. f2.avgScore,
  11722. f1.msg,
  11723. f1.caseName,
  11724. f1.checkStatus,
  11725. f1.mrStatus,
  11726. f1.chName,
  11727. f1.mrName,
  11728. f1.chTime,
  11729. f1.mrTime
  11730. FROM
  11731. (SELECT
  11732. t.doctorName AS behDoctorName,
  11733. t.`name` AS patName,
  11734. t.behospitalCode AS behospitalCode,
  11735. t.behospitalDate AS behospitalDate,
  11736. t.leaveHospitalDate AS leaveHospitalDate,
  11737. qi.score_res AS score,
  11738. t.scoreBn,
  11739. qd.msg AS msg,
  11740. qc.NAME AS caseName,
  11741. t.behDeptId,
  11742. t.behDeptName,
  11743. t.hospitalId,
  11744. t.checkStatus,
  11745. t.mrStatus,
  11746. t.chName,
  11747. t.mrName,
  11748. t.chTime,
  11749. t.mrTime
  11750. FROM
  11751. (SELECT DISTINCT
  11752. t1.hospital_id AS hospitalId,
  11753. t1.behospital_code AS behospitalCode,
  11754. t1.bed_code AS bedCode,
  11755. t1.LEVEL AS LEVEL,
  11756. t1.grade_type AS gradeType,
  11757. t1.score_res AS scoreRes,
  11758. t1.scoreBn,
  11759. t1.NAME AS NAME,
  11760. t1.sex AS sex,
  11761. t1.beh_dept_id AS behDeptId,
  11762. t1.beh_dept_name AS behDeptName,
  11763. t1.doctor_id AS doctorId,
  11764. t1.doctor_name AS doctorName,
  11765. t1.beh_doctor_id AS behDoctorId,
  11766. t1.beh_doctor_name AS behDoctorName,
  11767. t1.director_doctor_id AS directorDoctorId,
  11768. t1.director_doctor_name AS directorDoctorName,
  11769. t1.birthday AS birthday,
  11770. t1.behospital_date AS behospitalDate,
  11771. t1.leave_hospital_date AS leaveHospitalDate,
  11772. t1.placefile_date AS placefileDate,
  11773. t1.gmt_create AS gradeTime,
  11774. t1.diagnose,
  11775. t1.ward_name AS wardName,
  11776. t2.age,
  11777. t1.file_code AS fileCode,
  11778. t1.checkStatus,
  11779. t1.mrStatus,
  11780. t1.chName,
  11781. t1.mrName,
  11782. t1.chTime,
  11783. t1.mrTime
  11784. FROM
  11785. (SELECT
  11786. be.*,
  11787. ifnull(mci.status,0) AS checkStatus,
  11788. ifnull(hm_mci.status,0) AS mrStatus,
  11789. mci.check_name as chName,
  11790. e.score_res as scoreBn,
  11791. hm_mci.check_name as mrName,
  11792. mci.gmt_create as chTime,
  11793. hm_mci.gmt_create as mrTime
  11794. FROM
  11795. (
  11796. SELECT DISTINCT
  11797. a.hospital_id,
  11798. a.behospital_code,
  11799. a.bed_code,
  11800. a.file_code,
  11801. b.LEVEL,
  11802. b.grade_type,
  11803. b.score_res,
  11804. a.NAME,
  11805. a.sex,
  11806. a.beh_dept_id,
  11807. a.beh_dept_name,
  11808. a.birthday,
  11809. a.behospital_date,
  11810. a.leave_hospital_date,
  11811. a.doctor_id,
  11812. a.doctor_name,
  11813. a.beh_doctor_id,
  11814. a.beh_doctor_name,
  11815. a.director_doctor_id,
  11816. a.director_doctor_name,
  11817. a.diagnose,
  11818. a.placefile_date,
  11819. a.ward_name,
  11820. b.gmt_create
  11821. FROM
  11822. med_behospital_info a,
  11823. med_qcresult_info b,
  11824. med_qcresult_detail c,
  11825. qc_cases_entry d
  11826. WHERE
  11827. a.is_deleted = 'N'
  11828. AND b.is_deleted = 'N'
  11829. AND c.is_deleted = 'N'
  11830. AND d.is_deleted = 'N'
  11831. AND a.hospital_id = b.hospital_id
  11832. AND a.hospital_id = c.hospital_id
  11833. AND a.behospital_code = b.behospital_code
  11834. AND a.behospital_code = c.behospital_code
  11835. AND c.cases_id = d.cases_id
  11836. AND c.cases_entry_id = d.id
  11837. AND a.qc_type_id != 0
  11838. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11839. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11840. </if>
  11841. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11842. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11843. </if>
  11844. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11845. <if test="qcResultShortPageVO.startDate != null ">
  11846. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11847. </if>
  11848. <if test="qcResultShortPageVO.endDate != null ">
  11849. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11850. </if>
  11851. </if>
  11852. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11853. <if test="qcResultShortPageVO.startDate != null ">
  11854. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11855. </if>
  11856. <if test="qcResultShortPageVO.endDate != null">
  11857. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11858. </if>
  11859. </if>
  11860. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11861. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11862. </if>
  11863. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11864. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  11865. </if>
  11866. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11867. AND b.`level` = #{qcResultShortPageVO.level}
  11868. </if>
  11869. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11870. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11871. </if>
  11872. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11873. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11874. </if>
  11875. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11876. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11877. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11878. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11879. </if>
  11880. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11881. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11882. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11883. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11884. </if>
  11885. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11886. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11887. </if>
  11888. <if test="qcResultShortPageVO.casesEntryId != null ">
  11889. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11890. </if>
  11891. <if test="qcResultShortPageVO.isReject != null">
  11892. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11893. </if>
  11894. <if test="qcResultShortPageVO.ruleType != null">
  11895. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11896. </if>
  11897. )be
  11898. left join med_check_info mci
  11899. on mci.is_deleted = 'N'
  11900. and mci.check_type = 0
  11901. and be.hospital_id = mci.hospital_id
  11902. and be.behospital_code = mci.behospital_code
  11903. left join med_check_info hm_mci
  11904. on hm_mci.is_deleted = 'N'
  11905. and hm_mci.check_type = 1
  11906. and be.hospital_id = hm_mci.hospital_id
  11907. and be.behospital_code = hm_mci.behospital_code
  11908. LEFT JOIN med_qcresult_cases e
  11909. on be.behospital_code = e.behospital_code
  11910. and be.hospital_id = e.hospital_id
  11911. AND e.is_deleted = 'N'
  11912. and e.cases_id = 243
  11913. ) t1
  11914. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11915. AND t1.behospital_code = t2.behospital_code
  11916. AND t2.is_deleted = 'N'
  11917. ) t
  11918. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11919. AND t.hospitalId = qi.hospital_id
  11920. AND t.behospitalCode = qi.behospital_code
  11921. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  11922. AND t.hospitalId = qd.hospital_id
  11923. AND t.behospitalCode = qd.behospital_code
  11924. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  11925. AND qd.cases_id = qc.id
  11926. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  11927. AND qd.cases_id = qce.cases_id
  11928. AND qd.cases_entry_id = qce.id
  11929. where 1=1
  11930. <if test="qcResultShortPageVO.checkStatus != null">
  11931. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11932. </if>
  11933. <if test="qcResultShortPageVO.mrStatus != null">
  11934. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11935. </if>
  11936. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11937. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11938. </if>
  11939. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11940. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11941. </if>
  11942. <if test="qcResultShortPageVO.chTimeStart != null ">
  11943. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11944. </if>
  11945. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11946. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11947. </if>
  11948. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11949. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11950. </if>
  11951. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11952. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11953. </if>
  11954. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11955. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  11956. </if>
  11957. <if test="qcResultShortPageVO.casesEntryId != null ">
  11958. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  11959. </if>
  11960. )f1,
  11961. (SELECT
  11962. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  11963. t.behDeptId,
  11964. t.behDeptName
  11965. FROM
  11966. (SELECT DISTINCT
  11967. t1.hospital_id AS hospitalId,
  11968. t1.behospital_code AS behospitalCode,
  11969. t1.bed_code AS bedCode,
  11970. t1.LEVEL AS LEVEL,
  11971. t1.grade_type AS gradeType,
  11972. t1.score_res AS scoreRes,
  11973. t1.NAME AS NAME,
  11974. t1.sex AS sex,
  11975. t1.beh_dept_id AS behDeptId,
  11976. t1.beh_dept_name AS behDeptName,
  11977. t1.doctor_id AS doctorId,
  11978. t1.doctor_name AS doctorName,
  11979. t1.beh_doctor_id AS behDoctorId,
  11980. t1.beh_doctor_name AS behDoctorName,
  11981. t1.director_doctor_id AS directorDoctorId,
  11982. t1.director_doctor_name AS directorDoctorName,
  11983. t1.birthday AS birthday,
  11984. t1.behospital_date AS behospitalDate,
  11985. t1.leave_hospital_date AS leaveHospitalDate,
  11986. t1.placefile_date AS placefileDate,
  11987. t1.gmt_create AS gradeTime,
  11988. t1.diagnose,
  11989. t1.ward_name AS wardName,
  11990. t2.age,
  11991. t1.file_code AS fileCode,
  11992. t1.checkStatus,
  11993. t1.mrStatus,
  11994. t1.chName,
  11995. t1.mrName,
  11996. t1.chTime,
  11997. t1.mrTime
  11998. FROM
  11999. (SELECT
  12000. be.*,
  12001. ifnull(mci.status,0) AS checkStatus,
  12002. ifnull(hm_mci.status,0) AS mrStatus,
  12003. mci.check_name as chName,
  12004. hm_mci.check_name as mrName,
  12005. mci.gmt_create as chTime,
  12006. hm_mci.gmt_create as mrTime
  12007. FROM
  12008. (
  12009. SELECT DISTINCT
  12010. a.hospital_id,
  12011. a.behospital_code,
  12012. a.bed_code,
  12013. a.file_code,
  12014. b.LEVEL,
  12015. b.grade_type,
  12016. b.score_res,
  12017. a.NAME,
  12018. a.sex,
  12019. a.beh_dept_id,
  12020. a.beh_dept_name,
  12021. a.birthday,
  12022. a.behospital_date,
  12023. a.leave_hospital_date,
  12024. a.doctor_id,
  12025. a.doctor_name,
  12026. a.beh_doctor_id,
  12027. a.beh_doctor_name,
  12028. a.director_doctor_id,
  12029. a.director_doctor_name,
  12030. a.diagnose,
  12031. a.placefile_date,
  12032. a.ward_name,
  12033. b.gmt_create
  12034. FROM
  12035. med_behospital_info a,
  12036. med_qcresult_info b,
  12037. med_qcresult_detail c,
  12038. qc_cases_entry d
  12039. WHERE
  12040. a.is_deleted = 'N'
  12041. AND b.is_deleted = 'N'
  12042. AND c.is_deleted = 'N'
  12043. AND d.is_deleted = 'N'
  12044. AND a.hospital_id = b.hospital_id
  12045. AND a.hospital_id = c.hospital_id
  12046. AND a.behospital_code = b.behospital_code
  12047. AND a.behospital_code = c.behospital_code
  12048. AND c.cases_id = d.cases_id
  12049. AND c.cases_entry_id = d.id
  12050. AND a.qc_type_id != 0
  12051. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12052. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12053. </if>
  12054. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12055. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12056. </if>
  12057. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12058. <if test="qcResultShortPageVO.startDate != null ">
  12059. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12060. </if>
  12061. <if test="qcResultShortPageVO.endDate != null ">
  12062. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12063. </if>
  12064. </if>
  12065. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12066. <if test="qcResultShortPageVO.startDate != null ">
  12067. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12068. </if>
  12069. <if test="qcResultShortPageVO.endDate != null">
  12070. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12071. </if>
  12072. </if>
  12073. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12074. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12075. </if>
  12076. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12077. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  12078. </if>
  12079. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12080. AND b.`level` = #{qcResultShortPageVO.level}
  12081. </if>
  12082. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12083. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12084. </if>
  12085. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12086. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12087. </if>
  12088. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12089. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12090. </if>
  12091. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12092. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12093. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12094. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12095. </if>
  12096. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12097. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12098. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12099. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12100. </if>
  12101. <if test="qcResultShortPageVO.casesEntryId != null ">
  12102. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12103. </if>
  12104. <if test="qcResultShortPageVO.isReject != null">
  12105. AND c.is_reject = #{qcResultShortPageVO.isReject}
  12106. </if>
  12107. <if test="qcResultShortPageVO.ruleType != null">
  12108. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12109. </if>
  12110. )be
  12111. left join med_check_info mci
  12112. on mci.is_deleted = 'N'
  12113. and mci.check_type = 0
  12114. and be.hospital_id = mci.hospital_id
  12115. and be.behospital_code = mci.behospital_code
  12116. left join med_check_info hm_mci
  12117. on hm_mci.is_deleted = 'N'
  12118. and hm_mci.check_type = 1
  12119. and be.hospital_id = hm_mci.hospital_id
  12120. and be.behospital_code = hm_mci.behospital_code
  12121. ) t1
  12122. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12123. AND t1.behospital_code = t2.behospital_code
  12124. AND t2.is_deleted = 'N'
  12125. ) t
  12126. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12127. AND t.hospitalId = qi.hospital_id
  12128. AND t.behospitalCode = qi.behospital_code
  12129. where 1=1
  12130. <if test="qcResultShortPageVO.checkStatus != null">
  12131. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12132. </if>
  12133. <if test="qcResultShortPageVO.mrStatus != null">
  12134. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12135. </if>
  12136. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12137. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12138. </if>
  12139. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12140. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12141. </if>
  12142. <if test="qcResultShortPageVO.chTimeStart != null ">
  12143. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12144. </if>
  12145. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12146. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12147. </if>
  12148. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12149. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12150. </if>
  12151. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12152. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12153. </if>
  12154. GROUP BY
  12155. t.behDeptId,
  12156. t.behDeptName
  12157. )f2
  12158. WHERE
  12159. f1.behDeptId = f2.behDeptId
  12160. AND f1.behDeptName = f2.behDeptName
  12161. </select>
  12162. <!-- 31天再入院详情页-->
  12163. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  12164. SELECT
  12165. t.fileCode,
  12166. t.diagnose,
  12167. t.NAME,
  12168. t.sex,
  12169. t.hospitalId,
  12170. t.behDeptId,
  12171. t.behDeptName,
  12172. t.behospitalCode,
  12173. t.behospitalDate,
  12174. t.leaveHospitalDate,
  12175. t.lastBehDeptId,
  12176. t.lastBehDeptName,
  12177. t.lastBehospitalCode,
  12178. t.lastBehospitalDate,
  12179. t.lastLeaveHospitalDate,
  12180. t.diffDays,
  12181. mqi.score_res AS scoreRes,
  12182. mqi.LEVEL AS LEVEL,
  12183. mqi_last.score_res AS lastScoreRes,
  12184. mqi_last.LEVEL AS lastLevel,
  12185. mhp.total_fee AS totleFee,
  12186. mhp.behospital_day_num AS behospitalDayNum,
  12187. mhp_last.total_fee AS lastTotleFee,
  12188. mhp_last.behospital_day_num AS lastBehospitalDayNum
  12189. FROM
  12190. (
  12191. SELECT
  12192. be.fileCode,
  12193. be.diagnose,
  12194. be.NAME,
  12195. be.sex,
  12196. be.hospitalId,
  12197. be.behDeptId,
  12198. be.behDeptName,
  12199. be.behospitalCode,
  12200. be.behospitalDate,
  12201. be.leaveHospitalDate,
  12202. be.lastBehDeptId,
  12203. be.lastBehDeptName,
  12204. be.lastBehospitalCode,
  12205. be.lastBehospitalDate,
  12206. be.lastLeaveHospitalDate,
  12207. be.diffDays
  12208. FROM
  12209. (
  12210. SELECT
  12211. r1.file_code AS fileCode,
  12212. r1.diagnose,
  12213. r1.NAME,
  12214. r1.sex,
  12215. r1.hospital_id AS hospitalId,
  12216. r1.beh_dept_id AS behDeptId,
  12217. r1.beh_dept_name AS behDeptName,
  12218. r1.behospital_code AS behospitalCode,
  12219. r1.behospital_date AS behospitalDate,
  12220. r1.leave_hospital_date AS leaveHospitalDate,
  12221. r2.beh_dept_id AS lastBehDeptId,
  12222. r2.beh_dept_name AS lastBehDeptName,
  12223. r2.behospital_code AS lastBehospitalCode,
  12224. r2.behospital_date AS lastBehospitalDate,
  12225. r2.leave_hospital_date AS lastLeaveHospitalDate,
  12226. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  12227. FROM
  12228. (
  12229. SELECT
  12230. ( @rownum := @rownum + 1 ) AS rownum,
  12231. t1.file_code,
  12232. t1.diagnose,
  12233. t1.NAME,
  12234. t1.sex,
  12235. t1.hospital_id,
  12236. t1.beh_dept_id,
  12237. t1.beh_dept_name,
  12238. t1.behospital_code,
  12239. t1.behospital_date,
  12240. t1.leave_hospital_date
  12241. FROM
  12242. (
  12243. SELECT
  12244. tt1.file_code,
  12245. tt1.diagnose,
  12246. tt2.NAME,
  12247. tt2.sex,
  12248. tt2.hospital_id,
  12249. tt2.beh_dept_id,
  12250. tt2.beh_dept_name,
  12251. tt2.behospital_code,
  12252. tt2.behospital_date,
  12253. tt2.leave_hospital_date
  12254. FROM
  12255. (
  12256. SELECT
  12257. a.file_code,
  12258. a.diagnose
  12259. FROM
  12260. med_behospital_info a
  12261. WHERE
  12262. a.is_deleted = 'N'
  12263. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12264. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  12265. </if>
  12266. AND a.qc_type_id != 0
  12267. AND IFNULL( a.diagnose, '' )!= ''
  12268. AND IFNULL( a.file_code, '' )!= ''
  12269. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12270. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  12271. </if>
  12272. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12273. <if test="reBeHosPageVO.startDate != null ">
  12274. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12275. </if>
  12276. <if test="reBeHosPageVO.endDate != null ">
  12277. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12278. </if>
  12279. </if>
  12280. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12281. <if test="reBeHosPageVO.startDate != null ">
  12282. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12283. </if>
  12284. <if test="reBeHosPageVO.endDate != null">
  12285. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12286. </if>
  12287. </if>
  12288. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12289. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12290. </if>
  12291. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12292. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  12293. </if>
  12294. GROUP BY
  12295. a.file_code,
  12296. a.diagnose
  12297. HAVING
  12298. count(*)> 1
  12299. ) tt1,
  12300. med_behospital_info tt2
  12301. WHERE
  12302. tt2.is_deleted = 'N'
  12303. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12304. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  12305. </if>
  12306. AND tt2.qc_type_id != 0
  12307. AND tt1.file_code = tt2.file_code
  12308. AND tt1.diagnose = tt2.diagnose
  12309. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12310. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  12311. </if>
  12312. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12313. <if test="reBeHosPageVO.startDate != null ">
  12314. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12315. </if>
  12316. <if test="reBeHosPageVO.endDate != null ">
  12317. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12318. </if>
  12319. </if>
  12320. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12321. <if test="reBeHosPageVO.startDate != null ">
  12322. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12323. </if>
  12324. <if test="reBeHosPageVO.endDate != null">
  12325. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12326. </if>
  12327. </if>
  12328. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12329. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12330. </if>
  12331. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12332. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  12333. </if>
  12334. ORDER BY
  12335. tt1.file_code,
  12336. tt1.diagnose,
  12337. tt2.behospital_date DESC
  12338. ) t1,
  12339. ( SELECT @rownum := 0 ) r
  12340. ) r1
  12341. LEFT JOIN (
  12342. SELECT
  12343. ( @INDEX := @INDEX + 1 ) AS rownum,
  12344. t1.file_code,
  12345. t1.diagnose,
  12346. t1.NAME,
  12347. t1.sex,
  12348. t1.hospital_id,
  12349. t1.beh_dept_id,
  12350. t1.beh_dept_name,
  12351. t1.behospital_code,
  12352. t1.behospital_date,
  12353. t1.leave_hospital_date
  12354. FROM
  12355. (
  12356. SELECT
  12357. tt1.file_code,
  12358. tt1.diagnose,
  12359. tt2.NAME,
  12360. tt2.sex,
  12361. tt2.hospital_id,
  12362. tt2.beh_dept_id,
  12363. tt2.beh_dept_name,
  12364. tt2.behospital_code,
  12365. tt2.behospital_date,
  12366. tt2.leave_hospital_date
  12367. FROM
  12368. (
  12369. SELECT
  12370. a.file_code,
  12371. a.diagnose
  12372. FROM
  12373. med_behospital_info a
  12374. WHERE
  12375. a.is_deleted = 'N'
  12376. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12377. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  12378. </if>
  12379. AND a.qc_type_id != 0
  12380. AND IFNULL( a.diagnose, '' )!= ''
  12381. AND IFNULL( a.file_code, '' )!= ''
  12382. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12383. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  12384. </if>
  12385. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12386. <if test="reBeHosPageVO.startDate != null ">
  12387. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12388. </if>
  12389. <if test="reBeHosPageVO.endDate != null ">
  12390. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12391. </if>
  12392. </if>
  12393. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12394. <if test="reBeHosPageVO.startDate != null ">
  12395. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12396. </if>
  12397. <if test="reBeHosPageVO.endDate != null">
  12398. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12399. </if>
  12400. </if>
  12401. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12402. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12403. </if>
  12404. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12405. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  12406. </if>
  12407. GROUP BY
  12408. a.file_code,
  12409. a.diagnose
  12410. HAVING
  12411. count(*)> 1
  12412. ) tt1,
  12413. med_behospital_info tt2
  12414. WHERE
  12415. tt2.is_deleted = 'N'
  12416. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12417. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  12418. </if>
  12419. AND tt2.qc_type_id != 0
  12420. AND tt1.file_code = tt2.file_code
  12421. AND tt1.diagnose = tt2.diagnose
  12422. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12423. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  12424. </if>
  12425. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12426. <if test="reBeHosPageVO.startDate != null ">
  12427. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12428. </if>
  12429. <if test="reBeHosPageVO.endDate != null ">
  12430. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12431. </if>
  12432. </if>
  12433. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12434. <if test="reBeHosPageVO.startDate != null ">
  12435. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12436. </if>
  12437. <if test="reBeHosPageVO.endDate != null">
  12438. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12439. </if>
  12440. </if>
  12441. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12442. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12443. </if>
  12444. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12445. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  12446. </if>
  12447. ORDER BY
  12448. tt1.file_code,
  12449. tt1.diagnose,
  12450. tt2.behospital_date DESC
  12451. ) t1,(
  12452. SELECT
  12453. @INDEX := 0
  12454. ) r
  12455. ) r2 ON r1.file_code = r2.file_code
  12456. AND r1.rownum = r2.rownum - 1
  12457. ) be
  12458. WHERE
  12459. be.diffDays IS NOT NULL
  12460. AND be.diffDays BETWEEN 0
  12461. AND 31
  12462. ) t
  12463. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  12464. AND t.hospitalId = mqi.hospital_id
  12465. AND t.behospitalCode = mqi.behospital_code
  12466. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  12467. AND t.hospitalId = mqi_last.hospital_id
  12468. AND t.lastBehospitalCode = mqi_last.behospital_code
  12469. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  12470. AND t.hospitalId = mhp.hospital_id
  12471. AND t.behospitalCode = mhp.behospital_code
  12472. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  12473. AND t.hospitalId = mhp_last.hospital_id
  12474. AND t.lastBehospitalCode = mhp_last.behospital_code
  12475. </select>
  12476. <!-- 31天再入院详情页-科室-->
  12477. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  12478. SELECT
  12479. t.fileCode,
  12480. t.diagnose,
  12481. t.NAME,
  12482. t.sex,
  12483. t.hospitalId,
  12484. t.behDeptId,
  12485. t.behDeptName,
  12486. t.doctorId,
  12487. t.doctorName,
  12488. t.behospitalCode,
  12489. t.behospitalDate,
  12490. t.leaveHospitalDate,
  12491. t.lastBehDeptId,
  12492. t.lastBehDeptName,
  12493. t.lastBehospitalCode,
  12494. t.lastBehospitalDate,
  12495. t.lastLeaveHospitalDate,
  12496. t.diffDays,
  12497. mqi.score_res AS scoreRes,
  12498. mqi.LEVEL AS LEVEL,
  12499. mqi_last.score_res AS lastScoreRes,
  12500. mqi_last.LEVEL AS lastLevel,
  12501. mhp.total_fee AS totleFee,
  12502. mhp.behospital_day_num AS behospitalDayNum,
  12503. mhp_last.total_fee AS lastTotleFee,
  12504. mhp_last.behospital_day_num AS lastBehospitalDayNum
  12505. FROM
  12506. (
  12507. SELECT
  12508. be.fileCode,
  12509. be.diagnose,
  12510. be.NAME,
  12511. be.sex,
  12512. be.hospitalId,
  12513. be.behDeptId,
  12514. be.behDeptName,
  12515. be.doctorId,
  12516. be.doctorName,
  12517. be.behospitalCode,
  12518. be.behospitalDate,
  12519. be.leaveHospitalDate,
  12520. be.lastBehDeptId,
  12521. be.lastBehDeptName,
  12522. be.lastBoctorId,
  12523. be.lastBoctorName,
  12524. be.lastBehospitalCode,
  12525. be.lastBehospitalDate,
  12526. be.lastLeaveHospitalDate,
  12527. be.diffDays
  12528. FROM
  12529. (
  12530. SELECT
  12531. r1.file_code AS fileCode,
  12532. r1.diagnose,
  12533. r1.NAME,
  12534. r1.sex,
  12535. r1.hospital_id AS hospitalId,
  12536. r1.beh_dept_id AS behDeptId,
  12537. r1.beh_dept_name AS behDeptName,
  12538. r1.doctor_id as doctorId,
  12539. r1.doctor_name as doctorName,
  12540. r1.behospital_code AS behospitalCode,
  12541. r1.behospital_date AS behospitalDate,
  12542. r1.leave_hospital_date AS leaveHospitalDate,
  12543. r2.beh_dept_id AS lastBehDeptId,
  12544. r2.beh_dept_name AS lastBehDeptName,
  12545. r2.behospital_code AS lastBehospitalCode,
  12546. r2.behospital_date AS lastBehospitalDate,
  12547. r2.doctor_id as lastBoctorId,
  12548. r2.doctor_name as lastBoctorName,
  12549. r2.leave_hospital_date AS lastLeaveHospitalDate,
  12550. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  12551. FROM
  12552. (
  12553. SELECT
  12554. ( @rownum := @rownum + 1 ) AS rownum,
  12555. t1.file_code,
  12556. t1.diagnose,
  12557. t1.NAME,
  12558. t1.sex,
  12559. t1.doctor_id,
  12560. t1.doctor_name,
  12561. t1.hospital_id,
  12562. t1.beh_dept_id,
  12563. t1.beh_dept_name,
  12564. t1.behospital_code,
  12565. t1.behospital_date,
  12566. t1.leave_hospital_date
  12567. FROM
  12568. (
  12569. SELECT
  12570. tt1.file_code,
  12571. tt1.diagnose,
  12572. tt1.doctor_id,
  12573. tt1.doctor_name,
  12574. tt2.NAME,
  12575. tt2.sex,
  12576. tt2.hospital_id,
  12577. tt2.beh_dept_id,
  12578. tt2.beh_dept_name,
  12579. tt2.behospital_code,
  12580. tt2.behospital_date,
  12581. tt2.leave_hospital_date
  12582. FROM
  12583. (
  12584. SELECT
  12585. a.file_code,
  12586. a.diagnose,
  12587. a.doctor_id,
  12588. a.doctor_name
  12589. FROM
  12590. med_behospital_info a,
  12591. sys_user_dept c
  12592. WHERE
  12593. a.is_deleted = 'N'
  12594. AND c.is_deleted = 'N'
  12595. AND a.hospital_id = c.hospital_id
  12596. AND a.beh_dept_id = c.dept_id
  12597. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  12598. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  12599. </if>
  12600. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12601. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  12602. </if>
  12603. <if test="reBeHosPageVO.userId!=null">
  12604. AND c.user_id = #{reBeHosPageVO.userId}
  12605. </if>
  12606. AND a.qc_type_id != 0
  12607. AND IFNULL( a.diagnose, '' )!= ''
  12608. AND IFNULL( a.file_code, '' )!= ''
  12609. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12610. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  12611. </if>
  12612. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12613. <if test="reBeHosPageVO.startDate != null ">
  12614. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12615. </if>
  12616. <if test="reBeHosPageVO.endDate != null ">
  12617. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12618. </if>
  12619. </if>
  12620. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12621. <if test="reBeHosPageVO.startDate != null ">
  12622. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12623. </if>
  12624. <if test="reBeHosPageVO.endDate != null">
  12625. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12626. </if>
  12627. </if>
  12628. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12629. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12630. </if>
  12631. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12632. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  12633. </if>
  12634. GROUP BY
  12635. a.file_code,
  12636. a.diagnose
  12637. HAVING
  12638. count(*)> 1
  12639. ) tt1,
  12640. med_behospital_info tt2
  12641. WHERE
  12642. tt2.is_deleted = 'N'
  12643. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12644. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  12645. </if>
  12646. AND tt2.qc_type_id != 0
  12647. AND tt1.file_code = tt2.file_code
  12648. AND tt1.diagnose = tt2.diagnose
  12649. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12650. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  12651. </if>
  12652. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12653. <if test="reBeHosPageVO.startDate != null ">
  12654. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12655. </if>
  12656. <if test="reBeHosPageVO.endDate != null ">
  12657. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12658. </if>
  12659. </if>
  12660. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12661. <if test="reBeHosPageVO.startDate != null ">
  12662. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12663. </if>
  12664. <if test="reBeHosPageVO.endDate != null">
  12665. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12666. </if>
  12667. </if>
  12668. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12669. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12670. </if>
  12671. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12672. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  12673. </if>
  12674. ORDER BY
  12675. tt1.file_code,
  12676. tt1.diagnose,
  12677. tt2.behospital_date DESC
  12678. ) t1,
  12679. ( SELECT @rownum := 0 ) r
  12680. ) r1
  12681. LEFT JOIN (
  12682. SELECT
  12683. ( @INDEX := @INDEX + 1 ) AS rownum,
  12684. t1.file_code,
  12685. t1.diagnose,
  12686. t1.NAME,
  12687. t1.sex,
  12688. t1.hospital_id,
  12689. t1.beh_dept_id,
  12690. t1.beh_dept_name,
  12691. t1.doctor_id,
  12692. t1.doctor_name,
  12693. t1.behospital_code,
  12694. t1.behospital_date,
  12695. t1.leave_hospital_date
  12696. FROM
  12697. (
  12698. SELECT
  12699. tt1.file_code,
  12700. tt1.diagnose,
  12701. tt1.doctor_id,
  12702. tt1.doctor_name,
  12703. tt2.NAME,
  12704. tt2.sex,
  12705. tt2.hospital_id,
  12706. tt2.beh_dept_id,
  12707. tt2.beh_dept_name,
  12708. tt2.behospital_code,
  12709. tt2.behospital_date,
  12710. tt2.leave_hospital_date
  12711. FROM
  12712. (
  12713. SELECT
  12714. a.file_code,
  12715. a.diagnose,
  12716. a.doctor_id ,
  12717. a.doctor_name
  12718. FROM
  12719. med_behospital_info a,
  12720. sys_user_dept c
  12721. WHERE
  12722. a.is_deleted = 'N'
  12723. AND c.is_deleted = 'N'
  12724. AND a.hospital_id = c.hospital_id
  12725. AND a.beh_dept_id = c.dept_id
  12726. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  12727. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  12728. </if>
  12729. <if test="reBeHosPageVO.userId!=null">
  12730. AND c.user_id = #{reBeHosPageVO.userId}
  12731. </if>
  12732. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12733. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  12734. </if>
  12735. AND a.qc_type_id != 0
  12736. AND IFNULL( a.diagnose, '' )!= ''
  12737. AND IFNULL( a.file_code, '' )!= ''
  12738. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12739. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  12740. </if>
  12741. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12742. <if test="reBeHosPageVO.startDate != null ">
  12743. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12744. </if>
  12745. <if test="reBeHosPageVO.endDate != null ">
  12746. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12747. </if>
  12748. </if>
  12749. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12750. <if test="reBeHosPageVO.startDate != null ">
  12751. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12752. </if>
  12753. <if test="reBeHosPageVO.endDate != null">
  12754. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12755. </if>
  12756. </if>
  12757. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12758. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12759. </if>
  12760. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12761. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  12762. </if>
  12763. GROUP BY
  12764. a.file_code,
  12765. a.diagnose
  12766. HAVING
  12767. count(*)> 1
  12768. ) tt1,
  12769. med_behospital_info tt2
  12770. WHERE
  12771. tt2.is_deleted = 'N'
  12772. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  12773. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  12774. </if>
  12775. AND tt2.qc_type_id != 0
  12776. AND tt1.file_code = tt2.file_code
  12777. AND tt1.diagnose = tt2.diagnose
  12778. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  12779. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  12780. </if>
  12781. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  12782. <if test="reBeHosPageVO.startDate != null ">
  12783. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  12784. </if>
  12785. <if test="reBeHosPageVO.endDate != null ">
  12786. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  12787. </if>
  12788. </if>
  12789. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  12790. <if test="reBeHosPageVO.startDate != null ">
  12791. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  12792. </if>
  12793. <if test="reBeHosPageVO.endDate != null">
  12794. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  12795. </if>
  12796. </if>
  12797. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  12798. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  12799. </if>
  12800. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  12801. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  12802. </if>
  12803. ORDER BY
  12804. tt1.file_code,
  12805. tt1.diagnose,
  12806. tt2.behospital_date DESC
  12807. ) t1,(
  12808. SELECT
  12809. @INDEX := 0
  12810. ) r
  12811. ) r2 ON r1.file_code = r2.file_code
  12812. AND r1.rownum = r2.rownum - 1
  12813. ) be
  12814. WHERE
  12815. be.diffDays IS NOT NULL
  12816. AND be.diffDays BETWEEN 0
  12817. AND 31
  12818. ) t
  12819. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  12820. AND t.hospitalId = mqi.hospital_id
  12821. AND t.behospitalCode = mqi.behospital_code
  12822. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  12823. AND t.hospitalId = mqi_last.hospital_id
  12824. AND t.lastBehospitalCode = mqi_last.behospital_code
  12825. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  12826. AND t.hospitalId = mhp.hospital_id
  12827. AND t.behospitalCode = mhp.behospital_code
  12828. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  12829. AND t.hospitalId = mhp_last.hospital_id
  12830. AND t.lastBehospitalCode = mhp_last.behospital_code
  12831. </select>
  12832. <!-- 单条条目缺陷统计-->
  12833. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  12834. SELECT
  12835. a.beh_dept_id AS id,
  12836. a.beh_dept_name AS NAME,
  12837. count(*) AS num
  12838. FROM
  12839. med_behospital_info a,
  12840. med_qcresult_detail b
  12841. WHERE
  12842. a.is_deleted = 'N'
  12843. AND b.is_deleted = 'N'
  12844. AND a.hospital_id = b.hospital_id
  12845. AND a.behospital_code = b.behospital_code
  12846. AND a.qc_type_id != 0
  12847. and b.cases_entry_id=2658
  12848. <if test="isPlacefile != null and isPlacefile != ''">
  12849. and a.is_placefile = #{isPlacefile}
  12850. </if>
  12851. <if test="hospitalId != null and hospitalId != ''">
  12852. AND a.hospital_id = #{hospitalId}
  12853. </if>
  12854. <if test="isPlacefile != null and isPlacefile == 0">
  12855. <if test="startDate != null and startDate != ''">
  12856. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12857. </if>
  12858. <if test="endDate != null and endDate != ''">
  12859. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12860. </if>
  12861. </if>
  12862. <if test="isPlacefile != null and isPlacefile == 1">
  12863. <if test="startDate != null and startDate != ''">
  12864. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12865. </if>
  12866. <if test="endDate != null and endDate != ''">
  12867. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12868. </if>
  12869. </if>
  12870. GROUP BY
  12871. a.beh_dept_id,
  12872. a.beh_dept_name
  12873. </select>
  12874. <!-- 单条条目缺陷统计-->
  12875. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  12876. SELECT
  12877. a.beh_dept_id AS deptId,
  12878. a.beh_dept_name AS deptName,
  12879. a.doctor_id as doctorId,
  12880. a.doctor_name as doctorName,
  12881. count(*) AS num
  12882. FROM
  12883. med_behospital_info a,
  12884. med_qcresult_detail b,
  12885. sys_user_dept c
  12886. WHERE
  12887. a.is_deleted = 'N'
  12888. AND b.is_deleted = 'N'
  12889. AND c.is_deleted = 'N'
  12890. AND a.hospital_id = b.hospital_id
  12891. AND a.hospital_id = c.hospital_id
  12892. AND a.behospital_code = b.behospital_code
  12893. AND a.beh_dept_id = c.dept_id
  12894. AND a.qc_type_id != 0
  12895. and b.cases_entry_id=2658
  12896. <if test="isPlacefile != null and isPlacefile != ''">
  12897. and a.is_placefile = #{isPlacefile}
  12898. </if>
  12899. <if test="hospitalId != null and hospitalId != ''">
  12900. AND a.hospital_id = #{hospitalId}
  12901. </if>
  12902. <if test="userId!=null">
  12903. AND c.user_id = #{userId}
  12904. </if>
  12905. <if test="isPlacefile != null and isPlacefile == 0">
  12906. <if test="startDate != null and startDate != ''">
  12907. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12908. </if>
  12909. <if test="endDate != null and endDate != ''">
  12910. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12911. </if>
  12912. </if>
  12913. <if test="isPlacefile != null and isPlacefile == 1">
  12914. <if test="startDate != null and startDate != ''">
  12915. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12916. </if>
  12917. <if test="endDate != null and endDate != ''">
  12918. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12919. </if>
  12920. </if>
  12921. GROUP BY
  12922. a.beh_dept_id,
  12923. a.beh_dept_name,
  12924. a.doctor_id,
  12925. a.doctor_name
  12926. </select>
  12927. <!-- 病案首页改善率质控评分页(内页)-->
  12928. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12929. SELECT
  12930. t.*
  12931. FROM
  12932. (
  12933. SELECT DISTINCT
  12934. t1.hospital_id AS hospitalId,
  12935. t1.behospital_code AS behospitalCode,
  12936. t1.bed_code AS bedCode,
  12937. t1.LEVEL AS LEVEL,
  12938. t1.grade_type AS gradeType,
  12939. t1.score_res AS scoreRes,
  12940. t1.NAME AS NAME,
  12941. t1.sex AS sex,
  12942. t1.beh_dept_id AS behDeptId,
  12943. t1.beh_dept_name AS behDeptName,
  12944. t1.doctor_id AS doctorId,
  12945. t1.doctor_name AS doctorName,
  12946. t1.beh_doctor_id AS behDoctorId,
  12947. t1.beh_doctor_name AS behDoctorName,
  12948. t1.director_doctor_id AS directorDoctorId,
  12949. t1.director_doctor_name AS directorDoctorName,
  12950. t1.birthday AS birthday,
  12951. t1.behospital_date AS behospitalDate,
  12952. t1.leave_hospital_date AS leaveHospitalDate,
  12953. t1.placefile_date AS placefileDate,
  12954. t1.gmt_create AS gradeTime,
  12955. t1.diagnose,
  12956. t1.ward_name AS wardName,
  12957. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12958. t1.file_code AS fileCode,
  12959. t1.checkStatus,
  12960. t1.mrStatus,
  12961. t1.chName,
  12962. t1.mrName,
  12963. t1.chTime,
  12964. t1.mrTime
  12965. FROM
  12966. (
  12967. SELECT
  12968. be.*,
  12969. ifnull( mci.STATUS, 0 ) AS checkStatus,
  12970. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  12971. mci.check_name AS chName,
  12972. hm_mci.check_name AS mrName,
  12973. mci.gmt_create AS chTime,
  12974. hm_mci.gmt_create AS mrTime
  12975. FROM
  12976. (
  12977. SELECT DISTINCT
  12978. a.hospital_id,
  12979. a.behospital_code,
  12980. a.bed_code,
  12981. a.file_code,
  12982. c.LEVEL,
  12983. c.grade_type,
  12984. c.score_res,
  12985. a.NAME,
  12986. a.sex,
  12987. a.beh_dept_id,
  12988. a.beh_dept_name,
  12989. a.birthday,
  12990. a.behospital_date,
  12991. a.leave_hospital_date,
  12992. a.doctor_id,
  12993. a.doctor_name,
  12994. a.beh_doctor_id,
  12995. a.beh_doctor_name,
  12996. a.director_doctor_id,
  12997. a.director_doctor_name,
  12998. a.diagnose,
  12999. a.placefile_date,
  13000. a.ward_name,
  13001. c.gmt_create
  13002. FROM
  13003. med_behospital_info a,
  13004. med_home_page b,
  13005. med_qcresult_info c,
  13006. med_qcresult_cases d,
  13007. (
  13008. SELECT
  13009. m4.*
  13010. FROM
  13011. med_behospital_info m1,
  13012. med_home_page m2,
  13013. med_qcresult_info m3,
  13014. med_qcresult_cases m4
  13015. WHERE
  13016. m1.is_deleted = 'N'
  13017. AND m2.is_deleted = 'N'
  13018. AND m3.is_deleted = 'Y'
  13019. AND m4.is_deleted = 'Y'
  13020. AND m1.hospital_id = m2.hospital_id
  13021. AND m1.hospital_id = m3.hospital_id
  13022. AND m1.hospital_id = m4.hospital_id
  13023. AND m1.behospital_code = m2.behospital_code
  13024. AND m1.behospital_code = m3.behospital_code
  13025. AND m1.behospital_code = m4.behospital_code
  13026. AND m3.gmt_create = m4.gmt_create
  13027. AND m3.have_home_page = 1
  13028. AND m4.cases_id = 243
  13029. AND m1.qc_type_id != 0
  13030. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13031. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13032. </if>
  13033. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13034. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13035. </if>
  13036. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13037. <if test="qcResultShortPageVO.startDate != null ">
  13038. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13039. </if>
  13040. <if test="qcResultShortPageVO.endDate != null ">
  13041. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13042. </if>
  13043. </if>
  13044. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13045. <if test="qcResultShortPageVO.startDate != null">
  13046. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13047. </if>
  13048. <if test="qcResultShortPageVO.endDate != null ">
  13049. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13050. </if>
  13051. </if>
  13052. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13053. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  13054. </if>
  13055. GROUP BY
  13056. m1.behospital_code
  13057. ORDER BY
  13058. m1.behospital_code,
  13059. m4.gmt_create
  13060. ) e
  13061. WHERE
  13062. a.is_deleted = 'N'
  13063. AND b.is_deleted = 'N'
  13064. AND c.is_deleted = 'N'
  13065. AND d.is_deleted = 'N'
  13066. AND a.hospital_id = b.hospital_id
  13067. AND a.hospital_id = c.hospital_id
  13068. AND a.hospital_id = d.hospital_id
  13069. AND a.hospital_id = e.hospital_id
  13070. AND a.behospital_code = b.behospital_code
  13071. AND a.behospital_code = c.behospital_code
  13072. AND a.behospital_code = d.behospital_code
  13073. AND a.behospital_code = e.behospital_code
  13074. AND d.cases_id = 243
  13075. AND d.score_res > e.score_res
  13076. AND a.qc_type_id != 0
  13077. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13078. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13079. </if>
  13080. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13081. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13082. </if>
  13083. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13084. <if test="qcResultShortPageVO.startDate != null ">
  13085. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13086. </if>
  13087. <if test="qcResultShortPageVO.endDate != null ">
  13088. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13089. </if>
  13090. </if>
  13091. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13092. <if test="qcResultShortPageVO.startDate != null ">
  13093. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13094. </if>
  13095. <if test="qcResultShortPageVO.endDate != null">
  13096. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13097. </if>
  13098. </if>
  13099. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13100. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13101. </if>
  13102. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13103. AND c.`level` = #{qcResultShortPageVO.level}
  13104. </if>
  13105. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13106. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13107. </if>
  13108. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13109. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13110. </if>
  13111. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13112. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13113. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13114. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13115. </if>
  13116. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13117. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13118. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13119. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13120. </if>
  13121. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  13122. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  13123. </if>
  13124. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  13125. AND d.score_res = 20
  13126. </if>
  13127. ) be
  13128. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13129. AND mci.check_type = 0
  13130. AND be.hospital_id = mci.hospital_id
  13131. AND be.behospital_code = mci.behospital_code
  13132. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  13133. AND hm_mci.check_type = 1
  13134. AND be.hospital_id = hm_mci.hospital_id
  13135. AND be.behospital_code = hm_mci.behospital_code
  13136. ) t1
  13137. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13138. AND t1.behospital_code = t2.behospital_code
  13139. AND t2.is_deleted = 'N'
  13140. ) t
  13141. WHERE
  13142. 1 = 1
  13143. <if test="qcResultShortPageVO.checkStatus != null">
  13144. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13145. </if>
  13146. <if test="qcResultShortPageVO.mrStatus != null">
  13147. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13148. </if>
  13149. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13150. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13151. </if>
  13152. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13153. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13154. </if>
  13155. <if test="qcResultShortPageVO.chTimeStart != null ">
  13156. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13157. </if>
  13158. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13159. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13160. </if>
  13161. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13162. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13163. </if>
  13164. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13165. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13166. </if>
  13167. </select>
  13168. <!-- 病案首页改善率质控评分页(内页)-科室-->
  13169. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  13170. SELECT
  13171. t.*
  13172. FROM
  13173. (
  13174. SELECT DISTINCT
  13175. t1.hospital_id AS hospitalId,
  13176. t1.behospital_code AS behospitalCode,
  13177. t1.bed_code AS bedCode,
  13178. t1.LEVEL AS LEVEL,
  13179. t1.grade_type AS gradeType,
  13180. t1.score_res AS scoreRes,
  13181. t1.NAME AS NAME,
  13182. t1.sex AS sex,
  13183. t1.beh_dept_id AS behDeptId,
  13184. t1.beh_dept_name AS behDeptName,
  13185. t1.doctor_id AS doctorId,
  13186. t1.doctor_name AS doctorName,
  13187. t1.beh_doctor_id AS behDoctorId,
  13188. t1.beh_doctor_name AS behDoctorName,
  13189. t1.director_doctor_id AS directorDoctorId,
  13190. t1.director_doctor_name AS directorDoctorName,
  13191. t1.birthday AS birthday,
  13192. t1.behospital_date AS behospitalDate,
  13193. t1.leave_hospital_date AS leaveHospitalDate,
  13194. t1.placefile_date AS placefileDate,
  13195. t1.gmt_create AS gradeTime,
  13196. t1.diagnose,
  13197. t1.ward_name AS wardName,
  13198. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  13199. t1.file_code AS fileCode,
  13200. t1.checkStatus,
  13201. t1.mrStatus,
  13202. t1.chName,
  13203. t1.mrName,
  13204. t1.chTime,
  13205. t1.mrTime
  13206. FROM
  13207. (
  13208. SELECT
  13209. be.*,
  13210. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13211. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  13212. mci.check_name AS chName,
  13213. hm_mci.check_name AS mrName,
  13214. mci.gmt_create AS chTime,
  13215. hm_mci.gmt_create AS mrTime
  13216. FROM
  13217. (
  13218. SELECT DISTINCT
  13219. a.hospital_id,
  13220. a.behospital_code,
  13221. a.bed_code,
  13222. a.file_code,
  13223. c.LEVEL,
  13224. c.grade_type,
  13225. c.score_res,
  13226. a.NAME,
  13227. a.sex,
  13228. a.beh_dept_id,
  13229. a.beh_dept_name,
  13230. a.birthday,
  13231. a.behospital_date,
  13232. a.leave_hospital_date,
  13233. a.doctor_id,
  13234. a.doctor_name,
  13235. a.beh_doctor_id,
  13236. a.beh_doctor_name,
  13237. a.director_doctor_id,
  13238. a.director_doctor_name,
  13239. a.diagnose,
  13240. a.placefile_date,
  13241. a.ward_name,
  13242. c.gmt_create
  13243. FROM
  13244. med_behospital_info a,
  13245. med_home_page b,
  13246. med_qcresult_info c,
  13247. med_qcresult_cases d,
  13248. sys_user_dept f,
  13249. (
  13250. SELECT
  13251. m4.*
  13252. FROM
  13253. med_behospital_info m1,
  13254. med_home_page m2,
  13255. med_qcresult_info m3,
  13256. med_qcresult_cases m4
  13257. WHERE
  13258. m1.is_deleted = 'N'
  13259. AND m2.is_deleted = 'N'
  13260. AND m3.is_deleted = 'Y'
  13261. AND m4.is_deleted = 'Y'
  13262. AND m1.hospital_id = m2.hospital_id
  13263. AND m1.hospital_id = m3.hospital_id
  13264. AND m1.hospital_id = m4.hospital_id
  13265. AND m1.behospital_code = m2.behospital_code
  13266. AND m1.behospital_code = m3.behospital_code
  13267. AND m1.behospital_code = m4.behospital_code
  13268. AND m3.gmt_create = m4.gmt_create
  13269. AND m3.have_home_page = 1
  13270. AND m4.cases_id = 243
  13271. AND m1.qc_type_id != 0
  13272. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13273. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13274. </if>
  13275. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13276. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13277. </if>
  13278. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13279. <if test="qcResultShortPageVO.startDate != null ">
  13280. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13281. </if>
  13282. <if test="qcResultShortPageVO.endDate != null ">
  13283. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13284. </if>
  13285. </if>
  13286. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13287. <if test="qcResultShortPageVO.startDate != null">
  13288. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13289. </if>
  13290. <if test="qcResultShortPageVO.endDate != null ">
  13291. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13292. </if>
  13293. </if>
  13294. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13295. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  13296. </if>
  13297. GROUP BY
  13298. m1.behospital_code
  13299. ORDER BY
  13300. m1.behospital_code,
  13301. m4.gmt_create
  13302. ) e
  13303. WHERE
  13304. a.is_deleted = 'N'
  13305. AND b.is_deleted = 'N'
  13306. AND c.is_deleted = 'N'
  13307. AND d.is_deleted = 'N'
  13308. AND f.is_deleted = 'N'
  13309. AND a.hospital_id = b.hospital_id
  13310. AND a.hospital_id = c.hospital_id
  13311. AND a.hospital_id = d.hospital_id
  13312. AND a.hospital_id = f.hospital_id
  13313. AND a.hospital_id = e.hospital_id
  13314. AND a.behospital_code = b.behospital_code
  13315. AND a.behospital_code = c.behospital_code
  13316. AND a.behospital_code = d.behospital_code
  13317. AND a.beh_dept_id = f.dept_id
  13318. AND a.behospital_code = e.behospital_code
  13319. AND d.cases_id = 243
  13320. AND d.score_res > e.score_res
  13321. AND a.qc_type_id != 0
  13322. <if test="qcResultShortPageVO.userId!=null">
  13323. AND f.user_id = #{qcResultShortPageVO.userId}
  13324. </if>
  13325. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13326. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13327. </if>
  13328. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13329. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13330. </if>
  13331. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13332. <if test="qcResultShortPageVO.startDate != null ">
  13333. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13334. </if>
  13335. <if test="qcResultShortPageVO.endDate != null ">
  13336. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13337. </if>
  13338. </if>
  13339. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13340. <if test="qcResultShortPageVO.startDate != null ">
  13341. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13342. </if>
  13343. <if test="qcResultShortPageVO.endDate != null">
  13344. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13345. </if>
  13346. </if>
  13347. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13348. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13349. </if>
  13350. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13351. AND c.`level` = #{qcResultShortPageVO.level}
  13352. </if>
  13353. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13354. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13355. </if>
  13356. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13357. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13358. </if>
  13359. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13360. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13361. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13362. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13363. </if>
  13364. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13365. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13366. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13367. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13368. </if>
  13369. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  13370. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  13371. </if>
  13372. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  13373. AND d.score_res = 20
  13374. </if>
  13375. ) be
  13376. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13377. AND mci.check_type = 0
  13378. AND be.hospital_id = mci.hospital_id
  13379. AND be.behospital_code = mci.behospital_code
  13380. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  13381. AND hm_mci.check_type = 1
  13382. AND be.hospital_id = hm_mci.hospital_id
  13383. AND be.behospital_code = hm_mci.behospital_code
  13384. ) t1
  13385. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13386. AND t1.behospital_code = t2.behospital_code
  13387. AND t2.is_deleted = 'N'
  13388. ) t
  13389. WHERE
  13390. 1 = 1
  13391. <if test="qcResultShortPageVO.checkStatus != null">
  13392. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13393. </if>
  13394. <if test="qcResultShortPageVO.mrStatus != null">
  13395. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13396. </if>
  13397. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13398. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13399. </if>
  13400. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13401. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13402. </if>
  13403. <if test="qcResultShortPageVO.chTimeStart != null ">
  13404. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13405. </if>
  13406. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13407. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13408. </if>
  13409. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13410. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13411. </if>
  13412. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13413. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13414. </if>
  13415. </select>
  13416. <!-- 质控核查质控评分页(内页)-->
  13417. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  13418. SELECT
  13419. t.*
  13420. FROM
  13421. (
  13422. SELECT DISTINCT
  13423. t1.hospital_id AS hospitalId,
  13424. t1.behospital_code AS behospitalCode,
  13425. t1.bed_code AS bedCode,
  13426. t1.LEVEL AS LEVEL,
  13427. t1.grade_type AS gradeType,
  13428. t1.score_res AS scoreRes,
  13429. t1.scoreBn,
  13430. t1.NAME AS NAME,
  13431. t1.sex AS sex,
  13432. t1.beh_dept_id AS behDeptId,
  13433. t1.beh_dept_name AS behDeptName,
  13434. t1.doctor_id AS doctorId,
  13435. t1.doctor_name AS doctorName,
  13436. t1.beh_doctor_id AS behDoctorId,
  13437. t1.beh_doctor_name AS behDoctorName,
  13438. t1.director_doctor_id AS directorDoctorId,
  13439. t1.director_doctor_name AS directorDoctorName,
  13440. t1.birthday AS birthday,
  13441. t1.behospital_date AS behospitalDate,
  13442. t1.leave_hospital_date AS leaveHospitalDate,
  13443. t1.placefile_date AS placefileDate,
  13444. t1.gmt_create AS gradeTime,
  13445. t1.diagnose,
  13446. t1.ward_name AS wardName,
  13447. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  13448. t1.file_code AS fileCode,
  13449. t1.checkStatus,
  13450. t1.mrStatus,
  13451. t1.chName,
  13452. t1.mrName,
  13453. t1.chTime,
  13454. t1.mrTime
  13455. FROM
  13456. (
  13457. SELECT
  13458. be.*,
  13459. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13460. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  13461. mci.check_name AS chName,
  13462. e.score_res as scoreBn,
  13463. hm_mci.check_name AS mrName,
  13464. mci.gmt_create AS chTime,
  13465. hm_mci.gmt_create AS mrTime
  13466. FROM
  13467. (
  13468. SELECT DISTINCT
  13469. a.hospital_id,
  13470. a.behospital_code,
  13471. a.bed_code,
  13472. a.file_code,
  13473. b.LEVEL,
  13474. b.grade_type,
  13475. b.score_res,
  13476. a.NAME,
  13477. a.sex,
  13478. a.beh_dept_id,
  13479. a.beh_dept_name,
  13480. a.birthday,
  13481. a.behospital_date,
  13482. a.leave_hospital_date,
  13483. a.doctor_id,
  13484. a.doctor_name,
  13485. a.beh_doctor_id,
  13486. a.beh_doctor_name,
  13487. a.director_doctor_id,
  13488. a.director_doctor_name,
  13489. a.diagnose,
  13490. a.placefile_date,
  13491. a.ward_name,
  13492. b.gmt_create
  13493. FROM
  13494. med_behospital_info a,
  13495. med_qcresult_info b
  13496. WHERE
  13497. a.is_deleted = 'N'
  13498. AND b.is_deleted = 'N'
  13499. AND a.hospital_id = b.hospital_id
  13500. AND a.behospital_code = b.behospital_code
  13501. AND a.qc_type_id != 0
  13502. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13503. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13504. </if>
  13505. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13506. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13507. </if>
  13508. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13509. <if test="qcResultShortPageVO.startDate != null ">
  13510. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13511. </if>
  13512. <if test="qcResultShortPageVO.endDate != null ">
  13513. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13514. </if>
  13515. </if>
  13516. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13517. <if test="qcResultShortPageVO.startDate != null ">
  13518. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13519. </if>
  13520. <if test="qcResultShortPageVO.endDate != null">
  13521. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13522. </if>
  13523. </if>
  13524. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13525. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13526. </if>
  13527. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13528. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  13529. </if>
  13530. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13531. AND b.`level` = #{qcResultShortPageVO.level}
  13532. </if>
  13533. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13534. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13535. </if>
  13536. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13537. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13538. </if>
  13539. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13540. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13541. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13542. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13543. </if>
  13544. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13545. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13546. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13547. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13548. </if>
  13549. ) be
  13550. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13551. AND mci.check_type = 0
  13552. AND be.hospital_id = mci.hospital_id
  13553. AND be.behospital_code = mci.behospital_code
  13554. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  13555. AND hm_mci.check_type = 1
  13556. AND be.hospital_id = hm_mci.hospital_id
  13557. AND be.behospital_code = hm_mci.behospital_code
  13558. LEFT JOIN med_qcresult_cases e
  13559. on be.behospital_code = e.behospital_code
  13560. and be.hospital_id = e.hospital_id
  13561. AND e.is_deleted = 'N'
  13562. and e.cases_id = 243
  13563. ) t1
  13564. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13565. AND t1.behospital_code = t2.behospital_code
  13566. AND t2.is_deleted = 'N'
  13567. ) t
  13568. WHERE
  13569. 1 = 1
  13570. <if test="qcResultShortPageVO.checkStatus != null">
  13571. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13572. </if>
  13573. <if test="qcResultShortPageVO.mrStatus != null">
  13574. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13575. </if>
  13576. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13577. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13578. </if>
  13579. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13580. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13581. </if>
  13582. <if test="qcResultShortPageVO.chTimeStart != null ">
  13583. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13584. </if>
  13585. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13586. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13587. </if>
  13588. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13589. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13590. </if>
  13591. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13592. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13593. </if>
  13594. </select>
  13595. <!-- 质控核查质控评分页-科室(内页)-->
  13596. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  13597. SELECT
  13598. t.*
  13599. FROM
  13600. (
  13601. SELECT DISTINCT
  13602. t1.hospital_id AS hospitalId,
  13603. t1.behospital_code AS behospitalCode,
  13604. t1.bed_code AS bedCode,
  13605. t1.LEVEL AS LEVEL,
  13606. t1.grade_type AS gradeType,
  13607. t1.score_res AS scoreRes,
  13608. t1.scoreBn,
  13609. t1.NAME AS NAME,
  13610. t1.sex AS sex,
  13611. t1.beh_dept_id AS behDeptId,
  13612. t1.beh_dept_name AS behDeptName,
  13613. t1.doctor_id AS doctorId,
  13614. t1.doctor_name AS doctorName,
  13615. t1.beh_doctor_id AS behDoctorId,
  13616. t1.beh_doctor_name AS behDoctorName,
  13617. t1.director_doctor_id AS directorDoctorId,
  13618. t1.director_doctor_name AS directorDoctorName,
  13619. t1.birthday AS birthday,
  13620. t1.behospital_date AS behospitalDate,
  13621. t1.leave_hospital_date AS leaveHospitalDate,
  13622. t1.placefile_date AS placefileDate,
  13623. t1.gmt_create AS gradeTime,
  13624. t1.diagnose,
  13625. t1.ward_name AS wardName,
  13626. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  13627. t1.file_code AS fileCode,
  13628. t1.checkStatus,
  13629. t1.mrStatus,
  13630. t1.chName,
  13631. t1.mrName,
  13632. t1.chTime,
  13633. t1.mrTime
  13634. FROM
  13635. (
  13636. SELECT
  13637. be.*,
  13638. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13639. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  13640. mci.check_name AS chName,
  13641. e.score_res as scoreBn,
  13642. hm_mci.check_name AS mrName,
  13643. mci.gmt_create AS chTime,
  13644. hm_mci.gmt_create AS mrTime
  13645. FROM
  13646. (
  13647. SELECT DISTINCT
  13648. a.hospital_id,
  13649. a.behospital_code,
  13650. a.bed_code,
  13651. a.file_code,
  13652. b.LEVEL,
  13653. b.grade_type,
  13654. b.score_res,
  13655. a.NAME,
  13656. a.sex,
  13657. a.beh_dept_id,
  13658. a.beh_dept_name,
  13659. a.birthday,
  13660. a.behospital_date,
  13661. a.leave_hospital_date,
  13662. a.doctor_id,
  13663. a.doctor_name,
  13664. a.beh_doctor_id,
  13665. a.beh_doctor_name,
  13666. a.director_doctor_id,
  13667. a.director_doctor_name,
  13668. a.diagnose,
  13669. a.placefile_date,
  13670. a.ward_name,
  13671. b.gmt_create
  13672. FROM
  13673. med_behospital_info a,
  13674. med_qcresult_info b,
  13675. sys_user_dept c
  13676. WHERE
  13677. a.is_deleted = 'N'
  13678. AND b.is_deleted = 'N'
  13679. AND c.is_deleted = 'N'
  13680. AND a.hospital_id = b.hospital_id
  13681. AND a.hospital_id = c.hospital_id
  13682. AND a.beh_dept_id = c.dept_id
  13683. AND a.behospital_code = b.behospital_code
  13684. AND a.qc_type_id != 0
  13685. <if test="qcResultShortPageVO.userId!=null">
  13686. AND c.user_id = #{qcResultShortPageVO.userId}
  13687. </if>
  13688. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13689. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13690. </if>
  13691. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13692. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13693. </if>
  13694. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13695. <if test="qcResultShortPageVO.startDate != null ">
  13696. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13697. </if>
  13698. <if test="qcResultShortPageVO.endDate != null ">
  13699. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13700. </if>
  13701. </if>
  13702. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13703. <if test="qcResultShortPageVO.startDate != null ">
  13704. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13705. </if>
  13706. <if test="qcResultShortPageVO.endDate != null">
  13707. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13708. </if>
  13709. </if>
  13710. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13711. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13712. </if>
  13713. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13714. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  13715. </if>
  13716. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13717. AND b.`level` = #{qcResultShortPageVO.level}
  13718. </if>
  13719. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13720. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13721. </if>
  13722. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13723. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13724. </if>
  13725. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13726. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13727. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13728. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13729. </if>
  13730. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13731. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13732. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13733. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13734. </if>
  13735. ) be
  13736. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13737. AND mci.check_type = 0
  13738. AND be.hospital_id = mci.hospital_id
  13739. AND be.behospital_code = mci.behospital_code
  13740. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  13741. AND hm_mci.check_type = 1
  13742. AND be.hospital_id = hm_mci.hospital_id
  13743. AND be.behospital_code = hm_mci.behospital_code
  13744. LEFT JOIN med_qcresult_cases e
  13745. on be.behospital_code = e.behospital_code
  13746. and be.hospital_id = e.hospital_id
  13747. AND e.is_deleted = 'N'
  13748. and e.cases_id = 243
  13749. ) t1
  13750. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13751. AND t1.behospital_code = t2.behospital_code
  13752. AND t2.is_deleted = 'N'
  13753. ) t
  13754. WHERE
  13755. 1 = 1
  13756. <if test="qcResultShortPageVO.checkStatus != null">
  13757. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13758. </if>
  13759. <if test="qcResultShortPageVO.mrStatus != null">
  13760. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13761. </if>
  13762. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13763. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13764. </if>
  13765. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13766. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13767. </if>
  13768. <if test="qcResultShortPageVO.chTimeStart != null ">
  13769. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13770. </if>
  13771. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13772. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13773. </if>
  13774. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13775. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13776. </if>
  13777. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13778. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13779. </if>
  13780. </select>
  13781. <!-- 病案首页改善率质控评分页导出-->
  13782. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  13783. SELECT
  13784. f1.behDeptId,
  13785. f1.behDeptName,
  13786. f1.behDoctorName,
  13787. f1.patName,
  13788. f1.behospitalCode,
  13789. f1.hospitalId,
  13790. f1.behospitalDate,
  13791. f1.leaveHospitalDate,
  13792. f1.score,
  13793. f2.avgScore,
  13794. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13795. f1.msg,
  13796. f1.caseName,
  13797. </if>
  13798. f1.checkStatus,
  13799. f1.mrStatus,
  13800. f1.chName,
  13801. f1.mrName,
  13802. f1.chTime,
  13803. f1.mrTime
  13804. FROM
  13805. (SELECT
  13806. t.doctorName AS behDoctorName,
  13807. t.`name` AS patName,
  13808. t.behospitalCode AS behospitalCode,
  13809. t.behospitalDate AS behospitalDate,
  13810. t.leaveHospitalDate AS leaveHospitalDate,
  13811. qi.score_res AS score,
  13812. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13813. qd.msg AS msg,
  13814. qc.NAME AS caseName,
  13815. </if>
  13816. t.behDeptId,
  13817. t.behDeptName,
  13818. t.hospitalId,
  13819. t.checkStatus,
  13820. t.mrStatus,
  13821. t.chName,
  13822. t.mrName,
  13823. t.chTime,
  13824. t.mrTime
  13825. FROM
  13826. (
  13827. SELECT DISTINCT
  13828. t1.hospital_id AS hospitalId,
  13829. t1.behospital_code AS behospitalCode,
  13830. t1.bed_code AS bedCode,
  13831. t1.LEVEL AS LEVEL,
  13832. t1.grade_type AS gradeType,
  13833. t1.score_res AS scoreRes,
  13834. t1.NAME AS NAME,
  13835. t1.sex AS sex,
  13836. t1.beh_dept_id AS behDeptId,
  13837. t1.beh_dept_name AS behDeptName,
  13838. t1.doctor_id AS doctorId,
  13839. t1.doctor_name AS doctorName,
  13840. t1.beh_doctor_id AS behDoctorId,
  13841. t1.beh_doctor_name AS behDoctorName,
  13842. t1.director_doctor_id AS directorDoctorId,
  13843. t1.director_doctor_name AS directorDoctorName,
  13844. t1.birthday AS birthday,
  13845. t1.behospital_date AS behospitalDate,
  13846. t1.leave_hospital_date AS leaveHospitalDate,
  13847. t1.placefile_date AS placefileDate,
  13848. t1.gmt_create AS gradeTime,
  13849. t1.diagnose,
  13850. t1.ward_name AS wardName,
  13851. t2.age,
  13852. t1.file_code AS fileCode,
  13853. t1.checkStatus,
  13854. t1.mrStatus,
  13855. t1.chName,
  13856. t1.mrName,
  13857. t1.chTime,
  13858. t1.mrTime
  13859. FROM
  13860. (
  13861. SELECT
  13862. be.*,
  13863. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13864. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  13865. mci.check_name AS chName,
  13866. hm_mci.check_name AS mrName,
  13867. mci.gmt_create AS chTime,
  13868. hm_mci.gmt_create AS mrTime
  13869. FROM
  13870. (
  13871. SELECT DISTINCT
  13872. a.hospital_id,
  13873. a.behospital_code,
  13874. a.bed_code,
  13875. a.file_code,
  13876. c.LEVEL,
  13877. c.grade_type,
  13878. c.score_res,
  13879. a.NAME,
  13880. a.sex,
  13881. a.beh_dept_id,
  13882. a.beh_dept_name,
  13883. a.birthday,
  13884. a.behospital_date,
  13885. a.leave_hospital_date,
  13886. a.doctor_id,
  13887. a.doctor_name,
  13888. a.beh_doctor_id,
  13889. a.beh_doctor_name,
  13890. a.director_doctor_id,
  13891. a.director_doctor_name,
  13892. a.diagnose,
  13893. a.placefile_date,
  13894. a.ward_name,
  13895. c.gmt_create
  13896. FROM
  13897. med_behospital_info a,
  13898. med_home_page b,
  13899. med_qcresult_info c,
  13900. med_qcresult_cases d,
  13901. (
  13902. SELECT
  13903. m4.*
  13904. FROM
  13905. med_behospital_info m1,
  13906. med_home_page m2,
  13907. med_qcresult_info m3,
  13908. med_qcresult_cases m4
  13909. WHERE
  13910. m1.is_deleted = 'N'
  13911. AND m2.is_deleted = 'N'
  13912. AND m3.is_deleted = 'Y'
  13913. AND m4.is_deleted = 'Y'
  13914. AND m1.hospital_id = m2.hospital_id
  13915. AND m1.hospital_id = m3.hospital_id
  13916. AND m1.hospital_id = m4.hospital_id
  13917. AND m1.behospital_code = m2.behospital_code
  13918. AND m1.behospital_code = m3.behospital_code
  13919. AND m1.behospital_code = m4.behospital_code
  13920. AND m3.gmt_create = m4.gmt_create
  13921. AND m3.have_home_page = 1
  13922. AND m4.cases_id = 243
  13923. AND m1.qc_type_id != 0
  13924. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13925. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13926. </if>
  13927. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13928. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13929. </if>
  13930. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13931. <if test="qcResultShortPageVO.startDate != null ">
  13932. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13933. </if>
  13934. <if test="qcResultShortPageVO.endDate != null ">
  13935. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13936. </if>
  13937. </if>
  13938. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13939. <if test="qcResultShortPageVO.startDate != null">
  13940. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13941. </if>
  13942. <if test="qcResultShortPageVO.endDate != null ">
  13943. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13944. </if>
  13945. </if>
  13946. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13947. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  13948. </if>
  13949. GROUP BY
  13950. m1.behospital_code
  13951. ORDER BY
  13952. m1.behospital_code,
  13953. m4.gmt_create
  13954. ) e
  13955. WHERE
  13956. a.is_deleted = 'N'
  13957. AND b.is_deleted = 'N'
  13958. AND c.is_deleted = 'N'
  13959. AND d.is_deleted = 'N'
  13960. AND a.hospital_id = b.hospital_id
  13961. AND a.hospital_id = c.hospital_id
  13962. AND a.hospital_id = d.hospital_id
  13963. AND a.hospital_id = e.hospital_id
  13964. AND a.behospital_code = b.behospital_code
  13965. AND a.behospital_code = c.behospital_code
  13966. AND a.behospital_code = d.behospital_code
  13967. AND a.behospital_code = e.behospital_code
  13968. AND d.cases_id = 243
  13969. AND d.score_res > e.score_res
  13970. AND a.qc_type_id != 0
  13971. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13972. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13973. </if>
  13974. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13975. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13976. </if>
  13977. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13978. <if test="qcResultShortPageVO.startDate != null ">
  13979. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13980. </if>
  13981. <if test="qcResultShortPageVO.endDate != null ">
  13982. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13983. </if>
  13984. </if>
  13985. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13986. <if test="qcResultShortPageVO.startDate != null ">
  13987. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13988. </if>
  13989. <if test="qcResultShortPageVO.endDate != null">
  13990. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13991. </if>
  13992. </if>
  13993. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13994. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13995. </if>
  13996. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13997. AND c.`level` = #{qcResultShortPageVO.level}
  13998. </if>
  13999. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14000. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14001. </if>
  14002. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14003. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14004. </if>
  14005. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14006. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14007. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14008. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14009. </if>
  14010. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14011. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14012. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14013. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14014. </if>
  14015. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  14016. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  14017. </if>
  14018. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  14019. AND d.score_res = 20
  14020. </if>
  14021. ) be
  14022. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14023. AND mci.check_type = 0
  14024. AND be.hospital_id = mci.hospital_id
  14025. AND be.behospital_code = mci.behospital_code
  14026. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14027. AND hm_mci.check_type = 1
  14028. AND be.hospital_id = hm_mci.hospital_id
  14029. AND be.behospital_code = hm_mci.behospital_code
  14030. ) t1
  14031. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14032. AND t1.behospital_code = t2.behospital_code
  14033. AND t2.is_deleted = 'N'
  14034. ) t
  14035. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14036. AND t.hospitalId = qi.hospital_id
  14037. AND t.behospitalCode = qi.behospital_code
  14038. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14039. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14040. AND t.hospitalId = qd.hospital_id
  14041. AND t.behospitalCode = qd.behospital_code
  14042. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14043. AND qd.cases_id = qc.id
  14044. </if>
  14045. where 1=1
  14046. <if test="qcResultShortPageVO.checkStatus != null">
  14047. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14048. </if>
  14049. <if test="qcResultShortPageVO.mrStatus != null">
  14050. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14051. </if>
  14052. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14053. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14054. </if>
  14055. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14056. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14057. </if>
  14058. <if test="qcResultShortPageVO.chTimeStart != null ">
  14059. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14060. </if>
  14061. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14062. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14063. </if>
  14064. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14065. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14066. </if>
  14067. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14068. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14069. </if>
  14070. )f1,
  14071. (SELECT
  14072. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14073. t.behDeptId,
  14074. t.behDeptName
  14075. FROM
  14076. (
  14077. SELECT DISTINCT
  14078. t1.hospital_id AS hospitalId,
  14079. t1.behospital_code AS behospitalCode,
  14080. t1.bed_code AS bedCode,
  14081. t1.LEVEL AS LEVEL,
  14082. t1.grade_type AS gradeType,
  14083. t1.score_res AS scoreRes,
  14084. t1.NAME AS NAME,
  14085. t1.sex AS sex,
  14086. t1.beh_dept_id AS behDeptId,
  14087. t1.beh_dept_name AS behDeptName,
  14088. t1.doctor_id AS doctorId,
  14089. t1.doctor_name AS doctorName,
  14090. t1.beh_doctor_id AS behDoctorId,
  14091. t1.beh_doctor_name AS behDoctorName,
  14092. t1.director_doctor_id AS directorDoctorId,
  14093. t1.director_doctor_name AS directorDoctorName,
  14094. t1.birthday AS birthday,
  14095. t1.behospital_date AS behospitalDate,
  14096. t1.leave_hospital_date AS leaveHospitalDate,
  14097. t1.placefile_date AS placefileDate,
  14098. t1.gmt_create AS gradeTime,
  14099. t1.diagnose,
  14100. t1.ward_name AS wardName,
  14101. t2.age,
  14102. t1.file_code AS fileCode,
  14103. t1.checkStatus,
  14104. t1.mrStatus,
  14105. t1.chName,
  14106. t1.mrName,
  14107. t1.chTime,
  14108. t1.mrTime
  14109. FROM
  14110. (
  14111. SELECT
  14112. be.*,
  14113. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14114. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14115. mci.check_name AS chName,
  14116. hm_mci.check_name AS mrName,
  14117. mci.gmt_create AS chTime,
  14118. hm_mci.gmt_create AS mrTime
  14119. FROM
  14120. (
  14121. SELECT DISTINCT
  14122. a.hospital_id,
  14123. a.behospital_code,
  14124. a.bed_code,
  14125. a.file_code,
  14126. c.LEVEL,
  14127. c.grade_type,
  14128. c.score_res,
  14129. a.NAME,
  14130. a.sex,
  14131. a.beh_dept_id,
  14132. a.beh_dept_name,
  14133. a.birthday,
  14134. a.behospital_date,
  14135. a.leave_hospital_date,
  14136. a.doctor_id,
  14137. a.doctor_name,
  14138. a.beh_doctor_id,
  14139. a.beh_doctor_name,
  14140. a.director_doctor_id,
  14141. a.director_doctor_name,
  14142. a.diagnose,
  14143. a.placefile_date,
  14144. a.ward_name,
  14145. c.gmt_create
  14146. FROM
  14147. med_behospital_info a,
  14148. med_home_page b,
  14149. med_qcresult_info c,
  14150. med_qcresult_cases d,
  14151. (
  14152. SELECT
  14153. m4.*
  14154. FROM
  14155. med_behospital_info m1,
  14156. med_home_page m2,
  14157. med_qcresult_info m3,
  14158. med_qcresult_cases m4
  14159. WHERE
  14160. m1.is_deleted = 'N'
  14161. AND m2.is_deleted = 'N'
  14162. AND m3.is_deleted = 'Y'
  14163. AND m4.is_deleted = 'Y'
  14164. AND m1.hospital_id = m2.hospital_id
  14165. AND m1.hospital_id = m3.hospital_id
  14166. AND m1.hospital_id = m4.hospital_id
  14167. AND m1.behospital_code = m2.behospital_code
  14168. AND m1.behospital_code = m3.behospital_code
  14169. AND m1.behospital_code = m4.behospital_code
  14170. AND m3.gmt_create = m4.gmt_create
  14171. AND m3.have_home_page = 1
  14172. AND m4.cases_id = 243
  14173. AND m1.qc_type_id != 0
  14174. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14175. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14176. </if>
  14177. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14178. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14179. </if>
  14180. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14181. <if test="qcResultShortPageVO.startDate != null ">
  14182. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14183. </if>
  14184. <if test="qcResultShortPageVO.endDate != null ">
  14185. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14186. </if>
  14187. </if>
  14188. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14189. <if test="qcResultShortPageVO.startDate != null">
  14190. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14191. </if>
  14192. <if test="qcResultShortPageVO.endDate != null ">
  14193. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14194. </if>
  14195. </if>
  14196. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14197. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  14198. </if>
  14199. GROUP BY
  14200. m1.behospital_code
  14201. ORDER BY
  14202. m1.behospital_code,
  14203. m4.gmt_create
  14204. ) e
  14205. WHERE
  14206. a.is_deleted = 'N'
  14207. AND b.is_deleted = 'N'
  14208. AND c.is_deleted = 'N'
  14209. AND d.is_deleted = 'N'
  14210. AND a.hospital_id = b.hospital_id
  14211. AND a.hospital_id = c.hospital_id
  14212. AND a.hospital_id = d.hospital_id
  14213. AND a.hospital_id = e.hospital_id
  14214. AND a.behospital_code = b.behospital_code
  14215. AND a.behospital_code = c.behospital_code
  14216. AND a.behospital_code = d.behospital_code
  14217. AND a.behospital_code = e.behospital_code
  14218. AND d.cases_id = 243
  14219. AND d.score_res > e.score_res
  14220. AND a.qc_type_id != 0
  14221. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14222. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14223. </if>
  14224. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14225. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14226. </if>
  14227. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14228. <if test="qcResultShortPageVO.startDate != null ">
  14229. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14230. </if>
  14231. <if test="qcResultShortPageVO.endDate != null ">
  14232. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14233. </if>
  14234. </if>
  14235. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14236. <if test="qcResultShortPageVO.startDate != null ">
  14237. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14238. </if>
  14239. <if test="qcResultShortPageVO.endDate != null">
  14240. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14241. </if>
  14242. </if>
  14243. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14244. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14245. </if>
  14246. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14247. AND c.`level` = #{qcResultShortPageVO.level}
  14248. </if>
  14249. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14250. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14251. </if>
  14252. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14253. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14254. </if>
  14255. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14256. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14257. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14258. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14259. </if>
  14260. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14261. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14262. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14263. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14264. </if>
  14265. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  14266. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  14267. </if>
  14268. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  14269. AND d.score_res = 20
  14270. </if>
  14271. ) be
  14272. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14273. AND mci.check_type = 0
  14274. AND be.hospital_id = mci.hospital_id
  14275. AND be.behospital_code = mci.behospital_code
  14276. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14277. AND hm_mci.check_type = 1
  14278. AND be.hospital_id = hm_mci.hospital_id
  14279. AND be.behospital_code = hm_mci.behospital_code
  14280. ) t1
  14281. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14282. AND t1.behospital_code = t2.behospital_code
  14283. AND t2.is_deleted = 'N'
  14284. ) t
  14285. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14286. AND t.hospitalId = qi.hospital_id
  14287. AND t.behospitalCode = qi.behospital_code
  14288. where 1=1
  14289. <if test="qcResultShortPageVO.checkStatus != null">
  14290. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14291. </if>
  14292. <if test="qcResultShortPageVO.mrStatus != null">
  14293. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14294. </if>
  14295. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14296. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14297. </if>
  14298. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14299. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14300. </if>
  14301. <if test="qcResultShortPageVO.chTimeStart != null ">
  14302. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14303. </if>
  14304. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14305. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14306. </if>
  14307. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14308. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14309. </if>
  14310. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14311. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14312. </if>
  14313. GROUP BY
  14314. t.behDeptId,
  14315. t.behDeptName
  14316. )f2
  14317. WHERE
  14318. f1.behDeptId = f2.behDeptId
  14319. AND f1.behDeptName = f2.behDeptName
  14320. </select>
  14321. <!-- 病案首页改善率质控评分页导出-->
  14322. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  14323. SELECT
  14324. f1.behDeptId,
  14325. f1.behDeptName,
  14326. f1.doctorId,
  14327. f1.doctorName,
  14328. f1.patName,
  14329. f1.behospitalCode,
  14330. f1.hospitalId,
  14331. f1.behospitalDate,
  14332. f1.leaveHospitalDate,
  14333. f1.score,
  14334. f2.avgScore,
  14335. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14336. f1.msg,
  14337. f1.caseName,
  14338. </if>
  14339. f1.checkStatus,
  14340. f1.mrStatus,
  14341. f1.chName,
  14342. f1.mrName,
  14343. f1.chTime,
  14344. f1.mrTime
  14345. FROM
  14346. (SELECT
  14347. t.doctorId,
  14348. t.doctorName,
  14349. t.`name` AS patName,
  14350. t.behospitalCode AS behospitalCode,
  14351. t.behospitalDate AS behospitalDate,
  14352. t.leaveHospitalDate AS leaveHospitalDate,
  14353. qi.score_res AS score,
  14354. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14355. qd.msg AS msg,
  14356. qc.NAME AS caseName,
  14357. </if>
  14358. t.behDeptId,
  14359. t.behDeptName,
  14360. t.hospitalId,
  14361. t.checkStatus,
  14362. t.mrStatus,
  14363. t.chName,
  14364. t.mrName,
  14365. t.chTime,
  14366. t.mrTime
  14367. FROM
  14368. (
  14369. SELECT DISTINCT
  14370. t1.hospital_id AS hospitalId,
  14371. t1.behospital_code AS behospitalCode,
  14372. t1.bed_code AS bedCode,
  14373. t1.LEVEL AS LEVEL,
  14374. t1.grade_type AS gradeType,
  14375. t1.score_res AS scoreRes,
  14376. t1.NAME AS NAME,
  14377. t1.sex AS sex,
  14378. t1.beh_dept_id AS behDeptId,
  14379. t1.beh_dept_name AS behDeptName,
  14380. t1.doctor_id AS doctorId,
  14381. t1.doctor_name AS doctorName,
  14382. t1.beh_doctor_id AS behDoctorId,
  14383. t1.beh_doctor_name AS behDoctorName,
  14384. t1.director_doctor_id AS directorDoctorId,
  14385. t1.director_doctor_name AS directorDoctorName,
  14386. t1.birthday AS birthday,
  14387. t1.behospital_date AS behospitalDate,
  14388. t1.leave_hospital_date AS leaveHospitalDate,
  14389. t1.placefile_date AS placefileDate,
  14390. t1.gmt_create AS gradeTime,
  14391. t1.diagnose,
  14392. t1.ward_name AS wardName,
  14393. t2.age,
  14394. t1.file_code AS fileCode,
  14395. t1.checkStatus,
  14396. t1.mrStatus,
  14397. t1.chName,
  14398. t1.mrName,
  14399. t1.chTime,
  14400. t1.mrTime
  14401. FROM
  14402. (
  14403. SELECT
  14404. be.*,
  14405. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14406. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14407. mci.check_name AS chName,
  14408. hm_mci.check_name AS mrName,
  14409. mci.gmt_create AS chTime,
  14410. hm_mci.gmt_create AS mrTime
  14411. FROM
  14412. (
  14413. SELECT DISTINCT
  14414. a.hospital_id,
  14415. a.behospital_code,
  14416. a.bed_code,
  14417. a.file_code,
  14418. c.LEVEL,
  14419. c.grade_type,
  14420. c.score_res,
  14421. a.NAME,
  14422. a.sex,
  14423. a.beh_dept_id,
  14424. a.beh_dept_name,
  14425. a.birthday,
  14426. a.behospital_date,
  14427. a.leave_hospital_date,
  14428. a.doctor_id,
  14429. a.doctor_name,
  14430. a.beh_doctor_id,
  14431. a.beh_doctor_name,
  14432. a.director_doctor_id,
  14433. a.director_doctor_name,
  14434. a.diagnose,
  14435. a.placefile_date,
  14436. a.ward_name,
  14437. c.gmt_create
  14438. FROM
  14439. med_behospital_info a,
  14440. med_home_page b,
  14441. med_qcresult_info c,
  14442. med_qcresult_cases d,
  14443. sys_user_dept f,
  14444. (
  14445. SELECT
  14446. m4.*
  14447. FROM
  14448. med_behospital_info m1,
  14449. med_home_page m2,
  14450. med_qcresult_info m3,
  14451. med_qcresult_cases m4
  14452. WHERE
  14453. m1.is_deleted = 'N'
  14454. AND m2.is_deleted = 'N'
  14455. AND m3.is_deleted = 'Y'
  14456. AND m4.is_deleted = 'Y'
  14457. AND m1.hospital_id = m2.hospital_id
  14458. AND m1.hospital_id = m3.hospital_id
  14459. AND m1.hospital_id = m4.hospital_id
  14460. AND m1.behospital_code = m2.behospital_code
  14461. AND m1.behospital_code = m3.behospital_code
  14462. AND m1.behospital_code = m4.behospital_code
  14463. AND m3.gmt_create = m4.gmt_create
  14464. AND m3.have_home_page = 1
  14465. AND m4.cases_id = 243
  14466. AND m1.qc_type_id != 0
  14467. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14468. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14469. </if>
  14470. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14471. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14472. </if>
  14473. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14474. <if test="qcResultShortPageVO.startDate != null ">
  14475. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14476. </if>
  14477. <if test="qcResultShortPageVO.endDate != null ">
  14478. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14479. </if>
  14480. </if>
  14481. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14482. <if test="qcResultShortPageVO.startDate != null">
  14483. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14484. </if>
  14485. <if test="qcResultShortPageVO.endDate != null ">
  14486. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14487. </if>
  14488. </if>
  14489. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14490. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  14491. </if>
  14492. GROUP BY
  14493. m1.behospital_code
  14494. ORDER BY
  14495. m1.behospital_code,
  14496. m4.gmt_create
  14497. ) e
  14498. WHERE
  14499. a.is_deleted = 'N'
  14500. AND b.is_deleted = 'N'
  14501. AND c.is_deleted = 'N'
  14502. AND d.is_deleted = 'N'
  14503. AND f.is_deleted = 'N'
  14504. AND a.hospital_id = b.hospital_id
  14505. AND a.hospital_id = c.hospital_id
  14506. AND a.hospital_id = d.hospital_id
  14507. AND a.hospital_id = e.hospital_id
  14508. AND a.hospital_id = f.hospital_id
  14509. AND a.behospital_code = b.behospital_code
  14510. AND a.behospital_code = c.behospital_code
  14511. AND a.behospital_code = d.behospital_code
  14512. AND a.behospital_code = e.behospital_code
  14513. AND a.beh_dept_id = f.dept_id
  14514. AND d.cases_id = 243
  14515. AND d.score_res > e.score_res
  14516. AND a.qc_type_id != 0
  14517. <if test="qcResultShortPageVO.userId!=null">
  14518. AND f.user_id = #{qcResultShortPageVO.userId}
  14519. </if>
  14520. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14521. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14522. </if>
  14523. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14524. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14525. </if>
  14526. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14527. <if test="qcResultShortPageVO.startDate != null ">
  14528. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14529. </if>
  14530. <if test="qcResultShortPageVO.endDate != null ">
  14531. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14532. </if>
  14533. </if>
  14534. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14535. <if test="qcResultShortPageVO.startDate != null ">
  14536. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14537. </if>
  14538. <if test="qcResultShortPageVO.endDate != null">
  14539. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14540. </if>
  14541. </if>
  14542. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14543. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14544. </if>
  14545. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14546. AND c.`level` = #{qcResultShortPageVO.level}
  14547. </if>
  14548. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14549. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14550. </if>
  14551. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14552. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14553. </if>
  14554. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14555. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14556. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14557. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14558. </if>
  14559. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14560. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14561. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14562. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14563. </if>
  14564. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  14565. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  14566. </if>
  14567. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  14568. AND d.score_res = 20
  14569. </if>
  14570. ) be
  14571. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14572. AND mci.check_type = 0
  14573. AND be.hospital_id = mci.hospital_id
  14574. AND be.behospital_code = mci.behospital_code
  14575. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14576. AND hm_mci.check_type = 1
  14577. AND be.hospital_id = hm_mci.hospital_id
  14578. AND be.behospital_code = hm_mci.behospital_code
  14579. ) t1
  14580. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14581. AND t1.behospital_code = t2.behospital_code
  14582. AND t2.is_deleted = 'N'
  14583. ) t
  14584. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14585. AND t.hospitalId = qi.hospital_id
  14586. AND t.behospitalCode = qi.behospital_code
  14587. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14588. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14589. AND t.hospitalId = qd.hospital_id
  14590. AND t.behospitalCode = qd.behospital_code
  14591. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14592. AND qd.cases_id = qc.id
  14593. </if>
  14594. where 1=1
  14595. <if test="qcResultShortPageVO.checkStatus != null">
  14596. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14597. </if>
  14598. <if test="qcResultShortPageVO.mrStatus != null">
  14599. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14600. </if>
  14601. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14602. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14603. </if>
  14604. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14605. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14606. </if>
  14607. <if test="qcResultShortPageVO.chTimeStart != null ">
  14608. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14609. </if>
  14610. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14611. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14612. </if>
  14613. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14614. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14615. </if>
  14616. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14617. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14618. </if>
  14619. )f1,
  14620. (SELECT
  14621. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14622. t.behDeptId,
  14623. t.behDeptName,
  14624. t.doctorId,
  14625. t.doctorName
  14626. FROM
  14627. (
  14628. SELECT DISTINCT
  14629. t1.hospital_id AS hospitalId,
  14630. t1.behospital_code AS behospitalCode,
  14631. t1.bed_code AS bedCode,
  14632. t1.LEVEL AS LEVEL,
  14633. t1.grade_type AS gradeType,
  14634. t1.score_res AS scoreRes,
  14635. t1.NAME AS NAME,
  14636. t1.sex AS sex,
  14637. t1.beh_dept_id AS behDeptId,
  14638. t1.beh_dept_name AS behDeptName,
  14639. t1.doctor_id AS doctorId,
  14640. t1.doctor_name AS doctorName,
  14641. t1.beh_doctor_id AS behDoctorId,
  14642. t1.beh_doctor_name AS behDoctorName,
  14643. t1.director_doctor_id AS directorDoctorId,
  14644. t1.director_doctor_name AS directorDoctorName,
  14645. t1.birthday AS birthday,
  14646. t1.behospital_date AS behospitalDate,
  14647. t1.leave_hospital_date AS leaveHospitalDate,
  14648. t1.placefile_date AS placefileDate,
  14649. t1.gmt_create AS gradeTime,
  14650. t1.diagnose,
  14651. t1.ward_name AS wardName,
  14652. t2.age,
  14653. t1.file_code AS fileCode,
  14654. t1.checkStatus,
  14655. t1.mrStatus,
  14656. t1.chName,
  14657. t1.mrName,
  14658. t1.chTime,
  14659. t1.mrTime
  14660. FROM
  14661. (
  14662. SELECT
  14663. be.*,
  14664. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14665. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14666. mci.check_name AS chName,
  14667. hm_mci.check_name AS mrName,
  14668. mci.gmt_create AS chTime,
  14669. hm_mci.gmt_create AS mrTime
  14670. FROM
  14671. (
  14672. SELECT DISTINCT
  14673. a.hospital_id,
  14674. a.behospital_code,
  14675. a.bed_code,
  14676. a.file_code,
  14677. c.LEVEL,
  14678. c.grade_type,
  14679. c.score_res,
  14680. a.NAME,
  14681. a.sex,
  14682. a.beh_dept_id,
  14683. a.beh_dept_name,
  14684. a.birthday,
  14685. a.behospital_date,
  14686. a.leave_hospital_date,
  14687. a.doctor_id,
  14688. a.doctor_name,
  14689. a.beh_doctor_id,
  14690. a.beh_doctor_name,
  14691. a.director_doctor_id,
  14692. a.director_doctor_name,
  14693. a.diagnose,
  14694. a.placefile_date,
  14695. a.ward_name,
  14696. c.gmt_create
  14697. FROM
  14698. med_behospital_info a,
  14699. med_home_page b,
  14700. med_qcresult_info c,
  14701. med_qcresult_cases d,
  14702. sys_user_dept f,
  14703. (
  14704. SELECT
  14705. m4.*
  14706. FROM
  14707. med_behospital_info m1,
  14708. med_home_page m2,
  14709. med_qcresult_info m3,
  14710. med_qcresult_cases m4
  14711. WHERE
  14712. m1.is_deleted = 'N'
  14713. AND m2.is_deleted = 'N'
  14714. AND m3.is_deleted = 'Y'
  14715. AND m4.is_deleted = 'Y'
  14716. AND m1.hospital_id = m2.hospital_id
  14717. AND m1.hospital_id = m3.hospital_id
  14718. AND m1.hospital_id = m4.hospital_id
  14719. AND m1.behospital_code = m2.behospital_code
  14720. AND m1.behospital_code = m3.behospital_code
  14721. AND m1.behospital_code = m4.behospital_code
  14722. AND m3.gmt_create = m4.gmt_create
  14723. AND m3.have_home_page = 1
  14724. AND m4.cases_id = 243
  14725. AND m1.qc_type_id != 0
  14726. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14727. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14728. </if>
  14729. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14730. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14731. </if>
  14732. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14733. <if test="qcResultShortPageVO.startDate != null ">
  14734. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14735. </if>
  14736. <if test="qcResultShortPageVO.endDate != null ">
  14737. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14738. </if>
  14739. </if>
  14740. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14741. <if test="qcResultShortPageVO.startDate != null">
  14742. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14743. </if>
  14744. <if test="qcResultShortPageVO.endDate != null ">
  14745. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14746. </if>
  14747. </if>
  14748. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14749. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  14750. </if>
  14751. GROUP BY
  14752. m1.behospital_code
  14753. ORDER BY
  14754. m1.behospital_code,
  14755. m4.gmt_create
  14756. ) e
  14757. WHERE
  14758. a.is_deleted = 'N'
  14759. AND b.is_deleted = 'N'
  14760. AND c.is_deleted = 'N'
  14761. AND d.is_deleted = 'N'
  14762. AND f.is_deleted = 'N'
  14763. AND a.hospital_id = b.hospital_id
  14764. AND a.hospital_id = c.hospital_id
  14765. AND a.hospital_id = d.hospital_id
  14766. AND a.hospital_id = e.hospital_id
  14767. AND a.hospital_id = f.hospital_id
  14768. AND a.behospital_code = b.behospital_code
  14769. AND a.behospital_code = c.behospital_code
  14770. AND a.behospital_code = d.behospital_code
  14771. AND a.behospital_code = e.behospital_code
  14772. AND a.beh_dept_id = f.dept_id
  14773. AND d.cases_id = 243
  14774. AND d.score_res > e.score_res
  14775. AND a.qc_type_id != 0
  14776. <if test="qcResultShortPageVO.userId!=null">
  14777. AND f.user_id = #{qcResultShortPageVO.userId}
  14778. </if>
  14779. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14780. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14781. </if>
  14782. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14783. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14784. </if>
  14785. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14786. <if test="qcResultShortPageVO.startDate != null ">
  14787. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14788. </if>
  14789. <if test="qcResultShortPageVO.endDate != null ">
  14790. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14791. </if>
  14792. </if>
  14793. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14794. <if test="qcResultShortPageVO.startDate != null ">
  14795. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14796. </if>
  14797. <if test="qcResultShortPageVO.endDate != null">
  14798. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14799. </if>
  14800. </if>
  14801. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14802. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14803. </if>
  14804. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14805. AND c.`level` = #{qcResultShortPageVO.level}
  14806. </if>
  14807. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14808. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14809. </if>
  14810. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14811. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14812. </if>
  14813. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14814. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14815. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14816. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14817. </if>
  14818. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14819. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14820. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14821. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14822. </if>
  14823. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  14824. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  14825. </if>
  14826. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  14827. AND d.score_res = 20
  14828. </if>
  14829. ) be
  14830. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14831. AND mci.check_type = 0
  14832. AND be.hospital_id = mci.hospital_id
  14833. AND be.behospital_code = mci.behospital_code
  14834. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14835. AND hm_mci.check_type = 1
  14836. AND be.hospital_id = hm_mci.hospital_id
  14837. AND be.behospital_code = hm_mci.behospital_code
  14838. ) t1
  14839. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14840. AND t1.behospital_code = t2.behospital_code
  14841. AND t2.is_deleted = 'N'
  14842. ) t
  14843. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14844. AND t.hospitalId = qi.hospital_id
  14845. AND t.behospitalCode = qi.behospital_code
  14846. where 1=1
  14847. <if test="qcResultShortPageVO.checkStatus != null">
  14848. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14849. </if>
  14850. <if test="qcResultShortPageVO.mrStatus != null">
  14851. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14852. </if>
  14853. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14854. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14855. </if>
  14856. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14857. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14858. </if>
  14859. <if test="qcResultShortPageVO.chTimeStart != null ">
  14860. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14861. </if>
  14862. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14863. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14864. </if>
  14865. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14866. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14867. </if>
  14868. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14869. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14870. </if>
  14871. GROUP BY
  14872. t.doctorId,
  14873. t.doctorName
  14874. )f2
  14875. WHERE
  14876. f1.doctorId = f2.doctorId
  14877. AND f1.doctorName = f2.doctorName
  14878. </select>
  14879. <!-- 质控核查质控评分页导出-->
  14880. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  14881. SELECT
  14882. f1.behDeptId,
  14883. f1.behDeptName,
  14884. f1.behDoctorName,
  14885. f1.patName,
  14886. f1.behospitalCode,
  14887. f1.hospitalId,
  14888. f1.behospitalDate,
  14889. f1.leaveHospitalDate,
  14890. f1.score,
  14891. f1.scoreBn,
  14892. f2.avgScore,
  14893. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14894. f1.msg,
  14895. f1.caseName,
  14896. </if>
  14897. f1.checkStatus,
  14898. f1.mrStatus,
  14899. f1.chName,
  14900. f1.mrName,
  14901. f1.chTime,
  14902. f1.mrTime
  14903. FROM
  14904. (SELECT
  14905. t.doctorName AS behDoctorName,
  14906. t.`name` AS patName,
  14907. t.behospitalCode AS behospitalCode,
  14908. t.behospitalDate AS behospitalDate,
  14909. t.leaveHospitalDate AS leaveHospitalDate,
  14910. qi.score_res AS score,
  14911. t.scoreBn,
  14912. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14913. qd.msg AS msg,
  14914. qc.NAME AS caseName,
  14915. </if>
  14916. t.behDeptId,
  14917. t.behDeptName,
  14918. t.hospitalId,
  14919. t.checkStatus,
  14920. t.mrStatus,
  14921. t.chName,
  14922. t.mrName,
  14923. t.chTime,
  14924. t.mrTime
  14925. FROM
  14926. (
  14927. SELECT DISTINCT
  14928. t1.hospital_id AS hospitalId,
  14929. t1.behospital_code AS behospitalCode,
  14930. t1.bed_code AS bedCode,
  14931. t1.LEVEL AS LEVEL,
  14932. t1.grade_type AS gradeType,
  14933. t1.score_res AS scoreRes,
  14934. t1.scoreBn,
  14935. t1.NAME AS NAME,
  14936. t1.sex AS sex,
  14937. t1.beh_dept_id AS behDeptId,
  14938. t1.beh_dept_name AS behDeptName,
  14939. t1.doctor_id AS doctorId,
  14940. t1.doctor_name AS doctorName,
  14941. t1.beh_doctor_id AS behDoctorId,
  14942. t1.beh_doctor_name AS behDoctorName,
  14943. t1.director_doctor_id AS directorDoctorId,
  14944. t1.director_doctor_name AS directorDoctorName,
  14945. t1.birthday AS birthday,
  14946. t1.behospital_date AS behospitalDate,
  14947. t1.leave_hospital_date AS leaveHospitalDate,
  14948. t1.placefile_date AS placefileDate,
  14949. t1.gmt_create AS gradeTime,
  14950. t1.diagnose,
  14951. t1.ward_name AS wardName,
  14952. t2.age,
  14953. t1.file_code AS fileCode,
  14954. t1.checkStatus,
  14955. t1.mrStatus,
  14956. t1.chName,
  14957. t1.mrName,
  14958. t1.chTime,
  14959. t1.mrTime
  14960. FROM
  14961. (
  14962. SELECT
  14963. be.*,
  14964. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14965. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14966. mci.check_name AS chName,
  14967. e.score_res as scoreBn,
  14968. hm_mci.check_name AS mrName,
  14969. mci.gmt_create AS chTime,
  14970. hm_mci.gmt_create AS mrTime
  14971. FROM
  14972. (
  14973. SELECT DISTINCT
  14974. a.hospital_id,
  14975. a.behospital_code,
  14976. a.bed_code,
  14977. a.file_code,
  14978. b.LEVEL,
  14979. b.grade_type,
  14980. b.score_res,
  14981. a.NAME,
  14982. a.sex,
  14983. a.beh_dept_id,
  14984. a.beh_dept_name,
  14985. a.birthday,
  14986. a.behospital_date,
  14987. a.leave_hospital_date,
  14988. a.doctor_id,
  14989. a.doctor_name,
  14990. a.beh_doctor_id,
  14991. a.beh_doctor_name,
  14992. a.director_doctor_id,
  14993. a.director_doctor_name,
  14994. a.diagnose,
  14995. a.placefile_date,
  14996. a.ward_name,
  14997. b.gmt_create
  14998. FROM
  14999. med_behospital_info a,
  15000. med_qcresult_info b
  15001. WHERE
  15002. a.is_deleted = 'N'
  15003. AND b.is_deleted = 'N'
  15004. AND a.hospital_id = b.hospital_id
  15005. AND a.behospital_code = b.behospital_code
  15006. AND a.qc_type_id != 0
  15007. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15008. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15009. </if>
  15010. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15011. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15012. </if>
  15013. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15014. <if test="qcResultShortPageVO.startDate != null ">
  15015. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15016. </if>
  15017. <if test="qcResultShortPageVO.endDate != null ">
  15018. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15019. </if>
  15020. </if>
  15021. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15022. <if test="qcResultShortPageVO.startDate != null ">
  15023. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15024. </if>
  15025. <if test="qcResultShortPageVO.endDate != null">
  15026. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15027. </if>
  15028. </if>
  15029. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15030. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15031. </if>
  15032. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15033. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  15034. </if>
  15035. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15036. AND c.`level` = #{qcResultShortPageVO.level}
  15037. </if>
  15038. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15039. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15040. </if>
  15041. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15042. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15043. </if>
  15044. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15045. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15046. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15047. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15048. </if>
  15049. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15050. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15051. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15052. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15053. </if>
  15054. ) be
  15055. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15056. AND mci.check_type = 0
  15057. AND be.hospital_id = mci.hospital_id
  15058. AND be.behospital_code = mci.behospital_code
  15059. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15060. AND hm_mci.check_type = 1
  15061. AND be.hospital_id = hm_mci.hospital_id
  15062. AND be.behospital_code = hm_mci.behospital_code
  15063. LEFT JOIN med_qcresult_cases e
  15064. on be.behospital_code = e.behospital_code
  15065. and be.hospital_id = e.hospital_id
  15066. AND e.is_deleted = 'N'
  15067. and e.cases_id = 243
  15068. ) t1
  15069. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15070. AND t1.behospital_code = t2.behospital_code
  15071. AND t2.is_deleted = 'N'
  15072. ) t
  15073. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15074. AND t.hospitalId = qi.hospital_id
  15075. AND t.behospitalCode = qi.behospital_code
  15076. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15077. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15078. AND t.hospitalId = qd.hospital_id
  15079. AND t.behospitalCode = qd.behospital_code
  15080. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15081. AND qd.cases_id = qc.id
  15082. </if>
  15083. where 1=1
  15084. <if test="qcResultShortPageVO.checkStatus != null">
  15085. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15086. </if>
  15087. <if test="qcResultShortPageVO.mrStatus != null">
  15088. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15089. </if>
  15090. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15091. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15092. </if>
  15093. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15094. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15095. </if>
  15096. <if test="qcResultShortPageVO.chTimeStart != null ">
  15097. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15098. </if>
  15099. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15100. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15101. </if>
  15102. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15103. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15104. </if>
  15105. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15106. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15107. </if>
  15108. )f1,
  15109. (SELECT
  15110. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15111. t.behDeptId,
  15112. t.behDeptName
  15113. FROM
  15114. (
  15115. SELECT DISTINCT
  15116. t1.hospital_id AS hospitalId,
  15117. t1.behospital_code AS behospitalCode,
  15118. t1.bed_code AS bedCode,
  15119. t1.LEVEL AS LEVEL,
  15120. t1.grade_type AS gradeType,
  15121. t1.score_res AS scoreRes,
  15122. t1.NAME AS NAME,
  15123. t1.sex AS sex,
  15124. t1.beh_dept_id AS behDeptId,
  15125. t1.beh_dept_name AS behDeptName,
  15126. t1.doctor_id AS doctorId,
  15127. t1.doctor_name AS doctorName,
  15128. t1.beh_doctor_id AS behDoctorId,
  15129. t1.beh_doctor_name AS behDoctorName,
  15130. t1.director_doctor_id AS directorDoctorId,
  15131. t1.director_doctor_name AS directorDoctorName,
  15132. t1.birthday AS birthday,
  15133. t1.behospital_date AS behospitalDate,
  15134. t1.leave_hospital_date AS leaveHospitalDate,
  15135. t1.placefile_date AS placefileDate,
  15136. t1.gmt_create AS gradeTime,
  15137. t1.diagnose,
  15138. t1.ward_name AS wardName,
  15139. t2.age,
  15140. t1.file_code AS fileCode,
  15141. t1.checkStatus,
  15142. t1.mrStatus,
  15143. t1.chName,
  15144. t1.mrName,
  15145. t1.chTime,
  15146. t1.mrTime
  15147. FROM
  15148. (
  15149. SELECT
  15150. be.*,
  15151. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15152. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15153. mci.check_name AS chName,
  15154. hm_mci.check_name AS mrName,
  15155. mci.gmt_create AS chTime,
  15156. hm_mci.gmt_create AS mrTime
  15157. FROM
  15158. (
  15159. SELECT DISTINCT
  15160. a.hospital_id,
  15161. a.behospital_code,
  15162. a.bed_code,
  15163. a.file_code,
  15164. b.LEVEL,
  15165. b.grade_type,
  15166. b.score_res,
  15167. a.NAME,
  15168. a.sex,
  15169. a.beh_dept_id,
  15170. a.beh_dept_name,
  15171. a.birthday,
  15172. a.behospital_date,
  15173. a.leave_hospital_date,
  15174. a.doctor_id,
  15175. a.doctor_name,
  15176. a.beh_doctor_id,
  15177. a.beh_doctor_name,
  15178. a.director_doctor_id,
  15179. a.director_doctor_name,
  15180. a.diagnose,
  15181. a.placefile_date,
  15182. a.ward_name,
  15183. b.gmt_create
  15184. FROM
  15185. med_behospital_info a,
  15186. med_qcresult_info b
  15187. WHERE
  15188. a.is_deleted = 'N'
  15189. AND b.is_deleted = 'N'
  15190. AND a.hospital_id = b.hospital_id
  15191. AND a.behospital_code = b.behospital_code
  15192. AND a.qc_type_id != 0
  15193. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15194. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15195. </if>
  15196. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15197. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15198. </if>
  15199. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15200. <if test="qcResultShortPageVO.startDate != null ">
  15201. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15202. </if>
  15203. <if test="qcResultShortPageVO.endDate != null ">
  15204. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15205. </if>
  15206. </if>
  15207. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15208. <if test="qcResultShortPageVO.startDate != null ">
  15209. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15210. </if>
  15211. <if test="qcResultShortPageVO.endDate != null">
  15212. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15213. </if>
  15214. </if>
  15215. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15216. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15217. </if>
  15218. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15219. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  15220. </if>
  15221. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15222. AND c.`level` = #{qcResultShortPageVO.level}
  15223. </if>
  15224. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15225. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15226. </if>
  15227. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15228. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15229. </if>
  15230. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15231. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15232. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15233. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15234. </if>
  15235. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15236. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15237. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15238. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15239. </if>
  15240. ) be
  15241. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15242. AND mci.check_type = 0
  15243. AND be.hospital_id = mci.hospital_id
  15244. AND be.behospital_code = mci.behospital_code
  15245. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15246. AND hm_mci.check_type = 1
  15247. AND be.hospital_id = hm_mci.hospital_id
  15248. AND be.behospital_code = hm_mci.behospital_code
  15249. ) t1
  15250. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15251. AND t1.behospital_code = t2.behospital_code
  15252. AND t2.is_deleted = 'N'
  15253. ) t
  15254. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15255. AND t.hospitalId = qi.hospital_id
  15256. AND t.behospitalCode = qi.behospital_code
  15257. where 1=1
  15258. <if test="qcResultShortPageVO.checkStatus != null">
  15259. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15260. </if>
  15261. <if test="qcResultShortPageVO.mrStatus != null">
  15262. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15263. </if>
  15264. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15265. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15266. </if>
  15267. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15268. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15269. </if>
  15270. <if test="qcResultShortPageVO.chTimeStart != null ">
  15271. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15272. </if>
  15273. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15274. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15275. </if>
  15276. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15277. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15278. </if>
  15279. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15280. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15281. </if>
  15282. GROUP BY
  15283. t.behDeptId,
  15284. t.behDeptName
  15285. )f2
  15286. WHERE
  15287. f1.behDeptId = f2.behDeptId
  15288. AND f1.behDeptName = f2.behDeptName
  15289. </select>
  15290. <!-- 质控核查质控评分页导出 -科室-->
  15291. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  15292. SELECT
  15293. f1.behDeptId,
  15294. f1.behDeptName,
  15295. f1.doctorName AS behDoctorName,
  15296. f1.doctorId,
  15297. f1.patName,
  15298. f1.behospitalCode,
  15299. f1.hospitalId,
  15300. f1.behospitalDate,
  15301. f1.leaveHospitalDate,
  15302. f1.score,
  15303. f1.scoreBn,
  15304. f2.avgScore,
  15305. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15306. f1.msg,
  15307. f1.caseName,
  15308. </if>
  15309. f1.checkStatus,
  15310. f1.mrStatus,
  15311. f1.chName,
  15312. f1.mrName,
  15313. f1.chTime,
  15314. f1.mrTime
  15315. FROM
  15316. (SELECT
  15317. t.doctorName,
  15318. t.doctorId,
  15319. t.`name` AS patName,
  15320. t.behospitalCode AS behospitalCode,
  15321. t.behospitalDate AS behospitalDate,
  15322. t.leaveHospitalDate AS leaveHospitalDate,
  15323. qi.score_res AS score,
  15324. t.scoreBn,
  15325. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15326. qd.msg AS msg,
  15327. qc.NAME AS caseName,
  15328. </if>
  15329. t.behDeptId,
  15330. t.behDeptName,
  15331. t.hospitalId,
  15332. t.checkStatus,
  15333. t.mrStatus,
  15334. t.chName,
  15335. t.mrName,
  15336. t.chTime,
  15337. t.mrTime
  15338. FROM
  15339. (
  15340. SELECT DISTINCT
  15341. t1.hospital_id AS hospitalId,
  15342. t1.behospital_code AS behospitalCode,
  15343. t1.bed_code AS bedCode,
  15344. t1.LEVEL AS LEVEL,
  15345. t1.grade_type AS gradeType,
  15346. t1.score_res AS scoreRes,
  15347. t1.scoreBn,
  15348. t1.NAME AS NAME,
  15349. t1.sex AS sex,
  15350. t1.beh_dept_id AS behDeptId,
  15351. t1.beh_dept_name AS behDeptName,
  15352. t1.doctor_id AS doctorId,
  15353. t1.doctor_name AS doctorName,
  15354. t1.beh_doctor_id AS behDoctorId,
  15355. t1.beh_doctor_name AS behDoctorName,
  15356. t1.director_doctor_id AS directorDoctorId,
  15357. t1.director_doctor_name AS directorDoctorName,
  15358. t1.birthday AS birthday,
  15359. t1.behospital_date AS behospitalDate,
  15360. t1.leave_hospital_date AS leaveHospitalDate,
  15361. t1.placefile_date AS placefileDate,
  15362. t1.gmt_create AS gradeTime,
  15363. t1.diagnose,
  15364. t1.ward_name AS wardName,
  15365. t2.age,
  15366. t1.file_code AS fileCode,
  15367. t1.checkStatus,
  15368. t1.mrStatus,
  15369. t1.chName,
  15370. t1.mrName,
  15371. t1.chTime,
  15372. t1.mrTime
  15373. FROM
  15374. (
  15375. SELECT
  15376. be.*,
  15377. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15378. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15379. mci.check_name AS chName,
  15380. e.score_res as scoreBn,
  15381. hm_mci.check_name AS mrName,
  15382. mci.gmt_create AS chTime,
  15383. hm_mci.gmt_create AS mrTime
  15384. FROM
  15385. (
  15386. SELECT DISTINCT
  15387. a.hospital_id,
  15388. a.behospital_code,
  15389. a.bed_code,
  15390. a.file_code,
  15391. b.LEVEL,
  15392. b.grade_type,
  15393. b.score_res,
  15394. a.NAME,
  15395. a.sex,
  15396. a.beh_dept_id,
  15397. a.beh_dept_name,
  15398. a.birthday,
  15399. a.behospital_date,
  15400. a.leave_hospital_date,
  15401. a.doctor_id,
  15402. a.doctor_name,
  15403. a.beh_doctor_id,
  15404. a.beh_doctor_name,
  15405. a.director_doctor_id,
  15406. a.director_doctor_name,
  15407. a.diagnose,
  15408. a.placefile_date,
  15409. a.ward_name,
  15410. b.gmt_create
  15411. FROM
  15412. med_behospital_info a,
  15413. med_qcresult_info b,
  15414. sys_user_dept c
  15415. WHERE
  15416. a.is_deleted = 'N'
  15417. AND b.is_deleted = 'N'
  15418. AND c.is_deleted = 'N'
  15419. AND a.hospital_id = b.hospital_id
  15420. AND a.hospital_id = c.hospital_id
  15421. AND a.behospital_code = b.behospital_code
  15422. AND a.beh_dept_id = c.dept_id
  15423. AND a.qc_type_id != 0
  15424. <if test="qcResultShortPageVO.userId!=null">
  15425. AND c.user_id = #{qcResultShortPageVO.userId}
  15426. </if>
  15427. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15428. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15429. </if>
  15430. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15431. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15432. </if>
  15433. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15434. <if test="qcResultShortPageVO.startDate != null ">
  15435. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15436. </if>
  15437. <if test="qcResultShortPageVO.endDate != null ">
  15438. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15439. </if>
  15440. </if>
  15441. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15442. <if test="qcResultShortPageVO.startDate != null ">
  15443. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15444. </if>
  15445. <if test="qcResultShortPageVO.endDate != null">
  15446. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15447. </if>
  15448. </if>
  15449. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15450. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15451. </if>
  15452. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15453. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  15454. </if>
  15455. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15456. AND c.`level` = #{qcResultShortPageVO.level}
  15457. </if>
  15458. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15459. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15460. </if>
  15461. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15462. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15463. </if>
  15464. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15465. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15466. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15467. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15468. </if>
  15469. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15470. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15471. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15472. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15473. </if>
  15474. ) be
  15475. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15476. AND mci.check_type = 0
  15477. AND be.hospital_id = mci.hospital_id
  15478. AND be.behospital_code = mci.behospital_code
  15479. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15480. AND hm_mci.check_type = 1
  15481. AND be.hospital_id = hm_mci.hospital_id
  15482. AND be.behospital_code = hm_mci.behospital_code
  15483. LEFT JOIN med_qcresult_cases e
  15484. on be.behospital_code = e.behospital_code
  15485. and be.hospital_id = e.hospital_id
  15486. AND e.is_deleted = 'N'
  15487. and e.cases_id = 243
  15488. ) t1
  15489. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15490. AND t1.behospital_code = t2.behospital_code
  15491. AND t2.is_deleted = 'N'
  15492. ) t
  15493. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15494. AND t.hospitalId = qi.hospital_id
  15495. AND t.behospitalCode = qi.behospital_code
  15496. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15497. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15498. AND t.hospitalId = qd.hospital_id
  15499. AND t.behospitalCode = qd.behospital_code
  15500. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15501. AND qd.cases_id = qc.id
  15502. </if>
  15503. where 1=1
  15504. <if test="qcResultShortPageVO.checkStatus != null">
  15505. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15506. </if>
  15507. <if test="qcResultShortPageVO.mrStatus != null">
  15508. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15509. </if>
  15510. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15511. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15512. </if>
  15513. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15514. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15515. </if>
  15516. <if test="qcResultShortPageVO.chTimeStart != null ">
  15517. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15518. </if>
  15519. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15520. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15521. </if>
  15522. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15523. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15524. </if>
  15525. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15526. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15527. </if>
  15528. )f1,
  15529. (SELECT
  15530. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15531. t.behDeptId,
  15532. t.behDeptName,
  15533. t.doctorId,
  15534. t.doctorName
  15535. FROM
  15536. (
  15537. SELECT DISTINCT
  15538. t1.hospital_id AS hospitalId,
  15539. t1.behospital_code AS behospitalCode,
  15540. t1.bed_code AS bedCode,
  15541. t1.LEVEL AS LEVEL,
  15542. t1.grade_type AS gradeType,
  15543. t1.score_res AS scoreRes,
  15544. t1.NAME AS NAME,
  15545. t1.sex AS sex,
  15546. t1.beh_dept_id AS behDeptId,
  15547. t1.beh_dept_name AS behDeptName,
  15548. t1.doctor_id AS doctorId,
  15549. t1.doctor_name AS doctorName,
  15550. t1.beh_doctor_id AS behDoctorId,
  15551. t1.beh_doctor_name AS behDoctorName,
  15552. t1.director_doctor_id AS directorDoctorId,
  15553. t1.director_doctor_name AS directorDoctorName,
  15554. t1.birthday AS birthday,
  15555. t1.behospital_date AS behospitalDate,
  15556. t1.leave_hospital_date AS leaveHospitalDate,
  15557. t1.placefile_date AS placefileDate,
  15558. t1.gmt_create AS gradeTime,
  15559. t1.diagnose,
  15560. t1.ward_name AS wardName,
  15561. t2.age,
  15562. t1.file_code AS fileCode,
  15563. t1.checkStatus,
  15564. t1.mrStatus,
  15565. t1.chName,
  15566. t1.mrName,
  15567. t1.chTime,
  15568. t1.mrTime
  15569. FROM
  15570. (
  15571. SELECT
  15572. be.*,
  15573. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15574. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15575. mci.check_name AS chName,
  15576. hm_mci.check_name AS mrName,
  15577. mci.gmt_create AS chTime,
  15578. hm_mci.gmt_create AS mrTime
  15579. FROM
  15580. (
  15581. SELECT DISTINCT
  15582. a.hospital_id,
  15583. a.behospital_code,
  15584. a.bed_code,
  15585. a.file_code,
  15586. b.LEVEL,
  15587. b.grade_type,
  15588. b.score_res,
  15589. a.NAME,
  15590. a.sex,
  15591. a.beh_dept_id,
  15592. a.beh_dept_name,
  15593. a.birthday,
  15594. a.behospital_date,
  15595. a.leave_hospital_date,
  15596. a.doctor_id,
  15597. a.doctor_name,
  15598. a.beh_doctor_id,
  15599. a.beh_doctor_name,
  15600. a.director_doctor_id,
  15601. a.director_doctor_name,
  15602. a.diagnose,
  15603. a.placefile_date,
  15604. a.ward_name,
  15605. b.gmt_create
  15606. FROM
  15607. med_behospital_info a,
  15608. med_qcresult_info b,
  15609. sys_user_dept c
  15610. WHERE
  15611. a.is_deleted = 'N'
  15612. AND b.is_deleted = 'N'
  15613. AND c.is_deleted = 'N'
  15614. AND a.hospital_id = b.hospital_id
  15615. AND a.hospital_id = c.hospital_id
  15616. AND a.behospital_code = b.behospital_code
  15617. AND a.beh_dept_id = c.dept_id
  15618. AND a.qc_type_id != 0
  15619. <if test="qcResultShortPageVO.userId!=null">
  15620. AND c.user_id = #{qcResultShortPageVO.userId}
  15621. </if>
  15622. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15623. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15624. </if>
  15625. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15626. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15627. </if>
  15628. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15629. <if test="qcResultShortPageVO.startDate != null ">
  15630. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15631. </if>
  15632. <if test="qcResultShortPageVO.endDate != null ">
  15633. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15634. </if>
  15635. </if>
  15636. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15637. <if test="qcResultShortPageVO.startDate != null ">
  15638. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15639. </if>
  15640. <if test="qcResultShortPageVO.endDate != null">
  15641. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15642. </if>
  15643. </if>
  15644. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15645. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15646. </if>
  15647. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15648. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  15649. </if>
  15650. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15651. AND c.`level` = #{qcResultShortPageVO.level}
  15652. </if>
  15653. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15654. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15655. </if>
  15656. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15657. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15658. </if>
  15659. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15660. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15661. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15662. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15663. </if>
  15664. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15665. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15666. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15667. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15668. </if>
  15669. ) be
  15670. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15671. AND mci.check_type = 0
  15672. AND be.hospital_id = mci.hospital_id
  15673. AND be.behospital_code = mci.behospital_code
  15674. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15675. AND hm_mci.check_type = 1
  15676. AND be.hospital_id = hm_mci.hospital_id
  15677. AND be.behospital_code = hm_mci.behospital_code
  15678. ) t1
  15679. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15680. AND t1.behospital_code = t2.behospital_code
  15681. AND t2.is_deleted = 'N'
  15682. ) t
  15683. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15684. AND t.hospitalId = qi.hospital_id
  15685. AND t.behospitalCode = qi.behospital_code
  15686. where 1=1
  15687. <if test="qcResultShortPageVO.checkStatus != null">
  15688. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15689. </if>
  15690. <if test="qcResultShortPageVO.mrStatus != null">
  15691. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15692. </if>
  15693. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15694. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15695. </if>
  15696. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15697. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15698. </if>
  15699. <if test="qcResultShortPageVO.chTimeStart != null ">
  15700. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15701. </if>
  15702. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15703. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15704. </if>
  15705. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15706. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15707. </if>
  15708. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15709. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15710. </if>
  15711. GROUP BY
  15712. t.doctorId,
  15713. t.doctorName
  15714. )f2
  15715. WHERE
  15716. f1.doctorId = f2.doctorId
  15717. AND f1.doctorName = f2.doctorName
  15718. </select>
  15719. </mapper>