BehospitalInfoMapper.xml 258 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  7. <id column="behospital_code" property="behospitalCode"/>
  8. <result column="hospital_id" property="hospitalId"/>
  9. <result column="name" property="name"/>
  10. <result column="sex" property="sex"/>
  11. <result column="birthday" property="birthday"/>
  12. <result column="file_code" property="fileCode"/>
  13. <result column="qc_type_id" property="qcTypeId"/>
  14. <result column="ward_code" property="wardCode"/>
  15. <result column="ward_name" property="wardName"/>
  16. <result column="beh_dept_id" property="behDeptId"/>
  17. <result column="beh_dept_name" property="behDeptName"/>
  18. <result column="bed_code" property="bedCode"/>
  19. <result column="bed_name" property="bedName"/>
  20. <result column="insurance_name" property="insuranceName"/>
  21. <result column="job_type" property="jobType"/>
  22. <result column="behospital_date" property="behospitalDate"/>
  23. <result column="leave_hospital_date" property="leaveHospitalDate"/>
  24. <result column="diagnose_icd" property="diagnoseIcd"/>
  25. <result column="diagnose" property="diagnose"/>
  26. <result column="beh_doctor_id" property="behDoctorId"/>
  27. <result column="beh_doctor_name" property="behDoctorName"/>
  28. <result column="doctor_id" property="doctorId"/>
  29. <result column="doctor_name" property="doctorName"/>
  30. <result column="director_doctor_id" property="directorDoctorId"/>
  31. <result column="director_doctor_name" property="directorDoctorName"/>
  32. <result column="is_placefile" property="isPlacefile"/>
  33. <result column="placefile_date" property="placefileDate"/>
  34. <result column="is_deleted" property="isDeleted"/>
  35. <result column="gmt_create" property="gmtCreate"/>
  36. <result column="gmt_modified" property="gmtModified"/>
  37. <result column="creator" property="creator"/>
  38. <result column="modifier" property="modifier"/>
  39. </resultMap>
  40. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  41. SELECT * FROM (
  42. select t.*,
  43. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  44. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  45. g.check_type AS ch_type,
  46. h.check_type AS mr_type,
  47. g.check_name AS ch_name,
  48. h.check_name AS mr_name,
  49. g.check_time AS ch_time,
  50. h.check_time AS mr_time
  51. from (
  52. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  53. grade_time, c.age from med_behospital_info a
  54. LEFT JOIN med_qcresult_info b
  55. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  56. left join med_home_page c
  57. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  58. ) t
  59. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  60. ON t.behospital_code = g.behospital_code
  61. AND t.hospital_id = g.hospital_id
  62. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  63. ON t.behospital_code = h.behospital_code
  64. AND t.hospital_id = h.hospital_id
  65. where t.is_deleted = 'N'
  66. <if test="deptId != null and deptId != ''">
  67. and t.beh_dept_id = #{deptId}
  68. </if>
  69. <if test="doctorName != null and doctorName != ''">
  70. and CONCAT(
  71. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  72. like CONCAT('%',#{doctorName},'%')
  73. </if>
  74. <if test="name != null and name != ''">
  75. and t.name like CONCAT('%',#{name},'%')
  76. </if>
  77. <if test="doctorCode != null and doctorCode != ''">
  78. and (t.doctor_id = #{doctorCode}
  79. or t.beh_doctor_id = #{doctorCode}
  80. or t.director_doctor_id = #{doctorCode})
  81. </if>
  82. <if test="fileCode != null and fileCode != ''">
  83. and t.file_code like CONCAT('%',#{fileCode},'%')
  84. </if>
  85. <if test="hospitalId != null">
  86. and t.hospital_id = #{hospitalId}
  87. </if>
  88. <if test="behospitalCode != null and behospitalCode != ''">
  89. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  90. </if>
  91. <if test="behosDateStart != null">
  92. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  93. </if>
  94. <if test="behosDateEnd != null">
  95. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  96. </if>
  97. <if test="leaveHosDateStart != null">
  98. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  99. </if>
  100. <if test="leaveHosDateEnd != null">
  101. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  102. </if>
  103. <if test="level != null and level != ''">
  104. and t.level = #{level}
  105. </if>
  106. <if test="isPlacefile != null and isPlacefile != ''">
  107. and t.is_placefile = #{isPlacefile}
  108. </if>
  109. and t.qc_type_id != 0) p
  110. where p.is_deleted="N"
  111. <if test="checkStatus != null ">
  112. and p.check_status = #{checkStatus}
  113. </if>
  114. <if test="mrStatus != null ">
  115. AND p.mr_status = #{mrStatus}
  116. </if>
  117. <if test="chName != null and chName !=''">
  118. AND p.ch_name like CONCAT('%',#{chName},'%')
  119. </if>
  120. <if test="mrName != null and mrName !=''">
  121. AND p.mr_name like CONCAT('%',#{mrName},'%')
  122. </if>
  123. <if test="chTimeStart != null">
  124. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  125. </if>
  126. <if test="chTimeEnd != null">
  127. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  128. </if>
  129. <if test="mrTimeStart != null">
  130. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  131. </if>
  132. <if test="mrTimeEnd != null">
  133. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  134. </if>
  135. </select>
  136. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  137. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  138. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
  139. c.opt_type, c.grade_type, c.gmt_create, c.gmt_modified,
  140. a.type, a.drgs
  141. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  142. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  143. and a.id = c.cases_entry_id
  144. and a.mode_id = b.id
  145. AND c.cases_id = d.cases_id
  146. and c.hospital_id = d.hospital_id
  147. and c.hospital_id = #{hospitalId}
  148. and c.behospital_code = #{behospitalCode}
  149. order by b.order_no, c.grade_type desc, a.order_no
  150. </select>
  151. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  152. SELECT b.id model_id,b.`name` model_name,
  153. d.score,d.msg,d.cases_entry_id,d.is_reject,
  154. a.cases_id cases_id, a.name standard_msg,a.code
  155. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  156. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  157. and a.mode_id = b.id
  158. and a.id = d.cases_entry_id
  159. and d.is_used = 1
  160. and d.hospital_id = #{hospitalId}
  161. and a.code in
  162. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  163. #{item}
  164. </foreach>
  165. <if test="modeId != null">
  166. and a.mode_id = #{modeId}
  167. </if>
  168. order by b.order_no, a.order_no;
  169. </select>
  170. <!-- 各科室缺陷占比-全院-首页 -->
  171. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  172. resultType="com.diagbot.dto.NumDTO">
  173. SELECT
  174. a.beh_dept_id as id,
  175. a.beh_dept_name as name,
  176. count(*) AS num
  177. FROM
  178. med_behospital_info a,
  179. med_qcresult_info c,
  180. med_qcresult_detail d
  181. WHERE
  182. a.behospital_code = c.behospital_code
  183. AND a.hospital_id = c.hospital_id
  184. AND a.behospital_code = d.behospital_code
  185. AND a.hospital_id = d.hospital_id
  186. AND a.is_deleted = 'N'
  187. AND c.is_deleted = 'N'
  188. AND d.is_deleted = 'N'
  189. <if test="isPlacefile != null and isPlacefile != ''">
  190. and a.is_placefile = #{isPlacefile}
  191. </if>
  192. <![CDATA[AND a.qc_type_id <>0 ]]>
  193. <if test="hospitalId != null and hospitalId != ''">
  194. AND a.hospital_id = #{hospitalId}
  195. </if>
  196. <if test="startDate != null and startDate != ''">
  197. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  198. </if>
  199. <if test="endDate != null and endDate != ''">
  200. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  201. </if>
  202. GROUP BY
  203. a.beh_dept_id,
  204. a.beh_dept_name
  205. ORDER BY
  206. count(*) DESC
  207. </select>
  208. <!-- 质控结果缺陷总数查询-->
  209. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  210. SELECT
  211. count(*) AS totle
  212. FROM
  213. med_behospital_info a,
  214. med_qcresult_info c,
  215. med_qcresult_detail d
  216. WHERE
  217. a.behospital_code = c.behospital_code
  218. AND a.hospital_id = c.hospital_id
  219. AND a.behospital_code = d.behospital_code
  220. AND a.hospital_id = d.hospital_id
  221. AND a.is_deleted = 'N'
  222. AND c.is_deleted = 'N'
  223. AND d.is_deleted = 'N'
  224. <if test="isPlacefile != null and isPlacefile != ''">
  225. and a.is_placefile = #{isPlacefile}
  226. </if>
  227. <![CDATA[AND a.qc_type_id <>0 ]]>
  228. <if test="hospitalId != null and hospitalId != ''">
  229. AND a.hospital_id = #{hospitalId}
  230. </if>
  231. <if test="startDate != null and startDate != ''">
  232. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  233. </if>
  234. <if test="endDate != null and endDate != ''">
  235. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  236. </if>
  237. </select>
  238. <!--获取病历-->
  239. <select id="getNoGrade" resultMap="BaseResultMap">
  240. select * from med_behospital_info a
  241. where a.is_deleted = 'N'
  242. and a.qc_type_id != 0
  243. <if test="isPlacefile != null and isPlacefile != ''">
  244. and a.is_placefile = #{isPlacefile}
  245. </if>
  246. <if test="filterFlag != null and filterFlag == 0">
  247. and
  248. not EXISTS (
  249. SELECT
  250. 1
  251. FROM
  252. med_qcresult_info b
  253. WHERE
  254. b.is_deleted = 'N'
  255. AND a.hospital_id = b.hospital_id
  256. AND a.behospital_code = b.behospital_code
  257. )
  258. </if>
  259. <if test="leaveDate != null">
  260. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  261. </if>
  262. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  263. and a.hospital_id in
  264. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  265. #{item}
  266. </foreach>
  267. </if>
  268. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  269. and a.behospital_code in
  270. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  271. #{item}
  272. </foreach>
  273. </if>
  274. <if test="individuation != null and individuation.contains(1)">
  275. union
  276. select * from med_behospital_info b
  277. where b.is_deleted = 'N'
  278. and b.qc_type_id != 0
  279. <if test="isPlacefile != null and isPlacefile != ''">
  280. and b.is_placefile = #{isPlacefile}
  281. </if>
  282. <if test="startLeaveDate != null">
  283. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  284. </if>
  285. <if test="endLeaveDate != null">
  286. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  287. </if>
  288. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  289. and b.hospital_id in
  290. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  291. #{item}
  292. </foreach>
  293. </if>
  294. </if>
  295. </select>
  296. <!--质控评分(科室)分页-->
  297. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  298. SELECT * from (
  299. SELECT
  300. t.*,
  301. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  302. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  303. g.check_type as ch_type,
  304. h.check_type AS mr_type,
  305. g.check_name as ch_name,
  306. h.check_name as mr_name,
  307. g.check_time as ch_time,
  308. h.check_time AS mr_time
  309. FROM
  310. ( SELECT
  311. a.*,
  312. IFNULL(b.level, '未评分') AS `level`,
  313. b.grade_type,
  314. b.score_res,
  315. b.gmt_create AS grade_time,
  316. c.age
  317. FROM
  318. med_behospital_info a
  319. JOIN sys_user_dept d
  320. ON a.hospital_id = d.hospital_id
  321. AND a.beh_dept_id = d.dept_id
  322. LEFT JOIN med_qcresult_info b
  323. ON a.behospital_code = b.behospital_code
  324. AND b.is_deleted = 'N'
  325. LEFT JOIN med_home_page c
  326. ON a.behospital_code = c.behospital_code
  327. AND c.is_deleted = 'N'
  328. WHERE d.is_deleted = 'N'
  329. AND d.user_id = #{userId}
  330. ) t
  331. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  332. ON t.behospital_code = g.behospital_code
  333. AND t.hospital_id = g.hospital_id
  334. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  335. ON t.behospital_code = h.behospital_code
  336. AND t.hospital_id = h.hospital_id
  337. where t.is_deleted = 'N'
  338. <if test="deptId != null and deptId != ''">
  339. and t.beh_dept_id = #{deptId}
  340. </if>
  341. <if test="doctorName != null and doctorName != ''">
  342. and CONCAT(
  343. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  344. like CONCAT('%',#{doctorName},'%')
  345. </if>
  346. <if test="doctorCode != null and doctorCode != ''">
  347. and (t.doctor_id = #{doctorCode}
  348. or t.beh_doctor_id = #{doctorCode}
  349. or t.director_doctor_id = #{doctorCode})
  350. </if>
  351. <if test="name != null and name != ''">
  352. and t.name like CONCAT('%',#{name},'%')
  353. </if>
  354. <if test="fileCode != null and fileCode != ''">
  355. and t.file_code like CONCAT('%',#{fileCode},'%')
  356. </if>
  357. <if test="hospitalId != null">
  358. and t.hospital_id = #{hospitalId}
  359. </if>
  360. <if test="behospitalCode != null and behospitalCode != ''">
  361. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  362. </if>
  363. <if test="behosDateStart != null">
  364. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  365. </if>
  366. <if test="behosDateEnd != null">
  367. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  368. </if>
  369. <if test="leaveHosDateStart != null">
  370. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  371. </if>
  372. <if test="leaveHosDateEnd != null">
  373. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  374. </if>
  375. <if test="level != null and level != ''">
  376. and t.level = #{level}
  377. </if>
  378. <if test="isPlacefile != null and isPlacefile != ''">
  379. and t.is_placefile = #{isPlacefile}
  380. </if>
  381. and t.qc_type_id != 0) p
  382. where p.is_deleted="N"
  383. <if test="checkStatus != null ">
  384. and p.check_status = #{checkStatus}
  385. </if>
  386. <if test="mrStatus != null ">
  387. AND p.mr_status = #{mrStatus}
  388. </if>
  389. <if test="chName != null and chName !=''">
  390. AND p.ch_name like CONCAT('%',#{chName},'%')
  391. </if>
  392. <if test="mrName != null and mrName !=''">
  393. AND p.mr_name like CONCAT('%',#{mrName},'%')
  394. </if>
  395. <if test="chTimeStart != null">
  396. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  397. </if>
  398. <if test="chTimeEnd != null">
  399. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  400. </if>
  401. <if test="mrTimeStart != null">
  402. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  403. </if>
  404. <if test="mrTimeEnd != null">
  405. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  406. </if>
  407. </select>
  408. <!--质控评分(个人)分页-->
  409. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  410. Select * from (
  411. select t.*,
  412. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  413. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  414. g.check_type as ch_type,
  415. h.check_type AS mr_type,
  416. g.check_name as ch_name,
  417. h.check_name as mr_name,
  418. g.check_time as ch_time,
  419. h.check_time AS mr_time
  420. from (SELECT
  421. a.*,
  422. IFNULL(b.level, '未评分') AS `level`,
  423. b.grade_type,
  424. b.score_res,
  425. b.gmt_create AS grade_time,
  426. c.age
  427. FROM
  428. med_behospital_info a
  429. JOIN
  430. (SELECT
  431. u.id,
  432. u.linkman AS linkman,
  433. uh.hospital_id
  434. FROM
  435. sys_user u
  436. JOIN sys_user_hospital uh
  437. ON u.id = uh.user_id
  438. WHERE u.is_deleted = "N"
  439. AND u.id = #{userId}
  440. AND uh.hospital_id = #{hospitalId}) u1
  441. ON a.hospital_id = u1.hospital_id
  442. LEFT JOIN med_qcresult_info b
  443. ON a.behospital_code = b.behospital_code
  444. AND b.is_deleted = 'N'
  445. LEFT JOIN med_home_page c
  446. ON a.behospital_code = c.behospital_code
  447. AND c.is_deleted = 'N'
  448. WHERE CONCAT(
  449. IFNULL(a.doctor_name, ''),
  450. IFNULL(a.beh_doctor_name, ''),
  451. IFNULL(a.director_doctor_name, '')
  452. ) LIKE CONCAT('%', u1.linkman, '%')
  453. ) t
  454. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  455. ON t.behospital_code = g.behospital_code
  456. AND t.hospital_id = g.hospital_id
  457. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  458. ON t.behospital_code = h.behospital_code
  459. AND t.hospital_id = h.hospital_id
  460. WHERE t.is_deleted = 'N'
  461. <if test="deptId != null and deptId != ''">
  462. and t.beh_dept_id = #{deptId}
  463. </if>
  464. <if test="name != null and name != ''">
  465. and t.name like CONCAT('%',#{name},'%')
  466. </if>
  467. <if test="fileCode != null and fileCode != ''">
  468. and t.file_code like CONCAT('%',#{fileCode},'%')
  469. </if>
  470. <if test="behospitalCode != null and behospitalCode != ''">
  471. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  472. </if>
  473. <if test="behosDateStart != null">
  474. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  475. </if>
  476. <if test="behosDateEnd != null">
  477. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  478. </if>
  479. <if test="leaveHosDateStart != null">
  480. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  481. </if>
  482. <if test="leaveHosDateEnd != null">
  483. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  484. </if>
  485. <if test="level != null and level != ''">
  486. and t.level = #{level}
  487. </if>
  488. <if test="isPlacefile != null and isPlacefile != ''">
  489. and t.is_placefile = #{isPlacefile}
  490. </if>
  491. and t.qc_type_id != 0) p
  492. where p.is_deleted="N"
  493. <if test="checkStatus != null ">
  494. and p.check_status = #{checkStatus}
  495. </if>
  496. <if test="mrStatus != null ">
  497. AND p.mr_status = #{mrStatus}
  498. </if>
  499. <if test="chName != null and chName !=''">
  500. AND p.ch_name like CONCAT('%',#{chName},'%')
  501. </if>
  502. <if test="mrName != null and mrName !=''">
  503. AND p.mr_name like CONCAT('%',#{mrName},'%')
  504. </if>
  505. <if test="chTimeStart != null">
  506. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  507. </if>
  508. <if test="chTimeEnd != null">
  509. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  510. </if>
  511. <if test="mrTimeStart != null">
  512. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  513. </if>
  514. <if test="mrTimeEnd != null">
  515. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  516. </if>
  517. </select>
  518. <!--质控评分(医疗组)分页-->
  519. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  520. select * from (
  521. select t.*,
  522. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  523. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  524. g.check_type as ch_type,
  525. h.check_type AS mr_type,
  526. g.check_name as ch_name,
  527. h.check_name as mr_name,
  528. g.check_time as ch_time,
  529. h.check_time AS mr_time
  530. from (
  531. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  532. grade_time, c.age from med_behospital_info a
  533. LEFT JOIN med_qcresult_info b
  534. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  535. left join med_home_page c
  536. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  537. ) t
  538. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  539. ON t.behospital_code = g.behospital_code
  540. AND t.hospital_id = g.hospital_id
  541. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  542. ON t.behospital_code = h.behospital_code
  543. AND t.hospital_id = h.hospital_id
  544. WHERE t.is_deleted = 'N'
  545. and
  546. t.doctor_id in (
  547. SELECT doctor_id FROM `bas_doctor_info`
  548. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  549. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  550. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  551. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  552. and c1.username = c3.doctor_id
  553. and c2.hospital_id = #{hospitalId}
  554. and c1.id = #{userId}
  555. )
  556. )
  557. <if test="deptId != null and deptId != ''">
  558. and t.beh_dept_id = #{deptId}
  559. </if>
  560. <if test="doctorName != null and doctorName != ''">
  561. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  562. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  563. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  564. </if>
  565. <if test="name != null and name != ''">
  566. and t.name like CONCAT('%',#{name},'%')
  567. </if>
  568. <if test="doctorCode != null and doctorCode != ''">
  569. and (t.doctor_id = #{doctorCode}
  570. or t.beh_doctor_id = #{doctorCode}
  571. or t.director_doctor_id = #{doctorCode})
  572. </if>
  573. <if test="fileCode != null and fileCode != ''">
  574. and t.file_code like CONCAT('%',#{fileCode},'%')
  575. </if>
  576. <if test="hospitalId != null">
  577. and t.hospital_id = #{hospitalId}
  578. </if>
  579. <if test="behospitalCode != null and behospitalCode != ''">
  580. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  581. </if>
  582. <if test="behosDateStart != null">
  583. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  584. </if>
  585. <if test="behosDateEnd != null">
  586. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  587. </if>
  588. <if test="leaveHosDateStart != null">
  589. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  590. </if>
  591. <if test="leaveHosDateEnd != null">
  592. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  593. </if>
  594. <if test="level != null and level != ''">
  595. and t.level = #{level}
  596. </if>
  597. <if test="isPlacefile != null and isPlacefile != ''">
  598. and t.is_placefile = #{isPlacefile}
  599. </if>
  600. and t.qc_type_id != 0) p
  601. where p.is_deleted="N"
  602. <if test="checkStatus != null ">
  603. and p.check_status = #{checkStatus}
  604. </if>
  605. <if test="mrStatus != null ">
  606. AND p.mr_status = #{mrStatus}
  607. </if>
  608. <if test="chName != null and chName !=''">
  609. AND p.ch_name like CONCAT('%',#{chName},'%')
  610. </if>
  611. <if test="mrName != null and mrName !=''">
  612. AND p.mr_name like CONCAT('%',#{mrName},'%')
  613. </if>
  614. <if test="chTimeStart != null">
  615. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  616. </if>
  617. <if test="chTimeEnd != null">
  618. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  619. </if>
  620. <if test="mrTimeStart != null">
  621. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  622. </if>
  623. <if test="mrTimeEnd != null">
  624. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  625. </if>
  626. </select>
  627. <!-- 出院总人数统计-全院-首页 -->
  628. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  629. SELECT
  630. COUNT(*)
  631. FROM
  632. med_behospital_info a
  633. WHERE
  634. a.is_deleted = 'N'
  635. <if test="isPlacefile != null and isPlacefile != ''">
  636. and a.is_placefile = #{isPlacefile}
  637. </if>
  638. <if test="hospitalId != null and hospitalId != ''">
  639. AND a.hospital_id = #{hospitalId}
  640. </if>
  641. <if test="startDate != null and startDate != ''">
  642. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  643. </if>
  644. <if test="endDate != null and endDate != ''">
  645. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  646. </if>
  647. </select>
  648. <!-- 新生儿出院人数统计-全院-首页 -->
  649. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  650. SELECT
  651. COUNT(*)
  652. FROM
  653. med_behospital_info a,
  654. med_home_page b
  655. WHERE
  656. a.is_deleted = 'N'
  657. AND b.is_deleted = 'N'
  658. AND a.hospital_id = b.hospital_id
  659. AND a.behospital_code = b.behospital_code
  660. <if test="isPlacefile != null and isPlacefile != ''">
  661. and a.is_placefile = #{isPlacefile}
  662. </if>
  663. AND (
  664. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' )
  665. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' )
  666. )
  667. <![CDATA[AND a.qc_type_id <>0 ]]>
  668. <if test="hospitalId != null and hospitalId != ''">
  669. AND a.hospital_id = #{hospitalId}
  670. </if>
  671. <if test="startDate != null and startDate != ''">
  672. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  673. </if>
  674. <if test="endDate != null and endDate != ''">
  675. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  676. </if>
  677. </select>
  678. <!-- 死亡人数统计-全院-首页 -->
  679. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  680. SELECT
  681. COUNT(*)
  682. FROM
  683. med_behospital_info a,
  684. med_home_page b
  685. WHERE
  686. a.is_deleted = 'N'
  687. AND b.is_deleted = 'N'
  688. AND a.hospital_id = b.hospital_id
  689. AND a.behospital_code = b.behospital_code
  690. AND b.return_to_type = '死亡'
  691. <if test="isPlacefile != null and isPlacefile != ''">
  692. and a.is_placefile = #{isPlacefile}
  693. </if>
  694. <![CDATA[AND a.qc_type_id <>0 ]]>
  695. <if test="hospitalId != null and hospitalId != ''">
  696. AND a.hospital_id = #{hospitalId}
  697. </if>
  698. <if test="startDate != null and startDate != ''">
  699. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  700. </if>
  701. <if test="endDate != null and endDate != ''">
  702. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  703. </if>
  704. </select>
  705. <!-- 手术人数统计-全院-首页 -->
  706. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  707. SELECT
  708. COUNT( DISTINCT a.behospital_code )
  709. FROM
  710. med_behospital_info a,
  711. med_medical_record c,
  712. qc_mode d
  713. WHERE
  714. a.is_deleted = 'N'
  715. AND c.is_deleted = 'N'
  716. AND d.is_deleted = 'N'
  717. AND a.hospital_id = c.hospital_id
  718. AND a.behospital_code = c.behospital_code
  719. AND c.mode_id = d.id
  720. <if test="isPlacefile != null and isPlacefile != ''">
  721. and a.is_placefile = #{isPlacefile}
  722. </if>
  723. AND d.`name` = '手术记录'
  724. <![CDATA[AND a.qc_type_id <>0 ]]>
  725. <if test="hospitalId != null and hospitalId != ''">
  726. AND a.hospital_id = #{hospitalId}
  727. </if>
  728. <if test="startDate != null and startDate != ''">
  729. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  730. </if>
  731. <if test="endDate != null and endDate != ''">
  732. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  733. </if>
  734. </select>
  735. <!-- 出院总人数统计-科室-首页 -->
  736. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  737. resultType="com.diagbot.dto.NumDTO">
  738. SELECT
  739. a.beh_dept_id AS id,
  740. a.beh_dept_name AS NAME,
  741. COUNT(*) AS num
  742. FROM
  743. med_behospital_info a,
  744. sys_user_dept c
  745. WHERE
  746. a.is_deleted = 'N'
  747. AND c.is_deleted = 'N'
  748. AND a.hospital_id = c.hospital_id
  749. AND a.beh_dept_id = c.dept_id
  750. <if test="isPlacefile != null and isPlacefile != ''">
  751. and a.is_placefile = #{isPlacefile}
  752. </if>
  753. <if test="userId!=null">
  754. AND c.user_id = #{userId}
  755. </if>
  756. <if test="hospitalId != null and hospitalId != ''">
  757. AND a.hospital_id = #{hospitalId}
  758. </if>
  759. <if test="startDate != null and startDate != ''">
  760. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  761. </if>
  762. <if test="endDate != null and endDate != ''">
  763. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  764. </if>
  765. GROUP BY
  766. a.beh_dept_id,
  767. a.beh_dept_name
  768. </select>
  769. <!-- 新生儿出院人数统计-科室-首页 -->
  770. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  771. resultType="com.diagbot.dto.NumDTO">
  772. SELECT
  773. a.beh_dept_id AS id,
  774. a.beh_dept_name AS NAME,
  775. COUNT(*) AS num
  776. FROM
  777. med_behospital_info a,
  778. med_home_page b,
  779. sys_user_dept c
  780. WHERE
  781. a.is_deleted = 'N'
  782. AND b.is_deleted = 'N'
  783. AND c.is_deleted = 'N'
  784. AND a.hospital_id = b.hospital_id
  785. AND a.hospital_id = c.hospital_id
  786. AND a.behospital_code = b.behospital_code
  787. AND a.beh_dept_id = c.dept_id
  788. AND (
  789. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' )
  790. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' )
  791. )
  792. <if test="isPlacefile != null and isPlacefile != ''">
  793. and a.is_placefile = #{isPlacefile}
  794. </if>
  795. <![CDATA[AND a.qc_type_id <>0 ]]>
  796. <if test="userId!=null">
  797. AND c.user_id = #{userId}
  798. </if>
  799. <if test="hospitalId != null and hospitalId != ''">
  800. AND a.hospital_id = #{hospitalId}
  801. </if>
  802. <if test="startDate != null and startDate != ''">
  803. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  804. </if>
  805. <if test="endDate != null and endDate != ''">
  806. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  807. </if>
  808. GROUP BY
  809. a.beh_dept_id,
  810. a.beh_dept_name
  811. </select>
  812. <!-- 死亡人数统计-科室-首页 -->
  813. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  814. resultType="com.diagbot.dto.NumDTO">
  815. SELECT
  816. a.beh_dept_id AS id,
  817. a.beh_dept_name AS NAME,
  818. COUNT(*) AS num
  819. FROM
  820. med_behospital_info a,
  821. med_home_page b,
  822. sys_user_dept c
  823. WHERE
  824. a.is_deleted = 'N'
  825. AND b.is_deleted = 'N'
  826. AND c.is_deleted = 'N'
  827. AND a.hospital_id = b.hospital_id
  828. AND a.hospital_id = c.hospital_id
  829. AND a.behospital_code = b.behospital_code
  830. AND a.beh_dept_id = c.dept_id
  831. AND b.return_to_type = '死亡'
  832. <if test="isPlacefile != null and isPlacefile != ''">
  833. and a.is_placefile = #{isPlacefile}
  834. </if>
  835. <![CDATA[AND a.qc_type_id <>0 ]]>
  836. <if test="userId!=null">
  837. AND c.user_id = #{userId}
  838. </if>
  839. <if test="hospitalId != null and hospitalId != ''">
  840. AND a.hospital_id = #{hospitalId}
  841. </if>
  842. <if test="startDate != null and startDate != ''">
  843. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  844. </if>
  845. <if test="endDate != null and endDate != ''">
  846. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  847. </if>
  848. GROUP BY
  849. a.beh_dept_id,
  850. a.beh_dept_name
  851. </select>
  852. <!-- 手术人数统计-科室-首页 -->
  853. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  854. resultType="com.diagbot.dto.NumDTO">
  855. SELECT
  856. a.beh_dept_id AS id,
  857. a.beh_dept_name AS NAME,
  858. COUNT( DISTINCT a.behospital_code ) AS num
  859. FROM
  860. med_behospital_info a,
  861. sys_user_dept c,
  862. med_medical_record d,
  863. qc_mode e
  864. WHERE
  865. a.is_deleted = 'N'
  866. AND c.is_deleted = 'N'
  867. AND d.is_deleted = 'N'
  868. AND e.is_deleted = 'N'
  869. AND a.hospital_id = c.hospital_id
  870. AND a.hospital_id = d.hospital_id
  871. AND a.behospital_code = d.behospital_code
  872. AND a.beh_dept_id = c.dept_id
  873. AND d.mode_id = e.id
  874. AND e.`name` = '手术记录'
  875. <if test="isPlacefile != null and isPlacefile != ''">
  876. and a.is_placefile = #{isPlacefile}
  877. </if>
  878. <![CDATA[AND a.qc_type_id <>0 ]]>
  879. <if test="userId!=null">
  880. AND c.user_id = #{userId}
  881. </if>
  882. <if test="hospitalId != null and hospitalId != ''">
  883. AND a.hospital_id = #{hospitalId}
  884. </if>
  885. <if test="startDate != null and startDate != ''">
  886. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  887. </if>
  888. <if test="endDate != null and endDate != ''">
  889. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  890. </if>
  891. GROUP BY
  892. a.beh_dept_id,
  893. a.beh_dept_name
  894. </select>
  895. <!-- 各科室缺陷占比排行(分页) -->
  896. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  897. SELECT t.*
  898. FROM
  899. (SELECT
  900. t1.beh_dept_name AS NAME,
  901. t1.num AS num,
  902. t2.totle AS totleNum,
  903. round( t1.num / t2.totle, 4 ) AS percent,
  904. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  905. FROM
  906. (
  907. SELECT
  908. a.beh_dept_id,
  909. a.beh_dept_name,
  910. count(*) AS num
  911. FROM
  912. med_behospital_info a,
  913. med_qcresult_info c,
  914. med_qcresult_detail d
  915. WHERE
  916. a.behospital_code = c.behospital_code
  917. AND a.hospital_id = c.hospital_id
  918. AND a.behospital_code = d.behospital_code
  919. AND a.hospital_id = d.hospital_id
  920. AND a.is_deleted = 'N'
  921. AND c.is_deleted = 'N'
  922. AND d.is_deleted = 'N'
  923. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  924. and a.is_placefile = #{filterPageVO.isPlacefile}
  925. </if>
  926. <![CDATA[AND a.qc_type_id <>0 ]]>
  927. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  928. AND a.hospital_id = #{filterPageVO.hospitalId}
  929. </if>
  930. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  931. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  932. </if>
  933. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  934. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  935. </if>
  936. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  937. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  938. </if>
  939. GROUP BY
  940. a.beh_dept_id,
  941. a.beh_dept_name
  942. ORDER BY
  943. count(*) DESC
  944. ) t1,
  945. (
  946. SELECT
  947. count(*) AS totle
  948. FROM
  949. med_behospital_info a,
  950. med_qcresult_info c,
  951. med_qcresult_detail d
  952. WHERE
  953. a.behospital_code = c.behospital_code
  954. AND a.hospital_id = c.hospital_id
  955. AND a.behospital_code = d.behospital_code
  956. AND a.hospital_id = d.hospital_id
  957. AND a.is_deleted = 'N'
  958. AND c.is_deleted = 'N'
  959. AND d.is_deleted = 'N'
  960. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  961. and a.is_placefile = #{filterPageVO.isPlacefile}
  962. </if>
  963. <![CDATA[AND a.qc_type_id <>0 ]]>
  964. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  965. AND a.hospital_id = #{filterPageVO.hospitalId}
  966. </if>
  967. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  968. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  969. </if>
  970. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  971. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  972. </if>
  973. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  974. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  975. </if>
  976. ) t2
  977. )t
  978. </select>
  979. <!-- 科室缺陷占比(主任医生) -->
  980. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  981. SELECT
  982. t.*
  983. FROM
  984. (
  985. SELECT
  986. t1.NAME,
  987. t1.num AS num,
  988. t2.totle AS totleNum,
  989. round( t1.num / t2.totle, 4 ) AS percent,
  990. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  991. FROM
  992. (
  993. SELECT
  994. d.msg as name,
  995. count(*) AS num
  996. FROM
  997. med_behospital_info a,
  998. med_qcresult_info c,
  999. med_qcresult_detail d,
  1000. sys_user_dept e
  1001. WHERE
  1002. a.behospital_code = c.behospital_code
  1003. AND a.hospital_id = c.hospital_id
  1004. AND a.behospital_code = d.behospital_code
  1005. AND a.hospital_id = d.hospital_id
  1006. AND a.is_deleted = 'N'
  1007. AND c.is_deleted = 'N'
  1008. AND d.is_deleted = 'N'
  1009. AND e.is_deleted = 'N'
  1010. AND a.beh_dept_id = e.dept_id
  1011. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1012. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1013. </if>
  1014. <![CDATA[AND a.qc_type_id <>0 ]]>
  1015. <if test="filterPageByDeptVO.userId!=null">
  1016. AND e.user_id = #{filterPageByDeptVO.userId}
  1017. </if>
  1018. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1019. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1020. </if>
  1021. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1022. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1023. </if>
  1024. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1025. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1026. </if>
  1027. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1028. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1029. </if>
  1030. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1031. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1032. </if>
  1033. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1034. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1035. </if>
  1036. GROUP BY
  1037. d.msg
  1038. ORDER BY
  1039. count(*) DESC
  1040. ) t1,
  1041. (
  1042. SELECT
  1043. count(*) AS totle
  1044. FROM
  1045. med_behospital_info a,
  1046. med_qcresult_info c,
  1047. med_qcresult_detail d,
  1048. sys_user_dept e
  1049. WHERE
  1050. a.behospital_code = c.behospital_code
  1051. AND a.hospital_id = c.hospital_id
  1052. AND a.behospital_code = d.behospital_code
  1053. AND a.hospital_id = d.hospital_id
  1054. AND a.is_deleted = 'N'
  1055. AND c.is_deleted = 'N'
  1056. AND d.is_deleted = 'N'
  1057. AND e.is_deleted = 'N'
  1058. AND a.beh_dept_id = e.dept_id
  1059. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1060. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1061. </if>
  1062. <![CDATA[AND a.qc_type_id <>0 ]]>
  1063. <if test="filterPageByDeptVO.userId!=null">
  1064. AND e.user_id = #{filterPageByDeptVO.userId}
  1065. </if>
  1066. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1067. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1068. </if>
  1069. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1070. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1071. </if>
  1072. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1073. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1074. </if>
  1075. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1076. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1077. </if>
  1078. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1079. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1080. </if>
  1081. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1082. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1083. </if>
  1084. ) t2
  1085. )t
  1086. </select>
  1087. <!-- 各科室缺陷占比(组合)-全院 -->
  1088. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  1089. resultType="com.diagbot.dto.LevelStatisticsDTO">
  1090. SELECT
  1091. t1.deptId,
  1092. t1.deptName,
  1093. t2.entryNum,
  1094. t1.mrNum,
  1095. t1.totleValue,
  1096. t1.averageValue,
  1097. t1.firstLevelNum,
  1098. t1.secondLevelNum,
  1099. t1.thirdLevelNum,
  1100. t1.firstLevelPercent,
  1101. t1.secondLevelPercent,
  1102. t1.thirdLevelPercent,
  1103. t1.firstLevelPercentStr,
  1104. t1.secondLevelPercentStr,
  1105. t1.thirdLevelPercentStr
  1106. FROM
  1107. (
  1108. SELECT
  1109. a.beh_dept_id AS deptId,
  1110. a.beh_dept_name AS deptName,
  1111. count(*) AS mrNum,
  1112. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1113. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1114. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1115. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1116. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1117. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1118. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1119. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1120. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1121. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1122. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1123. FROM
  1124. med_behospital_info a,
  1125. med_qcresult_info c
  1126. WHERE
  1127. a.is_deleted = 'N'
  1128. AND c.is_deleted = 'N'
  1129. AND a.hospital_id = c.hospital_id
  1130. AND a.behospital_code = c.behospital_code
  1131. <if test="isPlacefile != null and isPlacefile != ''">
  1132. and a.is_placefile = #{isPlacefile}
  1133. </if>
  1134. AND a.qc_type_id != 0
  1135. <if test="hospitalId != null and hospitalId != ''">
  1136. AND a.hospital_id = #{hospitalId}
  1137. </if>
  1138. <if test="startDate != null and startDate != ''">
  1139. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1140. </if>
  1141. <if test="endDate != null and endDate != ''">
  1142. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1143. </if>
  1144. <if test="level != null and level != ''">
  1145. and c.level = #{level}
  1146. </if>
  1147. <if test="name != null and name != ''">
  1148. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1149. </if>
  1150. GROUP BY
  1151. a.beh_dept_id,
  1152. a.beh_dept_name
  1153. ) t1,
  1154. (
  1155. SELECT
  1156. a.beh_dept_id AS deptId,
  1157. a.beh_dept_name AS deptName,
  1158. count( * ) AS entryNum
  1159. FROM
  1160. med_behospital_info a,
  1161. med_qcresult_info c,
  1162. med_qcresult_detail d,
  1163. qc_cases_entry e
  1164. WHERE
  1165. a.is_deleted = 'N'
  1166. AND c.is_deleted = 'N'
  1167. AND d.is_deleted = 'N'
  1168. AND e.is_deleted = 'N'
  1169. AND a.hospital_id = c.hospital_id
  1170. AND a.hospital_id = d.hospital_id
  1171. AND a.behospital_code = c.behospital_code
  1172. AND a.behospital_code = d.behospital_code
  1173. AND d.cases_id = e.cases_id
  1174. AND d.cases_entry_id = e.id
  1175. <if test="isPlacefile != null and isPlacefile != ''">
  1176. and a.is_placefile = #{isPlacefile}
  1177. </if>
  1178. AND a.qc_type_id != 0
  1179. <if test="hospitalId != null and hospitalId != ''">
  1180. AND a.hospital_id = #{hospitalId}
  1181. </if>
  1182. <if test="startDate != null and startDate != ''">
  1183. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1184. </if>
  1185. <if test="endDate != null and endDate != ''">
  1186. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1187. </if>
  1188. <if test="level != null and level != ''">
  1189. and c.level = #{level}
  1190. </if>
  1191. <if test="name != null and name != ''">
  1192. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1193. </if>
  1194. GROUP BY
  1195. a.beh_dept_id,
  1196. a.beh_dept_name
  1197. ) t2
  1198. WHERE
  1199. t1.deptId = t2.deptId
  1200. AND t1.deptName = t2.deptName
  1201. <if test="asc != null and asc !=''">
  1202. order by
  1203. <choose>
  1204. <when test='asc=="deptId"'>deptId asc</when>
  1205. <when test='asc=="deptName"'>deptName asc</when>
  1206. <when test='asc=="entryNum"'>entryNum asc</when>
  1207. <when test='asc=="mrNum"'>mrNum asc</when>
  1208. <when test='asc=="totleValue"'>totleValue asc</when>
  1209. <when test='asc=="averageValue"'>averageValue asc</when>
  1210. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1211. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1212. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1213. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1214. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1215. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1216. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1217. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1218. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1219. <otherwise>deptName asc</otherwise>
  1220. </choose>
  1221. </if>
  1222. <if test="desc != null and desc!=''">
  1223. order by
  1224. <choose>
  1225. <when test='desc=="deptId"'>deptId desc</when>
  1226. <when test='desc=="deptName"'>deptName desc</when>
  1227. <when test='desc=="entryNum"'>entryNum desc</when>
  1228. <when test='desc=="mrNum"'>mrNum desc</when>
  1229. <when test='desc=="totleValue"'>totleValue desc</when>
  1230. <when test='desc=="averageValue"'>averageValue desc</when>
  1231. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1232. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1233. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1234. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1235. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1236. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1237. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1238. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1239. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1240. <otherwise>deptName desc</otherwise>
  1241. </choose>
  1242. </if>
  1243. </select>
  1244. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  1245. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  1246. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1247. SELECT
  1248. t1.deptId,
  1249. t1.deptName,
  1250. t1.deptClassId,
  1251. t1.deptClass,
  1252. t2.entryNum,
  1253. t1.mrNum,
  1254. t1.totleValue,
  1255. t1.averageValue,
  1256. t1.firstLevelNum,
  1257. t1.secondLevelNum,
  1258. t1.thirdLevelNum,
  1259. t1.firstLevelPercent,
  1260. t1.secondLevelPercent,
  1261. t1.thirdLevelPercent,
  1262. t1.firstLevelPercentStr,
  1263. t1.secondLevelPercentStr,
  1264. t1.thirdLevelPercentStr
  1265. FROM
  1266. (
  1267. SELECT
  1268. a.beh_dept_id AS deptId,
  1269. a.beh_dept_name AS deptName,
  1270. e.dept_id AS deptClassId,
  1271. e.dept_name AS deptClass,
  1272. count( DISTINCT c.id ) AS mrNum,
  1273. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1274. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1275. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  1276. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  1277. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  1278. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  1279. ) AS firstLevelPercent,
  1280. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1281. ) AS secondLevelPercent,
  1282. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1283. ) AS thirdLevelPercent,
  1284. concat(
  1285. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  1286. 100, 2 ),
  1287. '%'
  1288. ) AS firstLevelPercentStr,
  1289. concat(
  1290. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  1291. 100, 2 ),
  1292. '%'
  1293. ) AS secondLevelPercentStr,
  1294. concat(
  1295. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  1296. 100, 2 ),
  1297. '%'
  1298. ) AS thirdLevelPercentStr
  1299. FROM
  1300. med_behospital_info a,
  1301. med_qcresult_info c,
  1302. bas_dept_info d,
  1303. bas_dept_info e
  1304. WHERE
  1305. a.is_deleted = 'N'
  1306. AND c.is_deleted = 'N'
  1307. AND d.is_deleted = 'N'
  1308. AND e.is_deleted = 'N'
  1309. AND a.hospital_id = c.hospital_id
  1310. AND a.hospital_id = d.hospital_id
  1311. AND a.hospital_id = e.hospital_id
  1312. AND a.behospital_code = c.behospital_code
  1313. AND a.beh_dept_id = d.dept_id
  1314. AND d.parent_dept_id = e.dept_id
  1315. <if test="isPlacefile != null and isPlacefile != ''">
  1316. and a.is_placefile = #{isPlacefile}
  1317. </if>
  1318. <![CDATA[AND a.qc_type_id <>0 ]]>
  1319. <if test="hospitalId != null and hospitalId != ''">
  1320. AND a.hospital_id = #{hospitalId}
  1321. </if>
  1322. <if test="startDate != null and startDate != ''">
  1323. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1324. </if>
  1325. <if test="endDate != null and endDate != ''">
  1326. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1327. </if>
  1328. <if test="level != null and level != ''">
  1329. and c.level = #{level}
  1330. </if>
  1331. <if test="name != null and name != ''">
  1332. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1333. </if>
  1334. <if test="deptClass != null and deptClass != ''">
  1335. and e.dept_name = #{deptClass}
  1336. </if>
  1337. GROUP BY
  1338. a.beh_dept_id,
  1339. a.beh_dept_name,
  1340. e.dept_id,
  1341. e.dept_name
  1342. ) t1,
  1343. (
  1344. SELECT
  1345. a.beh_dept_id AS deptId,
  1346. a.beh_dept_name AS deptName,
  1347. g.dept_id AS deptClassId,
  1348. g.dept_name AS deptClass,
  1349. count( * ) AS entryNum
  1350. FROM
  1351. med_behospital_info a,
  1352. med_qcresult_info c,
  1353. med_qcresult_detail d,
  1354. qc_cases_entry e,
  1355. bas_dept_info f,
  1356. bas_dept_info g
  1357. WHERE
  1358. a.is_deleted = 'N'
  1359. AND c.is_deleted = 'N'
  1360. AND d.is_deleted = 'N'
  1361. AND e.is_deleted = 'N'
  1362. AND f.is_deleted = 'N'
  1363. AND g.is_deleted = 'N'
  1364. AND a.hospital_id = c.hospital_id
  1365. AND a.hospital_id = d.hospital_id
  1366. AND a.hospital_id = f.hospital_id
  1367. AND a.hospital_id = g.hospital_id
  1368. AND a.behospital_code = c.behospital_code
  1369. AND a.behospital_code = d.behospital_code
  1370. AND d.cases_id = e.cases_id
  1371. AND d.cases_entry_id = e.id
  1372. AND a.beh_dept_id = f.dept_id
  1373. AND f.parent_dept_id = g.dept_id
  1374. <if test="isPlacefile != null and isPlacefile != ''">
  1375. and a.is_placefile = #{isPlacefile}
  1376. </if>
  1377. <![CDATA[AND a.qc_type_id <>0 ]]>
  1378. <if test="hospitalId != null and hospitalId != ''">
  1379. AND a.hospital_id = #{hospitalId}
  1380. </if>
  1381. <if test="startDate != null and startDate != ''">
  1382. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1383. </if>
  1384. <if test="endDate != null and endDate != ''">
  1385. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1386. </if>
  1387. <if test="level != null and level != ''">
  1388. and c.level = #{level}
  1389. </if>
  1390. <if test="name != null and name != ''">
  1391. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1392. </if>
  1393. <if test="deptClass != null and deptClass != ''">
  1394. and g.dept_name = #{deptClass}
  1395. </if>
  1396. GROUP BY
  1397. a.beh_dept_id,
  1398. a.beh_dept_name,
  1399. g.dept_id,
  1400. g.dept_name
  1401. ) t2
  1402. WHERE
  1403. t1.deptId = t2.deptId
  1404. AND t1.deptName = t2.deptName
  1405. AND t1.deptClassId = t2.deptClassId
  1406. AND t1.deptClass = t2.deptClass
  1407. <if test="asc != null and asc !=''">
  1408. order by
  1409. <choose>
  1410. <when test='asc=="deptId"'>deptId asc</when>
  1411. <when test='asc=="deptName"'>deptName asc</when>
  1412. <when test='asc=="deptClassId"'>deptClassId asc</when>
  1413. <when test='asc=="deptClass"'>deptClass asc</when>
  1414. <when test='asc=="entryNum"'>entryNum asc</when>
  1415. <when test='asc=="mrNum"'>mrNum asc</when>
  1416. <when test='asc=="totleValue"'>totleValue asc</when>
  1417. <when test='asc=="averageValue"'>averageValue asc</when>
  1418. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1419. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1420. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1421. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1422. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1423. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1424. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1425. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1426. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1427. <otherwise>deptName asc</otherwise>
  1428. </choose>
  1429. </if>
  1430. <if test="desc != null and desc!=''">
  1431. order by
  1432. <choose>
  1433. <when test='desc=="deptId"'>deptId desc</when>
  1434. <when test='desc=="deptName"'>deptName desc</when>
  1435. <when test='desc=="deptClassId"'>deptClassId desc</when>
  1436. <when test='desc=="deptClass"'>deptClass desc</when>
  1437. <when test='desc=="entryNum"'>entryNum desc</when>
  1438. <when test='desc=="mrNum"'>mrNum desc</when>
  1439. <when test='desc=="totleValue"'>totleValue desc</when>
  1440. <when test='desc=="averageValue"'>averageValue desc</when>
  1441. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1442. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1443. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1444. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1445. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1446. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1447. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1448. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1449. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1450. <otherwise>deptName desc</otherwise>
  1451. </choose>
  1452. </if>
  1453. </select>
  1454. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  1455. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1456. SELECT
  1457. t1.deptId,
  1458. t1.deptName,
  1459. t1.deptClassId,
  1460. t1.deptClass,
  1461. t2.entryNum,
  1462. t1.mrNum,
  1463. t1.totleValue,
  1464. t1.averageValue,
  1465. t1.firstLevelNum,
  1466. t1.secondLevelNum,
  1467. t1.thirdLevelNum,
  1468. t1.firstLevelPercent,
  1469. t1.secondLevelPercent,
  1470. t1.thirdLevelPercent,
  1471. t1.firstLevelPercentStr,
  1472. t1.secondLevelPercentStr,
  1473. t1.thirdLevelPercentStr
  1474. FROM
  1475. (
  1476. SELECT
  1477. tt1.deptId,
  1478. tt1.deptName,
  1479. e.dept_id AS deptClassId,
  1480. e.dept_name AS deptClass,
  1481. count(*) AS mrNum,
  1482. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1483. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1484. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  1485. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  1486. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  1487. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  1488. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  1489. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  1490. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1491. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1492. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1493. FROM
  1494. (
  1495. SELECT
  1496. a.beh_dept_id AS deptId,
  1497. a.beh_dept_name AS deptName,
  1498. d.parent_dept_id AS parentDeptId,
  1499. a.hospital_id AS hospitalId,
  1500. a.behospital_code AS behospitalCode,
  1501. c.score_res AS score,
  1502. c.LEVEL
  1503. FROM
  1504. med_behospital_info a,
  1505. med_qcresult_info c,
  1506. bas_dept_info d
  1507. WHERE
  1508. a.is_deleted = 'N'
  1509. AND c.is_deleted = 'N'
  1510. AND d.is_deleted = 'N'
  1511. AND a.hospital_id = c.hospital_id
  1512. AND a.hospital_id = d.hospital_id
  1513. AND a.behospital_code = c.behospital_code
  1514. AND a.beh_dept_id = d.dept_id
  1515. <if test="isPlacefile != null and isPlacefile != ''">
  1516. and a.is_placefile = #{isPlacefile}
  1517. </if>
  1518. AND a.qc_type_id != 0
  1519. <if test="hospitalId != null and hospitalId != ''">
  1520. AND a.hospital_id = #{hospitalId}
  1521. </if>
  1522. <if test="startDate != null and startDate != ''">
  1523. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1524. </if>
  1525. <if test="endDate != null and endDate != ''">
  1526. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1527. </if>
  1528. <if test="level != null and level != ''">
  1529. and c.level = #{level}
  1530. </if>
  1531. <if test="name != null and name != ''">
  1532. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1533. </if>
  1534. ) tt1
  1535. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  1536. AND e.is_deleted = 'N'
  1537. AND tt1.hospitalId = e.hospital_id
  1538. <if test="deptClass != null and deptClass != ''">
  1539. WHERE e.dept_name = #{deptClass}
  1540. </if>
  1541. GROUP BY
  1542. tt1.deptId,
  1543. tt1.deptName,
  1544. e.dept_id,
  1545. e.dept_name
  1546. ) t1,
  1547. (
  1548. SELECT
  1549. tt2.deptId,
  1550. tt2.deptName,
  1551. g.dept_id AS deptClassId,
  1552. g.dept_name AS deptClass,
  1553. count( * ) AS entryNum
  1554. FROM
  1555. (
  1556. SELECT
  1557. a.beh_dept_id AS deptId,
  1558. a.beh_dept_name AS deptName,
  1559. f.parent_dept_id AS parentDeptId,
  1560. a.hospital_id AS hospitalId,
  1561. a.behospital_code AS behospitalCode
  1562. FROM
  1563. med_behospital_info a,
  1564. med_qcresult_info c,
  1565. med_qcresult_detail d,
  1566. qc_cases_entry e,
  1567. bas_dept_info f
  1568. WHERE
  1569. a.is_deleted = 'N'
  1570. AND c.is_deleted = 'N'
  1571. AND d.is_deleted = 'N'
  1572. AND e.is_deleted = 'N'
  1573. AND f.is_deleted = 'N'
  1574. AND a.hospital_id = c.hospital_id
  1575. AND a.hospital_id = d.hospital_id
  1576. AND a.hospital_id = f.hospital_id
  1577. AND a.behospital_code = c.behospital_code
  1578. AND a.behospital_code = d.behospital_code
  1579. AND d.cases_id = e.cases_id
  1580. AND d.cases_entry_id = e.id
  1581. AND a.beh_dept_id = f.dept_id
  1582. <if test="isPlacefile != null and isPlacefile != ''">
  1583. and a.is_placefile = #{isPlacefile}
  1584. </if>
  1585. AND a.qc_type_id != 0
  1586. <if test="hospitalId != null and hospitalId != ''">
  1587. AND a.hospital_id = #{hospitalId}
  1588. </if>
  1589. <if test="startDate != null and startDate != ''">
  1590. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1591. </if>
  1592. <if test="endDate != null and endDate != ''">
  1593. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1594. </if>
  1595. <if test="level != null and level != ''">
  1596. and c.level = #{level}
  1597. </if>
  1598. <if test="name != null and name != ''">
  1599. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1600. </if>
  1601. ) tt2
  1602. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  1603. AND g.is_deleted = 'N'
  1604. AND tt2.hospitalId = g.hospital_id
  1605. <if test="deptClass != null and deptClass != ''">
  1606. WHERE g.dept_name = #{deptClass}
  1607. </if>
  1608. GROUP BY
  1609. tt2.deptId,
  1610. tt2.deptName,
  1611. g.dept_id,
  1612. g.dept_name
  1613. ) t2
  1614. WHERE
  1615. t1.deptId = t2.deptId
  1616. AND t1.deptName = t2.deptName
  1617. <if test="asc != null and asc !=''">
  1618. order by
  1619. <choose>
  1620. <when test='asc=="deptId"'>deptId asc</when>
  1621. <when test='asc=="deptName"'>deptName asc</when>
  1622. <when test='asc=="deptClassId"'>deptClassId asc</when>
  1623. <when test='asc=="deptClass"'>deptClass asc</when>
  1624. <when test='asc=="entryNum"'>entryNum asc</when>
  1625. <when test='asc=="mrNum"'>mrNum asc</when>
  1626. <when test='asc=="totleValue"'>totleValue asc</when>
  1627. <when test='asc=="averageValue"'>averageValue asc</when>
  1628. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1629. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1630. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1631. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1632. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1633. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1634. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1635. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1636. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1637. <otherwise>deptName asc</otherwise>
  1638. </choose>
  1639. </if>
  1640. <if test="desc != null and desc!=''">
  1641. order by
  1642. <choose>
  1643. <when test='desc=="deptId"'>deptId desc</when>
  1644. <when test='desc=="deptName"'>deptName desc</when>
  1645. <when test='desc=="deptClassId"'>deptClassId desc</when>
  1646. <when test='desc=="deptClass"'>deptClass desc</when>
  1647. <when test='desc=="entryNum"'>entryNum desc</when>
  1648. <when test='desc=="mrNum"'>mrNum desc</when>
  1649. <when test='desc=="totleValue"'>totleValue desc</when>
  1650. <when test='desc=="averageValue"'>averageValue desc</when>
  1651. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1652. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1653. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1654. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1655. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1656. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1657. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1658. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1659. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1660. <otherwise>deptName desc</otherwise>
  1661. </choose>
  1662. </if>
  1663. </select>
  1664. <!-- 病案首页合格率占比 -全院-->
  1665. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  1666. resultType="com.diagbot.dto.HomePageNumDTO">
  1667. SELECT
  1668. t1.deptId,
  1669. t1.deptName,
  1670. t2.entryNum,
  1671. t1.mrNum,
  1672. t1.totleValue,
  1673. t1.averageValue,
  1674. t1.firstLevelNum,
  1675. t1.secondLevelNum,
  1676. t1.firstLevelPercent,
  1677. t1.secondLevelPercent,
  1678. t1.firstLevelPercentStr,
  1679. t1.secondLevelPercentStr,
  1680. t3.emptyNum,
  1681. t3.errorNum,
  1682. t3.entryTotleNum,
  1683. t3.emptyPercent,
  1684. t3.errorPercent,
  1685. t3.emptyPercentStr,
  1686. t3.errorPercentStr
  1687. FROM
  1688. (
  1689. SELECT
  1690. a.beh_dept_id AS deptId,
  1691. a.beh_dept_name AS deptName,
  1692. count( * ) AS mrNum,
  1693. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1694. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1695. SUM( c.`level` = '合格' ) AS firstLevelNum,
  1696. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  1697. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  1698. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  1699. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  1700. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  1701. FROM
  1702. med_behospital_info a,
  1703. med_qcresult_cases c
  1704. WHERE
  1705. a.is_deleted = 'N'
  1706. AND c.is_deleted = 'N'
  1707. AND a.hospital_id = c.hospital_id
  1708. AND a.behospital_code = c.behospital_code
  1709. AND c.cases_id = 243
  1710. <if test="isPlacefile != null and isPlacefile != ''">
  1711. and a.is_placefile = #{isPlacefile}
  1712. </if>
  1713. AND a.qc_type_id != 0
  1714. <if test="hospitalId != null and hospitalId != ''">
  1715. AND a.hospital_id = #{hospitalId}
  1716. </if>
  1717. <if test="startDate != null and startDate != ''">
  1718. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1719. </if>
  1720. <if test="endDate != null and endDate != ''">
  1721. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1722. </if>
  1723. <if test="level != null and level != ''">
  1724. and c.level = #{level}
  1725. </if>
  1726. <if test="name != null and name != ''">
  1727. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1728. </if>
  1729. GROUP BY
  1730. a.beh_dept_id,
  1731. a.beh_dept_name
  1732. ) t1,
  1733. (
  1734. SELECT
  1735. a.beh_dept_id AS deptId,
  1736. a.beh_dept_name AS deptName,
  1737. count( * ) AS entryNum
  1738. FROM
  1739. med_behospital_info a,
  1740. med_qcresult_cases c,
  1741. med_qcresult_detail d,
  1742. qc_cases_entry e
  1743. WHERE
  1744. a.is_deleted = 'N'
  1745. AND c.is_deleted = 'N'
  1746. AND d.is_deleted = 'N'
  1747. AND e.is_deleted = 'N'
  1748. AND a.hospital_id = c.hospital_id
  1749. AND a.hospital_id = d.hospital_id
  1750. AND a.behospital_code = c.behospital_code
  1751. AND a.behospital_code = d.behospital_code
  1752. AND c.cases_id = d.cases_id
  1753. AND d.cases_id = e.cases_id
  1754. AND d.cases_entry_id = e.id
  1755. AND d.cases_id = 243
  1756. <if test="isPlacefile != null and isPlacefile != ''">
  1757. and a.is_placefile = #{isPlacefile}
  1758. </if>
  1759. AND a.qc_type_id != 0
  1760. <if test="hospitalId != null and hospitalId != ''">
  1761. AND a.hospital_id = #{hospitalId}
  1762. </if>
  1763. <if test="startDate != null and startDate != ''">
  1764. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1765. </if>
  1766. <if test="endDate != null and endDate != ''">
  1767. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1768. </if>
  1769. <if test="level != null and level != ''">
  1770. and c.level = #{level}
  1771. </if>
  1772. <if test="name != null and name != ''">
  1773. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1774. </if>
  1775. GROUP BY
  1776. a.beh_dept_id,
  1777. a.beh_dept_name
  1778. ) t2,(
  1779. SELECT
  1780. h1.deptId,
  1781. h1.deptName,
  1782. h1.emptyNum,
  1783. h1.errorNum,
  1784. h1.mrNum,
  1785. h2.entryNum,
  1786. h1.mrNum * h2.entryNum AS entryTotleNum,
  1787. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  1788. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  1789. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  1790. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  1791. FROM
  1792. (
  1793. SELECT
  1794. a.beh_dept_id AS deptId,
  1795. a.beh_dept_name AS deptName,
  1796. sum( d.rule_type = 1 ) AS emptyNum,
  1797. sum( d.rule_type = 2 ) AS errorNum,
  1798. count( DISTINCT a.behospital_code ) AS mrNum
  1799. FROM
  1800. med_behospital_info a,
  1801. med_qcresult_cases b,
  1802. med_qcresult_detail c,
  1803. qc_cases_entry d
  1804. WHERE
  1805. a.is_deleted = 'N'
  1806. AND b.is_deleted = 'N'
  1807. AND c.is_deleted = 'N'
  1808. AND d.is_deleted = 'N'
  1809. AND a.hospital_id = b.hospital_id
  1810. AND a.hospital_id = c.hospital_id
  1811. AND a.behospital_code = b.behospital_code
  1812. AND a.behospital_code = c.behospital_code
  1813. AND b.cases_id = c.cases_id
  1814. AND c.cases_id = d.cases_id
  1815. AND c.cases_entry_id = d.id
  1816. <if test="isPlacefile != null and isPlacefile != ''">
  1817. and a.is_placefile = #{isPlacefile}
  1818. </if>
  1819. AND d.cases_id = 243
  1820. AND a.qc_type_id != 0
  1821. <if test="hospitalId != null and hospitalId != ''">
  1822. AND a.hospital_id = #{hospitalId}
  1823. </if>
  1824. <if test="startDate != null and startDate != ''">
  1825. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1826. </if>
  1827. <if test="endDate != null and endDate != ''">
  1828. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1829. </if>
  1830. <if test="level != null and level != ''">
  1831. and b.level = #{level}
  1832. </if>
  1833. <if test="name != null and name != ''">
  1834. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1835. </if>
  1836. GROUP BY
  1837. a.beh_dept_id,
  1838. a.beh_dept_name
  1839. ) h1,(
  1840. SELECT
  1841. count(*) AS entryNum
  1842. FROM
  1843. qc_cases_entry
  1844. WHERE
  1845. is_deleted = 'N'
  1846. AND cases_id = 243
  1847. ) h2
  1848. ) t3
  1849. WHERE
  1850. t1.deptId = t2.deptId
  1851. AND t1.deptId = t3.deptId
  1852. AND t1.deptName = t2.deptName
  1853. AND t1.deptName = t3.deptName
  1854. <if test="asc != null and asc !=''">
  1855. order by
  1856. <choose>
  1857. <when test='asc=="deptId"'>deptId asc</when>
  1858. <when test='asc=="deptName"'>deptName asc</when>
  1859. <when test='asc=="entryNum"'>entryNum asc</when>
  1860. <when test='asc=="mrNum"'>mrNum asc</when>
  1861. <when test='asc=="totleValue"'>totleValue asc</when>
  1862. <when test='asc=="averageValue"'>averageValue asc</when>
  1863. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1864. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1865. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1866. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1867. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1868. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1869. <when test='asc=="emptyNum"'>emptyNum asc</when>
  1870. <when test='asc=="errorNum"'>errorNum asc</when>
  1871. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  1872. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  1873. <when test='asc=="errorPercent"'>errorPercent asc</when>
  1874. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  1875. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  1876. <otherwise>deptName asc</otherwise>
  1877. </choose>
  1878. </if>
  1879. <if test="desc != null and desc!=''">
  1880. order by
  1881. <choose>
  1882. <when test='desc=="deptId"'>deptId desc</when>
  1883. <when test='desc=="deptName"'>deptName desc</when>
  1884. <when test='desc=="entryNum"'>entryNum desc</when>
  1885. <when test='desc=="mrNum"'>mrNum desc</when>
  1886. <when test='desc=="totleValue"'>totleValue desc</when>
  1887. <when test='desc=="averageValue"'>averageValue desc</when>
  1888. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1889. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1890. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1891. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1892. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1893. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1894. <when test='desc=="emptyNum"'>emptyNum desc</when>
  1895. <when test='desc=="errorNum"'>errorNum desc</when>
  1896. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  1897. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  1898. <when test='desc=="errorPercent"'>errorPercent desc</when>
  1899. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  1900. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  1901. <otherwise>deptName desc</otherwise>
  1902. </choose>
  1903. </if>
  1904. </select>
  1905. <!-- 各科室缺陷占比-科室 -->
  1906. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  1907. resultType="com.diagbot.dto.LevelStatisticsDTO">
  1908. SELECT
  1909. t1.doctorId,
  1910. t1.doctorName,
  1911. t2.entryNum,
  1912. t1.mrNum,
  1913. t1.totleValue,
  1914. t1.averageValue,
  1915. t1.firstLevelNum,
  1916. t1.secondLevelNum,
  1917. t1.thirdLevelNum,
  1918. t1.firstLevelPercent,
  1919. t1.secondLevelPercent,
  1920. t1.thirdLevelPercent,
  1921. t1.firstLevelPercentStr,
  1922. t1.secondLevelPercentStr,
  1923. t1.thirdLevelPercentStr
  1924. FROM
  1925. (
  1926. SELECT
  1927. a.doctor_id AS doctorId,
  1928. a.doctor_name AS doctorName,
  1929. count(*) AS mrNum,
  1930. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1931. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1932. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1933. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1934. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1935. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1936. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1937. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1938. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1939. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1940. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1941. FROM
  1942. med_behospital_info a,
  1943. med_qcresult_info c,
  1944. sys_user_dept e
  1945. WHERE
  1946. a.is_deleted = 'N'
  1947. AND c.is_deleted = 'N'
  1948. AND e.is_deleted = 'N'
  1949. AND a.hospital_id = c.hospital_id
  1950. AND a.behospital_code = c.behospital_code
  1951. AND a.beh_dept_id = e.dept_id
  1952. <if test="isPlacefile != null and isPlacefile != ''">
  1953. and a.is_placefile = #{isPlacefile}
  1954. </if>
  1955. <![CDATA[AND a.qc_type_id <>0 ]]>
  1956. <if test="hospitalId != null and hospitalId != ''">
  1957. AND a.hospital_id = #{hospitalId}
  1958. </if>
  1959. <if test="startDate != null and startDate != ''">
  1960. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1961. </if>
  1962. <if test="endDate != null and endDate != ''">
  1963. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1964. </if>
  1965. <if test="level != null and level != ''">
  1966. and c.level = #{level}
  1967. </if>
  1968. <if test="name != null and name != ''">
  1969. and a.doctor_name like CONCAT('%',#{name},'%')
  1970. </if>
  1971. <if test="userId!=null and userId !=''">
  1972. AND e.user_id = #{userId}
  1973. </if>
  1974. <if test="deptName!=null and deptName !=''">
  1975. AND a.beh_dept_name = #{deptName}
  1976. </if>
  1977. GROUP BY
  1978. a.doctor_id,
  1979. a.doctor_name
  1980. ) t1,
  1981. (
  1982. SELECT
  1983. a.doctor_id AS doctorId,
  1984. a.doctor_name AS doctorName,
  1985. count( * ) AS entryNum
  1986. FROM
  1987. med_behospital_info a,
  1988. med_qcresult_info c,
  1989. med_qcresult_detail d,
  1990. qc_cases_entry e,
  1991. sys_user_dept f
  1992. WHERE
  1993. a.is_deleted = 'N'
  1994. AND c.is_deleted = 'N'
  1995. AND d.is_deleted = 'N'
  1996. AND e.is_deleted = 'N'
  1997. AND f.is_deleted = 'N'
  1998. AND a.hospital_id = c.hospital_id
  1999. AND a.hospital_id = d.hospital_id
  2000. AND a.behospital_code = c.behospital_code
  2001. AND a.behospital_code = d.behospital_code
  2002. AND d.cases_id = e.cases_id
  2003. AND d.cases_entry_id = e.id
  2004. AND a.beh_dept_id = f.dept_id
  2005. <if test="isPlacefile != null and isPlacefile != ''">
  2006. and a.is_placefile = #{isPlacefile}
  2007. </if>
  2008. <![CDATA[AND a.qc_type_id <>0 ]]>
  2009. <if test="hospitalId != null and hospitalId != ''">
  2010. AND a.hospital_id = #{hospitalId}
  2011. </if>
  2012. <if test="startDate != null and startDate != ''">
  2013. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2014. </if>
  2015. <if test="endDate != null and endDate != ''">
  2016. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2017. </if>
  2018. <if test="level != null and level != ''">
  2019. and c.level = #{level}
  2020. </if>
  2021. <if test="name != null and name != ''">
  2022. and a.doctor_name like CONCAT('%',#{name},'%')
  2023. </if>
  2024. <if test="userId!=null and userId !=''">
  2025. AND f.user_id = #{userId}
  2026. </if>
  2027. <if test="deptName!=null and deptName !=''">
  2028. AND a.beh_dept_name = #{deptName}
  2029. </if>
  2030. GROUP BY
  2031. a.doctor_id,
  2032. a.doctor_name
  2033. ) t2
  2034. WHERE
  2035. t1.doctorId = t2.doctorId
  2036. AND t1.doctorName = t2.doctorName
  2037. <if test="asc != null and asc !=''">
  2038. order by
  2039. <choose>
  2040. <when test='asc=="doctorId"'>doctorId asc</when>
  2041. <when test='asc=="doctorName"'>doctorName asc</when>
  2042. <when test='asc=="entryNum"'>entryNum asc</when>
  2043. <when test='asc=="mrNum"'>mrNum asc</when>
  2044. <when test='asc=="totleValue"'>totleValue asc</when>
  2045. <when test='asc=="averageValue"'>averageValue asc</when>
  2046. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2047. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2048. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2049. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2050. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2051. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2052. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2053. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2054. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2055. <otherwise>doctorName asc</otherwise>
  2056. </choose>
  2057. </if>
  2058. <if test="desc != null and desc!=''">
  2059. order by
  2060. <choose>
  2061. <when test='desc=="doctorId"'>doctorId desc</when>
  2062. <when test='desc=="doctorName"'>doctorName desc</when>
  2063. <when test='desc=="entryNum"'>entryNum desc</when>
  2064. <when test='desc=="mrNum"'>mrNum desc</when>
  2065. <when test='desc=="totleValue"'>totleValue desc</when>
  2066. <when test='desc=="averageValue"'>averageValue desc</when>
  2067. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2068. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2069. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2070. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2071. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2072. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2073. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2074. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2075. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2076. <otherwise>doctorName desc</otherwise>
  2077. </choose>
  2078. </if>
  2079. </select>
  2080. <!-- 病案首页合格率占比-科室 -->
  2081. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  2082. resultType="com.diagbot.dto.HomePageNumDTO">
  2083. SELECT
  2084. t1.doctorId,
  2085. t1.doctorName,
  2086. t2.entryNum,
  2087. t1.mrNum,
  2088. t1.totleValue,
  2089. t1.averageValue,
  2090. t1.firstLevelNum,
  2091. t1.secondLevelNum,
  2092. t1.firstLevelPercent,
  2093. t1.secondLevelPercent,
  2094. t1.firstLevelPercentStr,
  2095. t1.secondLevelPercentStr,
  2096. t3.emptyNum,
  2097. t3.errorNum,
  2098. t3.entryTotleNum,
  2099. t3.emptyPercent,
  2100. t3.errorPercent,
  2101. t3.emptyPercentStr,
  2102. t3.errorPercentStr
  2103. FROM
  2104. (
  2105. SELECT
  2106. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  2107. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  2108. count( * ) AS mrNum,
  2109. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2110. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2111. sum( c.`level` = '合格' ) AS firstLevelNum,
  2112. sum( c.`level` = '不合格' ) AS secondLevelNum,
  2113. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  2114. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  2115. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2116. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  2117. FROM
  2118. med_behospital_info a,
  2119. med_qcresult_cases c,
  2120. sys_user_dept f
  2121. WHERE
  2122. a.is_deleted = 'N'
  2123. AND c.is_deleted = 'N'
  2124. AND f.is_deleted = 'N'
  2125. AND a.hospital_id = c.hospital_id
  2126. AND a.behospital_code = c.behospital_code
  2127. AND a.beh_dept_id = f.dept_id
  2128. AND c.cases_id = 243
  2129. <if test="isPlacefile != null and isPlacefile != ''">
  2130. and a.is_placefile = #{isPlacefile}
  2131. </if>
  2132. <![CDATA[AND a.qc_type_id <>0 ]]>
  2133. <if test="hospitalId != null and hospitalId != ''">
  2134. AND a.hospital_id = #{hospitalId}
  2135. </if>
  2136. <if test="startDate != null and startDate != ''">
  2137. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2138. </if>
  2139. <if test="endDate != null and endDate != ''">
  2140. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2141. </if>
  2142. <if test="level != null and level != ''">
  2143. and c.level = #{level}
  2144. </if>
  2145. <if test="name != null and name != ''">
  2146. <if test="name == '未知'">
  2147. and (a.doctor_name is null or a.doctor_name='')
  2148. </if>
  2149. <if test="name != '未知'">
  2150. and a.doctor_name like CONCAT('%',#{name},'%')
  2151. </if>
  2152. </if>
  2153. <if test="userId!=null and userId !=''">
  2154. AND f.user_id = #{userId}
  2155. </if>
  2156. <if test="deptName!=null and deptName !=''">
  2157. AND a.beh_dept_name = #{deptName}
  2158. </if>
  2159. GROUP BY
  2160. a.doctor_id,
  2161. a.doctor_name
  2162. ) t1,
  2163. (
  2164. SELECT
  2165. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  2166. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  2167. count( * ) AS entryNum
  2168. FROM
  2169. med_behospital_info a,
  2170. med_qcresult_cases c,
  2171. med_qcresult_detail d,
  2172. qc_cases_entry e,
  2173. sys_user_dept f
  2174. WHERE
  2175. a.is_deleted = 'N'
  2176. AND c.is_deleted = 'N'
  2177. AND d.is_deleted = 'N'
  2178. AND e.is_deleted = 'N'
  2179. AND f.is_deleted = 'N'
  2180. AND a.hospital_id = c.hospital_id
  2181. AND a.hospital_id = d.hospital_id
  2182. AND a.behospital_code = c.behospital_code
  2183. AND a.behospital_code = d.behospital_code
  2184. AND a.beh_dept_id = f.dept_id
  2185. AND c.cases_id = d.cases_id
  2186. AND d.cases_id = e.cases_id
  2187. AND d.cases_entry_id = e.id
  2188. AND c.cases_id = 243
  2189. <if test="isPlacefile != null and isPlacefile != ''">
  2190. and a.is_placefile = #{isPlacefile}
  2191. </if>
  2192. <![CDATA[AND a.qc_type_id <>0 ]]>
  2193. <if test="hospitalId != null and hospitalId != ''">
  2194. AND a.hospital_id = #{hospitalId}
  2195. </if>
  2196. <if test="startDate != null and startDate != ''">
  2197. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2198. </if>
  2199. <if test="endDate != null and endDate != ''">
  2200. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2201. </if>
  2202. <if test="level != null and level != ''">
  2203. and c.level = #{level}
  2204. </if>
  2205. <if test="name != null and name != ''">
  2206. <if test="name == '未知'">
  2207. and (a.doctor_name is null or a.doctor_name='')
  2208. </if>
  2209. <if test="name != '未知'">
  2210. and a.doctor_name like CONCAT('%',#{name},'%')
  2211. </if>
  2212. </if>
  2213. <if test="userId!=null and userId !=''">
  2214. AND f.user_id = #{userId}
  2215. </if>
  2216. <if test="deptName!=null and deptName !=''">
  2217. AND a.beh_dept_name = #{deptName}
  2218. </if>
  2219. GROUP BY
  2220. a.doctor_id,
  2221. a.doctor_name
  2222. ) t2,(
  2223. SELECT
  2224. h1.doctorId,
  2225. h1.doctorName,
  2226. h1.emptyNum,
  2227. h1.errorNum,
  2228. h1.mrNum,
  2229. h2.entryNum,
  2230. h1.mrNum * h2.entryNum AS entryTotleNum,
  2231. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  2232. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  2233. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  2234. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  2235. FROM
  2236. (
  2237. SELECT
  2238. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  2239. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  2240. sum( d.rule_type = 1 ) AS emptyNum,
  2241. sum( d.rule_type = 2 ) AS errorNum,
  2242. count( DISTINCT a.behospital_code ) AS mrNum
  2243. FROM
  2244. med_behospital_info a,
  2245. med_qcresult_cases b,
  2246. med_qcresult_detail c,
  2247. qc_cases_entry d,
  2248. sys_user_dept e
  2249. WHERE
  2250. a.is_deleted = 'N'
  2251. AND b.is_deleted = 'N'
  2252. AND c.is_deleted = 'N'
  2253. AND d.is_deleted = 'N'
  2254. AND e.is_deleted = 'N'
  2255. AND a.hospital_id = b.hospital_id
  2256. AND a.hospital_id = c.hospital_id
  2257. AND a.hospital_id = e.hospital_id
  2258. AND a.behospital_code = b.behospital_code
  2259. AND a.behospital_code = c.behospital_code
  2260. AND b.cases_id = c.cases_id
  2261. AND c.cases_id = d.cases_id
  2262. AND c.cases_entry_id = d.id
  2263. AND a.beh_dept_id = e.dept_id
  2264. <if test="isPlacefile != null and isPlacefile != ''">
  2265. and a.is_placefile = #{isPlacefile}
  2266. </if>
  2267. AND d.cases_id = 243
  2268. <![CDATA[AND a.qc_type_id <>0 ]]>
  2269. <if test="hospitalId != null and hospitalId != ''">
  2270. AND a.hospital_id = #{hospitalId}
  2271. </if>
  2272. <if test="startDate != null and startDate != ''">
  2273. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2274. </if>
  2275. <if test="endDate != null and endDate != ''">
  2276. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2277. </if>
  2278. <if test="level != null and level != ''">
  2279. and b.level = #{level}
  2280. </if>
  2281. <if test="name != null and name != ''">
  2282. <if test="name == '未知'">
  2283. and (a.doctor_name is null or a.doctor_name='')
  2284. </if>
  2285. <if test="name != '未知'">
  2286. and a.doctor_name like CONCAT('%',#{name},'%')
  2287. </if>
  2288. </if>
  2289. <if test="userId!=null and userId !=''">
  2290. AND e.user_id = #{userId}
  2291. </if>
  2292. <if test="deptName!=null and deptName !=''">
  2293. AND a.beh_dept_name = #{deptName}
  2294. </if>
  2295. GROUP BY
  2296. a.doctor_id,
  2297. a.doctor_name
  2298. ) h1,(
  2299. SELECT
  2300. count(*) AS entryNum
  2301. FROM
  2302. qc_cases_entry
  2303. WHERE
  2304. is_deleted = 'N'
  2305. AND cases_id = 243
  2306. ) h2
  2307. ) t3
  2308. WHERE
  2309. t1.doctorId = t2.doctorId
  2310. AND t1.doctorId = t3.doctorId
  2311. AND t1.doctorName = t2.doctorName
  2312. AND t1.doctorName = t3.doctorName
  2313. <if test="asc != null and asc !=''">
  2314. order by
  2315. <choose>
  2316. <when test='asc=="doctorId"'>doctorId asc</when>
  2317. <when test='asc=="doctorName"'>doctorName asc</when>
  2318. <when test='asc=="entryNum"'>entryNum asc</when>
  2319. <when test='asc=="mrNum"'>mrNum asc</when>
  2320. <when test='asc=="totleValue"'>totleValue asc</when>
  2321. <when test='asc=="averageValue"'>averageValue asc</when>
  2322. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2323. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2324. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2325. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2326. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2327. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2328. <when test='asc=="emptyNum"'>emptyNum asc</when>
  2329. <when test='asc=="errorNum"'>errorNum asc</when>
  2330. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  2331. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  2332. <when test='asc=="errorPercent"'>errorPercent asc</when>
  2333. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  2334. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  2335. <otherwise>doctorName asc</otherwise>
  2336. </choose>
  2337. </if>
  2338. <if test="desc != null and desc!=''">
  2339. order by
  2340. <choose>
  2341. <when test='desc=="doctorId"'>doctorId desc</when>
  2342. <when test='desc=="doctorName"'>doctorName desc</when>
  2343. <when test='desc=="entryNum"'>entryNum desc</when>
  2344. <when test='desc=="mrNum"'>mrNum desc</when>
  2345. <when test='desc=="totleValue"'>totleValue desc</when>
  2346. <when test='desc=="averageValue"'>averageValue desc</when>
  2347. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2348. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2349. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2350. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2351. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2352. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2353. <when test='desc=="emptyNum"'>emptyNum desc</when>
  2354. <when test='desc=="errorNum"'>errorNum desc</when>
  2355. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  2356. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  2357. <when test='desc=="errorPercent"'>errorPercent desc</when>
  2358. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  2359. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  2360. <otherwise>doctorName desc</otherwise>
  2361. </choose>
  2362. </if>
  2363. </select>
  2364. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  2365. <result column="behDeptName" property="behDeptName"/>
  2366. <result column="avgScore" property="avgScore"/>
  2367. <collection property="excelBehospitalDTOS"
  2368. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  2369. <result column="behDoctorName" property="behDoctorName"/>
  2370. <result column="patName" property="patName"/>
  2371. <result column="behospitalCode" property="behospitalCode"/>
  2372. <result column="behospitalDate" property="behospitalDate"/>
  2373. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  2374. <result column="score" property="score"/>
  2375. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  2376. <result column="caseName" property="caseName"/>
  2377. <collection property="exportExcelMsgDTOS"
  2378. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  2379. <result column="msg" property="msg"/>
  2380. </collection>
  2381. </collection>
  2382. </collection>
  2383. </resultMap>
  2384. <select id="exportExcel" resultMap="ExportExcelMap">
  2385. SELECT DISTINCT
  2386. t1.beh_dept_name AS behDeptName,
  2387. t1.beh_doctor_name AS behDoctorName,
  2388. t1.`name` AS patName,
  2389. t1.behospital_code AS behospitalCode,
  2390. t1.behospital_date AS behospitalDate,
  2391. t1.leave_hospital_date AS leaveHospitalDate,
  2392. t2.score_res AS score,
  2393. "1" AS avgScore,
  2394. t4.`name` AS caseName,
  2395. t3.msg AS msg
  2396. FROM
  2397. med_behospital_info t1,
  2398. med_qcresult_info t2,
  2399. med_qcresult_detail t3,
  2400. qc_cases t4
  2401. WHERE
  2402. t1.is_deleted = 'N'
  2403. AND t2.is_deleted = 'N'
  2404. AND t3.is_deleted = 'N'
  2405. AND t4.is_deleted = 'N'
  2406. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  2407. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  2408. AND t1.hospital_id = t2.hospital_id
  2409. AND t1.behospital_code = t2.behospital_code
  2410. AND t1.hospital_id = t3.hospital_id
  2411. AND t1.behospital_code = t3.behospital_code
  2412. AND t3.cases_id = t4.id
  2413. ORDER BY
  2414. t1.beh_dept_id ASC,
  2415. t1.leave_hospital_date DESC,
  2416. t1.behospital_code ASC,
  2417. t4.`name` ASC
  2418. </select>
  2419. <!-- 质控评分导出到excel-->
  2420. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2421. SELECT * FROM (
  2422. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  2423. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  2424. g.check_type AS ch_type,
  2425. h.check_type AS mr_type,
  2426. g.check_name AS ch_name,
  2427. h.check_name AS mr_name,
  2428. g.check_time AS ch_time,
  2429. h.check_time AS mr_time
  2430. FROM (
  2431. SELECT
  2432. t1.behDeptId,
  2433. t1.behDeptName,
  2434. t1.behDoctorName,
  2435. t1.patName,
  2436. t1.behospitalCode,
  2437. t1.hospitalId,
  2438. t1.behospitalDate,
  2439. t1.leaveHospitalDate,
  2440. t1.score,
  2441. t2.avgScore,
  2442. t1.msg,
  2443. t1.caseName
  2444. FROM
  2445. (
  2446. SELECT
  2447. CONCAT(
  2448. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  2449. a.doctor_name
  2450. ) AS behDoctorName,
  2451. a.`name` AS patName,
  2452. a.behospital_code AS behospitalCode,
  2453. a.behospital_date AS behospitalDate,
  2454. a.leave_hospital_date AS leaveHospitalDate,
  2455. b.score_res AS score,
  2456. c.msg AS msg,
  2457. d.NAME AS caseName,
  2458. a.beh_dept_id AS behDeptId,
  2459. a.beh_dept_name AS behDeptName,
  2460. a.hospital_id AS hospitalId
  2461. FROM
  2462. med_behospital_info a,
  2463. med_qcresult_info b,
  2464. med_qcresult_detail c,
  2465. qc_cases d
  2466. WHERE
  2467. a.is_deleted = 'N'
  2468. AND b.is_deleted = 'N'
  2469. AND c.is_deleted = 'N'
  2470. AND d.is_deleted = 'N'
  2471. AND a.hospital_id = b.hospital_id
  2472. AND a.hospital_id = c.hospital_id
  2473. AND a.behospital_code = b.behospital_code
  2474. AND a.behospital_code = c.behospital_code
  2475. AND c.cases_id = d.id
  2476. <if test="isPlacefile != null and isPlacefile != ''">
  2477. and a.is_placefile = #{isPlacefile}
  2478. </if>
  2479. <![CDATA[AND a.qc_type_id <>0 ]]>
  2480. <if test="hospitalId != null and hospitalId != ''">
  2481. AND a.hospital_id = #{hospitalId}
  2482. </if>
  2483. <if test="leaveHosDateStart != null ">
  2484. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2485. </if>
  2486. <if test="leaveHosDateEnd != null ">
  2487. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2488. </if>
  2489. <if test="behospitalCode != null and behospitalCode != ''">
  2490. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2491. </if>
  2492. <if test="level != null and level != ''">
  2493. AND b.level = #{level}
  2494. </if>
  2495. <if test="doctorName != null and doctorName != ''">
  2496. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2497. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2498. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2499. </if>
  2500. <if test="doctorCode != null and doctorCode != ''">
  2501. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2502. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2503. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2504. </if>
  2505. <if test="deptId != null and deptId != ''">
  2506. AND a.beh_dept_id = #{deptId}
  2507. </if>
  2508. <if test="name != null and name != ''">
  2509. AND a.name like CONCAT('%',#{name},'%')
  2510. </if>
  2511. ) t1,
  2512. (
  2513. SELECT
  2514. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2515. a.beh_dept_id AS behDeptId,
  2516. a.beh_dept_name AS behDeptName
  2517. FROM
  2518. med_behospital_info a,
  2519. med_qcresult_info b
  2520. WHERE
  2521. a.is_deleted = 'N'
  2522. AND b.is_deleted = 'N'
  2523. AND a.hospital_id = b.hospital_id
  2524. AND a.behospital_code = b.behospital_code
  2525. <if test="isPlacefile != null and isPlacefile != ''">
  2526. and a.is_placefile = #{isPlacefile}
  2527. </if>
  2528. <![CDATA[AND a.qc_type_id <>0 ]]>
  2529. <if test="hospitalId != null and hospitalId != ''">
  2530. AND a.hospital_id = #{hospitalId}
  2531. </if>
  2532. <if test="leaveHosDateStart != null ">
  2533. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2534. </if>
  2535. <if test="leaveHosDateEnd != null ">
  2536. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2537. </if>
  2538. <if test="behospitalCode != null and behospitalCode != ''">
  2539. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2540. </if>
  2541. <if test="level != null and level != ''">
  2542. AND b.level = #{level}
  2543. </if>
  2544. <if test="doctorName != null and doctorName != ''">
  2545. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2546. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2547. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2548. </if>
  2549. <if test="doctorCode != null and doctorCode != ''">
  2550. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2551. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2552. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2553. </if>
  2554. <if test="deptId != null and deptId != ''">
  2555. AND a.beh_dept_id = #{deptId}
  2556. </if>
  2557. <if test="name != null and name != ''">
  2558. AND a.name like CONCAT('%',#{name},'%')
  2559. </if>
  2560. GROUP BY
  2561. a.beh_dept_id,
  2562. a.beh_dept_name
  2563. ) t2
  2564. WHERE
  2565. t1.behDeptId = t2.behDeptId
  2566. AND t1.behDeptName = t2.behDeptName
  2567. ORDER BY
  2568. t1.behDeptName,
  2569. t1.behDoctorName,
  2570. t1.patName,
  2571. t1.behospitalCode,
  2572. t1.caseName)tp
  2573. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  2574. ON tp.behospitalCode = g.behospital_code
  2575. AND tp.hospitalId = g.hospital_id
  2576. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  2577. ON tp.behospitalCode = h.behospital_code
  2578. AND tp.hospitalId = h.hospital_id
  2579. ) tu
  2580. WHERE tu.behospitalCode IS NOT NULL
  2581. <if test="checkStatus != null ">
  2582. and tu.check_status = #{checkStatus}
  2583. </if>
  2584. <if test="mrStatus != null ">
  2585. AND tu.mr_status = #{mrStatus}
  2586. </if>
  2587. <if test="chName != null and chName !=''">
  2588. AND tu.ch_name like CONCAT('%',#{chName},'%')
  2589. </if>
  2590. <if test="mrName != null and mrName !=''">
  2591. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  2592. </if>
  2593. <if test="chTimeStart != null">
  2594. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  2595. </if>
  2596. <if test="chTimeEnd != null">
  2597. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  2598. </if>
  2599. <if test="mrTimeStart != null">
  2600. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  2601. </if>
  2602. <if test="mrTimeEnd != null">
  2603. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  2604. </if>
  2605. </select>
  2606. <!-- 科室质控评分导出到excel-->
  2607. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2608. SELECT * FROM (
  2609. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  2610. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  2611. g.check_type AS ch_type,
  2612. h.check_type AS mr_type,
  2613. g.check_name AS ch_name,
  2614. h.check_name AS mr_name,
  2615. g.check_time AS ch_time,
  2616. h.check_time AS mr_time
  2617. FROM (
  2618. SELECT
  2619. t1.behDeptId,
  2620. t1.behDeptName,
  2621. t1.behDoctorName,
  2622. t1.patName,
  2623. t1.behospitalCode,
  2624. t1.hospitalId,
  2625. t1.behospitalDate,
  2626. t1.leaveHospitalDate,
  2627. t1.score,
  2628. t2.avgScore,
  2629. t1.msg,
  2630. t1.caseName
  2631. FROM
  2632. (
  2633. SELECT
  2634. CONCAT(
  2635. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  2636. a.doctor_name
  2637. ) AS behDoctorName,
  2638. a.`name` AS patName,
  2639. a.behospital_code AS behospitalCode,
  2640. a.behospital_date AS behospitalDate,
  2641. a.leave_hospital_date AS leaveHospitalDate,
  2642. b.score_res AS score,
  2643. c.msg AS msg,
  2644. d.NAME AS caseName,
  2645. a.beh_dept_id AS behDeptId,
  2646. a.beh_dept_name AS behDeptName,
  2647. a.hospital_id AS hospitalId
  2648. FROM
  2649. med_behospital_info a,
  2650. med_qcresult_info b,
  2651. med_qcresult_detail c,
  2652. qc_cases d,
  2653. sys_user_dept e
  2654. WHERE
  2655. a.is_deleted = 'N'
  2656. AND b.is_deleted = 'N'
  2657. AND c.is_deleted = 'N'
  2658. AND d.is_deleted = 'N'
  2659. AND e.is_deleted = 'N'
  2660. AND a.hospital_id = b.hospital_id
  2661. AND a.hospital_id = c.hospital_id
  2662. AND a.hospital_id = e.hospital_id
  2663. AND a.behospital_code = b.behospital_code
  2664. AND a.behospital_code = c.behospital_code
  2665. AND c.cases_id = d.id
  2666. AND a.beh_dept_id = e.dept_id
  2667. <if test="isPlacefile != null and isPlacefile != ''">
  2668. and a.is_placefile = #{isPlacefile}
  2669. </if>
  2670. <![CDATA[AND a.qc_type_id <>0 ]]>
  2671. <if test="hospitalId != null and hospitalId != ''">
  2672. AND a.hospital_id = #{hospitalId}
  2673. </if>
  2674. <if test="userId != null ">
  2675. AND e.user_id = #{userId}
  2676. </if>
  2677. <if test="leaveHosDateStart != null ">
  2678. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2679. </if>
  2680. <if test="leaveHosDateEnd != null ">
  2681. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2682. </if>
  2683. <if test="behospitalCode != null and behospitalCode != ''">
  2684. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2685. </if>
  2686. <if test="level != null and level != ''">
  2687. AND b.level = #{level}
  2688. </if>
  2689. <if test="doctorName != null and doctorName != ''">
  2690. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2691. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2692. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2693. </if>
  2694. <if test="doctorCode != null and doctorCode != ''">
  2695. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2696. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2697. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2698. </if>
  2699. <if test="deptId != null and deptId != ''">
  2700. AND a.beh_dept_id = #{deptId}
  2701. </if>
  2702. <if test="name != null and name != ''">
  2703. AND a.name like CONCAT('%',#{name},'%')
  2704. </if>
  2705. ) t1,
  2706. (
  2707. SELECT
  2708. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2709. a.beh_dept_id AS behDeptId,
  2710. a.beh_dept_name AS behDeptName
  2711. FROM
  2712. med_behospital_info a,
  2713. med_qcresult_info b,
  2714. sys_user_dept c
  2715. WHERE
  2716. a.is_deleted = 'N'
  2717. AND b.is_deleted = 'N'
  2718. AND c.is_deleted = 'N'
  2719. AND a.hospital_id = b.hospital_id
  2720. AND a.hospital_id = c.hospital_id
  2721. AND a.behospital_code = b.behospital_code
  2722. AND a.beh_dept_id = c.dept_id
  2723. <if test="isPlacefile != null and isPlacefile != ''">
  2724. and a.is_placefile = #{isPlacefile}
  2725. </if>
  2726. <![CDATA[AND a.qc_type_id <>0 ]]>
  2727. <if test="hospitalId != null and hospitalId != ''">
  2728. AND a.hospital_id = #{hospitalId}
  2729. </if>
  2730. <if test="userId != null ">
  2731. AND c.user_id = #{userId}
  2732. </if>
  2733. <if test="leaveHosDateStart != null ">
  2734. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2735. </if>
  2736. <if test="leaveHosDateEnd != null ">
  2737. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2738. </if>
  2739. <if test="behospitalCode != null and behospitalCode != ''">
  2740. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2741. </if>
  2742. <if test="level != null and level != ''">
  2743. AND b.level = #{level}
  2744. </if>
  2745. <if test="doctorName != null and doctorName != ''">
  2746. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2747. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2748. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2749. </if>
  2750. <if test="doctorCode != null and doctorCode != ''">
  2751. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2752. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2753. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2754. </if>
  2755. <if test="deptId != null and deptId != ''">
  2756. AND a.beh_dept_id = #{deptId}
  2757. </if>
  2758. <if test="name != null and name != ''">
  2759. AND a.name like CONCAT('%',#{name},'%')
  2760. </if>
  2761. GROUP BY
  2762. a.beh_dept_id,
  2763. a.beh_dept_name
  2764. ) t2
  2765. WHERE
  2766. t1.behDeptId = t2.behDeptId
  2767. AND t1.behDeptName = t2.behDeptName
  2768. ORDER BY
  2769. t1.behDeptName,
  2770. t1.behDoctorName,
  2771. t1.patName,
  2772. t1.behospitalCode,
  2773. t1.caseName)tp
  2774. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  2775. ON tp.behospitalCode = g.behospital_code
  2776. AND tp.hospitalId = g.hospital_id
  2777. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  2778. ON tp.behospitalCode = h.behospital_code
  2779. AND tp.hospitalId = h.hospital_id
  2780. ) tu
  2781. WHERE tu.behospitalCode IS NOT NULL
  2782. <if test="checkStatus != null ">
  2783. and tu.check_status = #{checkStatus}
  2784. </if>
  2785. <if test="mrStatus != null ">
  2786. AND tu.mr_status = #{mrStatus}
  2787. </if>
  2788. <if test="chName != null and chName !=''">
  2789. AND tu.ch_name like CONCAT('%',#{chName},'%')
  2790. </if>
  2791. <if test="mrName != null and mrName !=''">
  2792. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  2793. </if>
  2794. <if test="chTimeStart != null">
  2795. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  2796. </if>
  2797. <if test="chTimeEnd != null">
  2798. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  2799. </if>
  2800. <if test="mrTimeStart != null">
  2801. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  2802. </if>
  2803. <if test="mrTimeEnd != null">
  2804. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  2805. </if>
  2806. </select>
  2807. <!-- 医疗组质控评分导出到excel-->
  2808. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2809. SELECT * FROM (
  2810. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  2811. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  2812. g.check_type AS ch_type,
  2813. h.check_type AS mr_type,
  2814. g.check_name AS ch_name,
  2815. h.check_name AS mr_name,
  2816. g.check_time AS ch_time,
  2817. h.check_time AS mr_time
  2818. FROM (
  2819. SELECT
  2820. t1.behDeptId,
  2821. t1.behDeptName,
  2822. t1.behDoctorName,
  2823. t1.patName,
  2824. t1.behospitalCode,
  2825. t1.hospitalId,
  2826. t1.behospitalDate,
  2827. t1.leaveHospitalDate,
  2828. t1.score,
  2829. t2.avgScore,
  2830. t1.msg,
  2831. t1.caseName
  2832. FROM
  2833. (
  2834. SELECT
  2835. CONCAT(
  2836. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  2837. a.doctor_name
  2838. ) AS behDoctorName,
  2839. a.`name` AS patName,
  2840. a.behospital_code AS behospitalCode,
  2841. a.behospital_date AS behospitalDate,
  2842. a.leave_hospital_date AS leaveHospitalDate,
  2843. b.score_res AS score,
  2844. c.msg AS msg,
  2845. d.NAME AS caseName,
  2846. a.beh_dept_id AS behDeptId,
  2847. a.beh_dept_name AS behDeptName,
  2848. a.hospital_id AS hospitalId
  2849. FROM
  2850. med_behospital_info a,
  2851. med_qcresult_info b,
  2852. med_qcresult_detail c,
  2853. qc_cases d
  2854. WHERE
  2855. a.is_deleted = 'N'
  2856. AND b.is_deleted = 'N'
  2857. AND c.is_deleted = 'N'
  2858. AND d.is_deleted = 'N'
  2859. AND a.hospital_id = b.hospital_id
  2860. AND a.hospital_id = c.hospital_id
  2861. AND a.behospital_code = b.behospital_code
  2862. AND a.behospital_code = c.behospital_code
  2863. AND c.cases_id = d.id
  2864. <if test="isPlacefile != null and isPlacefile != ''">
  2865. and a.is_placefile = #{isPlacefile}
  2866. </if>
  2867. AND a.doctor_id in
  2868. (SELECT doctor_id FROM `bas_doctor_info`
  2869. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  2870. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  2871. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  2872. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  2873. and c1.username = c3.doctor_id
  2874. and c2.hospital_id = #{hospitalId}
  2875. and c1.id = #{userId}
  2876. ))
  2877. <![CDATA[AND a.qc_type_id <>0 ]]>
  2878. <if test="hospitalId != null and hospitalId != ''">
  2879. AND a.hospital_id = #{hospitalId}
  2880. </if>
  2881. <if test="leaveHosDateStart != null ">
  2882. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2883. </if>
  2884. <if test="leaveHosDateEnd != null ">
  2885. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2886. </if>
  2887. <if test="behospitalCode != null and behospitalCode != ''">
  2888. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2889. </if>
  2890. <if test="level != null and level != ''">
  2891. AND b.level = #{level}
  2892. </if>
  2893. <if test="doctorName != null and doctorName != ''">
  2894. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2895. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2896. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2897. </if>
  2898. <if test="doctorCode != null and doctorCode != ''">
  2899. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2900. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2901. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2902. </if>
  2903. <if test="deptId != null and deptId != ''">
  2904. AND a.beh_dept_id = #{deptId}
  2905. </if>
  2906. <if test="name != null and name != ''">
  2907. AND a.name like CONCAT('%',#{name},'%')
  2908. </if>
  2909. ) t1,
  2910. (
  2911. SELECT
  2912. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2913. a.beh_dept_id AS behDeptId,
  2914. a.beh_dept_name AS behDeptName
  2915. FROM
  2916. med_behospital_info a,
  2917. med_qcresult_info b
  2918. WHERE
  2919. a.is_deleted = 'N'
  2920. AND a.doctor_id in
  2921. (SELECT doctor_id FROM `bas_doctor_info`
  2922. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  2923. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  2924. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  2925. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  2926. and c1.username = c3.doctor_id
  2927. and c2.hospital_id = #{hospitalId}
  2928. and c1.id = #{userId}
  2929. ))
  2930. AND b.is_deleted = 'N'
  2931. AND a.hospital_id = b.hospital_id
  2932. AND a.behospital_code = b.behospital_code
  2933. <if test="isPlacefile != null and isPlacefile != ''">
  2934. and a.is_placefile = #{isPlacefile}
  2935. </if>
  2936. <![CDATA[AND a.qc_type_id <>0 ]]>
  2937. <if test="hospitalId != null and hospitalId != ''">
  2938. AND a.hospital_id = #{hospitalId}
  2939. </if>
  2940. <if test="leaveHosDateStart != null ">
  2941. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2942. </if>
  2943. <if test="leaveHosDateEnd != null ">
  2944. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2945. </if>
  2946. <if test="behospitalCode != null and behospitalCode != ''">
  2947. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2948. </if>
  2949. <if test="level != null and level != ''">
  2950. AND b.level = #{level}
  2951. </if>
  2952. <if test="doctorName != null and doctorName != ''">
  2953. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2954. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2955. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2956. </if>
  2957. <if test="doctorCode != null and doctorCode != ''">
  2958. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2959. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2960. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2961. </if>
  2962. <if test="deptId != null and deptId != ''">
  2963. AND a.beh_dept_id = #{deptId}
  2964. </if>
  2965. <if test="name != null and name != ''">
  2966. AND a.name like CONCAT('%',#{name},'%')
  2967. </if>
  2968. GROUP BY
  2969. a.beh_dept_id,
  2970. a.beh_dept_name
  2971. ) t2
  2972. WHERE
  2973. t1.behDeptId = t2.behDeptId
  2974. AND t1.behDeptName = t2.behDeptName
  2975. ORDER BY
  2976. t1.behDeptName,
  2977. t1.behDoctorName,
  2978. t1.patName,
  2979. t1.behospitalCode,
  2980. t1.caseName)tp
  2981. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  2982. ON tp.behospitalCode = g.behospital_code
  2983. AND tp.hospitalId = g.hospital_id
  2984. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  2985. ON tp.behospitalCode = h.behospital_code
  2986. AND tp.hospitalId = h.hospital_id
  2987. ) tu
  2988. WHERE tu.behospitalCode IS NOT NULL
  2989. <if test="checkStatus != null ">
  2990. and tu.check_status = #{checkStatus}
  2991. </if>
  2992. <if test="mrStatus != null ">
  2993. AND tu.mr_status = #{mrStatus}
  2994. </if>
  2995. <if test="chName != null and chName !=''">
  2996. AND tu.ch_name like CONCAT('%',#{chName},'%')
  2997. </if>
  2998. <if test="mrName != null and mrName !=''">
  2999. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  3000. </if>
  3001. <if test="chTimeStart != null">
  3002. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  3003. </if>
  3004. <if test="chTimeEnd != null">
  3005. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  3006. </if>
  3007. <if test="mrTimeStart != null">
  3008. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  3009. </if>
  3010. <if test="mrTimeEnd != null">
  3011. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  3012. </if>
  3013. </select>
  3014. <!-- 条目缺陷质控评分页(内页)-->
  3015. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  3016. SELECT t.*
  3017. FROM
  3018. (SELECT DISTINCT
  3019. t1.hospital_id AS hospitalId,
  3020. t1.behospital_code AS behospitalCode,
  3021. t1.bed_code AS bedCode,
  3022. t1.LEVEL AS LEVEL,
  3023. t1.grade_type AS gradeType,
  3024. t1.score_res AS scoreRes,
  3025. t1.NAME AS NAME,
  3026. t1.sex AS sex,
  3027. t1.beh_dept_id AS behDeptId,
  3028. t1.beh_dept_name AS behDeptName,
  3029. t1.doctor_id AS doctorId,
  3030. t1.doctor_name AS doctorName,
  3031. t1.beh_doctor_id AS behDoctorId,
  3032. t1.beh_doctor_name AS behDoctorName,
  3033. t1.director_doctor_id AS directorDoctorId,
  3034. t1.director_doctor_name AS directorDoctorName,
  3035. t1.birthday AS birthday,
  3036. t1.behospital_date AS behospitalDate,
  3037. t1.leave_hospital_date AS leaveHospitalDate,
  3038. t1.placefile_date AS placefileDate,
  3039. t1.gmt_create AS gradeTime,
  3040. t1.diagnose,
  3041. t1.ward_name AS wardName,
  3042. t2.age,
  3043. t1.file_code AS fileCode,
  3044. t1.checkStatus,
  3045. t1.mrStatus,
  3046. t1.chName,
  3047. t1.mrName,
  3048. t1.chTime,
  3049. t1.mrTime
  3050. FROM
  3051. (
  3052. SELECT DISTINCT
  3053. tt1.*
  3054. FROM
  3055. (SELECT
  3056. be.*,
  3057. ifnull(mci.status,0) AS checkStatus,
  3058. ifnull(hm_mci.status,0) AS mrStatus,
  3059. mci.check_name as chName,
  3060. hm_mci.check_name as mrName,
  3061. mci.gmt_create as chTime,
  3062. hm_mci.gmt_create as mrTime
  3063. FROM
  3064. (
  3065. SELECT DISTINCT
  3066. a.hospital_id,
  3067. a.behospital_code,
  3068. a.bed_code,
  3069. a.file_code,
  3070. b.LEVEL,
  3071. b.grade_type,
  3072. b.score_res,
  3073. a.NAME,
  3074. a.sex,
  3075. a.beh_dept_id,
  3076. a.beh_dept_name,
  3077. a.birthday,
  3078. a.behospital_date,
  3079. a.leave_hospital_date,
  3080. a.doctor_id,
  3081. a.doctor_name,
  3082. a.beh_doctor_id,
  3083. a.beh_doctor_name,
  3084. a.director_doctor_id,
  3085. a.director_doctor_name,
  3086. a.diagnose,
  3087. a.placefile_date,
  3088. a.ward_name,
  3089. b.gmt_create
  3090. FROM
  3091. med_behospital_info a,
  3092. med_qcresult_info b,
  3093. med_qcresult_detail c,
  3094. qc_cases_entry d
  3095. WHERE
  3096. a.is_deleted = 'N'
  3097. AND b.is_deleted = 'N'
  3098. AND c.is_deleted = 'N'
  3099. AND d.is_deleted = 'N'
  3100. AND a.hospital_id = b.hospital_id
  3101. AND a.hospital_id = c.hospital_id
  3102. AND a.behospital_code = b.behospital_code
  3103. AND a.behospital_code = c.behospital_code
  3104. AND c.cases_id = d.cases_id
  3105. AND c.cases_entry_id = d.id
  3106. AND a.qc_type_id != 0
  3107. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  3108. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  3109. </if>
  3110. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3111. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3112. </if>
  3113. <if test="qcResultShortPageVO.startDate != null ">
  3114. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  3115. </if>
  3116. <if test="qcResultShortPageVO.endDate != null ">
  3117. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  3118. </if>
  3119. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  3120. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  3121. </if>
  3122. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  3123. AND b.`level` = #{qcResultShortPageVO.level}
  3124. </if>
  3125. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3126. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3127. </if>
  3128. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3129. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3130. </if>
  3131. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  3132. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  3133. </if>
  3134. <if test="qcResultShortPageVO.casesEntryId != null ">
  3135. AND d.id = #{qcResultShortPageVO.casesEntryId}
  3136. </if>
  3137. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  3138. AND d.cases_name = #{qcResultShortPageVO.casesName}
  3139. </if>
  3140. <if test="qcResultShortPageVO.casesId != null">
  3141. AND d.cases_id = #{qcResultShortPageVO.casesId}
  3142. </if>
  3143. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3144. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3145. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3146. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3147. </if>
  3148. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3149. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3150. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3151. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3152. </if>
  3153. <if test="qcResultShortPageVO.isReject != null">
  3154. AND c.is_reject = #{qcResultShortPageVO.isReject}
  3155. </if>
  3156. <if test="qcResultShortPageVO.ruleType != null">
  3157. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  3158. </if>
  3159. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  3160. AND TIMESTAMPDIFF(
  3161. DAY,
  3162. DATE( a.behospital_date ),
  3163. DATE( a.leave_hospital_date ))> 30
  3164. </if>
  3165. )be
  3166. left join med_check_info mci
  3167. on mci.is_deleted = 'N'
  3168. and mci.check_type = 0
  3169. and be.hospital_id = mci.hospital_id
  3170. and be.behospital_code = mci.behospital_code
  3171. left join med_check_info hm_mci
  3172. on hm_mci.is_deleted = 'N'
  3173. and hm_mci.check_type = 1
  3174. and be.hospital_id = hm_mci.hospital_id
  3175. and be.behospital_code = hm_mci.behospital_code
  3176. )tt1
  3177. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  3178. ,med_medical_record tt2
  3179. WHERE
  3180. tt2.is_deleted = 'N'
  3181. AND tt1.hospital_id = tt2.hospital_id
  3182. AND tt1.behospital_code = tt2.behospital_code
  3183. AND tt2.mode_id = 30
  3184. </if>
  3185. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  3186. ,med_crisis_info tt2
  3187. WHERE
  3188. tt2.is_deleted = 'N'
  3189. AND tt1.hospital_id = tt2.hospital_id
  3190. AND tt1.behospital_code = tt2.behospital_code
  3191. </if>
  3192. ) t1
  3193. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  3194. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  3195. AND t1.behospital_code = t2.behospital_code
  3196. AND t2.is_deleted = 'N'
  3197. </if>
  3198. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  3199. , med_home_page t2
  3200. , med_home_operation_info t3
  3201. WHERE t1.hospital_id = t2.hospital_id
  3202. AND t1.behospital_code = t2.behospital_code
  3203. AND t2.home_page_id = t3.home_page_id
  3204. AND t2.is_deleted = 'N'
  3205. AND t3.is_deleted = 'N'
  3206. </if>
  3207. ) t
  3208. where 1=1
  3209. <if test="qcResultShortPageVO.checkStatus != null">
  3210. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  3211. </if>
  3212. <if test="qcResultShortPageVO.mrStatus != null">
  3213. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  3214. </if>
  3215. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  3216. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  3217. </if>
  3218. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  3219. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  3220. </if>
  3221. <if test="qcResultShortPageVO.chTimeStart != null ">
  3222. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  3223. </if>
  3224. <if test="qcResultShortPageVO.chTimeEnd != null ">
  3225. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  3226. </if>
  3227. <if test="qcResultShortPageVO.mrTimeStart != null ">
  3228. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  3229. </if>
  3230. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  3231. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  3232. </if>
  3233. </select>
  3234. <!-- 条目缺陷质控评分页-科室(内页)-->
  3235. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  3236. SELECT DISTINCT
  3237. t1.hospital_id AS hospitalId,
  3238. t1.behospital_code AS behospitalCode,
  3239. t1.bed_code AS bedCode,
  3240. t1.LEVEL AS LEVEL,
  3241. t1.grade_type AS gradeType,
  3242. t1.score_res AS scoreRes,
  3243. t1.NAME AS NAME,
  3244. t1.sex AS sex,
  3245. t1.beh_dept_id AS behDeptId,
  3246. t1.beh_dept_name AS behDeptName,
  3247. t1.doctor_id AS doctorId,
  3248. t1.doctor_name AS doctorName,
  3249. t1.beh_doctor_id AS behDoctorId,
  3250. t1.beh_doctor_name AS behDoctorName,
  3251. t1.director_doctor_id AS directorDoctorId,
  3252. t1.director_doctor_name AS directorDoctorName,
  3253. t1.birthday AS birthday,
  3254. t1.behospital_date AS behospitalDate,
  3255. t1.leave_hospital_date AS leaveHospitalDate,
  3256. t1.placefile_date AS placefileDate,
  3257. t1.gmt_create AS gradeTime,
  3258. t1.diagnose,
  3259. t1.ward_name AS wardName,
  3260. t2.age,
  3261. t1.file_code AS fileCode
  3262. FROM
  3263. (
  3264. SELECT DISTINCT
  3265. a.hospital_id,
  3266. a.behospital_code,
  3267. a.bed_code,
  3268. a.file_code,
  3269. b.LEVEL,
  3270. b.grade_type,
  3271. b.score_res,
  3272. a.NAME,
  3273. a.sex,
  3274. a.beh_dept_id,
  3275. a.beh_dept_name,
  3276. a.birthday,
  3277. a.behospital_date,
  3278. a.leave_hospital_date,
  3279. a.doctor_id,
  3280. a.doctor_name,
  3281. a.beh_doctor_id,
  3282. a.beh_doctor_name,
  3283. a.director_doctor_id,
  3284. a.director_doctor_name,
  3285. a.diagnose,
  3286. a.placefile_date,
  3287. a.ward_name,
  3288. b.gmt_create
  3289. FROM
  3290. med_behospital_info a,
  3291. med_qcresult_info b,
  3292. med_qcresult_detail c,
  3293. qc_cases_entry d,
  3294. sys_user_dept e
  3295. WHERE
  3296. a.is_deleted = 'N'
  3297. AND b.is_deleted = 'N'
  3298. AND c.is_deleted = 'N'
  3299. AND d.is_deleted = 'N'
  3300. AND e.is_deleted = 'N'
  3301. AND a.hospital_id = b.hospital_id
  3302. AND a.hospital_id = c.hospital_id
  3303. AND a.hospital_id = e.hospital_id
  3304. AND a.behospital_code = b.behospital_code
  3305. AND a.behospital_code = c.behospital_code
  3306. AND a.beh_dept_id = e.dept_id
  3307. AND c.cases_id = d.cases_id
  3308. AND c.cases_entry_id = d.id
  3309. AND a.qc_type_id != 0
  3310. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  3311. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  3312. </if>
  3313. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  3314. AND e.user_id = #{qcResultShortPageVO.userId}
  3315. </if>
  3316. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3317. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3318. </if>
  3319. <if test="qcResultShortPageVO.startDate != null ">
  3320. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  3321. </if>
  3322. <if test="qcResultShortPageVO.endDate != null ">
  3323. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  3324. </if>
  3325. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  3326. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  3327. </if>
  3328. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3329. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  3330. </if>
  3331. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3332. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3333. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3334. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3335. </if>
  3336. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3337. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3338. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3339. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3340. </if>
  3341. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  3342. AND b.`level` = #{qcResultShortPageVO.level}
  3343. </if>
  3344. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3345. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3346. </if>
  3347. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3348. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3349. </if>
  3350. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  3351. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  3352. </if>
  3353. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  3354. AND d.id = #{qcResultShortPageVO.casesEntryId}
  3355. </if>
  3356. <if test="qcResultShortPageVO.isReject != null">
  3357. AND c.is_reject = #{qcResultShortPageVO.isReject}
  3358. </if>
  3359. <if test="qcResultShortPageVO.ruleType != null">
  3360. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  3361. </if>
  3362. ) t1
  3363. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  3364. AND t1.behospital_code = t2.behospital_code
  3365. AND t2.is_deleted = 'N'
  3366. </select>
  3367. <update id="updateBatchByKey">
  3368. <foreach collection="list" item="item" separator=";">
  3369. update med_behospital_info
  3370. <set>
  3371. <if test="item.name != null">
  3372. name = #{item.name},
  3373. </if>
  3374. <if test="item.sex != null">
  3375. sex = #{item.sex},
  3376. </if>
  3377. <if test="item.birthday != null">
  3378. birthday = #{item.birthday},
  3379. </if>
  3380. <if test="item.fileCode != null">
  3381. file_code = #{item.fileCode},
  3382. </if>
  3383. <if test="item.qcTypeId != null">
  3384. qc_type_id = #{item.qcTypeId},
  3385. </if>
  3386. <if test="item.wardCode != null">
  3387. ward_code = #{item.wardCode},
  3388. </if>
  3389. <if test="item.wardName != null">
  3390. ward_name = #{item.wardName},
  3391. </if>
  3392. <if test="item.behDeptId != null">
  3393. beh_dept_id = #{item.behDeptId},
  3394. </if>
  3395. <if test="item.behDeptName != null">
  3396. beh_dept_name = #{item.behDeptName},
  3397. </if>
  3398. <if test="item.bedCode != null">
  3399. bed_code = #{item.bedCode},
  3400. </if>
  3401. <if test="item.bedName != null">
  3402. bed_name = #{item.bedName},
  3403. </if>
  3404. <if test="item.insuranceName != null">
  3405. insurance_name = #{item.insuranceName},
  3406. </if>
  3407. <if test="item.jobType != null">
  3408. job_type = #{item.jobType},
  3409. </if>
  3410. <if test="item.behospitalDate != null">
  3411. behospital_date = #{item.behospitalDate},
  3412. </if>
  3413. <if test="item.leaveHospitalDate != null">
  3414. leave_hospital_date = #{item.leaveHospitalDate},
  3415. </if>
  3416. <if test="item.diagnoseIcd != null">
  3417. diagnose_icd = #{item.diagnoseIcd},
  3418. </if>
  3419. <if test="item.diagnose != null">
  3420. diagnose = #{item.diagnose},
  3421. </if>
  3422. <if test="item.behDoctorId != null">
  3423. beh_doctor_id = #{item.behDoctorId},
  3424. </if>
  3425. <if test="item.behDoctorName != null">
  3426. beh_doctor_name = #{item.behDoctorName},
  3427. </if>
  3428. <if test="item.doctorId != null">
  3429. doctor_id = #{item.doctorId},
  3430. </if>
  3431. <if test="item.doctorName != null">
  3432. doctor_name = #{item.doctorName},
  3433. </if>
  3434. <if test="item.directorDoctorId != null">
  3435. director_doctor_id = #{item.directorDoctorId},
  3436. </if>
  3437. <if test="item.directorDoctorName != null">
  3438. director_doctor_name = #{item.directorDoctorName},
  3439. </if>
  3440. <if test="item.placefileDate != null">
  3441. placefile_date = #{item.placefileDate},
  3442. </if>
  3443. <if test="item.isPlacefile != null">
  3444. is_placefile = #{item.isPlacefile},
  3445. </if>
  3446. <if test="item.gmtModified != null">
  3447. gmt_modified = #{item.gmtModified},
  3448. </if>
  3449. <if test="item.modifier != null">
  3450. modifier = #{item.modifier},
  3451. </if>
  3452. </set>
  3453. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  3454. </foreach>
  3455. </update>
  3456. <!-- 关键条目缺陷统计报表-->
  3457. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  3458. SELECT
  3459. deptId,
  3460. deptName,
  3461. consultationMRNum,
  3462. consultationNum,
  3463. 2511 AS consultationEntryId,
  3464. '普通会诊未在24小时内完成' AS consultationEntryName,
  3465. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  3466. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  3467. operationMRNum,
  3468. 2594 AS operationNameEntryId,
  3469. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  3470. operationNameNum,
  3471. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  3472. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  3473. 2973 AS operationTimeEntryId,
  3474. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  3475. operationTimeNum,
  3476. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  3477. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  3478. 2930 AS operation15MinuteEntryId,
  3479. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  3480. operation15MinuteNum,
  3481. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  3482. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  3483. 2419 AS crisisEntryId,
  3484. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  3485. crisisMRNum,
  3486. crisisNum,
  3487. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  3488. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  3489. 2495 AS stageSummaryEntryId,
  3490. '无阶段小结' AS stageSummaryEntryName,
  3491. stageSummaryMRNum,
  3492. stageSummaryNum,
  3493. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  3494. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr
  3495. FROM
  3496. (
  3497. SELECT
  3498. tt.deptId,
  3499. tt.deptName,
  3500. sum( tt.consultationNum ) AS consultationNum,
  3501. sum( tt.consultationMRNum ) AS consultationMRNum,
  3502. sum( tt.operationNameNum ) AS operationNameNum,
  3503. sum( tt.operationTimeNum ) AS operationTimeNum,
  3504. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  3505. sum( tt.operationMRNum ) AS operationMRNum,
  3506. sum( tt.crisisNum ) AS crisisNum,
  3507. sum( tt.crisisMRNum ) AS crisisMRNum,
  3508. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  3509. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum
  3510. FROM
  3511. (
  3512. (
  3513. SELECT
  3514. c.beh_dept_id AS deptId,
  3515. c.beh_dept_name AS deptName,
  3516. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  3517. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  3518. 0 AS operationNameNum,
  3519. 0 AS operationTimeNum,
  3520. 0 AS operation15MinuteNum,
  3521. 0 AS operationMRNum,
  3522. 0 AS crisisNum,
  3523. 0 AS crisisMRNum,
  3524. 0 AS stageSummaryNum,
  3525. 0 AS stageSummaryMRNum
  3526. FROM
  3527. (
  3528. SELECT DISTINCT
  3529. a.hospital_id,
  3530. a.behospital_code,
  3531. a.beh_dept_name,
  3532. a.beh_dept_id
  3533. FROM
  3534. med_behospital_info a,
  3535. med_medical_record b
  3536. WHERE
  3537. a.is_deleted = 'N'
  3538. AND b.is_deleted = 'N'
  3539. AND a.hospital_id = b.hospital_id
  3540. AND a.behospital_code = b.behospital_code
  3541. AND b.mode_id = 30
  3542. <if test="isPlacefile != null and isPlacefile != ''">
  3543. and a.is_placefile = #{isPlacefile}
  3544. </if>
  3545. AND a.qc_type_id != 0
  3546. <if test="hospitalId != null and hospitalId != ''">
  3547. AND a.hospital_id = #{hospitalId}
  3548. </if>
  3549. <if test="startDate != null">
  3550. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3551. </if>
  3552. <if test="endDate != null">
  3553. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3554. </if>
  3555. <if test="deptName != null and deptName != ''">
  3556. AND a.beh_dept_name = #{deptName}
  3557. </if>
  3558. ) c
  3559. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  3560. AND c.hospital_id = d.hospital_id
  3561. AND c.behospital_code = d.behospital_code
  3562. GROUP BY
  3563. c.beh_dept_id,
  3564. c.beh_dept_name
  3565. ) UNION
  3566. (
  3567. SELECT
  3568. d.beh_dept_id AS deptId,
  3569. d.beh_dept_name AS deptName,
  3570. 0 AS consultationNum,
  3571. 0 AS consultationMRNum,
  3572. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  3573. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  3574. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  3575. count( DISTINCT d.behospital_code ) AS operationMRNum,
  3576. 0 AS crisisNum,
  3577. 0 AS crisisMRNum,
  3578. 0 AS stageSummaryNum,
  3579. 0 AS stageSummaryMRNum
  3580. FROM
  3581. (
  3582. SELECT DISTINCT
  3583. a.hospital_id,
  3584. a.behospital_code,
  3585. a.beh_dept_name,
  3586. a.beh_dept_id
  3587. FROM
  3588. med_behospital_info a,
  3589. med_home_page b,
  3590. med_home_operation_info c
  3591. WHERE
  3592. a.is_deleted = 'N'
  3593. AND b.is_deleted = 'N'
  3594. AND c.is_deleted = 'N'
  3595. AND a.hospital_id = b.hospital_id
  3596. AND a.hospital_id = c.hospital_id
  3597. AND a.behospital_code = b.behospital_code
  3598. AND b.home_page_id = c.home_page_id
  3599. <if test="isPlacefile != null and isPlacefile != ''">
  3600. and a.is_placefile = #{isPlacefile}
  3601. </if>
  3602. AND a.qc_type_id != 0
  3603. <if test="hospitalId != null and hospitalId != ''">
  3604. AND a.hospital_id = #{hospitalId}
  3605. </if>
  3606. <if test="startDate != null">
  3607. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3608. </if>
  3609. <if test="endDate != null">
  3610. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3611. </if>
  3612. <if test="deptName != null and deptName != ''">
  3613. AND a.beh_dept_name = #{deptName}
  3614. </if>
  3615. ) d
  3616. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  3617. AND d.hospital_id = e.hospital_id
  3618. AND d.behospital_code = e.behospital_code
  3619. GROUP BY
  3620. d.beh_dept_id,
  3621. d.beh_dept_name
  3622. ) UNION
  3623. (
  3624. SELECT
  3625. c.beh_dept_id AS deptId,
  3626. c.beh_dept_name AS deptName,
  3627. 0 AS consultationNum,
  3628. 0 AS consultationMRNum,
  3629. 0 AS operationNameNum,
  3630. 0 AS operationTimeNum,
  3631. 0 AS operation15MinuteNum,
  3632. 0 AS operationMRNum,
  3633. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  3634. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  3635. 0 AS stageSummaryNum,
  3636. 0 AS stageSummaryMRNum
  3637. FROM
  3638. (
  3639. SELECT DISTINCT
  3640. a.hospital_id,
  3641. a.behospital_code,
  3642. a.beh_dept_name,
  3643. a.beh_dept_id
  3644. FROM
  3645. med_behospital_info a,
  3646. med_crisis_info b
  3647. WHERE
  3648. a.is_deleted = 'N'
  3649. AND b.is_deleted = 'N'
  3650. AND a.hospital_id = b.hospital_id
  3651. AND a.behospital_code = b.behospital_code
  3652. <if test="isPlacefile != null and isPlacefile != ''">
  3653. and a.is_placefile = #{isPlacefile}
  3654. </if>
  3655. AND a.qc_type_id != 0
  3656. <if test="hospitalId != null and hospitalId != ''">
  3657. AND a.hospital_id = #{hospitalId}
  3658. </if>
  3659. <if test="startDate != null">
  3660. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3661. </if>
  3662. <if test="endDate != null">
  3663. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3664. </if>
  3665. <if test="deptName != null and deptName != ''">
  3666. AND a.beh_dept_name = #{deptName}
  3667. </if>
  3668. ) c
  3669. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  3670. AND c.hospital_id = d.hospital_id
  3671. AND c.behospital_code = d.behospital_code
  3672. GROUP BY
  3673. c.beh_dept_id,
  3674. c.beh_dept_name
  3675. ) UNION
  3676. (
  3677. SELECT
  3678. b.beh_dept_id AS deptId,
  3679. b.beh_dept_name AS deptName,
  3680. 0 AS consultationNum,
  3681. 0 AS consultationMRNum,
  3682. 0 AS operationNameNum,
  3683. 0 AS operationTimeNum,
  3684. 0 AS operation15MinuteNum,
  3685. 0 AS operationMRNum,
  3686. 0 AS crisisNum,
  3687. 0 AS crisisMRNum,
  3688. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  3689. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum
  3690. FROM
  3691. (
  3692. SELECT DISTINCT
  3693. a.hospital_id,
  3694. a.behospital_code,
  3695. a.beh_dept_name,
  3696. a.beh_dept_id
  3697. FROM
  3698. med_behospital_info a
  3699. WHERE
  3700. a.is_deleted = 'N'
  3701. AND TIMESTAMPDIFF(
  3702. DAY,
  3703. DATE( behospital_date ),
  3704. DATE( leave_hospital_date ))> 30
  3705. <if test="isPlacefile != null and isPlacefile != ''">
  3706. and a.is_placefile = #{isPlacefile}
  3707. </if>
  3708. AND a.qc_type_id != 0
  3709. <if test="hospitalId != null and hospitalId != ''">
  3710. AND a.hospital_id = #{hospitalId}
  3711. </if>
  3712. <if test="startDate != null">
  3713. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3714. </if>
  3715. <if test="endDate != null">
  3716. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3717. </if>
  3718. <if test="deptName != null and deptName != ''">
  3719. AND a.beh_dept_name = #{deptName}
  3720. </if>
  3721. ) b
  3722. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  3723. AND b.hospital_id = c.hospital_id
  3724. AND b.behospital_code = c.behospital_code
  3725. GROUP BY
  3726. b.beh_dept_id,
  3727. b.beh_dept_name
  3728. )
  3729. ) tt
  3730. GROUP BY
  3731. tt.deptId,
  3732. tt.deptName
  3733. ) t
  3734. <if test="asc != null and asc !=''">
  3735. order by
  3736. <choose>
  3737. <when test='asc=="deptId"'>deptId asc</when>
  3738. <when test='asc=="deptName"'>deptName asc</when>
  3739. <when test='asc=="consultationNum"'>consultationNum asc</when>
  3740. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  3741. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  3742. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  3743. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  3744. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  3745. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  3746. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  3747. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  3748. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  3749. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  3750. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  3751. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  3752. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  3753. <when test='asc=="crisisNum"'>crisisNum asc</when>
  3754. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  3755. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  3756. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  3757. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  3758. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  3759. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  3760. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  3761. <otherwise>deptName asc</otherwise>
  3762. </choose>
  3763. </if>
  3764. <if test="desc != null and desc!=''">
  3765. order by
  3766. <choose>
  3767. <when test='desc=="deptId"'>deptId desc</when>
  3768. <when test='desc=="deptName"'>deptName desc</when>
  3769. <when test='desc=="consultationNum"'>consultationNum desc</when>
  3770. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  3771. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  3772. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  3773. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  3774. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  3775. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  3776. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  3777. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  3778. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  3779. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  3780. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  3781. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  3782. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  3783. <when test='desc=="crisisNum"'>crisisNum desc</when>
  3784. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  3785. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  3786. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  3787. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  3788. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  3789. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  3790. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  3791. <otherwise>deptName desc</otherwise>
  3792. </choose>
  3793. </if>
  3794. </select>
  3795. <!-- 非医嘱离院病人记录-->
  3796. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  3797. SELECT
  3798. count(*)
  3799. FROM
  3800. med_behospital_info a,
  3801. med_home_page b
  3802. WHERE
  3803. a.is_deleted = 'N'
  3804. AND b.is_deleted = 'N'
  3805. AND a.hospital_id = b.hospital_id
  3806. AND a.behospital_code = b.behospital_code
  3807. AND b.leave_hospital_type = '非医嘱离院'
  3808. <if test="isPlacefile != null and isPlacefile != ''">
  3809. and a.is_placefile = #{isPlacefile}
  3810. </if>
  3811. AND a.qc_type_id != 0
  3812. <if test="hospitalId != null and hospitalId != ''">
  3813. AND a.hospital_id = #{hospitalId}
  3814. </if>
  3815. <if test="startDate != null and startDate != ''">
  3816. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3817. </if>
  3818. <if test="endDate != null and endDate != ''">
  3819. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3820. </if>
  3821. </select>
  3822. <!-- 31天内再入院记录-->
  3823. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  3824. SELECT
  3825. count(*)
  3826. FROM
  3827. (
  3828. SELECT
  3829. r1.file_code,
  3830. r1.diagnose,
  3831. r1.behospital_code AS behospitalCode,
  3832. r1.behospital_date AS behospitalDate,
  3833. r1.leave_hospital_date AS leaveHospitalDate,
  3834. r2.behospital_code AS lastBehospitalCode,
  3835. r2.behospital_date AS lastBehospitalDate,
  3836. r2.leave_hospital_date AS lastLeaveHospitalDate,
  3837. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  3838. FROM
  3839. (
  3840. SELECT
  3841. ( @rownum := @rownum + 1 ) AS rownum,
  3842. t1.file_code,
  3843. t1.diagnose,
  3844. t1.behospital_code,
  3845. t1.behospital_date,
  3846. t1.leave_hospital_date
  3847. FROM
  3848. (
  3849. SELECT
  3850. tt1.file_code,
  3851. tt1.diagnose,
  3852. tt2.behospital_code,
  3853. tt2.behospital_date,
  3854. tt2.leave_hospital_date
  3855. FROM
  3856. (
  3857. SELECT
  3858. a.file_code,
  3859. a.diagnose
  3860. FROM
  3861. med_behospital_info a
  3862. WHERE
  3863. a.is_deleted = 'N'
  3864. <if test="isPlacefile != null and isPlacefile != ''">
  3865. and a.is_placefile = #{isPlacefile}
  3866. </if>
  3867. AND a.qc_type_id != 0
  3868. AND IFNULL( a.diagnose, '' )!= ''
  3869. AND IFNULL( a.file_code, '' )!= ''
  3870. <if test="hospitalId != null and hospitalId != ''">
  3871. AND a.hospital_id = #{hospitalId}
  3872. </if>
  3873. <if test="startDate != null and startDate != ''">
  3874. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3875. </if>
  3876. <if test="endDate != null and endDate != ''">
  3877. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3878. </if>
  3879. GROUP BY
  3880. a.file_code,
  3881. a.diagnose
  3882. HAVING
  3883. count(*)> 1
  3884. ) tt1,
  3885. med_behospital_info tt2
  3886. WHERE
  3887. tt2.is_deleted = 'N'
  3888. <if test="isPlacefile != null and isPlacefile != ''">
  3889. and tt2.is_placefile = #{isPlacefile}
  3890. </if>
  3891. AND tt2.qc_type_id != 0
  3892. AND tt1.file_code = tt2.file_code
  3893. AND tt1.diagnose = tt2.diagnose
  3894. <if test="hospitalId != null and hospitalId != ''">
  3895. AND tt2.hospital_id = #{hospitalId}
  3896. </if>
  3897. <if test="startDate != null and startDate != ''">
  3898. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  3899. </if>
  3900. <if test="endDate != null and endDate != ''">
  3901. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  3902. </if>
  3903. ORDER BY
  3904. tt1.file_code,
  3905. tt1.diagnose,
  3906. tt2.behospital_date DESC
  3907. ) t1,
  3908. ( SELECT @rownum := 0 ) r
  3909. ) r1
  3910. LEFT JOIN (
  3911. SELECT
  3912. ( @INDEX := @INDEX + 1 ) AS rownum,
  3913. t2.file_code,
  3914. t2.diagnose,
  3915. t2.behospital_code,
  3916. t2.behospital_date,
  3917. t2.leave_hospital_date
  3918. FROM
  3919. (
  3920. SELECT
  3921. tt1.file_code,
  3922. tt1.diagnose,
  3923. tt2.behospital_code,
  3924. tt2.behospital_date,
  3925. tt2.leave_hospital_date
  3926. FROM
  3927. (
  3928. SELECT
  3929. a.file_code,
  3930. a.diagnose
  3931. FROM
  3932. med_behospital_info a
  3933. WHERE
  3934. a.is_deleted = 'N'
  3935. <if test="isPlacefile != null and isPlacefile != ''">
  3936. and a.is_placefile = #{isPlacefile}
  3937. </if>
  3938. AND a.qc_type_id != 0
  3939. AND IFNULL( a.diagnose, '' )!= ''
  3940. AND IFNULL( a.file_code, '' )!= ''
  3941. <if test="hospitalId != null and hospitalId != ''">
  3942. AND a.hospital_id = #{hospitalId}
  3943. </if>
  3944. <if test="startDate != null and startDate != ''">
  3945. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3946. </if>
  3947. <if test="endDate != null and endDate != ''">
  3948. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3949. </if>
  3950. GROUP BY
  3951. a.file_code,
  3952. a.diagnose
  3953. HAVING
  3954. count(*)> 1
  3955. ) tt1,
  3956. med_behospital_info tt2
  3957. WHERE
  3958. tt2.is_deleted = 'N'
  3959. <if test="isPlacefile != null and isPlacefile != ''">
  3960. and tt2.is_placefile = #{isPlacefile}
  3961. </if>
  3962. AND tt2.qc_type_id != 0
  3963. AND tt1.file_code = tt2.file_code
  3964. AND tt1.diagnose = tt2.diagnose
  3965. <if test="hospitalId != null and hospitalId != ''">
  3966. AND tt2.hospital_id = #{hospitalId}
  3967. </if>
  3968. <if test="startDate != null and startDate != ''">
  3969. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  3970. </if>
  3971. <if test="endDate != null and endDate != ''">
  3972. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  3973. </if>
  3974. ORDER BY
  3975. tt1.file_code,
  3976. tt1.diagnose,
  3977. tt2.behospital_date DESC
  3978. ) t2,(
  3979. SELECT
  3980. @INDEX := 0
  3981. ) r
  3982. ) r2 ON r1.file_code = r2.file_code
  3983. AND r1.rownum = r2.rownum - 1
  3984. ) t
  3985. WHERE
  3986. t.diffDays IS NOT NULL
  3987. AND t.diffDays BETWEEN 0
  3988. AND 31
  3989. </select>
  3990. <!-- 病案首页质控病历数统计-全院(首页)-->
  3991. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  3992. SELECT
  3993. count( * ) AS mrNum,
  3994. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3995. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3996. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3997. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3998. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3999. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  4000. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  4001. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  4002. FROM
  4003. med_behospital_info a,
  4004. med_qcresult_cases c
  4005. WHERE
  4006. a.is_deleted = 'N'
  4007. AND c.is_deleted = 'N'
  4008. AND a.hospital_id = c.hospital_id
  4009. AND a.behospital_code = c.behospital_code
  4010. AND c.cases_id = 243
  4011. <if test="isPlacefile != null and isPlacefile != ''">
  4012. and a.is_placefile = #{isPlacefile}
  4013. </if>
  4014. AND a.qc_type_id != 0
  4015. <if test="hospitalId != null and hospitalId != ''">
  4016. AND a.hospital_id = #{hospitalId}
  4017. </if>
  4018. <if test="startDate != null and startDate != ''">
  4019. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4020. </if>
  4021. <if test="endDate != null and endDate != ''">
  4022. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4023. </if>
  4024. </select>
  4025. <!-- 病案首页完整率统计-全院(首页)-->
  4026. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  4027. SELECT
  4028. h1.emptyNum,
  4029. h1.mrNum,
  4030. h2.entryNum,
  4031. h1.mrNum * h2.entryNum AS entryTotleNum,
  4032. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  4033. CONCAT(
  4034. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  4035. '%'
  4036. ) AS emptyPercentStr
  4037. FROM
  4038. (
  4039. SELECT
  4040. sum( d.rule_type = 1 ) AS emptyNum,
  4041. count( DISTINCT a.behospital_code ) AS mrNum
  4042. FROM
  4043. med_behospital_info a,
  4044. med_qcresult_cases b,
  4045. med_qcresult_detail c,
  4046. qc_cases_entry d
  4047. WHERE
  4048. a.is_deleted = 'N'
  4049. AND b.is_deleted = 'N'
  4050. AND c.is_deleted = 'N'
  4051. AND d.is_deleted = 'N'
  4052. AND a.hospital_id = b.hospital_id
  4053. AND a.hospital_id = c.hospital_id
  4054. AND a.behospital_code = b.behospital_code
  4055. AND a.behospital_code = c.behospital_code
  4056. AND b.cases_id = c.cases_id
  4057. AND c.cases_id = d.cases_id
  4058. AND c.cases_entry_id = d.id
  4059. <if test="isPlacefile != null and isPlacefile != ''">
  4060. and a.is_placefile = #{isPlacefile}
  4061. </if>
  4062. AND d.cases_id = 243
  4063. AND a.qc_type_id != 0
  4064. <if test="hospitalId != null and hospitalId != ''">
  4065. AND a.hospital_id = #{hospitalId}
  4066. </if>
  4067. <if test="startDate != null and startDate != ''">
  4068. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4069. </if>
  4070. <if test="endDate != null and endDate != ''">
  4071. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4072. </if>
  4073. ) h1,(
  4074. SELECT
  4075. count(*) AS entryNum
  4076. FROM
  4077. qc_cases_entry
  4078. WHERE
  4079. is_deleted = 'N'
  4080. AND cases_id = 243
  4081. ) h2
  4082. </select>
  4083. <!-- 离院病人评分详情页-->
  4084. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  4085. SELECT
  4086. t.*
  4087. FROM
  4088. (SELECT DISTINCT
  4089. t1.hospital_id AS hospitalId,
  4090. t1.behospital_code AS behospitalCode,
  4091. t1.bed_code AS bedCode,
  4092. t1.LEVEL AS LEVEL,
  4093. t1.grade_type AS gradeType,
  4094. t1.score_res AS scoreRes,
  4095. t1.NAME AS NAME,
  4096. t1.sex AS sex,
  4097. t1.beh_dept_id AS behDeptId,
  4098. t1.beh_dept_name AS behDeptName,
  4099. t1.doctor_id AS doctorId,
  4100. t1.doctor_name AS doctorName,
  4101. t1.beh_doctor_id AS behDoctorId,
  4102. t1.beh_doctor_name AS behDoctorName,
  4103. t1.director_doctor_id AS directorDoctorId,
  4104. t1.director_doctor_name AS directorDoctorName,
  4105. t1.birthday AS birthday,
  4106. t1.behospital_date AS behospitalDate,
  4107. t1.leave_hospital_date AS leaveHospitalDate,
  4108. t1.placefile_date AS placefileDate,
  4109. t1.gmt_create AS gradeTime,
  4110. t1.diagnose,
  4111. t1.ward_name AS wardName,
  4112. t1.checkStatus,
  4113. t1.mrStatus,
  4114. t1.chName,
  4115. t1.mrName,
  4116. t1.chTime,
  4117. t1.mrTime,
  4118. t2.age,
  4119. t1.file_code AS fileCode
  4120. FROM
  4121. (
  4122. SELECT be.*,
  4123. ifnull(mci.status,0) AS checkStatus,
  4124. ifnull(hm_mci.status,0) AS mrStatus,
  4125. mci.check_name as chName,
  4126. hm_mci.check_name as mrName,
  4127. mci.gmt_create as chTime,
  4128. hm_mci.gmt_create as mrTime
  4129. FROM
  4130. (
  4131. SELECT DISTINCT
  4132. tt1.*
  4133. FROM
  4134. (
  4135. SELECT
  4136. b.*,
  4137. ifnull(c.LEVEL,'未评分') as LEVEL ,
  4138. c.grade_type,
  4139. c.score_res,
  4140. c.gmt_create
  4141. FROM
  4142. (
  4143. SELECT DISTINCT
  4144. a.hospital_id,
  4145. a.behospital_code,
  4146. a.bed_code,
  4147. a.NAME,
  4148. a.sex,
  4149. a.beh_dept_id,
  4150. a.beh_dept_name,
  4151. a.birthday,
  4152. a.behospital_date,
  4153. a.leave_hospital_date,
  4154. a.doctor_id,
  4155. a.doctor_name,
  4156. a.beh_doctor_id,
  4157. a.beh_doctor_name,
  4158. a.director_doctor_id,
  4159. a.director_doctor_name,
  4160. a.diagnose,
  4161. a.placefile_date,
  4162. a.ward_name,
  4163. a.file_code
  4164. FROM
  4165. med_behospital_info a
  4166. WHERE
  4167. a.is_deleted = 'N'
  4168. AND a.qc_type_id != 0
  4169. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  4170. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  4171. </if>
  4172. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4173. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4174. </if>
  4175. <if test="qcResultShortPageVO.startDate != null">
  4176. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  4177. </if>
  4178. <if test="qcResultShortPageVO.endDate != null ">
  4179. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  4180. </if>
  4181. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4182. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4183. </if>
  4184. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4185. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4186. </if>
  4187. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4188. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4189. </if>
  4190. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4191. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4192. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4193. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4194. </if>
  4195. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4196. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4197. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4198. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4199. </if>
  4200. ) b
  4201. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  4202. AND b.hospital_id = c.hospital_id
  4203. AND b.behospital_code = c.behospital_code
  4204. ) tt1
  4205. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  4206. ,med_medical_record tt2,
  4207. qc_mode tt3
  4208. WHERE
  4209. tt2.is_deleted = 'N'
  4210. AND tt3.is_deleted = 'N'
  4211. AND tt1.hospital_id = tt2.hospital_id
  4212. AND tt1.behospital_code = tt2.behospital_code
  4213. AND tt2.mode_id = tt3.id
  4214. AND tt3.`name` = '手术记录'
  4215. </if>
  4216. ) be
  4217. left join med_check_info mci
  4218. on mci.is_deleted = 'N'
  4219. and mci.check_type = 0
  4220. and be.hospital_id = mci.hospital_id
  4221. and be.behospital_code = mci.behospital_code
  4222. left join med_check_info hm_mci
  4223. on hm_mci.is_deleted = 'N'
  4224. and hm_mci.check_type = 1
  4225. and be.hospital_id = hm_mci.hospital_id
  4226. and be.behospital_code = hm_mci.behospital_code
  4227. )t1
  4228. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  4229. ,med_home_page t2
  4230. WHERE
  4231. t2.is_deleted = 'N'
  4232. AND t1.hospital_id = t2.hospital_id
  4233. AND t1.behospital_code = t2.behospital_code
  4234. AND (
  4235. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  4236. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  4237. )
  4238. </if>
  4239. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  4240. ,med_home_page t2
  4241. WHERE
  4242. t2.is_deleted = 'N'
  4243. AND t1.hospital_id = t2.hospital_id
  4244. AND t1.behospital_code = t2.behospital_code
  4245. AND t2.return_to_type = '死亡'
  4246. </if>
  4247. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  4248. ,med_home_page t2
  4249. WHERE
  4250. t2.is_deleted = 'N'
  4251. AND t1.hospital_id = t2.hospital_id
  4252. AND t1.behospital_code = t2.behospital_code
  4253. AND t2.leave_hospital_type = '非医嘱离院'
  4254. </if>
  4255. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  4256. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  4257. AND t1.hospital_id = t2.hospital_id
  4258. AND t1.behospital_code = t2.behospital_code
  4259. </if>
  4260. )t
  4261. where 1=1
  4262. <if test="qcResultShortPageVO.checkStatus != null">
  4263. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  4264. </if>
  4265. <if test="qcResultShortPageVO.mrStatus != null">
  4266. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  4267. </if>
  4268. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  4269. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  4270. </if>
  4271. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  4272. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  4273. </if>
  4274. <if test="qcResultShortPageVO.chTimeStart != null ">
  4275. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  4276. </if>
  4277. <if test="qcResultShortPageVO.chTimeEnd != null ">
  4278. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  4279. </if>
  4280. <if test="qcResultShortPageVO.mrTimeStart != null ">
  4281. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  4282. </if>
  4283. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  4284. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  4285. </if>
  4286. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  4287. AND t.`level` = #{qcResultShortPageVO.level}
  4288. </if>
  4289. </select>
  4290. <!-- 病案首页改善率统计(首页)-->
  4291. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  4292. SELECT
  4293. t2.homePageMRNum,
  4294. t1.improveNum,
  4295. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  4296. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  4297. t1.improveToPassNum,
  4298. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  4299. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  4300. t1.improveToFullNum,
  4301. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  4302. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  4303. FROM
  4304. (
  4305. SELECT
  4306. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  4307. sum( d.score_res = 20 ) AS improveToFullNum,
  4308. count(*) AS improveNum
  4309. FROM
  4310. med_behospital_info a,
  4311. med_home_page b,
  4312. med_qcresult_info c,
  4313. med_qcresult_cases d,
  4314. (
  4315. SELECT
  4316. m4.*
  4317. FROM
  4318. med_behospital_info m1,
  4319. med_home_page m2,
  4320. med_qcresult_info m3,
  4321. med_qcresult_cases m4
  4322. WHERE
  4323. m1.is_deleted = 'N'
  4324. AND m2.is_deleted = 'N'
  4325. AND m3.is_deleted = 'Y'
  4326. AND m4.is_deleted = 'Y'
  4327. AND m1.hospital_id = m2.hospital_id
  4328. AND m1.hospital_id = m3.hospital_id
  4329. AND m1.hospital_id = m4.hospital_id
  4330. AND m1.behospital_code = m2.behospital_code
  4331. AND m1.behospital_code = m3.behospital_code
  4332. AND m1.behospital_code = m4.behospital_code
  4333. AND m3.gmt_create = m4.gmt_create
  4334. AND m3.have_home_page = 1
  4335. AND m4.cases_id = 243
  4336. <if test="isPlacefile != null and isPlacefile != ''">
  4337. and m1.is_placefile = #{isPlacefile}
  4338. </if>
  4339. AND m1.qc_type_id != 0
  4340. <if test="hospitalId != null and hospitalId != ''">
  4341. AND m1.hospital_id = #{hospitalId}
  4342. </if>
  4343. <if test="startDate != null and startDate != ''">
  4344. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  4345. </if>
  4346. <if test="endDate != null and endDate != ''">
  4347. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  4348. </if>
  4349. GROUP BY
  4350. m1.behospital_code
  4351. ORDER BY
  4352. m1.behospital_code,
  4353. m4.gmt_create
  4354. ) e
  4355. WHERE
  4356. a.is_deleted = 'N'
  4357. AND b.is_deleted = 'N'
  4358. AND c.is_deleted = 'N'
  4359. AND d.is_deleted = 'N'
  4360. AND a.hospital_id = b.hospital_id
  4361. AND a.hospital_id = c.hospital_id
  4362. AND a.hospital_id = d.hospital_id
  4363. AND a.hospital_id = e.hospital_id
  4364. AND a.behospital_code = b.behospital_code
  4365. AND a.behospital_code = c.behospital_code
  4366. AND a.behospital_code = d.behospital_code
  4367. AND a.behospital_code = e.behospital_code
  4368. AND d.cases_id = 243
  4369. AND d.score_res > e.score_res
  4370. <if test="isPlacefile != null and isPlacefile != ''">
  4371. and a.is_placefile = #{isPlacefile}
  4372. </if>
  4373. AND a.qc_type_id != 0
  4374. <if test="hospitalId != null and hospitalId != ''">
  4375. AND a.hospital_id = #{hospitalId}
  4376. </if>
  4377. <if test="startDate != null and startDate != ''">
  4378. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4379. </if>
  4380. <if test="endDate != null and endDate != ''">
  4381. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4382. </if>
  4383. ) t1,
  4384. (
  4385. SELECT
  4386. count( DISTINCT a.behospital_code ) AS homePageMRNum
  4387. FROM
  4388. med_behospital_info a,
  4389. med_home_page b,
  4390. med_qcresult_info c
  4391. WHERE
  4392. a.is_deleted = 'N'
  4393. AND b.is_deleted = 'N'
  4394. AND a.hospital_id = b.hospital_id
  4395. AND a.hospital_id = c.hospital_id
  4396. AND a.behospital_code = b.behospital_code
  4397. AND a.behospital_code = c.behospital_code
  4398. AND a.qc_type_id != 0
  4399. <if test="isPlacefile != null and isPlacefile != ''">
  4400. and a.is_placefile = #{isPlacefile}
  4401. </if>
  4402. <if test="hospitalId != null and hospitalId != ''">
  4403. AND a.hospital_id = #{hospitalId}
  4404. </if>
  4405. <if test="startDate != null and startDate != ''">
  4406. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4407. </if>
  4408. <if test="endDate != null and endDate != ''">
  4409. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4410. </if>
  4411. ) t2
  4412. </select>
  4413. <!-- 质控核查统计(内页)-->
  4414. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  4415. SELECT
  4416. t.*
  4417. FROM
  4418. (SELECT
  4419. mr.beh_dept_id AS deptId,
  4420. mr.beh_dept_name AS deptName,
  4421. IFNULL( mr.mrNum, 0 ) AS mrNum,
  4422. ck.checkedNum AS checkedNum,
  4423. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  4424. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  4425. hmmr_t.homePageMRNum,
  4426. improve_t.improveNum,
  4427. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  4428. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  4429. improve_t.improveToPassNum,
  4430. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  4431. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  4432. improve_t.improveToFullNum,
  4433. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  4434. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  4435. FROM
  4436. (
  4437. SELECT
  4438. a.beh_dept_id,
  4439. a.beh_dept_name,
  4440. count(*) AS mrNum
  4441. FROM
  4442. med_behospital_info a,
  4443. med_qcresult_info b
  4444. WHERE
  4445. a.is_deleted = 'N'
  4446. AND b.is_deleted = 'N'
  4447. AND a.hospital_id = b.hospital_id
  4448. AND a.behospital_code = b.behospital_code
  4449. AND a.qc_type_id != 0
  4450. <if test="isPlacefile != null and isPlacefile != ''">
  4451. and a.is_placefile = #{isPlacefile}
  4452. </if>
  4453. <if test="hospitalId != null and hospitalId != ''">
  4454. AND a.hospital_id = #{hospitalId}
  4455. </if>
  4456. <if test="startDate != null and startDate != ''">
  4457. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4458. </if>
  4459. <if test="endDate != null and endDate != ''">
  4460. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4461. </if>
  4462. <if test="name != null and name != ''">
  4463. AND a.beh_dept_name like CONCAT('%', #{name}, '%')
  4464. </if>
  4465. GROUP BY
  4466. a.beh_dept_id,
  4467. a.beh_dept_name
  4468. ) mr
  4469. LEFT JOIN (
  4470. SELECT
  4471. a.beh_dept_id,
  4472. a.beh_dept_name,
  4473. count(*) AS checkedNum
  4474. FROM
  4475. med_behospital_info a,
  4476. med_qcresult_info b,
  4477. med_check_info c
  4478. WHERE
  4479. a.is_deleted = 'N'
  4480. AND b.is_deleted = 'N'
  4481. AND c.is_deleted = 'N'
  4482. AND a.hospital_id = b.hospital_id
  4483. AND a.hospital_id = c.hospital_id
  4484. AND a.behospital_code = b.behospital_code
  4485. AND a.behospital_code = c.behospital_code
  4486. AND a.qc_type_id != 0
  4487. <if test="isPlacefile != null and isPlacefile != ''">
  4488. and a.is_placefile = #{isPlacefile}
  4489. </if>
  4490. AND ifnull(c.`status`,0) = 1
  4491. <if test="hospitalId != null and hospitalId != ''">
  4492. AND a.hospital_id = #{hospitalId}
  4493. </if>
  4494. <if test="startDate != null and startDate != ''">
  4495. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4496. </if>
  4497. <if test="endDate != null and endDate != ''">
  4498. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4499. </if>
  4500. <if test="name != null and name != ''">
  4501. AND a.beh_dept_name like CONCAT('%', #{name}, '%')
  4502. </if>
  4503. GROUP BY
  4504. a.beh_dept_id,
  4505. a.beh_dept_name
  4506. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  4507. AND mr.beh_dept_name = ck.beh_dept_name
  4508. LEFT JOIN (
  4509. SELECT
  4510. a.beh_dept_id,
  4511. a.beh_dept_name,
  4512. count( DISTINCT a.behospital_code ) AS homePageMRNum
  4513. FROM
  4514. med_behospital_info a,
  4515. med_home_page b,
  4516. med_qcresult_info c
  4517. WHERE
  4518. a.is_deleted = 'N'
  4519. AND b.is_deleted = 'N'
  4520. AND a.hospital_id = b.hospital_id
  4521. AND a.hospital_id = c.hospital_id
  4522. AND a.behospital_code = b.behospital_code
  4523. AND a.behospital_code = c.behospital_code
  4524. AND a.qc_type_id != 0
  4525. <if test="isPlacefile != null and isPlacefile != ''">
  4526. and a.is_placefile = #{isPlacefile}
  4527. </if>
  4528. <if test="hospitalId != null and hospitalId != ''">
  4529. AND a.hospital_id = #{hospitalId}
  4530. </if>
  4531. <if test="startDate != null and startDate != ''">
  4532. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4533. </if>
  4534. <if test="endDate != null and endDate != ''">
  4535. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4536. </if>
  4537. <if test="name != null and name != ''">
  4538. AND a.beh_dept_name like CONCAT('%', #{name}, '%')
  4539. </if>
  4540. GROUP BY
  4541. a.beh_dept_id,
  4542. a.beh_dept_name
  4543. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  4544. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  4545. LEFT JOIN (
  4546. SELECT
  4547. a.beh_dept_id,
  4548. a.beh_dept_name,
  4549. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  4550. sum( d.score_res = 20 ) AS improveToFullNum,
  4551. count(*) AS improveNum
  4552. FROM
  4553. med_behospital_info a,
  4554. med_home_page b,
  4555. med_qcresult_info c,
  4556. med_qcresult_cases d,
  4557. (
  4558. SELECT
  4559. m4.*
  4560. FROM
  4561. med_behospital_info m1,
  4562. med_home_page m2,
  4563. med_qcresult_info m3,
  4564. med_qcresult_cases m4
  4565. WHERE
  4566. m1.is_deleted = 'N'
  4567. AND m2.is_deleted = 'N'
  4568. AND m3.is_deleted = 'Y'
  4569. AND m4.is_deleted = 'Y'
  4570. AND m1.hospital_id = m2.hospital_id
  4571. AND m1.hospital_id = m3.hospital_id
  4572. AND m1.hospital_id = m4.hospital_id
  4573. AND m1.behospital_code = m2.behospital_code
  4574. AND m1.behospital_code = m3.behospital_code
  4575. AND m1.behospital_code = m4.behospital_code
  4576. AND m3.gmt_create = m4.gmt_create
  4577. AND m3.have_home_page = 1
  4578. AND m4.cases_id = 243
  4579. <if test="isPlacefile != null and isPlacefile != ''">
  4580. and m1.is_placefile = #{isPlacefile}
  4581. </if>
  4582. AND m1.qc_type_id != 0
  4583. <if test="hospitalId != null and hospitalId != ''">
  4584. AND m1.hospital_id = #{hospitalId}
  4585. </if>
  4586. <if test="startDate != null and startDate != ''">
  4587. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  4588. </if>
  4589. <if test="endDate != null and endDate != ''">
  4590. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  4591. </if>
  4592. <if test="name != null and name != ''">
  4593. AND m1.beh_dept_name like CONCAT('%', #{name}, '%')
  4594. </if>
  4595. GROUP BY
  4596. m1.behospital_code
  4597. ORDER BY
  4598. m1.behospital_code,
  4599. m4.gmt_create
  4600. ) e
  4601. WHERE
  4602. a.is_deleted = 'N'
  4603. AND b.is_deleted = 'N'
  4604. AND c.is_deleted = 'N'
  4605. AND d.is_deleted = 'N'
  4606. AND a.hospital_id = b.hospital_id
  4607. AND a.hospital_id = c.hospital_id
  4608. AND a.hospital_id = d.hospital_id
  4609. AND a.hospital_id = e.hospital_id
  4610. AND a.behospital_code = b.behospital_code
  4611. AND a.behospital_code = c.behospital_code
  4612. AND a.behospital_code = d.behospital_code
  4613. AND a.behospital_code = e.behospital_code
  4614. AND d.cases_id = 243
  4615. AND d.score_res > e.score_res
  4616. <if test="hospitalId != null and hospitalId != ''">
  4617. AND a.hospital_id = #{hospitalId}
  4618. </if>
  4619. <if test="startDate != null and startDate != ''">
  4620. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4621. </if>
  4622. <if test="endDate != null and endDate != ''">
  4623. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4624. </if>
  4625. <if test="name != null and name != ''">
  4626. AND a.beh_dept_name like CONCAT('%', #{name}, '%')
  4627. </if>
  4628. GROUP BY
  4629. a.beh_dept_id,
  4630. a.beh_dept_name
  4631. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  4632. AND mr.beh_dept_name = improve_t.beh_dept_name
  4633. ) t
  4634. <if test="asc != null and asc !=''">
  4635. order by
  4636. <choose>
  4637. <when test='asc=="deptId"'>deptId asc</when>
  4638. <when test='asc=="deptName"'>deptName asc</when>
  4639. <when test='asc=="mrNum"'>mrNum asc</when>
  4640. <when test='asc=="checkedNum"'>checkedNum asc</when>
  4641. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  4642. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  4643. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  4644. <when test='asc=="improveNum"'>improveNum asc</when>
  4645. <when test='asc=="improvePercent"'>improvePercent asc</when>
  4646. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  4647. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  4648. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  4649. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  4650. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  4651. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  4652. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  4653. <otherwise>deptName asc</otherwise>
  4654. </choose>
  4655. </if>
  4656. <if test="desc != null and desc!=''">
  4657. order by
  4658. <choose>
  4659. <when test='desc=="deptId"'>deptId desc</when>
  4660. <when test='desc=="deptName"'>deptName desc</when>
  4661. <when test='desc=="mrNum"'>mrNum desc</when>
  4662. <when test='desc=="checkedNum"'>checkedNum desc</when>
  4663. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  4664. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  4665. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  4666. <when test='desc=="improveNum"'>improveNum desc</when>
  4667. <when test='desc=="improvePercent"'>improvePercent desc</when>
  4668. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  4669. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  4670. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  4671. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  4672. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  4673. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  4674. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  4675. <otherwise>deptName desc</otherwise>
  4676. </choose>
  4677. </if>
  4678. </select>
  4679. <!-- 离院病人评分详情页导出-->
  4680. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  4681. SELECT
  4682. f1.behDeptId,
  4683. f1.behDeptName,
  4684. f1.behDoctorName,
  4685. f1.patName,
  4686. f1.behospitalCode,
  4687. f1.hospitalId,
  4688. f1.behospitalDate,
  4689. f1.leaveHospitalDate,
  4690. f1.score,
  4691. f2.avgScore,
  4692. f1.msg,
  4693. f1.caseName,
  4694. f1.checkStatus,
  4695. f1.mrStatus,
  4696. f1.chName,
  4697. f1.mrName,
  4698. f1.chTime,
  4699. f1.mrTime
  4700. FROM
  4701. (SELECT
  4702. CONCAT(
  4703. ( CASE WHEN t.directorDoctorName IS NOT NULL AND t.directorDoctorName != '' THEN concat( t.directorDoctorName,
  4704. '\n' ) ELSE '' END ),
  4705. t.doctorName
  4706. ) AS behDoctorName,
  4707. t.`name` AS patName,
  4708. t.behospitalCode AS behospitalCode,
  4709. t.behospitalDate AS behospitalDate,
  4710. t.leaveHospitalDate AS leaveHospitalDate,
  4711. qi.score_res AS score,
  4712. qd.msg AS msg,
  4713. qc.NAME AS caseName,
  4714. t.behDeptId,
  4715. t.behDeptName,
  4716. t.hospitalId,
  4717. t.checkStatus,
  4718. t.mrStatus,
  4719. t.chName,
  4720. t.mrName,
  4721. t.chTime,
  4722. t.mrTime
  4723. FROM
  4724. (SELECT DISTINCT
  4725. t1.hospital_id AS hospitalId,
  4726. t1.behospital_code AS behospitalCode,
  4727. t1.bed_code AS bedCode,
  4728. t1.LEVEL AS LEVEL,
  4729. t1.grade_type AS gradeType,
  4730. t1.score_res AS scoreRes,
  4731. t1.NAME AS NAME,
  4732. t1.sex AS sex,
  4733. t1.beh_dept_id AS behDeptId,
  4734. t1.beh_dept_name AS behDeptName,
  4735. t1.doctor_id AS doctorId,
  4736. t1.doctor_name AS doctorName,
  4737. t1.beh_doctor_id AS behDoctorId,
  4738. t1.beh_doctor_name AS behDoctorName,
  4739. t1.director_doctor_id AS directorDoctorId,
  4740. t1.director_doctor_name AS directorDoctorName,
  4741. t1.birthday AS birthday,
  4742. t1.behospital_date AS behospitalDate,
  4743. t1.leave_hospital_date AS leaveHospitalDate,
  4744. t1.placefile_date AS placefileDate,
  4745. t1.gmt_create AS gradeTime,
  4746. t1.diagnose,
  4747. t1.ward_name AS wardName,
  4748. t1.checkStatus,
  4749. t1.mrStatus,
  4750. t1.chName,
  4751. t1.mrName,
  4752. t1.chTime,
  4753. t1.mrTime,
  4754. t2.age,
  4755. t1.file_code AS fileCode
  4756. FROM
  4757. (
  4758. SELECT be.*,
  4759. ifnull(mci.status,0) AS checkStatus,
  4760. ifnull(hm_mci.status,0) AS mrStatus,
  4761. mci.check_name as chName,
  4762. hm_mci.check_name as mrName,
  4763. mci.gmt_create as chTime,
  4764. hm_mci.gmt_create as mrTime
  4765. FROM
  4766. (
  4767. SELECT DISTINCT
  4768. tt1.*
  4769. FROM
  4770. (
  4771. SELECT
  4772. b.*,
  4773. ifnull(c.LEVEL,'未评分') as LEVEL ,
  4774. c.grade_type,
  4775. c.score_res,
  4776. c.gmt_create
  4777. FROM
  4778. (
  4779. SELECT DISTINCT
  4780. a.hospital_id,
  4781. a.behospital_code,
  4782. a.bed_code,
  4783. a.NAME,
  4784. a.sex,
  4785. a.beh_dept_id,
  4786. a.beh_dept_name,
  4787. a.birthday,
  4788. a.behospital_date,
  4789. a.leave_hospital_date,
  4790. a.doctor_id,
  4791. a.doctor_name,
  4792. a.beh_doctor_id,
  4793. a.beh_doctor_name,
  4794. a.director_doctor_id,
  4795. a.director_doctor_name,
  4796. a.diagnose,
  4797. a.placefile_date,
  4798. a.ward_name,
  4799. a.file_code
  4800. FROM
  4801. med_behospital_info a
  4802. WHERE
  4803. a.is_deleted = 'N'
  4804. AND a.qc_type_id != 0
  4805. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  4806. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  4807. </if>
  4808. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  4809. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  4810. </if>
  4811. <if test="qcResultShortPageVO.startDate != null">
  4812. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  4813. </if>
  4814. <if test="qcResultShortPageVO.endDate != null ">
  4815. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  4816. </if>
  4817. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  4818. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  4819. </if>
  4820. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  4821. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  4822. </if>
  4823. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  4824. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  4825. </if>
  4826. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  4827. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4828. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  4829. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  4830. </if>
  4831. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  4832. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4833. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  4834. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  4835. </if>
  4836. ) b
  4837. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  4838. AND b.hospital_id = c.hospital_id
  4839. AND b.behospital_code = c.behospital_code
  4840. ) tt1
  4841. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  4842. ,med_medical_record tt2,
  4843. qc_mode tt3
  4844. WHERE
  4845. tt2.is_deleted = 'N'
  4846. AND tt3.is_deleted = 'N'
  4847. AND tt1.hospital_id = tt2.hospital_id
  4848. AND tt1.behospital_code = tt2.behospital_code
  4849. AND tt2.mode_id = tt3.id
  4850. AND tt3.`name` = '手术记录'
  4851. </if>
  4852. ) be
  4853. left join med_check_info mci
  4854. on mci.is_deleted = 'N'
  4855. and mci.check_type = 0
  4856. and be.hospital_id = mci.hospital_id
  4857. and be.behospital_code = mci.behospital_code
  4858. left join med_check_info hm_mci
  4859. on hm_mci.is_deleted = 'N'
  4860. and hm_mci.check_type = 1
  4861. and be.hospital_id = hm_mci.hospital_id
  4862. and be.behospital_code = hm_mci.behospital_code
  4863. )t1
  4864. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  4865. ,med_home_page t2
  4866. WHERE
  4867. t2.is_deleted = 'N'
  4868. AND t1.hospital_id = t2.hospital_id
  4869. AND t1.behospital_code = t2.behospital_code
  4870. AND (
  4871. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  4872. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  4873. )
  4874. </if>
  4875. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  4876. ,med_home_page t2
  4877. WHERE
  4878. t2.is_deleted = 'N'
  4879. AND t1.hospital_id = t2.hospital_id
  4880. AND t1.behospital_code = t2.behospital_code
  4881. AND t2.return_to_type = '死亡'
  4882. </if>
  4883. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  4884. ,med_home_page t2
  4885. WHERE
  4886. t2.is_deleted = 'N'
  4887. AND t1.hospital_id = t2.hospital_id
  4888. AND t1.behospital_code = t2.behospital_code
  4889. AND t2.leave_hospital_type = '非医嘱离院'
  4890. </if>
  4891. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  4892. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  4893. AND t1.hospital_id = t2.hospital_id
  4894. AND t1.behospital_code = t2.behospital_code
  4895. </if>
  4896. )t
  4897. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  4898. AND t.hospitalId = qi.hospital_id
  4899. AND t.behospitalCode = qi.behospital_code
  4900. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  4901. AND t.hospitalId = qd.hospital_id
  4902. AND t.behospitalCode = qd.behospital_code
  4903. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  4904. AND qd.cases_id = qc.id
  4905. where 1=1
  4906. <if test="qcResultShortPageVO.checkStatus != null">
  4907. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  4908. </if>
  4909. <if test="qcResultShortPageVO.mrStatus != null">
  4910. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  4911. </if>
  4912. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  4913. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  4914. </if>
  4915. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  4916. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  4917. </if>
  4918. <if test="qcResultShortPageVO.chTimeStart != null ">
  4919. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  4920. </if>
  4921. <if test="qcResultShortPageVO.chTimeEnd != null ">
  4922. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  4923. </if>
  4924. <if test="qcResultShortPageVO.mrTimeStart != null ">
  4925. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  4926. </if>
  4927. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  4928. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  4929. </if>
  4930. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  4931. AND t.`level` = #{qcResultShortPageVO.level}
  4932. </if>)f1,(SELECT
  4933. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  4934. t.behDeptId,
  4935. t.behDeptName
  4936. FROM
  4937. (SELECT DISTINCT
  4938. t1.hospital_id AS hospitalId,
  4939. t1.behospital_code AS behospitalCode,
  4940. t1.bed_code AS bedCode,
  4941. t1.LEVEL AS LEVEL,
  4942. t1.grade_type AS gradeType,
  4943. t1.score_res AS scoreRes,
  4944. t1.NAME AS NAME,
  4945. t1.sex AS sex,
  4946. t1.beh_dept_id AS behDeptId,
  4947. t1.beh_dept_name AS behDeptName,
  4948. t1.doctor_id AS doctorId,
  4949. t1.doctor_name AS doctorName,
  4950. t1.beh_doctor_id AS behDoctorId,
  4951. t1.beh_doctor_name AS behDoctorName,
  4952. t1.director_doctor_id AS directorDoctorId,
  4953. t1.director_doctor_name AS directorDoctorName,
  4954. t1.birthday AS birthday,
  4955. t1.behospital_date AS behospitalDate,
  4956. t1.leave_hospital_date AS leaveHospitalDate,
  4957. t1.placefile_date AS placefileDate,
  4958. t1.gmt_create AS gradeTime,
  4959. t1.diagnose,
  4960. t1.ward_name AS wardName,
  4961. t1.checkStatus,
  4962. t1.mrStatus,
  4963. t1.chName,
  4964. t1.mrName,
  4965. t1.chTime,
  4966. t1.mrTime,
  4967. t2.age,
  4968. t1.file_code AS fileCode
  4969. FROM
  4970. (
  4971. SELECT be.*,
  4972. ifnull(mci.status,0) AS checkStatus,
  4973. ifnull(hm_mci.status,0) AS mrStatus,
  4974. mci.check_name as chName,
  4975. hm_mci.check_name as mrName,
  4976. mci.gmt_create as chTime,
  4977. hm_mci.gmt_create as mrTime
  4978. FROM
  4979. (
  4980. SELECT DISTINCT
  4981. tt1.*
  4982. FROM
  4983. (
  4984. SELECT
  4985. b.*,
  4986. ifnull(c.LEVEL,'未评分') as LEVEL ,
  4987. c.grade_type,
  4988. c.score_res,
  4989. c.gmt_create
  4990. FROM
  4991. (
  4992. SELECT DISTINCT
  4993. a.hospital_id,
  4994. a.behospital_code,
  4995. a.bed_code,
  4996. a.NAME,
  4997. a.sex,
  4998. a.beh_dept_id,
  4999. a.beh_dept_name,
  5000. a.birthday,
  5001. a.behospital_date,
  5002. a.leave_hospital_date,
  5003. a.doctor_id,
  5004. a.doctor_name,
  5005. a.beh_doctor_id,
  5006. a.beh_doctor_name,
  5007. a.director_doctor_id,
  5008. a.director_doctor_name,
  5009. a.diagnose,
  5010. a.placefile_date,
  5011. a.ward_name,
  5012. a.file_code
  5013. FROM
  5014. med_behospital_info a
  5015. WHERE
  5016. a.is_deleted = 'N'
  5017. AND a.qc_type_id != 0
  5018. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5019. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5020. </if>
  5021. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5022. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5023. </if>
  5024. <if test="qcResultShortPageVO.startDate != null">
  5025. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5026. </if>
  5027. <if test="qcResultShortPageVO.endDate != null ">
  5028. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5029. </if>
  5030. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  5031. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  5032. </if>
  5033. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5034. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5035. </if>
  5036. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5037. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5038. </if>
  5039. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5040. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5041. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5042. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5043. </if>
  5044. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5045. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5046. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5047. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5048. </if>
  5049. ) b
  5050. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  5051. AND b.hospital_id = c.hospital_id
  5052. AND b.behospital_code = c.behospital_code
  5053. ) tt1
  5054. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  5055. ,med_medical_record tt2,
  5056. qc_mode tt3
  5057. WHERE
  5058. tt2.is_deleted = 'N'
  5059. AND tt3.is_deleted = 'N'
  5060. AND tt1.hospital_id = tt2.hospital_id
  5061. AND tt1.behospital_code = tt2.behospital_code
  5062. AND tt2.mode_id = tt3.id
  5063. AND tt3.`name` = '手术记录'
  5064. </if>
  5065. ) be
  5066. left join med_check_info mci
  5067. on mci.is_deleted = 'N'
  5068. and mci.check_type = 0
  5069. and be.hospital_id = mci.hospital_id
  5070. and be.behospital_code = mci.behospital_code
  5071. left join med_check_info hm_mci
  5072. on hm_mci.is_deleted = 'N'
  5073. and hm_mci.check_type = 1
  5074. and be.hospital_id = hm_mci.hospital_id
  5075. and be.behospital_code = hm_mci.behospital_code
  5076. )t1
  5077. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  5078. ,med_home_page t2
  5079. WHERE
  5080. t2.is_deleted = 'N'
  5081. AND t1.hospital_id = t2.hospital_id
  5082. AND t1.behospital_code = t2.behospital_code
  5083. AND (
  5084. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
  5085. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
  5086. )
  5087. </if>
  5088. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  5089. ,med_home_page t2
  5090. WHERE
  5091. t2.is_deleted = 'N'
  5092. AND t1.hospital_id = t2.hospital_id
  5093. AND t1.behospital_code = t2.behospital_code
  5094. AND t2.return_to_type = '死亡'
  5095. </if>
  5096. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  5097. ,med_home_page t2
  5098. WHERE
  5099. t2.is_deleted = 'N'
  5100. AND t1.hospital_id = t2.hospital_id
  5101. AND t1.behospital_code = t2.behospital_code
  5102. AND t2.leave_hospital_type = '非医嘱离院'
  5103. </if>
  5104. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  5105. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  5106. AND t1.hospital_id = t2.hospital_id
  5107. AND t1.behospital_code = t2.behospital_code
  5108. </if>
  5109. )t
  5110. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  5111. AND t.hospitalId = qi.hospital_id
  5112. AND t.behospitalCode = qi.behospital_code
  5113. where 1=1
  5114. <if test="qcResultShortPageVO.checkStatus != null">
  5115. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5116. </if>
  5117. <if test="qcResultShortPageVO.mrStatus != null">
  5118. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5119. </if>
  5120. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5121. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5122. </if>
  5123. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5124. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5125. </if>
  5126. <if test="qcResultShortPageVO.chTimeStart != null ">
  5127. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5128. </if>
  5129. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5130. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5131. </if>
  5132. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5133. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5134. </if>
  5135. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5136. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5137. </if>
  5138. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5139. AND t.`level` = #{qcResultShortPageVO.level}
  5140. </if>
  5141. GROUP BY
  5142. t.behDeptId,
  5143. t.behDeptName
  5144. )f2
  5145. WHERE
  5146. f1.behDeptId = f2.behDeptId
  5147. AND f1.behDeptName = f2.behDeptName
  5148. </select>
  5149. <!-- 条目缺陷评分详情页导出-->
  5150. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  5151. SELECT
  5152. f1.behDeptId,
  5153. f1.behDeptName,
  5154. f1.behDoctorName,
  5155. f1.patName,
  5156. f1.behospitalCode,
  5157. f1.hospitalId,
  5158. f1.behospitalDate,
  5159. f1.leaveHospitalDate,
  5160. f1.score,
  5161. f2.avgScore,
  5162. f1.msg,
  5163. f1.caseName,
  5164. f1.checkStatus,
  5165. f1.mrStatus,
  5166. f1.chName,
  5167. f1.mrName,
  5168. f1.chTime,
  5169. f1.mrTime
  5170. FROM
  5171. (SELECT
  5172. CONCAT( ifnull( t.directorDoctorName, '' ), '\n', t.doctorName ) AS behDoctorName,
  5173. t.`name` AS patName,
  5174. t.behospitalCode AS behospitalCode,
  5175. t.behospitalDate AS behospitalDate,
  5176. t.leaveHospitalDate AS leaveHospitalDate,
  5177. qi.score_res AS score,
  5178. qd.msg AS msg,
  5179. qc.NAME AS caseName,
  5180. t.behDeptId,
  5181. t.behDeptName,
  5182. t.hospitalId,
  5183. t.checkStatus,
  5184. t.mrStatus,
  5185. t.chName,
  5186. t.mrName,
  5187. t.chTime,
  5188. t.mrTime
  5189. FROM
  5190. (SELECT DISTINCT
  5191. t1.hospital_id AS hospitalId,
  5192. t1.behospital_code AS behospitalCode,
  5193. t1.bed_code AS bedCode,
  5194. t1.LEVEL AS LEVEL,
  5195. t1.grade_type AS gradeType,
  5196. t1.score_res AS scoreRes,
  5197. t1.NAME AS NAME,
  5198. t1.sex AS sex,
  5199. t1.beh_dept_id AS behDeptId,
  5200. t1.beh_dept_name AS behDeptName,
  5201. t1.doctor_id AS doctorId,
  5202. t1.doctor_name AS doctorName,
  5203. t1.beh_doctor_id AS behDoctorId,
  5204. t1.beh_doctor_name AS behDoctorName,
  5205. t1.director_doctor_id AS directorDoctorId,
  5206. t1.director_doctor_name AS directorDoctorName,
  5207. t1.birthday AS birthday,
  5208. t1.behospital_date AS behospitalDate,
  5209. t1.leave_hospital_date AS leaveHospitalDate,
  5210. t1.placefile_date AS placefileDate,
  5211. t1.gmt_create AS gradeTime,
  5212. t1.diagnose,
  5213. t1.ward_name AS wardName,
  5214. t2.age,
  5215. t1.file_code AS fileCode,
  5216. t1.checkStatus,
  5217. t1.mrStatus,
  5218. t1.chName,
  5219. t1.mrName,
  5220. t1.chTime,
  5221. t1.mrTime
  5222. FROM
  5223. (
  5224. SELECT DISTINCT
  5225. tt1.*
  5226. FROM
  5227. (SELECT
  5228. be.*,
  5229. ifnull(mci.status,0) AS checkStatus,
  5230. ifnull(hm_mci.status,0) AS mrStatus,
  5231. mci.check_name as chName,
  5232. hm_mci.check_name as mrName,
  5233. mci.gmt_create as chTime,
  5234. hm_mci.gmt_create as mrTime
  5235. FROM
  5236. (
  5237. SELECT DISTINCT
  5238. a.hospital_id,
  5239. a.behospital_code,
  5240. a.bed_code,
  5241. a.file_code,
  5242. b.LEVEL,
  5243. b.grade_type,
  5244. b.score_res,
  5245. a.NAME,
  5246. a.sex,
  5247. a.beh_dept_id,
  5248. a.beh_dept_name,
  5249. a.birthday,
  5250. a.behospital_date,
  5251. a.leave_hospital_date,
  5252. a.doctor_id,
  5253. a.doctor_name,
  5254. a.beh_doctor_id,
  5255. a.beh_doctor_name,
  5256. a.director_doctor_id,
  5257. a.director_doctor_name,
  5258. a.diagnose,
  5259. a.placefile_date,
  5260. a.ward_name,
  5261. b.gmt_create
  5262. FROM
  5263. med_behospital_info a,
  5264. med_qcresult_info b,
  5265. med_qcresult_detail c,
  5266. qc_cases_entry d
  5267. WHERE
  5268. a.is_deleted = 'N'
  5269. AND b.is_deleted = 'N'
  5270. AND c.is_deleted = 'N'
  5271. AND d.is_deleted = 'N'
  5272. AND a.hospital_id = b.hospital_id
  5273. AND a.hospital_id = c.hospital_id
  5274. AND a.behospital_code = b.behospital_code
  5275. AND a.behospital_code = c.behospital_code
  5276. AND c.cases_id = d.cases_id
  5277. AND c.cases_entry_id = d.id
  5278. AND a.qc_type_id != 0
  5279. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5280. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5281. </if>
  5282. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5283. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5284. </if>
  5285. <if test="qcResultShortPageVO.startDate != null ">
  5286. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5287. </if>
  5288. <if test="qcResultShortPageVO.endDate != null ">
  5289. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5290. </if>
  5291. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  5292. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  5293. </if>
  5294. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5295. AND b.`level` = #{qcResultShortPageVO.level}
  5296. </if>
  5297. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5298. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5299. </if>
  5300. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5301. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5302. </if>
  5303. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5304. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5305. </if>
  5306. <if test="qcResultShortPageVO.casesEntryId != null ">
  5307. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5308. </if>
  5309. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5310. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5311. </if>
  5312. <if test="qcResultShortPageVO.casesId != null">
  5313. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5314. </if>
  5315. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5316. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5317. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5318. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5319. </if>
  5320. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5321. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5322. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5323. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5324. </if>
  5325. <if test="qcResultShortPageVO.isReject != null">
  5326. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5327. </if>
  5328. <if test="qcResultShortPageVO.ruleType != null">
  5329. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5330. </if>
  5331. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5332. AND TIMESTAMPDIFF(
  5333. DAY,
  5334. DATE( a.behospital_date ),
  5335. DATE( a.leave_hospital_date ))> 30
  5336. </if>
  5337. )be
  5338. left join med_check_info mci
  5339. on mci.is_deleted = 'N'
  5340. and mci.check_type = 0
  5341. and be.hospital_id = mci.hospital_id
  5342. and be.behospital_code = mci.behospital_code
  5343. left join med_check_info hm_mci
  5344. on hm_mci.is_deleted = 'N'
  5345. and hm_mci.check_type = 1
  5346. and be.hospital_id = hm_mci.hospital_id
  5347. and be.behospital_code = hm_mci.behospital_code
  5348. )tt1
  5349. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5350. ,med_medical_record tt2
  5351. WHERE
  5352. tt2.is_deleted = 'N'
  5353. AND tt1.hospital_id = tt2.hospital_id
  5354. AND tt1.behospital_code = tt2.behospital_code
  5355. AND tt2.mode_id = 30
  5356. </if>
  5357. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5358. ,med_crisis_info tt2
  5359. WHERE
  5360. tt2.is_deleted = 'N'
  5361. AND tt1.hospital_id = tt2.hospital_id
  5362. AND tt1.behospital_code = tt2.behospital_code
  5363. </if>
  5364. ) t1
  5365. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5366. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5367. AND t1.behospital_code = t2.behospital_code
  5368. AND t2.is_deleted = 'N'
  5369. </if>
  5370. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5371. , med_home_page t2
  5372. , med_home_operation_info t3
  5373. WHERE t1.hospital_id = t2.hospital_id
  5374. AND t1.behospital_code = t2.behospital_code
  5375. AND t2.home_page_id = t3.home_page_id
  5376. AND t2.is_deleted = 'N'
  5377. AND t3.is_deleted = 'N'
  5378. </if>
  5379. ) t
  5380. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  5381. AND t.hospitalId = qi.hospital_id
  5382. AND t.behospitalCode = qi.behospital_code
  5383. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  5384. AND t.hospitalId = qd.hospital_id
  5385. AND t.behospitalCode = qd.behospital_code
  5386. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  5387. AND qd.cases_id = qc.id
  5388. where 1=1
  5389. <if test="qcResultShortPageVO.checkStatus != null">
  5390. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5391. </if>
  5392. <if test="qcResultShortPageVO.mrStatus != null">
  5393. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5394. </if>
  5395. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5396. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5397. </if>
  5398. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5399. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5400. </if>
  5401. <if test="qcResultShortPageVO.chTimeStart != null ">
  5402. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5403. </if>
  5404. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5405. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5406. </if>
  5407. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5408. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5409. </if>
  5410. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5411. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5412. </if>
  5413. )f1,
  5414. (SELECT
  5415. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  5416. t.behDeptId,
  5417. t.behDeptName
  5418. FROM
  5419. (SELECT DISTINCT
  5420. t1.hospital_id AS hospitalId,
  5421. t1.behospital_code AS behospitalCode,
  5422. t1.bed_code AS bedCode,
  5423. t1.LEVEL AS LEVEL,
  5424. t1.grade_type AS gradeType,
  5425. t1.score_res AS scoreRes,
  5426. t1.NAME AS NAME,
  5427. t1.sex AS sex,
  5428. t1.beh_dept_id AS behDeptId,
  5429. t1.beh_dept_name AS behDeptName,
  5430. t1.doctor_id AS doctorId,
  5431. t1.doctor_name AS doctorName,
  5432. t1.beh_doctor_id AS behDoctorId,
  5433. t1.beh_doctor_name AS behDoctorName,
  5434. t1.director_doctor_id AS directorDoctorId,
  5435. t1.director_doctor_name AS directorDoctorName,
  5436. t1.birthday AS birthday,
  5437. t1.behospital_date AS behospitalDate,
  5438. t1.leave_hospital_date AS leaveHospitalDate,
  5439. t1.placefile_date AS placefileDate,
  5440. t1.gmt_create AS gradeTime,
  5441. t1.diagnose,
  5442. t1.ward_name AS wardName,
  5443. t2.age,
  5444. t1.file_code AS fileCode,
  5445. t1.checkStatus,
  5446. t1.mrStatus,
  5447. t1.chName,
  5448. t1.mrName,
  5449. t1.chTime,
  5450. t1.mrTime
  5451. FROM
  5452. (
  5453. SELECT DISTINCT
  5454. tt1.*
  5455. FROM
  5456. (SELECT
  5457. be.*,
  5458. ifnull(mci.status,0) AS checkStatus,
  5459. ifnull(hm_mci.status,0) AS mrStatus,
  5460. mci.check_name as chName,
  5461. hm_mci.check_name as mrName,
  5462. mci.gmt_create as chTime,
  5463. hm_mci.gmt_create as mrTime
  5464. FROM
  5465. (
  5466. SELECT DISTINCT
  5467. a.hospital_id,
  5468. a.behospital_code,
  5469. a.bed_code,
  5470. a.file_code,
  5471. b.LEVEL,
  5472. b.grade_type,
  5473. b.score_res,
  5474. a.NAME,
  5475. a.sex,
  5476. a.beh_dept_id,
  5477. a.beh_dept_name,
  5478. a.birthday,
  5479. a.behospital_date,
  5480. a.leave_hospital_date,
  5481. a.doctor_id,
  5482. a.doctor_name,
  5483. a.beh_doctor_id,
  5484. a.beh_doctor_name,
  5485. a.director_doctor_id,
  5486. a.director_doctor_name,
  5487. a.diagnose,
  5488. a.placefile_date,
  5489. a.ward_name,
  5490. b.gmt_create
  5491. FROM
  5492. med_behospital_info a,
  5493. med_qcresult_info b,
  5494. med_qcresult_detail c,
  5495. qc_cases_entry d
  5496. WHERE
  5497. a.is_deleted = 'N'
  5498. AND b.is_deleted = 'N'
  5499. AND c.is_deleted = 'N'
  5500. AND d.is_deleted = 'N'
  5501. AND a.hospital_id = b.hospital_id
  5502. AND a.hospital_id = c.hospital_id
  5503. AND a.behospital_code = b.behospital_code
  5504. AND a.behospital_code = c.behospital_code
  5505. AND c.cases_id = d.cases_id
  5506. AND c.cases_entry_id = d.id
  5507. AND a.qc_type_id != 0
  5508. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5509. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5510. </if>
  5511. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5512. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5513. </if>
  5514. <if test="qcResultShortPageVO.startDate != null ">
  5515. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5516. </if>
  5517. <if test="qcResultShortPageVO.endDate != null ">
  5518. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5519. </if>
  5520. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  5521. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  5522. </if>
  5523. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5524. AND b.`level` = #{qcResultShortPageVO.level}
  5525. </if>
  5526. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5527. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5528. </if>
  5529. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5530. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5531. </if>
  5532. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5533. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5534. </if>
  5535. <if test="qcResultShortPageVO.casesEntryId != null ">
  5536. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5537. </if>
  5538. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5539. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5540. </if>
  5541. <if test="qcResultShortPageVO.casesId != null">
  5542. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5543. </if>
  5544. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5545. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5546. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5547. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5548. </if>
  5549. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5550. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5551. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5552. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5553. </if>
  5554. <if test="qcResultShortPageVO.isReject != null">
  5555. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5556. </if>
  5557. <if test="qcResultShortPageVO.ruleType != null">
  5558. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5559. </if>
  5560. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5561. AND TIMESTAMPDIFF(
  5562. DAY,
  5563. DATE( a.behospital_date ),
  5564. DATE( a.leave_hospital_date ))> 30
  5565. </if>
  5566. )be
  5567. left join med_check_info mci
  5568. on mci.is_deleted = 'N'
  5569. and mci.check_type = 0
  5570. and be.hospital_id = mci.hospital_id
  5571. and be.behospital_code = mci.behospital_code
  5572. left join med_check_info hm_mci
  5573. on hm_mci.is_deleted = 'N'
  5574. and hm_mci.check_type = 1
  5575. and be.hospital_id = hm_mci.hospital_id
  5576. and be.behospital_code = hm_mci.behospital_code
  5577. )tt1
  5578. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5579. ,med_medical_record tt2
  5580. WHERE
  5581. tt2.is_deleted = 'N'
  5582. AND tt1.hospital_id = tt2.hospital_id
  5583. AND tt1.behospital_code = tt2.behospital_code
  5584. AND tt2.mode_id = 30
  5585. </if>
  5586. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5587. ,med_crisis_info tt2
  5588. WHERE
  5589. tt2.is_deleted = 'N'
  5590. AND tt1.hospital_id = tt2.hospital_id
  5591. AND tt1.behospital_code = tt2.behospital_code
  5592. </if>
  5593. ) t1
  5594. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5595. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5596. AND t1.behospital_code = t2.behospital_code
  5597. AND t2.is_deleted = 'N'
  5598. </if>
  5599. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5600. , med_home_page t2
  5601. , med_home_operation_info t3
  5602. WHERE t1.hospital_id = t2.hospital_id
  5603. AND t1.behospital_code = t2.behospital_code
  5604. AND t2.home_page_id = t3.home_page_id
  5605. AND t2.is_deleted = 'N'
  5606. AND t3.is_deleted = 'N'
  5607. </if>
  5608. ) t
  5609. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  5610. AND t.hospitalId = qi.hospital_id
  5611. AND t.behospitalCode = qi.behospital_code
  5612. where 1=1
  5613. <if test="qcResultShortPageVO.checkStatus != null">
  5614. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5615. </if>
  5616. <if test="qcResultShortPageVO.mrStatus != null">
  5617. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5618. </if>
  5619. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5620. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5621. </if>
  5622. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5623. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5624. </if>
  5625. <if test="qcResultShortPageVO.chTimeStart != null ">
  5626. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5627. </if>
  5628. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5629. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5630. </if>
  5631. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5632. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5633. </if>
  5634. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5635. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5636. </if>
  5637. GROUP BY
  5638. t.behDeptId,
  5639. t.behDeptName
  5640. )f2
  5641. WHERE
  5642. f1.behDeptId = f2.behDeptId
  5643. AND f1.behDeptName = f2.behDeptName
  5644. </select>
  5645. <!-- 未整改病历统计-->
  5646. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  5647. SELECT
  5648. a.beh_dept_id AS deptId,
  5649. a.beh_dept_name AS deptName,
  5650. d.id AS casesEntryId,
  5651. d.NAME AS casesEntryName,
  5652. count(*) AS casesEntryNum
  5653. FROM
  5654. med_behospital_info a,
  5655. med_qcresult_info b,
  5656. med_qcresult_detail c,
  5657. qc_cases_entry d
  5658. WHERE
  5659. a.is_deleted = 'N'
  5660. AND b.is_deleted = 'N'
  5661. AND c.is_deleted = 'N'
  5662. AND d.is_deleted = 'N'
  5663. AND a.hospital_id = b.hospital_id
  5664. AND a.hospital_id = c.hospital_id
  5665. AND a.behospital_code = b.behospital_code
  5666. AND a.behospital_code = c.behospital_code
  5667. AND c.cases_entry_id = d.id
  5668. AND a.qc_type_id != 0
  5669. <if test="isPlacefile != null and isPlacefile != ''">
  5670. and a.is_placefile = #{isPlacefile}
  5671. </if>
  5672. <if test="hospitalId != null and hospitalId != ''">
  5673. AND a.hospital_id = #{hospitalId}
  5674. </if>
  5675. <if test="startDate != null">
  5676. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5677. </if>
  5678. <if test="endDate != null">
  5679. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5680. </if>
  5681. <if test="name != null and name != ''">
  5682. AND a.beh_dept_name like CONCAT('%', #{name}, '%')
  5683. </if>
  5684. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  5685. AND c.cases_entry_id IN
  5686. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  5687. #{item}
  5688. </foreach>
  5689. </if>
  5690. GROUP BY
  5691. a.beh_dept_id,
  5692. a.beh_dept_name,
  5693. c.cases_entry_id,
  5694. d.NAME
  5695. </select>
  5696. <!-- 未整改病历质控评分页(内页)-->
  5697. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5698. SELECT t.*
  5699. FROM
  5700. (SELECT DISTINCT
  5701. t1.hospital_id AS hospitalId,
  5702. t1.behospital_code AS behospitalCode,
  5703. t1.bed_code AS bedCode,
  5704. t1.LEVEL AS LEVEL,
  5705. t1.grade_type AS gradeType,
  5706. t1.score_res AS scoreRes,
  5707. t1.NAME AS NAME,
  5708. t1.sex AS sex,
  5709. t1.beh_dept_id AS behDeptId,
  5710. t1.beh_dept_name AS behDeptName,
  5711. t1.doctor_id AS doctorId,
  5712. t1.doctor_name AS doctorName,
  5713. t1.beh_doctor_id AS behDoctorId,
  5714. t1.beh_doctor_name AS behDoctorName,
  5715. t1.director_doctor_id AS directorDoctorId,
  5716. t1.director_doctor_name AS directorDoctorName,
  5717. t1.birthday AS birthday,
  5718. t1.behospital_date AS behospitalDate,
  5719. t1.leave_hospital_date AS leaveHospitalDate,
  5720. t1.placefile_date AS placefileDate,
  5721. t1.gmt_create AS gradeTime,
  5722. t1.diagnose,
  5723. t1.ward_name AS wardName,
  5724. t2.age,
  5725. t1.file_code AS fileCode,
  5726. t1.checkStatus,
  5727. t1.mrStatus,
  5728. t1.chName,
  5729. t1.mrName,
  5730. t1.chTime,
  5731. t1.mrTime
  5732. FROM
  5733. (SELECT
  5734. be.*,
  5735. ifnull(mci.status,0) AS checkStatus,
  5736. ifnull(hm_mci.status,0) AS mrStatus,
  5737. mci.check_name as chName,
  5738. hm_mci.check_name as mrName,
  5739. mci.gmt_create as chTime,
  5740. hm_mci.gmt_create as mrTime
  5741. FROM
  5742. (
  5743. SELECT DISTINCT
  5744. a.hospital_id,
  5745. a.behospital_code,
  5746. a.bed_code,
  5747. a.file_code,
  5748. b.LEVEL,
  5749. b.grade_type,
  5750. b.score_res,
  5751. a.NAME,
  5752. a.sex,
  5753. a.beh_dept_id,
  5754. a.beh_dept_name,
  5755. a.birthday,
  5756. a.behospital_date,
  5757. a.leave_hospital_date,
  5758. a.doctor_id,
  5759. a.doctor_name,
  5760. a.beh_doctor_id,
  5761. a.beh_doctor_name,
  5762. a.director_doctor_id,
  5763. a.director_doctor_name,
  5764. a.diagnose,
  5765. a.placefile_date,
  5766. a.ward_name,
  5767. b.gmt_create
  5768. FROM
  5769. med_behospital_info a,
  5770. med_qcresult_info b,
  5771. med_qcresult_detail c,
  5772. qc_cases_entry d
  5773. WHERE
  5774. a.is_deleted = 'N'
  5775. AND b.is_deleted = 'N'
  5776. AND c.is_deleted = 'N'
  5777. AND d.is_deleted = 'N'
  5778. AND a.hospital_id = b.hospital_id
  5779. AND a.hospital_id = c.hospital_id
  5780. AND a.behospital_code = b.behospital_code
  5781. AND a.behospital_code = c.behospital_code
  5782. AND c.cases_id = d.cases_id
  5783. AND c.cases_entry_id = d.id
  5784. AND a.qc_type_id != 0
  5785. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5786. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5787. </if>
  5788. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5789. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5790. </if>
  5791. <if test="qcResultShortPageVO.startDate != null ">
  5792. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5793. </if>
  5794. <if test="qcResultShortPageVO.endDate != null ">
  5795. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5796. </if>
  5797. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  5798. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  5799. </if>
  5800. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5801. AND b.`level` = #{qcResultShortPageVO.level}
  5802. </if>
  5803. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5804. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5805. </if>
  5806. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5807. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5808. </if>
  5809. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5810. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5811. </if>
  5812. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5813. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5814. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5815. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5816. </if>
  5817. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5818. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5819. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5820. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5821. </if>
  5822. <if test="qcResultShortPageVO.casesEntryId != null ">
  5823. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5824. </if>
  5825. <if test="qcResultShortPageVO.isReject != null">
  5826. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5827. </if>
  5828. <if test="qcResultShortPageVO.ruleType != null">
  5829. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5830. </if>
  5831. )be
  5832. left join med_check_info mci
  5833. on mci.is_deleted = 'N'
  5834. and mci.check_type = 0
  5835. and be.hospital_id = mci.hospital_id
  5836. and be.behospital_code = mci.behospital_code
  5837. left join med_check_info hm_mci
  5838. on hm_mci.is_deleted = 'N'
  5839. and hm_mci.check_type = 1
  5840. and be.hospital_id = hm_mci.hospital_id
  5841. and be.behospital_code = hm_mci.behospital_code
  5842. ) t1
  5843. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5844. AND t1.behospital_code = t2.behospital_code
  5845. AND t2.is_deleted = 'N'
  5846. ) t
  5847. where 1=1
  5848. <if test="qcResultShortPageVO.checkStatus != null">
  5849. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5850. </if>
  5851. <if test="qcResultShortPageVO.mrStatus != null">
  5852. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5853. </if>
  5854. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5855. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5856. </if>
  5857. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5858. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5859. </if>
  5860. <if test="qcResultShortPageVO.chTimeStart != null ">
  5861. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5862. </if>
  5863. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5864. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5865. </if>
  5866. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5867. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5868. </if>
  5869. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5870. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5871. </if>
  5872. </select>
  5873. <!-- 未整改病历缺陷评分详情页导出-->
  5874. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  5875. SELECT
  5876. f1.behDeptId,
  5877. f1.behDeptName,
  5878. f1.behDoctorName,
  5879. f1.patName,
  5880. f1.behospitalCode,
  5881. f1.hospitalId,
  5882. f1.behospitalDate,
  5883. f1.leaveHospitalDate,
  5884. f1.score,
  5885. f2.avgScore,
  5886. f1.msg,
  5887. f1.caseName,
  5888. f1.checkStatus,
  5889. f1.mrStatus,
  5890. f1.chName,
  5891. f1.mrName,
  5892. f1.chTime,
  5893. f1.mrTime
  5894. FROM
  5895. (SELECT
  5896. CONCAT( ifnull( t.directorDoctorName, '' ), '\n', t.doctorName ) AS behDoctorName,
  5897. t.`name` AS patName,
  5898. t.behospitalCode AS behospitalCode,
  5899. t.behospitalDate AS behospitalDate,
  5900. t.leaveHospitalDate AS leaveHospitalDate,
  5901. qi.score_res AS score,
  5902. qd.msg AS msg,
  5903. qc.NAME AS caseName,
  5904. t.behDeptId,
  5905. t.behDeptName,
  5906. t.hospitalId,
  5907. t.checkStatus,
  5908. t.mrStatus,
  5909. t.chName,
  5910. t.mrName,
  5911. t.chTime,
  5912. t.mrTime
  5913. FROM
  5914. (SELECT DISTINCT
  5915. t1.hospital_id AS hospitalId,
  5916. t1.behospital_code AS behospitalCode,
  5917. t1.bed_code AS bedCode,
  5918. t1.LEVEL AS LEVEL,
  5919. t1.grade_type AS gradeType,
  5920. t1.score_res AS scoreRes,
  5921. t1.NAME AS NAME,
  5922. t1.sex AS sex,
  5923. t1.beh_dept_id AS behDeptId,
  5924. t1.beh_dept_name AS behDeptName,
  5925. t1.doctor_id AS doctorId,
  5926. t1.doctor_name AS doctorName,
  5927. t1.beh_doctor_id AS behDoctorId,
  5928. t1.beh_doctor_name AS behDoctorName,
  5929. t1.director_doctor_id AS directorDoctorId,
  5930. t1.director_doctor_name AS directorDoctorName,
  5931. t1.birthday AS birthday,
  5932. t1.behospital_date AS behospitalDate,
  5933. t1.leave_hospital_date AS leaveHospitalDate,
  5934. t1.placefile_date AS placefileDate,
  5935. t1.gmt_create AS gradeTime,
  5936. t1.diagnose,
  5937. t1.ward_name AS wardName,
  5938. t2.age,
  5939. t1.file_code AS fileCode,
  5940. t1.checkStatus,
  5941. t1.mrStatus,
  5942. t1.chName,
  5943. t1.mrName,
  5944. t1.chTime,
  5945. t1.mrTime
  5946. FROM
  5947. (SELECT
  5948. be.*,
  5949. ifnull(mci.status,0) AS checkStatus,
  5950. ifnull(hm_mci.status,0) AS mrStatus,
  5951. mci.check_name as chName,
  5952. hm_mci.check_name as mrName,
  5953. mci.gmt_create as chTime,
  5954. hm_mci.gmt_create as mrTime
  5955. FROM
  5956. (
  5957. SELECT DISTINCT
  5958. a.hospital_id,
  5959. a.behospital_code,
  5960. a.bed_code,
  5961. a.file_code,
  5962. b.LEVEL,
  5963. b.grade_type,
  5964. b.score_res,
  5965. a.NAME,
  5966. a.sex,
  5967. a.beh_dept_id,
  5968. a.beh_dept_name,
  5969. a.birthday,
  5970. a.behospital_date,
  5971. a.leave_hospital_date,
  5972. a.doctor_id,
  5973. a.doctor_name,
  5974. a.beh_doctor_id,
  5975. a.beh_doctor_name,
  5976. a.director_doctor_id,
  5977. a.director_doctor_name,
  5978. a.diagnose,
  5979. a.placefile_date,
  5980. a.ward_name,
  5981. b.gmt_create
  5982. FROM
  5983. med_behospital_info a,
  5984. med_qcresult_info b,
  5985. med_qcresult_detail c,
  5986. qc_cases_entry d
  5987. WHERE
  5988. a.is_deleted = 'N'
  5989. AND b.is_deleted = 'N'
  5990. AND c.is_deleted = 'N'
  5991. AND d.is_deleted = 'N'
  5992. AND a.hospital_id = b.hospital_id
  5993. AND a.hospital_id = c.hospital_id
  5994. AND a.behospital_code = b.behospital_code
  5995. AND a.behospital_code = c.behospital_code
  5996. AND c.cases_id = d.cases_id
  5997. AND c.cases_entry_id = d.id
  5998. AND a.qc_type_id != 0
  5999. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6000. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6001. </if>
  6002. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6003. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6004. </if>
  6005. <if test="qcResultShortPageVO.startDate != null ">
  6006. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6007. </if>
  6008. <if test="qcResultShortPageVO.endDate != null ">
  6009. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6010. </if>
  6011. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  6012. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  6013. </if>
  6014. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6015. AND b.`level` = #{qcResultShortPageVO.level}
  6016. </if>
  6017. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6018. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6019. </if>
  6020. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6021. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6022. </if>
  6023. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  6024. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  6025. </if>
  6026. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6027. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6028. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6029. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  6030. </if>
  6031. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6032. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6033. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6034. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  6035. </if>
  6036. <if test="qcResultShortPageVO.casesEntryId != null ">
  6037. AND d.id = #{qcResultShortPageVO.casesEntryId}
  6038. </if>
  6039. <if test="qcResultShortPageVO.isReject != null">
  6040. AND c.is_reject = #{qcResultShortPageVO.isReject}
  6041. </if>
  6042. <if test="qcResultShortPageVO.ruleType != null">
  6043. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  6044. </if>
  6045. )be
  6046. left join med_check_info mci
  6047. on mci.is_deleted = 'N'
  6048. and mci.check_type = 0
  6049. and be.hospital_id = mci.hospital_id
  6050. and be.behospital_code = mci.behospital_code
  6051. left join med_check_info hm_mci
  6052. on hm_mci.is_deleted = 'N'
  6053. and hm_mci.check_type = 1
  6054. and be.hospital_id = hm_mci.hospital_id
  6055. and be.behospital_code = hm_mci.behospital_code
  6056. ) t1
  6057. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  6058. AND t1.behospital_code = t2.behospital_code
  6059. AND t2.is_deleted = 'N'
  6060. ) t
  6061. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  6062. AND t.hospitalId = qi.hospital_id
  6063. AND t.behospitalCode = qi.behospital_code
  6064. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  6065. AND t.hospitalId = qd.hospital_id
  6066. AND t.behospitalCode = qd.behospital_code
  6067. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  6068. AND qd.cases_id = qc.id
  6069. where 1=1
  6070. <if test="qcResultShortPageVO.checkStatus != null">
  6071. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6072. </if>
  6073. <if test="qcResultShortPageVO.mrStatus != null">
  6074. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6075. </if>
  6076. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6077. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6078. </if>
  6079. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6080. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6081. </if>
  6082. <if test="qcResultShortPageVO.chTimeStart != null ">
  6083. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6084. </if>
  6085. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6086. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6087. </if>
  6088. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6089. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6090. </if>
  6091. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6092. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6093. </if>
  6094. )f1,
  6095. (SELECT
  6096. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  6097. t.behDeptId,
  6098. t.behDeptName
  6099. FROM
  6100. (SELECT DISTINCT
  6101. t1.hospital_id AS hospitalId,
  6102. t1.behospital_code AS behospitalCode,
  6103. t1.bed_code AS bedCode,
  6104. t1.LEVEL AS LEVEL,
  6105. t1.grade_type AS gradeType,
  6106. t1.score_res AS scoreRes,
  6107. t1.NAME AS NAME,
  6108. t1.sex AS sex,
  6109. t1.beh_dept_id AS behDeptId,
  6110. t1.beh_dept_name AS behDeptName,
  6111. t1.doctor_id AS doctorId,
  6112. t1.doctor_name AS doctorName,
  6113. t1.beh_doctor_id AS behDoctorId,
  6114. t1.beh_doctor_name AS behDoctorName,
  6115. t1.director_doctor_id AS directorDoctorId,
  6116. t1.director_doctor_name AS directorDoctorName,
  6117. t1.birthday AS birthday,
  6118. t1.behospital_date AS behospitalDate,
  6119. t1.leave_hospital_date AS leaveHospitalDate,
  6120. t1.placefile_date AS placefileDate,
  6121. t1.gmt_create AS gradeTime,
  6122. t1.diagnose,
  6123. t1.ward_name AS wardName,
  6124. t2.age,
  6125. t1.file_code AS fileCode,
  6126. t1.checkStatus,
  6127. t1.mrStatus,
  6128. t1.chName,
  6129. t1.mrName,
  6130. t1.chTime,
  6131. t1.mrTime
  6132. FROM
  6133. (SELECT
  6134. be.*,
  6135. ifnull(mci.status,0) AS checkStatus,
  6136. ifnull(hm_mci.status,0) AS mrStatus,
  6137. mci.check_name as chName,
  6138. hm_mci.check_name as mrName,
  6139. mci.gmt_create as chTime,
  6140. hm_mci.gmt_create as mrTime
  6141. FROM
  6142. (
  6143. SELECT DISTINCT
  6144. a.hospital_id,
  6145. a.behospital_code,
  6146. a.bed_code,
  6147. a.file_code,
  6148. b.LEVEL,
  6149. b.grade_type,
  6150. b.score_res,
  6151. a.NAME,
  6152. a.sex,
  6153. a.beh_dept_id,
  6154. a.beh_dept_name,
  6155. a.birthday,
  6156. a.behospital_date,
  6157. a.leave_hospital_date,
  6158. a.doctor_id,
  6159. a.doctor_name,
  6160. a.beh_doctor_id,
  6161. a.beh_doctor_name,
  6162. a.director_doctor_id,
  6163. a.director_doctor_name,
  6164. a.diagnose,
  6165. a.placefile_date,
  6166. a.ward_name,
  6167. b.gmt_create
  6168. FROM
  6169. med_behospital_info a,
  6170. med_qcresult_info b,
  6171. med_qcresult_detail c,
  6172. qc_cases_entry d
  6173. WHERE
  6174. a.is_deleted = 'N'
  6175. AND b.is_deleted = 'N'
  6176. AND c.is_deleted = 'N'
  6177. AND d.is_deleted = 'N'
  6178. AND a.hospital_id = b.hospital_id
  6179. AND a.hospital_id = c.hospital_id
  6180. AND a.behospital_code = b.behospital_code
  6181. AND a.behospital_code = c.behospital_code
  6182. AND c.cases_id = d.cases_id
  6183. AND c.cases_entry_id = d.id
  6184. AND a.qc_type_id != 0
  6185. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6186. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6187. </if>
  6188. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6189. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6190. </if>
  6191. <if test="qcResultShortPageVO.startDate != null ">
  6192. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6193. </if>
  6194. <if test="qcResultShortPageVO.endDate != null ">
  6195. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6196. </if>
  6197. <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
  6198. AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
  6199. </if>
  6200. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6201. AND b.`level` = #{qcResultShortPageVO.level}
  6202. </if>
  6203. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6204. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6205. </if>
  6206. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6207. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6208. </if>
  6209. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  6210. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  6211. </if>
  6212. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6213. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6214. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6215. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  6216. </if>
  6217. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6218. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6219. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6220. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  6221. </if>
  6222. <if test="qcResultShortPageVO.casesEntryId != null ">
  6223. AND d.id = #{qcResultShortPageVO.casesEntryId}
  6224. </if>
  6225. <if test="qcResultShortPageVO.isReject != null">
  6226. AND c.is_reject = #{qcResultShortPageVO.isReject}
  6227. </if>
  6228. <if test="qcResultShortPageVO.ruleType != null">
  6229. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  6230. </if>
  6231. )be
  6232. left join med_check_info mci
  6233. on mci.is_deleted = 'N'
  6234. and mci.check_type = 0
  6235. and be.hospital_id = mci.hospital_id
  6236. and be.behospital_code = mci.behospital_code
  6237. left join med_check_info hm_mci
  6238. on hm_mci.is_deleted = 'N'
  6239. and hm_mci.check_type = 1
  6240. and be.hospital_id = hm_mci.hospital_id
  6241. and be.behospital_code = hm_mci.behospital_code
  6242. ) t1
  6243. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  6244. AND t1.behospital_code = t2.behospital_code
  6245. AND t2.is_deleted = 'N'
  6246. ) t
  6247. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  6248. AND t.hospitalId = qi.hospital_id
  6249. AND t.behospitalCode = qi.behospital_code
  6250. where 1=1
  6251. <if test="qcResultShortPageVO.checkStatus != null">
  6252. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6253. </if>
  6254. <if test="qcResultShortPageVO.mrStatus != null">
  6255. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6256. </if>
  6257. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6258. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6259. </if>
  6260. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6261. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6262. </if>
  6263. <if test="qcResultShortPageVO.chTimeStart != null ">
  6264. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6265. </if>
  6266. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6267. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6268. </if>
  6269. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6270. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6271. </if>
  6272. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6273. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6274. </if>
  6275. GROUP BY
  6276. t.behDeptId,
  6277. t.behDeptName
  6278. )f2
  6279. WHERE
  6280. f1.behDeptId = f2.behDeptId
  6281. AND f1.behDeptName = f2.behDeptName
  6282. </select>
  6283. <!-- 31天再入院详情页-->
  6284. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  6285. SELECT
  6286. t.fileCode,
  6287. t.diagnose,
  6288. t.NAME,
  6289. t.sex,
  6290. t.hospitalId,
  6291. t.behDeptId,
  6292. t.behDeptName,
  6293. t.behospitalCode,
  6294. t.behospitalDate,
  6295. t.leaveHospitalDate,
  6296. t.lastBehDeptId,
  6297. t.lastBehDeptName,
  6298. t.lastBehospitalCode,
  6299. t.lastBehospitalDate,
  6300. t.lastLeaveHospitalDate,
  6301. t.diffDays,
  6302. mqi.score_res AS scoreRes,
  6303. mqi.LEVEL AS LEVEL,
  6304. mqi_last.score_res AS lastScoreRes,
  6305. mqi_last.LEVEL AS lastLevel
  6306. FROM
  6307. (
  6308. SELECT
  6309. be.fileCode,
  6310. be.diagnose,
  6311. be.NAME,
  6312. be.sex,
  6313. be.hospitalId,
  6314. be.behDeptId,
  6315. be.behDeptName,
  6316. be.behospitalCode,
  6317. be.behospitalDate,
  6318. be.leaveHospitalDate,
  6319. be.lastBehDeptId,
  6320. be.lastBehDeptName,
  6321. be.lastBehospitalCode,
  6322. be.lastBehospitalDate,
  6323. be.lastLeaveHospitalDate,
  6324. be.diffDays
  6325. FROM
  6326. (
  6327. SELECT
  6328. r1.file_code AS fileCode,
  6329. r1.diagnose,
  6330. r1.NAME,
  6331. r1.sex,
  6332. r1.hospital_id AS hospitalId,
  6333. r1.beh_dept_id AS behDeptId,
  6334. r1.beh_dept_name AS behDeptName,
  6335. r1.behospital_code AS behospitalCode,
  6336. r1.behospital_date AS behospitalDate,
  6337. r1.leave_hospital_date AS leaveHospitalDate,
  6338. r2.beh_dept_id AS lastBehDeptId,
  6339. r2.beh_dept_name AS lastBehDeptName,
  6340. r2.behospital_code AS lastBehospitalCode,
  6341. r2.behospital_date AS lastBehospitalDate,
  6342. r2.leave_hospital_date AS lastLeaveHospitalDate,
  6343. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  6344. FROM
  6345. (
  6346. SELECT
  6347. ( @rownum := @rownum + 1 ) AS rownum,
  6348. t1.file_code,
  6349. t1.diagnose,
  6350. t1.NAME,
  6351. t1.sex,
  6352. t1.hospital_id,
  6353. t1.beh_dept_id,
  6354. t1.beh_dept_name,
  6355. t1.behospital_code,
  6356. t1.behospital_date,
  6357. t1.leave_hospital_date
  6358. FROM
  6359. (
  6360. SELECT
  6361. tt1.file_code,
  6362. tt1.diagnose,
  6363. tt2.NAME,
  6364. tt2.sex,
  6365. tt2.hospital_id,
  6366. tt2.beh_dept_id,
  6367. tt2.beh_dept_name,
  6368. tt2.behospital_code,
  6369. tt2.behospital_date,
  6370. tt2.leave_hospital_date
  6371. FROM
  6372. (
  6373. SELECT
  6374. a.file_code,
  6375. a.diagnose
  6376. FROM
  6377. med_behospital_info a
  6378. WHERE
  6379. a.is_deleted = 'N'
  6380. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  6381. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  6382. </if>
  6383. AND a.qc_type_id != 0
  6384. AND IFNULL( a.diagnose, '' )!= ''
  6385. AND IFNULL( a.file_code, '' )!= ''
  6386. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  6387. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  6388. </if>
  6389. <if test="reBeHosPageVO.startDate != null">
  6390. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  6391. </if>
  6392. <if test="reBeHosPageVO.endDate != null">
  6393. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  6394. </if>
  6395. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  6396. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  6397. </if>
  6398. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  6399. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  6400. </if>
  6401. GROUP BY
  6402. a.file_code,
  6403. a.diagnose
  6404. HAVING
  6405. count(*)> 1
  6406. ) tt1,
  6407. med_behospital_info tt2
  6408. WHERE
  6409. tt2.is_deleted = 'N'
  6410. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  6411. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  6412. </if>
  6413. AND tt2.qc_type_id != 0
  6414. AND tt1.file_code = tt2.file_code
  6415. AND tt1.diagnose = tt2.diagnose
  6416. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  6417. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  6418. </if>
  6419. <if test="reBeHosPageVO.startDate != null">
  6420. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  6421. </if>
  6422. <if test="reBeHosPageVO.endDate != null">
  6423. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  6424. </if>
  6425. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  6426. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  6427. </if>
  6428. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  6429. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  6430. </if>
  6431. ORDER BY
  6432. tt1.file_code,
  6433. tt1.diagnose,
  6434. tt2.behospital_date DESC
  6435. ) t1,
  6436. ( SELECT @rownum := 0 ) r
  6437. ) r1
  6438. LEFT JOIN (
  6439. SELECT
  6440. ( @INDEX := @INDEX + 1 ) AS rownum,
  6441. t1.file_code,
  6442. t1.diagnose,
  6443. t1.NAME,
  6444. t1.sex,
  6445. t1.hospital_id,
  6446. t1.beh_dept_id,
  6447. t1.beh_dept_name,
  6448. t1.behospital_code,
  6449. t1.behospital_date,
  6450. t1.leave_hospital_date
  6451. FROM
  6452. (
  6453. SELECT
  6454. tt1.file_code,
  6455. tt1.diagnose,
  6456. tt2.NAME,
  6457. tt2.sex,
  6458. tt2.hospital_id,
  6459. tt2.beh_dept_id,
  6460. tt2.beh_dept_name,
  6461. tt2.behospital_code,
  6462. tt2.behospital_date,
  6463. tt2.leave_hospital_date
  6464. FROM
  6465. (
  6466. SELECT
  6467. a.file_code,
  6468. a.diagnose
  6469. FROM
  6470. med_behospital_info a
  6471. WHERE
  6472. a.is_deleted = 'N'
  6473. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  6474. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  6475. </if>
  6476. AND a.qc_type_id != 0
  6477. AND IFNULL( a.diagnose, '' )!= ''
  6478. AND IFNULL( a.file_code, '' )!= ''
  6479. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  6480. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  6481. </if>
  6482. <if test="reBeHosPageVO.startDate != null ">
  6483. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  6484. </if>
  6485. <if test="reBeHosPageVO.endDate != null ">
  6486. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  6487. </if>
  6488. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  6489. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  6490. </if>
  6491. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  6492. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  6493. </if>
  6494. GROUP BY
  6495. a.file_code,
  6496. a.diagnose
  6497. HAVING
  6498. count(*)> 1
  6499. ) tt1,
  6500. med_behospital_info tt2
  6501. WHERE
  6502. tt2.is_deleted = 'N'
  6503. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  6504. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  6505. </if>
  6506. AND tt2.qc_type_id != 0
  6507. AND tt1.file_code = tt2.file_code
  6508. AND tt1.diagnose = tt2.diagnose
  6509. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  6510. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  6511. </if>
  6512. <if test="reBeHosPageVO.startDate != null ">
  6513. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  6514. </if>
  6515. <if test="reBeHosPageVO.endDate != null ">
  6516. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  6517. </if>
  6518. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  6519. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  6520. </if>
  6521. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  6522. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  6523. </if>
  6524. ORDER BY
  6525. tt1.file_code,
  6526. tt1.diagnose,
  6527. tt2.behospital_date DESC
  6528. ) t1,(
  6529. SELECT
  6530. @INDEX := 0
  6531. ) r
  6532. ) r2 ON r1.file_code = r2.file_code
  6533. AND r1.rownum = r2.rownum - 1
  6534. ) be
  6535. WHERE
  6536. be.diffDays IS NOT NULL
  6537. AND be.diffDays BETWEEN 0
  6538. AND 31
  6539. ) t
  6540. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  6541. AND t.hospitalId = mqi.hospital_id
  6542. AND t.behospitalCode = mqi.behospital_code
  6543. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  6544. AND t.hospitalId = mqi_last.hospital_id
  6545. AND t.lastBehospitalCode = mqi_last.behospital_code
  6546. </select>
  6547. </mapper>