BehospitalInfoMapper.xml 294 KB

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