12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
- <id column="behospital_code" property="behospitalCode"/>
- <result column="hospital_id" property="hospitalId"/>
- <result column="name" property="name"/>
- <result column="sex" property="sex"/>
- <result column="birthday" property="birthday"/>
- <result column="file_code" property="fileCode"/>
- <result column="qc_type_id" property="qcTypeId"/>
- <result column="ward_code" property="wardCode"/>
- <result column="ward_name" property="wardName"/>
- <result column="beh_dept_id" property="behDeptId"/>
- <result column="beh_dept_name" property="behDeptName"/>
- <result column="bed_code" property="bedCode"/>
- <result column="bed_name" property="bedName"/>
- <result column="insurance_name" property="insuranceName"/>
- <result column="job_type" property="jobType"/>
- <result column="behospital_date" property="behospitalDate"/>
- <result column="leave_hospital_date" property="leaveHospitalDate"/>
- <result column="diagnose_icd" property="diagnoseIcd"/>
- <result column="diagnose" property="diagnose"/>
- <result column="beh_doctor_id" property="behDoctorId"/>
- <result column="beh_doctor_name" property="behDoctorName"/>
- <result column="doctor_id" property="doctorId"/>
- <result column="doctor_name" property="doctorName"/>
- <result column="director_doctor_id" property="directorDoctorId"/>
- <result column="director_doctor_name" property="directorDoctorName"/>
- <result column="is_placefile" property="isPlacefile"/>
- <result column="placefile_date" property="placefileDate"/>
- <result column="is_deleted" property="isDeleted"/>
- <result column="gmt_create" property="gmtCreate"/>
- <result column="gmt_modified" property="gmtModified"/>
- <result column="creator" property="creator"/>
- <result column="modifier" property="modifier"/>
- </resultMap>
- <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
- SELECT * FROM (
- select t.*,
- CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type AS ch_type,
- h.check_type AS mr_type,
- g.check_name AS ch_name,
- h.check_name AS mr_name,
- g.check_time AS ch_time,
- h.check_time AS mr_time
- from (
- select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
- grade_time, c.age from med_behospital_info a
- LEFT JOIN med_qcresult_info b
- on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
- left join med_home_page c
- on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
- ) t
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON t.behospital_code = g.behospital_code
- AND t.hospital_id = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON t.behospital_code = h.behospital_code
- AND t.hospital_id = h.hospital_id
- where t.is_deleted = 'N'
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="doctorName != null and doctorName != ''">
- and CONCAT(
- IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
- like CONCAT('%',#{doctorName},'%')
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- and (t.doctor_id = #{doctorCode}
- or t.beh_doctor_id = #{doctorCode}
- or t.director_doctor_id = #{doctorCode})
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="hospitalId != null">
- and t.hospital_id = #{hospitalId}
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- <if test="isPlacefile != null and isPlacefile != ''">
- and t.is_placefile = #{isPlacefile}
- </if>
- and t.qc_type_id != 0) p
- where p.is_deleted="N"
- <if test="checkStatus != null ">
- and p.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND p.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND p.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND p.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
- SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
- a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
- c.opt_type, c.grade_type, c.gmt_create, c.gmt_modified,
- a.type, a.drgs
- FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
- where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
- and a.id = c.cases_entry_id
- and a.mode_id = b.id
- AND c.cases_id = d.cases_id
- and c.hospital_id = d.hospital_id
- and c.hospital_id = #{hospitalId}
- and c.behospital_code = #{behospitalCode}
- order by b.order_no, c.grade_type desc, a.order_no
- </select>
- <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
- SELECT b.id model_id,b.`name` model_name,
- d.score,d.msg,d.cases_entry_id,d.is_reject,
- a.cases_id cases_id, a.name standard_msg,a.code
- FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
- where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
- and a.mode_id = b.id
- and a.id = d.cases_entry_id
- and d.is_used = 1
- and d.hospital_id = #{hospitalId}
- and a.code in
- <foreach collection="codeList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- <if test="modeId != null">
- and a.mode_id = #{modeId}
- </if>
- order by b.order_no, a.order_no;
- </select>
- <!-- 各科室缺陷占比-全院-首页 -->
- <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
- resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id as id,
- a.beh_dept_name as name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ORDER BY
- count(*) DESC
- </select>
- <!-- 质控结果缺陷总数查询-->
- <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!--获取病历-->
- <select id="getNoGrade" resultMap="BaseResultMap">
- select * from med_behospital_info a
- where a.is_deleted = 'N'
- and a.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="filterFlag != null and filterFlag == 0">
- and
- not EXISTS (
- SELECT
- 1
- FROM
- med_qcresult_info b
- WHERE
- b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- )
- </if>
- <if test="leaveDate != null">
- <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
- </if>
- <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
- and a.hospital_id in
- <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
- and a.behospital_code in
- <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="individuation != null and individuation.contains(1)">
- union
- select * from med_behospital_info b
- where b.is_deleted = 'N'
- and b.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and b.is_placefile = #{isPlacefile}
- </if>
- <if test="startLeaveDate != null">
- <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
- </if>
- <if test="endLeaveDate != null">
- <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
- </if>
- <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
- and b.hospital_id in
- <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- </select>
- <!--质控评分(科室)分页-->
- <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
- SELECT * from (
- SELECT
- t.*,
- CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type as ch_type,
- h.check_type AS mr_type,
- g.check_name as ch_name,
- h.check_name as mr_name,
- g.check_time as ch_time,
- h.check_time AS mr_time
- FROM
- ( SELECT
- a.*,
- IFNULL(b.level, '未评分') AS `level`,
- b.grade_type,
- b.score_res,
- b.gmt_create AS grade_time,
- c.age
- FROM
- med_behospital_info a
- JOIN sys_user_dept d
- ON a.hospital_id = d.hospital_id
- AND a.beh_dept_id = d.dept_id
- LEFT JOIN med_qcresult_info b
- ON a.behospital_code = b.behospital_code
- AND b.is_deleted = 'N'
- LEFT JOIN med_home_page c
- ON a.behospital_code = c.behospital_code
- AND c.is_deleted = 'N'
- WHERE d.is_deleted = 'N'
- AND d.user_id = #{userId}
- ) t
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON t.behospital_code = g.behospital_code
- AND t.hospital_id = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON t.behospital_code = h.behospital_code
- AND t.hospital_id = h.hospital_id
- where t.is_deleted = 'N'
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="doctorName != null and doctorName != ''">
- and CONCAT(
- IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
- like CONCAT('%',#{doctorName},'%')
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- and (t.doctor_id = #{doctorCode}
- or t.beh_doctor_id = #{doctorCode}
- or t.director_doctor_id = #{doctorCode})
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="hospitalId != null">
- and t.hospital_id = #{hospitalId}
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- <if test="isPlacefile != null and isPlacefile != ''">
- and t.is_placefile = #{isPlacefile}
- </if>
- and t.qc_type_id != 0) p
- where p.is_deleted="N"
- <if test="checkStatus != null ">
- and p.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND p.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND p.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND p.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <!--质控评分(个人)分页-->
- <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
- Select * from (
- select t.*,
- CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type as ch_type,
- h.check_type AS mr_type,
- g.check_name as ch_name,
- h.check_name as mr_name,
- g.check_time as ch_time,
- h.check_time AS mr_time
- from (SELECT
- a.*,
- IFNULL(b.level, '未评分') AS `level`,
- b.grade_type,
- b.score_res,
- b.gmt_create AS grade_time,
- c.age
- FROM
- med_behospital_info a
- JOIN
- (SELECT
- u.id,
- u.linkman AS linkman,
- uh.hospital_id
- FROM
- sys_user u
- JOIN sys_user_hospital uh
- ON u.id = uh.user_id
- WHERE u.is_deleted = "N"
- AND u.id = #{userId}
- AND uh.hospital_id = #{hospitalId}) u1
- ON a.hospital_id = u1.hospital_id
- LEFT JOIN med_qcresult_info b
- ON a.behospital_code = b.behospital_code
- AND b.is_deleted = 'N'
- LEFT JOIN med_home_page c
- ON a.behospital_code = c.behospital_code
- AND c.is_deleted = 'N'
- WHERE CONCAT(
- IFNULL(a.doctor_name, ''),
- IFNULL(a.beh_doctor_name, ''),
- IFNULL(a.director_doctor_name, '')
- ) LIKE CONCAT('%', u1.linkman, '%')
- ) t
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON t.behospital_code = g.behospital_code
- AND t.hospital_id = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON t.behospital_code = h.behospital_code
- AND t.hospital_id = h.hospital_id
- WHERE t.is_deleted = 'N'
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- <if test="isPlacefile != null and isPlacefile != ''">
- and t.is_placefile = #{isPlacefile}
- </if>
- and t.qc_type_id != 0) p
- where p.is_deleted="N"
- <if test="checkStatus != null ">
- and p.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND p.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND p.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND p.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <!--质控评分(医疗组)分页-->
- <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
- select * from (
- select t.*,
- CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type as ch_type,
- h.check_type AS mr_type,
- g.check_name as ch_name,
- h.check_name as mr_name,
- g.check_time as ch_time,
- h.check_time AS mr_time
- from (
- select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
- grade_time, c.age from med_behospital_info a
- LEFT JOIN med_qcresult_info b
- on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
- left join med_home_page c
- on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
- ) t
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON t.behospital_code = g.behospital_code
- AND t.hospital_id = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON t.behospital_code = h.behospital_code
- AND t.hospital_id = h.hospital_id
- WHERE t.is_deleted = 'N'
- and
- t.doctor_id in (
- SELECT doctor_id FROM `bas_doctor_info`
- where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
- select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
- where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
- and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
- and c1.username = c3.doctor_id
- and c2.hospital_id = #{hospitalId}
- and c1.id = #{userId}
- )
- )
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="doctorName != null and doctorName != ''">
- and (t.doctor_name like CONCAT('%',#{doctorName},'%')
- or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- and (t.doctor_id = #{doctorCode}
- or t.beh_doctor_id = #{doctorCode}
- or t.director_doctor_id = #{doctorCode})
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="hospitalId != null">
- and t.hospital_id = #{hospitalId}
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- <if test="isPlacefile != null and isPlacefile != ''">
- and t.is_placefile = #{isPlacefile}
- </if>
- and t.qc_type_id != 0) p
- where p.is_deleted="N"
- <if test="checkStatus != null ">
- and p.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND p.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND p.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND p.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <!-- 出院总人数统计-全院-首页 -->
- <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- COUNT(*)
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!-- 新生儿出院人数统计-全院-首页 -->
- <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- COUNT(*)
- FROM
- med_behospital_info a,
- med_home_page b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND (
- ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' )
- OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' )
- )
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!-- 死亡人数统计-全院-首页 -->
- <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- COUNT(*)
- FROM
- med_behospital_info a,
- med_home_page b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- AND b.return_to_type = '死亡'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!-- 手术人数统计-全院-首页 -->
- <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- COUNT( DISTINCT a.behospital_code )
- FROM
- med_behospital_info a,
- med_medical_record c,
- qc_mode d
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = c.behospital_code
- AND c.mode_id = d.id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND d.`name` = '手术记录'
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!-- 出院总人数统计-科室-首页 -->
- <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
- resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- COUNT(*) AS num
- FROM
- med_behospital_info a,
- sys_user_dept c
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.beh_dept_id = c.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="userId!=null">
- AND c.user_id = #{userId}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 新生儿出院人数统计-科室-首页 -->
- <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
- resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- COUNT(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- sys_user_dept c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.beh_dept_id = c.dept_id
- AND (
- ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' )
- OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' )
- )
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND c.user_id = #{userId}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 死亡人数统计-科室-首页 -->
- <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
- resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- COUNT(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- sys_user_dept c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.beh_dept_id = c.dept_id
- AND b.return_to_type = '死亡'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND c.user_id = #{userId}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 手术人数统计-科室-首页 -->
- <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
- resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- COUNT( DISTINCT a.behospital_code ) AS num
- FROM
- med_behospital_info a,
- sys_user_dept c,
- med_medical_record d,
- qc_mode e
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.beh_dept_id = c.dept_id
- AND d.mode_id = e.id
- AND e.`name` = '手术记录'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND c.user_id = #{userId}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 各科室缺陷占比排行(分页) -->
- <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
- SELECT t.*
- FROM
- (SELECT
- t1.beh_dept_name AS NAME,
- t1.num AS num,
- t2.totle AS totleNum,
- round( t1.num / t2.totle, 4 ) AS percent,
- concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
- FROM
- (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
- and a.is_placefile = #{filterPageVO.isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ORDER BY
- count(*) DESC
- ) t1,
- (
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
- and a.is_placefile = #{filterPageVO.isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- ) t2
- )t
- </select>
- <!-- 科室缺陷占比(主任医生) -->
- <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
- SELECT
- t.*
- FROM
- (
- SELECT
- t1.NAME,
- t1.num AS num,
- t2.totle AS totleNum,
- round( t1.num / t2.totle, 4 ) AS percent,
- concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
- FROM
- (
- SELECT
- d.msg as name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d,
- sys_user_dept e
- WHERE
- a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.beh_dept_id = e.dept_id
- <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
- and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.userId!=null">
- AND e.user_id = #{filterPageByDeptVO.userId}
- </if>
- <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
- </if>
- <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
- </if>
- <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
- </if>
- <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
- AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
- AND a.doctor_name = #{filterPageByDeptVO.doctorName}
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
- </if>
- GROUP BY
- d.msg
- ORDER BY
- count(*) DESC
- ) t1,
- (
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d,
- sys_user_dept e
- WHERE
- a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.beh_dept_id = e.dept_id
- <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
- and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.userId!=null">
- AND e.user_id = #{filterPageByDeptVO.userId}
- </if>
- <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
- </if>
- <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
- </if>
- <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
- </if>
- <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
- AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
- AND a.doctor_name = #{filterPageByDeptVO.doctorName}
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
- </if>
- ) t2
- )t
- </select>
- <!-- 各科室缺陷占比(组合)-全院 -->
- <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
- resultType="com.diagbot.dto.LevelStatisticsDTO">
- SELECT
- t1.deptId,
- t1.deptName,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.thirdLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.thirdLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr,
- t1.thirdLevelPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count(*) AS mrNum,
- ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
- SUM( c.`level` = '甲' ) AS firstLevelNum,
- SUM( c.`level` = '乙' ) AS secondLevelNum,
- SUM( c.`level` = '丙' ) AS thirdLevelNum,
- ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
- ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
- ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
- concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
- concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
- concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
- FROM
- med_behospital_info a,
- med_qcresult_info c
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = c.behospital_code
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t1,
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases_entry e
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t2
- WHERE
- t1.deptId = t2.deptId
- AND t1.deptName = t2.deptName
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="deptId"'>deptId asc</when>
- <when test='asc=="deptName"'>deptName asc</when>
- <when test='asc=="entryNum"'>entryNum asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="totleValue"'>totleValue asc</when>
- <when test='asc=="averageValue"'>averageValue asc</when>
- <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
- <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
- <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
- <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
- <otherwise>deptName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="deptId"'>deptId desc</when>
- <when test='desc=="deptName"'>deptName desc</when>
- <when test='desc=="entryNum"'>entryNum desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="totleValue"'>totleValue desc</when>
- <when test='desc=="averageValue"'>averageValue desc</when>
- <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
- <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
- <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
- <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
- <otherwise>deptName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
- <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
- resultType="com.diagbot.dto.LevelStatisticsTZDTO">
- SELECT
- t1.deptId,
- t1.deptName,
- t1.deptClassId,
- t1.deptClass,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.thirdLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.thirdLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr,
- t1.thirdLevelPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- e.dept_id AS deptClassId,
- e.dept_name AS deptClass,
- count( DISTINCT c.id ) AS mrNum,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
- COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
- COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
- COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
- ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
- ) AS firstLevelPercent,
- ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
- ) AS secondLevelPercent,
- ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
- ) AS thirdLevelPercent,
- concat(
- ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
- 100, 2 ),
- '%'
- ) AS firstLevelPercentStr,
- concat(
- ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
- 100, 2 ),
- '%'
- ) AS secondLevelPercentStr,
- concat(
- ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
- 100, 2 ),
- '%'
- ) AS thirdLevelPercentStr
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- bas_dept_info d,
- bas_dept_info e
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.hospital_id = e.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.beh_dept_id = d.dept_id
- AND d.parent_dept_id = e.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- <if test="deptClass != null and deptClass != ''">
- and e.dept_name = #{deptClass}
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name,
- e.dept_id,
- e.dept_name
- ) t1,
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- g.dept_id AS deptClassId,
- g.dept_name AS deptClass,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases_entry e,
- bas_dept_info f,
- bas_dept_info g
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND f.is_deleted = 'N'
- AND g.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.hospital_id = f.hospital_id
- AND a.hospital_id = g.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND a.beh_dept_id = f.dept_id
- AND f.parent_dept_id = g.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- <if test="deptClass != null and deptClass != ''">
- and g.dept_name = #{deptClass}
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name,
- g.dept_id,
- g.dept_name
- ) t2
- WHERE
- t1.deptId = t2.deptId
- AND t1.deptName = t2.deptName
- AND t1.deptClassId = t2.deptClassId
- AND t1.deptClass = t2.deptClass
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="deptId"'>deptId asc</when>
- <when test='asc=="deptName"'>deptName asc</when>
- <when test='asc=="deptClassId"'>deptClassId asc</when>
- <when test='asc=="deptClass"'>deptClass asc</when>
- <when test='asc=="entryNum"'>entryNum asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="totleValue"'>totleValue asc</when>
- <when test='asc=="averageValue"'>averageValue asc</when>
- <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
- <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
- <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
- <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
- <otherwise>deptName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="deptId"'>deptId desc</when>
- <when test='desc=="deptName"'>deptName desc</when>
- <when test='desc=="deptClassId"'>deptClassId desc</when>
- <when test='desc=="deptClass"'>deptClass desc</when>
- <when test='desc=="entryNum"'>entryNum desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="totleValue"'>totleValue desc</when>
- <when test='desc=="averageValue"'>averageValue desc</when>
- <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
- <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
- <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
- <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
- <otherwise>deptName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
- <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
- SELECT
- t1.deptId,
- t1.deptName,
- t1.deptClassId,
- t1.deptClass,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.thirdLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.thirdLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr,
- t1.thirdLevelPercentStr
- FROM
- (
- SELECT
- tt1.deptId,
- tt1.deptName,
- e.dept_id AS deptClassId,
- e.dept_name AS deptClass,
- count(*) AS mrNum,
- ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
- sum( tt1.`level` = '甲' ) AS firstLevelNum,
- sum( tt1.`level` = '乙' ) AS secondLevelNum,
- sum( tt1.`level` = '丙' ) AS thirdLevelNum,
- ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
- ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
- ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
- concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
- concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
- concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- d.parent_dept_id AS parentDeptId,
- a.hospital_id AS hospitalId,
- a.behospital_code AS behospitalCode,
- c.score_res AS score,
- c.LEVEL
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- bas_dept_info d
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.beh_dept_id = d.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- ) tt1
- LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
- AND e.is_deleted = 'N'
- AND tt1.hospitalId = e.hospital_id
- <if test="deptClass != null and deptClass != ''">
- WHERE e.dept_name = #{deptClass}
- </if>
- GROUP BY
- tt1.deptId,
- tt1.deptName,
- e.dept_id,
- e.dept_name
- ) t1,
- (
- SELECT
- tt2.deptId,
- tt2.deptName,
- g.dept_id AS deptClassId,
- g.dept_name AS deptClass,
- count( * ) AS entryNum
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- f.parent_dept_id AS parentDeptId,
- a.hospital_id AS hospitalId,
- a.behospital_code AS behospitalCode
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases_entry e,
- bas_dept_info f
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND f.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.hospital_id = f.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND a.beh_dept_id = f.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- ) tt2
- LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
- AND g.is_deleted = 'N'
- AND tt2.hospitalId = g.hospital_id
- <if test="deptClass != null and deptClass != ''">
- WHERE g.dept_name = #{deptClass}
- </if>
- GROUP BY
- tt2.deptId,
- tt2.deptName,
- g.dept_id,
- g.dept_name
- ) t2
- WHERE
- t1.deptId = t2.deptId
- AND t1.deptName = t2.deptName
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="deptId"'>deptId asc</when>
- <when test='asc=="deptName"'>deptName asc</when>
- <when test='asc=="deptClassId"'>deptClassId asc</when>
- <when test='asc=="deptClass"'>deptClass asc</when>
- <when test='asc=="entryNum"'>entryNum asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="totleValue"'>totleValue asc</when>
- <when test='asc=="averageValue"'>averageValue asc</when>
- <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
- <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
- <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
- <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
- <otherwise>deptName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="deptId"'>deptId desc</when>
- <when test='desc=="deptName"'>deptName desc</when>
- <when test='desc=="deptClassId"'>deptClassId desc</when>
- <when test='desc=="deptClass"'>deptClass desc</when>
- <when test='desc=="entryNum"'>entryNum desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="totleValue"'>totleValue desc</when>
- <when test='desc=="averageValue"'>averageValue desc</when>
- <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
- <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
- <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
- <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
- <otherwise>deptName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 病案首页合格率占比 -全院-->
- <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
- resultType="com.diagbot.dto.HomePageNumDTO">
- SELECT
- t1.deptId,
- t1.deptName,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr,
- t3.emptyNum,
- t3.errorNum,
- t3.entryTotleNum,
- t3.emptyPercent,
- t3.errorPercent,
- t3.emptyPercentStr,
- t3.errorPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count( * ) AS mrNum,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
- SUM( c.`level` = '合格' ) AS firstLevelNum,
- SUM( c.`level` = '不合格' ) AS secondLevelNum,
- ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
- ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
- concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
- concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
- FROM
- med_behospital_info a,
- med_qcresult_cases c
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t1,
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_qcresult_cases c,
- med_qcresult_detail d,
- qc_cases_entry e
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND c.cases_id = d.cases_id
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND d.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t2,(
- SELECT
- h1.deptId,
- h1.deptName,
- h1.emptyNum,
- h1.errorNum,
- h1.mrNum,
- h2.entryNum,
- h1.mrNum * h2.entryNum AS entryTotleNum,
- ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
- ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
- CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
- CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- sum( d.rule_type = 1 ) AS emptyNum,
- sum( d.rule_type = 2 ) AS errorNum,
- count( DISTINCT a.behospital_code ) AS mrNum
- FROM
- med_behospital_info a,
- med_qcresult_cases b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND b.cases_id = c.cases_id
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND d.cases_id = 243
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and b.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) h1,(
- SELECT
- count(*) AS entryNum
- FROM
- qc_cases_entry
- WHERE
- is_deleted = 'N'
- AND cases_id = 243
- ) h2
- ) t3
- WHERE
- t1.deptId = t2.deptId
- AND t1.deptId = t3.deptId
- AND t1.deptName = t2.deptName
- AND t1.deptName = t3.deptName
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="deptId"'>deptId asc</when>
- <when test='asc=="deptName"'>deptName asc</when>
- <when test='asc=="entryNum"'>entryNum asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="totleValue"'>totleValue asc</when>
- <when test='asc=="averageValue"'>averageValue asc</when>
- <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
- <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
- <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="emptyNum"'>emptyNum asc</when>
- <when test='asc=="errorNum"'>errorNum asc</when>
- <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
- <when test='asc=="emptyPercent"'>emptyPercent asc</when>
- <when test='asc=="errorPercent"'>errorPercent asc</when>
- <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
- <when test='asc=="errorPercentStr"'>errorPercent asc</when>
- <otherwise>deptName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="deptId"'>deptId desc</when>
- <when test='desc=="deptName"'>deptName desc</when>
- <when test='desc=="entryNum"'>entryNum desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="totleValue"'>totleValue desc</when>
- <when test='desc=="averageValue"'>averageValue desc</when>
- <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
- <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
- <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="emptyNum"'>emptyNum desc</when>
- <when test='desc=="errorNum"'>errorNum desc</when>
- <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
- <when test='desc=="emptyPercent"'>emptyPercent desc</when>
- <when test='desc=="errorPercent"'>errorPercent desc</when>
- <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
- <when test='desc=="errorPercentStr"'>errorPercent desc</when>
- <otherwise>deptName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 各科室缺陷占比-科室 -->
- <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
- resultType="com.diagbot.dto.LevelStatisticsDTO">
- SELECT
- t1.doctorId,
- t1.doctorName,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.thirdLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.thirdLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr,
- t1.thirdLevelPercentStr
- FROM
- (
- SELECT
- a.doctor_id AS doctorId,
- a.doctor_name AS doctorName,
- count(*) AS mrNum,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
- SUM( c.`level` = '甲' ) AS firstLevelNum,
- SUM( c.`level` = '乙' ) AS secondLevelNum,
- SUM( c.`level` = '丙' ) AS thirdLevelNum,
- ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
- ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
- ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
- concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
- concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
- concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- sys_user_dept e
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.beh_dept_id = e.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.doctor_name like CONCAT('%',#{name},'%')
- </if>
- <if test="userId!=null and userId !=''">
- AND e.user_id = #{userId}
- </if>
- <if test="deptName!=null and deptName !=''">
- AND a.beh_dept_name = #{deptName}
- </if>
- GROUP BY
- a.doctor_id,
- a.doctor_name
- ) t1,
- (
- SELECT
- a.doctor_id AS doctorId,
- a.doctor_name AS doctorName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases_entry e,
- sys_user_dept f
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND f.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND a.beh_dept_id = f.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.doctor_name like CONCAT('%',#{name},'%')
- </if>
- <if test="userId!=null and userId !=''">
- AND f.user_id = #{userId}
- </if>
- <if test="deptName!=null and deptName !=''">
- AND a.beh_dept_name = #{deptName}
- </if>
- GROUP BY
- a.doctor_id,
- a.doctor_name
- ) t2
- WHERE
- t1.doctorId = t2.doctorId
- AND t1.doctorName = t2.doctorName
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="doctorId"'>doctorId asc</when>
- <when test='asc=="doctorName"'>doctorName asc</when>
- <when test='asc=="entryNum"'>entryNum asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="totleValue"'>totleValue asc</when>
- <when test='asc=="averageValue"'>averageValue asc</when>
- <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
- <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
- <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
- <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
- <otherwise>doctorName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="doctorId"'>doctorId desc</when>
- <when test='desc=="doctorName"'>doctorName desc</when>
- <when test='desc=="entryNum"'>entryNum desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="totleValue"'>totleValue desc</when>
- <when test='desc=="averageValue"'>averageValue desc</when>
- <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
- <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
- <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
- <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
- <otherwise>doctorName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 病案首页合格率占比-科室 -->
- <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
- resultType="com.diagbot.dto.HomePageNumDTO">
- SELECT
- t1.doctorId,
- t1.doctorName,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr,
- t3.emptyNum,
- t3.errorNum,
- t3.entryTotleNum,
- t3.emptyPercent,
- t3.errorPercent,
- t3.emptyPercentStr,
- t3.errorPercentStr
- FROM
- (
- SELECT
- CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
- CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
- count( * ) AS mrNum,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
- sum( c.`level` = '合格' ) AS firstLevelNum,
- sum( c.`level` = '不合格' ) AS secondLevelNum,
- ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
- ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
- concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
- concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
- FROM
- med_behospital_info a,
- med_qcresult_cases c,
- sys_user_dept f
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND f.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.beh_dept_id = f.dept_id
- AND c.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- <if test="name == '未知'">
- and (a.doctor_name is null or a.doctor_name='')
- </if>
- <if test="name != '未知'">
- and a.doctor_name like CONCAT('%',#{name},'%')
- </if>
- </if>
- <if test="userId!=null and userId !=''">
- AND f.user_id = #{userId}
- </if>
- <if test="deptName!=null and deptName !=''">
- AND a.beh_dept_name = #{deptName}
- </if>
- GROUP BY
- a.doctor_id,
- a.doctor_name
- ) t1,
- (
- SELECT
- CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
- CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_qcresult_cases c,
- med_qcresult_detail d,
- qc_cases_entry e,
- sys_user_dept f
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND f.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND a.beh_dept_id = f.dept_id
- AND c.cases_id = d.cases_id
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND c.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- <if test="name == '未知'">
- and (a.doctor_name is null or a.doctor_name='')
- </if>
- <if test="name != '未知'">
- and a.doctor_name like CONCAT('%',#{name},'%')
- </if>
- </if>
- <if test="userId!=null and userId !=''">
- AND f.user_id = #{userId}
- </if>
- <if test="deptName!=null and deptName !=''">
- AND a.beh_dept_name = #{deptName}
- </if>
- GROUP BY
- a.doctor_id,
- a.doctor_name
- ) t2,(
- SELECT
- h1.doctorId,
- h1.doctorName,
- h1.emptyNum,
- h1.errorNum,
- h1.mrNum,
- h2.entryNum,
- h1.mrNum * h2.entryNum AS entryTotleNum,
- ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
- ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
- CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
- CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
- FROM
- (
- SELECT
- CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
- CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
- sum( d.rule_type = 1 ) AS emptyNum,
- sum( d.rule_type = 2 ) AS errorNum,
- count( DISTINCT a.behospital_code ) AS mrNum
- FROM
- med_behospital_info a,
- med_qcresult_cases b,
- med_qcresult_detail c,
- qc_cases_entry d,
- sys_user_dept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = e.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND b.cases_id = c.cases_id
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.beh_dept_id = e.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND d.cases_id = 243
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="level != null and level != ''">
- and b.level = #{level}
- </if>
- <if test="name != null and name != ''">
- <if test="name == '未知'">
- and (a.doctor_name is null or a.doctor_name='')
- </if>
- <if test="name != '未知'">
- and a.doctor_name like CONCAT('%',#{name},'%')
- </if>
- </if>
- <if test="userId!=null and userId !=''">
- AND e.user_id = #{userId}
- </if>
- <if test="deptName!=null and deptName !=''">
- AND a.beh_dept_name = #{deptName}
- </if>
- GROUP BY
- a.doctor_id,
- a.doctor_name
- ) h1,(
- SELECT
- count(*) AS entryNum
- FROM
- qc_cases_entry
- WHERE
- is_deleted = 'N'
- AND cases_id = 243
- ) h2
- ) t3
- WHERE
- t1.doctorId = t2.doctorId
- AND t1.doctorId = t3.doctorId
- AND t1.doctorName = t2.doctorName
- AND t1.doctorName = t3.doctorName
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="doctorId"'>doctorId asc</when>
- <when test='asc=="doctorName"'>doctorName asc</when>
- <when test='asc=="entryNum"'>entryNum asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="totleValue"'>totleValue asc</when>
- <when test='asc=="averageValue"'>averageValue asc</when>
- <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
- <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
- <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="emptyNum"'>emptyNum asc</when>
- <when test='asc=="errorNum"'>errorNum asc</when>
- <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
- <when test='asc=="emptyPercent"'>emptyPercent asc</when>
- <when test='asc=="errorPercent"'>errorPercent asc</when>
- <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
- <when test='asc=="errorPercentStr"'>errorPercent asc</when>
- <otherwise>doctorName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="doctorId"'>doctorId desc</when>
- <when test='desc=="doctorName"'>doctorName desc</when>
- <when test='desc=="entryNum"'>entryNum desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="totleValue"'>totleValue desc</when>
- <when test='desc=="averageValue"'>averageValue desc</when>
- <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
- <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
- <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="emptyNum"'>emptyNum desc</when>
- <when test='desc=="errorNum"'>errorNum desc</when>
- <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
- <when test='desc=="emptyPercent"'>emptyPercent desc</when>
- <when test='desc=="errorPercent"'>errorPercent desc</when>
- <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
- <when test='desc=="errorPercentStr"'>errorPercent desc</when>
- <otherwise>doctorName desc</otherwise>
- </choose>
- </if>
- </select>
- <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
- <result column="behDeptName" property="behDeptName"/>
- <result column="avgScore" property="avgScore"/>
- <collection property="excelBehospitalDTOS"
- ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
- <result column="behDoctorName" property="behDoctorName"/>
- <result column="patName" property="patName"/>
- <result column="behospitalCode" property="behospitalCode"/>
- <result column="behospitalDate" property="behospitalDate"/>
- <result column="leaveHospitalDate" property="leaveHospitalDate"/>
- <result column="score" property="score"/>
- <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
- <result column="caseName" property="caseName"/>
- <collection property="exportExcelMsgDTOS"
- ofType="com.diagbot.dto.ExportExcelMsgDTO">
- <result column="msg" property="msg"/>
- </collection>
- </collection>
- </collection>
- </resultMap>
- <select id="exportExcel" resultMap="ExportExcelMap">
- SELECT DISTINCT
- t1.beh_dept_name AS behDeptName,
- t1.beh_doctor_name AS behDoctorName,
- t1.`name` AS patName,
- t1.behospital_code AS behospitalCode,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t2.score_res AS score,
- "1" AS avgScore,
- t4.`name` AS caseName,
- t3.msg AS msg
- FROM
- med_behospital_info t1,
- med_qcresult_info t2,
- med_qcresult_detail t3,
- qc_cases t4
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- AND t4.is_deleted = 'N'
- <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
- <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t1.hospital_id = t3.hospital_id
- AND t1.behospital_code = t3.behospital_code
- AND t3.cases_id = t4.id
- ORDER BY
- t1.beh_dept_id ASC,
- t1.leave_hospital_date DESC,
- t1.behospital_code ASC,
- t4.`name` ASC
- </select>
- <!-- 质控评分导出到excel-->
- <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
- SELECT * FROM (
- SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type AS ch_type,
- h.check_type AS mr_type,
- g.check_name AS ch_name,
- h.check_name AS mr_name,
- g.check_time AS ch_time,
- h.check_time AS mr_time
- FROM (
- SELECT
- t1.behDeptId,
- t1.behDeptName,
- t1.behDoctorName,
- t1.patName,
- t1.behospitalCode,
- t1.hospitalId,
- t1.behospitalDate,
- t1.leaveHospitalDate,
- t1.score,
- t2.avgScore,
- t1.msg,
- t1.caseName
- FROM
- (
- SELECT
- CONCAT(
- ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
- a.doctor_name
- ) AS behDoctorName,
- a.`name` AS patName,
- a.behospital_code AS behospitalCode,
- a.behospital_date AS behospitalDate,
- a.leave_hospital_date AS leaveHospitalDate,
- b.score_res AS score,
- c.msg AS msg,
- d.NAME AS caseName,
- a.beh_dept_id AS behDeptId,
- a.beh_dept_name AS behDeptName,
- a.hospital_id AS hospitalId
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="leaveHosDateStart != null ">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
- </if>
- <if test="leaveHosDateEnd != null ">
- <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="level != null and level != ''">
- AND b.level = #{level}
- </if>
- <if test="doctorName != null and doctorName != ''">
- AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
- </if>
- <if test="deptId != null and deptId != ''">
- AND a.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- AND a.name like CONCAT('%',#{name},'%')
- </if>
- ) t1,
- (
- SELECT
- ROUND( AVG( b.score_res ), 2 ) AS avgScore,
- a.beh_dept_id AS behDeptId,
- a.beh_dept_name AS behDeptName
- FROM
- med_behospital_info a,
- med_qcresult_info b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="leaveHosDateStart != null ">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
- </if>
- <if test="leaveHosDateEnd != null ">
- <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="level != null and level != ''">
- AND b.level = #{level}
- </if>
- <if test="doctorName != null and doctorName != ''">
- AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
- </if>
- <if test="deptId != null and deptId != ''">
- AND a.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- AND a.name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t2
- WHERE
- t1.behDeptId = t2.behDeptId
- AND t1.behDeptName = t2.behDeptName
- ORDER BY
- t1.behDeptName,
- t1.behDoctorName,
- t1.patName,
- t1.behospitalCode,
- t1.caseName)tp
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON tp.behospitalCode = g.behospital_code
- AND tp.hospitalId = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON tp.behospitalCode = h.behospital_code
- AND tp.hospitalId = h.hospital_id
- ) tu
- WHERE tu.behospitalCode IS NOT NULL
- <if test="checkStatus != null ">
- and tu.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND tu.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND tu.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND tu.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <!-- 科室质控评分导出到excel-->
- <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
- SELECT * FROM (
- SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type AS ch_type,
- h.check_type AS mr_type,
- g.check_name AS ch_name,
- h.check_name AS mr_name,
- g.check_time AS ch_time,
- h.check_time AS mr_time
- FROM (
- SELECT
- t1.behDeptId,
- t1.behDeptName,
- t1.behDoctorName,
- t1.patName,
- t1.behospitalCode,
- t1.hospitalId,
- t1.behospitalDate,
- t1.leaveHospitalDate,
- t1.score,
- t2.avgScore,
- t1.msg,
- t1.caseName
- FROM
- (
- SELECT
- CONCAT(
- ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
- a.doctor_name
- ) AS behDoctorName,
- a.`name` AS patName,
- a.behospital_code AS behospitalCode,
- a.behospital_date AS behospitalDate,
- a.leave_hospital_date AS leaveHospitalDate,
- b.score_res AS score,
- c.msg AS msg,
- d.NAME AS caseName,
- a.beh_dept_id AS behDeptId,
- a.beh_dept_name AS behDeptName,
- a.hospital_id AS hospitalId
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases d,
- sys_user_dept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = e.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.id
- AND a.beh_dept_id = e.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="userId != null ">
- AND e.user_id = #{userId}
- </if>
- <if test="leaveHosDateStart != null ">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
- </if>
- <if test="leaveHosDateEnd != null ">
- <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="level != null and level != ''">
- AND b.level = #{level}
- </if>
- <if test="doctorName != null and doctorName != ''">
- AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
- </if>
- <if test="deptId != null and deptId != ''">
- AND a.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- AND a.name like CONCAT('%',#{name},'%')
- </if>
- ) t1,
- (
- SELECT
- ROUND( AVG( b.score_res ), 2 ) AS avgScore,
- a.beh_dept_id AS behDeptId,
- a.beh_dept_name AS behDeptName
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- sys_user_dept c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.beh_dept_id = c.dept_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="userId != null ">
- AND c.user_id = #{userId}
- </if>
- <if test="leaveHosDateStart != null ">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
- </if>
- <if test="leaveHosDateEnd != null ">
- <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="level != null and level != ''">
- AND b.level = #{level}
- </if>
- <if test="doctorName != null and doctorName != ''">
- AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
- </if>
- <if test="deptId != null and deptId != ''">
- AND a.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- AND a.name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t2
- WHERE
- t1.behDeptId = t2.behDeptId
- AND t1.behDeptName = t2.behDeptName
- ORDER BY
- t1.behDeptName,
- t1.behDoctorName,
- t1.patName,
- t1.behospitalCode,
- t1.caseName)tp
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON tp.behospitalCode = g.behospital_code
- AND tp.hospitalId = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON tp.behospitalCode = h.behospital_code
- AND tp.hospitalId = h.hospital_id
- ) tu
- WHERE tu.behospitalCode IS NOT NULL
- <if test="checkStatus != null ">
- and tu.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND tu.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND tu.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND tu.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <!-- 医疗组质控评分导出到excel-->
- <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
- SELECT * FROM (
- SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
- CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
- g.check_type AS ch_type,
- h.check_type AS mr_type,
- g.check_name AS ch_name,
- h.check_name AS mr_name,
- g.check_time AS ch_time,
- h.check_time AS mr_time
- FROM (
- SELECT
- t1.behDeptId,
- t1.behDeptName,
- t1.behDoctorName,
- t1.patName,
- t1.behospitalCode,
- t1.hospitalId,
- t1.behospitalDate,
- t1.leaveHospitalDate,
- t1.score,
- t2.avgScore,
- t1.msg,
- t1.caseName
- FROM
- (
- SELECT
- CONCAT(
- ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
- a.doctor_name
- ) AS behDoctorName,
- a.`name` AS patName,
- a.behospital_code AS behospitalCode,
- a.behospital_date AS behospitalDate,
- a.leave_hospital_date AS leaveHospitalDate,
- b.score_res AS score,
- c.msg AS msg,
- d.NAME AS caseName,
- a.beh_dept_id AS behDeptId,
- a.beh_dept_name AS behDeptName,
- a.hospital_id AS hospitalId
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.doctor_id in
- (SELECT doctor_id FROM `bas_doctor_info`
- where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
- select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
- where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
- and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
- and c1.username = c3.doctor_id
- and c2.hospital_id = #{hospitalId}
- and c1.id = #{userId}
- ))
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="leaveHosDateStart != null ">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
- </if>
- <if test="leaveHosDateEnd != null ">
- <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="level != null and level != ''">
- AND b.level = #{level}
- </if>
- <if test="doctorName != null and doctorName != ''">
- AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
- </if>
- <if test="deptId != null and deptId != ''">
- AND a.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- AND a.name like CONCAT('%',#{name},'%')
- </if>
- ) t1,
- (
- SELECT
- ROUND( AVG( b.score_res ), 2 ) AS avgScore,
- a.beh_dept_id AS behDeptId,
- a.beh_dept_name AS behDeptName
- FROM
- med_behospital_info a,
- med_qcresult_info b
- WHERE
- a.is_deleted = 'N'
- AND a.doctor_id in
- (SELECT doctor_id FROM `bas_doctor_info`
- where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
- select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
- where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
- and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
- and c1.username = c3.doctor_id
- and c2.hospital_id = #{hospitalId}
- and c1.id = #{userId}
- ))
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="leaveHosDateStart != null ">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
- </if>
- <if test="leaveHosDateEnd != null ">
- <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="level != null and level != ''">
- AND b.level = #{level}
- </if>
- <if test="doctorName != null and doctorName != ''">
- AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
- OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
- OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
- </if>
- <if test="deptId != null and deptId != ''">
- AND a.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- AND a.name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t2
- WHERE
- t1.behDeptId = t2.behDeptId
- AND t1.behDeptName = t2.behDeptName
- ORDER BY
- t1.behDeptName,
- t1.behDoctorName,
- t1.patName,
- t1.behospitalCode,
- t1.caseName)tp
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
- ON tp.behospitalCode = g.behospital_code
- AND tp.hospitalId = g.hospital_id
- LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
- ON tp.behospitalCode = h.behospital_code
- AND tp.hospitalId = h.hospital_id
- ) tu
- WHERE tu.behospitalCode IS NOT NULL
- <if test="checkStatus != null ">
- and tu.check_status = #{checkStatus}
- </if>
- <if test="mrStatus != null ">
- AND tu.mr_status = #{mrStatus}
- </if>
- <if test="chName != null and chName !=''">
- AND tu.ch_name like CONCAT('%',#{chName},'%')
- </if>
- <if test="mrName != null and mrName !=''">
- AND tu.mr_name like CONCAT('%',#{mrName},'%')
- </if>
- <if test="chTimeStart != null">
- <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
- </if>
- <if test="chTimeEnd != null">
- <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
- </if>
- <if test="mrTimeStart != null">
- <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
- </if>
- <if test="mrTimeEnd != null">
- <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
- </if>
- </select>
- <!-- 条目缺陷质控评分页(内页)-->
- <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
- SELECT t.*
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime
- FROM
- (
- SELECT DISTINCT
- tt1.*
- FROM
- (SELECT
- be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME = #{qcResultShortPageVO.casesEntryName}
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null ">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
- AND d.cases_name = #{qcResultShortPageVO.casesName}
- </if>
- <if test="qcResultShortPageVO.casesId != null">
- AND d.cases_id = #{qcResultShortPageVO.casesId}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
- AND TIMESTAMPDIFF(
- DAY,
- DATE( a.behospital_date ),
- DATE( a.leave_hospital_date ))> 30
- </if>
- )be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- )tt1
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
- ,med_medical_record tt2
- WHERE
- tt2.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- AND tt2.mode_id = 30
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
- ,med_crisis_info tt2
- WHERE
- tt2.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- </if>
- ) t1
- <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
- , med_home_page t2
- , med_home_operation_info t3
- WHERE t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.home_page_id = t3.home_page_id
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- </if>
- ) t
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- </select>
- <!-- 条目缺陷质控评分页-科室(内页)-->
- <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
- SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d,
- sys_user_dept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = e.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.beh_dept_id = e.dept_id
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
- AND e.user_id = #{qcResultShortPageVO.userId}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND a.doctor_name = #{qcResultShortPageVO.doctorName}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- ) t1
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- </select>
- <update id="updateBatchByKey">
- <foreach collection="list" item="item" separator=";">
- update med_behospital_info
- <set>
- <if test="item.name != null">
- name = #{item.name},
- </if>
- <if test="item.sex != null">
- sex = #{item.sex},
- </if>
- <if test="item.birthday != null">
- birthday = #{item.birthday},
- </if>
- <if test="item.fileCode != null">
- file_code = #{item.fileCode},
- </if>
- <if test="item.qcTypeId != null">
- qc_type_id = #{item.qcTypeId},
- </if>
- <if test="item.wardCode != null">
- ward_code = #{item.wardCode},
- </if>
- <if test="item.wardName != null">
- ward_name = #{item.wardName},
- </if>
- <if test="item.behDeptId != null">
- beh_dept_id = #{item.behDeptId},
- </if>
- <if test="item.behDeptName != null">
- beh_dept_name = #{item.behDeptName},
- </if>
- <if test="item.bedCode != null">
- bed_code = #{item.bedCode},
- </if>
- <if test="item.bedName != null">
- bed_name = #{item.bedName},
- </if>
- <if test="item.insuranceName != null">
- insurance_name = #{item.insuranceName},
- </if>
- <if test="item.jobType != null">
- job_type = #{item.jobType},
- </if>
- <if test="item.behospitalDate != null">
- behospital_date = #{item.behospitalDate},
- </if>
- <if test="item.leaveHospitalDate != null">
- leave_hospital_date = #{item.leaveHospitalDate},
- </if>
- <if test="item.diagnoseIcd != null">
- diagnose_icd = #{item.diagnoseIcd},
- </if>
- <if test="item.diagnose != null">
- diagnose = #{item.diagnose},
- </if>
- <if test="item.behDoctorId != null">
- beh_doctor_id = #{item.behDoctorId},
- </if>
- <if test="item.behDoctorName != null">
- beh_doctor_name = #{item.behDoctorName},
- </if>
- <if test="item.doctorId != null">
- doctor_id = #{item.doctorId},
- </if>
- <if test="item.doctorName != null">
- doctor_name = #{item.doctorName},
- </if>
- <if test="item.directorDoctorId != null">
- director_doctor_id = #{item.directorDoctorId},
- </if>
- <if test="item.directorDoctorName != null">
- director_doctor_name = #{item.directorDoctorName},
- </if>
- <if test="item.placefileDate != null">
- placefile_date = #{item.placefileDate},
- </if>
- <if test="item.isPlacefile != null">
- is_placefile = #{item.isPlacefile},
- </if>
- <if test="item.gmtModified != null">
- gmt_modified = #{item.gmtModified},
- </if>
- <if test="item.modifier != null">
- modifier = #{item.modifier},
- </if>
- </set>
- where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
- </foreach>
- </update>
- <!-- 关键条目缺陷统计报表-->
- <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
- SELECT
- deptId,
- deptName,
- consultationMRNum,
- consultationNum,
- 2511 AS consultationEntryId,
- '普通会诊未在24小时内完成' AS consultationEntryName,
- ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
- CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
- operationMRNum,
- 2594 AS operationNameEntryId,
- '首页手术名称与手术记录不一致' AS operationNameEntryName,
- operationNameNum,
- ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
- CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
- 2973 AS operationTimeEntryId,
- '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
- operationTimeNum,
- ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
- CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
- 2930 AS operation15MinuteEntryId,
- '术后首次病程未即刻完成' AS operation15MinuteEntryName,
- operation15MinuteNum,
- ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
- CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
- 2419 AS crisisEntryId,
- '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
- crisisMRNum,
- crisisNum,
- ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
- CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
- 2495 AS stageSummaryEntryId,
- '无阶段小结' AS stageSummaryEntryName,
- stageSummaryMRNum,
- stageSummaryNum,
- ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
- CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr
- FROM
- (
- SELECT
- tt.deptId,
- tt.deptName,
- sum( tt.consultationNum ) AS consultationNum,
- sum( tt.consultationMRNum ) AS consultationMRNum,
- sum( tt.operationNameNum ) AS operationNameNum,
- sum( tt.operationTimeNum ) AS operationTimeNum,
- sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
- sum( tt.operationMRNum ) AS operationMRNum,
- sum( tt.crisisNum ) AS crisisNum,
- sum( tt.crisisMRNum ) AS crisisMRNum,
- sum( tt.stageSummaryNum ) AS stageSummaryNum,
- sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum
- FROM
- (
- (
- SELECT
- c.beh_dept_id AS deptId,
- c.beh_dept_name AS deptName,
- sum( d.cases_entry_id = 2511 ) AS consultationNum,
- count( DISTINCT c.behospital_code ) AS consultationMRNum,
- 0 AS operationNameNum,
- 0 AS operationTimeNum,
- 0 AS operation15MinuteNum,
- 0 AS operationMRNum,
- 0 AS crisisNum,
- 0 AS crisisMRNum,
- 0 AS stageSummaryNum,
- 0 AS stageSummaryMRNum
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.beh_dept_name,
- a.beh_dept_id
- FROM
- med_behospital_info a,
- med_medical_record b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- AND b.mode_id = 30
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="deptName != null and deptName != ''">
- AND a.beh_dept_name = #{deptName}
- </if>
- ) c
- LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
- AND c.hospital_id = d.hospital_id
- AND c.behospital_code = d.behospital_code
- GROUP BY
- c.beh_dept_id,
- c.beh_dept_name
- ) UNION
- (
- SELECT
- d.beh_dept_id AS deptId,
- d.beh_dept_name AS deptName,
- 0 AS consultationNum,
- 0 AS consultationMRNum,
- sum( e.cases_entry_id = 2594 ) AS operationNameNum,
- sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
- sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
- count( DISTINCT d.behospital_code ) AS operationMRNum,
- 0 AS crisisNum,
- 0 AS crisisMRNum,
- 0 AS stageSummaryNum,
- 0 AS stageSummaryMRNum
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.beh_dept_name,
- a.beh_dept_id
- FROM
- med_behospital_info a,
- med_home_page b,
- med_home_operation_info c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND b.home_page_id = c.home_page_id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="deptName != null and deptName != ''">
- AND a.beh_dept_name = #{deptName}
- </if>
- ) d
- LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
- AND d.hospital_id = e.hospital_id
- AND d.behospital_code = e.behospital_code
- GROUP BY
- d.beh_dept_id,
- d.beh_dept_name
- ) UNION
- (
- SELECT
- c.beh_dept_id AS deptId,
- c.beh_dept_name AS deptName,
- 0 AS consultationNum,
- 0 AS consultationMRNum,
- 0 AS operationNameNum,
- 0 AS operationTimeNum,
- 0 AS operation15MinuteNum,
- 0 AS operationMRNum,
- sum( d.cases_entry_id = 2419 ) AS crisisNum,
- count( DISTINCT c.behospital_code ) AS crisisMRNum,
- 0 AS stageSummaryNum,
- 0 AS stageSummaryMRNum
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.beh_dept_name,
- a.beh_dept_id
- FROM
- med_behospital_info a,
- med_crisis_info b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="deptName != null and deptName != ''">
- AND a.beh_dept_name = #{deptName}
- </if>
- ) c
- LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
- AND c.hospital_id = d.hospital_id
- AND c.behospital_code = d.behospital_code
- GROUP BY
- c.beh_dept_id,
- c.beh_dept_name
- ) UNION
- (
- SELECT
- b.beh_dept_id AS deptId,
- b.beh_dept_name AS deptName,
- 0 AS consultationNum,
- 0 AS consultationMRNum,
- 0 AS operationNameNum,
- 0 AS operationTimeNum,
- 0 AS operation15MinuteNum,
- 0 AS operationMRNum,
- 0 AS crisisNum,
- 0 AS crisisMRNum,
- sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
- count( DISTINCT b.behospital_code ) AS stageSummaryMRNum
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.beh_dept_name,
- a.beh_dept_id
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- AND TIMESTAMPDIFF(
- DAY,
- DATE( behospital_date ),
- DATE( leave_hospital_date ))> 30
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="deptName != null and deptName != ''">
- AND a.beh_dept_name = #{deptName}
- </if>
- ) b
- LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
- AND b.hospital_id = c.hospital_id
- AND b.behospital_code = c.behospital_code
- GROUP BY
- b.beh_dept_id,
- b.beh_dept_name
- )
- ) tt
- GROUP BY
- tt.deptId,
- tt.deptName
- ) t
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="deptId"'>deptId asc</when>
- <when test='asc=="deptName"'>deptName asc</when>
- <when test='asc=="consultationNum"'>consultationNum asc</when>
- <when test='asc=="consultationPercent"'>consultationPercent asc</when>
- <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
- <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
- <when test='asc=="operationNameNum"'>operationNameNum asc</when>
- <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
- <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
- <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
- <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
- <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
- <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
- <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
- <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
- <when test='asc=="operationMRNum"'>operationMRNum asc</when>
- <when test='asc=="crisisNum"'>crisisNum asc</when>
- <when test='asc=="crisisPercent"'>crisisPercent asc</when>
- <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
- <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
- <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
- <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
- <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
- <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
- <otherwise>deptName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="deptId"'>deptId desc</when>
- <when test='desc=="deptName"'>deptName desc</when>
- <when test='desc=="consultationNum"'>consultationNum desc</when>
- <when test='desc=="consultationPercent"'>consultationPercent desc</when>
- <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
- <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
- <when test='desc=="operationNameNum"'>operationNameNum desc</when>
- <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
- <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
- <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
- <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
- <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
- <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
- <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
- <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
- <when test='desc=="operationMRNum"'>operationMRNum desc</when>
- <when test='desc=="crisisNum"'>crisisNum desc</when>
- <when test='desc=="crisisPercent"'>crisisPercent desc</when>
- <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
- <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
- <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
- <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
- <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
- <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
- <otherwise>deptName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 非医嘱离院病人记录-->
- <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
- SELECT
- count(*)
- FROM
- med_behospital_info a,
- med_home_page b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- AND b.leave_hospital_type = '非医嘱离院'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!-- 31天内再入院记录-->
- <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
- SELECT
- count(*)
- FROM
- (
- SELECT
- r1.file_code,
- r1.diagnose,
- r1.behospital_code AS behospitalCode,
- r1.behospital_date AS behospitalDate,
- r1.leave_hospital_date AS leaveHospitalDate,
- r2.behospital_code AS lastBehospitalCode,
- r2.behospital_date AS lastBehospitalDate,
- r2.leave_hospital_date AS lastLeaveHospitalDate,
- TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
- FROM
- (
- SELECT
- ( @rownum := @rownum + 1 ) AS rownum,
- t1.file_code,
- t1.diagnose,
- t1.behospital_code,
- t1.behospital_date,
- t1.leave_hospital_date
- FROM
- (
- SELECT
- tt1.file_code,
- tt1.diagnose,
- tt2.behospital_code,
- tt2.behospital_date,
- tt2.leave_hospital_date
- FROM
- (
- SELECT
- a.file_code,
- a.diagnose
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- AND IFNULL( a.diagnose, '' )!= ''
- AND IFNULL( a.file_code, '' )!= ''
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.file_code,
- a.diagnose
- HAVING
- count(*)> 1
- ) tt1,
- med_behospital_info tt2
- WHERE
- tt2.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and tt2.is_placefile = #{isPlacefile}
- </if>
- AND tt2.qc_type_id != 0
- AND tt1.file_code = tt2.file_code
- AND tt1.diagnose = tt2.diagnose
- <if test="hospitalId != null and hospitalId != ''">
- AND tt2.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
- </if>
- ORDER BY
- tt1.file_code,
- tt1.diagnose,
- tt2.behospital_date DESC
- ) t1,
- ( SELECT @rownum := 0 ) r
- ) r1
- LEFT JOIN (
- SELECT
- ( @INDEX := @INDEX + 1 ) AS rownum,
- t2.file_code,
- t2.diagnose,
- t2.behospital_code,
- t2.behospital_date,
- t2.leave_hospital_date
- FROM
- (
- SELECT
- tt1.file_code,
- tt1.diagnose,
- tt2.behospital_code,
- tt2.behospital_date,
- tt2.leave_hospital_date
- FROM
- (
- SELECT
- a.file_code,
- a.diagnose
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- AND IFNULL( a.diagnose, '' )!= ''
- AND IFNULL( a.file_code, '' )!= ''
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- a.file_code,
- a.diagnose
- HAVING
- count(*)> 1
- ) tt1,
- med_behospital_info tt2
- WHERE
- tt2.is_deleted = 'N'
- <if test="isPlacefile != null and isPlacefile != ''">
- and tt2.is_placefile = #{isPlacefile}
- </if>
- AND tt2.qc_type_id != 0
- AND tt1.file_code = tt2.file_code
- AND tt1.diagnose = tt2.diagnose
- <if test="hospitalId != null and hospitalId != ''">
- AND tt2.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
- </if>
- ORDER BY
- tt1.file_code,
- tt1.diagnose,
- tt2.behospital_date DESC
- ) t2,(
- SELECT
- @INDEX := 0
- ) r
- ) r2 ON r1.file_code = r2.file_code
- AND r1.rownum = r2.rownum - 1
- ) t
- WHERE
- t.diffDays IS NOT NULL
- AND t.diffDays BETWEEN 0
- AND 31
- </select>
- <!-- 病案首页质控病历数统计-全院(首页)-->
- <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
- SELECT
- count( * ) AS mrNum,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
- ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
- SUM( c.`level` = '合格' ) AS firstLevelNum,
- SUM( c.`level` = '不合格' ) AS secondLevelNum,
- ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
- ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
- concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
- concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
- FROM
- med_behospital_info a,
- med_qcresult_cases c
- WHERE
- a.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- </select>
- <!-- 病案首页完整率统计-全院(首页)-->
- <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
- SELECT
- h1.emptyNum,
- h1.mrNum,
- h2.entryNum,
- h1.mrNum * h2.entryNum AS entryTotleNum,
- ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
- CONCAT(
- ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
- '%'
- ) AS emptyPercentStr
- FROM
- (
- SELECT
- sum( d.rule_type = 1 ) AS emptyNum,
- count( DISTINCT a.behospital_code ) AS mrNum
- FROM
- med_behospital_info a,
- med_qcresult_cases b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND b.cases_id = c.cases_id
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND d.cases_id = 243
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- ) h1,(
- SELECT
- count(*) AS entryNum
- FROM
- qc_cases_entry
- WHERE
- is_deleted = 'N'
- AND cases_id = 243
- ) h2
- </select>
- <!-- 离院病人评分详情页-->
- <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
- SELECT
- t.*
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime,
- t2.age,
- t1.file_code AS fileCode
- FROM
- (
- SELECT be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- tt1.*
- FROM
- (
- SELECT
- b.*,
- ifnull(c.LEVEL,'未评分') as LEVEL ,
- c.grade_type,
- c.score_res,
- c.gmt_create
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- a.file_code
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- ) b
- LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
- AND b.hospital_id = c.hospital_id
- AND b.behospital_code = c.behospital_code
- ) tt1
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
- ,med_medical_record tt2,
- qc_mode tt3
- WHERE
- tt2.is_deleted = 'N'
- AND tt3.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- AND tt2.mode_id = tt3.id
- AND tt3.`name` = '手术记录'
- </if>
- ) be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- )t1
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND (
- ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
- OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
- )
- </if>
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.return_to_type = '死亡'
- </if>
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.leave_hospital_type = '非医嘱离院'
- </if>
- <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
- LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- </if>
- )t
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- and t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND t.`level` = #{qcResultShortPageVO.level}
- </if>
- </select>
- <!-- 病案首页改善率统计(首页)-->
- <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
- SELECT
- t2.homePageMRNum,
- t1.improveNum,
- round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
- Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
- t1.improveToPassNum,
- round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
- Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
- t1.improveToFullNum,
- round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
- Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
- FROM
- (
- SELECT
- <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
- sum( d.score_res = 20 ) AS improveToFullNum,
- count(*) AS improveNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_cases d,
- (
- SELECT
- m4.*
- FROM
- med_behospital_info m1,
- med_home_page m2,
- med_qcresult_info m3,
- med_qcresult_cases m4
- WHERE
- m1.is_deleted = 'N'
- AND m2.is_deleted = 'N'
- AND m3.is_deleted = 'Y'
- AND m4.is_deleted = 'Y'
- AND m1.hospital_id = m2.hospital_id
- AND m1.hospital_id = m3.hospital_id
- AND m1.hospital_id = m4.hospital_id
- AND m1.behospital_code = m2.behospital_code
- AND m1.behospital_code = m3.behospital_code
- AND m1.behospital_code = m4.behospital_code
- AND m3.gmt_create = m4.gmt_create
- AND m3.have_home_page = 1
- AND m4.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and m1.is_placefile = #{isPlacefile}
- </if>
- AND m1.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND m1.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
- </if>
- GROUP BY
- m1.behospital_code
- ORDER BY
- m1.behospital_code,
- m4.gmt_create
- ) e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.hospital_id = e.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND a.behospital_code = e.behospital_code
- AND d.cases_id = 243
- AND d.score_res > e.score_res
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND a.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- ) t1,
- (
- SELECT
- count( DISTINCT a.behospital_code ) AS homePageMRNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- ) t2
- </select>
- <!-- 质控核查统计(内页)-->
- <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
- SELECT
- t.*
- FROM
- (SELECT
- mr.beh_dept_id AS deptId,
- mr.beh_dept_name AS deptName,
- IFNULL( mr.mrNum, 0 ) AS mrNum,
- ck.checkedNum AS checkedNum,
- ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
- CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
- hmmr_t.homePageMRNum,
- improve_t.improveNum,
- round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
- Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
- improve_t.improveToPassNum,
- round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
- Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
- improve_t.improveToFullNum,
- round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
- Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- count(*) AS mrNum
- FROM
- med_behospital_info a,
- med_qcresult_info b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="name != null and name != ''">
- AND a.beh_dept_name like CONCAT('%', #{name}, '%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) mr
- LEFT JOIN (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- count(*) AS checkedNum
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_check_info c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- AND ifnull(c.`status`,0) = 1
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="name != null and name != ''">
- AND a.beh_dept_name like CONCAT('%', #{name}, '%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) ck ON mr.beh_dept_id = ck.beh_dept_id
- AND mr.beh_dept_name = ck.beh_dept_name
- LEFT JOIN (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- count( DISTINCT a.behospital_code ) AS homePageMRNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="name != null and name != ''">
- AND a.beh_dept_name like CONCAT('%', #{name}, '%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
- AND mr.beh_dept_name = hmmr_t.beh_dept_name
- LEFT JOIN (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
- sum( d.score_res = 20 ) AS improveToFullNum,
- count(*) AS improveNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_cases d,
- (
- SELECT
- m4.*
- FROM
- med_behospital_info m1,
- med_home_page m2,
- med_qcresult_info m3,
- med_qcresult_cases m4
- WHERE
- m1.is_deleted = 'N'
- AND m2.is_deleted = 'N'
- AND m3.is_deleted = 'Y'
- AND m4.is_deleted = 'Y'
- AND m1.hospital_id = m2.hospital_id
- AND m1.hospital_id = m3.hospital_id
- AND m1.hospital_id = m4.hospital_id
- AND m1.behospital_code = m2.behospital_code
- AND m1.behospital_code = m3.behospital_code
- AND m1.behospital_code = m4.behospital_code
- AND m3.gmt_create = m4.gmt_create
- AND m3.have_home_page = 1
- AND m4.cases_id = 243
- <if test="isPlacefile != null and isPlacefile != ''">
- and m1.is_placefile = #{isPlacefile}
- </if>
- AND m1.qc_type_id != 0
- <if test="hospitalId != null and hospitalId != ''">
- AND m1.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="name != null and name != ''">
- AND m1.beh_dept_name like CONCAT('%', #{name}, '%')
- </if>
- GROUP BY
- m1.behospital_code
- ORDER BY
- m1.behospital_code,
- m4.gmt_create
- ) e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.hospital_id = d.hospital_id
- AND a.hospital_id = e.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND a.behospital_code = e.behospital_code
- AND d.cases_id = 243
- AND d.score_res > e.score_res
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null and startDate != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null and endDate != ''">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="name != null and name != ''">
- AND a.beh_dept_name like CONCAT('%', #{name}, '%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
- AND mr.beh_dept_name = improve_t.beh_dept_name
- ) t
- <if test="asc != null and asc !=''">
- order by
- <choose>
- <when test='asc=="deptId"'>deptId asc</when>
- <when test='asc=="deptName"'>deptName asc</when>
- <when test='asc=="mrNum"'>mrNum asc</when>
- <when test='asc=="checkedNum"'>checkedNum asc</when>
- <when test='asc=="checkedPercent"'>checkedPercent asc</when>
- <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
- <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
- <when test='asc=="improveNum"'>improveNum asc</when>
- <when test='asc=="improvePercent"'>improvePercent asc</when>
- <when test='asc=="improvePercentStr"'>improvePercent asc</when>
- <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
- <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
- <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
- <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
- <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
- <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
- <otherwise>deptName asc</otherwise>
- </choose>
- </if>
- <if test="desc != null and desc!=''">
- order by
- <choose>
- <when test='desc=="deptId"'>deptId desc</when>
- <when test='desc=="deptName"'>deptName desc</when>
- <when test='desc=="mrNum"'>mrNum desc</when>
- <when test='desc=="checkedNum"'>checkedNum desc</when>
- <when test='desc=="checkedPercent"'>checkedPercent desc</when>
- <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
- <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
- <when test='desc=="improveNum"'>improveNum desc</when>
- <when test='desc=="improvePercent"'>improvePercent desc</when>
- <when test='desc=="improvePercentStr"'>improvePercent desc</when>
- <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
- <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
- <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
- <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
- <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
- <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
- <otherwise>deptName desc</otherwise>
- </choose>
- </if>
- </select>
- <!-- 离院病人评分详情页导出-->
- <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
- SELECT
- f1.behDeptId,
- f1.behDeptName,
- f1.behDoctorName,
- f1.patName,
- f1.behospitalCode,
- f1.hospitalId,
- f1.behospitalDate,
- f1.leaveHospitalDate,
- f1.score,
- f2.avgScore,
- f1.msg,
- f1.caseName,
- f1.checkStatus,
- f1.mrStatus,
- f1.chName,
- f1.mrName,
- f1.chTime,
- f1.mrTime
- FROM
- (SELECT
- CONCAT(
- ( CASE WHEN t.directorDoctorName IS NOT NULL AND t.directorDoctorName != '' THEN concat( t.directorDoctorName,
- '\n' ) ELSE '' END ),
- t.doctorName
- ) AS behDoctorName,
- t.`name` AS patName,
- t.behospitalCode AS behospitalCode,
- t.behospitalDate AS behospitalDate,
- t.leaveHospitalDate AS leaveHospitalDate,
- qi.score_res AS score,
- qd.msg AS msg,
- qc.NAME AS caseName,
- t.behDeptId,
- t.behDeptName,
- t.hospitalId,
- t.checkStatus,
- t.mrStatus,
- t.chName,
- t.mrName,
- t.chTime,
- t.mrTime
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime,
- t2.age,
- t1.file_code AS fileCode
- FROM
- (
- SELECT be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- tt1.*
- FROM
- (
- SELECT
- b.*,
- ifnull(c.LEVEL,'未评分') as LEVEL ,
- c.grade_type,
- c.score_res,
- c.gmt_create
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- a.file_code
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- ) b
- LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
- AND b.hospital_id = c.hospital_id
- AND b.behospital_code = c.behospital_code
- ) tt1
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
- ,med_medical_record tt2,
- qc_mode tt3
- WHERE
- tt2.is_deleted = 'N'
- AND tt3.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- AND tt2.mode_id = tt3.id
- AND tt3.`name` = '手术记录'
- </if>
- ) be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- )t1
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND (
- ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
- OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
- )
- </if>
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.return_to_type = '死亡'
- </if>
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.leave_hospital_type = '非医嘱离院'
- </if>
- <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
- LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- </if>
- )t
- LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
- AND t.hospitalId = qi.hospital_id
- AND t.behospitalCode = qi.behospital_code
- LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
- AND t.hospitalId = qd.hospital_id
- AND t.behospitalCode = qd.behospital_code
- LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
- AND qd.cases_id = qc.id
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- and t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND t.`level` = #{qcResultShortPageVO.level}
- </if>)f1,(SELECT
- ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
- t.behDeptId,
- t.behDeptName
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime,
- t2.age,
- t1.file_code AS fileCode
- FROM
- (
- SELECT be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- tt1.*
- FROM
- (
- SELECT
- b.*,
- ifnull(c.LEVEL,'未评分') as LEVEL ,
- c.grade_type,
- c.score_res,
- c.gmt_create
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- a.file_code
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- ) b
- LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
- AND b.hospital_id = c.hospital_id
- AND b.behospital_code = c.behospital_code
- ) tt1
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
- ,med_medical_record tt2,
- qc_mode tt3
- WHERE
- tt2.is_deleted = 'N'
- AND tt3.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- AND tt2.mode_id = tt3.id
- AND tt3.`name` = '手术记录'
- </if>
- ) be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- )t1
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND (
- ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
- OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
- )
- </if>
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.return_to_type = '死亡'
- </if>
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
- ,med_home_page t2
- WHERE
- t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.leave_hospital_type = '非医嘱离院'
- </if>
- <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
- LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
- AND t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- </if>
- )t
- LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
- AND t.hospitalId = qi.hospital_id
- AND t.behospitalCode = qi.behospital_code
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- and t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND t.`level` = #{qcResultShortPageVO.level}
- </if>
- GROUP BY
- t.behDeptId,
- t.behDeptName
- )f2
- WHERE
- f1.behDeptId = f2.behDeptId
- AND f1.behDeptName = f2.behDeptName
- </select>
- <!-- 条目缺陷评分详情页导出-->
- <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
- SELECT
- f1.behDeptId,
- f1.behDeptName,
- f1.behDoctorName,
- f1.patName,
- f1.behospitalCode,
- f1.hospitalId,
- f1.behospitalDate,
- f1.leaveHospitalDate,
- f1.score,
- f2.avgScore,
- f1.msg,
- f1.caseName,
- f1.checkStatus,
- f1.mrStatus,
- f1.chName,
- f1.mrName,
- f1.chTime,
- f1.mrTime
- FROM
- (SELECT
- CONCAT( ifnull( t.directorDoctorName, '' ), '\n', t.doctorName ) AS behDoctorName,
- t.`name` AS patName,
- t.behospitalCode AS behospitalCode,
- t.behospitalDate AS behospitalDate,
- t.leaveHospitalDate AS leaveHospitalDate,
- qi.score_res AS score,
- qd.msg AS msg,
- qc.NAME AS caseName,
- t.behDeptId,
- t.behDeptName,
- t.hospitalId,
- t.checkStatus,
- t.mrStatus,
- t.chName,
- t.mrName,
- t.chTime,
- t.mrTime
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime
- FROM
- (
- SELECT DISTINCT
- tt1.*
- FROM
- (SELECT
- be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME = #{qcResultShortPageVO.casesEntryName}
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null ">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
- AND d.cases_name = #{qcResultShortPageVO.casesName}
- </if>
- <if test="qcResultShortPageVO.casesId != null">
- AND d.cases_id = #{qcResultShortPageVO.casesId}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
- AND TIMESTAMPDIFF(
- DAY,
- DATE( a.behospital_date ),
- DATE( a.leave_hospital_date ))> 30
- </if>
- )be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- )tt1
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
- ,med_medical_record tt2
- WHERE
- tt2.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- AND tt2.mode_id = 30
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
- ,med_crisis_info tt2
- WHERE
- tt2.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- </if>
- ) t1
- <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
- , med_home_page t2
- , med_home_operation_info t3
- WHERE t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.home_page_id = t3.home_page_id
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- </if>
- ) t
- LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
- AND t.hospitalId = qi.hospital_id
- AND t.behospitalCode = qi.behospital_code
- LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
- AND t.hospitalId = qd.hospital_id
- AND t.behospitalCode = qd.behospital_code
- LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
- AND qd.cases_id = qc.id
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- )f1,
- (SELECT
- ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
- t.behDeptId,
- t.behDeptName
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime
- FROM
- (
- SELECT DISTINCT
- tt1.*
- FROM
- (SELECT
- be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME = #{qcResultShortPageVO.casesEntryName}
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null ">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
- AND d.cases_name = #{qcResultShortPageVO.casesName}
- </if>
- <if test="qcResultShortPageVO.casesId != null">
- AND d.cases_id = #{qcResultShortPageVO.casesId}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
- AND TIMESTAMPDIFF(
- DAY,
- DATE( a.behospital_date ),
- DATE( a.leave_hospital_date ))> 30
- </if>
- )be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- )tt1
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
- ,med_medical_record tt2
- WHERE
- tt2.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- AND tt2.mode_id = 30
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
- ,med_crisis_info tt2
- WHERE
- tt2.is_deleted = 'N'
- AND tt1.hospital_id = tt2.hospital_id
- AND tt1.behospital_code = tt2.behospital_code
- </if>
- ) t1
- <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
- , med_home_page t2
- , med_home_operation_info t3
- WHERE t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.home_page_id = t3.home_page_id
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- </if>
- ) t
- LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
- AND t.hospitalId = qi.hospital_id
- AND t.behospitalCode = qi.behospital_code
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- GROUP BY
- t.behDeptId,
- t.behDeptName
- )f2
- WHERE
- f1.behDeptId = f2.behDeptId
- AND f1.behDeptName = f2.behDeptName
- </select>
- <!-- 未整改病历统计-->
- <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- d.id AS casesEntryId,
- d.NAME AS casesEntryName,
- count(*) AS casesEntryNum
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="isPlacefile != null and isPlacefile != ''">
- and a.is_placefile = #{isPlacefile}
- </if>
- <if test="hospitalId != null and hospitalId != ''">
- AND a.hospital_id = #{hospitalId}
- </if>
- <if test="startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
- </if>
- <if test="endDate != null">
- <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
- </if>
- <if test="name != null and name != ''">
- AND a.beh_dept_name like CONCAT('%', #{name}, '%')
- </if>
- <if test="casesEntryIds != null and casesEntryIds.size()>0">
- AND c.cases_entry_id IN
- <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name,
- c.cases_entry_id,
- d.NAME
- </select>
- <!-- 未整改病历质控评分页(内页)-->
- <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
- SELECT t.*
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime
- FROM
- (SELECT
- be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME = #{qcResultShortPageVO.casesEntryName}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null ">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- )be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- ) t1
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- ) t
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- </select>
- <!-- 未整改病历缺陷评分详情页导出-->
- <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
- SELECT
- f1.behDeptId,
- f1.behDeptName,
- f1.behDoctorName,
- f1.patName,
- f1.behospitalCode,
- f1.hospitalId,
- f1.behospitalDate,
- f1.leaveHospitalDate,
- f1.score,
- f2.avgScore,
- f1.msg,
- f1.caseName,
- f1.checkStatus,
- f1.mrStatus,
- f1.chName,
- f1.mrName,
- f1.chTime,
- f1.mrTime
- FROM
- (SELECT
- CONCAT( ifnull( t.directorDoctorName, '' ), '\n', t.doctorName ) AS behDoctorName,
- t.`name` AS patName,
- t.behospitalCode AS behospitalCode,
- t.behospitalDate AS behospitalDate,
- t.leaveHospitalDate AS leaveHospitalDate,
- qi.score_res AS score,
- qd.msg AS msg,
- qc.NAME AS caseName,
- t.behDeptId,
- t.behDeptName,
- t.hospitalId,
- t.checkStatus,
- t.mrStatus,
- t.chName,
- t.mrName,
- t.chTime,
- t.mrTime
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime
- FROM
- (SELECT
- be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME = #{qcResultShortPageVO.casesEntryName}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null ">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- )be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- ) t1
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- ) t
- LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
- AND t.hospitalId = qi.hospital_id
- AND t.behospitalCode = qi.behospital_code
- LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
- AND t.hospitalId = qd.hospital_id
- AND t.behospitalCode = qd.behospital_code
- LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
- AND qd.cases_id = qc.id
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- )f1,
- (SELECT
- ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
- t.behDeptId,
- t.behDeptName
- FROM
- (SELECT DISTINCT
- t1.hospital_id AS hospitalId,
- t1.behospital_code AS behospitalCode,
- t1.bed_code AS bedCode,
- t1.LEVEL AS LEVEL,
- t1.grade_type AS gradeType,
- t1.score_res AS scoreRes,
- t1.NAME AS NAME,
- t1.sex AS sex,
- t1.beh_dept_id AS behDeptId,
- t1.beh_dept_name AS behDeptName,
- t1.doctor_id AS doctorId,
- t1.doctor_name AS doctorName,
- t1.beh_doctor_id AS behDoctorId,
- t1.beh_doctor_name AS behDoctorName,
- t1.director_doctor_id AS directorDoctorId,
- t1.director_doctor_name AS directorDoctorName,
- t1.birthday AS birthday,
- t1.behospital_date AS behospitalDate,
- t1.leave_hospital_date AS leaveHospitalDate,
- t1.placefile_date AS placefileDate,
- t1.gmt_create AS gradeTime,
- t1.diagnose,
- t1.ward_name AS wardName,
- t2.age,
- t1.file_code AS fileCode,
- t1.checkStatus,
- t1.mrStatus,
- t1.chName,
- t1.mrName,
- t1.chTime,
- t1.mrTime
- FROM
- (SELECT
- be.*,
- ifnull(mci.status,0) AS checkStatus,
- ifnull(hm_mci.status,0) AS mrStatus,
- mci.check_name as chName,
- hm_mci.check_name as mrName,
- mci.gmt_create as chTime,
- hm_mci.gmt_create as mrTime
- FROM
- (
- SELECT DISTINCT
- a.hospital_id,
- a.behospital_code,
- a.bed_code,
- a.file_code,
- b.LEVEL,
- b.grade_type,
- b.score_res,
- a.NAME,
- a.sex,
- a.beh_dept_id,
- a.beh_dept_name,
- a.birthday,
- a.behospital_date,
- a.leave_hospital_date,
- a.doctor_id,
- a.doctor_name,
- a.beh_doctor_id,
- a.beh_doctor_name,
- a.director_doctor_id,
- a.director_doctor_name,
- a.diagnose,
- a.placefile_date,
- a.ward_name,
- b.gmt_create
- FROM
- med_behospital_info a,
- med_qcresult_info b,
- med_qcresult_detail c,
- qc_cases_entry d
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- AND a.qc_type_id != 0
- <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
- and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
- </if>
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
- </if>
- <if test="qcResultShortPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
- </if>
- <if test="qcResultShortPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
- </if>
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
- </if>
- <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
- AND b.`level` = #{qcResultShortPageVO.level}
- </if>
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
- </if>
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
- </if>
- <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
- AND d.NAME = #{qcResultShortPageVO.casesEntryName}
- </if>
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
- </if>
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
- </if>
- <if test="qcResultShortPageVO.casesEntryId != null ">
- AND d.id = #{qcResultShortPageVO.casesEntryId}
- </if>
- <if test="qcResultShortPageVO.isReject != null">
- AND c.is_reject = #{qcResultShortPageVO.isReject}
- </if>
- <if test="qcResultShortPageVO.ruleType != null">
- AND d.rule_type = #{qcResultShortPageVO.ruleType}
- </if>
- )be
- left join med_check_info mci
- on mci.is_deleted = 'N'
- and mci.check_type = 0
- and be.hospital_id = mci.hospital_id
- and be.behospital_code = mci.behospital_code
- left join med_check_info hm_mci
- on hm_mci.is_deleted = 'N'
- and hm_mci.check_type = 1
- and be.hospital_id = hm_mci.hospital_id
- and be.behospital_code = hm_mci.behospital_code
- ) t1
- LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
- AND t1.behospital_code = t2.behospital_code
- AND t2.is_deleted = 'N'
- ) t
- LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
- AND t.hospitalId = qi.hospital_id
- AND t.behospitalCode = qi.behospital_code
- where 1=1
- <if test="qcResultShortPageVO.checkStatus != null">
- AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
- </if>
- <if test="qcResultShortPageVO.mrStatus != null">
- AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
- </if>
- <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
- AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
- </if>
- <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
- AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
- </if>
- <if test="qcResultShortPageVO.chTimeStart != null ">
- <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.chTimeEnd != null ">
- <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeStart != null ">
- <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
- </if>
- <if test="qcResultShortPageVO.mrTimeEnd != null ">
- <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
- </if>
- GROUP BY
- t.behDeptId,
- t.behDeptName
- )f2
- WHERE
- f1.behDeptId = f2.behDeptId
- AND f1.behDeptName = f2.behDeptName
- </select>
- <!-- 31天再入院详情页-->
- <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
- SELECT
- t.fileCode,
- t.diagnose,
- t.NAME,
- t.sex,
- t.hospitalId,
- t.behDeptId,
- t.behDeptName,
- t.behospitalCode,
- t.behospitalDate,
- t.leaveHospitalDate,
- t.lastBehDeptId,
- t.lastBehDeptName,
- t.lastBehospitalCode,
- t.lastBehospitalDate,
- t.lastLeaveHospitalDate,
- t.diffDays,
- mqi.score_res AS scoreRes,
- mqi.LEVEL AS LEVEL,
- mqi_last.score_res AS lastScoreRes,
- mqi_last.LEVEL AS lastLevel
- FROM
- (
- SELECT
- be.fileCode,
- be.diagnose,
- be.NAME,
- be.sex,
- be.hospitalId,
- be.behDeptId,
- be.behDeptName,
- be.behospitalCode,
- be.behospitalDate,
- be.leaveHospitalDate,
- be.lastBehDeptId,
- be.lastBehDeptName,
- be.lastBehospitalCode,
- be.lastBehospitalDate,
- be.lastLeaveHospitalDate,
- be.diffDays
- FROM
- (
- SELECT
- r1.file_code AS fileCode,
- r1.diagnose,
- r1.NAME,
- r1.sex,
- r1.hospital_id AS hospitalId,
- r1.beh_dept_id AS behDeptId,
- r1.beh_dept_name AS behDeptName,
- r1.behospital_code AS behospitalCode,
- r1.behospital_date AS behospitalDate,
- r1.leave_hospital_date AS leaveHospitalDate,
- r2.beh_dept_id AS lastBehDeptId,
- r2.beh_dept_name AS lastBehDeptName,
- r2.behospital_code AS lastBehospitalCode,
- r2.behospital_date AS lastBehospitalDate,
- r2.leave_hospital_date AS lastLeaveHospitalDate,
- TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
- FROM
- (
- SELECT
- ( @rownum := @rownum + 1 ) AS rownum,
- t1.file_code,
- t1.diagnose,
- t1.NAME,
- t1.sex,
- t1.hospital_id,
- t1.beh_dept_id,
- t1.beh_dept_name,
- t1.behospital_code,
- t1.behospital_date,
- t1.leave_hospital_date
- FROM
- (
- SELECT
- tt1.file_code,
- tt1.diagnose,
- tt2.NAME,
- tt2.sex,
- tt2.hospital_id,
- tt2.beh_dept_id,
- tt2.beh_dept_name,
- tt2.behospital_code,
- tt2.behospital_date,
- tt2.leave_hospital_date
- FROM
- (
- SELECT
- a.file_code,
- a.diagnose
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
- and a.is_placefile = #{reBeHosPageVO.isPlacefile}
- </if>
- AND a.qc_type_id != 0
- AND IFNULL( a.diagnose, '' )!= ''
- AND IFNULL( a.file_code, '' )!= ''
- <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
- AND a.hospital_id = #{reBeHosPageVO.hospitalId}
- </if>
- <if test="reBeHosPageVO.startDate != null">
- <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
- </if>
- <if test="reBeHosPageVO.endDate != null">
- <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
- </if>
- <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
- AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
- </if>
- <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
- AND a.name like concat('%', #{reBeHosPageVO.name},'%')
- </if>
- GROUP BY
- a.file_code,
- a.diagnose
- HAVING
- count(*)> 1
- ) tt1,
- med_behospital_info tt2
- WHERE
- tt2.is_deleted = 'N'
- <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
- and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
- </if>
- AND tt2.qc_type_id != 0
- AND tt1.file_code = tt2.file_code
- AND tt1.diagnose = tt2.diagnose
- <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
- AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
- </if>
- <if test="reBeHosPageVO.startDate != null">
- <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
- </if>
- <if test="reBeHosPageVO.endDate != null">
- <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
- </if>
- <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
- AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
- </if>
- <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
- AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
- </if>
- ORDER BY
- tt1.file_code,
- tt1.diagnose,
- tt2.behospital_date DESC
- ) t1,
- ( SELECT @rownum := 0 ) r
- ) r1
- LEFT JOIN (
- SELECT
- ( @INDEX := @INDEX + 1 ) AS rownum,
- t1.file_code,
- t1.diagnose,
- t1.NAME,
- t1.sex,
- t1.hospital_id,
- t1.beh_dept_id,
- t1.beh_dept_name,
- t1.behospital_code,
- t1.behospital_date,
- t1.leave_hospital_date
- FROM
- (
- SELECT
- tt1.file_code,
- tt1.diagnose,
- tt2.NAME,
- tt2.sex,
- tt2.hospital_id,
- tt2.beh_dept_id,
- tt2.beh_dept_name,
- tt2.behospital_code,
- tt2.behospital_date,
- tt2.leave_hospital_date
- FROM
- (
- SELECT
- a.file_code,
- a.diagnose
- FROM
- med_behospital_info a
- WHERE
- a.is_deleted = 'N'
- <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
- and a.is_placefile = #{reBeHosPageVO.isPlacefile}
- </if>
- AND a.qc_type_id != 0
- AND IFNULL( a.diagnose, '' )!= ''
- AND IFNULL( a.file_code, '' )!= ''
- <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
- AND a.hospital_id = #{reBeHosPageVO.hospitalId}
- </if>
- <if test="reBeHosPageVO.startDate != null ">
- <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
- </if>
- <if test="reBeHosPageVO.endDate != null ">
- <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
- </if>
- <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
- AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
- </if>
- <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
- AND a.name like concat('%', #{reBeHosPageVO.name},'%')
- </if>
- GROUP BY
- a.file_code,
- a.diagnose
- HAVING
- count(*)> 1
- ) tt1,
- med_behospital_info tt2
- WHERE
- tt2.is_deleted = 'N'
- <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
- and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
- </if>
- AND tt2.qc_type_id != 0
- AND tt1.file_code = tt2.file_code
- AND tt1.diagnose = tt2.diagnose
- <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
- AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
- </if>
- <if test="reBeHosPageVO.startDate != null ">
- <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
- </if>
- <if test="reBeHosPageVO.endDate != null ">
- <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
- </if>
- <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
- AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
- </if>
- <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
- AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
- </if>
- ORDER BY
- tt1.file_code,
- tt1.diagnose,
- tt2.behospital_date DESC
- ) t1,(
- SELECT
- @INDEX := 0
- ) r
- ) r2 ON r1.file_code = r2.file_code
- AND r1.rownum = r2.rownum - 1
- ) be
- WHERE
- be.diffDays IS NOT NULL
- AND be.diffDays BETWEEN 0
- AND 31
- ) t
- LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
- AND t.hospitalId = mqi.hospital_id
- AND t.behospitalCode = mqi.behospital_code
- LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
- AND t.hospitalId = mqi_last.hospital_id
- AND t.lastBehospitalCode = mqi_last.behospital_code
- </select>
- </mapper>
|