BehospitalInfoMapper.xml 709 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543
  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,IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,e.score_res as score_bn 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. LEFT JOIN med_qcresult_cases e
  59. on a.behospital_code = e.behospital_code
  60. AND e.is_deleted = 'N'
  61. and e.cases_id = 243
  62. ) t
  63. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  64. ON t.behospital_code = g.behospital_code
  65. AND t.hospital_id = g.hospital_id
  66. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  67. ON t.behospital_code = h.behospital_code
  68. AND t.hospital_id = h.hospital_id
  69. where t.is_deleted = 'N'
  70. <if test="diagnose != null and diagnose != ''">
  71. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  72. </if>
  73. <if test="deptName != null and deptName != ''">
  74. and t.beh_dept_name= #{deptName}
  75. </if>
  76. <if test="doctorName != null and doctorName != ''">
  77. and CONCAT(
  78. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  79. like CONCAT('%',#{doctorName},'%')
  80. </if>
  81. <if test="name != null and name != ''">
  82. and t.name like CONCAT('%',#{name},'%')
  83. </if>
  84. <if test="doctorCode != null and doctorCode != ''">
  85. and (t.doctor_id = #{doctorCode}
  86. or t.beh_doctor_id = #{doctorCode}
  87. or t.director_doctor_id = #{doctorCode})
  88. </if>
  89. <if test="fileCode != null and fileCode != ''">
  90. and t.file_code like CONCAT('%',#{fileCode},'%')
  91. </if>
  92. <if test="hospitalId != null">
  93. and t.hospital_id = #{hospitalId}
  94. </if>
  95. <if test="behospitalCode != null and behospitalCode != ''">
  96. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  97. </if>
  98. <if test="behosDateStart != null">
  99. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  100. </if>
  101. <if test="behosDateEnd != null">
  102. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  103. </if>
  104. <if test="leaveHosDateStart != null">
  105. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  106. </if>
  107. <if test="leaveHosDateEnd != null">
  108. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  109. </if>
  110. <if test="level != null and level != ''">
  111. and t.level = #{level}
  112. </if>
  113. <if test="isPlacefile != null and isPlacefile != ''">
  114. and t.is_placefile = #{isPlacefile}
  115. </if>
  116. and t.qc_type_id != 0) p
  117. where p.is_deleted="N"
  118. <if test="checkStatus != null ">
  119. and p.check_status = #{checkStatus}
  120. </if>
  121. <if test="mrStatus != null ">
  122. AND p.mr_status = #{mrStatus}
  123. </if>
  124. <if test="chName != null and chName !=''">
  125. AND p.ch_name like CONCAT('%',#{chName},'%')
  126. </if>
  127. <if test="mrName != null and mrName !=''">
  128. AND p.mr_name like CONCAT('%',#{mrName},'%')
  129. </if>
  130. <if test="chTimeStart != null">
  131. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  132. </if>
  133. <if test="chTimeEnd != null">
  134. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  135. </if>
  136. <if test="mrTimeStart != null">
  137. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  138. </if>
  139. <if test="mrTimeEnd != null">
  140. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  141. </if>
  142. </select>
  143. <!-- <select id="getQualityCase" resultType="com.diagbot.dto.QualityControlDTO">
  144. SELECT
  145. m1.* ,
  146. m2.score_res as totalScore
  147. from(
  148. SELECT DISTINCT
  149. m1.hospital_id,
  150. m1.behospital_code,
  151. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  152. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  153. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  154. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  155. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  156. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  157. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  158. FROM (
  159. SELECT
  160. c.behospital_code,
  161. a.mode_id,
  162. c.cases_score,
  163. c.cases_id,
  164. c.hospital_id
  165. FROM
  166. `qc_cases_entry` a,
  167. qc_mode b,
  168. med_qcresult_detail c,
  169. qc_cases_hospital d,
  170. med_behospital_info e
  171. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  172. AND a.id = c.cases_entry_id
  173. AND a.mode_id = b.id
  174. AND c.cases_id = d.cases_id
  175. AND c.hospital_id = d.hospital_id
  176. AND c.behospital_code = e.behospital_code
  177. AND c.hospital_id = e.hospital_id
  178. <if test="hospitalId != null">
  179. and c.hospital_id = #{hospitalId}
  180. </if>
  181. <if test="deptName != null and deptName != ''">
  182. and e.beh_dept_name= #{deptName}
  183. </if>
  184. <if test="behospitalCode != null and behospitalCode != ''">
  185. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  186. </if>
  187. <if test="isPlacefile != null and isPlacefile != ''">
  188. and e.is_placefile = #{isPlacefile}
  189. </if>
  190. <if test="behosDateStart != null">
  191. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  192. </if>
  193. <if test="behosDateEnd != null">
  194. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  195. </if>
  196. <if test="leaveHosDateStart != null">
  197. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  198. </if>
  199. <if test="leaveHosDateEnd != null">
  200. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  201. </if>
  202. <if test="level != null and level != ''">
  203. and e.level = #{level}
  204. </if>
  205. <if test="level != null and level != ''">
  206. and e.level = #{level}
  207. </if>
  208. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  209. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  210. ON m2.is_deleted = 'N'
  211. AND m1.hospital_id = m2.hospital_id
  212. AND m1.behospital_code = m2.behospital_code
  213. </select>
  214. <select id="getQualitySorce" resultType="com.diagbot.dto.QualityControlDTO">
  215. SELECT
  216. t1.behospital_code,
  217. t1.hospital_id,
  218. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  219. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  220. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  221. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  222. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  223. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  224. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  225. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  226. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  227. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  228. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  229. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  230. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  231. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  232. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  233. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  234. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  235. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  236. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  237. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  238. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  239. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id != 1 AND t1.mode_id != 2 AND t1.mode_id != 6 AND t1.mode_id != 8 AND t1.mode_id != 156 AND t1.mode_id != 17 AND t1.mode_id != 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS otherCase
  240. FROM (
  241. SELECT
  242. c.behospital_code,
  243. c.hospital_id,
  244. a.mode_id,
  245. c.cases_score,
  246. c.score,
  247. c.msg,
  248. c.is_reject,
  249. c.cases_id
  250. FROM
  251. `qc_cases_entry` a,
  252. qc_mode b,
  253. med_qcresult_detail c,
  254. qc_cases_hospital d,
  255. med_behospital_info e
  256. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  257. AND a.id = c.cases_entry_id
  258. AND a.mode_id = b.id
  259. AND c.cases_id = d.cases_id
  260. AND c.hospital_id = d.hospital_id
  261. AND c.behospital_code = e.behospital_code
  262. AND c.hospital_id = e.hospital_id
  263. <if test="hospitalId != null">
  264. and c.hospital_id = #{hospitalId}
  265. </if>
  266. <if test="deptName != null and deptName != ''">
  267. and e.beh_dept_name= #{deptName}
  268. </if>
  269. <if test="behospitalCode != null and behospitalCode != ''">
  270. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  271. </if>
  272. <if test="isPlacefile != null and isPlacefile != ''">
  273. and e.is_placefile = #{isPlacefile}
  274. </if>
  275. <if test="behosDateStart != null">
  276. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  277. </if>
  278. <if test="behosDateEnd != null">
  279. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  280. </if>
  281. <if test="leaveHosDateStart != null">
  282. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  283. </if>
  284. <if test="leaveHosDateEnd != null">
  285. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  286. </if>
  287. <if test="level != null and level != ''">
  288. and e.level = #{level}
  289. </if>
  290. <if test="level != null and level != ''">
  291. and e.level = #{level}
  292. </if>
  293. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  294. )t1 GROUP BY behospital_code
  295. </select>
  296. -->
  297. <select id="getQualityCaseSorce" resultType="com.diagbot.dto.CaseScoreDTO">
  298. SELECT a.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,a.mode_id as modelId,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  299. FROM `qc_cases_entry` a, med_qcresult_detail c,med_behospital_info e
  300. where a.is_deleted = 'N' and c.is_deleted = 'N'AND e.is_deleted = 'N'
  301. and a.id = c.cases_entry_id
  302. AND c.behospital_code = e.behospital_code
  303. AND c.hospital_id = e.hospital_id
  304. and c.hospital_id = #{hospitalId}
  305. <if test="deptName != null and deptName != ''">
  306. and e.beh_dept_name= #{deptName}
  307. </if>
  308. <if test="behospitalCode != null and behospitalCode != ''">
  309. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  310. </if>
  311. <if test="isPlacefile != null and isPlacefile != ''">
  312. and e.is_placefile = #{isPlacefile}
  313. </if>
  314. <if test="behosDateStart != null">
  315. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  316. </if>
  317. <if test="behosDateEnd != null">
  318. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  319. </if>
  320. <if test="leaveHosDateStart != null">
  321. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  322. </if>
  323. <if test="leaveHosDateEnd != null">
  324. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  325. </if>
  326. GROUP BY c.behospital_code,a.mode_id,c.cases_entry_id
  327. order by c.behospital_code
  328. </select>
  329. <select id="getQualityCaseSorceByDept" resultType="com.diagbot.dto.CaseScoreDTO">
  330. SELECT a.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,a.mode_id as modelId,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  331. FROM `qc_cases_entry` a, med_qcresult_detail c,sys_user_dept d,med_behospital_info e
  332. where a.is_deleted = 'N' and c.is_deleted = 'N' AND d.is_deleted = 'N' AND e.is_deleted = 'N'
  333. and a.id = c.cases_entry_id
  334. AND c.behospital_code = e.behospital_code
  335. ON d.hospital_id = e.hospital_id
  336. AND e.beh_dept_id = d.dept_id
  337. AND c.hospital_id = e.hospital_id
  338. and c.hospital_id = #{hospitalId}
  339. <if test="deptName != null and deptName != ''">
  340. and e.beh_dept_name= #{deptName}
  341. </if>
  342. <if test="userId != null and userId != ''">
  343. and d.user_id = #{userId}
  344. </if>
  345. <if test="behospitalCode != null and behospitalCode != ''">
  346. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  347. </if>
  348. <if test="isPlacefile != null and isPlacefile != ''">
  349. and e.is_placefile = #{isPlacefile}
  350. </if>
  351. <if test="behosDateStart != null">
  352. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  353. </if>
  354. <if test="behosDateEnd != null">
  355. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  356. </if>
  357. <if test="leaveHosDateStart != null">
  358. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  359. </if>
  360. <if test="leaveHosDateEnd != null">
  361. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  362. </if>
  363. GROUP BY c.behospital_code,a.mode_id,c.cases_entry_id
  364. order by c.behospital_code
  365. </select>
  366. <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  367. SELECT * FROM (
  368. select
  369. t.name AS NAME,
  370. t.behospital_code AS behospitalCode,
  371. t.doctor_name AS doctorName,
  372. t.beh_dept_name AS deptName,
  373. t.beh_dept_id AS deptId,
  374. t.leave_hospital_date AS leaveHospitalDate,
  375. t.level,
  376. t.score_res as totalScore,
  377. t.is_deleted,
  378. g.check_name AS chName,
  379. h.check_name AS mrName
  380. from (
  381. select a.*,
  382. ifnull(b.level,'未评分') as level,
  383. b.grade_type,
  384. b.score_res
  385. from med_behospital_info a
  386. LEFT JOIN med_qcresult_info b
  387. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  388. ) t
  389. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  390. ON t.behospital_code = g.behospital_code
  391. AND t.hospital_id = g.hospital_id
  392. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  393. ON t.behospital_code = h.behospital_code
  394. AND t.hospital_id = h.hospital_id
  395. where t.is_deleted = 'N'
  396. <if test="diagnose != null and diagnose != ''">
  397. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  398. </if>
  399. <if test="deptName != null and deptName != ''">
  400. and t.beh_dept_name= #{deptName}
  401. </if>
  402. <if test="doctorName != null and doctorName != ''">
  403. and CONCAT(
  404. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  405. like CONCAT('%',#{doctorName},'%')
  406. </if>
  407. <if test="name != null and name != ''">
  408. and t.name like CONCAT('%',#{name},'%')
  409. </if>
  410. <if test="doctorCode != null and doctorCode != ''">
  411. and (t.doctor_id = #{doctorCode}
  412. or t.beh_doctor_id = #{doctorCode}
  413. or t.director_doctor_id = #{doctorCode})
  414. </if>
  415. <if test="fileCode != null and fileCode != ''">
  416. and t.file_code like CONCAT('%',#{fileCode},'%')
  417. </if>
  418. <if test="hospitalId != null">
  419. and t.hospital_id = #{hospitalId}
  420. </if>
  421. <if test="behospitalCode != null and behospitalCode != ''">
  422. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  423. </if>
  424. <if test="behosDateStart != null">
  425. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  426. </if>
  427. <if test="behosDateEnd != null">
  428. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  429. </if>
  430. <if test="leaveHosDateStart != null">
  431. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  432. </if>
  433. <if test="leaveHosDateEnd != null">
  434. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  435. </if>
  436. <if test="level != null and level != ''">
  437. and t.level = #{level}
  438. </if>
  439. <if test="isPlacefile != null and isPlacefile != ''">
  440. and t.is_placefile = #{isPlacefile}
  441. </if>
  442. and t.qc_type_id != 0) p
  443. where p.is_deleted="N"
  444. <if test="chName != null and chName !=''">
  445. AND p.chName like CONCAT('%',#{chName},'%')
  446. </if>
  447. <if test="mrName != null and mrName !=''">
  448. AND p.mrName like CONCAT('%',#{mrName},'%')
  449. </if>
  450. </select>
  451. <select id="qualityControlByDept" resultType="com.diagbot.dto.QualityControlDeptDTO">
  452. SELECT * FROM (
  453. select
  454. t.name AS NAME,
  455. t.behospital_code AS behospitalCode,
  456. t.doctor_name AS doctorName,
  457. t.beh_dept_name AS deptName,
  458. t.beh_dept_id AS deptId,
  459. t.leave_hospital_date AS leaveHospitalDate,
  460. t.level,
  461. t.score_res as totalScore,
  462. t.is_deleted,
  463. g.check_name AS chName,
  464. h.check_name AS mrName
  465. from (
  466. select a.*, ifnull(b.level,'未评分') as level, b.grade_type,d.user_id, b.score_res, b.gmt_create as
  467. grade_time from med_behospital_info a
  468. LEFT JOIN med_qcresult_info b
  469. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  470. LEFT JOIN sys_user_dept d
  471. ON a.hospital_id = d.hospital_id
  472. AND a.beh_dept_id = d.dept_id
  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. AND t.user_id = #{userId}
  482. <if test="diagnose != null and diagnose != ''">
  483. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  484. </if>
  485. <if test="deptName != null and deptName != ''">
  486. and t.beh_dept_name= #{deptName}
  487. </if>
  488. <if test="doctorName != null and doctorName != ''">
  489. and CONCAT(
  490. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  491. like CONCAT('%',#{doctorName},'%')
  492. </if>
  493. <if test="name != null and name != ''">
  494. and t.name like CONCAT('%',#{name},'%')
  495. </if>
  496. <if test="doctorCode != null and doctorCode != ''">
  497. and (t.doctor_id = #{doctorCode}
  498. or t.beh_doctor_id = #{doctorCode}
  499. or t.director_doctor_id = #{doctorCode})
  500. </if>
  501. <if test="fileCode != null and fileCode != ''">
  502. and t.file_code like CONCAT('%',#{fileCode},'%')
  503. </if>
  504. <if test="hospitalId != null">
  505. and t.hospital_id = #{hospitalId}
  506. </if>
  507. <if test="behospitalCode != null and behospitalCode != ''">
  508. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  509. </if>
  510. <if test="behosDateStart != null">
  511. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  512. </if>
  513. <if test="behosDateEnd != null">
  514. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  515. </if>
  516. <if test="leaveHosDateStart != null">
  517. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  518. </if>
  519. <if test="leaveHosDateEnd != null">
  520. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  521. </if>
  522. <if test="level != null and level != ''">
  523. and t.level = #{level}
  524. </if>
  525. <if test="isPlacefile != null and isPlacefile != ''">
  526. and t.is_placefile = #{isPlacefile}
  527. </if>
  528. and t.qc_type_id != 0) p
  529. where p.is_deleted="N"
  530. <if test="chName != null and chName !=''">
  531. AND p.chName like CONCAT('%',#{chName},'%')
  532. </if>
  533. <if test="mrName != null and mrName !=''">
  534. AND p.mrName like CONCAT('%',#{mrName},'%')
  535. </if>
  536. </select>
  537. <!-- <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  538. SELECT m.* FROM(
  539. SELECT
  540. a.name AS NAME,
  541. a.behospital_code AS behospitalCode,
  542. a.doctor_name AS doctorName,
  543. a.beh_dept_name AS deptName,
  544. a.beh_dept_id AS deptId,
  545. a.leave_hospital_date AS leaveHospitalDate,
  546. c.behospital_code,
  547. c.hospital_id,
  548. c.admissionNote,
  549. c.firstCourseNote,
  550. c.medHomePage,
  551. c.docAdviceNote,
  552. c.courseRecord,
  553. c.operationInfo,
  554. c.dischargeNote,
  555. c.admissionNoteScore,
  556. c.firstCourseNoteScore,
  557. c. medHomePageScore,
  558. c.docAdviceNoteScore,
  559. c.courseRecordScore,
  560. c.operationInfoScore,
  561. c.dischargeNoteScore,
  562. c.otherCase,
  563. (100.0-c.score_res) AS otherCaseScore,
  564. IFNULL(b.level,'未评分') AS `level`,
  565. g.check_name AS ch_name,
  566. h.check_name AS mr_name
  567. FROM
  568. med_behospital_info a LEFT JOIN med_qcresult_info b
  569. ON a.behospital_code = b.behospital_code AND b.is_deleted = 'N'
  570. LEFT JOIN (
  571. SELECT
  572. t.behospital_code,
  573. t.hospital_id,
  574. t.admissionNote,
  575. t.firstCourseNote,
  576. t.medHomePage,
  577. t.docAdviceNote,
  578. t.courseRecord,
  579. t.operationInfo,
  580. t.dischargeNote,
  581. t.otherCase,
  582. t.score_res,
  583. if(t.admissionNoteScoreOn >= t.admissionNoteTolScore, (t.admissionNoteTolScore + t.admissionNoteScoreTh),(t.admissionNoteScoreOn + t.admissionNoteScoreTh)) AS admissionNoteScore,
  584. if(t.firstCourseNoteScoreOn >= t.firstCourseNoteTolScore, (t.firstCourseNoteTolScore + t.firstCourseNoteScoreTh),(t.firstCourseNoteScoreOn + t.firstCourseNoteScoreTh)) AS firstCourseNoteScore,
  585. if(t.medHomePageScoreOn >= t.medHomePageTolScore, (t.medHomePageTolScore + t.medHomePageScoreTh),(t.medHomePageScoreOn + t.medHomePageScoreTh)) AS medHomePageScore,
  586. if(t.docAdviceNoteScoreOn >= t.docAdviceNoteTolScore, (t.docAdviceNoteTolScore + t.docAdviceNoteScoreTh),(t.docAdviceNoteScoreOn + t.docAdviceNoteScoreTh)) AS docAdviceNoteScore,
  587. if(t.courseRecordScoreOn >= t.courseRecordTolScore, (t.courseRecordTolScore + t.courseRecordScoreTh),(t.courseRecordScoreOn + t.courseRecordScoreTh)) AS courseRecordScore,
  588. if(t.operationInfoScoreOn >= t.operationInfoTolScore, (t.operationInfoTolScore + t.operationInfoScoreTh),(t.operationInfoScoreOn + t.operationInfoScoreTh)) AS operationInfoScore,
  589. if(t.dischargeNoteScoreOn >= t.dischargeNoteTolScore, (t.dischargeNoteTolScore + t.dischargeNoteScoreTh),(t.dischargeNoteScoreOn + t.dischargeNoteScoreTh)) AS dischargeNoteScore
  590. from(
  591. select
  592. t1.*,
  593. t2.admissionNoteTolScore,
  594. t2.firstCourseNoteTolScore,
  595. t2.medHomePageTolScore,
  596. t2.docAdviceNoteTolScore,
  597. t2.courseRecordTolScore,
  598. t2.operationInfoTolScore,
  599. t2.dischargeNoteTolScore,
  600. t2.score_res FROM (
  601. SELECT
  602. t1.behospital_code,
  603. t1.hospital_id,
  604. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  605. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  606. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  607. (SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS admissionNoteScoreTh,
  608. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  609. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  610. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  611. (SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) -SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS firstCourseNoteScoreTh,
  612. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  613. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  614. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  615. (SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS medHomePageScoreTh,
  616. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  617. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  618. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  619. (SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS docAdviceNoteScoreTh,
  620. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  621. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  622. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  623. (SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS courseRecordScoreTh,
  624. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  625. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  626. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  627. (SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS operationInfoScoreTh,
  628. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  629. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  630. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  631. (SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END)-GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' )) AS dischargeNoteScoreTh,
  632. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id != 1 AND t1.mode_id != 2 AND t1.mode_id != 6 AND t1.mode_id != 8 AND t1.mode_id != 156 AND t1.mode_id != 17 AND t1.mode_id != 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS otherCase
  633. FROM (
  634. SELECT
  635. c.behospital_code,
  636. c.hospital_id,
  637. a.mode_id,
  638. c.cases_score,
  639. c.score,
  640. c.msg,
  641. c.is_reject,
  642. c.cases_id
  643. FROM
  644. `qc_cases_entry` a,
  645. qc_mode b,
  646. med_qcresult_detail c,
  647. qc_cases_hospital d,
  648. med_behospital_info e
  649. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  650. AND a.id = c.cases_entry_id
  651. AND a.mode_id = b.id
  652. AND c.cases_id = d.cases_id
  653. AND c.hospital_id = d.hospital_id
  654. AND c.behospital_code = e.behospital_code
  655. AND c.hospital_id = e.hospital_id
  656. <if test="hospitalId != null">
  657. and c.hospital_id = #{hospitalId}
  658. </if>
  659. <if test="deptName != null and deptName != ''">
  660. and e.beh_dept_name= #{deptName}
  661. </if>
  662. <if test="behospitalCode != null and behospitalCode != ''">
  663. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  664. </if>
  665. <if test="isPlacefile != null and isPlacefile != ''">
  666. and e.is_placefile = #{isPlacefile}
  667. </if>
  668. <if test="behosDateStart != null">
  669. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  670. </if>
  671. <if test="behosDateEnd != null">
  672. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  673. </if>
  674. <if test="leaveHosDateStart != null">
  675. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  676. </if>
  677. <if test="leaveHosDateEnd != null">
  678. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  679. </if>
  680. <if test="level != null and level != ''">
  681. and e.level = #{level}
  682. </if>
  683. <if test="level != null and level != ''">
  684. and e.level = #{level}
  685. </if>
  686. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  687. )t1 GROUP BY behospital_code)t1
  688. LEFT JOIN (
  689. SELECT m1.*, m2.score_res FROM(
  690. SELECT
  691. m1.hospital_id,
  692. m1.behospital_code,
  693. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  694. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  695. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  696. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  697. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  698. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  699. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  700. FROM (
  701. SELECT
  702. c.behospital_code,
  703. a.mode_id,
  704. c.cases_score,
  705. c.cases_id,
  706. c.hospital_id
  707. FROM
  708. `qc_cases_entry` a,
  709. qc_mode b,
  710. med_qcresult_detail c,
  711. qc_cases_hospital d,
  712. med_behospital_info e
  713. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  714. AND a.id = c.cases_entry_id
  715. AND a.mode_id = b.id
  716. AND c.cases_id = d.cases_id
  717. AND c.hospital_id = d.hospital_id
  718. AND c.behospital_code = e.behospital_code
  719. AND c.hospital_id = e.hospital_id
  720. <if test="hospitalId != null">
  721. and c.hospital_id = #{hospitalId}
  722. </if>
  723. <if test="deptName != null and deptName != ''">
  724. and e.beh_dept_name= #{deptName}
  725. </if>
  726. <if test="behospitalCode != null and behospitalCode != ''">
  727. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  728. </if>
  729. <if test="isPlacefile != null and isPlacefile != ''">
  730. and e.is_placefile = #{isPlacefile}
  731. </if>
  732. <if test="behosDateStart != null">
  733. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  734. </if>
  735. <if test="behosDateEnd != null">
  736. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  737. </if>
  738. <if test="leaveHosDateStart != null">
  739. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  740. </if>
  741. <if test="leaveHosDateEnd != null">
  742. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  743. </if>
  744. <if test="level != null and level != ''">
  745. and e.level = #{level}
  746. </if>
  747. <if test="level != null and level != ''">
  748. and e.level = #{level}
  749. </if>
  750. GROUP BY mode_id
  751. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  752. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  753. ON m2.is_deleted = 'N'
  754. AND m1.hospital_id = m2.hospital_id
  755. AND m1.behospital_code = m2.behospital_code
  756. )t2
  757. ON t1.hospital_id = t2.hospital_id
  758. AND t1.behospital_code = t2.behospital_code)t)c
  759. ON a.behospital_code = c.behospital_code
  760. AND a.hospital_id = c.hospital_id
  761. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  762. ON a.behospital_code = g.behospital_code
  763. AND a.hospital_id = g.hospital_id
  764. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  765. ON a.behospital_code = h.behospital_code
  766. AND a.hospital_id = h.hospital_id
  767. where
  768. a.is_deleted = 'N'
  769. <if test="deptName != null and deptName != ''">
  770. and a.beh_dept_name= #{deptName}
  771. </if>
  772. <if test="doctorName != null and doctorName != ''">
  773. and CONCAT(
  774. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  775. like CONCAT('%',#{doctorName},'%')
  776. </if>
  777. <if test="name != null and name != ''">
  778. and a.name like CONCAT('%',#{name},'%')
  779. </if>
  780. <if test="doctorCode != null and doctorCode != ''">
  781. and (a.doctor_id = #{doctorCode}
  782. or a.beh_doctor_id = #{doctorCode}
  783. or a.director_doctor_id = #{doctorCode})
  784. </if>
  785. <if test="fileCode != null and fileCode != ''">
  786. and a.file_code like CONCAT('%',#{fileCode},'%')
  787. </if>
  788. <if test="hospitalId != null">
  789. and a.hospital_id = #{hospitalId}
  790. </if>
  791. <if test="behospitalCode != null and behospitalCode != ''">
  792. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  793. </if>
  794. <if test="behosDateStart != null">
  795. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  796. </if>
  797. <if test="behosDateEnd != null">
  798. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  799. </if>
  800. <if test="leaveHosDateStart != null">
  801. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  802. </if>
  803. <if test="leaveHosDateEnd != null">
  804. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  805. </if>
  806. <if test="level != null and level != ''">
  807. and a.level = #{level}
  808. </if>
  809. <if test="isPlacefile != null and isPlacefile != ''">
  810. and a.is_placefile = #{isPlacefile}
  811. </if>
  812. and a.qc_type_id != 0
  813. <if test="chName != null and chName !=''">
  814. AND g.ch_name like CONCAT('%',#{chName},'%')
  815. </if>
  816. <if test="mrName != null and mrName !=''">
  817. AND h.mr_name like CONCAT('%',#{mrName},'%')
  818. </if>)m
  819. </select>-->
  820. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  821. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  822. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
  823. c.opt_type, c.grade_type, c.gmt_create, c.gmt_modified,
  824. a.type, a.drgs
  825. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  826. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  827. and a.id = c.cases_entry_id
  828. and a.mode_id = b.id
  829. AND c.cases_id = d.cases_id
  830. and c.hospital_id = d.hospital_id
  831. and c.hospital_id = #{hospitalId}
  832. and c.behospital_code = #{behospitalCode}
  833. order by b.order_no, c.grade_type desc, a.order_no
  834. </select>
  835. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  836. SELECT b.id model_id,b.`name` model_name,
  837. d.score,d.msg,d.cases_entry_id,d.is_reject,
  838. a.cases_id cases_id, a.name standard_msg,a.code
  839. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  840. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  841. and a.mode_id = b.id
  842. and a.id = d.cases_entry_id
  843. and d.is_used = 1
  844. and d.hospital_id = #{hospitalId}
  845. and a.code in
  846. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  847. #{item}
  848. </foreach>
  849. <if test="modeId != null">
  850. and a.mode_id = #{modeId}
  851. </if>
  852. order by b.order_no, a.order_no;
  853. </select>
  854. <!-- 各科室缺陷占比-全院-首页 -->
  855. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  856. resultType="com.diagbot.dto.NumDTO">
  857. SELECT
  858. a.beh_dept_id as id,
  859. a.beh_dept_name as name,
  860. count(*) AS num
  861. FROM
  862. med_behospital_info a,
  863. med_qcresult_info c,
  864. med_qcresult_detail d
  865. WHERE
  866. a.behospital_code = c.behospital_code
  867. AND a.hospital_id = c.hospital_id
  868. AND a.behospital_code = d.behospital_code
  869. AND a.hospital_id = d.hospital_id
  870. AND a.is_deleted = 'N'
  871. AND c.is_deleted = 'N'
  872. AND d.is_deleted = 'N'
  873. <if test="isPlacefile != null and isPlacefile != ''">
  874. and a.is_placefile = #{isPlacefile}
  875. </if>
  876. <![CDATA[AND a.qc_type_id <>0 ]]>
  877. <if test="hospitalId != null and hospitalId != ''">
  878. AND a.hospital_id = #{hospitalId}
  879. </if>
  880. <if test="isPlacefile != null and isPlacefile == 0">
  881. <if test="startDate != null and startDate != ''">
  882. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  883. </if>
  884. <if test="endDate != null and endDate != ''">
  885. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  886. </if>
  887. </if>
  888. <if test="isPlacefile != null and isPlacefile == 1">
  889. <if test="startDate != null and startDate != ''">
  890. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  891. </if>
  892. <if test="endDate != null and endDate != ''">
  893. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  894. </if>
  895. </if>
  896. GROUP BY
  897. a.beh_dept_id,
  898. a.beh_dept_name
  899. ORDER BY
  900. count(*) DESC
  901. </select>
  902. <!-- 质控结果缺陷总数查询-->
  903. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  904. SELECT
  905. count(*) AS totle
  906. FROM
  907. med_behospital_info a,
  908. med_qcresult_info c,
  909. med_qcresult_detail d
  910. WHERE
  911. a.behospital_code = c.behospital_code
  912. AND a.hospital_id = c.hospital_id
  913. AND a.behospital_code = d.behospital_code
  914. AND a.hospital_id = d.hospital_id
  915. AND a.is_deleted = 'N'
  916. AND c.is_deleted = 'N'
  917. AND d.is_deleted = 'N'
  918. <if test="isPlacefile != null and isPlacefile != ''">
  919. and a.is_placefile = #{isPlacefile}
  920. </if>
  921. <![CDATA[AND a.qc_type_id <>0 ]]>
  922. <if test="hospitalId != null and hospitalId != ''">
  923. AND a.hospital_id = #{hospitalId}
  924. </if>
  925. <if test="isPlacefile != null and isPlacefile == 0">
  926. <if test="startDate != null and startDate != ''">
  927. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  928. </if>
  929. <if test="endDate != null and endDate != ''">
  930. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  931. </if>
  932. </if>
  933. <if test="isPlacefile != null and isPlacefile == 1">
  934. <if test="startDate != null and startDate != ''">
  935. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  936. </if>
  937. <if test="endDate != null and endDate != ''">
  938. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  939. </if>
  940. </if>
  941. </select>
  942. <!--获取病历-->
  943. <select id="getNoGrade" resultMap="BaseResultMap">
  944. select * from med_behospital_info a
  945. where a.is_deleted = 'N'
  946. and a.qc_type_id != 0
  947. <if test="isPlacefile != null and isPlacefile != ''">
  948. and a.is_placefile = #{isPlacefile}
  949. </if>
  950. <if test="filterFlag != null and filterFlag == 0">
  951. and
  952. not EXISTS (
  953. SELECT
  954. 1
  955. FROM
  956. med_qcresult_info b
  957. WHERE
  958. b.is_deleted = 'N'
  959. AND a.hospital_id = b.hospital_id
  960. AND a.behospital_code = b.behospital_code
  961. )
  962. </if>
  963. <if test="leaveDate != null">
  964. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  965. </if>
  966. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  967. and a.hospital_id in
  968. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  969. #{item}
  970. </foreach>
  971. </if>
  972. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  973. and a.behospital_code in
  974. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  975. #{item}
  976. </foreach>
  977. </if>
  978. <if test="individuation != null and individuation.contains(1)">
  979. union
  980. select * from med_behospital_info b
  981. where b.is_deleted = 'N'
  982. and b.qc_type_id != 0
  983. <if test="isPlacefile != null and isPlacefile != ''">
  984. and b.is_placefile = #{isPlacefile}
  985. </if>
  986. <if test="startLeaveDate != null">
  987. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  988. </if>
  989. <if test="endLeaveDate != null">
  990. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  991. </if>
  992. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  993. and b.hospital_id in
  994. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  995. #{item}
  996. </foreach>
  997. </if>
  998. </if>
  999. </select>
  1000. <!--质控评分(科室)分页-->
  1001. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1002. SELECT * from (
  1003. SELECT
  1004. t.*,
  1005. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1006. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1007. g.check_type as ch_type,
  1008. h.check_type AS mr_type,
  1009. g.check_name as ch_name,
  1010. h.check_name as mr_name,
  1011. g.check_time as ch_time,
  1012. h.check_time AS mr_time
  1013. FROM
  1014. ( SELECT
  1015. a.*,
  1016. IFNULL(b.level, '未评分') AS `level`,
  1017. b.grade_type,
  1018. b.score_res,
  1019. e.score_res as score_bn,
  1020. b.gmt_create AS grade_time,
  1021. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1022. FROM
  1023. med_behospital_info a
  1024. JOIN sys_user_dept d
  1025. ON a.hospital_id = d.hospital_id
  1026. AND a.beh_dept_id = d.dept_id
  1027. LEFT JOIN med_qcresult_info b
  1028. ON a.behospital_code = b.behospital_code
  1029. AND b.is_deleted = 'N'
  1030. LEFT JOIN med_qcresult_cases e
  1031. on a.behospital_code = e.behospital_code
  1032. AND e.is_deleted = 'N'
  1033. and e.cases_id = 243
  1034. LEFT JOIN med_home_page c
  1035. ON a.behospital_code = c.behospital_code
  1036. AND c.is_deleted = 'N'
  1037. WHERE d.is_deleted = 'N'
  1038. AND d.user_id = #{userId}
  1039. ) t
  1040. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  1041. ON t.behospital_code = g.behospital_code
  1042. AND t.hospital_id = g.hospital_id
  1043. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1044. ON t.behospital_code = h.behospital_code
  1045. AND t.hospital_id = h.hospital_id
  1046. where t.is_deleted = 'N'
  1047. <if test="diagnose != null and diagnose != ''">
  1048. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1049. </if>
  1050. <if test="deptName != null and deptName != ''">
  1051. and t.beh_dept_name = #{deptName}
  1052. </if>
  1053. <if test="doctorName != null and doctorName != ''">
  1054. and CONCAT(
  1055. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  1056. like CONCAT('%',#{doctorName},'%')
  1057. </if>
  1058. <if test="doctorCode != null and doctorCode != ''">
  1059. and (t.doctor_id = #{doctorCode}
  1060. or t.beh_doctor_id = #{doctorCode}
  1061. or t.director_doctor_id = #{doctorCode})
  1062. </if>
  1063. <if test="name != null and name != ''">
  1064. and t.name like CONCAT('%',#{name},'%')
  1065. </if>
  1066. <if test="fileCode != null and fileCode != ''">
  1067. and t.file_code like CONCAT('%',#{fileCode},'%')
  1068. </if>
  1069. <if test="hospitalId != null">
  1070. and t.hospital_id = #{hospitalId}
  1071. </if>
  1072. <if test="behospitalCode != null and behospitalCode != ''">
  1073. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1074. </if>
  1075. <if test="behosDateStart != null">
  1076. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1077. </if>
  1078. <if test="behosDateEnd != null">
  1079. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1080. </if>
  1081. <if test="leaveHosDateStart != null">
  1082. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1083. </if>
  1084. <if test="leaveHosDateEnd != null">
  1085. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1086. </if>
  1087. <if test="level != null and level != ''">
  1088. and t.level = #{level}
  1089. </if>
  1090. <if test="isPlacefile != null and isPlacefile != ''">
  1091. and t.is_placefile = #{isPlacefile}
  1092. </if>
  1093. and t.qc_type_id != 0) p
  1094. where p.is_deleted="N"
  1095. <if test="checkStatus != null ">
  1096. and p.check_status = #{checkStatus}
  1097. </if>
  1098. <if test="mrStatus != null ">
  1099. AND p.mr_status = #{mrStatus}
  1100. </if>
  1101. <if test="chName != null and chName !=''">
  1102. AND p.ch_name like CONCAT('%',#{chName},'%')
  1103. </if>
  1104. <if test="mrName != null and mrName !=''">
  1105. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1106. </if>
  1107. <if test="chTimeStart != null">
  1108. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1109. </if>
  1110. <if test="chTimeEnd != null">
  1111. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1112. </if>
  1113. <if test="mrTimeStart != null">
  1114. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1115. </if>
  1116. <if test="mrTimeEnd != null">
  1117. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1118. </if>
  1119. </select>
  1120. <!--质控评分(个人)分页-->
  1121. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1122. Select * from (
  1123. select t.*,
  1124. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1125. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1126. g.check_type as ch_type,
  1127. h.check_type AS mr_type,
  1128. g.check_name as ch_name,
  1129. h.check_name as mr_name,
  1130. g.check_time as ch_time,
  1131. h.check_time AS mr_time
  1132. from (SELECT
  1133. a.*,
  1134. IFNULL(b.level, '未评分') AS `level`,
  1135. b.grade_type,
  1136. b.score_res,
  1137. e.score_res as score_bn,
  1138. b.gmt_create AS grade_time,
  1139. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1140. FROM
  1141. med_behospital_info a
  1142. JOIN
  1143. (SELECT
  1144. u.id,
  1145. u.linkman AS linkman,
  1146. uh.hospital_id
  1147. FROM
  1148. sys_user u
  1149. JOIN sys_user_hospital uh
  1150. ON u.id = uh.user_id
  1151. WHERE u.is_deleted = "N"
  1152. AND u.id = #{userId}
  1153. AND uh.hospital_id = #{hospitalId}) u1
  1154. ON a.hospital_id = u1.hospital_id
  1155. LEFT JOIN med_qcresult_info b
  1156. ON a.behospital_code = b.behospital_code
  1157. AND b.is_deleted = 'N'
  1158. LEFT JOIN med_qcresult_cases e
  1159. on a.behospital_code = e.behospital_code
  1160. AND e.is_deleted = 'N'
  1161. and e.cases_id = 243
  1162. LEFT JOIN med_home_page c
  1163. ON a.behospital_code = c.behospital_code
  1164. AND c.is_deleted = 'N'
  1165. WHERE
  1166. a.is_deleted = 'N'
  1167. and a.doctor_name = u1.linkman
  1168. or a.beh_doctor_name = u1.linkman
  1169. or a.director_doctor_name = u1.linkman
  1170. ) t
  1171. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  1172. ON t.behospital_code = g.behospital_code
  1173. AND t.hospital_id = g.hospital_id
  1174. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1175. ON t.behospital_code = h.behospital_code
  1176. AND t.hospital_id = h.hospital_id
  1177. WHERE t.is_deleted = 'N'
  1178. <if test="diagnose != null and diagnose != ''">
  1179. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1180. </if>
  1181. <if test="deptName != null and deptName != ''">
  1182. and t.beh_dept_name = #{deptName}
  1183. </if>
  1184. <if test="name != null and name != ''">
  1185. and t.name like CONCAT('%',#{name},'%')
  1186. </if>
  1187. <if test="fileCode != null and fileCode != ''">
  1188. and t.file_code like CONCAT('%',#{fileCode},'%')
  1189. </if>
  1190. <if test="behospitalCode != null and behospitalCode != ''">
  1191. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1192. </if>
  1193. <if test="behosDateStart != null">
  1194. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1195. </if>
  1196. <if test="behosDateEnd != null">
  1197. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1198. </if>
  1199. <if test="leaveHosDateStart != null">
  1200. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1201. </if>
  1202. <if test="leaveHosDateEnd != null">
  1203. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1204. </if>
  1205. <if test="level != null and level != ''">
  1206. and t.level = #{level}
  1207. </if>
  1208. <if test="isPlacefile != null and isPlacefile != ''">
  1209. and t.is_placefile = #{isPlacefile}
  1210. </if>
  1211. and t.qc_type_id != 0) p
  1212. where p.is_deleted="N"
  1213. <if test="checkStatus != null ">
  1214. and p.check_status = #{checkStatus}
  1215. </if>
  1216. <if test="mrStatus != null ">
  1217. AND p.mr_status = #{mrStatus}
  1218. </if>
  1219. <if test="chName != null and chName !=''">
  1220. AND p.ch_name like CONCAT('%',#{chName},'%')
  1221. </if>
  1222. <if test="mrName != null and mrName !=''">
  1223. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1224. </if>
  1225. <if test="chTimeStart != null">
  1226. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1227. </if>
  1228. <if test="chTimeEnd != null">
  1229. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1230. </if>
  1231. <if test="mrTimeStart != null">
  1232. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1233. </if>
  1234. <if test="mrTimeEnd != null">
  1235. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1236. </if>
  1237. </select>
  1238. <!--质控评分(医疗组)分页-->
  1239. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1240. select * from (
  1241. select t.*,
  1242. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1243. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1244. g.check_type as ch_type,
  1245. h.check_type AS mr_type,
  1246. g.check_name as ch_name,
  1247. h.check_name as mr_name,
  1248. g.check_time as ch_time,
  1249. h.check_time AS mr_time
  1250. from (
  1251. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  1252. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  1253. LEFT JOIN med_qcresult_info b
  1254. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  1255. LEFT JOIN med_qcresult_cases e
  1256. on a.behospital_code = e.behospital_code
  1257. AND e.is_deleted = 'N'
  1258. and e.cases_id = 243
  1259. left join med_home_page c
  1260. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  1261. ) t
  1262. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  1263. ON t.behospital_code = g.behospital_code
  1264. AND t.hospital_id = g.hospital_id
  1265. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1266. ON t.behospital_code = h.behospital_code
  1267. AND t.hospital_id = h.hospital_id
  1268. WHERE t.is_deleted = 'N'
  1269. and
  1270. t.doctor_id in (
  1271. SELECT doctor_id FROM `bas_doctor_info`
  1272. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  1273. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  1274. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  1275. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  1276. and c1.username = c3.doctor_id
  1277. and c2.hospital_id = #{hospitalId}
  1278. and c1.id = #{userId}
  1279. )
  1280. )
  1281. <if test="diagnose != null and diagnose != ''">
  1282. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1283. </if>
  1284. <if test="doctorName != null and doctorName != ''">
  1285. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  1286. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  1287. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  1288. </if>
  1289. <if test="name != null and name != ''">
  1290. and t.name like CONCAT('%',#{name},'%')
  1291. </if>
  1292. <if test="doctorCode != null and doctorCode != ''">
  1293. and (t.doctor_id = #{doctorCode}
  1294. or t.beh_doctor_id = #{doctorCode}
  1295. or t.director_doctor_id = #{doctorCode})
  1296. </if>
  1297. <if test="fileCode != null and fileCode != ''">
  1298. and t.file_code like CONCAT('%',#{fileCode},'%')
  1299. </if>
  1300. <if test="hospitalId != null">
  1301. and t.hospital_id = #{hospitalId}
  1302. </if>
  1303. <if test="behospitalCode != null and behospitalCode != ''">
  1304. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1305. </if>
  1306. <if test="behosDateStart != null">
  1307. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1308. </if>
  1309. <if test="behosDateEnd != null">
  1310. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1311. </if>
  1312. <if test="leaveHosDateStart != null">
  1313. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1314. </if>
  1315. <if test="leaveHosDateEnd != null">
  1316. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1317. </if>
  1318. <if test="level != null and level != ''">
  1319. and t.level = #{level}
  1320. </if>
  1321. <if test="isPlacefile != null and isPlacefile != ''">
  1322. and t.is_placefile = #{isPlacefile}
  1323. </if>
  1324. and t.qc_type_id != 0) p
  1325. where p.is_deleted="N"
  1326. <if test="checkStatus != null ">
  1327. and p.check_status = #{checkStatus}
  1328. </if>
  1329. <if test="mrStatus != null ">
  1330. AND p.mr_status = #{mrStatus}
  1331. </if>
  1332. <if test="chName != null and chName !=''">
  1333. AND p.ch_name like CONCAT('%',#{chName},'%')
  1334. </if>
  1335. <if test="mrName != null and mrName !=''">
  1336. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1337. </if>
  1338. <if test="chTimeStart != null">
  1339. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1340. </if>
  1341. <if test="chTimeEnd != null">
  1342. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1343. </if>
  1344. <if test="mrTimeStart != null">
  1345. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1346. </if>
  1347. <if test="mrTimeEnd != null">
  1348. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1349. </if>
  1350. </select>
  1351. <!-- 出院总人数统计-全院-首页 -->
  1352. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1353. SELECT
  1354. COUNT(*)
  1355. FROM
  1356. med_behospital_info a
  1357. WHERE
  1358. a.is_deleted = 'N'
  1359. <if test="isPlacefile != null and isPlacefile != ''">
  1360. and a.is_placefile = #{isPlacefile}
  1361. </if>
  1362. <if test="hospitalId != null and hospitalId != ''">
  1363. AND a.hospital_id = #{hospitalId}
  1364. </if>
  1365. <if test="isPlacefile != null and isPlacefile == 0">
  1366. <if test="startDate != null and startDate != ''">
  1367. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1368. </if>
  1369. <if test="endDate != null and endDate != ''">
  1370. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1371. </if>
  1372. </if>
  1373. <if test="isPlacefile != null and isPlacefile == 1">
  1374. <if test="startDate != null and startDate != ''">
  1375. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1376. </if>
  1377. <if test="endDate != null and endDate != ''">
  1378. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1379. </if>
  1380. </if>
  1381. </select>
  1382. <!-- 新生儿出院人数统计-全院-首页 -->
  1383. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1384. SELECT
  1385. COUNT(*)
  1386. FROM
  1387. med_behospital_info a,
  1388. med_home_page b
  1389. WHERE
  1390. a.is_deleted = 'N'
  1391. AND b.is_deleted = 'N'
  1392. AND a.hospital_id = b.hospital_id
  1393. AND a.behospital_code = b.behospital_code
  1394. <if test="isPlacefile != null and isPlacefile != ''">
  1395. and a.is_placefile = #{isPlacefile}
  1396. </if>
  1397. AND (
  1398. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  1399. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1400. )
  1401. <![CDATA[AND a.qc_type_id <>0 ]]>
  1402. <if test="hospitalId != null and hospitalId != ''">
  1403. AND a.hospital_id = #{hospitalId}
  1404. </if>
  1405. <if test="isPlacefile != null and isPlacefile == 0">
  1406. <if test="startDate != null and startDate != ''">
  1407. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1408. </if>
  1409. <if test="endDate != null and endDate != ''">
  1410. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1411. </if>
  1412. </if>
  1413. <if test="isPlacefile != null and isPlacefile == 1">
  1414. <if test="startDate != null and startDate != ''">
  1415. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1416. </if>
  1417. <if test="endDate != null and endDate != ''">
  1418. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1419. </if>
  1420. </if>
  1421. </select>
  1422. <!-- 死亡人数统计-全院-首页 -->
  1423. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1424. select COUNT(*) from(
  1425. SELECT distinct a.*
  1426. FROM
  1427. med_behospital_info a,
  1428. med_medical_record b,
  1429. med_medical_record_content c
  1430. WHERE
  1431. a.is_deleted = 'N'
  1432. AND b.is_deleted = 'N'
  1433. AND c.is_deleted = 'N'
  1434. AND a.hospital_id = b.hospital_id
  1435. AND a.hospital_id = c.hospital_id
  1436. AND a.behospital_code = b.behospital_code
  1437. AND b.rec_id = c.rec_id
  1438. and b.mode_id = '24'
  1439. <if test="isPlacefile != null and isPlacefile != ''">
  1440. and a.is_placefile = #{isPlacefile}
  1441. </if>
  1442. <![CDATA[AND a.qc_type_id <>0 ]]>
  1443. <if test="hospitalId != null and hospitalId != ''">
  1444. AND a.hospital_id = #{hospitalId}
  1445. </if>
  1446. <if test="isPlacefile != null and isPlacefile == 0">
  1447. <if test="startDate != null and startDate != ''">
  1448. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1449. </if>
  1450. <if test="endDate != null and endDate != ''">
  1451. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1452. </if>
  1453. </if>
  1454. <if test="isPlacefile != null and isPlacefile == 1">
  1455. <if test="startDate != null and startDate != ''">
  1456. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1457. </if>
  1458. <if test="endDate != null and endDate != ''">
  1459. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1460. </if>
  1461. </if>)m
  1462. </select>
  1463. <!-- 手术人数统计-全院-首页 -->
  1464. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1465. SELECT
  1466. COUNT( DISTINCT a.behospital_code )
  1467. FROM
  1468. med_behospital_info a,
  1469. med_medical_record c,
  1470. qc_mode d
  1471. WHERE
  1472. a.is_deleted = 'N'
  1473. AND c.is_deleted = 'N'
  1474. AND d.is_deleted = 'N'
  1475. AND a.hospital_id = c.hospital_id
  1476. AND a.behospital_code = c.behospital_code
  1477. AND c.mode_id = d.id
  1478. <if test="isPlacefile != null and isPlacefile != ''">
  1479. and a.is_placefile = #{isPlacefile}
  1480. </if>
  1481. AND d.`name` = '手术记录'
  1482. <![CDATA[AND a.qc_type_id <>0 ]]>
  1483. <if test="hospitalId != null and hospitalId != ''">
  1484. AND a.hospital_id = #{hospitalId}
  1485. </if>
  1486. <if test="isPlacefile != null and isPlacefile == 0">
  1487. <if test="startDate != null and startDate != ''">
  1488. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1489. </if>
  1490. <if test="endDate != null and endDate != ''">
  1491. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1492. </if>
  1493. </if>
  1494. <if test="isPlacefile != null and isPlacefile == 1">
  1495. <if test="startDate != null and startDate != ''">
  1496. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1497. </if>
  1498. <if test="endDate != null and endDate != ''">
  1499. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1500. </if>
  1501. </if>
  1502. </select>
  1503. <!-- 入院人数统计-首页 -->
  1504. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  1505. resultType="com.diagbot.dto.NumDTO">
  1506. SELECT
  1507. a.beh_dept_id AS id,
  1508. a.beh_dept_name AS NAME,
  1509. COUNT(*) AS num
  1510. FROM
  1511. med_behospital_info a
  1512. WHERE
  1513. a.is_deleted = 'N'
  1514. <if test="isPlacefile != null and isPlacefile != ''">
  1515. and a.is_placefile = #{isPlacefile}
  1516. </if>
  1517. <if test="hospitalId != null and hospitalId != ''">
  1518. AND a.hospital_id = #{hospitalId}
  1519. </if>
  1520. <if test="isPlacefile != null and isPlacefile == 0">
  1521. <if test="startDate != null and startDate != ''">
  1522. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1523. </if>
  1524. <if test="endDate != null and endDate != ''">
  1525. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1526. </if>
  1527. </if>
  1528. <if test="isPlacefile != null and isPlacefile == 1">
  1529. <if test="startDate != null and startDate != ''">
  1530. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1531. </if>
  1532. <if test="endDate != null and endDate != ''">
  1533. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1534. </if>
  1535. </if>
  1536. GROUP BY
  1537. a.beh_dept_id,
  1538. a.beh_dept_name
  1539. </select>
  1540. <!-- 出院总人数统计-科室-首页 -->
  1541. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1542. resultType="com.diagbot.dto.NumDTO">
  1543. SELECT
  1544. a.beh_dept_id AS id,
  1545. a.beh_dept_name AS NAME,
  1546. COUNT(*) AS num
  1547. FROM
  1548. med_behospital_info a,
  1549. sys_user_dept c
  1550. WHERE
  1551. a.is_deleted = 'N'
  1552. AND c.is_deleted = 'N'
  1553. AND a.hospital_id = c.hospital_id
  1554. AND a.beh_dept_id = c.dept_id
  1555. <if test="isPlacefile != null and isPlacefile != ''">
  1556. and a.is_placefile = #{isPlacefile}
  1557. </if>
  1558. <if test="userId!=null">
  1559. AND c.user_id = #{userId}
  1560. </if>
  1561. <if test="hospitalId != null and hospitalId != ''">
  1562. AND a.hospital_id = #{hospitalId}
  1563. </if>
  1564. <if test="isPlacefile != null and isPlacefile == 0">
  1565. <if test="startDate != null and startDate != ''">
  1566. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1567. </if>
  1568. <if test="endDate != null and endDate != ''">
  1569. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1570. </if>
  1571. </if>
  1572. <if test="isPlacefile != null and isPlacefile == 1">
  1573. <if test="startDate != null and startDate != ''">
  1574. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1575. </if>
  1576. <if test="endDate != null and endDate != ''">
  1577. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1578. </if>
  1579. </if>
  1580. GROUP BY
  1581. a.beh_dept_id,
  1582. a.beh_dept_name
  1583. </select>
  1584. <!-- 入院总人数统计-科室-首页 -->
  1585. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1586. resultType="com.diagbot.dto.AdmissionCountDTO">
  1587. SELECT
  1588. a.beh_dept_id as deptId,
  1589. a.beh_dept_name as deptName,
  1590. a.doctor_id as doctorId,
  1591. a.doctor_name as doctorName,
  1592. COUNT(*) AS num
  1593. FROM
  1594. med_behospital_info a,
  1595. sys_user_dept c
  1596. WHERE
  1597. a.is_deleted = 'N'
  1598. AND c.is_deleted = 'N'
  1599. AND a.hospital_id = c.hospital_id
  1600. AND a.beh_dept_id = c.dept_id
  1601. <if test="isPlacefile != null and isPlacefile != ''">
  1602. and a.is_placefile = #{isPlacefile}
  1603. </if>
  1604. <if test="userId!=null">
  1605. AND c.user_id = #{userId}
  1606. </if>
  1607. <if test="hospitalId != null and hospitalId != ''">
  1608. AND a.hospital_id = #{hospitalId}
  1609. </if>
  1610. <if test="isPlacefile != null and isPlacefile == 0">
  1611. <if test="startDate != null and startDate != ''">
  1612. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1613. </if>
  1614. <if test="endDate != null and endDate != ''">
  1615. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1616. </if>
  1617. </if>
  1618. <if test="isPlacefile != null and isPlacefile == 1">
  1619. <if test="startDate != null and startDate != ''">
  1620. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1621. </if>
  1622. <if test="endDate != null and endDate != ''">
  1623. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1624. </if>
  1625. </if>
  1626. GROUP BY
  1627. a.beh_dept_id,
  1628. a.beh_dept_name,
  1629. a.doctor_id,
  1630. a.doctor_name
  1631. </select>
  1632. <!-- 新生儿出院人数统计-科室-首页 -->
  1633. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1634. resultType="com.diagbot.dto.NumDTO">
  1635. SELECT
  1636. a.beh_dept_id AS id,
  1637. a.beh_dept_name AS NAME,
  1638. COUNT(*) AS num
  1639. FROM
  1640. med_behospital_info a,
  1641. med_home_page b,
  1642. sys_user_dept c
  1643. WHERE
  1644. a.is_deleted = 'N'
  1645. AND b.is_deleted = 'N'
  1646. AND c.is_deleted = 'N'
  1647. AND a.hospital_id = b.hospital_id
  1648. AND a.hospital_id = c.hospital_id
  1649. AND a.behospital_code = b.behospital_code
  1650. AND a.beh_dept_id = c.dept_id
  1651. AND (
  1652. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  1653. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1654. )
  1655. <if test="isPlacefile != null and isPlacefile != ''">
  1656. and a.is_placefile = #{isPlacefile}
  1657. </if>
  1658. <![CDATA[AND a.qc_type_id <>0 ]]>
  1659. <if test="userId!=null">
  1660. AND c.user_id = #{userId}
  1661. </if>
  1662. <if test="hospitalId != null and hospitalId != ''">
  1663. AND a.hospital_id = #{hospitalId}
  1664. </if>
  1665. <if test="isPlacefile != null and isPlacefile == 0">
  1666. <if test="startDate != null and startDate != ''">
  1667. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1668. </if>
  1669. <if test="endDate != null and endDate != ''">
  1670. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1671. </if>
  1672. </if>
  1673. <if test="isPlacefile != null and isPlacefile == 1">
  1674. <if test="startDate != null and startDate != ''">
  1675. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1676. </if>
  1677. <if test="endDate != null and endDate != ''">
  1678. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1679. </if>
  1680. </if>
  1681. GROUP BY
  1682. a.beh_dept_id,
  1683. a.beh_dept_name
  1684. </select>
  1685. <!-- 死亡人数统计-科室-首页 -->
  1686. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1687. resultType="com.diagbot.dto.NumDTO">
  1688. SELECT
  1689. a.beh_dept_id AS id,
  1690. a.beh_dept_name AS NAME,
  1691. COUNT(*) AS num
  1692. FROM
  1693. med_behospital_info a,
  1694. sys_user_dept c,
  1695. med_medical_record d,
  1696. med_medical_record_content e
  1697. WHERE
  1698. a.is_deleted = 'N'
  1699. AND c.is_deleted = 'N'
  1700. AND d.is_deleted = 'N'
  1701. AND e.is_deleted = 'N'
  1702. AND a.hospital_id = c.hospital_id
  1703. AND a.hospital_id = d.hospital_id
  1704. AND a.hospital_id = e.hospital_id
  1705. AND a.behospital_code = d.behospital_code
  1706. AND a.beh_dept_id = c.dept_id
  1707. AND d.rec_id = e.rec_id
  1708. AND d.mode_id = '24'
  1709. <if test="isPlacefile != null and isPlacefile != ''">
  1710. and a.is_placefile = #{isPlacefile}
  1711. </if>
  1712. <![CDATA[AND a.qc_type_id <>0 ]]>
  1713. <if test="userId!=null">
  1714. AND c.user_id = #{userId}
  1715. </if>
  1716. <if test="hospitalId != null and hospitalId != ''">
  1717. AND a.hospital_id = #{hospitalId}
  1718. </if>
  1719. <if test="isPlacefile != null and isPlacefile == 0">
  1720. <if test="startDate != null and startDate != ''">
  1721. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1722. </if>
  1723. <if test="endDate != null and endDate != ''">
  1724. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1725. </if>
  1726. </if>
  1727. <if test="isPlacefile != null and isPlacefile == 1">
  1728. <if test="startDate != null and startDate != ''">
  1729. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1730. </if>
  1731. <if test="endDate != null and endDate != ''">
  1732. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1733. </if>
  1734. </if>
  1735. GROUP BY
  1736. a.beh_dept_id,
  1737. a.beh_dept_name
  1738. </select>
  1739. <!-- 手术人数统计-科室-首页 -->
  1740. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1741. resultType="com.diagbot.dto.NumDTO">
  1742. SELECT
  1743. a.beh_dept_id AS id,
  1744. a.beh_dept_name AS NAME,
  1745. COUNT( DISTINCT a.behospital_code ) AS num
  1746. FROM
  1747. med_behospital_info a,
  1748. sys_user_dept c,
  1749. med_medical_record d,
  1750. qc_mode e
  1751. WHERE
  1752. a.is_deleted = 'N'
  1753. AND c.is_deleted = 'N'
  1754. AND d.is_deleted = 'N'
  1755. AND e.is_deleted = 'N'
  1756. AND a.hospital_id = c.hospital_id
  1757. AND a.hospital_id = d.hospital_id
  1758. AND a.behospital_code = d.behospital_code
  1759. AND a.beh_dept_id = c.dept_id
  1760. AND d.mode_id = e.id
  1761. AND e.`name` = '手术记录'
  1762. <if test="isPlacefile != null and isPlacefile != ''">
  1763. and a.is_placefile = #{isPlacefile}
  1764. </if>
  1765. <![CDATA[AND a.qc_type_id <>0 ]]>
  1766. <if test="userId!=null">
  1767. AND c.user_id = #{userId}
  1768. </if>
  1769. <if test="hospitalId != null and hospitalId != ''">
  1770. AND a.hospital_id = #{hospitalId}
  1771. </if>
  1772. <if test="isPlacefile != null and isPlacefile == 0">
  1773. <if test="startDate != null and startDate != ''">
  1774. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1775. </if>
  1776. <if test="endDate != null and endDate != ''">
  1777. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1778. </if>
  1779. </if>
  1780. <if test="isPlacefile != null and isPlacefile == 1">
  1781. <if test="startDate != null and startDate != ''">
  1782. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1783. </if>
  1784. <if test="endDate != null and endDate != ''">
  1785. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1786. </if>
  1787. </if>
  1788. GROUP BY
  1789. a.beh_dept_id,
  1790. a.beh_dept_name
  1791. </select>
  1792. <!-- 各科室缺陷占比排行(分页) -->
  1793. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1794. SELECT t.*
  1795. FROM
  1796. (SELECT
  1797. t1.beh_dept_name AS NAME,
  1798. t1.num AS num,
  1799. t2.totle AS totleNum,
  1800. round( t1.num / t2.totle, 4 ) AS percent,
  1801. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1802. FROM
  1803. (
  1804. SELECT
  1805. a.beh_dept_id,
  1806. a.beh_dept_name,
  1807. count(*) AS num
  1808. FROM
  1809. med_behospital_info a,
  1810. med_qcresult_info c,
  1811. med_qcresult_detail d
  1812. WHERE
  1813. a.behospital_code = c.behospital_code
  1814. AND a.hospital_id = c.hospital_id
  1815. AND a.behospital_code = d.behospital_code
  1816. AND a.hospital_id = d.hospital_id
  1817. AND a.is_deleted = 'N'
  1818. AND c.is_deleted = 'N'
  1819. AND d.is_deleted = 'N'
  1820. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1821. and a.is_placefile = #{filterPageVO.isPlacefile}
  1822. </if>
  1823. <![CDATA[AND a.qc_type_id <>0 ]]>
  1824. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1825. AND a.hospital_id = #{filterPageVO.hospitalId}
  1826. </if>
  1827. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1828. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1829. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1830. </if>
  1831. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1832. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1833. </if>
  1834. </if>
  1835. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1836. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1837. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1838. </if>
  1839. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1840. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1841. </if>
  1842. </if>
  1843. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1844. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1845. </if>
  1846. GROUP BY
  1847. a.beh_dept_id,
  1848. a.beh_dept_name
  1849. ORDER BY
  1850. count(*) DESC
  1851. ) t1,
  1852. (
  1853. SELECT
  1854. count(*) AS totle
  1855. FROM
  1856. med_behospital_info a,
  1857. med_qcresult_info c,
  1858. med_qcresult_detail d
  1859. WHERE
  1860. a.behospital_code = c.behospital_code
  1861. AND a.hospital_id = c.hospital_id
  1862. AND a.behospital_code = d.behospital_code
  1863. AND a.hospital_id = d.hospital_id
  1864. AND a.is_deleted = 'N'
  1865. AND c.is_deleted = 'N'
  1866. AND d.is_deleted = 'N'
  1867. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1868. and a.is_placefile = #{filterPageVO.isPlacefile}
  1869. </if>
  1870. <![CDATA[AND a.qc_type_id <>0 ]]>
  1871. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1872. AND a.hospital_id = #{filterPageVO.hospitalId}
  1873. </if>
  1874. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1875. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1876. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1877. </if>
  1878. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1879. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1880. </if>
  1881. </if>
  1882. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1883. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1884. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1885. </if>
  1886. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1887. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1888. </if>
  1889. </if>
  1890. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1891. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1892. </if>
  1893. ) t2
  1894. )t
  1895. </select>
  1896. <!-- 科室缺陷占比(主任医生) -->
  1897. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  1898. SELECT
  1899. t.*
  1900. FROM
  1901. (
  1902. SELECT
  1903. t1.NAME,
  1904. t1.num AS num,
  1905. t2.totle AS totleNum,
  1906. round( t1.num / t2.totle, 4 ) AS percent,
  1907. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1908. FROM
  1909. (
  1910. SELECT
  1911. d.msg as name,
  1912. count(*) AS num
  1913. FROM
  1914. med_behospital_info a,
  1915. med_qcresult_info c,
  1916. med_qcresult_detail d,
  1917. sys_user_dept e
  1918. WHERE
  1919. a.behospital_code = c.behospital_code
  1920. AND a.hospital_id = c.hospital_id
  1921. AND a.behospital_code = d.behospital_code
  1922. AND a.hospital_id = d.hospital_id
  1923. AND a.is_deleted = 'N'
  1924. AND c.is_deleted = 'N'
  1925. AND d.is_deleted = 'N'
  1926. AND e.is_deleted = 'N'
  1927. AND a.beh_dept_id = e.dept_id
  1928. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1929. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1930. </if>
  1931. <![CDATA[AND a.qc_type_id <>0 ]]>
  1932. <if test="filterPageByDeptVO.userId!=null">
  1933. AND e.user_id = #{filterPageByDeptVO.userId}
  1934. </if>
  1935. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1936. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1937. </if>
  1938. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1939. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1940. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1941. </if>
  1942. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1943. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1944. </if>
  1945. </if>
  1946. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1947. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1948. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1949. </if>
  1950. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1951. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1952. </if>
  1953. </if>
  1954. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1955. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1956. </if>
  1957. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1958. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1959. </if>
  1960. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1961. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1962. </if>
  1963. GROUP BY
  1964. d.msg
  1965. ORDER BY
  1966. count(*) DESC
  1967. ) t1,
  1968. (
  1969. SELECT
  1970. count(*) AS totle
  1971. FROM
  1972. med_behospital_info a,
  1973. med_qcresult_info c,
  1974. med_qcresult_detail d,
  1975. sys_user_dept e
  1976. WHERE
  1977. a.behospital_code = c.behospital_code
  1978. AND a.hospital_id = c.hospital_id
  1979. AND a.behospital_code = d.behospital_code
  1980. AND a.hospital_id = d.hospital_id
  1981. AND a.is_deleted = 'N'
  1982. AND c.is_deleted = 'N'
  1983. AND d.is_deleted = 'N'
  1984. AND e.is_deleted = 'N'
  1985. AND a.beh_dept_id = e.dept_id
  1986. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1987. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1988. </if>
  1989. <![CDATA[AND a.qc_type_id <>0 ]]>
  1990. <if test="filterPageByDeptVO.userId!=null">
  1991. AND e.user_id = #{filterPageByDeptVO.userId}
  1992. </if>
  1993. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1994. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1995. </if>
  1996. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1997. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1998. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1999. </if>
  2000. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2001. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  2002. </if>
  2003. </if>
  2004. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  2005. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2006. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  2007. </if>
  2008. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2009. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  2010. </if>
  2011. </if>
  2012. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  2013. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  2014. </if>
  2015. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  2016. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  2017. </if>
  2018. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  2019. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  2020. </if>
  2021. ) t2
  2022. )t
  2023. </select>
  2024. <!-- 各科室缺陷占比(组合)-全院 -->
  2025. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2026. resultType="com.diagbot.dto.LevelStatisticsDTO">
  2027. SELECT
  2028. m1.deptId,
  2029. m1.deptName,
  2030. m1.entryNum,
  2031. m2.sameNum,
  2032. m1.mrNum,
  2033. m2.sameMrNum,
  2034. m1.totleValue,
  2035. m2.sameTotleValue,
  2036. m1.averageValue,
  2037. m2.sameAvgValue,
  2038. m1.firstLevelNum,
  2039. m2.sameFirstLevelNum,
  2040. m1.secondLevelNum,
  2041. m2.sameSecondLevelNum,
  2042. m1.thirdLevelNum,
  2043. m2.sameThirdLevelNum,
  2044. m1.firstLevelPercent,
  2045. m2.sameFirstLevelPercent,
  2046. m1.secondLevelPercent,
  2047. m2.sameSecondLevelPercent,
  2048. m1.thirdLevelPercent,
  2049. m2.sameThirdLevelPercent,
  2050. m1.firstLevelPercentStr,
  2051. m2.sameFirstLevelPercentStr,
  2052. m1.secondLevelPercentStr,
  2053. m2.sameSecondLevelPercentStr,
  2054. m1.thirdLevelPercentStr,
  2055. m2.sameThirdLevelPercentStr
  2056. FROM
  2057. (
  2058. SELECT
  2059. t1.deptId,
  2060. t1.deptName,
  2061. t2.entryNum,
  2062. t1.mrNum,
  2063. t1.totleValue,
  2064. t1.averageValue,
  2065. t1.firstLevelNum,
  2066. t1.secondLevelNum,
  2067. t1.thirdLevelNum,
  2068. t1.firstLevelPercent,
  2069. t1.secondLevelPercent,
  2070. t1.thirdLevelPercent,
  2071. t1.firstLevelPercentStr,
  2072. t1.secondLevelPercentStr,
  2073. t1.thirdLevelPercentStr
  2074. FROM
  2075. (
  2076. SELECT
  2077. a.beh_dept_id AS deptId,
  2078. a.beh_dept_name AS deptName,
  2079. count(*) AS mrNum,
  2080. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2081. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2082. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2083. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2084. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2085. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2086. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2087. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2088. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2089. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2090. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2091. FROM
  2092. med_behospital_info a,
  2093. med_qcresult_info c
  2094. WHERE
  2095. a.is_deleted = 'N'
  2096. AND c.is_deleted = 'N'
  2097. AND a.hospital_id = c.hospital_id
  2098. AND a.behospital_code = c.behospital_code
  2099. <if test="isPlacefile != null and isPlacefile != ''">
  2100. and a.is_placefile = #{isPlacefile}
  2101. </if>
  2102. AND a.qc_type_id != 0
  2103. <if test="hospitalId != null and hospitalId != ''">
  2104. AND a.hospital_id = #{hospitalId}
  2105. </if>
  2106. <if test="isPlacefile != null and isPlacefile == 0">
  2107. <if test="startDate != null and startDate != ''">
  2108. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2109. </if>
  2110. <if test="endDate != null and endDate != ''">
  2111. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2112. </if>
  2113. </if>
  2114. <if test="isPlacefile != null and isPlacefile == 1">
  2115. <if test="startDate != null and startDate != ''">
  2116. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2117. </if>
  2118. <if test="endDate != null and endDate != ''">
  2119. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2120. </if>
  2121. </if>
  2122. <if test="level != null and level != ''">
  2123. and c.level = #{level}
  2124. </if>
  2125. <if test="deptName != null and deptName != ''">
  2126. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2127. </if>
  2128. GROUP BY
  2129. a.beh_dept_id,
  2130. a.beh_dept_name
  2131. ) t1,
  2132. (
  2133. SELECT
  2134. a.beh_dept_id AS deptId,
  2135. a.beh_dept_name AS deptName,
  2136. count( * ) AS entryNum
  2137. FROM
  2138. med_behospital_info a,
  2139. med_qcresult_info c,
  2140. med_qcresult_detail d,
  2141. qc_cases_entry e
  2142. WHERE
  2143. a.is_deleted = 'N'
  2144. AND c.is_deleted = 'N'
  2145. AND d.is_deleted = 'N'
  2146. AND e.is_deleted = 'N'
  2147. AND a.hospital_id = c.hospital_id
  2148. AND a.hospital_id = d.hospital_id
  2149. AND a.behospital_code = c.behospital_code
  2150. AND a.behospital_code = d.behospital_code
  2151. AND d.cases_id = e.cases_id
  2152. AND d.cases_entry_id = e.id
  2153. <if test="isPlacefile != null and isPlacefile != ''">
  2154. and a.is_placefile = #{isPlacefile}
  2155. </if>
  2156. AND a.qc_type_id != 0
  2157. <if test="hospitalId != null and hospitalId != ''">
  2158. AND a.hospital_id = #{hospitalId}
  2159. </if>
  2160. <if test="isPlacefile != null and isPlacefile == 0">
  2161. <if test="startDate != null and startDate != ''">
  2162. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2163. </if>
  2164. <if test="endDate != null and endDate != ''">
  2165. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2166. </if>
  2167. </if>
  2168. <if test="isPlacefile != null and isPlacefile == 1">
  2169. <if test="startDate != null and startDate != ''">
  2170. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2171. </if>
  2172. <if test="endDate != null and endDate != ''">
  2173. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2174. </if>
  2175. </if>
  2176. <if test="level != null and level != ''">
  2177. and c.level = #{level}
  2178. </if>
  2179. <if test="deptName != null and deptName != ''">
  2180. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2181. </if>
  2182. GROUP BY
  2183. a.beh_dept_id,
  2184. a.beh_dept_name
  2185. ) t2
  2186. WHERE
  2187. t1.deptId = t2.deptId
  2188. AND t1.deptName = t2.deptName)m1 left join
  2189. ( SELECT
  2190. t1.deptId,
  2191. t1.deptName,
  2192. t2.entryNum as sameNum,
  2193. t1.mrNum as sameMrNum,
  2194. t1.totleValue as sameTotleValue,
  2195. t1.averageValue as sameAvgValue,
  2196. t1.firstLevelNum as sameFirstLevelNum,
  2197. t1.secondLevelNum as sameSecondLevelNum,
  2198. t1.thirdLevelNum as sameThirdLevelNum,
  2199. t1.firstLevelPercent as sameFirstLevelPercent,
  2200. t1.secondLevelPercent as sameSecondLevelPercent,
  2201. t1.thirdLevelPercent as sameThirdLevelPercent,
  2202. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2203. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2204. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2205. FROM
  2206. (
  2207. SELECT
  2208. a.beh_dept_id AS deptId,
  2209. a.beh_dept_name AS deptName,
  2210. count(*) AS mrNum,
  2211. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2212. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2213. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2214. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2215. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2216. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2217. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2218. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2219. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2220. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2221. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2222. FROM
  2223. med_behospital_info a,
  2224. med_qcresult_info c
  2225. WHERE
  2226. a.is_deleted = 'N'
  2227. AND c.is_deleted = 'N'
  2228. AND a.hospital_id = c.hospital_id
  2229. AND a.behospital_code = c.behospital_code
  2230. <if test="isPlacefile != null and isPlacefile != ''">
  2231. and a.is_placefile = #{isPlacefile}
  2232. </if>
  2233. AND a.qc_type_id != 0
  2234. <if test="hospitalId != null and hospitalId != ''">
  2235. AND a.hospital_id = #{hospitalId}
  2236. </if>
  2237. <if test="isPlacefile != null and isPlacefile == 0">
  2238. <if test="lastStartDate != null and lastStartDate != ''">
  2239. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2240. </if>
  2241. <if test="lastEndDate != null and lastEndDate != ''">
  2242. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2243. </if>
  2244. </if>
  2245. <if test="isPlacefile != null and isPlacefile == 1">
  2246. <if test="lastStartDate != null and lastStartDate != ''">
  2247. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2248. </if>
  2249. <if test="lastEndDate != null and lastEndDate != ''">
  2250. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2251. </if>
  2252. </if>
  2253. <if test="level != null and level != ''">
  2254. and c.level = #{level}
  2255. </if>
  2256. <if test="deptName != null and deptName != ''">
  2257. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2258. </if>
  2259. GROUP BY
  2260. a.beh_dept_id,
  2261. a.beh_dept_name
  2262. ) t1,
  2263. (
  2264. SELECT
  2265. a.beh_dept_id AS deptId,
  2266. a.beh_dept_name AS deptName,
  2267. count( * ) AS entryNum
  2268. FROM
  2269. med_behospital_info a,
  2270. med_qcresult_info c,
  2271. med_qcresult_detail d,
  2272. qc_cases_entry e
  2273. WHERE
  2274. a.is_deleted = 'N'
  2275. AND c.is_deleted = 'N'
  2276. AND d.is_deleted = 'N'
  2277. AND e.is_deleted = 'N'
  2278. AND a.hospital_id = c.hospital_id
  2279. AND a.hospital_id = d.hospital_id
  2280. AND a.behospital_code = c.behospital_code
  2281. AND a.behospital_code = d.behospital_code
  2282. AND d.cases_id = e.cases_id
  2283. AND d.cases_entry_id = e.id
  2284. <if test="isPlacefile != null and isPlacefile != ''">
  2285. and a.is_placefile = #{isPlacefile}
  2286. </if>
  2287. AND a.qc_type_id != 0
  2288. <if test="hospitalId != null and hospitalId != ''">
  2289. AND a.hospital_id = #{hospitalId}
  2290. </if>
  2291. <if test="isPlacefile != null and isPlacefile == 0">
  2292. <if test="lastStartDate != null and lastStartDate != ''">
  2293. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2294. </if>
  2295. <if test="lastEndDate != null and lastEndDate != ''">
  2296. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2297. </if>
  2298. </if>
  2299. <if test="isPlacefile != null and isPlacefile == 1">
  2300. <if test="lastStartDate != null and lastStartDate != ''">
  2301. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2302. </if>
  2303. <if test="lastEndDate != null and lastEndDate != ''">
  2304. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2305. </if>
  2306. </if>
  2307. <if test="level != null and level != ''">
  2308. and c.level = #{level}
  2309. </if>
  2310. <if test="deptName != null and deptName != ''">
  2311. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2312. </if>
  2313. GROUP BY
  2314. a.beh_dept_id,
  2315. a.beh_dept_name
  2316. ) t2
  2317. WHERE
  2318. t1.deptId = t2.deptId
  2319. AND t1.deptName = t2.deptName)m2
  2320. on
  2321. m1.deptId = m2.deptId
  2322. AND m1.deptName = m2.deptName
  2323. <if test="asc != null and asc !=''">
  2324. order by
  2325. <choose>
  2326. <when test='asc=="deptId"'>m1.deptId asc</when>
  2327. <when test='asc=="deptName"'>m1.deptName asc</when>
  2328. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2329. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2330. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2331. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2332. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2333. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2334. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2335. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2336. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2337. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2338. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2339. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2340. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2341. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2342. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2343. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2344. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2345. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2346. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2347. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2348. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2349. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2350. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2351. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2352. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2353. <otherwise>deptName asc</otherwise>
  2354. </choose>
  2355. </if>
  2356. <if test="desc != null and desc!=''">
  2357. order by
  2358. <choose>
  2359. <when test='desc=="deptId"'>m1.deptId desc</when>
  2360. <when test='desc=="deptName"'>m1.deptName desc</when>
  2361. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2362. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2363. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2364. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2365. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2366. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2367. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2368. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2369. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2370. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2371. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2372. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2373. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2374. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2375. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2376. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2377. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2378. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2379. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2380. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2381. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2382. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2383. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2384. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2385. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2386. <otherwise>deptName desc</otherwise>
  2387. </choose>
  2388. </if>
  2389. </select>
  2390. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  2391. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  2392. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2393. SELECT
  2394. t1.deptId,
  2395. t1.deptName,
  2396. t1.deptClassId,
  2397. t1.deptClass,
  2398. t2.entryNum,
  2399. t1.mrNum,
  2400. t1.totleValue,
  2401. t1.averageValue,
  2402. t1.firstLevelNum,
  2403. t1.secondLevelNum,
  2404. t1.thirdLevelNum,
  2405. t1.firstLevelPercent,
  2406. t1.secondLevelPercent,
  2407. t1.thirdLevelPercent,
  2408. t1.firstLevelPercentStr,
  2409. t1.secondLevelPercentStr,
  2410. t1.thirdLevelPercentStr
  2411. FROM
  2412. (
  2413. SELECT
  2414. a.beh_dept_id AS deptId,
  2415. a.beh_dept_name AS deptName,
  2416. e.dept_id AS deptClassId,
  2417. e.dept_name AS deptClass,
  2418. count( DISTINCT c.id ) AS mrNum,
  2419. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2420. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  2421. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  2422. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  2423. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  2424. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  2425. ) AS firstLevelPercent,
  2426. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2427. ) AS secondLevelPercent,
  2428. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2429. ) AS thirdLevelPercent,
  2430. concat(
  2431. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  2432. 100, 2 ),
  2433. '%'
  2434. ) AS firstLevelPercentStr,
  2435. concat(
  2436. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  2437. 100, 2 ),
  2438. '%'
  2439. ) AS secondLevelPercentStr,
  2440. concat(
  2441. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  2442. 100, 2 ),
  2443. '%'
  2444. ) AS thirdLevelPercentStr
  2445. FROM
  2446. med_behospital_info a,
  2447. med_qcresult_info c,
  2448. bas_dept_info d,
  2449. bas_dept_info e
  2450. WHERE
  2451. a.is_deleted = 'N'
  2452. AND c.is_deleted = 'N'
  2453. AND d.is_deleted = 'N'
  2454. AND e.is_deleted = 'N'
  2455. AND a.hospital_id = c.hospital_id
  2456. AND a.hospital_id = d.hospital_id
  2457. AND a.hospital_id = e.hospital_id
  2458. AND a.behospital_code = c.behospital_code
  2459. AND a.beh_dept_id = d.dept_id
  2460. AND d.parent_dept_id = e.dept_id
  2461. <if test="isPlacefile != null and isPlacefile != ''">
  2462. and a.is_placefile = #{isPlacefile}
  2463. </if>
  2464. <![CDATA[AND a.qc_type_id <>0 ]]>
  2465. <if test="hospitalId != null and hospitalId != ''">
  2466. AND a.hospital_id = #{hospitalId}
  2467. </if>
  2468. <if test="isPlacefile != null and isPlacefile == 0">
  2469. <if test="startDate != null and startDate != ''">
  2470. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2471. </if>
  2472. <if test="endDate != null and endDate != ''">
  2473. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2474. </if>
  2475. </if>
  2476. <if test="isPlacefile != null and isPlacefile == 1">
  2477. <if test="startDate != null and startDate != ''">
  2478. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2479. </if>
  2480. <if test="endDate != null and endDate != ''">
  2481. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2482. </if>
  2483. </if>
  2484. <if test="level != null and level != ''">
  2485. and c.level = #{level}
  2486. </if>
  2487. <if test="deptName != null and deptName != ''">
  2488. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2489. </if>
  2490. <if test="deptClass != null and deptClass != ''">
  2491. and e.dept_name = #{deptClass}
  2492. </if>
  2493. GROUP BY
  2494. a.beh_dept_id,
  2495. a.beh_dept_name,
  2496. e.dept_id,
  2497. e.dept_name
  2498. ) t1,
  2499. (
  2500. SELECT
  2501. a.beh_dept_id AS deptId,
  2502. a.beh_dept_name AS deptName,
  2503. g.dept_id AS deptClassId,
  2504. g.dept_name AS deptClass,
  2505. count( * ) AS entryNum
  2506. FROM
  2507. med_behospital_info a,
  2508. med_qcresult_info c,
  2509. med_qcresult_detail d,
  2510. qc_cases_entry e,
  2511. bas_dept_info f,
  2512. bas_dept_info g
  2513. WHERE
  2514. a.is_deleted = 'N'
  2515. AND c.is_deleted = 'N'
  2516. AND d.is_deleted = 'N'
  2517. AND e.is_deleted = 'N'
  2518. AND f.is_deleted = 'N'
  2519. AND g.is_deleted = 'N'
  2520. AND a.hospital_id = c.hospital_id
  2521. AND a.hospital_id = d.hospital_id
  2522. AND a.hospital_id = f.hospital_id
  2523. AND a.hospital_id = g.hospital_id
  2524. AND a.behospital_code = c.behospital_code
  2525. AND a.behospital_code = d.behospital_code
  2526. AND d.cases_id = e.cases_id
  2527. AND d.cases_entry_id = e.id
  2528. AND a.beh_dept_id = f.dept_id
  2529. AND f.parent_dept_id = g.dept_id
  2530. <if test="isPlacefile != null and isPlacefile != ''">
  2531. and a.is_placefile = #{isPlacefile}
  2532. </if>
  2533. <![CDATA[AND a.qc_type_id <>0 ]]>
  2534. <if test="hospitalId != null and hospitalId != ''">
  2535. AND a.hospital_id = #{hospitalId}
  2536. </if>
  2537. <if test="isPlacefile != null and isPlacefile == 0">
  2538. <if test="startDate != null and startDate != ''">
  2539. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2540. </if>
  2541. <if test="endDate != null and endDate != ''">
  2542. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2543. </if>
  2544. </if>
  2545. <if test="isPlacefile != null and isPlacefile == 1">
  2546. <if test="startDate != null and startDate != ''">
  2547. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2548. </if>
  2549. <if test="endDate != null and endDate != ''">
  2550. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2551. </if>
  2552. </if>
  2553. <if test="level != null and level != ''">
  2554. and c.level = #{level}
  2555. </if>
  2556. <if test="deptName != null and deptName != ''">
  2557. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2558. </if>
  2559. <if test="deptClass != null and deptClass != ''">
  2560. and g.dept_name = #{deptClass}
  2561. </if>
  2562. GROUP BY
  2563. a.beh_dept_id,
  2564. a.beh_dept_name,
  2565. g.dept_id,
  2566. g.dept_name
  2567. ) t2
  2568. WHERE
  2569. t1.deptId = t2.deptId
  2570. AND t1.deptName = t2.deptName
  2571. AND t1.deptClassId = t2.deptClassId
  2572. AND t1.deptClass = t2.deptClass
  2573. <if test="asc != null and asc !=''">
  2574. order by
  2575. <choose>
  2576. <when test='asc=="deptId"'>deptId asc</when>
  2577. <when test='asc=="deptName"'>deptName asc</when>
  2578. <when test='asc=="deptClassId"'>deptClassId asc</when>
  2579. <when test='asc=="deptClass"'>deptClass asc</when>
  2580. <when test='asc=="entryNum"'>entryNum asc</when>
  2581. <when test='asc=="mrNum"'>mrNum asc</when>
  2582. <when test='asc=="totleValue"'>totleValue asc</when>
  2583. <when test='asc=="averageValue"'>averageValue asc</when>
  2584. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2585. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2586. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2587. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2588. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2589. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2590. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2591. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2592. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2593. <otherwise>deptName asc</otherwise>
  2594. </choose>
  2595. </if>
  2596. <if test="desc != null and desc!=''">
  2597. order by
  2598. <choose>
  2599. <when test='desc=="deptId"'>deptId desc</when>
  2600. <when test='desc=="deptName"'>deptName desc</when>
  2601. <when test='desc=="deptClassId"'>deptClassId desc</when>
  2602. <when test='desc=="deptClass"'>deptClass desc</when>
  2603. <when test='desc=="entryNum"'>entryNum desc</when>
  2604. <when test='desc=="mrNum"'>mrNum desc</when>
  2605. <when test='desc=="totleValue"'>totleValue desc</when>
  2606. <when test='desc=="averageValue"'>averageValue desc</when>
  2607. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2608. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2609. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2610. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2611. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2612. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2613. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2614. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2615. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2616. <otherwise>deptName desc</otherwise>
  2617. </choose>
  2618. </if>
  2619. </select>
  2620. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  2621. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2622. select
  2623. m1.deptId,
  2624. m1.deptName,
  2625. m1.deptClassId,
  2626. m1.deptClass,
  2627. m1.entryNum,
  2628. m2.sameNum,
  2629. m1.mrNum,
  2630. m2.sameMrNum,
  2631. m1.totleValue,
  2632. m2.sameTotleValue,
  2633. m1.averageValue,
  2634. m2.sameAvgValue,
  2635. m1.firstLevelNum,
  2636. m2.sameFirstLevelNum,
  2637. m1.secondLevelNum,
  2638. m2.sameSecondLevelNum,
  2639. m1.thirdLevelNum,
  2640. m2.sameThirdLevelNum,
  2641. m1.firstLevelPercent,
  2642. m2.sameFirstLevelPercent,
  2643. m1.secondLevelPercent,
  2644. m2.sameSecondLevelPercent,
  2645. m1.thirdLevelPercent,
  2646. m2.sameThirdLevelPercent,
  2647. m1.firstLevelPercentStr,
  2648. m2.sameFirstLevelPercentStr,
  2649. m1.secondLevelPercentStr,
  2650. m2.sameSecondLevelPercentStr,
  2651. m1.thirdLevelPercentStr,
  2652. m2.sameThirdLevelPercentStr
  2653. from (
  2654. SELECT
  2655. t1.deptId,
  2656. t1.deptName,
  2657. t1.deptClassId,
  2658. t1.deptClass,
  2659. t2.entryNum,
  2660. t1.mrNum,
  2661. t1.totleValue,
  2662. t1.averageValue,
  2663. t1.firstLevelNum,
  2664. t1.secondLevelNum,
  2665. t1.thirdLevelNum,
  2666. t1.firstLevelPercent,
  2667. t1.secondLevelPercent,
  2668. t1.thirdLevelPercent,
  2669. t1.firstLevelPercentStr,
  2670. t1.secondLevelPercentStr,
  2671. t1.thirdLevelPercentStr
  2672. FROM
  2673. (
  2674. SELECT
  2675. tt1.deptId,
  2676. tt1.deptName,
  2677. e.dept_id AS deptClassId,
  2678. e.dept_name AS deptClass,
  2679. count(*) AS mrNum,
  2680. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2681. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2682. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2683. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2684. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2685. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2686. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2687. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2688. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2689. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2690. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2691. FROM
  2692. (
  2693. SELECT
  2694. a.beh_dept_id AS deptId,
  2695. a.beh_dept_name AS deptName,
  2696. d.parent_dept_id AS parentDeptId,
  2697. a.hospital_id AS hospitalId,
  2698. a.behospital_code AS behospitalCode,
  2699. c.score_res AS score,
  2700. c.LEVEL
  2701. FROM
  2702. med_behospital_info a,
  2703. med_qcresult_info c,
  2704. bas_dept_info d
  2705. WHERE
  2706. a.is_deleted = 'N'
  2707. AND c.is_deleted = 'N'
  2708. AND d.is_deleted = 'N'
  2709. AND a.hospital_id = c.hospital_id
  2710. AND a.hospital_id = d.hospital_id
  2711. AND a.behospital_code = c.behospital_code
  2712. AND a.beh_dept_id = d.dept_id
  2713. <if test="isPlacefile != null and isPlacefile != ''">
  2714. and a.is_placefile = #{isPlacefile}
  2715. </if>
  2716. AND a.qc_type_id != 0
  2717. <if test="hospitalId != null and hospitalId != ''">
  2718. AND a.hospital_id = #{hospitalId}
  2719. </if>
  2720. <if test="isPlacefile != null and isPlacefile == 0">
  2721. <if test="startDate != null and startDate != ''">
  2722. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2723. </if>
  2724. <if test="endDate != null and endDate != ''">
  2725. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2726. </if>
  2727. </if>
  2728. <if test="isPlacefile != null and isPlacefile == 1">
  2729. <if test="startDate != null and startDate != ''">
  2730. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2731. </if>
  2732. <if test="endDate != null and endDate != ''">
  2733. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2734. </if>
  2735. </if>
  2736. <if test="level != null and level != ''">
  2737. and c.level = #{level}
  2738. </if>
  2739. <if test="deptName != null and deptName != ''">
  2740. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2741. </if>
  2742. ) tt1
  2743. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2744. AND e.is_deleted = 'N'
  2745. AND tt1.hospitalId = e.hospital_id
  2746. <if test="deptClass != null and deptClass != ''">
  2747. WHERE e.dept_name = #{deptClass}
  2748. </if>
  2749. GROUP BY
  2750. tt1.deptId,
  2751. tt1.deptName,
  2752. e.dept_id,
  2753. e.dept_name
  2754. ) t1,
  2755. (
  2756. SELECT
  2757. tt2.deptId,
  2758. tt2.deptName,
  2759. g.dept_id AS deptClassId,
  2760. g.dept_name AS deptClass,
  2761. count( * ) AS entryNum
  2762. FROM
  2763. (
  2764. SELECT
  2765. a.beh_dept_id AS deptId,
  2766. a.beh_dept_name AS deptName,
  2767. f.parent_dept_id AS parentDeptId,
  2768. a.hospital_id AS hospitalId,
  2769. a.behospital_code AS behospitalCode
  2770. FROM
  2771. med_behospital_info a,
  2772. med_qcresult_info c,
  2773. med_qcresult_detail d,
  2774. qc_cases_entry e,
  2775. bas_dept_info f
  2776. WHERE
  2777. a.is_deleted = 'N'
  2778. AND c.is_deleted = 'N'
  2779. AND d.is_deleted = 'N'
  2780. AND e.is_deleted = 'N'
  2781. AND f.is_deleted = 'N'
  2782. AND a.hospital_id = c.hospital_id
  2783. AND a.hospital_id = d.hospital_id
  2784. AND a.hospital_id = f.hospital_id
  2785. AND a.behospital_code = c.behospital_code
  2786. AND a.behospital_code = d.behospital_code
  2787. AND d.cases_id = e.cases_id
  2788. AND d.cases_entry_id = e.id
  2789. AND a.beh_dept_id = f.dept_id
  2790. <if test="isPlacefile != null and isPlacefile != ''">
  2791. and a.is_placefile = #{isPlacefile}
  2792. </if>
  2793. AND a.qc_type_id != 0
  2794. <if test="hospitalId != null and hospitalId != ''">
  2795. AND a.hospital_id = #{hospitalId}
  2796. </if>
  2797. <if test="isPlacefile != null and isPlacefile == 0">
  2798. <if test="startDate != null and startDate != ''">
  2799. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2800. </if>
  2801. <if test="endDate != null and endDate != ''">
  2802. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2803. </if>
  2804. </if>
  2805. <if test="isPlacefile != null and isPlacefile == 1">
  2806. <if test="startDate != null and startDate != ''">
  2807. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2808. </if>
  2809. <if test="endDate != null and endDate != ''">
  2810. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2811. </if>
  2812. </if>
  2813. <if test="level != null and level != ''">
  2814. and c.level = #{level}
  2815. </if>
  2816. <if test="deptName != null and deptName != ''">
  2817. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2818. </if>
  2819. ) tt2
  2820. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2821. AND g.is_deleted = 'N'
  2822. AND tt2.hospitalId = g.hospital_id
  2823. <if test="deptClass != null and deptClass != ''">
  2824. WHERE g.dept_name = #{deptClass}
  2825. </if>
  2826. GROUP BY
  2827. tt2.deptId,
  2828. tt2.deptName,
  2829. g.dept_id,
  2830. g.dept_name
  2831. ) t2
  2832. WHERE
  2833. t1.deptId = t2.deptId
  2834. AND t1.deptName = t2.deptName)m1 left join
  2835. ( SELECT
  2836. t1.deptId,
  2837. t1.deptName,
  2838. t1.deptClassId,
  2839. t1.deptClass,
  2840. t2.entryNum as sameNum,
  2841. t1.mrNum as sameMrNum,
  2842. t1.totleValue as sameTotleValue,
  2843. t1.averageValue as sameAvgValue,
  2844. t1.firstLevelNum as sameFirstLevelNum,
  2845. t1.secondLevelNum as sameSecondLevelNum,
  2846. t1.thirdLevelNum as sameThirdLevelNum,
  2847. t1.firstLevelPercent as sameFirstLevelPercent,
  2848. t1.secondLevelPercent as sameSecondLevelPercent,
  2849. t1.thirdLevelPercent as sameThirdLevelPercent,
  2850. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2851. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2852. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2853. FROM
  2854. (
  2855. SELECT
  2856. tt1.deptId,
  2857. tt1.deptName,
  2858. e.dept_id AS deptClassId,
  2859. e.dept_name AS deptClass,
  2860. count(*) AS mrNum,
  2861. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2862. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2863. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2864. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2865. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2866. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2867. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2868. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2869. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2870. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2871. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2872. FROM
  2873. (
  2874. SELECT
  2875. a.beh_dept_id AS deptId,
  2876. a.beh_dept_name AS deptName,
  2877. d.parent_dept_id AS parentDeptId,
  2878. a.hospital_id AS hospitalId,
  2879. a.behospital_code AS behospitalCode,
  2880. c.score_res AS score,
  2881. c.LEVEL
  2882. FROM
  2883. med_behospital_info a,
  2884. med_qcresult_info c,
  2885. bas_dept_info d
  2886. WHERE
  2887. a.is_deleted = 'N'
  2888. AND c.is_deleted = 'N'
  2889. AND d.is_deleted = 'N'
  2890. AND a.hospital_id = c.hospital_id
  2891. AND a.hospital_id = d.hospital_id
  2892. AND a.behospital_code = c.behospital_code
  2893. AND a.beh_dept_id = d.dept_id
  2894. <if test="isPlacefile != null and isPlacefile != ''">
  2895. and a.is_placefile = #{isPlacefile}
  2896. </if>
  2897. AND a.qc_type_id != 0
  2898. <if test="hospitalId != null and hospitalId != ''">
  2899. AND a.hospital_id = #{hospitalId}
  2900. </if>
  2901. <if test="isPlacefile != null and isPlacefile == 0">
  2902. <if test="lastStartDate != null and lastStartDate != ''">
  2903. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2904. </if>
  2905. <if test="lastEndDate != null and lastEndDate != ''">
  2906. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2907. </if>
  2908. </if>
  2909. <if test="isPlacefile != null and isPlacefile == 1">
  2910. <if test="lastStartDate != null and lastStartDate != ''">
  2911. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2912. </if>
  2913. <if test="lastEndDate != null and lastEndDate != ''">
  2914. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2915. </if>
  2916. </if>
  2917. <if test="level != null and level != ''">
  2918. and c.level = #{level}
  2919. </if>
  2920. <if test="deptName != null and deptName != ''">
  2921. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2922. </if>
  2923. ) tt1
  2924. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2925. AND e.is_deleted = 'N'
  2926. AND tt1.hospitalId = e.hospital_id
  2927. <if test="deptClass != null and deptClass != ''">
  2928. WHERE e.dept_name = #{deptClass}
  2929. </if>
  2930. GROUP BY
  2931. tt1.deptId,
  2932. tt1.deptName,
  2933. e.dept_id,
  2934. e.dept_name
  2935. ) t1,
  2936. (
  2937. SELECT
  2938. tt2.deptId,
  2939. tt2.deptName,
  2940. g.dept_id AS deptClassId,
  2941. g.dept_name AS deptClass,
  2942. count( * ) AS entryNum
  2943. FROM
  2944. (
  2945. SELECT
  2946. a.beh_dept_id AS deptId,
  2947. a.beh_dept_name AS deptName,
  2948. f.parent_dept_id AS parentDeptId,
  2949. a.hospital_id AS hospitalId,
  2950. a.behospital_code AS behospitalCode
  2951. FROM
  2952. med_behospital_info a,
  2953. med_qcresult_info c,
  2954. med_qcresult_detail d,
  2955. qc_cases_entry e,
  2956. bas_dept_info f
  2957. WHERE
  2958. a.is_deleted = 'N'
  2959. AND c.is_deleted = 'N'
  2960. AND d.is_deleted = 'N'
  2961. AND e.is_deleted = 'N'
  2962. AND f.is_deleted = 'N'
  2963. AND a.hospital_id = c.hospital_id
  2964. AND a.hospital_id = d.hospital_id
  2965. AND a.hospital_id = f.hospital_id
  2966. AND a.behospital_code = c.behospital_code
  2967. AND a.behospital_code = d.behospital_code
  2968. AND d.cases_id = e.cases_id
  2969. AND d.cases_entry_id = e.id
  2970. AND a.beh_dept_id = f.dept_id
  2971. <if test="isPlacefile != null and isPlacefile != ''">
  2972. and a.is_placefile = #{isPlacefile}
  2973. </if>
  2974. AND a.qc_type_id != 0
  2975. <if test="hospitalId != null and hospitalId != ''">
  2976. AND a.hospital_id = #{hospitalId}
  2977. </if>
  2978. <if test="isPlacefile != null and isPlacefile == 0">
  2979. <if test="lastStartDate != null and lastStartDate != ''">
  2980. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2981. </if>
  2982. <if test="lastEndDate != null and lastEndDate != ''">
  2983. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2984. </if>
  2985. </if>
  2986. <if test="isPlacefile != null and isPlacefile == 1">
  2987. <if test="lastStartDate != null and lastStartDate != ''">
  2988. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2989. </if>
  2990. <if test="lastEndDate != null and lastEndDate != ''">
  2991. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2992. </if>
  2993. </if>
  2994. <if test="level != null and level != ''">
  2995. and c.level = #{level}
  2996. </if>
  2997. <if test="deptName != null and deptName != ''">
  2998. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2999. </if>
  3000. ) tt2
  3001. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  3002. AND g.is_deleted = 'N'
  3003. AND tt2.hospitalId = g.hospital_id
  3004. <if test="deptClass != null and deptClass != ''">
  3005. WHERE g.dept_name = #{deptClass}
  3006. </if>
  3007. GROUP BY
  3008. tt2.deptId,
  3009. tt2.deptName,
  3010. g.dept_id,
  3011. g.dept_name
  3012. ) t2
  3013. WHERE
  3014. t1.deptId = t2.deptId
  3015. AND t1.deptName = t2.deptName)m2
  3016. on
  3017. m1.deptId = m2.deptId
  3018. and m1.deptName = m2.deptName
  3019. <if test="asc != null and asc !=''">
  3020. order by
  3021. <choose>
  3022. <when test='asc=="deptId"'>m1.deptId asc</when>
  3023. <when test='asc=="deptName"'>m1.deptName asc</when>
  3024. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  3025. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  3026. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3027. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3028. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3029. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3030. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3031. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3032. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3033. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3034. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3035. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3036. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3037. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3038. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3039. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3040. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3041. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3042. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3043. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3044. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3045. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3046. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3047. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3048. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3049. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3050. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3051. <otherwise>deptName asc</otherwise>
  3052. </choose>
  3053. </if>
  3054. <if test="desc != null and desc!=''">
  3055. order by
  3056. <choose>
  3057. <when test='desc=="deptId"'>m1.deptId desc</when>
  3058. <when test='desc=="deptName"'>m1.deptName desc</when>
  3059. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  3060. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  3061. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3062. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3063. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3064. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3065. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3066. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3067. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3068. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3069. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3070. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3071. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3072. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3073. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3074. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3075. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3076. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3077. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3078. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3079. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3080. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3081. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3082. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3083. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3084. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3085. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3086. <otherwise>deptName desc</otherwise>
  3087. </choose>
  3088. </if>
  3089. </select>
  3090. <!-- 病案首页合格率占比 -全院-->
  3091. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  3092. resultType="com.diagbot.dto.HomePageNumDTO">
  3093. SELECT
  3094. t1.deptId,
  3095. t1.deptName,
  3096. t2.entryNum,
  3097. t1.mrNum,
  3098. t1.totleValue,
  3099. t1.averageValue,
  3100. t1.firstLevelNum,
  3101. t1.secondLevelNum,
  3102. t1.firstLevelPercent,
  3103. t1.secondLevelPercent,
  3104. t1.firstLevelPercentStr,
  3105. t1.secondLevelPercentStr,
  3106. t3.emptyNum,
  3107. t3.errorNum,
  3108. t3.entryTotleNum,
  3109. t3.emptyPercent,
  3110. t3.errorPercent,
  3111. t3.emptyPercentStr,
  3112. t3.errorPercentStr
  3113. FROM
  3114. (
  3115. SELECT
  3116. a.beh_dept_id AS deptId,
  3117. a.beh_dept_name AS deptName,
  3118. count( * ) AS mrNum,
  3119. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3120. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3121. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3122. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3123. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3124. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3125. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3126. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3127. FROM
  3128. med_behospital_info a,
  3129. med_qcresult_cases c
  3130. WHERE
  3131. a.is_deleted = 'N'
  3132. AND c.is_deleted = 'N'
  3133. AND a.hospital_id = c.hospital_id
  3134. AND a.behospital_code = c.behospital_code
  3135. AND c.cases_id = 243
  3136. <if test="isPlacefile != null and isPlacefile != ''">
  3137. and a.is_placefile = #{isPlacefile}
  3138. </if>
  3139. AND a.qc_type_id != 0
  3140. <if test="hospitalId != null and hospitalId != ''">
  3141. AND a.hospital_id = #{hospitalId}
  3142. </if>
  3143. <if test="isPlacefile != null and isPlacefile == 0">
  3144. <if test="startDate != null and startDate != ''">
  3145. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3146. </if>
  3147. <if test="endDate != null and endDate != ''">
  3148. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3149. </if>
  3150. </if>
  3151. <if test="isPlacefile != null and isPlacefile == 1">
  3152. <if test="startDate != null and startDate != ''">
  3153. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3154. </if>
  3155. <if test="endDate != null and endDate != ''">
  3156. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3157. </if>
  3158. </if>
  3159. <if test="level != null and level != ''">
  3160. and c.level = #{level}
  3161. </if>
  3162. <if test="deptName != null and deptName != ''">
  3163. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3164. </if>
  3165. GROUP BY
  3166. a.beh_dept_id,
  3167. a.beh_dept_name
  3168. ) t1,
  3169. (
  3170. SELECT
  3171. a.beh_dept_id AS deptId,
  3172. a.beh_dept_name AS deptName,
  3173. count( * ) AS entryNum
  3174. FROM
  3175. med_behospital_info a,
  3176. med_qcresult_cases c,
  3177. med_qcresult_detail d,
  3178. qc_cases_entry e
  3179. WHERE
  3180. a.is_deleted = 'N'
  3181. AND c.is_deleted = 'N'
  3182. AND d.is_deleted = 'N'
  3183. AND e.is_deleted = 'N'
  3184. AND a.hospital_id = c.hospital_id
  3185. AND a.hospital_id = d.hospital_id
  3186. AND a.behospital_code = c.behospital_code
  3187. AND a.behospital_code = d.behospital_code
  3188. AND c.cases_id = d.cases_id
  3189. AND d.cases_id = e.cases_id
  3190. AND d.cases_entry_id = e.id
  3191. AND d.cases_id = 243
  3192. <if test="isPlacefile != null and isPlacefile != ''">
  3193. and a.is_placefile = #{isPlacefile}
  3194. </if>
  3195. AND a.qc_type_id != 0
  3196. <if test="hospitalId != null and hospitalId != ''">
  3197. AND a.hospital_id = #{hospitalId}
  3198. </if>
  3199. <if test="isPlacefile != null and isPlacefile == 0">
  3200. <if test="startDate != null and startDate != ''">
  3201. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3202. </if>
  3203. <if test="endDate != null and endDate != ''">
  3204. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3205. </if>
  3206. </if>
  3207. <if test="isPlacefile != null and isPlacefile == 1">
  3208. <if test="startDate != null and startDate != ''">
  3209. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3210. </if>
  3211. <if test="endDate != null and endDate != ''">
  3212. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3213. </if>
  3214. </if>
  3215. <if test="level != null and level != ''">
  3216. and c.level = #{level}
  3217. </if>
  3218. <if test="deptName != null and deptName != ''">
  3219. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3220. </if>
  3221. GROUP BY
  3222. a.beh_dept_id,
  3223. a.beh_dept_name
  3224. ) t2,(
  3225. SELECT
  3226. h1.deptId,
  3227. h1.deptName,
  3228. h1.emptyNum,
  3229. h1.errorNum,
  3230. h1.mrNum,
  3231. h2.entryNum,
  3232. h1.mrNum * h2.entryNum AS entryTotleNum,
  3233. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3234. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3235. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3236. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3237. FROM
  3238. (
  3239. SELECT
  3240. a.beh_dept_id AS deptId,
  3241. a.beh_dept_name AS deptName,
  3242. sum( d.rule_type = 1 ) AS emptyNum,
  3243. sum( d.rule_type = 2 ) AS errorNum,
  3244. count( DISTINCT a.behospital_code ) AS mrNum
  3245. FROM
  3246. med_behospital_info a,
  3247. med_qcresult_cases b,
  3248. med_qcresult_detail c,
  3249. qc_cases_entry d
  3250. WHERE
  3251. a.is_deleted = 'N'
  3252. AND b.is_deleted = 'N'
  3253. AND c.is_deleted = 'N'
  3254. AND d.is_deleted = 'N'
  3255. AND a.hospital_id = b.hospital_id
  3256. AND a.hospital_id = c.hospital_id
  3257. AND a.behospital_code = b.behospital_code
  3258. AND a.behospital_code = c.behospital_code
  3259. AND b.cases_id = c.cases_id
  3260. AND c.cases_id = d.cases_id
  3261. AND c.cases_entry_id = d.id
  3262. <if test="isPlacefile != null and isPlacefile != ''">
  3263. and a.is_placefile = #{isPlacefile}
  3264. </if>
  3265. AND d.cases_id = 243
  3266. AND a.qc_type_id != 0
  3267. <if test="hospitalId != null and hospitalId != ''">
  3268. AND a.hospital_id = #{hospitalId}
  3269. </if>
  3270. <if test="isPlacefile != null and isPlacefile == 0">
  3271. <if test="startDate != null and startDate != ''">
  3272. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3273. </if>
  3274. <if test="endDate != null and endDate != ''">
  3275. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3276. </if>
  3277. </if>
  3278. <if test="isPlacefile != null and isPlacefile == 1">
  3279. <if test="startDate != null and startDate != ''">
  3280. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3281. </if>
  3282. <if test="endDate != null and endDate != ''">
  3283. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3284. </if>
  3285. </if>
  3286. <if test="level != null and level != ''">
  3287. and b.level = #{level}
  3288. </if>
  3289. <if test="deptName != null and deptName != ''">
  3290. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3291. </if>
  3292. GROUP BY
  3293. a.beh_dept_id,
  3294. a.beh_dept_name
  3295. ) h1,(
  3296. SELECT
  3297. count(*) AS entryNum
  3298. FROM
  3299. qc_cases_entry
  3300. WHERE
  3301. is_deleted = 'N'
  3302. AND cases_id = 243
  3303. ) h2
  3304. ) t3
  3305. WHERE
  3306. t1.deptId = t2.deptId
  3307. AND t1.deptId = t3.deptId
  3308. AND t1.deptName = t2.deptName
  3309. AND t1.deptName = t3.deptName
  3310. <if test="asc != null and asc !=''">
  3311. order by
  3312. <choose>
  3313. <when test='asc=="deptId"'>deptId asc</when>
  3314. <when test='asc=="deptName"'>deptName asc</when>
  3315. <when test='asc=="entryNum"'>entryNum asc</when>
  3316. <when test='asc=="mrNum"'>mrNum asc</when>
  3317. <when test='asc=="totleValue"'>totleValue asc</when>
  3318. <when test='asc=="averageValue"'>averageValue asc</when>
  3319. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3320. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3321. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3322. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3323. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3324. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3325. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3326. <when test='asc=="errorNum"'>errorNum asc</when>
  3327. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3328. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3329. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3330. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3331. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3332. <otherwise>deptName asc</otherwise>
  3333. </choose>
  3334. </if>
  3335. <if test="desc != null and desc!=''">
  3336. order by
  3337. <choose>
  3338. <when test='desc=="deptId"'>deptId desc</when>
  3339. <when test='desc=="deptName"'>deptName desc</when>
  3340. <when test='desc=="entryNum"'>entryNum desc</when>
  3341. <when test='desc=="mrNum"'>mrNum desc</when>
  3342. <when test='desc=="totleValue"'>totleValue desc</when>
  3343. <when test='desc=="averageValue"'>averageValue desc</when>
  3344. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3345. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3346. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3347. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3348. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3349. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3350. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3351. <when test='desc=="errorNum"'>errorNum desc</when>
  3352. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3353. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3354. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3355. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3356. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3357. <otherwise>deptName desc</otherwise>
  3358. </choose>
  3359. </if>
  3360. </select>
  3361. <!-- 各科室缺陷占比-科室 -->
  3362. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3363. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3364. SELECT
  3365. m1.doctorId,
  3366. m1.doctorName,
  3367. m1.entryNum,
  3368. m2.sameNum,
  3369. m1.mrNum,
  3370. m2.sameMrNum,
  3371. m1.totleValue,
  3372. m2.sameTotleValue,
  3373. m1.averageValue,
  3374. m2.sameAvgValue,
  3375. m1.firstLevelNum,
  3376. m2.sameFirstLevelNum,
  3377. m1.secondLevelNum,
  3378. m2.sameSecondLevelNum,
  3379. m1.thirdLevelNum,
  3380. m2.sameThirdLevelNum,
  3381. m1.firstLevelPercent,
  3382. m2.sameFirstLevelPercent,
  3383. m1.secondLevelPercent,
  3384. m2.sameSecondLevelPercent,
  3385. m1.thirdLevelPercent,
  3386. m2.sameThirdLevelPercent,
  3387. m1.firstLevelPercentStr,
  3388. m2.sameFirstLevelPercentStr,
  3389. m1.secondLevelPercentStr,
  3390. m2.sameSecondLevelPercentStr,
  3391. m1.thirdLevelPercentStr,
  3392. m2.sameThirdLevelPercentStr
  3393. FROM
  3394. (
  3395. SELECT
  3396. t1.doctorId,
  3397. t1.doctorName,
  3398. t2.entryNum,
  3399. t1.mrNum,
  3400. t1.totleValue,
  3401. t1.averageValue,
  3402. t1.firstLevelNum,
  3403. t1.secondLevelNum,
  3404. t1.thirdLevelNum,
  3405. t1.firstLevelPercent,
  3406. t1.secondLevelPercent,
  3407. t1.thirdLevelPercent,
  3408. t1.firstLevelPercentStr,
  3409. t1.secondLevelPercentStr,
  3410. t1.thirdLevelPercentStr
  3411. FROM
  3412. (
  3413. SELECT
  3414. a.doctor_id AS doctorId,
  3415. a.doctor_name AS doctorName,
  3416. count(*) AS mrNum,
  3417. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3418. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3419. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3420. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3421. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3422. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3423. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3424. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3425. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3426. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3427. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3428. FROM
  3429. med_behospital_info a,
  3430. med_qcresult_info c,
  3431. sys_user_dept e
  3432. WHERE
  3433. a.is_deleted = 'N'
  3434. AND c.is_deleted = 'N'
  3435. AND e.is_deleted = 'N'
  3436. AND a.hospital_id = c.hospital_id
  3437. AND a.behospital_code = c.behospital_code
  3438. AND a.beh_dept_id = e.dept_id
  3439. <if test="isPlacefile != null and isPlacefile != ''">
  3440. and a.is_placefile = #{isPlacefile}
  3441. </if>
  3442. AND a.qc_type_id != 0
  3443. <if test="hospitalId != null and hospitalId != ''">
  3444. AND a.hospital_id = #{hospitalId}
  3445. </if>
  3446. <if test="isPlacefile != null and isPlacefile == 0">
  3447. <if test="startDate != null and startDate != ''">
  3448. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3449. </if>
  3450. <if test="endDate != null and endDate != ''">
  3451. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3452. </if>
  3453. </if>
  3454. <if test="isPlacefile != null and isPlacefile == 1">
  3455. <if test="startDate != null and startDate != ''">
  3456. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3457. </if>
  3458. <if test="endDate != null and endDate != ''">
  3459. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3460. </if>
  3461. </if>
  3462. <if test="level != null and level != ''">
  3463. and c.level = #{level}
  3464. </if>
  3465. <if test="doctorName != null and doctorName != ''">
  3466. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3467. </if>
  3468. <if test="userId!=null and userId !=''">
  3469. AND e.user_id = #{userId}
  3470. </if>
  3471. <if test="deptName != null and deptName != ''">
  3472. and a.beh_dept_name = #{deptName}
  3473. </if>
  3474. GROUP BY
  3475. a.doctor_id,
  3476. a.doctor_name
  3477. ) t1,
  3478. (
  3479. SELECT
  3480. a.doctor_id AS doctorId,
  3481. a.doctor_name AS doctorName,
  3482. count( * ) AS entryNum
  3483. FROM
  3484. med_behospital_info a,
  3485. med_qcresult_info c,
  3486. med_qcresult_detail d,
  3487. qc_cases_entry e,
  3488. sys_user_dept f
  3489. WHERE
  3490. a.is_deleted = 'N'
  3491. AND c.is_deleted = 'N'
  3492. AND d.is_deleted = 'N'
  3493. AND e.is_deleted = 'N'
  3494. AND f.is_deleted = 'N'
  3495. AND a.hospital_id = c.hospital_id
  3496. AND a.hospital_id = d.hospital_id
  3497. AND a.behospital_code = c.behospital_code
  3498. AND a.behospital_code = d.behospital_code
  3499. AND d.cases_id = e.cases_id
  3500. AND d.cases_entry_id = e.id
  3501. AND a.beh_dept_id = f.dept_id
  3502. <if test="isPlacefile != null and isPlacefile != ''">
  3503. and a.is_placefile = #{isPlacefile}
  3504. </if>
  3505. AND a.qc_type_id != 0
  3506. <if test="hospitalId != null and hospitalId != ''">
  3507. AND a.hospital_id = #{hospitalId}
  3508. </if>
  3509. <if test="isPlacefile != null and isPlacefile == 0">
  3510. <if test="startDate != null and startDate != ''">
  3511. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3512. </if>
  3513. <if test="endDate != null and endDate != ''">
  3514. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3515. </if>
  3516. </if>
  3517. <if test="isPlacefile != null and isPlacefile == 1">
  3518. <if test="startDate != null and startDate != ''">
  3519. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3520. </if>
  3521. <if test="endDate != null and endDate != ''">
  3522. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3523. </if>
  3524. </if>
  3525. <if test="level != null and level != ''">
  3526. and c.level = #{level}
  3527. </if>
  3528. <if test="doctorName != null and doctorName != ''">
  3529. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3530. </if>
  3531. <if test="userId!=null and userId !=''">
  3532. AND f.user_id = #{userId}
  3533. </if>
  3534. <if test="deptName != null and deptName != ''">
  3535. and a.beh_dept_name = #{deptName}
  3536. </if>
  3537. GROUP BY
  3538. a.doctor_id,
  3539. a.doctor_name
  3540. ) t2
  3541. WHERE
  3542. t1.doctorId = t2.doctorId
  3543. AND t1.doctorName = t2.doctorName
  3544. )m1 left join
  3545. ( SELECT
  3546. t1.doctorId,
  3547. t1.doctorName,
  3548. t2.entryNum as sameNum,
  3549. t1.mrNum as sameMrNum,
  3550. t1.totleValue as sameTotleValue,
  3551. t1.averageValue as sameAvgValue,
  3552. t1.firstLevelNum as sameFirstLevelNum,
  3553. t1.secondLevelNum as sameSecondLevelNum,
  3554. t1.thirdLevelNum as sameThirdLevelNum,
  3555. t1.firstLevelPercent as sameFirstLevelPercent,
  3556. t1.secondLevelPercent as sameSecondLevelPercent,
  3557. t1.thirdLevelPercent as sameThirdLevelPercent,
  3558. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3559. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3560. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3561. FROM
  3562. (
  3563. SELECT
  3564. a.doctor_id AS doctorId,
  3565. a.doctor_name AS doctorName,
  3566. count(*) AS mrNum,
  3567. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3568. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3569. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3570. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3571. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3572. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3573. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3574. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3575. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3576. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3577. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3578. FROM
  3579. med_behospital_info a,
  3580. med_qcresult_info c,
  3581. sys_user_dept e
  3582. WHERE
  3583. a.is_deleted = 'N'
  3584. AND c.is_deleted = 'N'
  3585. AND e.is_deleted = 'N'
  3586. AND a.hospital_id = c.hospital_id
  3587. AND a.behospital_code = c.behospital_code
  3588. AND a.beh_dept_id = e.dept_id
  3589. <if test="isPlacefile != null and isPlacefile != ''">
  3590. and a.is_placefile = #{isPlacefile}
  3591. </if>
  3592. AND a.qc_type_id != 0
  3593. <if test="hospitalId != null and hospitalId != ''">
  3594. AND a.hospital_id = #{hospitalId}
  3595. </if>
  3596. <if test="isPlacefile != null and isPlacefile == 0">
  3597. <if test="lastStartDate != null and lastStartDate != ''">
  3598. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3599. </if>
  3600. <if test="lastEndDate != null and lastEndDate != ''">
  3601. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3602. </if>
  3603. </if>
  3604. <if test="isPlacefile != null and isPlacefile == 1">
  3605. <if test="lastStartDate != null and lastStartDate != ''">
  3606. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3607. </if>
  3608. <if test="lastEndDate != null and lastEndDate != ''">
  3609. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3610. </if>
  3611. </if>
  3612. <if test="level != null and level != ''">
  3613. and c.level = #{level}
  3614. </if>
  3615. <if test="doctorName != null and doctorName != ''">
  3616. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3617. </if>
  3618. <if test="userId!=null and userId !=''">
  3619. AND e.user_id = #{userId}
  3620. </if>
  3621. <if test="deptName != null and deptName != ''">
  3622. and a.beh_dept_name = #{deptName}
  3623. </if>
  3624. GROUP BY
  3625. a.doctor_id,
  3626. a.doctor_name
  3627. ) t1,
  3628. (
  3629. SELECT
  3630. a.doctor_id AS doctorId,
  3631. a.doctor_name AS doctorName,
  3632. count( * ) AS entryNum
  3633. FROM
  3634. med_behospital_info a,
  3635. med_qcresult_info c,
  3636. med_qcresult_detail d,
  3637. qc_cases_entry e,
  3638. sys_user_dept f
  3639. WHERE
  3640. a.is_deleted = 'N'
  3641. AND c.is_deleted = 'N'
  3642. AND d.is_deleted = 'N'
  3643. AND e.is_deleted = 'N'
  3644. AND f.is_deleted = 'N'
  3645. AND a.hospital_id = c.hospital_id
  3646. AND a.hospital_id = d.hospital_id
  3647. AND a.behospital_code = c.behospital_code
  3648. AND a.behospital_code = d.behospital_code
  3649. AND d.cases_id = e.cases_id
  3650. AND d.cases_entry_id = e.id
  3651. AND a.beh_dept_id = f.dept_id
  3652. <if test="isPlacefile != null and isPlacefile != ''">
  3653. and a.is_placefile = #{isPlacefile}
  3654. </if>
  3655. AND a.qc_type_id != 0
  3656. <if test="hospitalId != null and hospitalId != ''">
  3657. AND a.hospital_id = #{hospitalId}
  3658. </if>
  3659. <if test="isPlacefile != null and isPlacefile == 0">
  3660. <if test="lastStartDate != null and lastStartDate != ''">
  3661. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3662. </if>
  3663. <if test="lastEndDate != null and lastEndDate != ''">
  3664. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3665. </if>
  3666. </if>
  3667. <if test="isPlacefile != null and isPlacefile == 1">
  3668. <if test="lastStartDate != null and lastStartDate != ''">
  3669. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3670. </if>
  3671. <if test="lastEndDate != null and lastEndDate != ''">
  3672. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3673. </if>
  3674. </if>
  3675. <if test="level != null and level != ''">
  3676. and c.level = #{level}
  3677. </if>
  3678. <if test="doctorName != null and doctorName != ''">
  3679. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3680. </if>
  3681. <if test="userId!=null and userId !=''">
  3682. AND f.user_id = #{userId}
  3683. </if>
  3684. <if test="deptName != null and deptName != ''">
  3685. and a.beh_dept_name = #{deptName}
  3686. </if>
  3687. GROUP BY
  3688. a.doctor_id,
  3689. a.doctor_name
  3690. ) t2
  3691. WHERE
  3692. t1.doctorId = t2.doctorId
  3693. AND t1.doctorName = t2.doctorName
  3694. )m2
  3695. on
  3696. m1.doctorId = m2.doctorId
  3697. AND m1.doctorName = m2.doctorName
  3698. <if test="asc != null and asc !=''">
  3699. order by
  3700. <choose>
  3701. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3702. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3703. <when test='asc=="name"'>m1.doctorName asc</when>
  3704. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3705. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3706. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3707. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3708. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3709. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3710. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3711. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3712. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3713. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3714. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3715. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3716. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3717. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3718. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3719. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3720. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3721. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3722. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3723. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3724. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3725. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3726. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3727. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3728. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3729. <otherwise>doctorName asc</otherwise>
  3730. </choose>
  3731. </if>
  3732. <if test="desc != null and desc!=''">
  3733. order by
  3734. <choose>
  3735. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3736. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3737. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3738. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3739. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3740. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3741. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3742. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3743. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3744. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3745. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3746. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3747. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3748. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3749. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3750. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3751. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3752. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3753. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3754. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3755. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3756. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3757. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3758. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3759. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3760. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3761. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3762. <otherwise>doctorName desc</otherwise>
  3763. </choose>
  3764. </if>
  3765. </select>
  3766. <!-- 病案首页合格率占比-科室 -->
  3767. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3768. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3769. SELECT
  3770. t1.doctorId,
  3771. t1.doctorName,
  3772. t2.entryNum,
  3773. t1.mrNum,
  3774. t1.totleValue,
  3775. t1.averageValue,
  3776. t1.firstLevelNum,
  3777. t1.secondLevelNum,
  3778. t1.firstLevelPercent,
  3779. t1.secondLevelPercent,
  3780. t1.firstLevelPercentStr,
  3781. t1.secondLevelPercentStr,
  3782. t3.emptyNum,
  3783. t3.errorNum,
  3784. t3.entryTotleNum,
  3785. t3.emptyPercent,
  3786. t3.errorPercent,
  3787. t3.emptyPercentStr,
  3788. t3.errorPercentStr
  3789. FROM
  3790. (
  3791. SELECT
  3792. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3793. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3794. count( * ) AS mrNum,
  3795. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3796. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3797. sum( c.`level` = '合格' ) AS firstLevelNum,
  3798. sum( c.`level` = '不合格' ) AS secondLevelNum,
  3799. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  3800. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3801. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3802. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3803. FROM
  3804. med_behospital_info a,
  3805. med_qcresult_cases c,
  3806. sys_user_dept f
  3807. WHERE
  3808. a.is_deleted = 'N'
  3809. AND c.is_deleted = 'N'
  3810. AND f.is_deleted = 'N'
  3811. AND a.hospital_id = c.hospital_id
  3812. AND a.behospital_code = c.behospital_code
  3813. AND a.beh_dept_id = f.dept_id
  3814. AND c.cases_id = 243
  3815. <if test="isPlacefile != null and isPlacefile != ''">
  3816. and a.is_placefile = #{isPlacefile}
  3817. </if>
  3818. <![CDATA[AND a.qc_type_id <>0 ]]>
  3819. <if test="hospitalId != null and hospitalId != ''">
  3820. AND a.hospital_id = #{hospitalId}
  3821. </if>
  3822. <if test="isPlacefile != null and isPlacefile == 0">
  3823. <if test="startDate != null and startDate != ''">
  3824. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3825. </if>
  3826. <if test="endDate != null and endDate != ''">
  3827. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3828. </if>
  3829. </if>
  3830. <if test="isPlacefile != null and isPlacefile == 1">
  3831. <if test="startDate != null and startDate != ''">
  3832. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3833. </if>
  3834. <if test="endDate != null and endDate != ''">
  3835. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3836. </if>
  3837. </if>
  3838. <if test="level != null and level != ''">
  3839. and c.level = #{level}
  3840. </if>
  3841. <if test="name != null and name != ''">
  3842. <if test="name == '未知'">
  3843. and (a.doctor_name is null or a.doctor_name='')
  3844. </if>
  3845. <if test="name != '未知'">
  3846. and a.doctor_name like CONCAT('%',#{name},'%')
  3847. </if>
  3848. </if>
  3849. <if test="userId!=null and userId !=''">
  3850. AND f.user_id = #{userId}
  3851. </if>
  3852. <if test="deptName!=null and deptName !=''">
  3853. AND a.beh_dept_name = #{deptName}
  3854. </if>
  3855. <if test="name != null and name != ''">
  3856. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3857. </if>
  3858. GROUP BY
  3859. a.doctor_id,
  3860. a.doctor_name
  3861. ) t1,
  3862. (
  3863. SELECT
  3864. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3865. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3866. count( * ) AS entryNum
  3867. FROM
  3868. med_behospital_info a,
  3869. med_qcresult_cases c,
  3870. med_qcresult_detail d,
  3871. qc_cases_entry e,
  3872. sys_user_dept f
  3873. WHERE
  3874. a.is_deleted = 'N'
  3875. AND c.is_deleted = 'N'
  3876. AND d.is_deleted = 'N'
  3877. AND e.is_deleted = 'N'
  3878. AND f.is_deleted = 'N'
  3879. AND a.hospital_id = c.hospital_id
  3880. AND a.hospital_id = d.hospital_id
  3881. AND a.behospital_code = c.behospital_code
  3882. AND a.behospital_code = d.behospital_code
  3883. AND a.beh_dept_id = f.dept_id
  3884. AND c.cases_id = d.cases_id
  3885. AND d.cases_id = e.cases_id
  3886. AND d.cases_entry_id = e.id
  3887. AND c.cases_id = 243
  3888. <if test="isPlacefile != null and isPlacefile != ''">
  3889. and a.is_placefile = #{isPlacefile}
  3890. </if>
  3891. <![CDATA[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 and startDate != ''">
  3897. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3898. </if>
  3899. <if test="endDate != null and endDate != ''">
  3900. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3901. </if>
  3902. </if>
  3903. <if test="isPlacefile != null and isPlacefile == 1">
  3904. <if test="startDate != null and startDate != ''">
  3905. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3906. </if>
  3907. <if test="endDate != null and endDate != ''">
  3908. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3909. </if>
  3910. </if>
  3911. <if test="level != null and level != ''">
  3912. and c.level = #{level}
  3913. </if>
  3914. <if test="name != null and name != ''">
  3915. <if test="name == '未知'">
  3916. and (a.doctor_name is null or a.doctor_name='')
  3917. </if>
  3918. <if test="name != '未知'">
  3919. and a.doctor_name like CONCAT('%',#{name},'%')
  3920. </if>
  3921. </if>
  3922. <if test="userId!=null and userId !=''">
  3923. AND f.user_id = #{userId}
  3924. </if>
  3925. <if test="deptName!=null and deptName !=''">
  3926. AND a.beh_dept_name = #{deptName}
  3927. </if>
  3928. <if test="name != null and name != ''">
  3929. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3930. </if>
  3931. GROUP BY
  3932. a.doctor_id,
  3933. a.doctor_name
  3934. ) t2,(
  3935. SELECT
  3936. h1.doctorId,
  3937. h1.doctorName,
  3938. h1.emptyNum,
  3939. h1.errorNum,
  3940. h1.mrNum,
  3941. h2.entryNum,
  3942. h1.mrNum * h2.entryNum AS entryTotleNum,
  3943. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3944. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3945. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3946. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3947. FROM
  3948. (
  3949. SELECT
  3950. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3951. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3952. sum( d.rule_type = 1 ) AS emptyNum,
  3953. sum( d.rule_type = 2 ) AS errorNum,
  3954. count( DISTINCT a.behospital_code ) AS mrNum
  3955. FROM
  3956. med_behospital_info a,
  3957. med_qcresult_cases b,
  3958. med_qcresult_detail c,
  3959. qc_cases_entry d,
  3960. sys_user_dept e
  3961. WHERE
  3962. a.is_deleted = 'N'
  3963. AND b.is_deleted = 'N'
  3964. AND c.is_deleted = 'N'
  3965. AND d.is_deleted = 'N'
  3966. AND e.is_deleted = 'N'
  3967. AND a.hospital_id = b.hospital_id
  3968. AND a.hospital_id = c.hospital_id
  3969. AND a.hospital_id = e.hospital_id
  3970. AND a.behospital_code = b.behospital_code
  3971. AND a.behospital_code = c.behospital_code
  3972. AND b.cases_id = c.cases_id
  3973. AND c.cases_id = d.cases_id
  3974. AND c.cases_entry_id = d.id
  3975. AND a.beh_dept_id = e.dept_id
  3976. <if test="isPlacefile != null and isPlacefile != ''">
  3977. and a.is_placefile = #{isPlacefile}
  3978. </if>
  3979. AND d.cases_id = 243
  3980. <![CDATA[AND a.qc_type_id <>0 ]]>
  3981. <if test="hospitalId != null and hospitalId != ''">
  3982. AND a.hospital_id = #{hospitalId}
  3983. </if>
  3984. <if test="isPlacefile != null and isPlacefile == 0">
  3985. <if test="startDate != null and startDate != ''">
  3986. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3987. </if>
  3988. <if test="endDate != null and endDate != ''">
  3989. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3990. </if>
  3991. </if>
  3992. <if test="isPlacefile != null and isPlacefile == 1">
  3993. <if test="startDate != null and startDate != ''">
  3994. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3995. </if>
  3996. <if test="endDate != null and endDate != ''">
  3997. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3998. </if>
  3999. </if>
  4000. <if test="level != null and level != ''">
  4001. and b.level = #{level}
  4002. </if>
  4003. <if test="name != null and name != ''">
  4004. <if test="name == '未知'">
  4005. and (a.doctor_name is null or a.doctor_name='')
  4006. </if>
  4007. <if test="name != '未知'">
  4008. and a.doctor_name like CONCAT('%',#{name},'%')
  4009. </if>
  4010. </if>
  4011. <if test="userId!=null and userId !=''">
  4012. AND e.user_id = #{userId}
  4013. </if>
  4014. <if test="deptName!=null and deptName !=''">
  4015. AND a.beh_dept_name = #{deptName}
  4016. </if>
  4017. <if test="name != null and name != ''">
  4018. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4019. </if>
  4020. GROUP BY
  4021. a.doctor_id,
  4022. a.doctor_name
  4023. ) h1,(
  4024. SELECT
  4025. count(*) AS entryNum
  4026. FROM
  4027. qc_cases_entry
  4028. WHERE
  4029. is_deleted = 'N'
  4030. AND cases_id = 243
  4031. ) h2
  4032. ) t3
  4033. WHERE
  4034. t1.doctorId = t2.doctorId
  4035. AND t1.doctorId = t3.doctorId
  4036. AND t1.doctorName = t2.doctorName
  4037. AND t1.doctorName = t3.doctorName
  4038. <if test="asc != null and asc !=''">
  4039. order by
  4040. <choose>
  4041. <when test='asc=="doctorId"'>doctorId asc</when>
  4042. <when test='asc=="doctorName"'>doctorName asc</when>
  4043. <when test='asc=="entryNum"'>entryNum asc</when>
  4044. <when test='asc=="mrNum"'>mrNum asc</when>
  4045. <when test='asc=="totleValue"'>totleValue asc</when>
  4046. <when test='asc=="averageValue"'>averageValue asc</when>
  4047. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4048. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4049. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4050. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4051. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4052. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4053. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4054. <when test='asc=="errorNum"'>errorNum asc</when>
  4055. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4056. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4057. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4058. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4059. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4060. <otherwise>doctorName asc</otherwise>
  4061. </choose>
  4062. </if>
  4063. <if test="desc != null and desc!=''">
  4064. order by
  4065. <choose>
  4066. <when test='desc=="doctorId"'>doctorId desc</when>
  4067. <when test='desc=="doctorName"'>doctorName desc</when>
  4068. <when test='desc=="entryNum"'>entryNum desc</when>
  4069. <when test='desc=="mrNum"'>mrNum desc</when>
  4070. <when test='desc=="totleValue"'>totleValue desc</when>
  4071. <when test='desc=="averageValue"'>averageValue desc</when>
  4072. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4073. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4074. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4075. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4076. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4077. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4078. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4079. <when test='desc=="errorNum"'>errorNum desc</when>
  4080. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4081. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4082. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4083. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4084. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4085. <otherwise>doctorName desc</otherwise>
  4086. </choose>
  4087. </if>
  4088. </select>
  4089. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4090. <result column="behDeptName" property="behDeptName"/>
  4091. <result column="doctorName" property="doctorName"/>
  4092. <result column="avgScore" property="avgScore"/>
  4093. <collection property="excelBehospitalDTOS"
  4094. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  4095. <result column="patName" property="patName"/>
  4096. <result column="behospitalCode" property="behospitalCode"/>
  4097. <result column="behospitalDate" property="behospitalDate"/>
  4098. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4099. <result column="score" property="score"/>
  4100. <result column="scoreBn" property="scoreBn"/>
  4101. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4102. <result column="caseName" property="caseName"/>
  4103. <collection property="exportExcelMsgDTOS"
  4104. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4105. <result column="msg" property="msg"/>
  4106. </collection>
  4107. </collection>
  4108. </collection>
  4109. </resultMap>
  4110. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  4111. <result column="behDeptName" property="behDeptName"/>
  4112. <result column="avgScore" property="avgScore"/>
  4113. <collection property="excelBehospitalDTOS"
  4114. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  4115. <result column="doctorName" property="doctorName"/>
  4116. <result column="patName" property="patName"/>
  4117. <result column="behospitalCode" property="behospitalCode"/>
  4118. <result column="behospitalDate" property="behospitalDate"/>
  4119. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4120. <result column="score" property="score"/>
  4121. <result column="scoreBn" property="scoreBn"/>
  4122. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4123. <result column="caseName" property="caseName"/>
  4124. <collection property="exportExcelMsgDTOS"
  4125. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4126. <result column="msg" property="msg"/>
  4127. </collection>
  4128. </collection>
  4129. </collection>
  4130. </resultMap>
  4131. <select id="exportExcel" resultMap="ExportExcelMap">
  4132. SELECT DISTINCT
  4133. t1.beh_dept_name AS behDeptName,
  4134. t1.beh_doctor_name AS doctorName,
  4135. t1.`name` AS patName,
  4136. t1.behospital_code AS behospitalCode,
  4137. t1.behospital_date AS behospitalDate,
  4138. t1.leave_hospital_date AS leaveHospitalDate,
  4139. t2.score_res AS score,
  4140. "1" AS avgScore,
  4141. t4.`name` AS caseName,
  4142. t3.msg AS msg
  4143. FROM
  4144. med_behospital_info t1,
  4145. med_qcresult_info t2,
  4146. med_qcresult_detail t3,
  4147. qc_cases t4
  4148. WHERE
  4149. t1.is_deleted = 'N'
  4150. AND t2.is_deleted = 'N'
  4151. AND t3.is_deleted = 'N'
  4152. AND t4.is_deleted = 'N'
  4153. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4154. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4155. AND t1.hospital_id = t2.hospital_id
  4156. AND t1.behospital_code = t2.behospital_code
  4157. AND t1.hospital_id = t3.hospital_id
  4158. AND t1.behospital_code = t3.behospital_code
  4159. AND t3.cases_id = t4.id
  4160. ORDER BY
  4161. t1.beh_dept_id ASC,
  4162. t1.leave_hospital_date DESC,
  4163. t1.behospital_code ASC,
  4164. t4.`name` ASC
  4165. </select>
  4166. <!-- 质控评分导出到excel-->
  4167. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4168. SELECT * FROM (
  4169. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4170. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4171. g.check_type AS ch_type,
  4172. h.check_type AS mr_type,
  4173. g.check_name AS ch_name,
  4174. h.check_name AS mr_name,
  4175. g.check_time AS ch_time,
  4176. h.check_time AS mr_time
  4177. FROM (
  4178. SELECT
  4179. t1.behDeptId,
  4180. t1.behDeptName,
  4181. t1.doctorName,
  4182. t1.patName,
  4183. t1.behospitalCode,
  4184. t1.hospitalId,
  4185. t1.behospitalDate,
  4186. t1.leaveHospitalDate,
  4187. t1.score,
  4188. <if test="radioCheck !=null and radioCheck == 1">
  4189. t1.msg,
  4190. t1.caseName,
  4191. </if>
  4192. t1.scoreBn,
  4193. t2.avgScore
  4194. FROM
  4195. (
  4196. SELECT
  4197. CONCAT(
  4198. ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
  4199. a.doctor_name
  4200. ) AS doctorName,
  4201. a.`name` AS patName,
  4202. a.behospital_code AS behospitalCode,
  4203. a.behospital_date AS behospitalDate,
  4204. a.leave_hospital_date AS leaveHospitalDate,
  4205. b.score_res AS score,
  4206. e.score_res as scoreBn,
  4207. <if test="radioCheck !=null and radioCheck == 1">
  4208. c.msg AS msg,
  4209. d.NAME AS caseName,
  4210. </if>
  4211. a.beh_dept_id AS behDeptId,
  4212. a.beh_dept_name AS behDeptName,
  4213. a.hospital_id AS hospitalId
  4214. FROM
  4215. med_behospital_info a
  4216. RIGHT JOIN
  4217. med_qcresult_info b
  4218. ON a.hospital_id = b.hospital_id
  4219. AND a.is_deleted = 'N'
  4220. AND b.is_deleted = 'N'
  4221. AND a.behospital_code = b.behospital_code
  4222. <if test="radioCheck !=null and radioCheck == 1">
  4223. LEFT JOIN
  4224. med_qcresult_detail c
  4225. ON c.is_deleted = 'N'
  4226. AND b.behospital_code = c.behospital_code
  4227. AND b.hospital_id = c.hospital_id
  4228. LEFT JOIN
  4229. qc_cases d
  4230. on d.is_deleted = 'N'
  4231. AND c.cases_id = d.id
  4232. </if>
  4233. LEFT JOIN med_qcresult_cases e
  4234. on b.behospital_code = e.behospital_code
  4235. and b.hospital_id = e.hospital_id
  4236. AND e.is_deleted = 'N'
  4237. and e.cases_id = 243
  4238. WHERE
  4239. 1=1
  4240. <if test="isPlacefile != null and isPlacefile != ''">
  4241. and a.is_placefile = #{isPlacefile}
  4242. </if>
  4243. <![CDATA[AND a.qc_type_id <>0 ]]>
  4244. <if test="hospitalId != null and hospitalId != ''">
  4245. AND a.hospital_id = #{hospitalId}
  4246. </if>
  4247. <if test="diagnose != null and diagnose != ''">
  4248. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4249. </if>
  4250. <if test="behosDateStart != null">
  4251. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4252. </if>
  4253. <if test="behosDateEnd != null">
  4254. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4255. </if>
  4256. <if test="leaveHosDateStart != null ">
  4257. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4258. </if>
  4259. <if test="leaveHosDateEnd != null ">
  4260. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4261. </if>
  4262. <if test="behospitalCode != null and behospitalCode != ''">
  4263. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4264. </if>
  4265. <if test="level != null and level != ''">
  4266. AND b.level = #{level}
  4267. </if>
  4268. <if test="doctorName != null and doctorName != ''">
  4269. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4270. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4271. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4272. </if>
  4273. <if test="doctorCode != null and doctorCode != ''">
  4274. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4275. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4276. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4277. </if>
  4278. <if test="deptName != null and deptName != ''">
  4279. and a.beh_dept_name = #{deptName}
  4280. </if>
  4281. <if test="name != null and name != ''">
  4282. AND a.name like CONCAT('%',#{name},'%')
  4283. </if>
  4284. ) t1,
  4285. (
  4286. SELECT
  4287. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4288. a.beh_dept_id AS behDeptId,
  4289. a.beh_dept_name AS behDeptName
  4290. FROM
  4291. med_behospital_info a,
  4292. med_qcresult_info b
  4293. WHERE
  4294. a.is_deleted = 'N'
  4295. AND b.is_deleted = 'N'
  4296. AND a.hospital_id = b.hospital_id
  4297. AND a.behospital_code = b.behospital_code
  4298. <if test="isPlacefile != null and isPlacefile != ''">
  4299. and a.is_placefile = #{isPlacefile}
  4300. </if>
  4301. <![CDATA[AND a.qc_type_id <>0 ]]>
  4302. <if test="hospitalId != null and hospitalId != ''">
  4303. AND a.hospital_id = #{hospitalId}
  4304. </if>
  4305. <if test="diagnose != null and diagnose != ''">
  4306. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4307. </if>
  4308. <if test="behosDateStart != null">
  4309. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4310. </if>
  4311. <if test="behosDateEnd != null">
  4312. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4313. </if>
  4314. <if test="leaveHosDateStart != null ">
  4315. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4316. </if>
  4317. <if test="leaveHosDateEnd != null ">
  4318. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4319. </if>
  4320. <if test="behospitalCode != null and behospitalCode != ''">
  4321. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4322. </if>
  4323. <if test="level != null and level != ''">
  4324. AND b.level = #{level}
  4325. </if>
  4326. <if test="doctorName != null and doctorName != ''">
  4327. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4328. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4329. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4330. </if>
  4331. <if test="doctorCode != null and doctorCode != ''">
  4332. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4333. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4334. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4335. </if>
  4336. <if test="deptName != null and deptName != ''">
  4337. and a.beh_dept_name = #{deptName}
  4338. </if>
  4339. <if test="name != null and name != ''">
  4340. AND a.name like CONCAT('%',#{name},'%')
  4341. </if>
  4342. GROUP BY
  4343. a.beh_dept_id,
  4344. a.beh_dept_name
  4345. ) t2
  4346. WHERE
  4347. t1.behDeptId = t2.behDeptId
  4348. AND t1.behDeptName = t2.behDeptName
  4349. ORDER BY
  4350. t1.behDeptName,
  4351. t1.doctorName,
  4352. t1.patName,
  4353. <if test="radioCheck !=null and radioCheck == 1">
  4354. t1.caseName,
  4355. </if>
  4356. t1.behospitalCode
  4357. )tp
  4358. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4359. ON tp.behospitalCode = g.behospital_code
  4360. AND tp.hospitalId = g.hospital_id
  4361. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4362. ON tp.behospitalCode = h.behospital_code
  4363. AND tp.hospitalId = h.hospital_id
  4364. ) tu
  4365. WHERE tu.behospitalCode IS NOT NULL
  4366. <if test="checkStatus != null ">
  4367. and tu.check_status = #{checkStatus}
  4368. </if>
  4369. <if test="mrStatus != null ">
  4370. AND tu.mr_status = #{mrStatus}
  4371. </if>
  4372. <if test="chName != null and chName !=''">
  4373. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4374. </if>
  4375. <if test="mrName != null and mrName !=''">
  4376. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4377. </if>
  4378. <if test="chTimeStart != null">
  4379. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4380. </if>
  4381. <if test="chTimeEnd != null">
  4382. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4383. </if>
  4384. <if test="mrTimeStart != null">
  4385. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4386. </if>
  4387. <if test="mrTimeEnd != null">
  4388. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4389. </if>
  4390. </select>
  4391. <!-- 科室质控评分导出到excel-->
  4392. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4393. SELECT * FROM (
  4394. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4395. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4396. g.check_type AS ch_type,
  4397. h.check_type AS mr_type,
  4398. g.check_name AS ch_name,
  4399. h.check_name AS mr_name,
  4400. g.check_time AS ch_time,
  4401. h.check_time AS mr_time
  4402. FROM (
  4403. SELECT
  4404. t1.behDeptId,
  4405. t1.behDeptName,
  4406. t1.doctorName,
  4407. t1.patName,
  4408. t1.behospitalCode,
  4409. t1.hospitalId,
  4410. t1.behospitalDate,
  4411. t1.leaveHospitalDate,
  4412. t1.score,
  4413. t2.avgScore,
  4414. <if test="radioCheck !=null and radioCheck == 1">
  4415. t1.msg,
  4416. t1.caseName,
  4417. </if>
  4418. e.score_res as scoreBn
  4419. FROM
  4420. (
  4421. SELECT
  4422. a.doctor_name AS doctorName,
  4423. a.`name` AS patName,
  4424. a.behospital_code AS behospitalCode,
  4425. a.hospital_id AS hospital_id,
  4426. a.behospital_date AS behospitalDate,
  4427. a.leave_hospital_date AS leaveHospitalDate,
  4428. b.score_res AS score,
  4429. <if test="radioCheck !=null and radioCheck == 1">
  4430. c.msg AS msg,
  4431. d.NAME AS caseName,
  4432. </if>
  4433. a.beh_dept_id AS behDeptId,
  4434. a.beh_dept_name AS behDeptName,
  4435. a.hospital_id AS hospitalId
  4436. FROM
  4437. med_behospital_info a,
  4438. med_qcresult_info b,
  4439. med_qcresult_detail c,
  4440. qc_cases d,
  4441. sys_user_dept e
  4442. WHERE
  4443. a.is_deleted = 'N'
  4444. AND b.is_deleted = 'N'
  4445. AND c.is_deleted = 'N'
  4446. AND d.is_deleted = 'N'
  4447. AND e.is_deleted = 'N'
  4448. AND a.hospital_id = b.hospital_id
  4449. AND a.hospital_id = c.hospital_id
  4450. AND a.hospital_id = e.hospital_id
  4451. AND a.behospital_code = b.behospital_code
  4452. AND a.behospital_code = c.behospital_code
  4453. AND c.cases_id = d.id
  4454. AND a.beh_dept_id = e.dept_id
  4455. <if test="diagnose != null and diagnose != ''">
  4456. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4457. </if>
  4458. <if test="isPlacefile != null and isPlacefile != ''">
  4459. and a.is_placefile = #{isPlacefile}
  4460. </if>
  4461. <![CDATA[AND a.qc_type_id <>0 ]]>
  4462. <if test="hospitalId != null and hospitalId != ''">
  4463. AND a.hospital_id = #{hospitalId}
  4464. </if>
  4465. <if test="userId != null ">
  4466. AND e.user_id = #{userId}
  4467. </if>
  4468. <if test="behosDateStart != null">
  4469. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4470. </if>
  4471. <if test="behosDateEnd != null">
  4472. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4473. </if>
  4474. <if test="leaveHosDateStart != null ">
  4475. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4476. </if>
  4477. <if test="leaveHosDateEnd != null ">
  4478. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4479. </if>
  4480. <if test="behospitalCode != null and behospitalCode != ''">
  4481. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4482. </if>
  4483. <if test="level != null and level != ''">
  4484. AND b.level = #{level}
  4485. </if>
  4486. <if test="doctorName != null and doctorName != ''">
  4487. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4488. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4489. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4490. </if>
  4491. <if test="doctorCode != null and doctorCode != ''">
  4492. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4493. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4494. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4495. </if>
  4496. <if test="deptName != null and deptName != ''">
  4497. and a.beh_dept_name = #{deptName}
  4498. </if>
  4499. <if test="name != null and name != ''">
  4500. AND a.name like CONCAT('%',#{name},'%')
  4501. </if>
  4502. ) t1
  4503. LEFT JOIN med_qcresult_cases e
  4504. on t1.behospitalCode = e.behospital_code
  4505. and t1.hospital_id = e.hospital_id
  4506. AND e.is_deleted = 'N'
  4507. and e.cases_id = 243,
  4508. (
  4509. SELECT
  4510. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4511. a.beh_dept_id AS behDeptId,
  4512. a.beh_dept_name AS behDeptName
  4513. FROM
  4514. med_behospital_info a,
  4515. med_qcresult_info b,
  4516. sys_user_dept c
  4517. WHERE
  4518. a.is_deleted = 'N'
  4519. AND b.is_deleted = 'N'
  4520. AND c.is_deleted = 'N'
  4521. AND a.hospital_id = b.hospital_id
  4522. AND a.hospital_id = c.hospital_id
  4523. AND a.behospital_code = b.behospital_code
  4524. AND a.beh_dept_id = c.dept_id
  4525. <if test="diagnose != null and diagnose != ''">
  4526. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4527. </if>
  4528. <if test="isPlacefile != null and isPlacefile != ''">
  4529. and a.is_placefile = #{isPlacefile}
  4530. </if>
  4531. <![CDATA[AND a.qc_type_id <>0 ]]>
  4532. <if test="hospitalId != null and hospitalId != ''">
  4533. AND a.hospital_id = #{hospitalId}
  4534. </if>
  4535. <if test="userId != null ">
  4536. AND c.user_id = #{userId}
  4537. </if>
  4538. <if test="behosDateStart != null">
  4539. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4540. </if>
  4541. <if test="behosDateEnd != null">
  4542. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4543. </if>
  4544. <if test="leaveHosDateStart != null ">
  4545. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4546. </if>
  4547. <if test="leaveHosDateEnd != null ">
  4548. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4549. </if>
  4550. <if test="behospitalCode != null and behospitalCode != ''">
  4551. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4552. </if>
  4553. <if test="level != null and level != ''">
  4554. AND b.level = #{level}
  4555. </if>
  4556. <if test="doctorName != null and doctorName != ''">
  4557. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4558. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4559. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4560. </if>
  4561. <if test="doctorCode != null and doctorCode != ''">
  4562. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4563. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4564. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4565. </if>
  4566. <if test="deptName != null and deptName != ''">
  4567. and a.beh_dept_name = #{deptName}
  4568. </if>
  4569. <if test="name != null and name != ''">
  4570. AND a.name like CONCAT('%',#{name},'%')
  4571. </if>
  4572. GROUP BY
  4573. a.beh_dept_id,
  4574. a.beh_dept_name
  4575. ) t2
  4576. WHERE
  4577. t1.behDeptId = t2.behDeptId
  4578. AND t1.behDeptName = t2.behDeptName
  4579. ORDER BY
  4580. t1.behDeptName,
  4581. t1.doctorName,
  4582. t1.patName,
  4583. <if test="radioCheck !=null and radioCheck == 1">
  4584. t1.caseName,
  4585. </if>
  4586. t1.behospitalCode
  4587. )tp
  4588. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4589. ON tp.behospitalCode = g.behospital_code
  4590. AND tp.hospitalId = g.hospital_id
  4591. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4592. ON tp.behospitalCode = h.behospital_code
  4593. AND tp.hospitalId = h.hospital_id
  4594. ) tu
  4595. WHERE tu.behospitalCode IS NOT NULL
  4596. <if test="checkStatus != null ">
  4597. and tu.check_status = #{checkStatus}
  4598. </if>
  4599. <if test="mrStatus != null ">
  4600. AND tu.mr_status = #{mrStatus}
  4601. </if>
  4602. <if test="chName != null and chName !=''">
  4603. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4604. </if>
  4605. <if test="mrName != null and mrName !=''">
  4606. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4607. </if>
  4608. <if test="chTimeStart != null">
  4609. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4610. </if>
  4611. <if test="chTimeEnd != null">
  4612. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4613. </if>
  4614. <if test="mrTimeStart != null">
  4615. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4616. </if>
  4617. <if test="mrTimeEnd != null">
  4618. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4619. </if>
  4620. </select>
  4621. <!-- 个人质控评分导出到excel-->
  4622. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4623. SELECT * FROM (
  4624. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4625. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4626. g.check_type AS ch_type,
  4627. h.check_type AS mr_type,
  4628. g.check_name AS ch_name,
  4629. h.check_name AS mr_name,
  4630. g.check_time AS ch_time,
  4631. h.check_time AS mr_time
  4632. FROM (
  4633. SELECT
  4634. t1.behDeptId,
  4635. t1.behDeptName,
  4636. t1.doctorName,
  4637. t1.patName,
  4638. t1.behospitalCode,
  4639. t1.hospitalId,
  4640. t1.behospitalDate,
  4641. t1.leaveHospitalDate,
  4642. t1.score,
  4643. t2.avgScore,
  4644. <if test="radioCheck !=null and radioCheck == 1">
  4645. t1.msg,
  4646. t1.caseName,
  4647. </if>
  4648. e.score_res as scoreBn
  4649. FROM
  4650. (
  4651. SELECT
  4652. a.doctor_name AS doctorName,
  4653. a.beh_doctor_name,
  4654. a.director_doctor_name,
  4655. a.`name` AS patName,
  4656. a.behospital_code AS behospitalCode,
  4657. a.behospital_date AS behospitalDate,
  4658. a.leave_hospital_date AS leaveHospitalDate,
  4659. b.score_res AS score,
  4660. <if test="radioCheck !=null and radioCheck == 1">
  4661. c.msg AS msg,
  4662. d.NAME AS caseName,
  4663. </if>
  4664. a.beh_dept_id AS behDeptId,
  4665. a.beh_dept_name AS behDeptName,
  4666. a.hospital_id AS hospitalId
  4667. FROM
  4668. med_behospital_info a,
  4669. med_qcresult_info b,
  4670. med_qcresult_detail c,
  4671. qc_cases d,
  4672. sys_user u,
  4673. sys_user_hospital uh
  4674. WHERE
  4675. a.is_deleted = 'N'
  4676. AND b.is_deleted = 'N'
  4677. AND c.is_deleted = 'N'
  4678. AND d.is_deleted = 'N'
  4679. AND u.is_deleted = 'N'
  4680. AND uh.is_deleted = 'N'
  4681. AND a.hospital_id = b.hospital_id
  4682. AND a.hospital_id = c.hospital_id
  4683. AND a.behospital_code = b.behospital_code
  4684. AND a.behospital_code = c.behospital_code
  4685. AND u.id = uh.user_id
  4686. AND a.hospital_id = uh.hospital_id
  4687. <if test="userId != null and userId != ''">
  4688. AND u.id = #{userId}
  4689. </if>
  4690. <if test="isPlacefile != null and isPlacefile != ''">
  4691. and a.is_placefile = #{isPlacefile}
  4692. </if>
  4693. <![CDATA[AND a.qc_type_id <>0 ]]>
  4694. <if test="hospitalId != null and hospitalId != ''">
  4695. AND a.hospital_id = #{hospitalId}
  4696. </if>
  4697. <if test="diagnose != null and diagnose != ''">
  4698. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4699. </if>
  4700. <if test="behosDateStart != null">
  4701. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4702. </if>
  4703. <if test="behosDateEnd != null">
  4704. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4705. </if>
  4706. <if test="leaveHosDateStart != null ">
  4707. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4708. </if>
  4709. <if test="leaveHosDateEnd != null ">
  4710. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4711. </if>
  4712. <if test="behospitalCode != null and behospitalCode != ''">
  4713. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4714. </if>
  4715. <if test="level != null and level != ''">
  4716. AND b.level = #{level}
  4717. </if>
  4718. <if test="doctorName != null and doctorName != ''">
  4719. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4720. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4721. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4722. </if>
  4723. <if test="doctorCode != null and doctorCode != ''">
  4724. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4725. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4726. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4727. </if>
  4728. <if test="deptId != null and deptId != ''">
  4729. AND a.beh_dept_id = #{deptId}
  4730. </if>
  4731. <if test="deptName != null and deptName != ''">
  4732. and a.beh_dept_name = #{deptName}
  4733. </if>
  4734. <if test="name != null and name != ''">
  4735. AND a.name like CONCAT('%',#{name},'%')
  4736. </if>
  4737. ) t1 LEFT JOIN med_qcresult_cases e
  4738. on t1.behospitalCode = e.behospital_code
  4739. and t1.hospitalId = e.hospital_id
  4740. AND e.is_deleted = 'N'
  4741. and e.cases_id = 243,
  4742. (
  4743. SELECT
  4744. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4745. a.beh_dept_id AS behDeptId,
  4746. a.beh_dept_name AS behDeptName
  4747. FROM
  4748. med_behospital_info a,
  4749. med_qcresult_info b,
  4750. sys_user u,
  4751. sys_user_hospital uh
  4752. WHERE
  4753. a.is_deleted = 'N'
  4754. AND b.is_deleted = 'N'
  4755. AND u.is_deleted = 'N'
  4756. AND uh.is_deleted = 'N'
  4757. AND a.hospital_id = b.hospital_id
  4758. AND a.behospital_code = b.behospital_code
  4759. AND u.id = uh.user_id
  4760. AND a.hospital_id = uh.hospital_id
  4761. and (a.doctor_name = u.linkman
  4762. or a.beh_doctor_name = u.linkman
  4763. or a.director_doctor_name = u.linkman)
  4764. <if test="userId != null and userId != ''">
  4765. AND u.id = #{userId}
  4766. </if>
  4767. <if test="diagnose != null and diagnose != ''">
  4768. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4769. </if>
  4770. <if test="isPlacefile != null and isPlacefile != ''">
  4771. and a.is_placefile = #{isPlacefile}
  4772. </if>
  4773. <![CDATA[AND a.qc_type_id <>0 ]]>
  4774. <if test="hospitalId != null and hospitalId != ''">
  4775. AND a.hospital_id = #{hospitalId}
  4776. </if>
  4777. <if test="behosDateStart != null">
  4778. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4779. </if>
  4780. <if test="behosDateEnd != null">
  4781. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4782. </if>
  4783. <if test="leaveHosDateStart != null ">
  4784. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4785. </if>
  4786. <if test="leaveHosDateEnd != null ">
  4787. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4788. </if>
  4789. <if test="behospitalCode != null and behospitalCode != ''">
  4790. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4791. </if>
  4792. <if test="level != null and level != ''">
  4793. AND b.level = #{level}
  4794. </if>
  4795. <if test="doctorName != null and doctorName != ''">
  4796. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4797. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4798. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4799. </if>
  4800. <if test="doctorCode != null and doctorCode != ''">
  4801. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4802. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4803. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4804. </if>
  4805. <if test="deptId != null and deptId != ''">
  4806. AND a.beh_dept_id = #{deptId}
  4807. </if>
  4808. <if test="deptName != null and deptName != ''">
  4809. and a.beh_dept_name = #{deptName}
  4810. </if>
  4811. <if test="name != null and name != ''">
  4812. AND a.name like CONCAT('%',#{name},'%')
  4813. </if>
  4814. ) t2
  4815. WHERE
  4816. t1.behDeptId = t2.behDeptId
  4817. AND t1.behDeptName = t2.behDeptName
  4818. ORDER BY
  4819. t1.behDeptName,
  4820. t1.doctorName,
  4821. t1.patName,
  4822. <if test="radioCheck !=null and radioCheck == 1">
  4823. t1.caseName,
  4824. </if>
  4825. t1.behospitalCode
  4826. )tp
  4827. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4828. ON tp.behospitalCode = g.behospital_code
  4829. AND tp.hospitalId = g.hospital_id
  4830. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4831. ON tp.behospitalCode = h.behospital_code
  4832. AND tp.hospitalId = h.hospital_id
  4833. ) tu
  4834. WHERE tu.behospitalCode IS NOT NULL
  4835. <if test="checkStatus != null ">
  4836. and tu.check_status = #{checkStatus}
  4837. </if>
  4838. <if test="mrStatus != null ">
  4839. AND tu.mr_status = #{mrStatus}
  4840. </if>
  4841. <if test="chName != null and chName !=''">
  4842. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4843. </if>
  4844. <if test="mrName != null and mrName !=''">
  4845. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4846. </if>
  4847. <if test="chTimeStart != null">
  4848. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4849. </if>
  4850. <if test="chTimeEnd != null">
  4851. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4852. </if>
  4853. <if test="mrTimeStart != null">
  4854. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4855. </if>
  4856. <if test="mrTimeEnd != null">
  4857. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4858. </if>
  4859. </select>
  4860. <!-- 医疗组质控评分导出到excel-->
  4861. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4862. SELECT * FROM (
  4863. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4864. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4865. g.check_type AS ch_type,
  4866. h.check_type AS mr_type,
  4867. g.check_name AS ch_name,
  4868. h.check_name AS mr_name,
  4869. g.check_time AS ch_time,
  4870. h.check_time AS mr_time
  4871. FROM (
  4872. SELECT
  4873. t1.behDeptId,
  4874. t1.behDeptName,
  4875. t1.doctorName,
  4876. t1.patName,
  4877. t1.behospitalCode,
  4878. t1.hospitalId,
  4879. t1.behospitalDate,
  4880. t1.leaveHospitalDate,
  4881. t1.score,
  4882. t2.avgScore,
  4883. <if test="radioCheck !=null and radioCheck == 1">
  4884. t1.msg,
  4885. t1.caseName,
  4886. </if>
  4887. e.score_res as scoreBn
  4888. FROM
  4889. (
  4890. SELECT
  4891. a.doctor_name AS doctorName,
  4892. a.`name` AS patName,
  4893. a.behospital_code AS behospitalCode,
  4894. a.behospital_date AS behospitalDate,
  4895. a.leave_hospital_date AS leaveHospitalDate,
  4896. b.score_res AS score,
  4897. <if test="radioCheck !=null and radioCheck == 1">
  4898. c.msg AS msg,
  4899. d.NAME AS caseName,
  4900. </if>
  4901. a.beh_dept_id AS behDeptId,
  4902. a.beh_dept_name AS behDeptName,
  4903. a.hospital_id AS hospitalId
  4904. FROM
  4905. med_behospital_info a,
  4906. med_qcresult_info b,
  4907. med_qcresult_detail c,
  4908. qc_cases d
  4909. WHERE
  4910. a.is_deleted = 'N'
  4911. AND b.is_deleted = 'N'
  4912. AND c.is_deleted = 'N'
  4913. AND d.is_deleted = 'N'
  4914. AND a.hospital_id = b.hospital_id
  4915. AND a.hospital_id = c.hospital_id
  4916. AND a.behospital_code = b.behospital_code
  4917. AND a.behospital_code = c.behospital_code
  4918. AND c.cases_id = d.id
  4919. <if test="isPlacefile != null and isPlacefile != ''">
  4920. and a.is_placefile = #{isPlacefile}
  4921. </if>
  4922. AND a.doctor_id in
  4923. (SELECT doctor_id FROM `bas_doctor_info`
  4924. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4925. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4926. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4927. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4928. and c1.username = c3.doctor_id
  4929. and c2.hospital_id = #{hospitalId}
  4930. and c1.id = #{userId}
  4931. ))
  4932. <![CDATA[AND a.qc_type_id <>0 ]]>
  4933. <if test="hospitalId != null and hospitalId != ''">
  4934. AND a.hospital_id = #{hospitalId}
  4935. </if>
  4936. <if test="diagnose != null and diagnose != ''">
  4937. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4938. </if>
  4939. <if test="behosDateStart != null">
  4940. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4941. </if>
  4942. <if test="behosDateEnd != null">
  4943. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4944. </if>
  4945. <if test="leaveHosDateStart != null ">
  4946. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4947. </if>
  4948. <if test="leaveHosDateEnd != null ">
  4949. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4950. </if>
  4951. <if test="behospitalCode != null and behospitalCode != ''">
  4952. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4953. </if>
  4954. <if test="level != null and level != ''">
  4955. AND b.level = #{level}
  4956. </if>
  4957. <if test="doctorName != null and doctorName != ''">
  4958. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4959. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4960. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4961. </if>
  4962. <if test="doctorCode != null and doctorCode != ''">
  4963. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4964. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4965. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4966. </if>
  4967. <if test="deptId != null and deptId != ''">
  4968. AND a.beh_dept_id = #{deptId}
  4969. </if>
  4970. <if test="name != null and name != ''">
  4971. AND a.name like CONCAT('%',#{name},'%')
  4972. </if>
  4973. ) t1 LEFT JOIN med_qcresult_cases e
  4974. on t1.behospitalCode = e.behospital_code
  4975. and t1.hospitalId = e.hospital_id
  4976. AND e.is_deleted = 'N'
  4977. and e.cases_id = 243,
  4978. (
  4979. SELECT
  4980. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4981. a.beh_dept_id AS behDeptId,
  4982. a.beh_dept_name AS behDeptName
  4983. FROM
  4984. med_behospital_info a,
  4985. med_qcresult_info b
  4986. WHERE
  4987. a.is_deleted = 'N'
  4988. AND a.doctor_id in
  4989. (SELECT doctor_id FROM `bas_doctor_info`
  4990. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4991. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4992. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4993. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4994. and c1.username = c3.doctor_id
  4995. and c2.hospital_id = #{hospitalId}
  4996. and c1.id = #{userId}
  4997. ))
  4998. AND b.is_deleted = 'N'
  4999. AND a.hospital_id = b.hospital_id
  5000. AND a.behospital_code = b.behospital_code
  5001. <if test="diagnose != null and diagnose != ''">
  5002. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5003. </if>
  5004. <if test="isPlacefile != null and isPlacefile != ''">
  5005. and a.is_placefile = #{isPlacefile}
  5006. </if>
  5007. <![CDATA[AND a.qc_type_id <>0 ]]>
  5008. <if test="hospitalId != null and hospitalId != ''">
  5009. AND a.hospital_id = #{hospitalId}
  5010. </if>
  5011. <if test="behosDateStart != null">
  5012. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5013. </if>
  5014. <if test="behosDateEnd != null">
  5015. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5016. </if>
  5017. <if test="leaveHosDateStart != null ">
  5018. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5019. </if>
  5020. <if test="leaveHosDateEnd != null ">
  5021. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5022. </if>
  5023. <if test="behospitalCode != null and behospitalCode != ''">
  5024. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5025. </if>
  5026. <if test="level != null and level != ''">
  5027. AND b.level = #{level}
  5028. </if>
  5029. <if test="doctorName != null and doctorName != ''">
  5030. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5031. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5032. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5033. </if>
  5034. <if test="doctorCode != null and doctorCode != ''">
  5035. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5036. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5037. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5038. </if>
  5039. <if test="deptId != null and deptId != ''">
  5040. AND a.beh_dept_id = #{deptId}
  5041. </if>
  5042. <if test="name != null and name != ''">
  5043. AND a.name like CONCAT('%',#{name},'%')
  5044. </if>
  5045. GROUP BY
  5046. a.beh_dept_id,
  5047. a.beh_dept_name
  5048. ) t2
  5049. WHERE
  5050. t1.behDeptId = t2.behDeptId
  5051. AND t1.behDeptName = t2.behDeptName
  5052. ORDER BY
  5053. t1.behDeptName,
  5054. t1.doctorName,
  5055. t1.patName,
  5056. <if test="radioCheck !=null and radioCheck == 1">
  5057. t1.caseName,
  5058. </if>
  5059. t1.behospitalCode
  5060. )tp
  5061. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5062. ON tp.behospitalCode = g.behospital_code
  5063. AND tp.hospitalId = g.hospital_id
  5064. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5065. ON tp.behospitalCode = h.behospital_code
  5066. AND tp.hospitalId = h.hospital_id
  5067. ) tu
  5068. WHERE tu.behospitalCode IS NOT NULL
  5069. <if test="checkStatus != null ">
  5070. and tu.check_status = #{checkStatus}
  5071. </if>
  5072. <if test="mrStatus != null ">
  5073. AND tu.mr_status = #{mrStatus}
  5074. </if>
  5075. <if test="chName != null and chName !=''">
  5076. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5077. </if>
  5078. <if test="mrName != null and mrName !=''">
  5079. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5080. </if>
  5081. <if test="chTimeStart != null">
  5082. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5083. </if>
  5084. <if test="chTimeEnd != null">
  5085. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5086. </if>
  5087. <if test="mrTimeStart != null">
  5088. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5089. </if>
  5090. <if test="mrTimeEnd != null">
  5091. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5092. </if>
  5093. </select>
  5094. <!-- 条目缺陷质控评分页(内页)-->
  5095. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5096. SELECT t.*
  5097. FROM
  5098. (SELECT DISTINCT
  5099. t1.hospital_id AS hospitalId,
  5100. t1.behospital_code AS behospitalCode,
  5101. t1.bed_code AS bedCode,
  5102. t1.LEVEL AS LEVEL,
  5103. t1.grade_type AS gradeType,
  5104. t1.score_res AS scoreRes,
  5105. t1.scoreBn,
  5106. t1.NAME AS NAME,
  5107. t1.sex AS sex,
  5108. t1.beh_dept_id AS behDeptId,
  5109. t1.beh_dept_name AS behDeptName,
  5110. t1.doctor_id AS doctorId,
  5111. t1.doctor_name AS doctorName,
  5112. t1.beh_doctor_id AS behDoctorId,
  5113. t1.beh_doctor_name AS behDoctorName,
  5114. t1.director_doctor_id AS directorDoctorId,
  5115. t1.director_doctor_name AS directorDoctorName,
  5116. t1.birthday AS birthday,
  5117. t1.behospital_date AS behospitalDate,
  5118. t1.leave_hospital_date AS leaveHospitalDate,
  5119. t1.placefile_date AS placefileDate,
  5120. t1.gmt_create AS gradeTime,
  5121. t1.diagnose,
  5122. t1.ward_name AS wardName,
  5123. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5124. t1.file_code AS fileCode,
  5125. t1.checkStatus,
  5126. t1.mrStatus,
  5127. t1.chName,
  5128. t1.mrName,
  5129. t1.chTime,
  5130. t1.mrTime
  5131. FROM
  5132. (
  5133. SELECT DISTINCT
  5134. tt1.*
  5135. FROM
  5136. (SELECT
  5137. be.*,
  5138. ifnull(mci.status,0) AS checkStatus,
  5139. ifnull(hm_mci.status,0) AS mrStatus,
  5140. mci.check_name as chName,
  5141. e.score_res as scoreBn,
  5142. hm_mci.check_name as mrName,
  5143. mci.gmt_create as chTime,
  5144. hm_mci.gmt_create as mrTime
  5145. FROM
  5146. (
  5147. SELECT DISTINCT
  5148. a.hospital_id,
  5149. a.behospital_code,
  5150. a.bed_code,
  5151. a.file_code,
  5152. b.LEVEL,
  5153. b.grade_type,
  5154. b.score_res,
  5155. a.NAME,
  5156. a.sex,
  5157. a.beh_dept_id,
  5158. a.beh_dept_name,
  5159. a.birthday,
  5160. a.behospital_date,
  5161. a.leave_hospital_date,
  5162. a.doctor_id,
  5163. a.doctor_name,
  5164. a.beh_doctor_id,
  5165. a.beh_doctor_name,
  5166. a.director_doctor_id,
  5167. a.director_doctor_name,
  5168. a.diagnose,
  5169. a.placefile_date,
  5170. a.ward_name,
  5171. b.gmt_create
  5172. FROM
  5173. med_behospital_info a,
  5174. med_qcresult_info b,
  5175. med_qcresult_detail c,
  5176. qc_cases_entry d
  5177. WHERE
  5178. a.is_deleted = 'N'
  5179. AND b.is_deleted = 'N'
  5180. AND c.is_deleted = 'N'
  5181. AND d.is_deleted = 'N'
  5182. AND a.hospital_id = b.hospital_id
  5183. AND a.hospital_id = c.hospital_id
  5184. AND a.behospital_code = b.behospital_code
  5185. AND a.behospital_code = c.behospital_code
  5186. AND c.cases_id = d.cases_id
  5187. AND c.cases_entry_id = d.id
  5188. AND a.qc_type_id != 0
  5189. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5190. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5191. </if>
  5192. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5193. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5194. </if>
  5195. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5196. <if test="qcResultShortPageVO.startDate != null ">
  5197. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5198. </if>
  5199. <if test="qcResultShortPageVO.endDate != null ">
  5200. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5201. </if>
  5202. </if>
  5203. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5204. <if test="qcResultShortPageVO.startDate != null ">
  5205. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5206. </if>
  5207. <if test="qcResultShortPageVO.endDate != null">
  5208. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5209. </if>
  5210. </if>
  5211. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5212. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5213. </if>
  5214. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5215. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5216. </if>
  5217. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5218. AND b.`level` = #{qcResultShortPageVO.level}
  5219. </if>
  5220. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5221. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5222. </if>
  5223. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5224. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5225. </if>
  5226. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5227. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5228. </if>
  5229. <if test="qcResultShortPageVO.casesEntryId != null ">
  5230. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5231. </if>
  5232. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5233. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5234. </if>
  5235. <if test="qcResultShortPageVO.casesId != null">
  5236. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5237. </if>
  5238. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5239. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5240. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5241. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5242. </if>
  5243. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5244. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5245. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5246. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5247. </if>
  5248. <if test="qcResultShortPageVO.isReject != null">
  5249. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5250. </if>
  5251. <if test="qcResultShortPageVO.ruleType != null">
  5252. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5253. </if>
  5254. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5255. AND TIMESTAMPDIFF(
  5256. DAY,
  5257. DATE( a.behospital_date ),
  5258. DATE( a.leave_hospital_date ))> 30
  5259. </if>
  5260. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5261. AND TIMESTAMPDIFF(
  5262. DAY,
  5263. DATE( a.behospital_date ),
  5264. DATE( a.leave_hospital_date ))> 31
  5265. </if>
  5266. )be
  5267. left join med_check_info mci
  5268. on mci.is_deleted = 'N'
  5269. and mci.check_type = 0
  5270. and be.hospital_id = mci.hospital_id
  5271. and be.behospital_code = mci.behospital_code
  5272. left join med_check_info hm_mci
  5273. on hm_mci.is_deleted = 'N'
  5274. and hm_mci.check_type = 1
  5275. and be.hospital_id = hm_mci.hospital_id
  5276. and be.behospital_code = hm_mci.behospital_code
  5277. LEFT JOIN med_qcresult_cases e
  5278. on be.behospital_code = e.behospital_code
  5279. and be.hospital_id = e.hospital_id
  5280. AND e.is_deleted = 'N'
  5281. and e.cases_id = 243
  5282. )tt1
  5283. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5284. ,med_medical_record tt2
  5285. WHERE
  5286. tt2.is_deleted = 'N'
  5287. AND tt1.hospital_id = tt2.hospital_id
  5288. AND tt1.behospital_code = tt2.behospital_code
  5289. AND tt2.mode_id = 30
  5290. </if>
  5291. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5292. ,med_crisis_info tt2
  5293. WHERE
  5294. tt2.is_deleted = 'N'
  5295. AND tt1.hospital_id = tt2.hospital_id
  5296. AND tt1.behospital_code = tt2.behospital_code
  5297. </if>
  5298. ) t1
  5299. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5300. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5301. AND t1.behospital_code = t2.behospital_code
  5302. AND t2.is_deleted = 'N'
  5303. </if>
  5304. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5305. , med_home_page t2
  5306. , med_home_operation_info t3
  5307. WHERE t1.hospital_id = t2.hospital_id
  5308. AND t1.behospital_code = t2.behospital_code
  5309. AND t2.home_page_id = t3.home_page_id
  5310. AND t2.is_deleted = 'N'
  5311. AND t3.is_deleted = 'N'
  5312. </if>
  5313. ) t
  5314. where 1=1
  5315. <if test="qcResultShortPageVO.checkStatus != null">
  5316. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5317. </if>
  5318. <if test="qcResultShortPageVO.mrStatus != null">
  5319. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5320. </if>
  5321. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5322. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5323. </if>
  5324. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5325. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5326. </if>
  5327. <if test="qcResultShortPageVO.chTimeStart != null ">
  5328. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5329. </if>
  5330. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5331. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5332. </if>
  5333. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5334. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5335. </if>
  5336. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5337. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5338. </if>
  5339. </select>
  5340. <!-- 条目缺陷质控评分页-科室(内页)-->
  5341. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5342. SELECT t.*
  5343. FROM
  5344. (SELECT DISTINCT
  5345. t1.hospital_id AS hospitalId,
  5346. t1.behospital_code AS behospitalCode,
  5347. t1.bed_code AS bedCode,
  5348. t1.LEVEL AS LEVEL,
  5349. t1.grade_type AS gradeType,
  5350. t1.score_res AS scoreRes,
  5351. t1.scoreBn,
  5352. t1.NAME AS NAME,
  5353. t1.sex AS sex,
  5354. t1.beh_dept_id AS behDeptId,
  5355. t1.beh_dept_name AS behDeptName,
  5356. t1.doctor_id AS doctorId,
  5357. t1.doctor_name AS doctorName,
  5358. t1.beh_doctor_id AS behDoctorId,
  5359. t1.beh_doctor_name AS behDoctorName,
  5360. t1.director_doctor_id AS directorDoctorId,
  5361. t1.director_doctor_name AS directorDoctorName,
  5362. t1.birthday AS birthday,
  5363. t1.behospital_date AS behospitalDate,
  5364. t1.leave_hospital_date AS leaveHospitalDate,
  5365. t1.placefile_date AS placefileDate,
  5366. t1.gmt_create AS gradeTime,
  5367. t1.diagnose,
  5368. t1.ward_name AS wardName,
  5369. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5370. t1.file_code AS fileCode,
  5371. t1.checkStatus,
  5372. t1.mrStatus,
  5373. t1.chName,
  5374. t1.mrName,
  5375. t1.chTime,
  5376. t1.mrTime
  5377. FROM
  5378. (
  5379. SELECT DISTINCT
  5380. tt1.*
  5381. FROM
  5382. (SELECT
  5383. be.*,
  5384. ifnull(mci.status,0) AS checkStatus,
  5385. ifnull(hm_mci.status,0) AS mrStatus,
  5386. mci.check_name as chName,
  5387. e.score_res as scoreBn,
  5388. hm_mci.check_name as mrName,
  5389. mci.gmt_create as chTime,
  5390. hm_mci.gmt_create as mrTime
  5391. FROM
  5392. (
  5393. SELECT DISTINCT
  5394. a.hospital_id,
  5395. a.behospital_code,
  5396. a.bed_code,
  5397. a.file_code,
  5398. b.LEVEL,
  5399. b.grade_type,
  5400. b.score_res,
  5401. a.NAME,
  5402. a.sex,
  5403. a.beh_dept_id,
  5404. a.beh_dept_name,
  5405. a.birthday,
  5406. a.behospital_date,
  5407. a.leave_hospital_date,
  5408. a.doctor_id,
  5409. a.doctor_name,
  5410. a.beh_doctor_id,
  5411. a.beh_doctor_name,
  5412. a.director_doctor_id,
  5413. a.director_doctor_name,
  5414. a.diagnose,
  5415. a.placefile_date,
  5416. a.ward_name,
  5417. b.gmt_create
  5418. FROM
  5419. med_behospital_info a,
  5420. med_qcresult_info b,
  5421. med_qcresult_detail c,
  5422. qc_cases_entry d,
  5423. sys_user_dept e
  5424. WHERE
  5425. a.is_deleted = 'N'
  5426. AND b.is_deleted = 'N'
  5427. AND c.is_deleted = 'N'
  5428. AND d.is_deleted = 'N'
  5429. AND e.is_deleted = 'N'
  5430. AND a.hospital_id = b.hospital_id
  5431. AND a.hospital_id = c.hospital_id
  5432. AND a.hospital_id = e.hospital_id
  5433. AND a.behospital_code = b.behospital_code
  5434. AND a.behospital_code = c.behospital_code
  5435. AND a.beh_dept_id = e.dept_id
  5436. AND c.cases_id = d.cases_id
  5437. AND c.cases_entry_id = d.id
  5438. AND a.qc_type_id != 0
  5439. <if test="qcResultShortPageVO.userId!=null">
  5440. AND e.user_id = #{qcResultShortPageVO.userId}
  5441. </if>
  5442. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5443. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5444. </if>
  5445. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5446. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5447. </if>
  5448. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5449. <if test="qcResultShortPageVO.startDate != null ">
  5450. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5451. </if>
  5452. <if test="qcResultShortPageVO.endDate != null ">
  5453. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5454. </if>
  5455. </if>
  5456. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5457. <if test="qcResultShortPageVO.startDate != null ">
  5458. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5459. </if>
  5460. <if test="qcResultShortPageVO.endDate != null">
  5461. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5462. </if>
  5463. </if>
  5464. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5465. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5466. </if>
  5467. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5468. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5469. </if>
  5470. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5471. AND b.`level` = #{qcResultShortPageVO.level}
  5472. </if>
  5473. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5474. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5475. </if>
  5476. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5477. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5478. </if>
  5479. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5480. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5481. </if>
  5482. <if test="qcResultShortPageVO.casesEntryId != null ">
  5483. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5484. </if>
  5485. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5486. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5487. </if>
  5488. <if test="qcResultShortPageVO.casesId != null">
  5489. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5490. </if>
  5491. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5492. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5493. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5494. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5495. </if>
  5496. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5497. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5498. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5499. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5500. </if>
  5501. <if test="qcResultShortPageVO.isReject != null">
  5502. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5503. </if>
  5504. <if test="qcResultShortPageVO.ruleType != null">
  5505. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5506. </if>
  5507. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5508. AND TIMESTAMPDIFF(
  5509. DAY,
  5510. DATE( a.behospital_date ),
  5511. DATE( a.leave_hospital_date ))> 30
  5512. </if>
  5513. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5514. AND TIMESTAMPDIFF(
  5515. DAY,
  5516. DATE( a.behospital_date ),
  5517. DATE( a.leave_hospital_date ))> 31
  5518. </if>
  5519. )be
  5520. left join med_check_info mci
  5521. on mci.is_deleted = 'N'
  5522. and mci.check_type = 0
  5523. and be.hospital_id = mci.hospital_id
  5524. and be.behospital_code = mci.behospital_code
  5525. left join med_check_info hm_mci
  5526. on hm_mci.is_deleted = 'N'
  5527. and hm_mci.check_type = 1
  5528. and be.hospital_id = hm_mci.hospital_id
  5529. and be.behospital_code = hm_mci.behospital_code
  5530. LEFT JOIN med_qcresult_cases e
  5531. on be.behospital_code = e.behospital_code
  5532. and be.hospital_id = e.hospital_id
  5533. AND e.is_deleted = 'N'
  5534. and e.cases_id = 243
  5535. )tt1
  5536. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5537. ,med_medical_record tt2
  5538. WHERE
  5539. tt2.is_deleted = 'N'
  5540. AND tt1.hospital_id = tt2.hospital_id
  5541. AND tt1.behospital_code = tt2.behospital_code
  5542. AND tt2.mode_id = 30
  5543. </if>
  5544. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5545. ,med_crisis_info tt2
  5546. WHERE
  5547. tt2.is_deleted = 'N'
  5548. AND tt1.hospital_id = tt2.hospital_id
  5549. AND tt1.behospital_code = tt2.behospital_code
  5550. </if>
  5551. ) t1
  5552. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5553. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5554. AND t1.behospital_code = t2.behospital_code
  5555. AND t2.is_deleted = 'N'
  5556. </if>
  5557. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5558. , med_home_page t2
  5559. , med_home_operation_info t3
  5560. WHERE t1.hospital_id = t2.hospital_id
  5561. AND t1.behospital_code = t2.behospital_code
  5562. AND t2.home_page_id = t3.home_page_id
  5563. AND t2.is_deleted = 'N'
  5564. AND t3.is_deleted = 'N'
  5565. </if>
  5566. ) t
  5567. where 1=1
  5568. <if test="qcResultShortPageVO.checkStatus != null">
  5569. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5570. </if>
  5571. <if test="qcResultShortPageVO.mrStatus != null">
  5572. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5573. </if>
  5574. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5575. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5576. </if>
  5577. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5578. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5579. </if>
  5580. <if test="qcResultShortPageVO.chTimeStart != null ">
  5581. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5582. </if>
  5583. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5584. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5585. </if>
  5586. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5587. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5588. </if>
  5589. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5590. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5591. </if>
  5592. </select>
  5593. <update id="updateBatchByKey">
  5594. <foreach collection="list" item="item" separator=";">
  5595. update med_behospital_info
  5596. <set>
  5597. <if test="item.name != null">
  5598. name = #{item.name},
  5599. </if>
  5600. <if test="item.sex != null">
  5601. sex = #{item.sex},
  5602. </if>
  5603. <if test="item.birthday != null">
  5604. birthday = #{item.birthday},
  5605. </if>
  5606. <if test="item.fileCode != null">
  5607. file_code = #{item.fileCode},
  5608. </if>
  5609. <if test="item.qcTypeId != null">
  5610. qc_type_id = #{item.qcTypeId},
  5611. </if>
  5612. <if test="item.wardCode != null">
  5613. ward_code = #{item.wardCode},
  5614. </if>
  5615. <if test="item.wardName != null">
  5616. ward_name = #{item.wardName},
  5617. </if>
  5618. <if test="item.behDeptId != null">
  5619. beh_dept_id = #{item.behDeptId},
  5620. </if>
  5621. <if test="item.behDeptName != null">
  5622. beh_dept_name = #{item.behDeptName},
  5623. </if>
  5624. <if test="item.bedCode != null">
  5625. bed_code = #{item.bedCode},
  5626. </if>
  5627. <if test="item.bedName != null">
  5628. bed_name = #{item.bedName},
  5629. </if>
  5630. <if test="item.insuranceName != null">
  5631. insurance_name = #{item.insuranceName},
  5632. </if>
  5633. <if test="item.jobType != null">
  5634. job_type = #{item.jobType},
  5635. </if>
  5636. <if test="item.behospitalDate != null">
  5637. behospital_date = #{item.behospitalDate},
  5638. </if>
  5639. <if test="item.leaveHospitalDate != null">
  5640. leave_hospital_date = #{item.leaveHospitalDate},
  5641. </if>
  5642. <if test="item.diagnoseIcd != null">
  5643. diagnose_icd = #{item.diagnoseIcd},
  5644. </if>
  5645. <if test="item.diagnose != null">
  5646. diagnose = #{item.diagnose},
  5647. </if>
  5648. <if test="item.behDoctorId != null">
  5649. beh_doctor_id = #{item.behDoctorId},
  5650. </if>
  5651. <if test="item.behDoctorName != null">
  5652. beh_doctor_name = #{item.behDoctorName},
  5653. </if>
  5654. <if test="item.doctorId != null">
  5655. doctor_id = #{item.doctorId},
  5656. </if>
  5657. <if test="item.doctorName != null">
  5658. doctor_name = #{item.doctorName},
  5659. </if>
  5660. <if test="item.directorDoctorId != null">
  5661. director_doctor_id = #{item.directorDoctorId},
  5662. </if>
  5663. <if test="item.directorDoctorName != null">
  5664. director_doctor_name = #{item.directorDoctorName},
  5665. </if>
  5666. <if test="item.placefileDate != null">
  5667. placefile_date = #{item.placefileDate},
  5668. </if>
  5669. <if test="item.isPlacefile != null">
  5670. is_placefile = #{item.isPlacefile},
  5671. </if>
  5672. <if test="item.gmtModified != null">
  5673. gmt_modified = #{item.gmtModified},
  5674. </if>
  5675. <if test="item.modifier != null">
  5676. modifier = #{item.modifier},
  5677. </if>
  5678. </set>
  5679. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  5680. </foreach>
  5681. </update>
  5682. <!-- 关键条目缺陷统计报表-->
  5683. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  5684. SELECT
  5685. deptId,
  5686. deptName,
  5687. consultationMRNum,
  5688. consultationNum,
  5689. 2511 AS consultationEntryId,
  5690. '普通会诊未在24小时内完成' AS consultationEntryName,
  5691. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  5692. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  5693. operationMRNum,
  5694. 2594 AS operationNameEntryId,
  5695. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  5696. operationNameNum,
  5697. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  5698. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  5699. 2973 AS operationTimeEntryId,
  5700. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  5701. operationTimeNum,
  5702. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  5703. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  5704. 2930 AS operation15MinuteEntryId,
  5705. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  5706. operation15MinuteNum,
  5707. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  5708. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  5709. 2419 AS crisisEntryId,
  5710. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  5711. crisisMRNum,
  5712. crisisNum,
  5713. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  5714. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  5715. 2495 AS stageSummaryEntryId,
  5716. '无阶段小结' AS stageSummaryEntryName,
  5717. stageSummaryMRNum,
  5718. stageSummaryNum,
  5719. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  5720. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  5721. beHosGT31DaysMRNum
  5722. FROM
  5723. (
  5724. SELECT
  5725. tt.deptId,
  5726. tt.deptName,
  5727. sum( tt.consultationNum ) AS consultationNum,
  5728. sum( tt.consultationMRNum ) AS consultationMRNum,
  5729. sum( tt.operationNameNum ) AS operationNameNum,
  5730. sum( tt.operationTimeNum ) AS operationTimeNum,
  5731. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  5732. sum( tt.operationMRNum ) AS operationMRNum,
  5733. sum( tt.crisisNum ) AS crisisNum,
  5734. sum( tt.crisisMRNum ) AS crisisMRNum,
  5735. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  5736. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  5737. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  5738. FROM
  5739. (
  5740. (
  5741. SELECT
  5742. c.beh_dept_id AS deptId,
  5743. c.beh_dept_name AS deptName,
  5744. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  5745. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  5746. 0 AS operationNameNum,
  5747. 0 AS operationTimeNum,
  5748. 0 AS operation15MinuteNum,
  5749. 0 AS operationMRNum,
  5750. 0 AS crisisNum,
  5751. 0 AS crisisMRNum,
  5752. 0 AS stageSummaryNum,
  5753. 0 AS stageSummaryMRNum,
  5754. 0 AS beHosGT31DaysMRNum
  5755. FROM
  5756. (
  5757. SELECT DISTINCT
  5758. a.hospital_id,
  5759. a.behospital_code,
  5760. a.beh_dept_name,
  5761. a.beh_dept_id
  5762. FROM
  5763. med_behospital_info a,
  5764. med_medical_record b
  5765. WHERE
  5766. a.is_deleted = 'N'
  5767. AND b.is_deleted = 'N'
  5768. AND a.hospital_id = b.hospital_id
  5769. AND a.behospital_code = b.behospital_code
  5770. AND b.mode_id = 30
  5771. <if test="isPlacefile != null and isPlacefile != ''">
  5772. and a.is_placefile = #{isPlacefile}
  5773. </if>
  5774. AND a.qc_type_id != 0
  5775. <if test="hospitalId != null and hospitalId != ''">
  5776. AND a.hospital_id = #{hospitalId}
  5777. </if>
  5778. <if test="isPlacefile != null and isPlacefile == 0">
  5779. <if test="startDate != null ">
  5780. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5781. </if>
  5782. <if test="endDate != null ">
  5783. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5784. </if>
  5785. </if>
  5786. <if test="isPlacefile != null and isPlacefile == 1">
  5787. <if test="startDate != null ">
  5788. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5789. </if>
  5790. <if test="endDate != null ">
  5791. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5792. </if>
  5793. </if>
  5794. <if test="deptName != null and deptName != ''">
  5795. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5796. </if>
  5797. ) c
  5798. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5799. AND c.hospital_id = d.hospital_id
  5800. AND c.behospital_code = d.behospital_code
  5801. GROUP BY
  5802. c.beh_dept_id,
  5803. c.beh_dept_name
  5804. ) UNION
  5805. (
  5806. SELECT
  5807. d.beh_dept_id AS deptId,
  5808. d.beh_dept_name AS deptName,
  5809. 0 AS consultationNum,
  5810. 0 AS consultationMRNum,
  5811. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  5812. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  5813. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  5814. count( DISTINCT d.behospital_code ) AS operationMRNum,
  5815. 0 AS crisisNum,
  5816. 0 AS crisisMRNum,
  5817. 0 AS stageSummaryNum,
  5818. 0 AS stageSummaryMRNum,
  5819. 0 AS beHosGT31DaysMRNum
  5820. FROM
  5821. (
  5822. SELECT DISTINCT
  5823. a.hospital_id,
  5824. a.behospital_code,
  5825. a.beh_dept_name,
  5826. a.beh_dept_id
  5827. FROM
  5828. med_behospital_info a,
  5829. med_home_page b,
  5830. med_home_operation_info c
  5831. WHERE
  5832. a.is_deleted = 'N'
  5833. AND b.is_deleted = 'N'
  5834. AND c.is_deleted = 'N'
  5835. AND a.hospital_id = b.hospital_id
  5836. AND a.hospital_id = c.hospital_id
  5837. AND a.behospital_code = b.behospital_code
  5838. AND b.home_page_id = c.home_page_id
  5839. <if test="isPlacefile != null and isPlacefile != ''">
  5840. and a.is_placefile = #{isPlacefile}
  5841. </if>
  5842. AND a.qc_type_id != 0
  5843. <if test="hospitalId != null and hospitalId != ''">
  5844. AND a.hospital_id = #{hospitalId}
  5845. </if>
  5846. <if test="isPlacefile != null and isPlacefile == 0">
  5847. <if test="startDate != null ">
  5848. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5849. </if>
  5850. <if test="endDate != null ">
  5851. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5852. </if>
  5853. </if>
  5854. <if test="isPlacefile != null and isPlacefile == 1">
  5855. <if test="startDate != null ">
  5856. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5857. </if>
  5858. <if test="endDate != null ">
  5859. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5860. </if>
  5861. </if>
  5862. <if test="deptName != null and deptName != ''">
  5863. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5864. </if>
  5865. ) d
  5866. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  5867. AND d.hospital_id = e.hospital_id
  5868. AND d.behospital_code = e.behospital_code
  5869. GROUP BY
  5870. d.beh_dept_id,
  5871. d.beh_dept_name
  5872. ) UNION
  5873. (
  5874. SELECT
  5875. c.beh_dept_id AS deptId,
  5876. c.beh_dept_name AS deptName,
  5877. 0 AS consultationNum,
  5878. 0 AS consultationMRNum,
  5879. 0 AS operationNameNum,
  5880. 0 AS operationTimeNum,
  5881. 0 AS operation15MinuteNum,
  5882. 0 AS operationMRNum,
  5883. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  5884. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  5885. 0 AS stageSummaryNum,
  5886. 0 AS stageSummaryMRNum,
  5887. 0 AS beHosGT31DaysMRNum
  5888. FROM
  5889. (
  5890. SELECT DISTINCT
  5891. a.hospital_id,
  5892. a.behospital_code,
  5893. a.beh_dept_name,
  5894. a.beh_dept_id
  5895. FROM
  5896. med_behospital_info a,
  5897. med_crisis_info b
  5898. WHERE
  5899. a.is_deleted = 'N'
  5900. AND b.is_deleted = 'N'
  5901. AND a.hospital_id = b.hospital_id
  5902. AND a.behospital_code = b.behospital_code
  5903. <if test="isPlacefile != null and isPlacefile != ''">
  5904. and a.is_placefile = #{isPlacefile}
  5905. </if>
  5906. AND a.qc_type_id != 0
  5907. <if test="hospitalId != null and hospitalId != ''">
  5908. AND a.hospital_id = #{hospitalId}
  5909. </if>
  5910. <if test="isPlacefile != null and isPlacefile == 0">
  5911. <if test="startDate != null ">
  5912. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5913. </if>
  5914. <if test="endDate != null ">
  5915. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5916. </if>
  5917. </if>
  5918. <if test="isPlacefile != null and isPlacefile == 1">
  5919. <if test="startDate != null ">
  5920. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5921. </if>
  5922. <if test="endDate != null ">
  5923. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5924. </if>
  5925. </if>
  5926. <if test="deptName != null and deptName != ''">
  5927. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5928. </if>
  5929. ) c
  5930. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5931. AND c.hospital_id = d.hospital_id
  5932. AND c.behospital_code = d.behospital_code
  5933. GROUP BY
  5934. c.beh_dept_id,
  5935. c.beh_dept_name
  5936. ) UNION
  5937. (
  5938. SELECT
  5939. b.beh_dept_id AS deptId,
  5940. b.beh_dept_name AS deptName,
  5941. 0 AS consultationNum,
  5942. 0 AS consultationMRNum,
  5943. 0 AS operationNameNum,
  5944. 0 AS operationTimeNum,
  5945. 0 AS operation15MinuteNum,
  5946. 0 AS operationMRNum,
  5947. 0 AS crisisNum,
  5948. 0 AS crisisMRNum,
  5949. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  5950. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  5951. 0 AS beHosGT31DaysMRNum
  5952. FROM
  5953. (
  5954. SELECT DISTINCT
  5955. a.hospital_id,
  5956. a.behospital_code,
  5957. a.beh_dept_name,
  5958. a.beh_dept_id
  5959. FROM
  5960. med_behospital_info a
  5961. WHERE
  5962. a.is_deleted = 'N'
  5963. AND TIMESTAMPDIFF(
  5964. DAY,
  5965. DATE( behospital_date ),
  5966. DATE( leave_hospital_date ))> 30
  5967. <if test="isPlacefile != null and isPlacefile != ''">
  5968. and a.is_placefile = #{isPlacefile}
  5969. </if>
  5970. AND a.qc_type_id != 0
  5971. <if test="hospitalId != null and hospitalId != ''">
  5972. AND a.hospital_id = #{hospitalId}
  5973. </if>
  5974. <if test="isPlacefile != null and isPlacefile == 0">
  5975. <if test="startDate != null ">
  5976. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5977. </if>
  5978. <if test="endDate != null ">
  5979. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5980. </if>
  5981. </if>
  5982. <if test="isPlacefile != null and isPlacefile == 1">
  5983. <if test="startDate != null ">
  5984. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5985. </if>
  5986. <if test="endDate != null ">
  5987. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5988. </if>
  5989. </if>
  5990. <if test="deptName != null and deptName != ''">
  5991. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5992. </if>
  5993. ) b
  5994. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  5995. AND b.hospital_id = c.hospital_id
  5996. AND b.behospital_code = c.behospital_code
  5997. GROUP BY
  5998. b.beh_dept_id,
  5999. b.beh_dept_name
  6000. ) UNION
  6001. (
  6002. SELECT
  6003. b.beh_dept_id AS deptId,
  6004. b.beh_dept_name AS deptName,
  6005. 0 AS consultationNum,
  6006. 0 AS consultationMRNum,
  6007. 0 AS operationNameNum,
  6008. 0 AS operationTimeNum,
  6009. 0 AS operation15MinuteNum,
  6010. 0 AS operationMRNum,
  6011. 0 AS crisisNum,
  6012. 0 AS crisisMRNum,
  6013. 0 AS stageSummaryNum,
  6014. 0 AS stageSummaryMRNum,
  6015. count(*) AS beHosGT31DaysMRNum
  6016. FROM
  6017. (
  6018. SELECT DISTINCT
  6019. a.hospital_id,
  6020. a.behospital_code,
  6021. a.beh_dept_name,
  6022. a.beh_dept_id
  6023. FROM
  6024. med_behospital_info a
  6025. WHERE
  6026. a.is_deleted = 'N'
  6027. AND TIMESTAMPDIFF(
  6028. DAY,
  6029. DATE( behospital_date ),
  6030. DATE( leave_hospital_date ))> 31
  6031. <if test="isPlacefile != null and isPlacefile != ''">
  6032. and a.is_placefile = #{isPlacefile}
  6033. </if>
  6034. AND a.qc_type_id != 0
  6035. <if test="hospitalId != null and hospitalId != ''">
  6036. AND a.hospital_id = #{hospitalId}
  6037. </if>
  6038. <if test="isPlacefile != null and isPlacefile == 0">
  6039. <if test="startDate != null ">
  6040. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6041. </if>
  6042. <if test="endDate != null ">
  6043. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6044. </if>
  6045. </if>
  6046. <if test="isPlacefile != null and isPlacefile == 1">
  6047. <if test="startDate != null ">
  6048. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6049. </if>
  6050. <if test="endDate != null ">
  6051. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6052. </if>
  6053. </if>
  6054. <if test="deptName != null and deptName != ''">
  6055. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6056. </if>
  6057. ) b
  6058. GROUP BY
  6059. b.beh_dept_id,
  6060. b.beh_dept_name
  6061. )
  6062. ) tt
  6063. GROUP BY
  6064. tt.deptId,
  6065. tt.deptName
  6066. ) t
  6067. <if test="asc != null and asc !=''">
  6068. order by
  6069. <choose>
  6070. <when test='asc=="deptId"'>deptId asc</when>
  6071. <when test='asc=="deptName"'>deptName asc</when>
  6072. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6073. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6074. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6075. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6076. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6077. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6078. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6079. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6080. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6081. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6082. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6083. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6084. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6085. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6086. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6087. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6088. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6089. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6090. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6091. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6092. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6093. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6094. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6095. <otherwise>deptName asc</otherwise>
  6096. </choose>
  6097. </if>
  6098. <if test="desc != null and desc!=''">
  6099. order by
  6100. <choose>
  6101. <when test='desc=="deptId"'>deptId desc</when>
  6102. <when test='desc=="deptName"'>deptName desc</when>
  6103. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6104. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6105. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6106. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6107. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6108. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6109. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6110. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6111. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6112. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6113. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6114. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6115. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6116. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6117. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6118. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6119. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6120. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6121. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6122. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6123. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6124. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6125. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6126. <otherwise>deptName desc</otherwise>
  6127. </choose>
  6128. </if>
  6129. </select>
  6130. <!-- 关键条目缺陷统计报表-科室-->
  6131. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6132. SELECT
  6133. deptId,
  6134. deptName,
  6135. doctorName,
  6136. consultationMRNum,
  6137. consultationNum,
  6138. 2511 AS consultationEntryId,
  6139. '普通会诊未在24小时内完成' AS consultationEntryName,
  6140. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6141. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6142. operationMRNum,
  6143. 2594 AS operationNameEntryId,
  6144. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6145. operationNameNum,
  6146. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6147. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6148. 2973 AS operationTimeEntryId,
  6149. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6150. operationTimeNum,
  6151. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6152. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6153. 2930 AS operation15MinuteEntryId,
  6154. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6155. operation15MinuteNum,
  6156. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6157. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6158. 2419 AS crisisEntryId,
  6159. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6160. crisisMRNum,
  6161. crisisNum,
  6162. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6163. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6164. 2495 AS stageSummaryEntryId,
  6165. '无阶段小结' AS stageSummaryEntryName,
  6166. stageSummaryMRNum,
  6167. stageSummaryNum,
  6168. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6169. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6170. beHosGT31DaysMRNum
  6171. FROM
  6172. (
  6173. SELECT
  6174. tt.deptId,
  6175. tt.deptName,
  6176. tt.doctorId,
  6177. tt.doctorName,
  6178. sum( tt.consultationNum ) AS consultationNum,
  6179. sum( tt.consultationMRNum ) AS consultationMRNum,
  6180. sum( tt.operationNameNum ) AS operationNameNum,
  6181. sum( tt.operationTimeNum ) AS operationTimeNum,
  6182. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6183. sum( tt.operationMRNum ) AS operationMRNum,
  6184. sum( tt.crisisNum ) AS crisisNum,
  6185. sum( tt.crisisMRNum ) AS crisisMRNum,
  6186. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6187. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6188. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6189. FROM
  6190. (
  6191. (
  6192. SELECT
  6193. c.beh_dept_id AS deptId,
  6194. c.beh_dept_name AS deptName,
  6195. c.doctorId,
  6196. c.doctorName,
  6197. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6198. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6199. 0 AS operationNameNum,
  6200. 0 AS operationTimeNum,
  6201. 0 AS operation15MinuteNum,
  6202. 0 AS operationMRNum,
  6203. 0 AS crisisNum,
  6204. 0 AS crisisMRNum,
  6205. 0 AS stageSummaryNum,
  6206. 0 AS stageSummaryMRNum,
  6207. 0 AS beHosGT31DaysMRNum
  6208. FROM
  6209. (
  6210. SELECT DISTINCT
  6211. a.hospital_id,
  6212. a.behospital_code,
  6213. a.beh_dept_name,
  6214. a.beh_dept_id,
  6215. a.doctor_id as doctorId,
  6216. a.doctor_name as doctorName
  6217. FROM
  6218. med_behospital_info a,
  6219. med_medical_record b,
  6220. sys_user_dept c
  6221. WHERE
  6222. a.is_deleted = 'N'
  6223. AND b.is_deleted = 'N'
  6224. AND c.is_deleted = 'N'
  6225. AND a.hospital_id = b.hospital_id
  6226. AND a.hospital_id = c.hospital_id
  6227. AND a.behospital_code = b.behospital_code
  6228. AND a.beh_dept_id = c.dept_id
  6229. AND b.mode_id = 30
  6230. <if test="userId!=null">
  6231. AND c.user_id = #{userId}
  6232. </if>
  6233. <if test="isPlacefile != null and isPlacefile != ''">
  6234. and a.is_placefile = #{isPlacefile}
  6235. </if>
  6236. AND a.qc_type_id != 0
  6237. <if test="hospitalId != null and hospitalId != ''">
  6238. AND a.hospital_id = #{hospitalId}
  6239. </if>
  6240. <if test="isPlacefile != null and isPlacefile == 0">
  6241. <if test="startDate != null ">
  6242. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6243. </if>
  6244. <if test="endDate != null ">
  6245. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6246. </if>
  6247. </if>
  6248. <if test="isPlacefile != null and isPlacefile == 1">
  6249. <if test="startDate != null ">
  6250. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6251. </if>
  6252. <if test="endDate != null ">
  6253. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6254. </if>
  6255. </if>
  6256. <if test="doctorName != null and doctorName != ''">
  6257. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6258. </if>
  6259. <if test="deptName != null and deptName != ''">
  6260. AND a.beh_dept_name = #{deptName}
  6261. </if>
  6262. ) c
  6263. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6264. AND c.hospital_id = d.hospital_id
  6265. AND c.behospital_code = d.behospital_code
  6266. GROUP BY
  6267. c.doctorId,
  6268. c.doctorName
  6269. ) UNION
  6270. (
  6271. SELECT
  6272. d.beh_dept_id AS deptId,
  6273. d.beh_dept_name AS deptName,
  6274. d.doctor_id as doctorId,
  6275. d.doctor_name as doctorName,
  6276. 0 AS consultationNum,
  6277. 0 AS consultationMRNum,
  6278. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6279. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6280. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6281. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6282. 0 AS crisisNum,
  6283. 0 AS crisisMRNum,
  6284. 0 AS stageSummaryNum,
  6285. 0 AS stageSummaryMRNum,
  6286. 0 AS beHosGT31DaysMRNum
  6287. FROM
  6288. (
  6289. SELECT DISTINCT
  6290. a.hospital_id,
  6291. a.behospital_code,
  6292. a.beh_dept_name,
  6293. a.beh_dept_id,
  6294. a.doctor_id,
  6295. a.doctor_name
  6296. FROM
  6297. med_behospital_info a,
  6298. med_home_page b,
  6299. med_home_operation_info c,
  6300. sys_user_dept d
  6301. WHERE
  6302. a.is_deleted = 'N'
  6303. AND b.is_deleted = 'N'
  6304. AND c.is_deleted = 'N'
  6305. AND d.is_deleted = 'N'
  6306. AND a.hospital_id = b.hospital_id
  6307. AND a.hospital_id = c.hospital_id
  6308. AND a.hospital_id = d.hospital_id
  6309. AND a.behospital_code = b.behospital_code
  6310. AND b.home_page_id = c.home_page_id
  6311. AND a.beh_dept_id = d.dept_id
  6312. <if test="userId!=null">
  6313. AND d.user_id = #{userId}
  6314. </if>
  6315. <if test="isPlacefile != null and isPlacefile != ''">
  6316. and a.is_placefile = #{isPlacefile}
  6317. </if>
  6318. AND a.qc_type_id != 0
  6319. <if test="hospitalId != null and hospitalId != ''">
  6320. AND a.hospital_id = #{hospitalId}
  6321. </if>
  6322. <if test="isPlacefile != null and isPlacefile == 0">
  6323. <if test="startDate != null ">
  6324. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6325. </if>
  6326. <if test="endDate != null ">
  6327. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6328. </if>
  6329. </if>
  6330. <if test="isPlacefile != null and isPlacefile == 1">
  6331. <if test="startDate != null ">
  6332. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6333. </if>
  6334. <if test="endDate != null ">
  6335. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6336. </if>
  6337. </if>
  6338. <if test="doctorName != null and doctorName != ''">
  6339. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6340. </if>
  6341. <if test="deptName != null and deptName != ''">
  6342. AND a.beh_dept_name = #{deptName}
  6343. </if>
  6344. ) d
  6345. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6346. AND d.hospital_id = e.hospital_id
  6347. AND d.behospital_code = e.behospital_code
  6348. GROUP BY
  6349. d.doctor_id,
  6350. d.doctor_name
  6351. ) UNION
  6352. (
  6353. SELECT
  6354. c.beh_dept_id AS deptId,
  6355. c.beh_dept_name AS deptName,
  6356. c.doctor_id as doctorId,
  6357. c.doctor_name as doctorName,
  6358. 0 AS consultationNum,
  6359. 0 AS consultationMRNum,
  6360. 0 AS operationNameNum,
  6361. 0 AS operationTimeNum,
  6362. 0 AS operation15MinuteNum,
  6363. 0 AS operationMRNum,
  6364. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6365. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6366. 0 AS stageSummaryNum,
  6367. 0 AS stageSummaryMRNum,
  6368. 0 AS beHosGT31DaysMRNum
  6369. FROM
  6370. (
  6371. SELECT DISTINCT
  6372. a.hospital_id,
  6373. a.behospital_code,
  6374. a.beh_dept_name,
  6375. a.beh_dept_id,
  6376. a.doctor_id,
  6377. a.doctor_name
  6378. FROM
  6379. med_behospital_info a,
  6380. med_crisis_info b,
  6381. sys_user_dept c
  6382. WHERE
  6383. a.is_deleted = 'N'
  6384. AND b.is_deleted = 'N'
  6385. AND c.is_deleted = 'N'
  6386. AND a.hospital_id = b.hospital_id
  6387. AND a.hospital_id = c.hospital_id
  6388. AND a.behospital_code = b.behospital_code
  6389. AND a.beh_dept_id = c.dept_id
  6390. <if test="userId!=null">
  6391. AND c.user_id = #{userId}
  6392. </if>
  6393. <if test="isPlacefile != null and isPlacefile != ''">
  6394. and a.is_placefile = #{isPlacefile}
  6395. </if>
  6396. AND a.qc_type_id != 0
  6397. <if test="hospitalId != null and hospitalId != ''">
  6398. AND a.hospital_id = #{hospitalId}
  6399. </if>
  6400. <if test="isPlacefile != null and isPlacefile == 0">
  6401. <if test="startDate != null ">
  6402. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6403. </if>
  6404. <if test="endDate != null ">
  6405. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6406. </if>
  6407. </if>
  6408. <if test="isPlacefile != null and isPlacefile == 1">
  6409. <if test="startDate != null ">
  6410. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6411. </if>
  6412. <if test="endDate != null ">
  6413. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6414. </if>
  6415. </if>
  6416. <if test="doctorName != null and doctorName != ''">
  6417. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6418. </if>
  6419. <if test="deptName != null and deptName != ''">
  6420. AND a.beh_dept_name = #{deptName}
  6421. </if>
  6422. ) c
  6423. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6424. AND c.hospital_id = d.hospital_id
  6425. AND c.behospital_code = d.behospital_code
  6426. GROUP BY
  6427. c.doctor_id,
  6428. c.doctor_name
  6429. ) UNION
  6430. (
  6431. SELECT
  6432. b.beh_dept_id AS deptId,
  6433. b.beh_dept_name AS deptName,
  6434. b.doctor_id as doctorId,
  6435. b.doctor_name as doctorName,
  6436. 0 AS consultationNum,
  6437. 0 AS consultationMRNum,
  6438. 0 AS operationNameNum,
  6439. 0 AS operationTimeNum,
  6440. 0 AS operation15MinuteNum,
  6441. 0 AS operationMRNum,
  6442. 0 AS crisisNum,
  6443. 0 AS crisisMRNum,
  6444. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6445. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6446. 0 AS beHosGT31DaysMRNum
  6447. FROM
  6448. (
  6449. SELECT DISTINCT
  6450. a.hospital_id,
  6451. a.behospital_code,
  6452. a.beh_dept_name,
  6453. a.beh_dept_id,
  6454. a.doctor_id,
  6455. a.doctor_name
  6456. FROM
  6457. med_behospital_info a,
  6458. sys_user_dept b
  6459. WHERE
  6460. a.is_deleted = 'N'
  6461. AND b.is_deleted = 'N'
  6462. AND a.hospital_id = b.hospital_id
  6463. AND a.beh_dept_id = b.dept_id
  6464. AND TIMESTAMPDIFF(
  6465. DAY,
  6466. DATE( behospital_date ),
  6467. DATE( leave_hospital_date ))> 30
  6468. <if test="userId!=null">
  6469. AND b.user_id = #{userId}
  6470. </if>
  6471. <if test="isPlacefile != null and isPlacefile != ''">
  6472. and a.is_placefile = #{isPlacefile}
  6473. </if>
  6474. AND a.qc_type_id != 0
  6475. <if test="hospitalId != null and hospitalId != ''">
  6476. AND a.hospital_id = #{hospitalId}
  6477. </if>
  6478. <if test="isPlacefile != null and isPlacefile == 0">
  6479. <if test="startDate != null ">
  6480. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6481. </if>
  6482. <if test="endDate != null ">
  6483. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6484. </if>
  6485. </if>
  6486. <if test="isPlacefile != null and isPlacefile == 1">
  6487. <if test="startDate != null ">
  6488. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6489. </if>
  6490. <if test="endDate != null ">
  6491. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6492. </if>
  6493. </if>
  6494. <if test="doctorName != null and doctorName != ''">
  6495. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6496. </if>
  6497. <if test="deptName != null and deptName != ''">
  6498. AND a.beh_dept_name = #{deptName}
  6499. </if>
  6500. ) b
  6501. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6502. AND b.hospital_id = c.hospital_id
  6503. AND b.behospital_code = c.behospital_code
  6504. GROUP BY
  6505. b.doctor_id,
  6506. b.doctor_name
  6507. ) UNION
  6508. (
  6509. SELECT
  6510. b.beh_dept_id AS deptId,
  6511. b.beh_dept_name AS deptName,
  6512. b.doctor_id as doctorId,
  6513. b.doctor_name as doctorName,
  6514. 0 AS consultationNum,
  6515. 0 AS consultationMRNum,
  6516. 0 AS operationNameNum,
  6517. 0 AS operationTimeNum,
  6518. 0 AS operation15MinuteNum,
  6519. 0 AS operationMRNum,
  6520. 0 AS crisisNum,
  6521. 0 AS crisisMRNum,
  6522. 0 AS stageSummaryNum,
  6523. 0 AS stageSummaryMRNum,
  6524. count(*) AS beHosGT31DaysMRNum
  6525. FROM
  6526. (
  6527. SELECT DISTINCT
  6528. a.hospital_id,
  6529. a.behospital_code,
  6530. a.beh_dept_name,
  6531. a.beh_dept_id,
  6532. a.doctor_id,
  6533. a.doctor_name
  6534. FROM
  6535. med_behospital_info a,
  6536. sys_user_dept b
  6537. WHERE
  6538. a.is_deleted = 'N'
  6539. AND b.is_deleted = 'N'
  6540. AND a.hospital_id = b.hospital_id
  6541. AND a.beh_dept_id = b.dept_id
  6542. AND TIMESTAMPDIFF(
  6543. DAY,
  6544. DATE( behospital_date ),
  6545. DATE( leave_hospital_date ))> 31
  6546. <if test="userId!=null">
  6547. AND b.user_id = #{userId}
  6548. </if>
  6549. <if test="isPlacefile != null and isPlacefile != ''">
  6550. and a.is_placefile = #{isPlacefile}
  6551. </if>
  6552. AND a.qc_type_id != 0
  6553. <if test="hospitalId != null and hospitalId != ''">
  6554. AND a.hospital_id = #{hospitalId}
  6555. </if>
  6556. <if test="isPlacefile != null and isPlacefile == 0">
  6557. <if test="startDate != null ">
  6558. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6559. </if>
  6560. <if test="endDate != null ">
  6561. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6562. </if>
  6563. </if>
  6564. <if test="isPlacefile != null and isPlacefile == 1">
  6565. <if test="startDate != null ">
  6566. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6567. </if>
  6568. <if test="endDate != null ">
  6569. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6570. </if>
  6571. </if>
  6572. <if test="doctorName != null and doctorName != ''">
  6573. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6574. </if>
  6575. <if test="deptName != null and deptName != ''">
  6576. AND a.beh_dept_name = #{deptName}
  6577. </if>
  6578. ) b
  6579. GROUP BY
  6580. b.doctor_id,
  6581. b.doctor_name
  6582. )
  6583. ) tt
  6584. GROUP BY
  6585. tt.doctorName
  6586. ) t
  6587. <if test="asc != null and asc !=''">
  6588. order by
  6589. <choose>
  6590. <when test='asc=="deptId"'>deptId asc</when>
  6591. <when test='asc=="deptName"'>deptName asc</when>
  6592. <when test='asc=="doctorName"'>doctorName asc</when>
  6593. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6594. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6595. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6596. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6597. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6598. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6599. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6600. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6601. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6602. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6603. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6604. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6605. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6606. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6607. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6608. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6609. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6610. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6611. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6612. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6613. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6614. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6615. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6616. <otherwise>doctorName asc</otherwise>
  6617. </choose>
  6618. </if>
  6619. <if test="desc != null and desc!=''">
  6620. order by
  6621. <choose>
  6622. <when test='desc=="deptId"'>deptId desc</when>
  6623. <when test='desc=="doctorName"'>doctorName desc</when>
  6624. <when test='desc=="deptName"'>deptName desc</when>
  6625. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6626. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6627. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6628. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6629. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6630. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6631. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6632. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6633. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6634. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6635. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6636. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6637. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6638. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6639. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6640. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6641. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6642. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6643. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6644. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6645. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6646. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6647. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6648. <otherwise>doctorName desc</otherwise>
  6649. </choose>
  6650. </if>
  6651. </select>
  6652. <!-- 非医嘱离院病人记录-->
  6653. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6654. SELECT
  6655. count(*)
  6656. FROM
  6657. med_behospital_info a,
  6658. med_home_page b
  6659. WHERE
  6660. a.is_deleted = 'N'
  6661. AND b.is_deleted = 'N'
  6662. AND a.hospital_id = b.hospital_id
  6663. AND a.behospital_code = b.behospital_code
  6664. AND b.leave_hospital_type = '非医嘱离院'
  6665. <if test="isPlacefile != null and isPlacefile != ''">
  6666. and a.is_placefile = #{isPlacefile}
  6667. </if>
  6668. AND a.qc_type_id != 0
  6669. <if test="hospitalId != null and hospitalId != ''">
  6670. AND a.hospital_id = #{hospitalId}
  6671. </if>
  6672. <if test="isPlacefile != null and isPlacefile == 0">
  6673. <if test="startDate != null and startDate != ''">
  6674. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6675. </if>
  6676. <if test="endDate != null and endDate != ''">
  6677. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6678. </if>
  6679. </if>
  6680. <if test="isPlacefile != null and isPlacefile == 1">
  6681. <if test="startDate != null and startDate != ''">
  6682. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6683. </if>
  6684. <if test="endDate != null and endDate != ''">
  6685. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6686. </if>
  6687. </if>
  6688. </select>
  6689. <!-- 31天内再入院记录-->
  6690. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6691. SELECT
  6692. count(*)
  6693. FROM
  6694. (
  6695. SELECT
  6696. r1.file_code,
  6697. r1.diagnose,
  6698. r1.behospital_code AS behospitalCode,
  6699. r1.behospital_date AS behospitalDate,
  6700. r1.leave_hospital_date AS leaveHospitalDate,
  6701. r2.behospital_code AS lastBehospitalCode,
  6702. r2.behospital_date AS lastBehospitalDate,
  6703. r2.leave_hospital_date AS lastLeaveHospitalDate,
  6704. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  6705. FROM
  6706. (
  6707. SELECT
  6708. ( @rownum := @rownum + 1 ) AS rownum,
  6709. t1.file_code,
  6710. t1.diagnose,
  6711. t1.behospital_code,
  6712. t1.behospital_date,
  6713. t1.leave_hospital_date
  6714. FROM
  6715. (
  6716. SELECT
  6717. tt1.file_code,
  6718. tt1.diagnose,
  6719. tt2.behospital_code,
  6720. tt2.behospital_date,
  6721. tt2.leave_hospital_date
  6722. FROM
  6723. (
  6724. SELECT
  6725. a.file_code,
  6726. a.diagnose
  6727. FROM
  6728. med_behospital_info a
  6729. WHERE
  6730. a.is_deleted = 'N'
  6731. <if test="isPlacefile != null and isPlacefile != ''">
  6732. and a.is_placefile = #{isPlacefile}
  6733. </if>
  6734. AND a.qc_type_id != 0
  6735. AND IFNULL( a.diagnose, '' )!= ''
  6736. AND IFNULL( a.file_code, '' )!= ''
  6737. <if test="hospitalId != null and hospitalId != ''">
  6738. AND a.hospital_id = #{hospitalId}
  6739. </if>
  6740. <if test="isPlacefile != null and isPlacefile == 0">
  6741. <if test="startDate != null and startDate != ''">
  6742. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6743. </if>
  6744. <if test="endDate != null and endDate != ''">
  6745. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6746. </if>
  6747. </if>
  6748. <if test="isPlacefile != null and isPlacefile == 1">
  6749. <if test="startDate != null and startDate != ''">
  6750. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6751. </if>
  6752. <if test="endDate != null and endDate != ''">
  6753. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6754. </if>
  6755. </if>
  6756. GROUP BY
  6757. a.file_code,
  6758. a.diagnose
  6759. HAVING
  6760. count(*)> 1
  6761. ) tt1,
  6762. med_behospital_info tt2
  6763. WHERE
  6764. tt2.is_deleted = 'N'
  6765. <if test="isPlacefile != null and isPlacefile != ''">
  6766. and tt2.is_placefile = #{isPlacefile}
  6767. </if>
  6768. AND tt2.qc_type_id != 0
  6769. AND tt1.file_code = tt2.file_code
  6770. AND tt1.diagnose = tt2.diagnose
  6771. <if test="hospitalId != null and hospitalId != ''">
  6772. AND tt2.hospital_id = #{hospitalId}
  6773. </if>
  6774. <if test="isPlacefile != null and isPlacefile == 0">
  6775. <if test="startDate != null and startDate != ''">
  6776. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6777. </if>
  6778. <if test="endDate != null and endDate != ''">
  6779. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6780. </if>
  6781. </if>
  6782. <if test="isPlacefile != null and isPlacefile == 1">
  6783. <if test="startDate != null and startDate != ''">
  6784. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6785. </if>
  6786. <if test="endDate != null and endDate != ''">
  6787. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6788. </if>
  6789. </if>
  6790. ORDER BY
  6791. tt1.file_code,
  6792. tt1.diagnose,
  6793. tt2.behospital_date DESC
  6794. ) t1,
  6795. ( SELECT @rownum := 0 ) r
  6796. ) r1
  6797. LEFT JOIN (
  6798. SELECT
  6799. ( @INDEX := @INDEX + 1 ) AS rownum,
  6800. t2.file_code,
  6801. t2.diagnose,
  6802. t2.behospital_code,
  6803. t2.behospital_date,
  6804. t2.leave_hospital_date
  6805. FROM
  6806. (
  6807. SELECT
  6808. tt1.file_code,
  6809. tt1.diagnose,
  6810. tt2.behospital_code,
  6811. tt2.behospital_date,
  6812. tt2.leave_hospital_date
  6813. FROM
  6814. (
  6815. SELECT
  6816. a.file_code,
  6817. a.diagnose
  6818. FROM
  6819. med_behospital_info a
  6820. WHERE
  6821. a.is_deleted = 'N'
  6822. <if test="isPlacefile != null and isPlacefile != ''">
  6823. and a.is_placefile = #{isPlacefile}
  6824. </if>
  6825. AND a.qc_type_id != 0
  6826. AND IFNULL( a.diagnose, '' )!= ''
  6827. AND IFNULL( a.file_code, '' )!= ''
  6828. <if test="hospitalId != null and hospitalId != ''">
  6829. AND a.hospital_id = #{hospitalId}
  6830. </if>
  6831. <if test="isPlacefile != null and isPlacefile == 0">
  6832. <if test="startDate != null and startDate != ''">
  6833. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6834. </if>
  6835. <if test="endDate != null and endDate != ''">
  6836. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6837. </if>
  6838. </if>
  6839. <if test="isPlacefile != null and isPlacefile == 1">
  6840. <if test="startDate != null and startDate != ''">
  6841. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6842. </if>
  6843. <if test="endDate != null and endDate != ''">
  6844. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6845. </if>
  6846. </if>
  6847. GROUP BY
  6848. a.file_code,
  6849. a.diagnose
  6850. HAVING
  6851. count(*)> 1
  6852. ) tt1,
  6853. med_behospital_info tt2
  6854. WHERE
  6855. tt2.is_deleted = 'N'
  6856. <if test="isPlacefile != null and isPlacefile != ''">
  6857. and tt2.is_placefile = #{isPlacefile}
  6858. </if>
  6859. AND tt2.qc_type_id != 0
  6860. AND tt1.file_code = tt2.file_code
  6861. AND tt1.diagnose = tt2.diagnose
  6862. <if test="hospitalId != null and hospitalId != ''">
  6863. AND tt2.hospital_id = #{hospitalId}
  6864. </if>
  6865. <if test="isPlacefile != null and isPlacefile == 0">
  6866. <if test="startDate != null and startDate != ''">
  6867. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6868. </if>
  6869. <if test="endDate != null and endDate != ''">
  6870. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6871. </if>
  6872. </if>
  6873. <if test="isPlacefile != null and isPlacefile == 1">
  6874. <if test="startDate != null and startDate != ''">
  6875. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6876. </if>
  6877. <if test="endDate != null and endDate != ''">
  6878. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6879. </if>
  6880. </if>
  6881. ORDER BY
  6882. tt1.file_code,
  6883. tt1.diagnose,
  6884. tt2.behospital_date DESC
  6885. ) t2,(
  6886. SELECT
  6887. @INDEX := 0
  6888. ) r
  6889. ) r2 ON r1.file_code = r2.file_code
  6890. AND r1.rownum = r2.rownum - 1
  6891. ) t
  6892. WHERE
  6893. t.diffDays IS NOT NULL
  6894. AND t.diffDays BETWEEN 0
  6895. AND 31
  6896. </select>
  6897. <!-- 病案首页质控病历数统计-全院(首页)-->
  6898. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  6899. SELECT
  6900. count( * ) AS mrNum,
  6901. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  6902. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  6903. SUM( c.`level` = '合格' ) AS firstLevelNum,
  6904. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  6905. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  6906. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  6907. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  6908. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  6909. FROM
  6910. med_behospital_info a,
  6911. med_qcresult_cases c
  6912. WHERE
  6913. a.is_deleted = 'N'
  6914. AND c.is_deleted = 'N'
  6915. AND a.hospital_id = c.hospital_id
  6916. AND a.behospital_code = c.behospital_code
  6917. AND c.cases_id = 243
  6918. <if test="isPlacefile != null and isPlacefile != ''">
  6919. and a.is_placefile = #{isPlacefile}
  6920. </if>
  6921. AND a.qc_type_id != 0
  6922. <if test="hospitalId != null and hospitalId != ''">
  6923. AND a.hospital_id = #{hospitalId}
  6924. </if>
  6925. <if test="isPlacefile != null and isPlacefile == 0">
  6926. <if test="startDate != null and startDate != ''">
  6927. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6928. </if>
  6929. <if test="endDate != null and endDate != ''">
  6930. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6931. </if>
  6932. </if>
  6933. <if test="isPlacefile != null and isPlacefile == 1">
  6934. <if test="startDate != null and startDate != ''">
  6935. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6936. </if>
  6937. <if test="endDate != null and endDate != ''">
  6938. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6939. </if>
  6940. </if>
  6941. </select>
  6942. <!-- 病案首页完整率统计-全院(首页)-->
  6943. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  6944. SELECT
  6945. h1.emptyNum,
  6946. h1.mrNum,
  6947. h2.entryNum,
  6948. h1.mrNum * h2.entryNum AS entryTotleNum,
  6949. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  6950. CONCAT(
  6951. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  6952. '%'
  6953. ) AS emptyPercentStr
  6954. FROM
  6955. (
  6956. SELECT
  6957. sum( d.rule_type = 1 ) AS emptyNum,
  6958. count( DISTINCT a.behospital_code ) AS mrNum
  6959. FROM
  6960. med_behospital_info a,
  6961. med_qcresult_cases b,
  6962. med_qcresult_detail c,
  6963. qc_cases_entry d
  6964. WHERE
  6965. a.is_deleted = 'N'
  6966. AND b.is_deleted = 'N'
  6967. AND c.is_deleted = 'N'
  6968. AND d.is_deleted = 'N'
  6969. AND a.hospital_id = b.hospital_id
  6970. AND a.hospital_id = c.hospital_id
  6971. AND a.behospital_code = b.behospital_code
  6972. AND a.behospital_code = c.behospital_code
  6973. AND b.cases_id = c.cases_id
  6974. AND c.cases_id = d.cases_id
  6975. AND c.cases_entry_id = d.id
  6976. <if test="isPlacefile != null and isPlacefile != ''">
  6977. and a.is_placefile = #{isPlacefile}
  6978. </if>
  6979. AND d.cases_id = 243
  6980. AND a.qc_type_id != 0
  6981. <if test="hospitalId != null and hospitalId != ''">
  6982. AND a.hospital_id = #{hospitalId}
  6983. </if>
  6984. <if test="isPlacefile != null and isPlacefile == 0">
  6985. <if test="startDate != null and startDate != ''">
  6986. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6987. </if>
  6988. <if test="endDate != null and endDate != ''">
  6989. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6990. </if>
  6991. </if>
  6992. <if test="isPlacefile != null and isPlacefile == 1">
  6993. <if test="startDate != null and startDate != ''">
  6994. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6995. </if>
  6996. <if test="endDate != null and endDate != ''">
  6997. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6998. </if>
  6999. </if>
  7000. ) h1,(
  7001. SELECT
  7002. count(*) AS entryNum
  7003. FROM
  7004. qc_cases_entry
  7005. WHERE
  7006. is_deleted = 'N'
  7007. AND cases_id = 243
  7008. ) h2
  7009. </select>
  7010. <!-- 离院病人评分详情页-->
  7011. <select id="getAge" resultType="java.util.Map">
  7012. SELECT
  7013. a.behospital_code as behospitalCode,
  7014. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  7015. FROM
  7016. med_home_page a
  7017. WHERE
  7018. a.is_deleted = 'N'
  7019. AND a.hospital_id = #{hospitalId}
  7020. AND a.behospital_code IN
  7021. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  7022. '${item}'
  7023. </foreach>
  7024. </select>
  7025. <!-- 离院病人评分详情页-->
  7026. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7027. SELECT
  7028. t.*
  7029. FROM
  7030. (SELECT DISTINCT
  7031. t1.hospital_id AS hospitalId,
  7032. t1.behospital_code AS behospitalCode,
  7033. t1.bed_code AS bedCode,
  7034. t1.LEVEL AS LEVEL,
  7035. t1.grade_type AS gradeType,
  7036. t1.score_res AS scoreRes,
  7037. t1.scoreBn,
  7038. t1.NAME AS NAME,
  7039. t1.sex AS sex,
  7040. t1.beh_dept_id AS behDeptId,
  7041. t1.beh_dept_name AS behDeptName,
  7042. t1.doctor_id AS doctorId,
  7043. t1.doctor_name AS doctorName,
  7044. t1.beh_doctor_id AS behDoctorId,
  7045. t1.beh_doctor_name AS behDoctorName,
  7046. t1.director_doctor_id AS directorDoctorId,
  7047. t1.director_doctor_name AS directorDoctorName,
  7048. t1.birthday AS birthday,
  7049. t1.behospital_date AS behospitalDate,
  7050. t1.leave_hospital_date AS leaveHospitalDate,
  7051. t1.placefile_date AS placefileDate,
  7052. t1.gmt_create AS gradeTime,
  7053. t1.diagnose,
  7054. t1.ward_name AS wardName,
  7055. t1.checkStatus,
  7056. t1.mrStatus,
  7057. t1.chName,
  7058. t1.mrName,
  7059. t1.chTime,
  7060. t1.mrTime,
  7061. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7062. t1.file_code AS fileCode
  7063. FROM
  7064. (
  7065. SELECT be.*,
  7066. ifnull(mci.status,0) AS checkStatus,
  7067. ifnull(hm_mci.status,0) AS mrStatus,
  7068. mci.check_name as chName,
  7069. e.score_res as scoreBn,
  7070. hm_mci.check_name as mrName,
  7071. mci.gmt_create as chTime,
  7072. hm_mci.gmt_create as mrTime
  7073. FROM
  7074. (
  7075. SELECT DISTINCT
  7076. tt1.*
  7077. FROM
  7078. (
  7079. SELECT
  7080. b.*,
  7081. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7082. c.grade_type,
  7083. c.score_res,
  7084. c.gmt_create
  7085. FROM
  7086. (
  7087. SELECT DISTINCT
  7088. a.hospital_id,
  7089. a.behospital_code,
  7090. a.bed_code,
  7091. a.NAME,
  7092. a.sex,
  7093. a.beh_dept_id,
  7094. a.beh_dept_name,
  7095. a.birthday,
  7096. a.behospital_date,
  7097. a.leave_hospital_date,
  7098. a.doctor_id,
  7099. a.doctor_name,
  7100. a.beh_doctor_id,
  7101. a.beh_doctor_name,
  7102. a.director_doctor_id,
  7103. a.director_doctor_name,
  7104. a.diagnose,
  7105. a.placefile_date,
  7106. a.ward_name,
  7107. a.file_code
  7108. FROM
  7109. med_behospital_info a
  7110. WHERE
  7111. a.is_deleted = 'N'
  7112. AND a.qc_type_id != 0
  7113. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7114. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7115. </if>
  7116. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7117. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7118. </if>
  7119. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7120. <if test="qcResultShortPageVO.startDate != null ">
  7121. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7122. </if>
  7123. <if test="qcResultShortPageVO.endDate != null ">
  7124. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7125. </if>
  7126. </if>
  7127. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7128. <if test="qcResultShortPageVO.startDate != null ">
  7129. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7130. </if>
  7131. <if test="qcResultShortPageVO.endDate != null">
  7132. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7133. </if>
  7134. </if>
  7135. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7136. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7137. </if>
  7138. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7139. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7140. </if>
  7141. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7142. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7143. </if>
  7144. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7145. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7146. </if>
  7147. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7148. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7149. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7150. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7151. </if>
  7152. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7153. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7154. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7155. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7156. </if>
  7157. ) b
  7158. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7159. AND b.hospital_id = c.hospital_id
  7160. AND b.behospital_code = c.behospital_code
  7161. ) tt1
  7162. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7163. ,med_medical_record tt2,
  7164. qc_mode tt3
  7165. WHERE
  7166. tt2.is_deleted = 'N'
  7167. AND tt3.is_deleted = 'N'
  7168. AND tt1.hospital_id = tt2.hospital_id
  7169. AND tt1.behospital_code = tt2.behospital_code
  7170. AND tt2.mode_id = tt3.id
  7171. AND tt3.`name` = '手术记录'
  7172. </if>
  7173. ) be
  7174. left join med_check_info mci
  7175. on mci.is_deleted = 'N'
  7176. and mci.check_type = 0
  7177. and be.hospital_id = mci.hospital_id
  7178. and be.behospital_code = mci.behospital_code
  7179. left join med_check_info hm_mci
  7180. on hm_mci.is_deleted = 'N'
  7181. and hm_mci.check_type = 1
  7182. and be.hospital_id = hm_mci.hospital_id
  7183. and be.behospital_code = hm_mci.behospital_code
  7184. LEFT JOIN med_qcresult_cases e
  7185. on be.behospital_code = e.behospital_code
  7186. and be.hospital_id = e.hospital_id
  7187. AND e.is_deleted = 'N'
  7188. and e.cases_id = 243
  7189. )t1
  7190. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7191. ,med_home_page t2
  7192. WHERE
  7193. t2.is_deleted = 'N'
  7194. AND t1.hospital_id = t2.hospital_id
  7195. AND t1.behospital_code = t2.behospital_code
  7196. AND (
  7197. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7198. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7199. )
  7200. </if>
  7201. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7202. , med_medical_record b,
  7203. med_medical_record_content c,
  7204. med_home_page t2
  7205. WHERE
  7206. b.is_deleted = 'N'
  7207. and c.is_deleted = 'N'
  7208. and t2.is_deleted = 'N'
  7209. and t1.hospital_id = b.hospital_id
  7210. and t1.hospital_id = c.hospital_id
  7211. and t1.hospital_id = t2.hospital_id
  7212. AND t1.behospital_code = b.behospital_code
  7213. AND t1.behospital_code = t2.behospital_code
  7214. AND b.rec_id = c.rec_id
  7215. and b.mode_id = '24'
  7216. </if>
  7217. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7218. ,med_home_page t2
  7219. WHERE
  7220. t2.is_deleted = 'N'
  7221. AND t1.hospital_id = t2.hospital_id
  7222. AND t1.behospital_code = t2.behospital_code
  7223. AND t2.leave_hospital_type = '非医嘱离院'
  7224. </if>
  7225. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7226. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7227. AND t1.hospital_id = t2.hospital_id
  7228. AND t1.behospital_code = t2.behospital_code
  7229. </if>
  7230. )t
  7231. where 1=1
  7232. <if test="qcResultShortPageVO.checkStatus != null">
  7233. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7234. </if>
  7235. <if test="qcResultShortPageVO.mrStatus != null">
  7236. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7237. </if>
  7238. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7239. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7240. </if>
  7241. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7242. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7243. </if>
  7244. <if test="qcResultShortPageVO.chTimeStart != null ">
  7245. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7246. </if>
  7247. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7248. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7249. </if>
  7250. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7251. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7252. </if>
  7253. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7254. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7255. </if>
  7256. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7257. AND t.`level` = #{qcResultShortPageVO.level}
  7258. </if>
  7259. </select>
  7260. <!-- 离院病人评分详情页-科室-->
  7261. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  7262. SELECT
  7263. t.*
  7264. FROM
  7265. (SELECT DISTINCT
  7266. t1.hospital_id AS hospitalId,
  7267. t1.behospital_code AS behospitalCode,
  7268. t1.bed_code AS bedCode,
  7269. t1.LEVEL AS LEVEL,
  7270. t1.grade_type AS gradeType,
  7271. t1.score_res AS scoreRes,
  7272. t1.scoreBn,
  7273. t1.NAME AS NAME,
  7274. t1.sex AS sex,
  7275. t1.beh_dept_id AS behDeptId,
  7276. t1.beh_dept_name AS behDeptName,
  7277. t1.doctor_id AS doctorId,
  7278. t1.doctor_name AS doctorName,
  7279. t1.beh_doctor_id AS behDoctorId,
  7280. t1.beh_doctor_name AS behDoctorName,
  7281. t1.director_doctor_id AS directorDoctorId,
  7282. t1.director_doctor_name AS directorDoctorName,
  7283. t1.birthday AS birthday,
  7284. t1.behospital_date AS behospitalDate,
  7285. t1.leave_hospital_date AS leaveHospitalDate,
  7286. t1.placefile_date AS placefileDate,
  7287. t1.gmt_create AS gradeTime,
  7288. t1.diagnose,
  7289. t1.ward_name AS wardName,
  7290. t1.checkStatus,
  7291. t1.mrStatus,
  7292. t1.chName,
  7293. t1.mrName,
  7294. t1.chTime,
  7295. t1.mrTime,
  7296. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7297. t1.file_code AS fileCode
  7298. FROM
  7299. (
  7300. SELECT be.*,
  7301. ifnull(mci.status,0) AS checkStatus,
  7302. ifnull(hm_mci.status,0) AS mrStatus,
  7303. mci.check_name as chName,
  7304. e.score_res as scoreBn,
  7305. hm_mci.check_name as mrName,
  7306. mci.gmt_create as chTime,
  7307. hm_mci.gmt_create as mrTime
  7308. FROM
  7309. (
  7310. SELECT DISTINCT
  7311. tt1.*
  7312. FROM
  7313. (
  7314. SELECT
  7315. b.*,
  7316. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7317. c.grade_type,
  7318. c.score_res,
  7319. c.gmt_create
  7320. FROM
  7321. (
  7322. SELECT DISTINCT
  7323. a.hospital_id,
  7324. a.behospital_code,
  7325. a.bed_code,
  7326. a.NAME,
  7327. a.sex,
  7328. a.beh_dept_id,
  7329. a.beh_dept_name,
  7330. a.birthday,
  7331. a.behospital_date,
  7332. a.leave_hospital_date,
  7333. a.doctor_id,
  7334. a.doctor_name,
  7335. a.beh_doctor_id,
  7336. a.beh_doctor_name,
  7337. a.director_doctor_id,
  7338. a.director_doctor_name,
  7339. a.diagnose,
  7340. a.placefile_date,
  7341. a.ward_name,
  7342. a.file_code
  7343. FROM
  7344. med_behospital_info a,
  7345. sys_user_dept b
  7346. WHERE
  7347. a.is_deleted = 'N'
  7348. AND b.is_deleted = 'N'
  7349. AND a.hospital_id = b.hospital_id
  7350. AND a.beh_dept_id = b.dept_id
  7351. AND a.qc_type_id != 0
  7352. <if test="qcResultShortPageVO.userId!=null">
  7353. AND b.user_id = #{qcResultShortPageVO.userId}
  7354. </if>
  7355. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7356. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7357. </if>
  7358. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7359. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7360. </if>
  7361. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7362. <if test="qcResultShortPageVO.startDate != null ">
  7363. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7364. </if>
  7365. <if test="qcResultShortPageVO.endDate != null ">
  7366. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7367. </if>
  7368. </if>
  7369. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7370. <if test="qcResultShortPageVO.startDate != null ">
  7371. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7372. </if>
  7373. <if test="qcResultShortPageVO.endDate != null">
  7374. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7375. </if>
  7376. </if>
  7377. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7378. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7379. </if>
  7380. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7381. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7382. </if>
  7383. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7384. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7385. </if>
  7386. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7387. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7388. </if>
  7389. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7390. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7391. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7392. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7393. </if>
  7394. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7395. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7396. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7397. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7398. </if>
  7399. ) b
  7400. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7401. AND b.hospital_id = c.hospital_id
  7402. AND b.behospital_code = c.behospital_code
  7403. ) tt1
  7404. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7405. ,med_medical_record tt2,
  7406. qc_mode tt3
  7407. WHERE
  7408. tt2.is_deleted = 'N'
  7409. AND tt3.is_deleted = 'N'
  7410. AND tt1.hospital_id = tt2.hospital_id
  7411. AND tt1.behospital_code = tt2.behospital_code
  7412. AND tt2.mode_id = tt3.id
  7413. AND tt3.`name` = '手术记录'
  7414. </if>
  7415. ) be
  7416. left join med_check_info mci
  7417. on mci.is_deleted = 'N'
  7418. and mci.check_type = 0
  7419. and be.hospital_id = mci.hospital_id
  7420. and be.behospital_code = mci.behospital_code
  7421. left join med_check_info hm_mci
  7422. on hm_mci.is_deleted = 'N'
  7423. and hm_mci.check_type = 1
  7424. and be.hospital_id = hm_mci.hospital_id
  7425. and be.behospital_code = hm_mci.behospital_code
  7426. LEFT JOIN med_qcresult_cases e
  7427. on be.behospital_code = e.behospital_code
  7428. and be.hospital_id = e.hospital_id
  7429. AND e.is_deleted = 'N'
  7430. and e.cases_id = 243
  7431. )t1
  7432. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7433. ,med_home_page t2
  7434. WHERE
  7435. t2.is_deleted = 'N'
  7436. AND t1.hospital_id = t2.hospital_id
  7437. AND t1.behospital_code = t2.behospital_code
  7438. AND (
  7439. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7440. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7441. )
  7442. </if>
  7443. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7444. , med_medical_record b,
  7445. med_medical_record_content c,
  7446. med_home_page t2
  7447. WHERE
  7448. b.is_deleted = 'N'
  7449. and c.is_deleted = 'N'
  7450. and t2.is_deleted = 'N'
  7451. and t1.hospital_id = b.hospital_id
  7452. and t1.hospital_id = c.hospital_id
  7453. and t1.hospital_id = t2.hospital_id
  7454. AND t1.behospital_code = b.behospital_code
  7455. AND t1.behospital_code = t2.behospital_code
  7456. AND b.rec_id = c.rec_id
  7457. and b.mode_id = '24'
  7458. </if>
  7459. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7460. ,med_home_page t2
  7461. WHERE
  7462. t2.is_deleted = 'N'
  7463. AND t1.hospital_id = t2.hospital_id
  7464. AND t1.behospital_code = t2.behospital_code
  7465. AND t2.leave_hospital_type = '非医嘱离院'
  7466. </if>
  7467. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7468. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7469. AND t1.hospital_id = t2.hospital_id
  7470. AND t1.behospital_code = t2.behospital_code
  7471. </if>
  7472. )t
  7473. where 1=1
  7474. <if test="qcResultShortPageVO.checkStatus != null">
  7475. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7476. </if>
  7477. <if test="qcResultShortPageVO.mrStatus != null">
  7478. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7479. </if>
  7480. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7481. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7482. </if>
  7483. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7484. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7485. </if>
  7486. <if test="qcResultShortPageVO.chTimeStart != null ">
  7487. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7488. </if>
  7489. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7490. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7491. </if>
  7492. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7493. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7494. </if>
  7495. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7496. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7497. </if>
  7498. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7499. AND t.`level` = #{qcResultShortPageVO.level}
  7500. </if>
  7501. </select>
  7502. <!-- 病案首页改善率统计(首页)-->
  7503. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7504. SELECT
  7505. t2.homePageMRNum,
  7506. t1.improveNum,
  7507. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  7508. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7509. t1.improveToPassNum,
  7510. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  7511. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7512. t1.improveToFullNum,
  7513. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  7514. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7515. FROM
  7516. (
  7517. SELECT
  7518. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7519. sum( d.score_res = 20 ) AS improveToFullNum,
  7520. count(*) AS improveNum
  7521. FROM
  7522. med_behospital_info a,
  7523. med_home_page b,
  7524. med_qcresult_info c,
  7525. med_qcresult_cases d,
  7526. (
  7527. SELECT
  7528. m4.*
  7529. FROM
  7530. med_behospital_info m1,
  7531. med_home_page m2,
  7532. med_qcresult_info m3,
  7533. med_qcresult_cases m4
  7534. WHERE
  7535. m1.is_deleted = 'N'
  7536. AND m2.is_deleted = 'N'
  7537. AND m3.is_deleted = 'Y'
  7538. AND m4.is_deleted = 'Y'
  7539. AND m1.hospital_id = m2.hospital_id
  7540. AND m1.hospital_id = m3.hospital_id
  7541. AND m1.hospital_id = m4.hospital_id
  7542. AND m1.behospital_code = m2.behospital_code
  7543. AND m1.behospital_code = m3.behospital_code
  7544. AND m1.behospital_code = m4.behospital_code
  7545. AND m3.gmt_create = m4.gmt_create
  7546. AND m3.have_home_page = 1
  7547. AND m4.cases_id = 243
  7548. <if test="isPlacefile != null and isPlacefile != ''">
  7549. and m1.is_placefile = #{isPlacefile}
  7550. </if>
  7551. AND m1.qc_type_id != 0
  7552. <if test="hospitalId != null and hospitalId != ''">
  7553. AND m1.hospital_id = #{hospitalId}
  7554. </if>
  7555. <if test="isPlacefile != null and isPlacefile == 0">
  7556. <if test="startDate != null and startDate != ''">
  7557. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7558. </if>
  7559. <if test="endDate != null and endDate != ''">
  7560. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7561. </if>
  7562. </if>
  7563. <if test="isPlacefile != null and isPlacefile == 1">
  7564. <if test="startDate != null and startDate != ''">
  7565. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7566. </if>
  7567. <if test="endDate != null and endDate != ''">
  7568. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7569. </if>
  7570. </if>
  7571. GROUP BY
  7572. m1.behospital_code
  7573. ORDER BY
  7574. m1.behospital_code,
  7575. m4.gmt_create
  7576. ) e
  7577. WHERE
  7578. a.is_deleted = 'N'
  7579. AND b.is_deleted = 'N'
  7580. AND c.is_deleted = 'N'
  7581. AND d.is_deleted = 'N'
  7582. AND a.hospital_id = b.hospital_id
  7583. AND a.hospital_id = c.hospital_id
  7584. AND a.hospital_id = d.hospital_id
  7585. AND a.hospital_id = e.hospital_id
  7586. AND a.behospital_code = b.behospital_code
  7587. AND a.behospital_code = c.behospital_code
  7588. AND a.behospital_code = d.behospital_code
  7589. AND a.behospital_code = e.behospital_code
  7590. AND d.cases_id = 243
  7591. AND d.score_res > e.score_res
  7592. <if test="isPlacefile != null and isPlacefile != ''">
  7593. and a.is_placefile = #{isPlacefile}
  7594. </if>
  7595. AND a.qc_type_id != 0
  7596. <if test="hospitalId != null and hospitalId != ''">
  7597. AND a.hospital_id = #{hospitalId}
  7598. </if>
  7599. <if test="isPlacefile != null and isPlacefile == 0">
  7600. <if test="startDate != null and startDate != ''">
  7601. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7602. </if>
  7603. <if test="endDate != null and endDate != ''">
  7604. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7605. </if>
  7606. </if>
  7607. <if test="isPlacefile != null and isPlacefile == 1">
  7608. <if test="startDate != null and startDate != ''">
  7609. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7610. </if>
  7611. <if test="endDate != null and endDate != ''">
  7612. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7613. </if>
  7614. </if>
  7615. ) t1,
  7616. (
  7617. SELECT
  7618. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7619. FROM
  7620. med_behospital_info a,
  7621. med_home_page b,
  7622. med_qcresult_info c
  7623. WHERE
  7624. a.is_deleted = 'N'
  7625. AND b.is_deleted = 'N'
  7626. AND a.hospital_id = b.hospital_id
  7627. AND a.hospital_id = c.hospital_id
  7628. AND a.behospital_code = b.behospital_code
  7629. AND a.behospital_code = c.behospital_code
  7630. AND a.qc_type_id != 0
  7631. <if test="isPlacefile != null and isPlacefile != ''">
  7632. and a.is_placefile = #{isPlacefile}
  7633. </if>
  7634. <if test="hospitalId != null and hospitalId != ''">
  7635. AND a.hospital_id = #{hospitalId}
  7636. </if>
  7637. <if test="isPlacefile != null and isPlacefile == 0">
  7638. <if test="startDate != null and startDate != ''">
  7639. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7640. </if>
  7641. <if test="endDate != null and endDate != ''">
  7642. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7643. </if>
  7644. </if>
  7645. <if test="isPlacefile != null and isPlacefile == 1">
  7646. <if test="startDate != null and startDate != ''">
  7647. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7648. </if>
  7649. <if test="endDate != null and endDate != ''">
  7650. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7651. </if>
  7652. </if>
  7653. ) t2
  7654. </select>
  7655. <!-- 质控核查统计(内页)-->
  7656. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7657. SELECT
  7658. t.*
  7659. FROM
  7660. (SELECT
  7661. mr.beh_dept_id AS deptId,
  7662. mr.beh_dept_name AS deptName,
  7663. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7664. ck.checkedNum AS checkedNum,
  7665. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7666. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7667. hmmr_t.homePageMRNum,
  7668. improve_t.improveNum,
  7669. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7670. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7671. improve_t.improveToPassNum,
  7672. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7673. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7674. improve_t.improveToFullNum,
  7675. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7676. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7677. FROM
  7678. (
  7679. SELECT
  7680. a.beh_dept_id,
  7681. a.beh_dept_name,
  7682. count(*) AS mrNum
  7683. FROM
  7684. med_behospital_info a,
  7685. med_qcresult_info b
  7686. WHERE
  7687. a.is_deleted = 'N'
  7688. AND b.is_deleted = 'N'
  7689. AND a.hospital_id = b.hospital_id
  7690. AND a.behospital_code = b.behospital_code
  7691. AND a.qc_type_id != 0
  7692. <if test="isPlacefile != null and isPlacefile != ''">
  7693. and a.is_placefile = #{isPlacefile}
  7694. </if>
  7695. <if test="hospitalId != null and hospitalId != ''">
  7696. AND a.hospital_id = #{hospitalId}
  7697. </if>
  7698. <if test="isPlacefile != null and isPlacefile == 0">
  7699. <if test="startDate != null and startDate != ''">
  7700. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7701. </if>
  7702. <if test="endDate != null and endDate != ''">
  7703. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7704. </if>
  7705. </if>
  7706. <if test="isPlacefile != null and isPlacefile == 1">
  7707. <if test="startDate != null and startDate != ''">
  7708. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7709. </if>
  7710. <if test="endDate != null and endDate != ''">
  7711. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7712. </if>
  7713. </if>
  7714. <if test="deptName != null and deptName != ''">
  7715. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7716. </if>
  7717. GROUP BY
  7718. a.beh_dept_id,
  7719. a.beh_dept_name
  7720. ) mr
  7721. LEFT JOIN (
  7722. SELECT
  7723. a.beh_dept_id,
  7724. a.beh_dept_name,
  7725. count(*) AS checkedNum
  7726. FROM
  7727. med_behospital_info a,
  7728. med_qcresult_info b,
  7729. med_check_info c
  7730. WHERE
  7731. a.is_deleted = 'N'
  7732. AND b.is_deleted = 'N'
  7733. AND c.is_deleted = 'N'
  7734. AND a.hospital_id = b.hospital_id
  7735. AND a.hospital_id = c.hospital_id
  7736. AND a.behospital_code = b.behospital_code
  7737. AND a.behospital_code = c.behospital_code
  7738. AND a.qc_type_id != 0
  7739. AND ifnull(c.`status`,0) = 1
  7740. AND c.check_type = 0
  7741. <if test="isPlacefile != null and isPlacefile != ''">
  7742. and a.is_placefile = #{isPlacefile}
  7743. </if>
  7744. <if test="hospitalId != null and hospitalId != ''">
  7745. AND a.hospital_id = #{hospitalId}
  7746. </if>
  7747. <if test="isPlacefile != null and isPlacefile == 0">
  7748. <if test="startDate != null and startDate != ''">
  7749. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7750. </if>
  7751. <if test="endDate != null and endDate != ''">
  7752. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7753. </if>
  7754. </if>
  7755. <if test="isPlacefile != null and isPlacefile == 1">
  7756. <if test="startDate != null and startDate != ''">
  7757. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7758. </if>
  7759. <if test="endDate != null and endDate != ''">
  7760. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7761. </if>
  7762. </if>
  7763. <if test="deptName != null and deptName != ''">
  7764. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7765. </if>
  7766. GROUP BY
  7767. a.beh_dept_id,
  7768. a.beh_dept_name
  7769. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  7770. AND mr.beh_dept_name = ck.beh_dept_name
  7771. LEFT JOIN (
  7772. SELECT
  7773. a.beh_dept_id,
  7774. a.beh_dept_name,
  7775. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7776. FROM
  7777. med_behospital_info a,
  7778. med_home_page b,
  7779. med_qcresult_info c
  7780. WHERE
  7781. a.is_deleted = 'N'
  7782. AND b.is_deleted = 'N'
  7783. AND a.hospital_id = b.hospital_id
  7784. AND a.hospital_id = c.hospital_id
  7785. AND a.behospital_code = b.behospital_code
  7786. AND a.behospital_code = c.behospital_code
  7787. AND a.qc_type_id != 0
  7788. <if test="isPlacefile != null and isPlacefile != ''">
  7789. and a.is_placefile = #{isPlacefile}
  7790. </if>
  7791. <if test="hospitalId != null and hospitalId != ''">
  7792. AND a.hospital_id = #{hospitalId}
  7793. </if>
  7794. <if test="isPlacefile != null and isPlacefile == 0">
  7795. <if test="startDate != null and startDate != ''">
  7796. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7797. </if>
  7798. <if test="endDate != null and endDate != ''">
  7799. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7800. </if>
  7801. </if>
  7802. <if test="isPlacefile != null and isPlacefile == 1">
  7803. <if test="startDate != null and startDate != ''">
  7804. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7805. </if>
  7806. <if test="endDate != null and endDate != ''">
  7807. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7808. </if>
  7809. </if>
  7810. <if test="deptName != null and deptName != ''">
  7811. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7812. </if>
  7813. GROUP BY
  7814. a.beh_dept_id,
  7815. a.beh_dept_name
  7816. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  7817. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  7818. LEFT JOIN (
  7819. SELECT
  7820. a.beh_dept_id,
  7821. a.beh_dept_name,
  7822. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7823. sum( d.score_res = 20 ) AS improveToFullNum,
  7824. count(*) AS improveNum
  7825. FROM
  7826. med_behospital_info a,
  7827. med_home_page b,
  7828. med_qcresult_info c,
  7829. med_qcresult_cases d,
  7830. (
  7831. SELECT
  7832. m4.*
  7833. FROM
  7834. med_behospital_info m1,
  7835. med_home_page m2,
  7836. med_qcresult_info m3,
  7837. med_qcresult_cases m4
  7838. WHERE
  7839. m1.is_deleted = 'N'
  7840. AND m2.is_deleted = 'N'
  7841. AND m3.is_deleted = 'Y'
  7842. AND m4.is_deleted = 'Y'
  7843. AND m1.hospital_id = m2.hospital_id
  7844. AND m1.hospital_id = m3.hospital_id
  7845. AND m1.hospital_id = m4.hospital_id
  7846. AND m1.behospital_code = m2.behospital_code
  7847. AND m1.behospital_code = m3.behospital_code
  7848. AND m1.behospital_code = m4.behospital_code
  7849. AND m3.gmt_create = m4.gmt_create
  7850. AND m3.have_home_page = 1
  7851. AND m4.cases_id = 243
  7852. <if test="isPlacefile != null and isPlacefile != ''">
  7853. and m1.is_placefile = #{isPlacefile}
  7854. </if>
  7855. AND m1.qc_type_id != 0
  7856. <if test="hospitalId != null and hospitalId != ''">
  7857. AND m1.hospital_id = #{hospitalId}
  7858. </if>
  7859. <if test="isPlacefile != null and isPlacefile == 0">
  7860. <if test="startDate != null and startDate != ''">
  7861. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7862. </if>
  7863. <if test="endDate != null and endDate != ''">
  7864. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7865. </if>
  7866. </if>
  7867. <if test="isPlacefile != null and isPlacefile == 1">
  7868. <if test="startDate != null and startDate != ''">
  7869. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7870. </if>
  7871. <if test="endDate != null and endDate != ''">
  7872. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7873. </if>
  7874. </if>
  7875. <if test="deptName != null and deptName != ''">
  7876. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7877. </if>
  7878. GROUP BY
  7879. m1.behospital_code
  7880. ORDER BY
  7881. m1.behospital_code,
  7882. m4.gmt_create
  7883. ) e
  7884. WHERE
  7885. a.is_deleted = 'N'
  7886. AND b.is_deleted = 'N'
  7887. AND c.is_deleted = 'N'
  7888. AND d.is_deleted = 'N'
  7889. AND a.hospital_id = b.hospital_id
  7890. AND a.hospital_id = c.hospital_id
  7891. AND a.hospital_id = d.hospital_id
  7892. AND a.hospital_id = e.hospital_id
  7893. AND a.behospital_code = b.behospital_code
  7894. AND a.behospital_code = c.behospital_code
  7895. AND a.behospital_code = d.behospital_code
  7896. AND a.behospital_code = e.behospital_code
  7897. AND d.cases_id = 243
  7898. AND d.score_res > e.score_res
  7899. <if test="hospitalId != null and hospitalId != ''">
  7900. AND a.hospital_id = #{hospitalId}
  7901. </if>
  7902. <if test="isPlacefile != null and isPlacefile == 0">
  7903. <if test="startDate != null and startDate != ''">
  7904. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7905. </if>
  7906. <if test="endDate != null and endDate != ''">
  7907. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7908. </if>
  7909. </if>
  7910. <if test="isPlacefile != null and isPlacefile == 1">
  7911. <if test="startDate != null and startDate != ''">
  7912. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7913. </if>
  7914. <if test="endDate != null and endDate != ''">
  7915. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7916. </if>
  7917. </if>
  7918. <if test="deptName != null and deptName != ''">
  7919. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7920. </if>
  7921. GROUP BY
  7922. a.beh_dept_id,
  7923. a.beh_dept_name
  7924. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  7925. AND mr.beh_dept_name = improve_t.beh_dept_name
  7926. ) t
  7927. <if test="asc != null and asc !=''">
  7928. order by
  7929. <choose>
  7930. <when test='asc=="deptId"'>deptId asc</when>
  7931. <when test='asc=="deptName"'>deptName asc</when>
  7932. <when test='asc=="mrNum"'>mrNum asc</when>
  7933. <when test='asc=="checkedNum"'>checkedNum asc</when>
  7934. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  7935. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  7936. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  7937. <when test='asc=="improveNum"'>improveNum asc</when>
  7938. <when test='asc=="improvePercent"'>improvePercent asc</when>
  7939. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  7940. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  7941. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  7942. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  7943. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  7944. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  7945. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  7946. <otherwise>deptName asc</otherwise>
  7947. </choose>
  7948. </if>
  7949. <if test="desc != null and desc!=''">
  7950. order by
  7951. <choose>
  7952. <when test='desc=="deptId"'>deptId desc</when>
  7953. <when test='desc=="deptName"'>deptName desc</when>
  7954. <when test='desc=="mrNum"'>mrNum desc</when>
  7955. <when test='desc=="checkedNum"'>checkedNum desc</when>
  7956. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  7957. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  7958. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  7959. <when test='desc=="improveNum"'>improveNum desc</when>
  7960. <when test='desc=="improvePercent"'>improvePercent desc</when>
  7961. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  7962. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  7963. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  7964. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  7965. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  7966. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  7967. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  7968. <otherwise>deptName desc</otherwise>
  7969. </choose>
  7970. </if>
  7971. </select>
  7972. <!-- 质控核查统计-科室(内页)-->
  7973. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  7974. SELECT
  7975. t.*
  7976. FROM
  7977. (SELECT
  7978. mr.beh_dept_id AS deptId,
  7979. mr.beh_dept_name AS deptName,
  7980. mr.doctorId,
  7981. mr.doctorName,
  7982. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7983. ck.checkedNum AS checkedNum,
  7984. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7985. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7986. hmmr_t.homePageMRNum,
  7987. improve_t.improveNum,
  7988. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7989. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7990. improve_t.improveToPassNum,
  7991. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7992. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7993. improve_t.improveToFullNum,
  7994. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7995. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7996. FROM
  7997. (
  7998. SELECT
  7999. a.beh_dept_id,
  8000. a.beh_dept_name,
  8001. a.doctor_id as doctorId,
  8002. a.doctor_name as doctorName,
  8003. count(*) AS mrNum
  8004. FROM
  8005. med_behospital_info a,
  8006. med_qcresult_info b,
  8007. sys_user_dept c
  8008. WHERE
  8009. a.is_deleted = 'N'
  8010. AND b.is_deleted = 'N'
  8011. AND c.is_deleted = 'N'
  8012. AND a.hospital_id = b.hospital_id
  8013. AND a.hospital_id = c.hospital_id
  8014. AND a.beh_dept_id = c.dept_id
  8015. AND a.behospital_code = b.behospital_code
  8016. AND a.qc_type_id != 0
  8017. <if test="userId!=null">
  8018. AND c.user_id = #{userId}
  8019. </if>
  8020. <if test="isPlacefile != null and isPlacefile != ''">
  8021. and a.is_placefile = #{isPlacefile}
  8022. </if>
  8023. <if test="hospitalId != null and hospitalId != ''">
  8024. AND a.hospital_id = #{hospitalId}
  8025. </if>
  8026. <if test="isPlacefile != null and isPlacefile == 0">
  8027. <if test="startDate != null and startDate != ''">
  8028. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8029. </if>
  8030. <if test="endDate != null and endDate != ''">
  8031. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8032. </if>
  8033. </if>
  8034. <if test="isPlacefile != null and isPlacefile == 1">
  8035. <if test="startDate != null and startDate != ''">
  8036. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8037. </if>
  8038. <if test="endDate != null and endDate != ''">
  8039. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8040. </if>
  8041. </if>
  8042. <if test="deptName != null and deptName != ''">
  8043. and a.beh_dept_name = #{deptName}
  8044. </if>
  8045. <if test="doctorName != null and doctorName != ''">
  8046. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8047. </if>
  8048. GROUP BY
  8049. a.doctor_id,
  8050. a.doctor_name
  8051. ) mr
  8052. LEFT JOIN (
  8053. SELECT
  8054. a.beh_dept_id,
  8055. a.beh_dept_name,
  8056. a.doctor_id as doctorId,
  8057. a.doctor_name as doctorName,
  8058. count(*) AS checkedNum
  8059. FROM
  8060. med_behospital_info a,
  8061. med_qcresult_info b,
  8062. med_check_info c,
  8063. sys_user_dept d
  8064. WHERE
  8065. a.is_deleted = 'N'
  8066. AND b.is_deleted = 'N'
  8067. AND c.is_deleted = 'N'
  8068. AND d.is_deleted = 'N'
  8069. AND a.hospital_id = b.hospital_id
  8070. AND a.hospital_id = c.hospital_id
  8071. AND a.hospital_id = d.hospital_id
  8072. AND a.behospital_code = b.behospital_code
  8073. AND a.behospital_code = c.behospital_code
  8074. AND a.beh_dept_id = d.dept_id
  8075. AND a.qc_type_id != 0
  8076. AND ifnull(c.`status`,0) = 1
  8077. AND c.check_type = 0
  8078. <if test="userId!=null">
  8079. AND d.user_id = #{userId}
  8080. </if>
  8081. <if test="isPlacefile != null and isPlacefile != ''">
  8082. and a.is_placefile = #{isPlacefile}
  8083. </if>
  8084. <if test="hospitalId != null and hospitalId != ''">
  8085. AND a.hospital_id = #{hospitalId}
  8086. </if>
  8087. <if test="isPlacefile != null and isPlacefile == 0">
  8088. <if test="startDate != null and startDate != ''">
  8089. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8090. </if>
  8091. <if test="endDate != null and endDate != ''">
  8092. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8093. </if>
  8094. </if>
  8095. <if test="isPlacefile != null and isPlacefile == 1">
  8096. <if test="startDate != null and startDate != ''">
  8097. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8098. </if>
  8099. <if test="endDate != null and endDate != ''">
  8100. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8101. </if>
  8102. </if>
  8103. <if test="deptName != null and deptName != ''">
  8104. and a.beh_dept_name = #{deptName}
  8105. </if>
  8106. <if test="doctorName != null and doctorName != ''">
  8107. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8108. </if>
  8109. GROUP BY
  8110. a.doctor_id,
  8111. a.doctor_name
  8112. ) ck ON mr.doctorId = ck.doctorId
  8113. AND mr.doctorName = ck.doctorName
  8114. LEFT JOIN (
  8115. SELECT
  8116. a.beh_dept_id,
  8117. a.beh_dept_name,
  8118. a.doctor_id as doctorId,
  8119. a.doctor_name as doctorName,
  8120. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8121. FROM
  8122. med_behospital_info a,
  8123. med_home_page b,
  8124. med_qcresult_info c,
  8125. sys_user_dept d
  8126. WHERE
  8127. a.is_deleted = 'N'
  8128. AND b.is_deleted = 'N'
  8129. AND c.is_deleted = 'N'
  8130. AND d.is_deleted = 'N'
  8131. AND a.hospital_id = b.hospital_id
  8132. AND a.hospital_id = c.hospital_id
  8133. AND a.hospital_id = d.hospital_id
  8134. AND a.behospital_code = b.behospital_code
  8135. AND a.behospital_code = c.behospital_code
  8136. AND a.beh_dept_id = d.dept_id
  8137. AND a.qc_type_id != 0
  8138. <if test="userId!=null">
  8139. AND d.user_id = #{userId}
  8140. </if>
  8141. <if test="isPlacefile != null and isPlacefile != ''">
  8142. and a.is_placefile = #{isPlacefile}
  8143. </if>
  8144. <if test="hospitalId != null and hospitalId != ''">
  8145. AND a.hospital_id = #{hospitalId}
  8146. </if>
  8147. <if test="isPlacefile != null and isPlacefile == 0">
  8148. <if test="startDate != null and startDate != ''">
  8149. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8150. </if>
  8151. <if test="endDate != null and endDate != ''">
  8152. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8153. </if>
  8154. </if>
  8155. <if test="isPlacefile != null and isPlacefile == 1">
  8156. <if test="startDate != null and startDate != ''">
  8157. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8158. </if>
  8159. <if test="endDate != null and endDate != ''">
  8160. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8161. </if>
  8162. </if>
  8163. <if test="deptName != null and deptName != ''">
  8164. and a.beh_dept_name = #{deptName}
  8165. </if>
  8166. <if test="doctorName != null and doctorName != ''">
  8167. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8168. </if>
  8169. GROUP BY
  8170. a.doctor_id,
  8171. a.doctor_name
  8172. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8173. AND mr.doctorName = hmmr_t.doctorName
  8174. LEFT JOIN (
  8175. SELECT
  8176. a.beh_dept_id,
  8177. a.beh_dept_name,
  8178. a.doctor_id as doctorId,
  8179. a.doctor_name as doctorName,
  8180. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8181. sum( d.score_res = 20 ) AS improveToFullNum,
  8182. count(*) AS improveNum
  8183. FROM
  8184. med_behospital_info a,
  8185. med_home_page b,
  8186. med_qcresult_info c,
  8187. med_qcresult_cases d,
  8188. sys_user_dept f,
  8189. (
  8190. SELECT
  8191. m4.*
  8192. FROM
  8193. med_behospital_info m1,
  8194. med_home_page m2,
  8195. med_qcresult_info m3,
  8196. med_qcresult_cases m4
  8197. WHERE
  8198. m1.is_deleted = 'N'
  8199. AND m2.is_deleted = 'N'
  8200. AND m3.is_deleted = 'Y'
  8201. AND m4.is_deleted = 'Y'
  8202. AND m1.hospital_id = m2.hospital_id
  8203. AND m1.hospital_id = m3.hospital_id
  8204. AND m1.hospital_id = m4.hospital_id
  8205. AND m1.behospital_code = m2.behospital_code
  8206. AND m1.behospital_code = m3.behospital_code
  8207. AND m1.behospital_code = m4.behospital_code
  8208. AND m3.gmt_create = m4.gmt_create
  8209. AND m3.have_home_page = 1
  8210. AND m4.cases_id = 243
  8211. <if test="isPlacefile != null and isPlacefile != ''">
  8212. and m1.is_placefile = #{isPlacefile}
  8213. </if>
  8214. AND m1.qc_type_id != 0
  8215. <if test="hospitalId != null and hospitalId != ''">
  8216. AND m1.hospital_id = #{hospitalId}
  8217. </if>
  8218. <if test="isPlacefile != null and isPlacefile == 0">
  8219. <if test="startDate != null and startDate != ''">
  8220. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8221. </if>
  8222. <if test="endDate != null and endDate != ''">
  8223. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8224. </if>
  8225. </if>
  8226. <if test="isPlacefile != null and isPlacefile == 1">
  8227. <if test="startDate != null and startDate != ''">
  8228. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8229. </if>
  8230. <if test="endDate != null and endDate != ''">
  8231. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8232. </if>
  8233. </if>
  8234. <if test="deptName != null and deptName != ''">
  8235. and m1.beh_dept_name = #{deptName}
  8236. </if>
  8237. GROUP BY
  8238. m1.behospital_code
  8239. ORDER BY
  8240. m1.behospital_code,
  8241. m4.gmt_create
  8242. ) e
  8243. WHERE
  8244. a.is_deleted = 'N'
  8245. AND b.is_deleted = 'N'
  8246. AND c.is_deleted = 'N'
  8247. AND d.is_deleted = 'N'
  8248. AND f.is_deleted = 'N'
  8249. AND a.hospital_id = b.hospital_id
  8250. AND a.hospital_id = c.hospital_id
  8251. AND a.hospital_id = d.hospital_id
  8252. AND a.hospital_id = e.hospital_id
  8253. AND a.hospital_id = f.hospital_id
  8254. AND a.behospital_code = b.behospital_code
  8255. AND a.behospital_code = c.behospital_code
  8256. AND a.behospital_code = d.behospital_code
  8257. AND a.behospital_code = e.behospital_code
  8258. AND a.beh_dept_id = f.dept_id
  8259. <if test="userId!=null">
  8260. AND f.user_id = #{userId}
  8261. </if>
  8262. AND d.cases_id = 243
  8263. AND d.score_res > e.score_res
  8264. <if test="hospitalId != null and hospitalId != ''">
  8265. AND a.hospital_id = #{hospitalId}
  8266. </if>
  8267. <if test="isPlacefile != null and isPlacefile == 0">
  8268. <if test="startDate != null and startDate != ''">
  8269. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8270. </if>
  8271. <if test="endDate != null and endDate != ''">
  8272. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8273. </if>
  8274. </if>
  8275. <if test="isPlacefile != null and isPlacefile == 1">
  8276. <if test="startDate != null and startDate != ''">
  8277. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8278. </if>
  8279. <if test="endDate != null and endDate != ''">
  8280. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8281. </if>
  8282. </if>
  8283. <if test="doctorName != null and doctorName != ''">
  8284. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8285. </if>
  8286. <if test="deptName != null and deptName != ''">
  8287. and a.beh_dept_name = #{deptName}
  8288. </if>
  8289. GROUP BY
  8290. a.doctor_id,
  8291. a.doctor_name
  8292. ) improve_t ON mr.doctorId = improve_t.doctorId
  8293. AND mr.doctorName = improve_t.doctorName
  8294. ) t
  8295. <if test="asc != null and asc !=''">
  8296. order by
  8297. <choose>
  8298. <when test='asc=="deptId"'>deptId asc</when>
  8299. <when test='asc=="deptName"'>deptName asc</when>
  8300. <when test='asc=="doctorName"'>doctorName asc</when>
  8301. <when test='asc=="mrNum"'>mrNum asc</when>
  8302. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8303. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8304. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8305. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8306. <when test='asc=="improveNum"'>improveNum asc</when>
  8307. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8308. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8309. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8310. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8311. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8312. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8313. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8314. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8315. <otherwise>doctorName asc</otherwise>
  8316. </choose>
  8317. </if>
  8318. <if test="desc != null and desc!=''">
  8319. order by
  8320. <choose>
  8321. <when test='desc=="deptId"'>deptId desc</when>
  8322. <when test='desc=="deptName"'>deptName desc</when>
  8323. <when test='desc=="doctorName"'>doctorName desc</when>
  8324. <when test='desc=="mrNum"'>mrNum desc</when>
  8325. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8326. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8327. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8328. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8329. <when test='desc=="improveNum"'>improveNum desc</when>
  8330. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8331. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8332. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8333. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8334. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8335. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8336. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8337. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8338. <otherwise>deptName desc</otherwise>
  8339. </choose>
  8340. </if>
  8341. </select>
  8342. <!-- 离院病人评分详情页导出-->
  8343. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  8344. SELECT
  8345. f1.behDeptId,
  8346. f1.behDeptName,
  8347. f1.doctorName,
  8348. f1.patName,
  8349. f1.behospitalCode,
  8350. f1.hospitalId,
  8351. f1.behospitalDate,
  8352. f1.leaveHospitalDate,
  8353. f1.score,
  8354. f2.avgScore,
  8355. f1.scoreBn,
  8356. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8357. f1.msg,
  8358. f1.caseName,
  8359. </if>
  8360. f1.checkStatus,
  8361. f1.mrStatus,
  8362. f1.chName,
  8363. f1.mrName,
  8364. f1.chTime,
  8365. f1.mrTime
  8366. FROM
  8367. (SELECT
  8368. t.doctorName,
  8369. t.`name` AS patName,
  8370. t.behospitalCode AS behospitalCode,
  8371. t.behospitalDate AS behospitalDate,
  8372. t.leaveHospitalDate AS leaveHospitalDate,
  8373. qi.score_res AS score,
  8374. t.scoreBn,
  8375. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8376. qd.msg AS msg,
  8377. qc.NAME AS caseName,
  8378. </if>
  8379. t.behDeptId,
  8380. t.behDeptName,
  8381. t.hospitalId,
  8382. t.checkStatus,
  8383. t.mrStatus,
  8384. t.chName,
  8385. t.mrName,
  8386. t.chTime,
  8387. t.mrTime
  8388. FROM
  8389. (SELECT DISTINCT
  8390. t1.hospital_id AS hospitalId,
  8391. t1.behospital_code AS behospitalCode,
  8392. t1.bed_code AS bedCode,
  8393. t1.LEVEL AS LEVEL,
  8394. t1.grade_type AS gradeType,
  8395. t1.score_res AS scoreRes,
  8396. t1.scoreBn,
  8397. t1.NAME AS NAME,
  8398. t1.sex AS sex,
  8399. t1.beh_dept_id AS behDeptId,
  8400. t1.beh_dept_name AS behDeptName,
  8401. t1.doctor_id AS doctorId,
  8402. t1.doctor_name AS doctorName,
  8403. t1.beh_doctor_id AS behDoctorId,
  8404. t1.beh_doctor_name AS behDoctorName,
  8405. t1.director_doctor_id AS directorDoctorId,
  8406. t1.director_doctor_name AS directorDoctorName,
  8407. t1.birthday AS birthday,
  8408. t1.behospital_date AS behospitalDate,
  8409. t1.leave_hospital_date AS leaveHospitalDate,
  8410. t1.placefile_date AS placefileDate,
  8411. t1.gmt_create AS gradeTime,
  8412. t1.diagnose,
  8413. t1.ward_name AS wardName,
  8414. t1.checkStatus,
  8415. t1.mrStatus,
  8416. t1.chName,
  8417. t1.mrName,
  8418. t1.chTime,
  8419. t1.mrTime,
  8420. t2.age,
  8421. t1.file_code AS fileCode
  8422. FROM
  8423. (
  8424. SELECT be.*,
  8425. ifnull(mci.status,0) AS checkStatus,
  8426. ifnull(hm_mci.status,0) AS mrStatus,
  8427. mci.check_name as chName,
  8428. e.score_res as scoreBn,
  8429. hm_mci.check_name as mrName,
  8430. mci.gmt_create as chTime,
  8431. hm_mci.gmt_create as mrTime
  8432. FROM
  8433. (
  8434. SELECT DISTINCT
  8435. tt1.*
  8436. FROM
  8437. (
  8438. SELECT
  8439. b.*,
  8440. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8441. c.grade_type,
  8442. c.score_res,
  8443. c.gmt_create
  8444. FROM
  8445. (
  8446. SELECT DISTINCT
  8447. a.hospital_id,
  8448. a.behospital_code,
  8449. a.bed_code,
  8450. a.NAME,
  8451. a.sex,
  8452. a.beh_dept_id,
  8453. a.beh_dept_name,
  8454. a.birthday,
  8455. a.behospital_date,
  8456. a.leave_hospital_date,
  8457. a.doctor_id,
  8458. a.doctor_name,
  8459. a.beh_doctor_id,
  8460. a.beh_doctor_name,
  8461. a.director_doctor_id,
  8462. a.director_doctor_name,
  8463. a.diagnose,
  8464. a.placefile_date,
  8465. a.ward_name,
  8466. a.file_code
  8467. FROM
  8468. med_behospital_info a
  8469. WHERE
  8470. a.is_deleted = 'N'
  8471. AND a.qc_type_id != 0
  8472. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8473. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8474. </if>
  8475. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8476. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8477. </if>
  8478. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8479. <if test="qcResultShortPageVO.startDate != null ">
  8480. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8481. </if>
  8482. <if test="qcResultShortPageVO.endDate != null ">
  8483. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8484. </if>
  8485. </if>
  8486. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8487. <if test="qcResultShortPageVO.startDate != null ">
  8488. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8489. </if>
  8490. <if test="qcResultShortPageVO.endDate != null">
  8491. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8492. </if>
  8493. </if>
  8494. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8495. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8496. </if>
  8497. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8498. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8499. </if>
  8500. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8501. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8502. </if>
  8503. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8504. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8505. </if>
  8506. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8507. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8508. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8509. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8510. </if>
  8511. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8512. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8513. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8514. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8515. </if>
  8516. ) b
  8517. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8518. AND b.hospital_id = c.hospital_id
  8519. AND b.behospital_code = c.behospital_code
  8520. ) tt1
  8521. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8522. ,med_medical_record tt2,
  8523. qc_mode tt3
  8524. WHERE
  8525. tt2.is_deleted = 'N'
  8526. AND tt3.is_deleted = 'N'
  8527. AND tt1.hospital_id = tt2.hospital_id
  8528. AND tt1.behospital_code = tt2.behospital_code
  8529. AND tt2.mode_id = tt3.id
  8530. AND tt3.`name` = '手术记录'
  8531. </if>
  8532. ) be
  8533. left join med_check_info mci
  8534. on mci.is_deleted = 'N'
  8535. and mci.check_type = 0
  8536. and be.hospital_id = mci.hospital_id
  8537. and be.behospital_code = mci.behospital_code
  8538. left join med_check_info hm_mci
  8539. on hm_mci.is_deleted = 'N'
  8540. and hm_mci.check_type = 1
  8541. and be.hospital_id = hm_mci.hospital_id
  8542. and be.behospital_code = hm_mci.behospital_code
  8543. LEFT JOIN med_qcresult_cases e
  8544. on be.behospital_code = e.behospital_code
  8545. and be.hospital_id = e.hospital_id
  8546. AND e.is_deleted = 'N'
  8547. and e.cases_id = 243
  8548. )t1
  8549. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8550. ,med_home_page t2
  8551. WHERE
  8552. t2.is_deleted = 'N'
  8553. AND t1.hospital_id = t2.hospital_id
  8554. AND t1.behospital_code = t2.behospital_code
  8555. AND (
  8556. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  8557. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8558. )
  8559. </if>
  8560. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8561. ,med_home_page t2
  8562. WHERE
  8563. t2.is_deleted = 'N'
  8564. AND t1.hospital_id = t2.hospital_id
  8565. AND t1.behospital_code = t2.behospital_code
  8566. AND t2.return_to_type = '死亡'
  8567. </if>
  8568. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8569. ,med_home_page t2
  8570. WHERE
  8571. t2.is_deleted = 'N'
  8572. AND t1.hospital_id = t2.hospital_id
  8573. AND t1.behospital_code = t2.behospital_code
  8574. AND t2.leave_hospital_type = '非医嘱离院'
  8575. </if>
  8576. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8577. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8578. AND t1.hospital_id = t2.hospital_id
  8579. AND t1.behospital_code = t2.behospital_code
  8580. </if>
  8581. )t
  8582. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8583. AND t.hospitalId = qi.hospital_id
  8584. AND t.behospitalCode = qi.behospital_code
  8585. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8586. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  8587. AND t.hospitalId = qd.hospital_id
  8588. AND t.behospitalCode = qd.behospital_code
  8589. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  8590. AND qd.cases_id = qc.id
  8591. </if>
  8592. where 1=1
  8593. <if test="qcResultShortPageVO.checkStatus != null">
  8594. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8595. </if>
  8596. <if test="qcResultShortPageVO.mrStatus != null">
  8597. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8598. </if>
  8599. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8600. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8601. </if>
  8602. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8603. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8604. </if>
  8605. <if test="qcResultShortPageVO.chTimeStart != null ">
  8606. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8607. </if>
  8608. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8609. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8610. </if>
  8611. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8612. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8613. </if>
  8614. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8615. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8616. </if>
  8617. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8618. AND t.`level` = #{qcResultShortPageVO.level}
  8619. </if>)f1,(SELECT
  8620. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8621. t.behDeptId,
  8622. t.behDeptName
  8623. FROM
  8624. (SELECT DISTINCT
  8625. t1.hospital_id AS hospitalId,
  8626. t1.behospital_code AS behospitalCode,
  8627. t1.bed_code AS bedCode,
  8628. t1.LEVEL AS LEVEL,
  8629. t1.grade_type AS gradeType,
  8630. t1.score_res AS scoreRes,
  8631. t1.NAME AS NAME,
  8632. t1.sex AS sex,
  8633. t1.beh_dept_id AS behDeptId,
  8634. t1.beh_dept_name AS behDeptName,
  8635. t1.doctor_id AS doctorId,
  8636. t1.doctor_name AS doctorName,
  8637. t1.beh_doctor_id AS behDoctorId,
  8638. t1.beh_doctor_name AS behDoctorName,
  8639. t1.director_doctor_id AS directorDoctorId,
  8640. t1.director_doctor_name AS directorDoctorName,
  8641. t1.birthday AS birthday,
  8642. t1.behospital_date AS behospitalDate,
  8643. t1.leave_hospital_date AS leaveHospitalDate,
  8644. t1.placefile_date AS placefileDate,
  8645. t1.gmt_create AS gradeTime,
  8646. t1.diagnose,
  8647. t1.ward_name AS wardName,
  8648. t1.checkStatus,
  8649. t1.mrStatus,
  8650. t1.chName,
  8651. t1.mrName,
  8652. t1.chTime,
  8653. t1.mrTime,
  8654. t2.age,
  8655. t1.file_code AS fileCode
  8656. FROM
  8657. (
  8658. SELECT be.*,
  8659. ifnull(mci.status,0) AS checkStatus,
  8660. ifnull(hm_mci.status,0) AS mrStatus,
  8661. mci.check_name as chName,
  8662. hm_mci.check_name as mrName,
  8663. mci.gmt_create as chTime,
  8664. hm_mci.gmt_create as mrTime
  8665. FROM
  8666. (
  8667. SELECT DISTINCT
  8668. tt1.*
  8669. FROM
  8670. (
  8671. SELECT
  8672. b.*,
  8673. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8674. c.grade_type,
  8675. c.score_res,
  8676. c.gmt_create
  8677. FROM
  8678. (
  8679. SELECT DISTINCT
  8680. a.hospital_id,
  8681. a.behospital_code,
  8682. a.bed_code,
  8683. a.NAME,
  8684. a.sex,
  8685. a.beh_dept_id,
  8686. a.beh_dept_name,
  8687. a.birthday,
  8688. a.behospital_date,
  8689. a.leave_hospital_date,
  8690. a.doctor_id,
  8691. a.doctor_name,
  8692. a.beh_doctor_id,
  8693. a.beh_doctor_name,
  8694. a.director_doctor_id,
  8695. a.director_doctor_name,
  8696. a.diagnose,
  8697. a.placefile_date,
  8698. a.ward_name,
  8699. a.file_code
  8700. FROM
  8701. med_behospital_info a
  8702. WHERE
  8703. a.is_deleted = 'N'
  8704. AND a.qc_type_id != 0
  8705. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8706. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8707. </if>
  8708. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8709. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8710. </if>
  8711. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8712. <if test="qcResultShortPageVO.startDate != null ">
  8713. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8714. </if>
  8715. <if test="qcResultShortPageVO.endDate != null ">
  8716. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8717. </if>
  8718. </if>
  8719. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8720. <if test="qcResultShortPageVO.startDate != null ">
  8721. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8722. </if>
  8723. <if test="qcResultShortPageVO.endDate != null">
  8724. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8725. </if>
  8726. </if>
  8727. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8728. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8729. </if>
  8730. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8731. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8732. </if>
  8733. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8734. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8735. </if>
  8736. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8737. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8738. </if>
  8739. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8740. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8741. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8742. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8743. </if>
  8744. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8745. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8746. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8747. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8748. </if>
  8749. ) b
  8750. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8751. AND b.hospital_id = c.hospital_id
  8752. AND b.behospital_code = c.behospital_code
  8753. ) tt1
  8754. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8755. ,med_medical_record tt2,
  8756. qc_mode tt3
  8757. WHERE
  8758. tt2.is_deleted = 'N'
  8759. AND tt3.is_deleted = 'N'
  8760. AND tt1.hospital_id = tt2.hospital_id
  8761. AND tt1.behospital_code = tt2.behospital_code
  8762. AND tt2.mode_id = tt3.id
  8763. AND tt3.`name` = '手术记录'
  8764. </if>
  8765. ) be
  8766. left join med_check_info mci
  8767. on mci.is_deleted = 'N'
  8768. and mci.check_type = 0
  8769. and be.hospital_id = mci.hospital_id
  8770. and be.behospital_code = mci.behospital_code
  8771. left join med_check_info hm_mci
  8772. on hm_mci.is_deleted = 'N'
  8773. and hm_mci.check_type = 1
  8774. and be.hospital_id = hm_mci.hospital_id
  8775. and be.behospital_code = hm_mci.behospital_code
  8776. )t1
  8777. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8778. ,med_home_page t2
  8779. WHERE
  8780. t2.is_deleted = 'N'
  8781. AND t1.hospital_id = t2.hospital_id
  8782. AND t1.behospital_code = t2.behospital_code
  8783. AND (
  8784. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  8785. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8786. )
  8787. </if>
  8788. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8789. ,med_home_page t2
  8790. WHERE
  8791. t2.is_deleted = 'N'
  8792. AND t1.hospital_id = t2.hospital_id
  8793. AND t1.behospital_code = t2.behospital_code
  8794. AND t2.return_to_type = '死亡'
  8795. </if>
  8796. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8797. ,med_home_page t2
  8798. WHERE
  8799. t2.is_deleted = 'N'
  8800. AND t1.hospital_id = t2.hospital_id
  8801. AND t1.behospital_code = t2.behospital_code
  8802. AND t2.leave_hospital_type = '非医嘱离院'
  8803. </if>
  8804. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8805. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8806. AND t1.hospital_id = t2.hospital_id
  8807. AND t1.behospital_code = t2.behospital_code
  8808. </if>
  8809. )t
  8810. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8811. AND t.hospitalId = qi.hospital_id
  8812. AND t.behospitalCode = qi.behospital_code
  8813. where 1=1
  8814. <if test="qcResultShortPageVO.checkStatus != null">
  8815. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8816. </if>
  8817. <if test="qcResultShortPageVO.mrStatus != null">
  8818. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8819. </if>
  8820. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8821. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8822. </if>
  8823. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8824. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8825. </if>
  8826. <if test="qcResultShortPageVO.chTimeStart != null ">
  8827. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8828. </if>
  8829. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8830. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8831. </if>
  8832. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8833. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8834. </if>
  8835. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8836. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8837. </if>
  8838. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8839. AND t.`level` = #{qcResultShortPageVO.level}
  8840. </if>
  8841. GROUP BY
  8842. t.behDeptId,
  8843. t.behDeptName
  8844. )f2
  8845. WHERE
  8846. f1.behDeptId = f2.behDeptId
  8847. AND f1.behDeptName = f2.behDeptName
  8848. </select>
  8849. <!-- 离院病人评分详情页导出-科室-->
  8850. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  8851. SELECT
  8852. f1.behDeptId,
  8853. f1.behDeptName,
  8854. f1.doctorName,
  8855. f1.patName,
  8856. f1.behospitalCode,
  8857. f1.hospitalId,
  8858. f1.behospitalDate,
  8859. f1.leaveHospitalDate,
  8860. f1.score,
  8861. f2.avgScore,
  8862. f1.scoreBn,
  8863. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8864. f1.msg,
  8865. f1.caseName,
  8866. </if>
  8867. f1.checkStatus,
  8868. f1.mrStatus,
  8869. f1.chName,
  8870. f1.mrName,
  8871. f1.chTime,
  8872. f1.mrTime
  8873. FROM
  8874. (SELECT
  8875. t.doctorName,
  8876. t.doctorId,
  8877. t.`name` AS patName,
  8878. t.behospitalCode AS behospitalCode,
  8879. t.behospitalDate AS behospitalDate,
  8880. t.leaveHospitalDate AS leaveHospitalDate,
  8881. qi.score_res AS score,
  8882. t.scoreBn,
  8883. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8884. qd.msg AS msg,
  8885. qc.NAME AS caseName,
  8886. </if>
  8887. t.behDeptId,
  8888. t.behDeptName,
  8889. t.hospitalId,
  8890. t.checkStatus,
  8891. t.mrStatus,
  8892. t.chName,
  8893. t.mrName,
  8894. t.chTime,
  8895. t.mrTime
  8896. FROM
  8897. (SELECT DISTINCT
  8898. t1.hospital_id AS hospitalId,
  8899. t1.behospital_code AS behospitalCode,
  8900. t1.bed_code AS bedCode,
  8901. t1.LEVEL AS LEVEL,
  8902. t1.grade_type AS gradeType,
  8903. t1.score_res AS scoreRes,
  8904. t1.scoreBn,
  8905. t1.NAME AS NAME,
  8906. t1.sex AS sex,
  8907. t1.beh_dept_id AS behDeptId,
  8908. t1.beh_dept_name AS behDeptName,
  8909. t1.doctor_id AS doctorId,
  8910. t1.doctor_name AS doctorName,
  8911. t1.beh_doctor_id AS behDoctorId,
  8912. t1.beh_doctor_name AS behDoctorName,
  8913. t1.director_doctor_id AS directorDoctorId,
  8914. t1.director_doctor_name AS directorDoctorName,
  8915. t1.birthday AS birthday,
  8916. t1.behospital_date AS behospitalDate,
  8917. t1.leave_hospital_date AS leaveHospitalDate,
  8918. t1.placefile_date AS placefileDate,
  8919. t1.gmt_create AS gradeTime,
  8920. t1.diagnose,
  8921. t1.ward_name AS wardName,
  8922. t1.checkStatus,
  8923. t1.mrStatus,
  8924. t1.chName,
  8925. t1.mrName,
  8926. t1.chTime,
  8927. t1.mrTime,
  8928. t2.age,
  8929. t1.file_code AS fileCode
  8930. FROM
  8931. (
  8932. SELECT be.*,
  8933. ifnull(mci.status,0) AS checkStatus,
  8934. ifnull(hm_mci.status,0) AS mrStatus,
  8935. mci.check_name as chName,
  8936. e.score_res as scoreBn,
  8937. hm_mci.check_name as mrName,
  8938. mci.gmt_create as chTime,
  8939. hm_mci.gmt_create as mrTime
  8940. FROM
  8941. (
  8942. SELECT DISTINCT
  8943. tt1.*
  8944. FROM
  8945. (
  8946. SELECT
  8947. b.*,
  8948. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8949. c.grade_type,
  8950. c.score_res,
  8951. c.gmt_create
  8952. FROM
  8953. (
  8954. SELECT DISTINCT
  8955. a.hospital_id,
  8956. a.behospital_code,
  8957. a.bed_code,
  8958. a.NAME,
  8959. a.sex,
  8960. a.beh_dept_id,
  8961. a.beh_dept_name,
  8962. a.birthday,
  8963. a.behospital_date,
  8964. a.leave_hospital_date,
  8965. a.doctor_id,
  8966. a.doctor_name,
  8967. a.beh_doctor_id,
  8968. a.beh_doctor_name,
  8969. a.director_doctor_id,
  8970. a.director_doctor_name,
  8971. a.diagnose,
  8972. a.placefile_date,
  8973. a.ward_name,
  8974. a.file_code
  8975. FROM
  8976. med_behospital_info a,
  8977. sys_user_dept b
  8978. WHERE
  8979. a.is_deleted = 'N'
  8980. AND b.is_deleted = 'N'
  8981. AND a.hospital_id = b.hospital_id
  8982. AND a.beh_dept_id = b.dept_id
  8983. AND a.qc_type_id != 0
  8984. <if test="qcResultShortPageVO.userId!=null">
  8985. AND b.user_id = #{qcResultShortPageVO.userId}
  8986. </if>
  8987. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8988. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8989. </if>
  8990. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8991. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8992. </if>
  8993. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8994. <if test="qcResultShortPageVO.startDate != null ">
  8995. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8996. </if>
  8997. <if test="qcResultShortPageVO.endDate != null ">
  8998. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8999. </if>
  9000. </if>
  9001. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9002. <if test="qcResultShortPageVO.startDate != null ">
  9003. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9004. </if>
  9005. <if test="qcResultShortPageVO.endDate != null">
  9006. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9007. </if>
  9008. </if>
  9009. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9010. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9011. </if>
  9012. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9013. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9014. </if>
  9015. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9016. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9017. </if>
  9018. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9019. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9020. </if>
  9021. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9022. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9023. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9024. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9025. </if>
  9026. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9027. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9028. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9029. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9030. </if>
  9031. ) b
  9032. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9033. AND b.hospital_id = c.hospital_id
  9034. AND b.behospital_code = c.behospital_code
  9035. ) tt1
  9036. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9037. ,med_medical_record tt2,
  9038. qc_mode tt3
  9039. WHERE
  9040. tt2.is_deleted = 'N'
  9041. AND tt3.is_deleted = 'N'
  9042. AND tt1.hospital_id = tt2.hospital_id
  9043. AND tt1.behospital_code = tt2.behospital_code
  9044. AND tt2.mode_id = tt3.id
  9045. AND tt3.`name` = '手术记录'
  9046. </if>
  9047. ) be
  9048. left join med_check_info mci
  9049. on mci.is_deleted = 'N'
  9050. and mci.check_type = 0
  9051. and be.hospital_id = mci.hospital_id
  9052. and be.behospital_code = mci.behospital_code
  9053. left join med_check_info hm_mci
  9054. on hm_mci.is_deleted = 'N'
  9055. and hm_mci.check_type = 1
  9056. and be.hospital_id = hm_mci.hospital_id
  9057. and be.behospital_code = hm_mci.behospital_code
  9058. LEFT JOIN med_qcresult_cases e
  9059. on be.behospital_code = e.behospital_code
  9060. and be.hospital_id = e.hospital_id
  9061. AND e.is_deleted = 'N'
  9062. and e.cases_id = 243
  9063. )t1
  9064. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9065. ,med_home_page t2
  9066. WHERE
  9067. t2.is_deleted = 'N'
  9068. AND t1.hospital_id = t2.hospital_id
  9069. AND t1.behospital_code = t2.behospital_code
  9070. AND (
  9071. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9072. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9073. )
  9074. </if>
  9075. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9076. ,med_home_page t2
  9077. WHERE
  9078. t2.is_deleted = 'N'
  9079. AND t1.hospital_id = t2.hospital_id
  9080. AND t1.behospital_code = t2.behospital_code
  9081. AND t2.return_to_type = '死亡'
  9082. </if>
  9083. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9084. ,med_home_page t2
  9085. WHERE
  9086. t2.is_deleted = 'N'
  9087. AND t1.hospital_id = t2.hospital_id
  9088. AND t1.behospital_code = t2.behospital_code
  9089. AND t2.leave_hospital_type = '非医嘱离院'
  9090. </if>
  9091. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9092. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9093. AND t1.hospital_id = t2.hospital_id
  9094. AND t1.behospital_code = t2.behospital_code
  9095. </if>
  9096. )t
  9097. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9098. AND t.hospitalId = qi.hospital_id
  9099. AND t.behospitalCode = qi.behospital_code
  9100. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9101. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9102. AND t.hospitalId = qd.hospital_id
  9103. AND t.behospitalCode = qd.behospital_code
  9104. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9105. AND qd.cases_id = qc.id
  9106. </if>
  9107. where 1=1
  9108. <if test="qcResultShortPageVO.checkStatus != null">
  9109. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9110. </if>
  9111. <if test="qcResultShortPageVO.mrStatus != null">
  9112. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9113. </if>
  9114. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9115. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9116. </if>
  9117. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9118. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9119. </if>
  9120. <if test="qcResultShortPageVO.chTimeStart != null ">
  9121. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9122. </if>
  9123. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9124. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9125. </if>
  9126. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9127. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9128. </if>
  9129. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9130. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9131. </if>
  9132. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9133. AND t.`level` = #{qcResultShortPageVO.level}
  9134. </if>)f1,(SELECT
  9135. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9136. t.behDeptId,
  9137. t.behDeptName,
  9138. t.doctorId,
  9139. t.doctorName
  9140. FROM
  9141. (SELECT DISTINCT
  9142. t1.hospital_id AS hospitalId,
  9143. t1.behospital_code AS behospitalCode,
  9144. t1.bed_code AS bedCode,
  9145. t1.LEVEL AS LEVEL,
  9146. t1.grade_type AS gradeType,
  9147. t1.score_res AS scoreRes,
  9148. t1.NAME AS NAME,
  9149. t1.sex AS sex,
  9150. t1.beh_dept_id AS behDeptId,
  9151. t1.beh_dept_name AS behDeptName,
  9152. t1.doctor_id AS doctorId,
  9153. t1.doctor_name AS doctorName,
  9154. t1.beh_doctor_id AS behDoctorId,
  9155. t1.beh_doctor_name AS behDoctorName,
  9156. t1.director_doctor_id AS directorDoctorId,
  9157. t1.director_doctor_name AS directorDoctorName,
  9158. t1.birthday AS birthday,
  9159. t1.behospital_date AS behospitalDate,
  9160. t1.leave_hospital_date AS leaveHospitalDate,
  9161. t1.placefile_date AS placefileDate,
  9162. t1.gmt_create AS gradeTime,
  9163. t1.diagnose,
  9164. t1.ward_name AS wardName,
  9165. t1.checkStatus,
  9166. t1.mrStatus,
  9167. t1.chName,
  9168. t1.mrName,
  9169. t1.chTime,
  9170. t1.mrTime,
  9171. t2.age,
  9172. t1.file_code AS fileCode
  9173. FROM
  9174. (
  9175. SELECT be.*,
  9176. ifnull(mci.status,0) AS checkStatus,
  9177. ifnull(hm_mci.status,0) AS mrStatus,
  9178. mci.check_name as chName,
  9179. hm_mci.check_name as mrName,
  9180. mci.gmt_create as chTime,
  9181. hm_mci.gmt_create as mrTime
  9182. FROM
  9183. (
  9184. SELECT DISTINCT
  9185. tt1.*
  9186. FROM
  9187. (
  9188. SELECT
  9189. b.*,
  9190. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9191. c.grade_type,
  9192. c.score_res,
  9193. c.gmt_create
  9194. FROM
  9195. (
  9196. SELECT DISTINCT
  9197. a.hospital_id,
  9198. a.behospital_code,
  9199. a.bed_code,
  9200. a.NAME,
  9201. a.sex,
  9202. a.beh_dept_id,
  9203. a.beh_dept_name,
  9204. a.birthday,
  9205. a.behospital_date,
  9206. a.leave_hospital_date,
  9207. a.doctor_id,
  9208. a.doctor_name,
  9209. a.beh_doctor_id,
  9210. a.beh_doctor_name,
  9211. a.director_doctor_id,
  9212. a.director_doctor_name,
  9213. a.diagnose,
  9214. a.placefile_date,
  9215. a.ward_name,
  9216. a.file_code
  9217. FROM
  9218. med_behospital_info a,
  9219. sys_user_dept b
  9220. WHERE
  9221. a.is_deleted = 'N'
  9222. AND b.is_deleted = 'N'
  9223. AND a.hospital_id = b.hospital_id
  9224. AND a.beh_dept_id = b.dept_id
  9225. AND a.qc_type_id != 0
  9226. <if test="qcResultShortPageVO.userId!=null">
  9227. AND b.user_id = #{qcResultShortPageVO.userId}
  9228. </if>
  9229. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9230. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9231. </if>
  9232. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9233. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9234. </if>
  9235. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9236. <if test="qcResultShortPageVO.startDate != null ">
  9237. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9238. </if>
  9239. <if test="qcResultShortPageVO.endDate != null ">
  9240. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9241. </if>
  9242. </if>
  9243. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9244. <if test="qcResultShortPageVO.startDate != null ">
  9245. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9246. </if>
  9247. <if test="qcResultShortPageVO.endDate != null">
  9248. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9249. </if>
  9250. </if>
  9251. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9252. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9253. </if>
  9254. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9255. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9256. </if>
  9257. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9258. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9259. </if>
  9260. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9261. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9262. </if>
  9263. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9264. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9265. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9266. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9267. </if>
  9268. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9269. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9270. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9271. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9272. </if>
  9273. ) b
  9274. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9275. AND b.hospital_id = c.hospital_id
  9276. AND b.behospital_code = c.behospital_code
  9277. ) tt1
  9278. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9279. ,med_medical_record tt2,
  9280. qc_mode tt3
  9281. WHERE
  9282. tt2.is_deleted = 'N'
  9283. AND tt3.is_deleted = 'N'
  9284. AND tt1.hospital_id = tt2.hospital_id
  9285. AND tt1.behospital_code = tt2.behospital_code
  9286. AND tt2.mode_id = tt3.id
  9287. AND tt3.`name` = '手术记录'
  9288. </if>
  9289. ) be
  9290. left join med_check_info mci
  9291. on mci.is_deleted = 'N'
  9292. and mci.check_type = 0
  9293. and be.hospital_id = mci.hospital_id
  9294. and be.behospital_code = mci.behospital_code
  9295. left join med_check_info hm_mci
  9296. on hm_mci.is_deleted = 'N'
  9297. and hm_mci.check_type = 1
  9298. and be.hospital_id = hm_mci.hospital_id
  9299. and be.behospital_code = hm_mci.behospital_code
  9300. )t1
  9301. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9302. ,med_home_page t2
  9303. WHERE
  9304. t2.is_deleted = 'N'
  9305. AND t1.hospital_id = t2.hospital_id
  9306. AND t1.behospital_code = t2.behospital_code
  9307. AND (
  9308. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9309. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9310. )
  9311. </if>
  9312. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9313. ,med_home_page t2
  9314. WHERE
  9315. t2.is_deleted = 'N'
  9316. AND t1.hospital_id = t2.hospital_id
  9317. AND t1.behospital_code = t2.behospital_code
  9318. AND t2.return_to_type = '死亡'
  9319. </if>
  9320. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9321. ,med_home_page t2
  9322. WHERE
  9323. t2.is_deleted = 'N'
  9324. AND t1.hospital_id = t2.hospital_id
  9325. AND t1.behospital_code = t2.behospital_code
  9326. AND t2.leave_hospital_type = '非医嘱离院'
  9327. </if>
  9328. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9329. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9330. AND t1.hospital_id = t2.hospital_id
  9331. AND t1.behospital_code = t2.behospital_code
  9332. </if>
  9333. )t
  9334. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9335. AND t.hospitalId = qi.hospital_id
  9336. AND t.behospitalCode = qi.behospital_code
  9337. where 1=1
  9338. <if test="qcResultShortPageVO.checkStatus != null">
  9339. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9340. </if>
  9341. <if test="qcResultShortPageVO.mrStatus != null">
  9342. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9343. </if>
  9344. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9345. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9346. </if>
  9347. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9348. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9349. </if>
  9350. <if test="qcResultShortPageVO.chTimeStart != null ">
  9351. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9352. </if>
  9353. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9354. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9355. </if>
  9356. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9357. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9358. </if>
  9359. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9360. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9361. </if>
  9362. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9363. AND t.`level` = #{qcResultShortPageVO.level}
  9364. </if>
  9365. GROUP BY
  9366. t.behDeptId,
  9367. t.behDeptName,
  9368. t.doctorId,
  9369. t.doctorName
  9370. )f2
  9371. WHERE
  9372. f1.doctorId = f2.doctorId
  9373. AND f1.doctorName = f2.doctorName
  9374. </select>
  9375. <!--缺陷详情质控评分页导出-科室-->
  9376. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  9377. SELECT * from(
  9378. SELECT
  9379. f1.*,
  9380. f2.avgScore
  9381. FROM
  9382. (SELECT
  9383. t.*,
  9384. qi.score_res AS score,
  9385. qd.msg AS msg,
  9386. qc.NAME AS caseName
  9387. FROM
  9388. (SELECT DISTINCT
  9389. t1.hospital_id AS hospitalId,
  9390. t1.behospital_code AS behospitalCode,
  9391. t1.bed_code AS bedCode,
  9392. t1.LEVEL AS LEVEL,
  9393. t1.grade_type AS gradeType,
  9394. t1.score_res AS scoreRes,
  9395. t1.scoreBn AS scoreBn,
  9396. t1.NAME AS patName,
  9397. t1.sex AS sex,
  9398. t1.beh_dept_id AS behDeptId,
  9399. t1.beh_dept_name AS behDeptName,
  9400. t1.doctor_id AS doctorId,
  9401. t1.doctor_name AS doctorName,
  9402. t1.beh_doctor_id AS behDoctorId,
  9403. t1.beh_doctor_name AS behDoctorName,
  9404. t1.director_doctor_id AS directorDoctorId,
  9405. t1.director_doctor_name AS directorDoctorName,
  9406. t1.birthday AS birthday,
  9407. t1.behospital_date AS behospitalDate,
  9408. t1.leave_hospital_date AS leaveHospitalDate,
  9409. t1.placefile_date AS placefileDate,
  9410. t1.gmt_create AS gradeTime,
  9411. t1.diagnose AS diagnose,
  9412. t1.ward_name AS wardName,
  9413. t1.file_code AS fileCode,
  9414. t1.checkStatus AS checkStatus,
  9415. t1.mrStatus AS mrStatus,
  9416. t1.chName AS chName,
  9417. t1.mrName AS mrName,
  9418. t1.chTime AS chTime,
  9419. t1.mrTime AS mrTime
  9420. FROM
  9421. (
  9422. SELECT DISTINCT
  9423. tt1.*
  9424. FROM
  9425. (SELECT
  9426. be.*,
  9427. ifnull(mci.status,0) AS checkStatus,
  9428. ifnull(hm_mci.status,0) AS mrStatus,
  9429. mci.check_name as chName,
  9430. hm_mci.check_name as mrName,
  9431. mci.gmt_create as chTime,
  9432. e.score_res as scoreBn,
  9433. hm_mci.gmt_create as mrTime
  9434. FROM
  9435. (
  9436. SELECT DISTINCT
  9437. a.hospital_id,
  9438. a.behospital_code,
  9439. a.bed_code,
  9440. a.file_code,
  9441. b.LEVEL,
  9442. b.grade_type,
  9443. b.score_res,
  9444. a.NAME,
  9445. a.sex,
  9446. a.beh_dept_id,
  9447. a.beh_dept_name,
  9448. a.birthday,
  9449. a.behospital_date,
  9450. a.leave_hospital_date,
  9451. a.doctor_id,
  9452. a.doctor_name,
  9453. a.beh_doctor_id,
  9454. a.beh_doctor_name,
  9455. a.director_doctor_id,
  9456. a.director_doctor_name,
  9457. a.diagnose,
  9458. a.placefile_date,
  9459. a.ward_name,
  9460. b.gmt_create
  9461. FROM
  9462. med_behospital_info a,
  9463. med_qcresult_info b,
  9464. med_qcresult_detail c,
  9465. qc_cases_entry d,
  9466. sys_user_dept e
  9467. WHERE
  9468. a.is_deleted = 'N'
  9469. AND b.is_deleted = 'N'
  9470. AND c.is_deleted = 'N'
  9471. AND d.is_deleted = 'N'
  9472. AND e.is_deleted = 'N'
  9473. AND a.hospital_id = b.hospital_id
  9474. AND a.hospital_id = c.hospital_id
  9475. AND a.hospital_id = e.hospital_id
  9476. AND a.behospital_code = b.behospital_code
  9477. AND a.behospital_code = c.behospital_code
  9478. AND a.beh_dept_id = e.dept_id
  9479. AND c.cases_id = d.cases_id
  9480. AND c.cases_entry_id = d.id
  9481. AND a.qc_type_id != 0
  9482. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9483. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9484. </if>
  9485. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  9486. AND e.user_id = #{qcResultShortPageVO.userId}
  9487. </if>
  9488. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9489. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9490. </if>
  9491. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9492. <if test="qcResultShortPageVO.startDate != null ">
  9493. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9494. </if>
  9495. <if test="qcResultShortPageVO.endDate != null ">
  9496. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9497. </if>
  9498. </if>
  9499. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9500. <if test="qcResultShortPageVO.startDate != null ">
  9501. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9502. </if>
  9503. <if test="qcResultShortPageVO.endDate != null">
  9504. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9505. </if>
  9506. </if>
  9507. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9508. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9509. </if>
  9510. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9511. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9512. </if>
  9513. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9514. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  9515. </if>
  9516. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9517. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9518. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9519. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9520. </if>
  9521. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9522. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9523. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9524. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9525. </if>
  9526. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9527. AND b.`level` = #{qcResultShortPageVO.level}
  9528. </if>
  9529. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9530. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9531. </if>
  9532. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9533. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9534. </if>
  9535. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9536. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  9537. </if>
  9538. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  9539. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9540. </if>
  9541. <if test="qcResultShortPageVO.isReject != null">
  9542. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9543. </if>
  9544. <if test="qcResultShortPageVO.ruleType != null">
  9545. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9546. </if>
  9547. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9548. AND TIMESTAMPDIFF(
  9549. DAY,
  9550. DATE( a.behospital_date ),
  9551. DATE( a.leave_hospital_date ))> 30
  9552. </if>
  9553. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9554. AND TIMESTAMPDIFF(
  9555. DAY,
  9556. DATE( a.behospital_date ),
  9557. DATE( a.leave_hospital_date ))> 31
  9558. </if>
  9559. )be
  9560. left join med_check_info mci
  9561. on mci.is_deleted = 'N'
  9562. and mci.check_type = 0
  9563. and be.hospital_id = mci.hospital_id
  9564. and be.behospital_code = mci.behospital_code
  9565. left join med_check_info hm_mci
  9566. on hm_mci.is_deleted = 'N'
  9567. and hm_mci.check_type = 1
  9568. and be.hospital_id = hm_mci.hospital_id
  9569. and be.behospital_code = hm_mci.behospital_code
  9570. LEFT JOIN med_qcresult_cases e
  9571. on be.behospital_code = e.behospital_code
  9572. and be.hospital_id = e.hospital_id
  9573. AND e.is_deleted = 'N'
  9574. and e.cases_id = 243
  9575. )tt1
  9576. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9577. ,med_medical_record tt2
  9578. WHERE
  9579. tt2.is_deleted = 'N'
  9580. AND tt1.hospital_id = tt2.hospital_id
  9581. AND tt1.behospital_code = tt2.behospital_code
  9582. AND tt2.mode_id = 30
  9583. </if>
  9584. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9585. ,med_crisis_info tt2
  9586. WHERE
  9587. tt2.is_deleted = 'N'
  9588. AND tt1.hospital_id = tt2.hospital_id
  9589. AND tt1.behospital_code = tt2.behospital_code
  9590. </if>
  9591. ) t1
  9592. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9593. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9594. AND t1.behospital_code = t2.behospital_code
  9595. AND t2.is_deleted = 'N'
  9596. </if>
  9597. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9598. , med_home_page t2
  9599. , med_home_operation_info t3
  9600. WHERE t1.hospital_id = t2.hospital_id
  9601. AND t1.behospital_code = t2.behospital_code
  9602. AND t2.home_page_id = t3.home_page_id
  9603. AND t2.is_deleted = 'N'
  9604. AND t3.is_deleted = 'N'
  9605. </if>
  9606. ) t
  9607. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9608. AND t.hospitalId = qi.hospital_id
  9609. AND t.behospitalCode = qi.behospital_code
  9610. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9611. AND t.hospitalId = qd.hospital_id
  9612. AND t.behospitalCode = qd.behospital_code
  9613. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9614. AND qd.cases_id = qc.id
  9615. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  9616. AND qd.cases_id = qce.cases_id
  9617. AND qd.cases_entry_id = qce.id
  9618. where 1=1
  9619. <if test="qcResultShortPageVO.checkStatus != null">
  9620. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9621. </if>
  9622. <if test="qcResultShortPageVO.mrStatus != null">
  9623. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9624. </if>
  9625. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9626. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9627. </if>
  9628. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9629. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9630. </if>
  9631. <if test="qcResultShortPageVO.chTimeStart != null ">
  9632. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9633. </if>
  9634. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9635. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9636. </if>
  9637. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9638. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9639. </if>
  9640. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9641. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9642. </if>
  9643. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9644. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  9645. </if>
  9646. <if test="qcResultShortPageVO.casesEntryId != null ">
  9647. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  9648. </if>
  9649. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9650. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  9651. </if>
  9652. <if test="qcResultShortPageVO.casesId != null">
  9653. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  9654. </if>
  9655. )f1,
  9656. (SELECT
  9657. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9658. t.behDeptId,
  9659. t.behDeptName,
  9660. t.doctorId,
  9661. t.doctorName
  9662. FROM
  9663. (SELECT DISTINCT
  9664. t1.hospital_id AS hospitalId,
  9665. t1.behospital_code AS behospitalCode,
  9666. t1.bed_code AS bedCode,
  9667. t1.LEVEL AS LEVEL,
  9668. t1.grade_type AS gradeType,
  9669. t1.score_res AS scoreRes,
  9670. t1.NAME AS NAME,
  9671. t1.sex AS sex,
  9672. t1.beh_dept_id AS behDeptId,
  9673. t1.beh_dept_name AS behDeptName,
  9674. t1.doctor_id AS doctorId,
  9675. t1.doctor_name AS doctorName,
  9676. t1.beh_doctor_id AS behDoctorId,
  9677. t1.beh_doctor_name AS behDoctorName,
  9678. t1.director_doctor_id AS directorDoctorId,
  9679. t1.director_doctor_name AS directorDoctorName,
  9680. t1.birthday AS birthday,
  9681. t1.behospital_date AS behospitalDate,
  9682. t1.leave_hospital_date AS leaveHospitalDate,
  9683. t1.placefile_date AS placefileDate,
  9684. t1.gmt_create AS gradeTime,
  9685. t1.diagnose,
  9686. t1.ward_name AS wardName,
  9687. t2.age,
  9688. t1.file_code AS fileCode,
  9689. t1.checkStatus,
  9690. t1.mrStatus,
  9691. t1.chName,
  9692. t1.mrName,
  9693. t1.chTime,
  9694. t1.mrTime
  9695. FROM
  9696. (
  9697. SELECT DISTINCT
  9698. tt1.*
  9699. FROM
  9700. (SELECT
  9701. be.*,
  9702. ifnull(mci.status,0) AS checkStatus,
  9703. ifnull(hm_mci.status,0) AS mrStatus,
  9704. mci.check_name as chName,
  9705. hm_mci.check_name as mrName,
  9706. mci.gmt_create as chTime,
  9707. hm_mci.gmt_create as mrTime
  9708. FROM
  9709. (
  9710. SELECT DISTINCT
  9711. a.hospital_id,
  9712. a.behospital_code,
  9713. a.bed_code,
  9714. a.file_code,
  9715. b.LEVEL,
  9716. b.grade_type,
  9717. b.score_res,
  9718. a.NAME,
  9719. a.sex,
  9720. a.beh_dept_id,
  9721. a.beh_dept_name,
  9722. a.birthday,
  9723. a.behospital_date,
  9724. a.leave_hospital_date,
  9725. a.doctor_id,
  9726. a.doctor_name,
  9727. a.beh_doctor_id,
  9728. a.beh_doctor_name,
  9729. a.director_doctor_id,
  9730. a.director_doctor_name,
  9731. a.diagnose,
  9732. a.placefile_date,
  9733. a.ward_name,
  9734. b.gmt_create
  9735. FROM
  9736. med_behospital_info a,
  9737. med_qcresult_info b,
  9738. med_qcresult_detail c,
  9739. qc_cases_entry d,
  9740. sys_user_dept e
  9741. WHERE
  9742. a.is_deleted = 'N'
  9743. AND b.is_deleted = 'N'
  9744. AND c.is_deleted = 'N'
  9745. AND d.is_deleted = 'N'
  9746. AND e.is_deleted = 'N'
  9747. AND a.hospital_id = b.hospital_id
  9748. AND a.hospital_id = c.hospital_id
  9749. AND a.hospital_id = e.hospital_id
  9750. AND a.behospital_code = b.behospital_code
  9751. AND a.behospital_code = c.behospital_code
  9752. AND a.beh_dept_id = e.dept_id
  9753. AND c.cases_id = d.cases_id
  9754. AND c.cases_entry_id = d.id
  9755. AND a.qc_type_id != 0
  9756. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9757. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9758. </if>
  9759. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9760. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9761. </if>
  9762. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9763. <if test="qcResultShortPageVO.startDate != null ">
  9764. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9765. </if>
  9766. <if test="qcResultShortPageVO.endDate != null ">
  9767. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9768. </if>
  9769. </if>
  9770. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9771. <if test="qcResultShortPageVO.startDate != null ">
  9772. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9773. </if>
  9774. <if test="qcResultShortPageVO.endDate != null">
  9775. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9776. </if>
  9777. </if>
  9778. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9779. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9780. </if>
  9781. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9782. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9783. </if>
  9784. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9785. AND b.`level` = #{qcResultShortPageVO.level}
  9786. </if>
  9787. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9788. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9789. </if>
  9790. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9791. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9792. </if>
  9793. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9794. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9795. </if>
  9796. <if test="qcResultShortPageVO.casesEntryId != null ">
  9797. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9798. </if>
  9799. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9800. AND d.cases_name = #{qcResultShortPageVO.casesName}
  9801. </if>
  9802. <if test="qcResultShortPageVO.casesId != null">
  9803. AND d.cases_id = #{qcResultShortPageVO.casesId}
  9804. </if>
  9805. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9806. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9807. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9808. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9809. </if>
  9810. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9811. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9812. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9813. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9814. </if>
  9815. <if test="qcResultShortPageVO.isReject != null">
  9816. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9817. </if>
  9818. <if test="qcResultShortPageVO.ruleType != null">
  9819. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9820. </if>
  9821. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9822. AND TIMESTAMPDIFF(
  9823. DAY,
  9824. DATE( a.behospital_date ),
  9825. DATE( a.leave_hospital_date ))> 30
  9826. </if>
  9827. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9828. AND TIMESTAMPDIFF(
  9829. DAY,
  9830. DATE( a.behospital_date ),
  9831. DATE( a.leave_hospital_date ))> 31
  9832. </if>
  9833. )be
  9834. left join med_check_info mci
  9835. on mci.is_deleted = 'N'
  9836. and mci.check_type = 0
  9837. and be.hospital_id = mci.hospital_id
  9838. and be.behospital_code = mci.behospital_code
  9839. left join med_check_info hm_mci
  9840. on hm_mci.is_deleted = 'N'
  9841. and hm_mci.check_type = 1
  9842. and be.hospital_id = hm_mci.hospital_id
  9843. and be.behospital_code = hm_mci.behospital_code
  9844. )tt1
  9845. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9846. ,med_medical_record tt2
  9847. WHERE
  9848. tt2.is_deleted = 'N'
  9849. AND tt1.hospital_id = tt2.hospital_id
  9850. AND tt1.behospital_code = tt2.behospital_code
  9851. AND tt2.mode_id = 30
  9852. </if>
  9853. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9854. ,med_crisis_info tt2
  9855. WHERE
  9856. tt2.is_deleted = 'N'
  9857. AND tt1.hospital_id = tt2.hospital_id
  9858. AND tt1.behospital_code = tt2.behospital_code
  9859. </if>
  9860. ) t1
  9861. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9862. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9863. AND t1.behospital_code = t2.behospital_code
  9864. AND t2.is_deleted = 'N'
  9865. </if>
  9866. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9867. , med_home_page t2
  9868. , med_home_operation_info t3
  9869. WHERE t1.hospital_id = t2.hospital_id
  9870. AND t1.behospital_code = t2.behospital_code
  9871. AND t2.home_page_id = t3.home_page_id
  9872. AND t2.is_deleted = 'N'
  9873. AND t3.is_deleted = 'N'
  9874. </if>
  9875. ) t
  9876. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9877. AND t.hospitalId = qi.hospital_id
  9878. AND t.behospitalCode = qi.behospital_code
  9879. where 1=1
  9880. <if test="qcResultShortPageVO.checkStatus != null">
  9881. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9882. </if>
  9883. <if test="qcResultShortPageVO.mrStatus != null">
  9884. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9885. </if>
  9886. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9887. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9888. </if>
  9889. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9890. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9891. </if>
  9892. <if test="qcResultShortPageVO.chTimeStart != null ">
  9893. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9894. </if>
  9895. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9896. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9897. </if>
  9898. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9899. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9900. </if>
  9901. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9902. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9903. </if>
  9904. GROUP BY
  9905. t.behDeptId,
  9906. t.behDeptName,
  9907. t.doctorId,
  9908. t.doctorName
  9909. )f2
  9910. WHERE
  9911. f1.doctorId = f2.doctorId
  9912. AND f1.doctorName = f2.doctorName
  9913. )m
  9914. </select>
  9915. <!-- 条目缺陷评分详情页导出-->
  9916. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  9917. SELECT * from(
  9918. SELECT
  9919. f1.*,
  9920. f2.avgScore
  9921. FROM
  9922. (SELECT
  9923. t.*,
  9924. qi.score_res AS score,
  9925. qd.msg AS msg,
  9926. qc.NAME AS caseName
  9927. FROM
  9928. (SELECT DISTINCT
  9929. t1.hospital_id AS hospitalId,
  9930. t1.behospital_code AS behospitalCode,
  9931. t1.bed_code AS bedCode,
  9932. t1.LEVEL AS LEVEL,
  9933. t1.grade_type AS gradeType,
  9934. t1.score_res AS scoreRes,
  9935. t1.scoreBn AS scoreBn,
  9936. t1.NAME AS patName,
  9937. t1.sex AS sex,
  9938. t1.beh_dept_id AS behDeptId,
  9939. t1.beh_dept_name AS behDeptName,
  9940. t1.doctor_id AS doctorId,
  9941. t1.doctor_name AS doctorName,
  9942. t1.beh_doctor_id AS behDoctorId,
  9943. t1.beh_doctor_name AS behDoctorName,
  9944. t1.director_doctor_id AS directorDoctorId,
  9945. t1.director_doctor_name AS directorDoctorName,
  9946. t1.birthday AS birthday,
  9947. t1.behospital_date AS behospitalDate,
  9948. t1.leave_hospital_date AS leaveHospitalDate,
  9949. t1.placefile_date AS placefileDate,
  9950. t1.gmt_create AS gradeTime,
  9951. t1.diagnose AS diagnose,
  9952. t1.ward_name AS wardName,
  9953. t1.file_code AS fileCode,
  9954. t1.checkStatus AS checkStatus,
  9955. t1.mrStatus AS mrStatus,
  9956. t1.chName AS chName,
  9957. t1.mrName AS mrName,
  9958. t1.chTime AS chTime,
  9959. t1.mrTime AS mrTime
  9960. FROM
  9961. (
  9962. SELECT DISTINCT
  9963. tt1.*
  9964. FROM
  9965. (SELECT
  9966. be.*,
  9967. ifnull(mci.status,0) AS checkStatus,
  9968. ifnull(hm_mci.status,0) AS mrStatus,
  9969. mci.check_name as chName,
  9970. hm_mci.check_name as mrName,
  9971. mci.gmt_create as chTime,
  9972. e.score_res as scoreBn,
  9973. hm_mci.gmt_create as mrTime
  9974. FROM
  9975. (
  9976. SELECT DISTINCT
  9977. a.hospital_id,
  9978. a.behospital_code,
  9979. a.bed_code,
  9980. a.file_code,
  9981. b.LEVEL,
  9982. b.grade_type,
  9983. b.score_res,
  9984. a.NAME,
  9985. a.sex,
  9986. a.beh_dept_id,
  9987. a.beh_dept_name,
  9988. a.birthday,
  9989. a.behospital_date,
  9990. a.leave_hospital_date,
  9991. a.doctor_id,
  9992. a.doctor_name,
  9993. a.beh_doctor_id,
  9994. a.beh_doctor_name,
  9995. a.director_doctor_id,
  9996. a.director_doctor_name,
  9997. a.diagnose,
  9998. a.placefile_date,
  9999. a.ward_name,
  10000. b.gmt_create
  10001. FROM
  10002. med_behospital_info a,
  10003. med_qcresult_info b,
  10004. med_qcresult_detail c,
  10005. qc_cases_entry d
  10006. WHERE
  10007. a.is_deleted = 'N'
  10008. AND b.is_deleted = 'N'
  10009. AND c.is_deleted = 'N'
  10010. AND d.is_deleted = 'N'
  10011. AND a.hospital_id = b.hospital_id
  10012. AND a.hospital_id = c.hospital_id
  10013. AND a.behospital_code = b.behospital_code
  10014. AND a.behospital_code = c.behospital_code
  10015. AND c.cases_id = d.cases_id
  10016. AND c.cases_entry_id = d.id
  10017. AND a.qc_type_id != 0
  10018. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10019. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10020. </if>
  10021. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10022. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10023. </if>
  10024. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10025. <if test="qcResultShortPageVO.startDate != null ">
  10026. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10027. </if>
  10028. <if test="qcResultShortPageVO.endDate != null ">
  10029. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10030. </if>
  10031. </if>
  10032. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10033. <if test="qcResultShortPageVO.startDate != null ">
  10034. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10035. </if>
  10036. <if test="qcResultShortPageVO.endDate != null">
  10037. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10038. </if>
  10039. </if>
  10040. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10041. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10042. </if>
  10043. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10044. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10045. </if>
  10046. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10047. AND b.`level` = #{qcResultShortPageVO.level}
  10048. </if>
  10049. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10050. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10051. </if>
  10052. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10053. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10054. </if>
  10055. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10056. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10057. </if>
  10058. <if test="qcResultShortPageVO.casesEntryId != null ">
  10059. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10060. </if>
  10061. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10062. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10063. </if>
  10064. <if test="qcResultShortPageVO.casesId != null">
  10065. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10066. </if>
  10067. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10068. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10069. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10070. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10071. </if>
  10072. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10073. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10074. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10075. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10076. </if>
  10077. <if test="qcResultShortPageVO.isReject != null">
  10078. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10079. </if>
  10080. <if test="qcResultShortPageVO.ruleType != null">
  10081. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10082. </if>
  10083. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10084. AND TIMESTAMPDIFF(
  10085. DAY,
  10086. DATE( a.behospital_date ),
  10087. DATE( a.leave_hospital_date ))> 30
  10088. </if>
  10089. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10090. AND TIMESTAMPDIFF(
  10091. DAY,
  10092. DATE( a.behospital_date ),
  10093. DATE( a.leave_hospital_date ))> 31
  10094. </if>
  10095. )be
  10096. left join med_check_info mci
  10097. on mci.is_deleted = 'N'
  10098. and mci.check_type = 0
  10099. and be.hospital_id = mci.hospital_id
  10100. and be.behospital_code = mci.behospital_code
  10101. left join med_check_info hm_mci
  10102. on hm_mci.is_deleted = 'N'
  10103. and hm_mci.check_type = 1
  10104. and be.hospital_id = hm_mci.hospital_id
  10105. and be.behospital_code = hm_mci.behospital_code
  10106. LEFT JOIN med_qcresult_cases e
  10107. on be.behospital_code = e.behospital_code
  10108. and be.hospital_id = e.hospital_id
  10109. AND e.is_deleted = 'N'
  10110. and e.cases_id = 243
  10111. )tt1
  10112. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10113. ,med_medical_record tt2
  10114. WHERE
  10115. tt2.is_deleted = 'N'
  10116. AND tt1.hospital_id = tt2.hospital_id
  10117. AND tt1.behospital_code = tt2.behospital_code
  10118. AND tt2.mode_id = 30
  10119. </if>
  10120. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10121. ,med_crisis_info tt2
  10122. WHERE
  10123. tt2.is_deleted = 'N'
  10124. AND tt1.hospital_id = tt2.hospital_id
  10125. AND tt1.behospital_code = tt2.behospital_code
  10126. </if>
  10127. ) t1
  10128. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10129. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10130. AND t1.behospital_code = t2.behospital_code
  10131. AND t2.is_deleted = 'N'
  10132. </if>
  10133. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10134. , med_home_page t2
  10135. , med_home_operation_info t3
  10136. WHERE t1.hospital_id = t2.hospital_id
  10137. AND t1.behospital_code = t2.behospital_code
  10138. AND t2.home_page_id = t3.home_page_id
  10139. AND t2.is_deleted = 'N'
  10140. AND t3.is_deleted = 'N'
  10141. </if>
  10142. ) t
  10143. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10144. AND t.hospitalId = qi.hospital_id
  10145. AND t.behospitalCode = qi.behospital_code
  10146. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10147. AND t.hospitalId = qd.hospital_id
  10148. AND t.behospitalCode = qd.behospital_code
  10149. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10150. AND qd.cases_id = qc.id
  10151. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10152. AND qd.cases_id = qce.cases_id
  10153. AND qd.cases_entry_id = qce.id
  10154. where 1=1
  10155. <if test="qcResultShortPageVO.checkStatus != null">
  10156. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10157. </if>
  10158. <if test="qcResultShortPageVO.mrStatus != null">
  10159. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10160. </if>
  10161. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10162. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10163. </if>
  10164. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10165. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10166. </if>
  10167. <if test="qcResultShortPageVO.chTimeStart != null ">
  10168. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10169. </if>
  10170. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10171. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10172. </if>
  10173. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10174. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10175. </if>
  10176. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10177. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10178. </if>
  10179. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10180. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10181. </if>
  10182. <if test="qcResultShortPageVO.casesEntryId != null ">
  10183. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10184. </if>
  10185. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10186. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10187. </if>
  10188. <if test="qcResultShortPageVO.casesId != null">
  10189. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10190. </if>
  10191. )f1,
  10192. (SELECT
  10193. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10194. t.behDeptId,
  10195. t.behDeptName
  10196. FROM
  10197. (SELECT DISTINCT
  10198. t1.hospital_id AS hospitalId,
  10199. t1.behospital_code AS behospitalCode,
  10200. t1.bed_code AS bedCode,
  10201. t1.LEVEL AS LEVEL,
  10202. t1.grade_type AS gradeType,
  10203. t1.score_res AS scoreRes,
  10204. t1.NAME AS NAME,
  10205. t1.sex AS sex,
  10206. t1.beh_dept_id AS behDeptId,
  10207. t1.beh_dept_name AS behDeptName,
  10208. t1.doctor_id AS doctorId,
  10209. t1.doctor_name AS doctorName,
  10210. t1.beh_doctor_id AS behDoctorId,
  10211. t1.beh_doctor_name AS behDoctorName,
  10212. t1.director_doctor_id AS directorDoctorId,
  10213. t1.director_doctor_name AS directorDoctorName,
  10214. t1.birthday AS birthday,
  10215. t1.behospital_date AS behospitalDate,
  10216. t1.leave_hospital_date AS leaveHospitalDate,
  10217. t1.placefile_date AS placefileDate,
  10218. t1.gmt_create AS gradeTime,
  10219. t1.diagnose,
  10220. t1.ward_name AS wardName,
  10221. t2.age,
  10222. t1.file_code AS fileCode,
  10223. t1.checkStatus,
  10224. t1.mrStatus,
  10225. t1.chName,
  10226. t1.mrName,
  10227. t1.chTime,
  10228. t1.mrTime
  10229. FROM
  10230. (
  10231. SELECT DISTINCT
  10232. tt1.*
  10233. FROM
  10234. (SELECT
  10235. be.*,
  10236. ifnull(mci.status,0) AS checkStatus,
  10237. ifnull(hm_mci.status,0) AS mrStatus,
  10238. mci.check_name as chName,
  10239. hm_mci.check_name as mrName,
  10240. mci.gmt_create as chTime,
  10241. hm_mci.gmt_create as mrTime
  10242. FROM
  10243. (
  10244. SELECT DISTINCT
  10245. a.hospital_id,
  10246. a.behospital_code,
  10247. a.bed_code,
  10248. a.file_code,
  10249. b.LEVEL,
  10250. b.grade_type,
  10251. b.score_res,
  10252. a.NAME,
  10253. a.sex,
  10254. a.beh_dept_id,
  10255. a.beh_dept_name,
  10256. a.birthday,
  10257. a.behospital_date,
  10258. a.leave_hospital_date,
  10259. a.doctor_id,
  10260. a.doctor_name,
  10261. a.beh_doctor_id,
  10262. a.beh_doctor_name,
  10263. a.director_doctor_id,
  10264. a.director_doctor_name,
  10265. a.diagnose,
  10266. a.placefile_date,
  10267. a.ward_name,
  10268. b.gmt_create
  10269. FROM
  10270. med_behospital_info a,
  10271. med_qcresult_info b,
  10272. med_qcresult_detail c,
  10273. qc_cases_entry d
  10274. WHERE
  10275. a.is_deleted = 'N'
  10276. AND b.is_deleted = 'N'
  10277. AND c.is_deleted = 'N'
  10278. AND d.is_deleted = 'N'
  10279. AND a.hospital_id = b.hospital_id
  10280. AND a.hospital_id = c.hospital_id
  10281. AND a.behospital_code = b.behospital_code
  10282. AND a.behospital_code = c.behospital_code
  10283. AND c.cases_id = d.cases_id
  10284. AND c.cases_entry_id = d.id
  10285. AND a.qc_type_id != 0
  10286. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10287. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10288. </if>
  10289. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10290. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10291. </if>
  10292. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10293. <if test="qcResultShortPageVO.startDate != null ">
  10294. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10295. </if>
  10296. <if test="qcResultShortPageVO.endDate != null ">
  10297. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10298. </if>
  10299. </if>
  10300. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10301. <if test="qcResultShortPageVO.startDate != null ">
  10302. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10303. </if>
  10304. <if test="qcResultShortPageVO.endDate != null">
  10305. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10306. </if>
  10307. </if>
  10308. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10309. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10310. </if>
  10311. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10312. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10313. </if>
  10314. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10315. AND b.`level` = #{qcResultShortPageVO.level}
  10316. </if>
  10317. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10318. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10319. </if>
  10320. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10321. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10322. </if>
  10323. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10324. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10325. </if>
  10326. <if test="qcResultShortPageVO.casesEntryId != null ">
  10327. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10328. </if>
  10329. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10330. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10331. </if>
  10332. <if test="qcResultShortPageVO.casesId != null">
  10333. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10334. </if>
  10335. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10336. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10337. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10338. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10339. </if>
  10340. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10341. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10342. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10343. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10344. </if>
  10345. <if test="qcResultShortPageVO.isReject != null">
  10346. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10347. </if>
  10348. <if test="qcResultShortPageVO.ruleType != null">
  10349. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10350. </if>
  10351. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10352. AND TIMESTAMPDIFF(
  10353. DAY,
  10354. DATE( a.behospital_date ),
  10355. DATE( a.leave_hospital_date ))> 30
  10356. </if>
  10357. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10358. AND TIMESTAMPDIFF(
  10359. DAY,
  10360. DATE( a.behospital_date ),
  10361. DATE( a.leave_hospital_date ))> 31
  10362. </if>
  10363. )be
  10364. left join med_check_info mci
  10365. on mci.is_deleted = 'N'
  10366. and mci.check_type = 0
  10367. and be.hospital_id = mci.hospital_id
  10368. and be.behospital_code = mci.behospital_code
  10369. left join med_check_info hm_mci
  10370. on hm_mci.is_deleted = 'N'
  10371. and hm_mci.check_type = 1
  10372. and be.hospital_id = hm_mci.hospital_id
  10373. and be.behospital_code = hm_mci.behospital_code
  10374. )tt1
  10375. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10376. ,med_medical_record tt2
  10377. WHERE
  10378. tt2.is_deleted = 'N'
  10379. AND tt1.hospital_id = tt2.hospital_id
  10380. AND tt1.behospital_code = tt2.behospital_code
  10381. AND tt2.mode_id = 30
  10382. </if>
  10383. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10384. ,med_crisis_info tt2
  10385. WHERE
  10386. tt2.is_deleted = 'N'
  10387. AND tt1.hospital_id = tt2.hospital_id
  10388. AND tt1.behospital_code = tt2.behospital_code
  10389. </if>
  10390. ) t1
  10391. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10392. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10393. AND t1.behospital_code = t2.behospital_code
  10394. AND t2.is_deleted = 'N'
  10395. </if>
  10396. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10397. , med_home_page t2
  10398. , med_home_operation_info t3
  10399. WHERE t1.hospital_id = t2.hospital_id
  10400. AND t1.behospital_code = t2.behospital_code
  10401. AND t2.home_page_id = t3.home_page_id
  10402. AND t2.is_deleted = 'N'
  10403. AND t3.is_deleted = 'N'
  10404. </if>
  10405. ) t
  10406. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10407. AND t.hospitalId = qi.hospital_id
  10408. AND t.behospitalCode = qi.behospital_code
  10409. where 1=1
  10410. <if test="qcResultShortPageVO.checkStatus != null">
  10411. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10412. </if>
  10413. <if test="qcResultShortPageVO.mrStatus != null">
  10414. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10415. </if>
  10416. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10417. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10418. </if>
  10419. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10420. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10421. </if>
  10422. <if test="qcResultShortPageVO.chTimeStart != null ">
  10423. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10424. </if>
  10425. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10426. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10427. </if>
  10428. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10429. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10430. </if>
  10431. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10432. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10433. </if>
  10434. GROUP BY
  10435. t.behDeptId,
  10436. t.behDeptName
  10437. )f2
  10438. WHERE
  10439. f1.behDeptId = f2.behDeptId
  10440. AND f1.behDeptName = f2.behDeptName
  10441. )m
  10442. </select>
  10443. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  10444. <result column="deptName" property="deptName"/>
  10445. <result column="deptId" property="deptId"/>
  10446. <result column="doctorGroup" property="doctorGroup"/>
  10447. <result column="doctorName" property="doctorName"/>
  10448. <result column="entry_2658_num" property="entry_2658_num"/>
  10449. <result column="entry_2686_num" property="entry_2686_num"/>
  10450. <result column="entry_2657_num" property="entry_2657_num"/>
  10451. <result column="entry_3010_num" property="entry_3010_num"/>
  10452. <result column="entry_2655_num" property="entry_2655_num"/>
  10453. <result column="entry_2654_num" property="entry_2654_num"/>
  10454. <result column="entry_2852_num" property="entry_2852_num"/>
  10455. <result column="entry_2287_num" property="entry_2287_num"/>
  10456. <result column="entry_3025_num" property="entry_3025_num"/>
  10457. <result column="entry_2170_num" property="entry_2170_num"/>
  10458. <result column="entry_2930_num" property="entry_2930_num"/>
  10459. <result column="entry_2900_num" property="entry_2900_num"/>
  10460. <result column="entry_2229_num" property="entry_2229_num"/>
  10461. <result column="entry_2217_num" property="entry_2217_num"/>
  10462. <result column="entry_2218_num" property="entry_2218_num"/>
  10463. <result column="entry_2220_num" property="entry_2220_num"/>
  10464. <result column="entry_2486_num" property="entry_2486_num"/>
  10465. <result column="entry_3063_num" property="entry_3063_num"/>
  10466. <result column="entry_3062_num" property="entry_3062_num"/>
  10467. <result column="entry_2495_num" property="entry_2495_num"/>
  10468. </resultMap>
  10469. <!-- 病历稽查表-->
  10470. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  10471. SELECT
  10472. a.beh_dept_id AS deptId,
  10473. a.beh_dept_name AS deptName,
  10474. a.doctor_name as doctorGroup,
  10475. a.doctor_name as doctorName,
  10476. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10477. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10478. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10479. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10480. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10481. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10482. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10483. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10484. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10485. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10486. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10487. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10488. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10489. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10490. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10491. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10492. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10493. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10494. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10495. sum(c.cases_entry_id = 2495) as entry_2495_num
  10496. FROM
  10497. med_behospital_info a,
  10498. med_qcresult_info b,
  10499. med_qcresult_detail c,
  10500. qc_cases_entry d,
  10501. bas_doctor_info e
  10502. WHERE
  10503. a.is_deleted = 'N'
  10504. AND b.is_deleted = 'N'
  10505. AND c.is_deleted = 'N'
  10506. AND d.is_deleted = 'N'
  10507. AND e.is_deleted = 'N'
  10508. AND a.hospital_id = b.hospital_id
  10509. AND a.hospital_id = c.hospital_id
  10510. AND a.hospital_id = e.hospital_id
  10511. AND a.behospital_code = b.behospital_code
  10512. AND a.behospital_code = c.behospital_code
  10513. AND a.beh_dept_id = e.dept_id
  10514. AND c.cases_entry_id = d.id
  10515. and a.doctor_id=e.doctor_id
  10516. and e.group_id is not NULL
  10517. AND LENGTH(e.group_id)>0
  10518. AND a.qc_type_id != 0
  10519. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10520. and a.is_placefile = #{filterVO.isPlacefile}
  10521. </if>
  10522. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10523. AND a.hospital_id = #{filterVO.hospitalId}
  10524. </if>
  10525. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10526. <if test="filterVO.startDate != null ">
  10527. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10528. </if>
  10529. <if test="filterVO.endDate != null ">
  10530. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10531. </if>
  10532. </if>
  10533. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10534. <if test="filterVO.startDate != null ">
  10535. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10536. </if>
  10537. <if test="filterVO.endDate != null ">
  10538. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10539. </if>
  10540. </if>
  10541. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10542. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10543. </if>
  10544. GROUP BY
  10545. a.beh_dept_id,
  10546. e.group_id,
  10547. a.doctor_id
  10548. </select>
  10549. <!-- 病历稽查表-科室-->
  10550. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  10551. SELECT
  10552. a.beh_dept_id AS deptId,
  10553. a.beh_dept_name AS deptName,
  10554. a.doctor_name as doctorName,
  10555. a.doctor_name as doctorGroup,
  10556. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10557. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10558. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10559. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10560. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10561. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10562. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10563. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10564. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10565. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10566. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10567. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10568. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10569. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10570. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10571. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10572. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10573. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10574. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10575. sum(c.cases_entry_id = 2495) as entry_2495_num
  10576. FROM
  10577. med_behospital_info a,
  10578. med_qcresult_info b,
  10579. med_qcresult_detail c,
  10580. qc_cases_entry d,
  10581. bas_doctor_info e,
  10582. sys_user_dept f
  10583. WHERE
  10584. a.is_deleted = 'N'
  10585. AND b.is_deleted = 'N'
  10586. AND c.is_deleted = 'N'
  10587. AND d.is_deleted = 'N'
  10588. AND e.is_deleted = 'N'
  10589. AND f.is_deleted = 'N'
  10590. AND a.hospital_id = b.hospital_id
  10591. AND a.hospital_id = c.hospital_id
  10592. AND a.hospital_id = e.hospital_id
  10593. AND a.hospital_id = f.hospital_id
  10594. AND a.behospital_code = b.behospital_code
  10595. AND a.behospital_code = c.behospital_code
  10596. AND a.beh_dept_id = f.dept_id
  10597. AND c.cases_entry_id = d.id
  10598. and a.doctor_id=e.doctor_id
  10599. and e.group_id is not NULL
  10600. AND LENGTH(e.group_id)>0
  10601. AND a.qc_type_id != 0
  10602. <if test="filterVO.userId!=null">
  10603. AND f.user_id = #{filterVO.userId}
  10604. </if>
  10605. <if test="filterVO.name != null and filterVO.name != ''">
  10606. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  10607. </if>
  10608. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10609. and a.is_placefile = #{filterVO.isPlacefile}
  10610. </if>
  10611. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10612. AND a.hospital_id = #{filterVO.hospitalId}
  10613. </if>
  10614. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10615. <if test="filterVO.startDate != null ">
  10616. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10617. </if>
  10618. <if test="filterVO.endDate != null ">
  10619. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10620. </if>
  10621. </if>
  10622. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10623. <if test="filterVO.startDate != null ">
  10624. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10625. </if>
  10626. <if test="filterVO.endDate != null ">
  10627. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10628. </if>
  10629. </if>
  10630. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10631. AND a.beh_dept_name = #{filterVO.deptName}
  10632. </if>
  10633. GROUP BY
  10634. a.beh_dept_id,
  10635. e.group_id,
  10636. a.doctor_name
  10637. </select>
  10638. <!-- 病历稽查表最新sql、id&&name-->
  10639. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  10640. SELECT
  10641. d.id,
  10642. d.name
  10643. from
  10644. qc_cases_entry d
  10645. where
  10646. 1=1
  10647. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  10648. and d.id in
  10649. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  10650. '${item}'
  10651. </foreach>
  10652. </if>
  10653. </select>
  10654. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  10655. <result column="deptName" property="deptName"/>
  10656. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10657. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  10658. <result column="doctorName" property="doctorName"/>
  10659. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10660. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  10661. <result column="RYJLW_24" property="ryjlw_24"/>
  10662. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10663. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10664. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10665. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10666. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10667. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10668. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10669. <result column="SQTLXJW" property="sqtlxjw"/>
  10670. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10671. <result column="XHSCW_30M" property="xhscw_30m"/>
  10672. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10673. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10674. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10675. <result column="ZKJLW_24" property="zkjlw_24"/>
  10676. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10677. <result column="SXHWJL" property="sxhwjl"/>
  10678. <result column="SXPJW_24" property="sxpjw_24"/>
  10679. <result column="WJZWJL" property="wjzwjl"/>
  10680. <result column="WYWWCXJ" property="wywwcxj"/>
  10681. </collection>
  10682. </collection>
  10683. </resultMap>
  10684. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  10685. <result column="deptName" property="deptName"/>
  10686. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10687. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  10688. <result column="doctorGroup" property="doctorGroup"/>
  10689. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10690. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  10691. <result column="doctorName" property="doctorName"/>
  10692. <result column="RYJLW_24" property="ryjlw_24"/>
  10693. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10694. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10695. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10696. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10697. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10698. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10699. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10700. <result column="SQTLXJW" property="sqtlxjw"/>
  10701. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10702. <result column="XHSCW_30M" property="xhscw_30m"/>
  10703. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10704. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10705. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10706. <result column="ZKJLW_24" property="zkjlw_24"/>
  10707. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10708. <result column="SXHWJL" property="sxhwjl"/>
  10709. <result column="SXPJW_24" property="sxpjw_24"/>
  10710. <result column="WJZWJL" property="wjzwjl"/>
  10711. <result column="WYWWCXJ" property="wywwcxj"/>
  10712. </collection>
  10713. </collection>
  10714. </resultMap>
  10715. <!-- 病历稽查表最新导出-->
  10716. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  10717. SELECT
  10718. a.beh_dept_id AS deptId,
  10719. a.beh_dept_name AS deptName,
  10720. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  10721. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10722. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10723. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10724. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10725. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10726. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10727. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10728. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10729. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10730. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10731. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10732. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10733. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10734. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10735. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10736. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10737. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10738. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10739. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10740. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10741. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  10742. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  10743. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  10744. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  10745. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  10746. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  10747. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  10748. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  10749. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  10750. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  10751. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  10752. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  10753. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  10754. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  10755. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  10756. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  10757. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  10758. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  10759. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  10760. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  10761. FROM
  10762. med_behospital_info a,
  10763. med_qcresult_info b,
  10764. med_qcresult_detail c,
  10765. qc_cases_entry d,
  10766. bas_doctor_info e
  10767. WHERE
  10768. a.is_deleted = 'N'
  10769. AND b.is_deleted = 'N'
  10770. AND c.is_deleted = 'N'
  10771. AND d.is_deleted = 'N'
  10772. AND e.is_deleted = 'N'
  10773. AND a.hospital_id = b.hospital_id
  10774. AND a.hospital_id = c.hospital_id
  10775. AND a.hospital_id = e.hospital_id
  10776. AND a.behospital_code = b.behospital_code
  10777. AND a.behospital_code = c.behospital_code
  10778. AND a.beh_dept_id = e.dept_id
  10779. AND c.cases_entry_id = d.id
  10780. and a.doctor_id=e.doctor_id
  10781. and e.group_id is not NULL
  10782. AND LENGTH(e.group_id)>0
  10783. AND a.qc_type_id != 0
  10784. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10785. and a.is_placefile = #{filterVO.isPlacefile}
  10786. </if>
  10787. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10788. AND a.hospital_id = #{filterVO.hospitalId}
  10789. </if>
  10790. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10791. <if test="filterVO.startDate != null ">
  10792. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10793. </if>
  10794. <if test="filterVO.endDate != null ">
  10795. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10796. </if>
  10797. </if>
  10798. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10799. <if test="filterVO.startDate != null ">
  10800. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10801. </if>
  10802. <if test="filterVO.endDate != null ">
  10803. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10804. </if>
  10805. </if>
  10806. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10807. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10808. </if>
  10809. GROUP BY
  10810. a.beh_dept_id,
  10811. e.group_id
  10812. </select>
  10813. <!-- 病历稽查表最新导出-->
  10814. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  10815. SELECT
  10816. a.beh_dept_id AS deptId,
  10817. a.beh_dept_name AS deptName,
  10818. a.doctor_name as doctorGroup,
  10819. a.doctor_name as doctorName,
  10820. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10821. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10822. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10823. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10824. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10825. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10826. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10827. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10828. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10829. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10830. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10831. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10832. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10833. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10834. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10835. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10836. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10837. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10838. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10839. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10840. FROM
  10841. med_behospital_info a,
  10842. med_qcresult_info b,
  10843. med_qcresult_detail c,
  10844. qc_cases_entry d,
  10845. bas_doctor_info e,
  10846. sys_user_dept f
  10847. WHERE
  10848. a.is_deleted = 'N'
  10849. AND b.is_deleted = 'N'
  10850. AND c.is_deleted = 'N'
  10851. AND d.is_deleted = 'N'
  10852. AND e.is_deleted = 'N'
  10853. AND f.is_deleted = 'N'
  10854. AND a.hospital_id = b.hospital_id
  10855. AND a.hospital_id = c.hospital_id
  10856. AND a.hospital_id = e.hospital_id
  10857. AND a.hospital_id = f.hospital_id
  10858. AND a.behospital_code = b.behospital_code
  10859. AND a.behospital_code = c.behospital_code
  10860. AND a.beh_dept_id = f.dept_id
  10861. AND c.cases_entry_id = d.id
  10862. and a.doctor_id=e.doctor_id
  10863. and e.group_id is not NULL
  10864. AND LENGTH(e.group_id)>0
  10865. AND a.qc_type_id != 0
  10866. <if test="filterVO.userId!=null">
  10867. AND f.user_id = #{filterVO.userId}
  10868. </if>
  10869. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10870. and a.is_placefile = #{filterVO.isPlacefile}
  10871. </if>
  10872. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10873. AND a.hospital_id = #{filterVO.hospitalId}
  10874. </if>
  10875. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10876. <if test="filterVO.startDate != null ">
  10877. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10878. </if>
  10879. <if test="filterVO.endDate != null ">
  10880. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10881. </if>
  10882. </if>
  10883. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10884. <if test="filterVO.startDate != null ">
  10885. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10886. </if>
  10887. <if test="filterVO.endDate != null ">
  10888. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10889. </if>
  10890. </if>
  10891. <if test="filterVO.name != null and filterVO.name != ''">
  10892. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  10893. </if>
  10894. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10895. AND a.beh_dept_name = #{filterVO.deptName}
  10896. </if>
  10897. GROUP BY
  10898. a.beh_dept_id,
  10899. e.group_id,
  10900. a.doctor_name
  10901. </select>
  10902. <!-- 未整改病历统计-->
  10903. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  10904. SELECT
  10905. a.beh_dept_id AS deptId,
  10906. a.beh_dept_name AS deptName,
  10907. d.id AS casesEntryId,
  10908. d.NAME AS casesEntryName,
  10909. count(*) AS casesEntryNum
  10910. FROM
  10911. med_behospital_info a,
  10912. med_qcresult_info b,
  10913. med_qcresult_detail c,
  10914. qc_cases_entry d
  10915. WHERE
  10916. a.is_deleted = 'N'
  10917. AND b.is_deleted = 'N'
  10918. AND c.is_deleted = 'N'
  10919. AND d.is_deleted = 'N'
  10920. AND a.hospital_id = b.hospital_id
  10921. AND a.hospital_id = c.hospital_id
  10922. AND a.behospital_code = b.behospital_code
  10923. AND a.behospital_code = c.behospital_code
  10924. AND c.cases_entry_id = d.id
  10925. AND a.qc_type_id != 0
  10926. <if test="isPlacefile != null and isPlacefile != ''">
  10927. and a.is_placefile = #{isPlacefile}
  10928. </if>
  10929. <if test="hospitalId != null and hospitalId != ''">
  10930. AND a.hospital_id = #{hospitalId}
  10931. </if>
  10932. <if test="isPlacefile != null and isPlacefile == 0">
  10933. <if test="startDate != null ">
  10934. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  10935. </if>
  10936. <if test="endDate != null ">
  10937. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  10938. </if>
  10939. </if>
  10940. <if test="isPlacefile != null and isPlacefile == 1">
  10941. <if test="startDate != null ">
  10942. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  10943. </if>
  10944. <if test="endDate != null ">
  10945. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  10946. </if>
  10947. </if>
  10948. <if test="deptName != null and deptName != ''">
  10949. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  10950. </if>
  10951. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  10952. AND c.cases_entry_id IN
  10953. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  10954. #{item}
  10955. </foreach>
  10956. </if>
  10957. GROUP BY
  10958. a.beh_dept_id,
  10959. a.beh_dept_name,
  10960. c.cases_entry_id,
  10961. d.NAME
  10962. </select>
  10963. <!-- 未整改病历统计-科室-->
  10964. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  10965. SELECT
  10966. a.beh_dept_id AS deptId,
  10967. a.beh_dept_name AS deptName,
  10968. a.doctor_id as doctorId,
  10969. a.doctor_name as doctorName,
  10970. d.id AS casesEntryId,
  10971. d.NAME AS casesEntryName,
  10972. count(*) AS casesEntryNum
  10973. FROM
  10974. med_behospital_info a,
  10975. med_qcresult_info b,
  10976. med_qcresult_detail c,
  10977. qc_cases_entry d,
  10978. sys_user_dept f
  10979. WHERE
  10980. a.is_deleted = 'N'
  10981. AND b.is_deleted = 'N'
  10982. AND c.is_deleted = 'N'
  10983. AND d.is_deleted = 'N'
  10984. AND f.is_deleted = 'N'
  10985. AND a.hospital_id = b.hospital_id
  10986. AND a.hospital_id = c.hospital_id
  10987. AND a.hospital_id = f.hospital_id
  10988. AND a.behospital_code = b.behospital_code
  10989. AND a.behospital_code = c.behospital_code
  10990. AND a.beh_dept_id = f.dept_id
  10991. AND c.cases_entry_id = d.id
  10992. AND a.qc_type_id != 0
  10993. <if test="userId!=null">
  10994. AND f.user_id = #{userId}
  10995. </if>
  10996. <if test="isPlacefile != null and isPlacefile != ''">
  10997. and a.is_placefile = #{isPlacefile}
  10998. </if>
  10999. <if test="hospitalId != null and hospitalId != ''">
  11000. AND a.hospital_id = #{hospitalId}
  11001. </if>
  11002. <if test="isPlacefile != null and isPlacefile == 0">
  11003. <if test="startDate != null ">
  11004. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11005. </if>
  11006. <if test="endDate != null ">
  11007. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11008. </if>
  11009. </if>
  11010. <if test="isPlacefile != null and isPlacefile == 1">
  11011. <if test="startDate != null ">
  11012. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11013. </if>
  11014. <if test="endDate != null ">
  11015. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11016. </if>
  11017. </if>
  11018. <if test="deptName != null and deptName != ''">
  11019. AND a.beh_dept_name= #{deptName}
  11020. </if>
  11021. <if test="doctorName != null and doctorName != ''">
  11022. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11023. </if>
  11024. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11025. AND c.cases_entry_id IN
  11026. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11027. #{item}
  11028. </foreach>
  11029. </if>
  11030. GROUP BY
  11031. a.doctor_id,
  11032. a.doctor_name,
  11033. c.cases_entry_id,
  11034. d.NAME
  11035. </select>
  11036. <!-- 不合格/合格数病历号(内页)科室-->
  11037. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  11038. SELECT t.*
  11039. FROM
  11040. (SELECT DISTINCT
  11041. t1.hospital_id AS hospitalId,
  11042. t1.behospital_code AS behospitalCode,
  11043. t1.bed_code AS bedCode,
  11044. t1.LEVEL AS LEVEL,
  11045. t1.grade_type AS gradeType,
  11046. t1.score_res AS scoreRes,
  11047. t1.scoreBn,
  11048. t1.NAME AS NAME,
  11049. t1.sex AS sex,
  11050. t1.beh_dept_id AS behDeptId,
  11051. t1.beh_dept_name AS behDeptName,
  11052. t1.doctor_id AS doctorId,
  11053. t1.doctor_name AS doctorName,
  11054. t1.beh_doctor_id AS behDoctorId,
  11055. t1.beh_doctor_name AS behDoctorName,
  11056. t1.director_doctor_id AS directorDoctorId,
  11057. t1.director_doctor_name AS directorDoctorName,
  11058. t1.birthday AS birthday,
  11059. t1.behospital_date AS behospitalDate,
  11060. t1.leave_hospital_date AS leaveHospitalDate,
  11061. t1.placefile_date AS placefileDate,
  11062. t1.gmt_create AS gradeTime,
  11063. t1.diagnose,
  11064. t1.ward_name AS wardName,
  11065. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11066. t1.file_code AS fileCode,
  11067. t1.checkStatus,
  11068. t1.mrStatus,
  11069. t1.chName,
  11070. t1.mrName,
  11071. t1.chTime,
  11072. t1.mrTime
  11073. FROM
  11074. (SELECT
  11075. be.*,
  11076. b.LEVEL,
  11077. b.grade_type,
  11078. b.score_res,
  11079. b.gmt_create,
  11080. ifnull(mci.status,0) AS checkStatus,
  11081. ifnull(hm_mci.status,0) AS mrStatus,
  11082. mci.check_name as chName,
  11083. hm_mci.check_name as mrName,
  11084. mci.gmt_create as chTime,
  11085. hm_mci.gmt_create as mrTime
  11086. FROM
  11087. (
  11088. SELECT DISTINCT
  11089. a.hospital_id,
  11090. a.behospital_code,
  11091. a.bed_code,
  11092. a.file_code,
  11093. e.score_res as scoreBn,
  11094. a.NAME,
  11095. a.sex,
  11096. a.beh_dept_id,
  11097. a.beh_dept_name,
  11098. a.birthday,
  11099. a.behospital_date,
  11100. a.leave_hospital_date,
  11101. a.doctor_id,
  11102. a.doctor_name,
  11103. a.beh_doctor_id,
  11104. a.beh_doctor_name,
  11105. a.director_doctor_id,
  11106. a.director_doctor_name,
  11107. a.diagnose,
  11108. a.placefile_date,
  11109. a.ward_name
  11110. FROM
  11111. med_behospital_info a,
  11112. sys_user_dept c,
  11113. med_qcresult_cases e
  11114. WHERE
  11115. a.is_deleted = 'N'
  11116. AND c.is_deleted = 'N'
  11117. AND e.is_deleted = 'N'
  11118. AND a.hospital_id = c.hospital_id
  11119. AND a.hospital_id = e.hospital_id
  11120. AND a.beh_dept_id = c.dept_id
  11121. AND a.behospital_code = e.behospital_code
  11122. AND a.qc_type_id != 0
  11123. AND e.cases_id = 243
  11124. <if test="userId!=null">
  11125. AND c.user_id = #{userId}
  11126. </if>
  11127. <if test="deptName != null and deptName != ''">
  11128. and a.beh_dept_name = #{deptName}
  11129. </if>
  11130. <if test="deptClass != null and deptClass != ''">
  11131. and a.beh_dept_id = #{deptClass}
  11132. </if>
  11133. <if test="titleName != null and titleName != '' ">
  11134. <if test="titleName == '不合格数'">
  11135. AND e.`level`='不合格'
  11136. </if>
  11137. <if test="titleName == '合格数'">
  11138. AND e.`level`='合格'
  11139. </if>
  11140. </if>
  11141. <if test="isPlacefile != null and isPlacefile != ''">
  11142. and a.is_placefile = #{isPlacefile}
  11143. </if>
  11144. <if test="doctorName != null and doctorName != ''">
  11145. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11146. </if>
  11147. <if test="hospitalId != null and hospitalId != ''">
  11148. AND a.hospital_id = #{hospitalId}
  11149. </if>
  11150. <if test="isPlacefile != null and isPlacefile == 0">
  11151. <if test="startDate != null ">
  11152. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11153. </if>
  11154. <if test="endDate != null ">
  11155. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11156. </if>
  11157. </if>
  11158. <if test="isPlacefile != null and isPlacefile == 1">
  11159. <if test="startDate != null ">
  11160. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11161. </if>
  11162. <if test="endDate != null">
  11163. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11164. </if>
  11165. </if>
  11166. <if test="diagnose != null and diagnose != ''">
  11167. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11168. </if>
  11169. <if test="behospitalCode != null and behospitalCode != ''">
  11170. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11171. </if>
  11172. <if test="patName != null and patName != ''">
  11173. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11174. </if>
  11175. <if test="doctorId != null and doctorId != ''">
  11176. AND (a.doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  11177. OR a.beh_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  11178. OR a.director_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' ))
  11179. </if>
  11180. )be
  11181. left join med_check_info mci
  11182. on mci.is_deleted = 'N'
  11183. and mci.check_type = 0
  11184. and be.hospital_id = mci.hospital_id
  11185. and be.behospital_code = mci.behospital_code
  11186. left join med_check_info hm_mci
  11187. on hm_mci.is_deleted = 'N'
  11188. and hm_mci.check_type = 1
  11189. and be.hospital_id = hm_mci.hospital_id
  11190. and be.behospital_code = hm_mci.behospital_code
  11191. left join med_qcresult_info b
  11192. on b.is_deleted = 'N'
  11193. AND be.hospital_id = b.hospital_id
  11194. AND be.behospital_code = b.behospital_code
  11195. where
  11196. 1=1
  11197. <if test="level != null and level != ''">
  11198. AND b.`level` = #{level}
  11199. </if>
  11200. ) t1
  11201. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11202. AND t1.behospital_code = t2.behospital_code
  11203. AND t2.is_deleted = 'N'
  11204. ) t,
  11205. (
  11206. SELECT
  11207. a.doctor_id as doctorId,
  11208. a.doctor_name as doctorName
  11209. FROM
  11210. med_behospital_info a,
  11211. sys_user_dept b,
  11212. med_qcresult_cases c,
  11213. med_qcresult_detail d,
  11214. qc_cases_entry e
  11215. WHERE
  11216. a.is_deleted = 'N'
  11217. AND b.is_deleted = 'N'
  11218. AND c.is_deleted = 'N'
  11219. AND d.is_deleted = 'N'
  11220. AND e.is_deleted = 'N'
  11221. AND a.hospital_id = b.hospital_id
  11222. AND a.hospital_id = c.hospital_id
  11223. AND a.hospital_id = d.hospital_id
  11224. AND a.behospital_code = c.behospital_code
  11225. AND a.behospital_code = d.behospital_code
  11226. AND a.beh_dept_id = b.dept_id
  11227. AND c.cases_id = d.cases_id
  11228. AND d.cases_id = e.cases_id
  11229. AND d.cases_entry_id = e.id
  11230. AND d.cases_id = 243
  11231. AND a.qc_type_id != 0
  11232. <!-- <if test="titleName != null ">-->
  11233. <!-- <if test="titleName == '不合格数'">-->
  11234. <!-- AND c.`level`='不合格'-->
  11235. <!-- </if>-->
  11236. <!-- <if test="titleName == '合格数'">-->
  11237. <!-- AND c.`level`='合格'-->
  11238. <!-- </if>-->
  11239. <!-- </if>-->
  11240. <if test="userId!=null">
  11241. AND b.user_id = #{userId}
  11242. </if>
  11243. <if test="deptName != null and deptName != ''">
  11244. and a.beh_dept_name = #{deptName}
  11245. </if>
  11246. <if test="doctorName != null and doctorName != ''">
  11247. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11248. </if>
  11249. <if test="deptClass != null and deptClass != ''">
  11250. and a.beh_dept_id = #{deptClass}
  11251. </if>
  11252. <if test="isPlacefile != null and isPlacefile != ''">
  11253. and a.is_placefile = #{isPlacefile}
  11254. </if>
  11255. <if test="hospitalId != null and hospitalId != ''">
  11256. AND a.hospital_id = #{hospitalId}
  11257. </if>
  11258. <if test="isPlacefile != null and isPlacefile == 0">
  11259. <if test="startDate != null ">
  11260. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11261. </if>
  11262. <if test="endDate != null ">
  11263. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11264. </if>
  11265. </if>
  11266. <if test="isPlacefile != null and isPlacefile == 1">
  11267. <if test="startDate != null ">
  11268. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11269. </if>
  11270. <if test="endDate != null">
  11271. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11272. </if>
  11273. </if>
  11274. <if test="diagnose != null and diagnose != ''">
  11275. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11276. </if>
  11277. <if test="behospitalCode != null and behospitalCode != ''">
  11278. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11279. </if>
  11280. <if test="patName != null and patName != ''">
  11281. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11282. </if>
  11283. GROUP BY
  11284. a.doctor_id,
  11285. a.doctor_name
  11286. ) t2
  11287. where
  11288. t.doctorId = t2.doctorId
  11289. AND t.doctorName = t2.doctorName
  11290. <if test="checkStatus != null">
  11291. AND t.checkStatus = #{checkStatus}
  11292. </if>
  11293. <if test="mrStatus != null">
  11294. AND t.mrStatus = #{mrStatus}
  11295. </if>
  11296. <if test="chName != null and chName!=''">
  11297. AND t.chName like concat('%', #{chName}, '%')
  11298. </if>
  11299. <if test="mrName != null and mrName!=''">
  11300. AND t.mrName like concat('%', #{mrName}, '%')
  11301. </if>
  11302. <if test="chTimeStart != null ">
  11303. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  11304. </if>
  11305. <if test="chTimeEnd != null ">
  11306. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  11307. </if>
  11308. <if test="mrTimeStart != null ">
  11309. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  11310. </if>
  11311. <if test="mrTimeEnd != null ">
  11312. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  11313. </if>
  11314. </select>
  11315. <!-- 不合格/合格数病历号(内页)全院-->
  11316. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11317. SELECT t.*
  11318. FROM
  11319. (SELECT DISTINCT
  11320. t1.hospital_id AS hospitalId,
  11321. t1.behospital_code AS behospitalCode,
  11322. t1.bed_code AS bedCode,
  11323. t1.LEVEL AS LEVEL,
  11324. t1.grade_type AS gradeType,
  11325. t1.score_res AS scoreRes,
  11326. t1.scoreBn,
  11327. t1.NAME AS NAME,
  11328. t1.sex AS sex,
  11329. t1.beh_dept_id AS behDeptId,
  11330. t1.beh_dept_name AS behDeptName,
  11331. t1.doctor_id AS doctorId,
  11332. t1.doctor_name AS doctorName,
  11333. t1.beh_doctor_id AS behDoctorId,
  11334. t1.beh_doctor_name AS behDoctorName,
  11335. t1.director_doctor_id AS directorDoctorId,
  11336. t1.director_doctor_name AS directorDoctorName,
  11337. t1.birthday AS birthday,
  11338. t1.behospital_date AS behospitalDate,
  11339. t1.leave_hospital_date AS leaveHospitalDate,
  11340. t1.placefile_date AS placefileDate,
  11341. t1.gmt_create AS gradeTime,
  11342. t1.diagnose,
  11343. t1.ward_name AS wardName,
  11344. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11345. t1.file_code AS fileCode,
  11346. t1.checkStatus,
  11347. t1.mrStatus,
  11348. t1.chName,
  11349. t1.mrName,
  11350. t1.chTime,
  11351. t1.mrTime
  11352. FROM
  11353. (SELECT
  11354. be.*,
  11355. b.LEVEL,
  11356. b.grade_type,
  11357. b.score_res,
  11358. b.gmt_create,
  11359. ifnull(mci.status,0) AS checkStatus,
  11360. ifnull(hm_mci.status,0) AS mrStatus,
  11361. mci.check_name as chName,
  11362. hm_mci.check_name as mrName,
  11363. mci.gmt_create as chTime,
  11364. hm_mci.gmt_create as mrTime
  11365. FROM
  11366. (
  11367. SELECT DISTINCT
  11368. a.hospital_id,
  11369. a.behospital_code,
  11370. a.bed_code,
  11371. a.file_code,
  11372. e.score_res as scoreBn,
  11373. a.NAME,
  11374. a.sex,
  11375. a.beh_dept_id,
  11376. a.beh_dept_name,
  11377. a.birthday,
  11378. a.behospital_date,
  11379. a.leave_hospital_date,
  11380. a.doctor_id,
  11381. a.doctor_name,
  11382. a.beh_doctor_id,
  11383. a.beh_doctor_name,
  11384. a.director_doctor_id,
  11385. a.director_doctor_name,
  11386. a.diagnose,
  11387. a.placefile_date,
  11388. a.ward_name
  11389. FROM
  11390. med_behospital_info a,
  11391. med_qcresult_cases e
  11392. WHERE
  11393. a.is_deleted = 'N'
  11394. AND e.is_deleted = 'N'
  11395. AND a.hospital_id = e.hospital_id
  11396. AND a.behospital_code = e.behospital_code
  11397. AND a.qc_type_id != 0
  11398. AND e.cases_id = 243
  11399. <if test="qcResultPageVO.titleName != null ">
  11400. <if test="qcResultPageVO.titleName == '不合格数'">
  11401. AND e.`level`='不合格'
  11402. </if>
  11403. <if test="qcResultPageVO.titleName == '合格数'">
  11404. AND e.`level`='合格'
  11405. </if>
  11406. </if>
  11407. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11408. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11409. </if>
  11410. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11411. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11412. </if>
  11413. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11414. <if test="qcResultPageVO.startDate != null ">
  11415. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11416. </if>
  11417. <if test="qcResultPageVO.endDate != null ">
  11418. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11419. </if>
  11420. </if>
  11421. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11422. <if test="qcResultPageVO.startDate != null ">
  11423. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11424. </if>
  11425. <if test="qcResultPageVO.endDate != null">
  11426. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11427. </if>
  11428. </if>
  11429. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11430. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11431. </if>
  11432. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11433. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  11434. </if>
  11435. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11436. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11437. </if>
  11438. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11439. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11440. </if>
  11441. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11442. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11443. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11444. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11445. </if>
  11446. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11447. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11448. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11449. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11450. </if>
  11451. )be
  11452. left join med_check_info mci
  11453. on mci.is_deleted = 'N'
  11454. and mci.check_type = 0
  11455. and be.hospital_id = mci.hospital_id
  11456. and be.behospital_code = mci.behospital_code
  11457. left join med_check_info hm_mci
  11458. on hm_mci.is_deleted = 'N'
  11459. and hm_mci.check_type = 1
  11460. and be.hospital_id = hm_mci.hospital_id
  11461. and be.behospital_code = hm_mci.behospital_code
  11462. left join med_qcresult_info b
  11463. on b.is_deleted = 'N'
  11464. AND be.hospital_id = b.hospital_id
  11465. AND be.behospital_code = b.behospital_code
  11466. where
  11467. 1=1
  11468. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  11469. AND b.`level` = #{qcResultPageVO.level}
  11470. </if>
  11471. ) t1
  11472. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11473. AND t1.behospital_code = t2.behospital_code
  11474. AND t2.is_deleted = 'N'
  11475. ) t,
  11476. (
  11477. SELECT
  11478. a.beh_dept_id AS deptId,
  11479. a.beh_dept_name AS deptName
  11480. FROM
  11481. med_behospital_info a,
  11482. med_qcresult_cases c,
  11483. med_qcresult_detail d,
  11484. qc_cases_entry e
  11485. WHERE
  11486. a.is_deleted = 'N'
  11487. AND c.is_deleted = 'N'
  11488. AND d.is_deleted = 'N'
  11489. AND e.is_deleted = 'N'
  11490. AND a.hospital_id = c.hospital_id
  11491. AND a.hospital_id = d.hospital_id
  11492. AND a.behospital_code = c.behospital_code
  11493. AND a.behospital_code = d.behospital_code
  11494. AND c.cases_id = d.cases_id
  11495. AND d.cases_id = e.cases_id
  11496. AND d.cases_entry_id = e.id
  11497. AND d.cases_id = 243
  11498. AND a.qc_type_id != 0
  11499. <!-- <if test="qcResultPageVO.titleName != null ">-->
  11500. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  11501. <!-- AND c.`level`='不合格'-->
  11502. <!-- </if>-->
  11503. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  11504. <!-- AND c.`level`='合格'-->
  11505. <!-- </if>-->
  11506. <!-- </if>-->
  11507. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11508. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11509. </if>
  11510. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11511. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11512. </if>
  11513. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11514. <if test="qcResultPageVO.startDate != null ">
  11515. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11516. </if>
  11517. <if test="qcResultPageVO.endDate != null ">
  11518. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11519. </if>
  11520. </if>
  11521. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11522. <if test="qcResultPageVO.startDate != null ">
  11523. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11524. </if>
  11525. <if test="qcResultPageVO.endDate != null">
  11526. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11527. </if>
  11528. </if>
  11529. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11530. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11531. </if>
  11532. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11533. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  11534. </if>
  11535. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11536. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11537. </if>
  11538. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11539. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11540. </if>
  11541. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11542. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11543. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11544. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11545. </if>
  11546. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11547. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11548. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11549. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11550. </if>
  11551. GROUP BY
  11552. a.beh_dept_id,
  11553. a.beh_dept_name
  11554. ) t2
  11555. where
  11556. t.behDeptId = t2.deptId
  11557. AND t.behDeptName = t2.deptName
  11558. <if test="qcResultPageVO.checkStatus != null">
  11559. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  11560. </if>
  11561. <if test="qcResultPageVO.mrStatus != null">
  11562. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  11563. </if>
  11564. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  11565. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  11566. </if>
  11567. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  11568. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  11569. </if>
  11570. <if test="qcResultPageVO.chTimeStart != null ">
  11571. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  11572. </if>
  11573. <if test="qcResultPageVO.chTimeEnd != null ">
  11574. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  11575. </if>
  11576. <if test="qcResultPageVO.mrTimeStart != null ">
  11577. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  11578. </if>
  11579. <if test="qcResultPageVO.mrTimeEnd != null ">
  11580. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  11581. </if>
  11582. </select>
  11583. <!-- 未整改病历质控评分页(内页)-->
  11584. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11585. SELECT t.*
  11586. FROM
  11587. (SELECT DISTINCT
  11588. t1.hospital_id AS hospitalId,
  11589. t1.behospital_code AS behospitalCode,
  11590. t1.bed_code AS bedCode,
  11591. t1.LEVEL AS LEVEL,
  11592. t1.grade_type AS gradeType,
  11593. t1.score_res AS scoreRes,
  11594. t1.scoreBn,
  11595. t1.NAME AS NAME,
  11596. t1.sex AS sex,
  11597. t1.beh_dept_id AS behDeptId,
  11598. t1.beh_dept_name AS behDeptName,
  11599. t1.doctor_id AS doctorId,
  11600. t1.doctor_name AS doctorName,
  11601. t1.beh_doctor_id AS behDoctorId,
  11602. t1.beh_doctor_name AS behDoctorName,
  11603. t1.director_doctor_id AS directorDoctorId,
  11604. t1.director_doctor_name AS directorDoctorName,
  11605. t1.birthday AS birthday,
  11606. t1.behospital_date AS behospitalDate,
  11607. t1.leave_hospital_date AS leaveHospitalDate,
  11608. t1.placefile_date AS placefileDate,
  11609. t1.gmt_create AS gradeTime,
  11610. t1.diagnose,
  11611. t1.ward_name AS wardName,
  11612. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11613. t1.file_code AS fileCode,
  11614. t1.checkStatus,
  11615. t1.mrStatus,
  11616. t1.chName,
  11617. t1.mrName,
  11618. t1.chTime,
  11619. t1.mrTime
  11620. FROM
  11621. (SELECT
  11622. be.*,
  11623. ifnull(mci.status,0) AS checkStatus,
  11624. ifnull(hm_mci.status,0) AS mrStatus,
  11625. mci.check_name as chName,
  11626. e.score_res as scoreBn,
  11627. hm_mci.check_name as mrName,
  11628. mci.gmt_create as chTime,
  11629. hm_mci.gmt_create as mrTime
  11630. FROM
  11631. (
  11632. SELECT DISTINCT
  11633. a.hospital_id,
  11634. a.behospital_code,
  11635. a.bed_code,
  11636. a.file_code,
  11637. b.LEVEL,
  11638. b.grade_type,
  11639. b.score_res,
  11640. a.NAME,
  11641. a.sex,
  11642. a.beh_dept_id,
  11643. a.beh_dept_name,
  11644. a.birthday,
  11645. a.behospital_date,
  11646. a.leave_hospital_date,
  11647. a.doctor_id,
  11648. a.doctor_name,
  11649. a.beh_doctor_id,
  11650. a.beh_doctor_name,
  11651. a.director_doctor_id,
  11652. a.director_doctor_name,
  11653. a.diagnose,
  11654. a.placefile_date,
  11655. a.ward_name,
  11656. b.gmt_create
  11657. FROM
  11658. med_behospital_info a,
  11659. med_qcresult_info b,
  11660. med_qcresult_detail c,
  11661. qc_cases_entry d
  11662. WHERE
  11663. a.is_deleted = 'N'
  11664. AND b.is_deleted = 'N'
  11665. AND c.is_deleted = 'N'
  11666. AND d.is_deleted = 'N'
  11667. AND a.hospital_id = b.hospital_id
  11668. AND a.hospital_id = c.hospital_id
  11669. AND a.behospital_code = b.behospital_code
  11670. AND a.behospital_code = c.behospital_code
  11671. AND c.cases_id = d.cases_id
  11672. AND c.cases_entry_id = d.id
  11673. AND a.qc_type_id != 0
  11674. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11675. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11676. </if>
  11677. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11678. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11679. </if>
  11680. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11681. <if test="qcResultShortPageVO.startDate != null ">
  11682. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11683. </if>
  11684. <if test="qcResultShortPageVO.endDate != null ">
  11685. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11686. </if>
  11687. </if>
  11688. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11689. <if test="qcResultShortPageVO.startDate != null ">
  11690. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11691. </if>
  11692. <if test="qcResultShortPageVO.endDate != null">
  11693. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11694. </if>
  11695. </if>
  11696. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11697. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11698. </if>
  11699. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11700. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11701. </if>
  11702. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11703. AND b.`level` = #{qcResultShortPageVO.level}
  11704. </if>
  11705. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11706. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11707. </if>
  11708. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11709. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11710. </if>
  11711. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11712. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11713. </if>
  11714. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11715. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11716. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11717. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11718. </if>
  11719. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11720. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11721. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11722. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11723. </if>
  11724. <if test="qcResultShortPageVO.casesEntryId != null ">
  11725. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11726. </if>
  11727. <if test="qcResultShortPageVO.isReject != null">
  11728. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11729. </if>
  11730. <if test="qcResultShortPageVO.ruleType != null">
  11731. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11732. </if>
  11733. )be
  11734. left join med_check_info mci
  11735. on mci.is_deleted = 'N'
  11736. and mci.check_type = 0
  11737. and be.hospital_id = mci.hospital_id
  11738. and be.behospital_code = mci.behospital_code
  11739. left join med_check_info hm_mci
  11740. on hm_mci.is_deleted = 'N'
  11741. and hm_mci.check_type = 1
  11742. and be.hospital_id = hm_mci.hospital_id
  11743. and be.behospital_code = hm_mci.behospital_code
  11744. LEFT JOIN med_qcresult_cases e
  11745. on be.behospital_code = e.behospital_code
  11746. and be.hospital_id = e.hospital_id
  11747. AND e.is_deleted = 'N'
  11748. and e.cases_id = 243
  11749. ) t1
  11750. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11751. AND t1.behospital_code = t2.behospital_code
  11752. AND t2.is_deleted = 'N'
  11753. ) t
  11754. where 1=1
  11755. <if test="qcResultShortPageVO.checkStatus != null">
  11756. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11757. </if>
  11758. <if test="qcResultShortPageVO.mrStatus != null">
  11759. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11760. </if>
  11761. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11762. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11763. </if>
  11764. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11765. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11766. </if>
  11767. <if test="qcResultShortPageVO.chTimeStart != null ">
  11768. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11769. </if>
  11770. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11771. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11772. </if>
  11773. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11774. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11775. </if>
  11776. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11777. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11778. </if>
  11779. </select>
  11780. <!-- 未整改病历质控评分页-科室(内页)-->
  11781. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  11782. SELECT t.*
  11783. FROM
  11784. (SELECT DISTINCT
  11785. t1.hospital_id AS hospitalId,
  11786. t1.behospital_code AS behospitalCode,
  11787. t1.bed_code AS bedCode,
  11788. t1.LEVEL AS LEVEL,
  11789. t1.grade_type AS gradeType,
  11790. t1.score_res AS scoreRes,
  11791. t1.scoreBn,
  11792. t1.NAME AS NAME,
  11793. t1.sex AS sex,
  11794. t1.beh_dept_id AS behDeptId,
  11795. t1.beh_dept_name AS behDeptName,
  11796. t1.doctor_id AS doctorId,
  11797. t1.doctor_name AS doctorName,
  11798. t1.beh_doctor_id AS behDoctorId,
  11799. t1.beh_doctor_name AS behDoctorName,
  11800. t1.director_doctor_id AS directorDoctorId,
  11801. t1.director_doctor_name AS directorDoctorName,
  11802. t1.birthday AS birthday,
  11803. t1.behospital_date AS behospitalDate,
  11804. t1.leave_hospital_date AS leaveHospitalDate,
  11805. t1.placefile_date AS placefileDate,
  11806. t1.gmt_create AS gradeTime,
  11807. t1.diagnose,
  11808. t1.ward_name AS wardName,
  11809. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11810. t1.file_code AS fileCode,
  11811. t1.checkStatus,
  11812. t1.mrStatus,
  11813. t1.chName,
  11814. t1.mrName,
  11815. t1.chTime,
  11816. t1.mrTime
  11817. FROM
  11818. (SELECT
  11819. be.*,
  11820. ifnull(mci.status,0) AS checkStatus,
  11821. ifnull(hm_mci.status,0) AS mrStatus,
  11822. mci.check_name as chName,
  11823. e.score_res as scoreBn,
  11824. hm_mci.check_name as mrName,
  11825. mci.gmt_create as chTime,
  11826. hm_mci.gmt_create as mrTime
  11827. FROM
  11828. (
  11829. SELECT DISTINCT
  11830. a.hospital_id,
  11831. a.behospital_code,
  11832. a.bed_code,
  11833. a.file_code,
  11834. b.LEVEL,
  11835. b.grade_type,
  11836. b.score_res,
  11837. a.NAME,
  11838. a.sex,
  11839. a.beh_dept_id,
  11840. a.beh_dept_name,
  11841. a.birthday,
  11842. a.behospital_date,
  11843. a.leave_hospital_date,
  11844. a.doctor_id,
  11845. a.doctor_name,
  11846. a.beh_doctor_id,
  11847. a.beh_doctor_name,
  11848. a.director_doctor_id,
  11849. a.director_doctor_name,
  11850. a.diagnose,
  11851. a.placefile_date,
  11852. a.ward_name,
  11853. b.gmt_create
  11854. FROM
  11855. med_behospital_info a,
  11856. med_qcresult_info b,
  11857. med_qcresult_detail c,
  11858. qc_cases_entry d,
  11859. sys_user_dept f
  11860. WHERE
  11861. a.is_deleted = 'N'
  11862. AND b.is_deleted = 'N'
  11863. AND c.is_deleted = 'N'
  11864. AND d.is_deleted = 'N'
  11865. AND f.is_deleted = 'N'
  11866. AND a.hospital_id = b.hospital_id
  11867. AND a.hospital_id = c.hospital_id
  11868. AND a.hospital_id = f.hospital_id
  11869. AND a.behospital_code = b.behospital_code
  11870. AND a.behospital_code = c.behospital_code
  11871. AND c.cases_id = d.cases_id
  11872. AND a.beh_dept_id = f.dept_id
  11873. AND c.cases_entry_id = d.id
  11874. AND a.qc_type_id != 0
  11875. <if test="qcResultShortPageVO.userId!=null">
  11876. AND f.user_id = #{qcResultShortPageVO.userId}
  11877. </if>
  11878. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11879. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11880. </if>
  11881. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11882. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11883. </if>
  11884. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11885. <if test="qcResultShortPageVO.startDate != null ">
  11886. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11887. </if>
  11888. <if test="qcResultShortPageVO.endDate != null ">
  11889. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11890. </if>
  11891. </if>
  11892. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11893. <if test="qcResultShortPageVO.startDate != null ">
  11894. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11895. </if>
  11896. <if test="qcResultShortPageVO.endDate != null">
  11897. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11898. </if>
  11899. </if>
  11900. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11901. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11902. </if>
  11903. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11904. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11905. </if>
  11906. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11907. AND b.`level` = #{qcResultShortPageVO.level}
  11908. </if>
  11909. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11910. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11911. </if>
  11912. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11913. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11914. </if>
  11915. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11916. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11917. </if>
  11918. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11919. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11920. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11921. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11922. </if>
  11923. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11924. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11925. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11926. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11927. </if>
  11928. <if test="qcResultShortPageVO.casesEntryId != null ">
  11929. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11930. </if>
  11931. <if test="qcResultShortPageVO.isReject != null">
  11932. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11933. </if>
  11934. <if test="qcResultShortPageVO.ruleType != null">
  11935. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11936. </if>
  11937. )be
  11938. left join med_check_info mci
  11939. on mci.is_deleted = 'N'
  11940. and mci.check_type = 0
  11941. and be.hospital_id = mci.hospital_id
  11942. and be.behospital_code = mci.behospital_code
  11943. left join med_check_info hm_mci
  11944. on hm_mci.is_deleted = 'N'
  11945. and hm_mci.check_type = 1
  11946. and be.hospital_id = hm_mci.hospital_id
  11947. and be.behospital_code = hm_mci.behospital_code
  11948. LEFT JOIN med_qcresult_cases e
  11949. on be.behospital_code = e.behospital_code
  11950. and be.hospital_id = e.hospital_id
  11951. AND e.is_deleted = 'N'
  11952. and e.cases_id = 243
  11953. ) t1
  11954. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11955. AND t1.behospital_code = t2.behospital_code
  11956. AND t2.is_deleted = 'N'
  11957. ) t
  11958. where 1=1
  11959. <if test="qcResultShortPageVO.checkStatus != null">
  11960. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11961. </if>
  11962. <if test="qcResultShortPageVO.mrStatus != null">
  11963. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11964. </if>
  11965. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11966. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11967. </if>
  11968. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11969. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11970. </if>
  11971. <if test="qcResultShortPageVO.chTimeStart != null ">
  11972. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11973. </if>
  11974. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11975. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11976. </if>
  11977. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11978. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11979. </if>
  11980. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11981. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11982. </if>
  11983. </select>
  11984. <!-- 病案首页不合格/合格数病历详情页导出-->
  11985. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  11986. SELECT
  11987. f1.behDeptId,
  11988. f1.behDeptName,
  11989. f1.doctorName,
  11990. f1.patName,
  11991. f1.behospitalCode,
  11992. f1.hospitalId,
  11993. f1.behospitalDate,
  11994. f1.leaveHospitalDate,
  11995. f1.score,
  11996. f1.scoreBn,
  11997. f2.avgScore,
  11998. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  11999. f1.msg,
  12000. f1.caseName,
  12001. </if>
  12002. f1.checkStatus,
  12003. f1.mrStatus,
  12004. f1.chName,
  12005. f1.mrName,
  12006. f1.chTime,
  12007. f1.mrTime
  12008. FROM
  12009. (SELECT
  12010. t.doctorName,
  12011. t.`name` AS patName,
  12012. t.behospitalCode AS behospitalCode,
  12013. t.behospitalDate AS behospitalDate,
  12014. t.leaveHospitalDate AS leaveHospitalDate,
  12015. qi.score_res AS score,
  12016. t.scoreBn,
  12017. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12018. qd.msg AS msg,
  12019. qc.NAME AS caseName,
  12020. </if>
  12021. t.behDeptId,
  12022. t.behDeptName,
  12023. t.hospitalId,
  12024. t.checkStatus,
  12025. t.mrStatus,
  12026. t.chName,
  12027. t.mrName,
  12028. t.chTime,
  12029. t.mrTime
  12030. FROM
  12031. (SELECT DISTINCT
  12032. t1.hospital_id AS hospitalId,
  12033. t1.behospital_code AS behospitalCode,
  12034. t1.bed_code AS bedCode,
  12035. t1.LEVEL AS LEVEL,
  12036. t1.grade_type AS gradeType,
  12037. t1.score_res AS scoreRes,
  12038. t1.scoreBn,
  12039. t1.NAME AS NAME,
  12040. t1.sex AS sex,
  12041. t1.beh_dept_id AS behDeptId,
  12042. t1.beh_dept_name AS behDeptName,
  12043. t1.doctor_id AS doctorId,
  12044. t1.doctor_name AS doctorName,
  12045. t1.beh_doctor_id AS behDoctorId,
  12046. t1.beh_doctor_name AS behDoctorName,
  12047. t1.director_doctor_id AS directorDoctorId,
  12048. t1.director_doctor_name AS directorDoctorName,
  12049. t1.birthday AS birthday,
  12050. t1.behospital_date AS behospitalDate,
  12051. t1.leave_hospital_date AS leaveHospitalDate,
  12052. t1.placefile_date AS placefileDate,
  12053. t1.gmt_create AS gradeTime,
  12054. t1.diagnose,
  12055. t1.ward_name AS wardName,
  12056. t2.age,
  12057. t1.file_code AS fileCode,
  12058. t1.checkStatus,
  12059. t1.mrStatus,
  12060. t1.chName,
  12061. t1.mrName,
  12062. t1.chTime,
  12063. t1.mrTime
  12064. FROM
  12065. (SELECT
  12066. be.*,
  12067. b.LEVEL,
  12068. b.grade_type,
  12069. b.score_res,
  12070. b.gmt_create,
  12071. ifnull(mci.status,0) AS checkStatus,
  12072. ifnull(hm_mci.status,0) AS mrStatus,
  12073. mci.check_name as chName,
  12074. hm_mci.check_name as mrName,
  12075. mci.gmt_create as chTime,
  12076. hm_mci.gmt_create as mrTime
  12077. FROM
  12078. (
  12079. SELECT DISTINCT
  12080. a.hospital_id,
  12081. a.behospital_code,
  12082. a.bed_code,
  12083. a.file_code,
  12084. c.score_res as scoreBn,
  12085. c.cases_id,
  12086. a.NAME,
  12087. a.sex,
  12088. a.beh_dept_id,
  12089. a.beh_dept_name,
  12090. a.birthday,
  12091. a.behospital_date,
  12092. a.leave_hospital_date,
  12093. a.doctor_id,
  12094. a.doctor_name,
  12095. a.beh_doctor_id,
  12096. a.beh_doctor_name,
  12097. a.director_doctor_id,
  12098. a.director_doctor_name,
  12099. a.diagnose,
  12100. a.placefile_date,
  12101. a.ward_name
  12102. FROM
  12103. med_behospital_info a,
  12104. med_qcresult_cases c
  12105. WHERE
  12106. a.is_deleted = 'N'
  12107. AND c.is_deleted = 'N'
  12108. AND a.hospital_id = c.hospital_id
  12109. AND a.behospital_code = c.behospital_code
  12110. AND a.qc_type_id != 0
  12111. AND c.cases_id = 243
  12112. <if test="qcResultShortPageVO.titleName != null ">
  12113. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12114. AND c.`level`='不合格'
  12115. </if>
  12116. <if test="qcResultShortPageVO.titleName == '合格数'">
  12117. AND c.`level`='合格'
  12118. </if>
  12119. </if>
  12120. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12121. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12122. </if>
  12123. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12124. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12125. </if>
  12126. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12127. <if test="qcResultShortPageVO.startDate != null ">
  12128. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12129. </if>
  12130. <if test="qcResultShortPageVO.endDate != null ">
  12131. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12132. </if>
  12133. </if>
  12134. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12135. <if test="qcResultShortPageVO.startDate != null ">
  12136. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12137. </if>
  12138. <if test="qcResultShortPageVO.endDate != null">
  12139. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12140. </if>
  12141. </if>
  12142. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12143. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12144. </if>
  12145. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12146. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12147. </if>
  12148. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12149. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12150. </if>
  12151. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12152. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12153. </if>
  12154. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12155. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12156. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12157. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12158. </if>
  12159. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12160. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12161. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12162. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12163. </if>
  12164. )be
  12165. left join med_check_info mci
  12166. on mci.is_deleted = 'N'
  12167. and mci.check_type = 0
  12168. and be.hospital_id = mci.hospital_id
  12169. and be.behospital_code = mci.behospital_code
  12170. left join med_check_info hm_mci
  12171. on hm_mci.is_deleted = 'N'
  12172. and hm_mci.check_type = 1
  12173. and be.hospital_id = hm_mci.hospital_id
  12174. and be.behospital_code = hm_mci.behospital_code
  12175. left join med_qcresult_info b
  12176. on b.is_deleted = 'N'
  12177. AND be.hospital_id = b.hospital_id
  12178. AND be.behospital_code = b.behospital_code
  12179. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12180. AND b.`level` = #{qcResultPageVO.level}
  12181. </if>
  12182. left join qc_cases_entry d
  12183. on d.is_deleted = 'N'
  12184. AND be.cases_id = d.cases_id
  12185. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12186. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12187. </if>
  12188. <if test="qcResultShortPageVO.casesEntryId != null ">
  12189. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12190. </if>
  12191. <if test="qcResultShortPageVO.ruleType != null">
  12192. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12193. </if>
  12194. ) t1
  12195. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12196. AND t1.behospital_code = t2.behospital_code
  12197. AND t2.is_deleted = 'N'
  12198. ) t
  12199. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12200. AND t.hospitalId = qi.hospital_id
  12201. AND t.behospitalCode = qi.behospital_code
  12202. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12203. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12204. AND t.hospitalId = qd.hospital_id
  12205. AND t.behospitalCode = qd.behospital_code
  12206. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12207. AND qd.cases_id = qc.id
  12208. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12209. AND qd.cases_id = qce.cases_id
  12210. AND qd.cases_entry_id = qce.id
  12211. </if>
  12212. where 1=1
  12213. <if test="qcResultShortPageVO.checkStatus != null">
  12214. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12215. </if>
  12216. <if test="qcResultShortPageVO.mrStatus != null">
  12217. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12218. </if>
  12219. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12220. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12221. </if>
  12222. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12223. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12224. </if>
  12225. <if test="qcResultShortPageVO.chTimeStart != null ">
  12226. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12227. </if>
  12228. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12229. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12230. </if>
  12231. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12232. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12233. </if>
  12234. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12235. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12236. </if>
  12237. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12238. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12239. </if>
  12240. <if test="qcResultShortPageVO.casesEntryId != null ">
  12241. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12242. </if>
  12243. )f1,
  12244. (SELECT
  12245. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12246. t.behDeptId,
  12247. t.behDeptName
  12248. FROM
  12249. (SELECT DISTINCT
  12250. t1.hospital_id AS hospitalId,
  12251. t1.behospital_code AS behospitalCode,
  12252. t1.bed_code AS bedCode,
  12253. t1.LEVEL AS LEVEL,
  12254. t1.grade_type AS gradeType,
  12255. t1.score_res AS scoreRes,
  12256. t1.NAME AS NAME,
  12257. t1.sex AS sex,
  12258. t1.beh_dept_id AS behDeptId,
  12259. t1.beh_dept_name AS behDeptName,
  12260. t1.doctor_id AS doctorId,
  12261. t1.doctor_name AS doctorName,
  12262. t1.beh_doctor_id AS behDoctorId,
  12263. t1.beh_doctor_name AS behDoctorName,
  12264. t1.director_doctor_id AS directorDoctorId,
  12265. t1.director_doctor_name AS directorDoctorName,
  12266. t1.birthday AS birthday,
  12267. t1.behospital_date AS behospitalDate,
  12268. t1.leave_hospital_date AS leaveHospitalDate,
  12269. t1.placefile_date AS placefileDate,
  12270. t1.gmt_create AS gradeTime,
  12271. t1.diagnose,
  12272. t1.ward_name AS wardName,
  12273. t2.age,
  12274. t1.file_code AS fileCode,
  12275. t1.checkStatus,
  12276. t1.mrStatus,
  12277. t1.chName,
  12278. t1.mrName,
  12279. t1.chTime,
  12280. t1.mrTime
  12281. FROM
  12282. (SELECT
  12283. be.*,
  12284. b.grade_type,
  12285. b.score_res,
  12286. b.gmt_create,
  12287. b.LEVEL,
  12288. ifnull(mci.status,0) AS checkStatus,
  12289. ifnull(hm_mci.status,0) AS mrStatus,
  12290. mci.check_name as chName,
  12291. hm_mci.check_name as mrName,
  12292. mci.gmt_create as chTime,
  12293. hm_mci.gmt_create as mrTime
  12294. FROM
  12295. (
  12296. SELECT DISTINCT
  12297. a.hospital_id,
  12298. a.behospital_code,
  12299. a.bed_code,
  12300. a.file_code,
  12301. a.NAME,
  12302. a.sex,
  12303. a.beh_dept_id,
  12304. a.beh_dept_name,
  12305. a.birthday,
  12306. a.behospital_date,
  12307. a.leave_hospital_date,
  12308. a.doctor_id,
  12309. a.doctor_name,
  12310. a.beh_doctor_id,
  12311. a.beh_doctor_name,
  12312. a.director_doctor_id,
  12313. a.director_doctor_name,
  12314. a.diagnose,
  12315. a.placefile_date,
  12316. a.ward_name
  12317. FROM
  12318. med_behospital_info a,
  12319. med_qcresult_detail k,
  12320. med_qcresult_cases c,
  12321. qc_cases_entry d
  12322. WHERE
  12323. a.is_deleted = 'N'
  12324. AND c.is_deleted = 'N'
  12325. AND d.is_deleted = 'N'
  12326. AND a.hospital_id = c.hospital_id
  12327. AND a.behospital_code = c.behospital_code
  12328. AND c.cases_id = d.cases_id
  12329. AND a.hospital_id = k.hospital_id
  12330. AND a.behospital_code = k.behospital_code
  12331. AND c.cases_id = k.cases_id
  12332. AND k.cases_id = d.cases_id
  12333. AND k.cases_entry_id = d.id
  12334. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12335. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12336. <!-- AND c.`level`='不合格'-->
  12337. <!-- </if>-->
  12338. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12339. <!-- AND c.`level`='合格'-->
  12340. <!-- </if>-->
  12341. <!-- </if>-->
  12342. AND a.qc_type_id != 0
  12343. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12344. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12345. </if>
  12346. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12347. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12348. </if>
  12349. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12350. <if test="qcResultShortPageVO.startDate != null ">
  12351. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12352. </if>
  12353. <if test="qcResultShortPageVO.endDate != null ">
  12354. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12355. </if>
  12356. </if>
  12357. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12358. <if test="qcResultShortPageVO.startDate != null ">
  12359. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12360. </if>
  12361. <if test="qcResultShortPageVO.endDate != null">
  12362. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12363. </if>
  12364. </if>
  12365. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12366. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12367. </if>
  12368. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12369. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12370. </if>
  12371. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12372. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12373. </if>
  12374. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12375. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12376. </if>
  12377. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12378. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12379. </if>
  12380. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12381. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12382. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12383. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12384. </if>
  12385. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12386. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12387. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12388. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12389. </if>
  12390. <if test="qcResultShortPageVO.casesEntryId != null ">
  12391. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12392. </if>
  12393. <if test="qcResultShortPageVO.ruleType != null">
  12394. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12395. </if>
  12396. )be
  12397. left join med_check_info mci
  12398. on mci.is_deleted = 'N'
  12399. and mci.check_type = 0
  12400. and be.hospital_id = mci.hospital_id
  12401. and be.behospital_code = mci.behospital_code
  12402. left join med_check_info hm_mci
  12403. on hm_mci.is_deleted = 'N'
  12404. and hm_mci.check_type = 1
  12405. and be.hospital_id = hm_mci.hospital_id
  12406. and be.behospital_code = hm_mci.behospital_code
  12407. left join med_qcresult_info b
  12408. on b.is_deleted = 'N'
  12409. AND be.hospital_id = b.hospital_id
  12410. AND be.behospital_code = b.behospital_code
  12411. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12412. AND b.`level` = #{qcResultPageVO.level}
  12413. </if>
  12414. ) t1
  12415. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12416. AND t1.behospital_code = t2.behospital_code
  12417. AND t2.is_deleted = 'N'
  12418. ) t
  12419. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12420. AND t.hospitalId = qi.hospital_id
  12421. AND t.behospitalCode = qi.behospital_code
  12422. where 1=1
  12423. <if test="qcResultShortPageVO.checkStatus != null">
  12424. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12425. </if>
  12426. <if test="qcResultShortPageVO.mrStatus != null">
  12427. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12428. </if>
  12429. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12430. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12431. </if>
  12432. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12433. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12434. </if>
  12435. <if test="qcResultShortPageVO.chTimeStart != null ">
  12436. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12437. </if>
  12438. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12439. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12440. </if>
  12441. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12442. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12443. </if>
  12444. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12445. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12446. </if>
  12447. GROUP BY
  12448. t.behDeptId,
  12449. t.behDeptName
  12450. )f2
  12451. WHERE
  12452. f1.behDeptId = f2.behDeptId
  12453. AND f1.behDeptName = f2.behDeptName
  12454. </select>
  12455. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  12456. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  12457. SELECT
  12458. f1.behDeptId,
  12459. f1.behDeptName,
  12460. f1.doctorName,
  12461. f1.patName,
  12462. f1.behospitalCode,
  12463. f1.hospitalId,
  12464. f1.behospitalDate,
  12465. f1.leaveHospitalDate,
  12466. f1.score,
  12467. f1.scoreBn,
  12468. f2.avgScore,
  12469. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12470. f1.msg,
  12471. f1.caseName,
  12472. </if>
  12473. f1.checkStatus,
  12474. f1.mrStatus,
  12475. f1.chName,
  12476. f1.mrName,
  12477. f1.chTime,
  12478. f1.mrTime
  12479. FROM
  12480. (SELECT
  12481. t.doctorName AS doctorName,
  12482. t.doctorId,
  12483. t.`name` AS patName,
  12484. t.behospitalCode AS behospitalCode,
  12485. t.behospitalDate AS behospitalDate,
  12486. t.leaveHospitalDate AS leaveHospitalDate,
  12487. qi.score_res AS score,
  12488. t.scoreBn,
  12489. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12490. qd.msg AS msg,
  12491. qc.NAME AS caseName,
  12492. </if>
  12493. t.behDeptId,
  12494. t.behDeptName,
  12495. t.hospitalId,
  12496. t.checkStatus,
  12497. t.mrStatus,
  12498. t.chName,
  12499. t.mrName,
  12500. t.chTime,
  12501. t.mrTime
  12502. FROM
  12503. (SELECT DISTINCT
  12504. t1.hospital_id AS hospitalId,
  12505. t1.behospital_code AS behospitalCode,
  12506. t1.bed_code AS bedCode,
  12507. t1.LEVEL AS LEVEL,
  12508. t1.grade_type AS gradeType,
  12509. t1.score_res AS scoreRes,
  12510. t1.scoreBn,
  12511. t1.NAME AS NAME,
  12512. t1.sex AS sex,
  12513. t1.beh_dept_id AS behDeptId,
  12514. t1.beh_dept_name AS behDeptName,
  12515. t1.doctor_id AS doctorId,
  12516. t1.doctor_name AS doctorName,
  12517. t1.beh_doctor_id AS behDoctorId,
  12518. t1.beh_doctor_name AS behDoctorName,
  12519. t1.director_doctor_id AS directorDoctorId,
  12520. t1.director_doctor_name AS directorDoctorName,
  12521. t1.birthday AS birthday,
  12522. t1.behospital_date AS behospitalDate,
  12523. t1.leave_hospital_date AS leaveHospitalDate,
  12524. t1.placefile_date AS placefileDate,
  12525. t1.gmt_create AS gradeTime,
  12526. t1.diagnose,
  12527. t1.ward_name AS wardName,
  12528. t2.age,
  12529. t1.file_code AS fileCode,
  12530. t1.checkStatus,
  12531. t1.mrStatus,
  12532. t1.chName,
  12533. t1.mrName,
  12534. t1.chTime,
  12535. t1.mrTime
  12536. FROM
  12537. (SELECT
  12538. be.*,
  12539. b.LEVEL,
  12540. b.grade_type,
  12541. b.score_res,
  12542. b.gmt_create,
  12543. ifnull(mci.status,0) AS checkStatus,
  12544. ifnull(hm_mci.status,0) AS mrStatus,
  12545. mci.check_name as chName,
  12546. hm_mci.check_name as mrName,
  12547. mci.gmt_create as chTime,
  12548. hm_mci.gmt_create as mrTime
  12549. FROM
  12550. (
  12551. SELECT DISTINCT
  12552. a.hospital_id,
  12553. a.behospital_code,
  12554. a.bed_code,
  12555. a.file_code,
  12556. c.score_res as scoreBn,
  12557. c.cases_id,
  12558. a.NAME,
  12559. a.sex,
  12560. a.beh_dept_id,
  12561. a.beh_dept_name,
  12562. a.birthday,
  12563. a.behospital_date,
  12564. a.leave_hospital_date,
  12565. a.doctor_id,
  12566. a.doctor_name,
  12567. a.beh_doctor_id,
  12568. a.beh_doctor_name,
  12569. a.director_doctor_id,
  12570. a.director_doctor_name,
  12571. a.diagnose,
  12572. a.placefile_date,
  12573. a.ward_name
  12574. FROM
  12575. med_behospital_info a,
  12576. sys_user_dept b,
  12577. med_qcresult_cases c
  12578. WHERE
  12579. a.is_deleted = 'N'
  12580. AND b.is_deleted = 'N'
  12581. AND c.is_deleted = 'N'
  12582. AND a.hospital_id = b.hospital_id
  12583. AND a.beh_dept_id = b.dept_id
  12584. AND a.hospital_id = c.hospital_id
  12585. AND a.behospital_code = c.behospital_code
  12586. AND a.qc_type_id != 0
  12587. AND c.cases_id = 243
  12588. <if test="qcResultShortPageVO.userId!=null">
  12589. AND b.user_id = #{qcResultShortPageVO.userId}
  12590. </if>
  12591. <if test="qcResultShortPageVO.titleName != null ">
  12592. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12593. AND c.`level`='不合格'
  12594. </if>
  12595. <if test="qcResultShortPageVO.titleName == '合格数'">
  12596. AND c.`level`='合格'
  12597. </if>
  12598. </if>
  12599. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12600. AND a.doctor_name like CONCAT('%', #{qcResultShortPageVO.doctorName}, '%')
  12601. </if>
  12602. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12603. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12604. </if>
  12605. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12606. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12607. </if>
  12608. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12609. <if test="qcResultShortPageVO.startDate != null ">
  12610. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12611. </if>
  12612. <if test="qcResultShortPageVO.endDate != null ">
  12613. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12614. </if>
  12615. </if>
  12616. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12617. <if test="qcResultShortPageVO.startDate != null ">
  12618. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12619. </if>
  12620. <if test="qcResultShortPageVO.endDate != null">
  12621. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12622. </if>
  12623. </if>
  12624. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12625. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12626. </if>
  12627. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12628. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  12629. </if>
  12630. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12631. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12632. </if>
  12633. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12634. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12635. </if>
  12636. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12637. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12638. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12639. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12640. </if>
  12641. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12642. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12643. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12644. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12645. </if>
  12646. )be
  12647. left join med_check_info mci
  12648. on mci.is_deleted = 'N'
  12649. and mci.check_type = 0
  12650. and be.hospital_id = mci.hospital_id
  12651. and be.behospital_code = mci.behospital_code
  12652. left join med_check_info hm_mci
  12653. on hm_mci.is_deleted = 'N'
  12654. and hm_mci.check_type = 1
  12655. and be.hospital_id = hm_mci.hospital_id
  12656. and be.behospital_code = hm_mci.behospital_code
  12657. left join med_qcresult_info b
  12658. on b.is_deleted = 'N'
  12659. AND be.hospital_id = b.hospital_id
  12660. AND be.behospital_code = b.behospital_code
  12661. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12662. AND b.`level` = #{qcResultPageVO.level}
  12663. </if>
  12664. left join qc_cases_entry d
  12665. on d.is_deleted = 'N'
  12666. AND be.cases_id = d.cases_id
  12667. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12668. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12669. </if>
  12670. <if test="qcResultShortPageVO.casesEntryId != null ">
  12671. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12672. </if>
  12673. <if test="qcResultShortPageVO.ruleType != null">
  12674. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12675. </if>
  12676. ) t1
  12677. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12678. AND t1.behospital_code = t2.behospital_code
  12679. AND t2.is_deleted = 'N'
  12680. ) t
  12681. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12682. AND t.hospitalId = qi.hospital_id
  12683. AND t.behospitalCode = qi.behospital_code
  12684. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12685. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12686. AND t.hospitalId = qd.hospital_id
  12687. AND t.behospitalCode = qd.behospital_code
  12688. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12689. AND qd.cases_id = qc.id
  12690. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12691. AND qd.cases_id = qce.cases_id
  12692. AND qd.cases_entry_id = qce.id
  12693. </if>
  12694. where 1=1
  12695. <if test="qcResultShortPageVO.checkStatus != null">
  12696. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12697. </if>
  12698. <if test="qcResultShortPageVO.mrStatus != null">
  12699. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12700. </if>
  12701. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12702. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12703. </if>
  12704. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12705. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12706. </if>
  12707. <if test="qcResultShortPageVO.chTimeStart != null ">
  12708. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12709. </if>
  12710. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12711. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12712. </if>
  12713. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12714. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12715. </if>
  12716. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12717. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12718. </if>
  12719. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12720. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12721. </if>
  12722. <if test="qcResultShortPageVO.casesEntryId != null ">
  12723. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12724. </if>
  12725. )f1,
  12726. (SELECT
  12727. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12728. t.doctorId,
  12729. t.doctorName
  12730. FROM
  12731. (SELECT DISTINCT
  12732. t1.hospital_id AS hospitalId,
  12733. t1.behospital_code AS behospitalCode,
  12734. t1.bed_code AS bedCode,
  12735. t1.LEVEL AS LEVEL,
  12736. t1.grade_type AS gradeType,
  12737. t1.score_res AS scoreRes,
  12738. t1.NAME AS NAME,
  12739. t1.sex AS sex,
  12740. t1.beh_dept_id AS behDeptId,
  12741. t1.beh_dept_name AS behDeptName,
  12742. t1.doctor_id AS doctorId,
  12743. t1.doctor_name AS doctorName,
  12744. t1.beh_doctor_id AS behDoctorId,
  12745. t1.beh_doctor_name AS behDoctorName,
  12746. t1.director_doctor_id AS directorDoctorId,
  12747. t1.director_doctor_name AS directorDoctorName,
  12748. t1.birthday AS birthday,
  12749. t1.behospital_date AS behospitalDate,
  12750. t1.leave_hospital_date AS leaveHospitalDate,
  12751. t1.placefile_date AS placefileDate,
  12752. t1.gmt_create AS gradeTime,
  12753. t1.diagnose,
  12754. t1.ward_name AS wardName,
  12755. t2.age,
  12756. t1.file_code AS fileCode,
  12757. t1.checkStatus,
  12758. t1.mrStatus,
  12759. t1.chName,
  12760. t1.mrName,
  12761. t1.chTime,
  12762. t1.mrTime
  12763. FROM
  12764. (SELECT
  12765. be.*,
  12766. b.grade_type,
  12767. b.score_res,
  12768. b.gmt_create,
  12769. b.LEVEL,
  12770. ifnull(mci.status,0) AS checkStatus,
  12771. ifnull(hm_mci.status,0) AS mrStatus,
  12772. mci.check_name as chName,
  12773. hm_mci.check_name as mrName,
  12774. mci.gmt_create as chTime,
  12775. hm_mci.gmt_create as mrTime
  12776. FROM
  12777. (
  12778. SELECT DISTINCT
  12779. a.hospital_id,
  12780. a.behospital_code,
  12781. a.bed_code,
  12782. a.file_code,
  12783. a.NAME,
  12784. a.sex,
  12785. a.beh_dept_id,
  12786. a.beh_dept_name,
  12787. a.birthday,
  12788. a.behospital_date,
  12789. a.leave_hospital_date,
  12790. a.doctor_id,
  12791. a.doctor_name,
  12792. a.beh_doctor_id,
  12793. a.beh_doctor_name,
  12794. a.director_doctor_id,
  12795. a.director_doctor_name,
  12796. a.diagnose,
  12797. a.placefile_date,
  12798. a.ward_name
  12799. FROM
  12800. med_behospital_info a,
  12801. med_qcresult_detail k,
  12802. sys_user_dept b,
  12803. med_qcresult_cases c,
  12804. qc_cases_entry d
  12805. WHERE
  12806. a.is_deleted = 'N'
  12807. AND b.is_deleted = 'N'
  12808. AND c.is_deleted = 'N'
  12809. AND d.is_deleted = 'N'
  12810. AND a.hospital_id = b.hospital_id
  12811. AND a.hospital_id = c.hospital_id
  12812. AND a.behospital_code = c.behospital_code
  12813. AND a.beh_dept_id = b.dept_id
  12814. AND c.cases_id = d.cases_id
  12815. AND a.hospital_id = k.hospital_id
  12816. AND a.behospital_code = k.behospital_code
  12817. AND c.cases_id = k.cases_id
  12818. AND k.cases_id = d.cases_id
  12819. AND k.cases_entry_id = d.id
  12820. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12821. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12822. <!-- AND c.`level`='不合格'-->
  12823. <!-- </if>-->
  12824. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12825. <!-- AND c.`level`='合格'-->
  12826. <!-- </if>-->
  12827. <!-- </if>-->
  12828. AND a.qc_type_id != 0
  12829. <if test="qcResultShortPageVO.userId!=null">
  12830. AND b.user_id = #{qcResultShortPageVO.userId}
  12831. </if>
  12832. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12833. and a.doctor_name = #{qcResultShortPageVO.doctorName}
  12834. </if>
  12835. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12836. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12837. </if>
  12838. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12839. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12840. </if>
  12841. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12842. <if test="qcResultShortPageVO.startDate != null ">
  12843. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12844. </if>
  12845. <if test="qcResultShortPageVO.endDate != null ">
  12846. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12847. </if>
  12848. </if>
  12849. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12850. <if test="qcResultShortPageVO.startDate != null ">
  12851. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12852. </if>
  12853. <if test="qcResultShortPageVO.endDate != null">
  12854. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12855. </if>
  12856. </if>
  12857. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12858. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12859. </if>
  12860. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12861. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  12862. </if>
  12863. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12864. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12865. </if>
  12866. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12867. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12868. </if>
  12869. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12870. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12871. </if>
  12872. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12873. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12874. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12875. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12876. </if>
  12877. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12878. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12879. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12880. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12881. </if>
  12882. <if test="qcResultShortPageVO.casesEntryId != null ">
  12883. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12884. </if>
  12885. <if test="qcResultShortPageVO.ruleType != null">
  12886. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12887. </if>
  12888. )be
  12889. left join med_check_info mci
  12890. on mci.is_deleted = 'N'
  12891. and mci.check_type = 0
  12892. and be.hospital_id = mci.hospital_id
  12893. and be.behospital_code = mci.behospital_code
  12894. left join med_check_info hm_mci
  12895. on hm_mci.is_deleted = 'N'
  12896. and hm_mci.check_type = 1
  12897. and be.hospital_id = hm_mci.hospital_id
  12898. and be.behospital_code = hm_mci.behospital_code
  12899. left join med_qcresult_info b
  12900. on b.is_deleted = 'N'
  12901. AND be.hospital_id = b.hospital_id
  12902. AND be.behospital_code = b.behospital_code
  12903. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12904. AND b.`level` = #{qcResultPageVO.level}
  12905. </if>
  12906. ) t1
  12907. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12908. AND t1.behospital_code = t2.behospital_code
  12909. AND t2.is_deleted = 'N'
  12910. ) t
  12911. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12912. AND t.hospitalId = qi.hospital_id
  12913. AND t.behospitalCode = qi.behospital_code
  12914. where 1=1
  12915. <if test="qcResultShortPageVO.checkStatus != null">
  12916. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12917. </if>
  12918. <if test="qcResultShortPageVO.mrStatus != null">
  12919. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12920. </if>
  12921. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12922. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12923. </if>
  12924. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12925. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12926. </if>
  12927. <if test="qcResultShortPageVO.chTimeStart != null ">
  12928. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12929. </if>
  12930. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12931. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12932. </if>
  12933. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12934. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12935. </if>
  12936. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12937. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12938. </if>
  12939. GROUP BY
  12940. t.behDeptId,
  12941. t.behDeptName,
  12942. t.doctorId,
  12943. t.doctorName
  12944. )f2
  12945. WHERE
  12946. f1.doctorId = f2.doctorId
  12947. AND f1.doctorName = f2.doctorName
  12948. </select>
  12949. <!-- 未整改病历缺陷评分详情页导出-->
  12950. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  12951. SELECT
  12952. f1.behDeptId,
  12953. f1.behDeptName,
  12954. f1.doctorName,
  12955. f1.patName,
  12956. f1.behospitalCode,
  12957. f1.hospitalId,
  12958. f1.behospitalDate,
  12959. f1.leaveHospitalDate,
  12960. f1.score,
  12961. f1.scoreBn,
  12962. f2.avgScore,
  12963. f1.msg,
  12964. f1.caseName,
  12965. f1.checkStatus,
  12966. f1.mrStatus,
  12967. f1.chName,
  12968. f1.mrName,
  12969. f1.chTime,
  12970. f1.mrTime
  12971. FROM
  12972. (SELECT
  12973. t.doctorName,
  12974. t.`name` AS patName,
  12975. t.behospitalCode AS behospitalCode,
  12976. t.behospitalDate AS behospitalDate,
  12977. t.leaveHospitalDate AS leaveHospitalDate,
  12978. qi.score_res AS score,
  12979. t.scoreBn,
  12980. qd.msg AS msg,
  12981. qc.NAME AS caseName,
  12982. t.behDeptId,
  12983. t.behDeptName,
  12984. t.hospitalId,
  12985. t.checkStatus,
  12986. t.mrStatus,
  12987. t.chName,
  12988. t.mrName,
  12989. t.chTime,
  12990. t.mrTime
  12991. FROM
  12992. (SELECT DISTINCT
  12993. t1.hospital_id AS hospitalId,
  12994. t1.behospital_code AS behospitalCode,
  12995. t1.bed_code AS bedCode,
  12996. t1.LEVEL AS LEVEL,
  12997. t1.grade_type AS gradeType,
  12998. t1.score_res AS scoreRes,
  12999. t1.scoreBn,
  13000. t1.NAME AS NAME,
  13001. t1.sex AS sex,
  13002. t1.beh_dept_id AS behDeptId,
  13003. t1.beh_dept_name AS behDeptName,
  13004. t1.doctor_id AS doctorId,
  13005. t1.doctor_name AS doctorName,
  13006. t1.beh_doctor_id AS behDoctorId,
  13007. t1.beh_doctor_name AS behDoctorName,
  13008. t1.director_doctor_id AS directorDoctorId,
  13009. t1.director_doctor_name AS directorDoctorName,
  13010. t1.birthday AS birthday,
  13011. t1.behospital_date AS behospitalDate,
  13012. t1.leave_hospital_date AS leaveHospitalDate,
  13013. t1.placefile_date AS placefileDate,
  13014. t1.gmt_create AS gradeTime,
  13015. t1.diagnose,
  13016. t1.ward_name AS wardName,
  13017. t2.age,
  13018. t1.file_code AS fileCode,
  13019. t1.checkStatus,
  13020. t1.mrStatus,
  13021. t1.chName,
  13022. t1.mrName,
  13023. t1.chTime,
  13024. t1.mrTime
  13025. FROM
  13026. (SELECT
  13027. be.*,
  13028. ifnull(mci.status,0) AS checkStatus,
  13029. ifnull(hm_mci.status,0) AS mrStatus,
  13030. mci.check_name as chName,
  13031. e.score_res as scoreBn,
  13032. hm_mci.check_name as mrName,
  13033. mci.gmt_create as chTime,
  13034. hm_mci.gmt_create as mrTime
  13035. FROM
  13036. (
  13037. SELECT DISTINCT
  13038. a.hospital_id,
  13039. a.behospital_code,
  13040. a.bed_code,
  13041. a.file_code,
  13042. b.LEVEL,
  13043. b.grade_type,
  13044. b.score_res,
  13045. a.NAME,
  13046. a.sex,
  13047. a.beh_dept_id,
  13048. a.beh_dept_name,
  13049. a.birthday,
  13050. a.behospital_date,
  13051. a.leave_hospital_date,
  13052. a.doctor_id,
  13053. a.doctor_name,
  13054. a.beh_doctor_id,
  13055. a.beh_doctor_name,
  13056. a.director_doctor_id,
  13057. a.director_doctor_name,
  13058. a.diagnose,
  13059. a.placefile_date,
  13060. a.ward_name,
  13061. b.gmt_create
  13062. FROM
  13063. med_behospital_info a,
  13064. med_qcresult_info b,
  13065. med_qcresult_detail c,
  13066. qc_cases_entry d
  13067. WHERE
  13068. a.is_deleted = 'N'
  13069. AND b.is_deleted = 'N'
  13070. AND c.is_deleted = 'N'
  13071. AND d.is_deleted = 'N'
  13072. AND a.hospital_id = b.hospital_id
  13073. AND a.hospital_id = c.hospital_id
  13074. AND a.behospital_code = b.behospital_code
  13075. AND a.behospital_code = c.behospital_code
  13076. AND c.cases_id = d.cases_id
  13077. AND c.cases_entry_id = d.id
  13078. AND a.qc_type_id != 0
  13079. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13080. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13081. </if>
  13082. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13083. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13084. </if>
  13085. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13086. <if test="qcResultShortPageVO.startDate != null ">
  13087. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13088. </if>
  13089. <if test="qcResultShortPageVO.endDate != null ">
  13090. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13091. </if>
  13092. </if>
  13093. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13094. <if test="qcResultShortPageVO.startDate != null ">
  13095. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13096. </if>
  13097. <if test="qcResultShortPageVO.endDate != null">
  13098. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13099. </if>
  13100. </if>
  13101. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13102. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13103. </if>
  13104. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13105. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13106. </if>
  13107. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13108. AND b.`level` = #{qcResultShortPageVO.level}
  13109. </if>
  13110. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13111. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13112. </if>
  13113. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13114. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13115. </if>
  13116. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13117. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13118. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13119. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13120. </if>
  13121. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13122. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13123. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13124. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13125. </if>
  13126. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13127. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13128. </if>
  13129. <if test="qcResultShortPageVO.casesEntryId != null ">
  13130. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13131. </if>
  13132. <if test="qcResultShortPageVO.isReject != null">
  13133. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13134. </if>
  13135. <if test="qcResultShortPageVO.ruleType != null">
  13136. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13137. </if>
  13138. )be
  13139. left join med_check_info mci
  13140. on mci.is_deleted = 'N'
  13141. and mci.check_type = 0
  13142. and be.hospital_id = mci.hospital_id
  13143. and be.behospital_code = mci.behospital_code
  13144. left join med_check_info hm_mci
  13145. on hm_mci.is_deleted = 'N'
  13146. and hm_mci.check_type = 1
  13147. and be.hospital_id = hm_mci.hospital_id
  13148. and be.behospital_code = hm_mci.behospital_code
  13149. LEFT JOIN med_qcresult_cases e
  13150. on be.behospital_code = e.behospital_code
  13151. and be.hospital_id = e.hospital_id
  13152. AND e.is_deleted = 'N'
  13153. and e.cases_id = 243
  13154. ) t1
  13155. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13156. AND t1.behospital_code = t2.behospital_code
  13157. AND t2.is_deleted = 'N'
  13158. ) t
  13159. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13160. AND t.hospitalId = qi.hospital_id
  13161. AND t.behospitalCode = qi.behospital_code
  13162. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13163. AND t.hospitalId = qd.hospital_id
  13164. AND t.behospitalCode = qd.behospital_code
  13165. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13166. AND qd.cases_id = qc.id
  13167. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13168. AND qd.cases_id = qce.cases_id
  13169. AND qd.cases_entry_id = qce.id
  13170. where 1=1
  13171. <if test="qcResultShortPageVO.checkStatus != null">
  13172. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13173. </if>
  13174. <if test="qcResultShortPageVO.mrStatus != null">
  13175. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13176. </if>
  13177. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13178. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13179. </if>
  13180. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13181. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13182. </if>
  13183. <if test="qcResultShortPageVO.chTimeStart != null ">
  13184. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13185. </if>
  13186. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13187. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13188. </if>
  13189. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13190. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13191. </if>
  13192. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13193. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13194. </if>
  13195. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13196. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13197. </if>
  13198. <if test="qcResultShortPageVO.casesEntryId != null ">
  13199. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13200. </if>
  13201. )f1,
  13202. (SELECT
  13203. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13204. t.behDeptId,
  13205. t.behDeptName
  13206. FROM
  13207. (SELECT DISTINCT
  13208. t1.hospital_id AS hospitalId,
  13209. t1.behospital_code AS behospitalCode,
  13210. t1.bed_code AS bedCode,
  13211. t1.LEVEL AS LEVEL,
  13212. t1.grade_type AS gradeType,
  13213. t1.score_res AS scoreRes,
  13214. t1.NAME AS NAME,
  13215. t1.sex AS sex,
  13216. t1.beh_dept_id AS behDeptId,
  13217. t1.beh_dept_name AS behDeptName,
  13218. t1.doctor_id AS doctorId,
  13219. t1.doctor_name AS doctorName,
  13220. t1.beh_doctor_id AS behDoctorId,
  13221. t1.beh_doctor_name AS behDoctorName,
  13222. t1.director_doctor_id AS directorDoctorId,
  13223. t1.director_doctor_name AS directorDoctorName,
  13224. t1.birthday AS birthday,
  13225. t1.behospital_date AS behospitalDate,
  13226. t1.leave_hospital_date AS leaveHospitalDate,
  13227. t1.placefile_date AS placefileDate,
  13228. t1.gmt_create AS gradeTime,
  13229. t1.diagnose,
  13230. t1.ward_name AS wardName,
  13231. t2.age,
  13232. t1.file_code AS fileCode,
  13233. t1.checkStatus,
  13234. t1.mrStatus,
  13235. t1.chName,
  13236. t1.mrName,
  13237. t1.chTime,
  13238. t1.mrTime
  13239. FROM
  13240. (SELECT
  13241. be.*,
  13242. ifnull(mci.status,0) AS checkStatus,
  13243. ifnull(hm_mci.status,0) AS mrStatus,
  13244. mci.check_name as chName,
  13245. hm_mci.check_name as mrName,
  13246. mci.gmt_create as chTime,
  13247. hm_mci.gmt_create as mrTime
  13248. FROM
  13249. (
  13250. SELECT DISTINCT
  13251. a.hospital_id,
  13252. a.behospital_code,
  13253. a.bed_code,
  13254. a.file_code,
  13255. b.LEVEL,
  13256. b.grade_type,
  13257. b.score_res,
  13258. a.NAME,
  13259. a.sex,
  13260. a.beh_dept_id,
  13261. a.beh_dept_name,
  13262. a.birthday,
  13263. a.behospital_date,
  13264. a.leave_hospital_date,
  13265. a.doctor_id,
  13266. a.doctor_name,
  13267. a.beh_doctor_id,
  13268. a.beh_doctor_name,
  13269. a.director_doctor_id,
  13270. a.director_doctor_name,
  13271. a.diagnose,
  13272. a.placefile_date,
  13273. a.ward_name,
  13274. b.gmt_create
  13275. FROM
  13276. med_behospital_info a,
  13277. med_qcresult_info b,
  13278. med_qcresult_detail c,
  13279. qc_cases_entry d
  13280. WHERE
  13281. a.is_deleted = 'N'
  13282. AND b.is_deleted = 'N'
  13283. AND c.is_deleted = 'N'
  13284. AND d.is_deleted = 'N'
  13285. AND a.hospital_id = b.hospital_id
  13286. AND a.hospital_id = c.hospital_id
  13287. AND a.behospital_code = b.behospital_code
  13288. AND a.behospital_code = c.behospital_code
  13289. AND c.cases_id = d.cases_id
  13290. AND c.cases_entry_id = d.id
  13291. AND a.qc_type_id != 0
  13292. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13293. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13294. </if>
  13295. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13296. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13297. </if>
  13298. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13299. <if test="qcResultShortPageVO.startDate != null ">
  13300. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13301. </if>
  13302. <if test="qcResultShortPageVO.endDate != null ">
  13303. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13304. </if>
  13305. </if>
  13306. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13307. <if test="qcResultShortPageVO.startDate != null ">
  13308. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13309. </if>
  13310. <if test="qcResultShortPageVO.endDate != null">
  13311. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13312. </if>
  13313. </if>
  13314. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13315. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13316. </if>
  13317. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13318. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13319. </if>
  13320. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13321. AND b.`level` = #{qcResultShortPageVO.level}
  13322. </if>
  13323. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13324. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13325. </if>
  13326. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13327. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13328. </if>
  13329. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13330. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13331. </if>
  13332. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13333. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13334. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13335. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13336. </if>
  13337. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13338. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13339. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13340. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13341. </if>
  13342. <if test="qcResultShortPageVO.casesEntryId != null ">
  13343. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13344. </if>
  13345. <if test="qcResultShortPageVO.isReject != null">
  13346. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13347. </if>
  13348. <if test="qcResultShortPageVO.ruleType != null">
  13349. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13350. </if>
  13351. )be
  13352. left join med_check_info mci
  13353. on mci.is_deleted = 'N'
  13354. and mci.check_type = 0
  13355. and be.hospital_id = mci.hospital_id
  13356. and be.behospital_code = mci.behospital_code
  13357. left join med_check_info hm_mci
  13358. on hm_mci.is_deleted = 'N'
  13359. and hm_mci.check_type = 1
  13360. and be.hospital_id = hm_mci.hospital_id
  13361. and be.behospital_code = hm_mci.behospital_code
  13362. ) t1
  13363. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13364. AND t1.behospital_code = t2.behospital_code
  13365. AND t2.is_deleted = 'N'
  13366. ) t
  13367. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13368. AND t.hospitalId = qi.hospital_id
  13369. AND t.behospitalCode = qi.behospital_code
  13370. where 1=1
  13371. <if test="qcResultShortPageVO.checkStatus != null">
  13372. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13373. </if>
  13374. <if test="qcResultShortPageVO.mrStatus != null">
  13375. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13376. </if>
  13377. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13378. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13379. </if>
  13380. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13381. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13382. </if>
  13383. <if test="qcResultShortPageVO.chTimeStart != null ">
  13384. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13385. </if>
  13386. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13387. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13388. </if>
  13389. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13390. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13391. </if>
  13392. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13393. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13394. </if>
  13395. GROUP BY
  13396. t.behDeptId,
  13397. t.behDeptName
  13398. )f2
  13399. WHERE
  13400. f1.behDeptId = f2.behDeptId
  13401. AND f1.behDeptName = f2.behDeptName
  13402. </select>
  13403. <!-- 未整改病历缺陷评分详情页导出-科室-->
  13404. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  13405. SELECT
  13406. f1.behDeptId,
  13407. f1.behDeptName,
  13408. f1.doctorName,
  13409. f1.patName,
  13410. f1.behospitalCode,
  13411. f1.hospitalId,
  13412. f1.behospitalDate,
  13413. f1.leaveHospitalDate,
  13414. f1.score,
  13415. f1.scoreBn,
  13416. f2.avgScore,
  13417. f1.msg,
  13418. f1.caseName,
  13419. f1.checkStatus,
  13420. f1.mrStatus,
  13421. f1.chName,
  13422. f1.mrName,
  13423. f1.chTime,
  13424. f1.mrTime
  13425. FROM
  13426. (SELECT
  13427. t.doctorName,
  13428. t.doctorId,
  13429. t.`name` AS patName,
  13430. t.behospitalCode AS behospitalCode,
  13431. t.behospitalDate AS behospitalDate,
  13432. t.leaveHospitalDate AS leaveHospitalDate,
  13433. qi.score_res AS score,
  13434. t.scoreBn,
  13435. qd.msg AS msg,
  13436. qc.NAME AS caseName,
  13437. t.behDeptId,
  13438. t.behDeptName,
  13439. t.hospitalId,
  13440. t.checkStatus,
  13441. t.mrStatus,
  13442. t.chName,
  13443. t.mrName,
  13444. t.chTime,
  13445. t.mrTime
  13446. FROM
  13447. (SELECT DISTINCT
  13448. t1.hospital_id AS hospitalId,
  13449. t1.behospital_code AS behospitalCode,
  13450. t1.bed_code AS bedCode,
  13451. t1.LEVEL AS LEVEL,
  13452. t1.grade_type AS gradeType,
  13453. t1.score_res AS scoreRes,
  13454. t1.scoreBn,
  13455. t1.NAME AS NAME,
  13456. t1.sex AS sex,
  13457. t1.beh_dept_id AS behDeptId,
  13458. t1.beh_dept_name AS behDeptName,
  13459. t1.doctor_id AS doctorId,
  13460. t1.doctor_name AS doctorName,
  13461. t1.beh_doctor_id AS behDoctorId,
  13462. t1.beh_doctor_name AS behDoctorName,
  13463. t1.director_doctor_id AS directorDoctorId,
  13464. t1.director_doctor_name AS directorDoctorName,
  13465. t1.birthday AS birthday,
  13466. t1.behospital_date AS behospitalDate,
  13467. t1.leave_hospital_date AS leaveHospitalDate,
  13468. t1.placefile_date AS placefileDate,
  13469. t1.gmt_create AS gradeTime,
  13470. t1.diagnose,
  13471. t1.ward_name AS wardName,
  13472. t2.age,
  13473. t1.file_code AS fileCode,
  13474. t1.checkStatus,
  13475. t1.mrStatus,
  13476. t1.chName,
  13477. t1.mrName,
  13478. t1.chTime,
  13479. t1.mrTime
  13480. FROM
  13481. (SELECT
  13482. be.*,
  13483. ifnull(mci.status,0) AS checkStatus,
  13484. ifnull(hm_mci.status,0) AS mrStatus,
  13485. mci.check_name as chName,
  13486. e.score_res as scoreBn,
  13487. hm_mci.check_name as mrName,
  13488. mci.gmt_create as chTime,
  13489. hm_mci.gmt_create as mrTime
  13490. FROM
  13491. (
  13492. SELECT DISTINCT
  13493. a.hospital_id,
  13494. a.behospital_code,
  13495. a.bed_code,
  13496. a.file_code,
  13497. b.LEVEL,
  13498. b.grade_type,
  13499. b.score_res,
  13500. a.NAME,
  13501. a.sex,
  13502. a.beh_dept_id,
  13503. a.beh_dept_name,
  13504. a.birthday,
  13505. a.behospital_date,
  13506. a.leave_hospital_date,
  13507. a.doctor_id,
  13508. a.doctor_name,
  13509. a.beh_doctor_id,
  13510. a.beh_doctor_name,
  13511. a.director_doctor_id,
  13512. a.director_doctor_name,
  13513. a.diagnose,
  13514. a.placefile_date,
  13515. a.ward_name,
  13516. b.gmt_create
  13517. FROM
  13518. med_behospital_info a,
  13519. med_qcresult_info b,
  13520. med_qcresult_detail c,
  13521. qc_cases_entry d,
  13522. sys_user_dept f
  13523. WHERE
  13524. a.is_deleted = 'N'
  13525. AND b.is_deleted = 'N'
  13526. AND c.is_deleted = 'N'
  13527. AND d.is_deleted = 'N'
  13528. AND f.is_deleted = 'N'
  13529. AND a.hospital_id = b.hospital_id
  13530. AND a.hospital_id = c.hospital_id
  13531. AND a.hospital_id = f.hospital_id
  13532. AND a.behospital_code = b.behospital_code
  13533. AND a.behospital_code = c.behospital_code
  13534. AND c.cases_id = d.cases_id
  13535. AND c.cases_entry_id = d.id
  13536. AND a.beh_dept_id = f.dept_id
  13537. AND a.qc_type_id != 0
  13538. <if test="qcResultShortPageVO.userId!=null">
  13539. AND f.user_id = #{qcResultShortPageVO.userId}
  13540. </if>
  13541. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13542. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13543. </if>
  13544. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13545. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13546. </if>
  13547. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13548. <if test="qcResultShortPageVO.startDate != null ">
  13549. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13550. </if>
  13551. <if test="qcResultShortPageVO.endDate != null ">
  13552. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13553. </if>
  13554. </if>
  13555. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13556. <if test="qcResultShortPageVO.startDate != null ">
  13557. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13558. </if>
  13559. <if test="qcResultShortPageVO.endDate != null">
  13560. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13561. </if>
  13562. </if>
  13563. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13564. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13565. </if>
  13566. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13567. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13568. </if>
  13569. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13570. AND b.`level` = #{qcResultShortPageVO.level}
  13571. </if>
  13572. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13573. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13574. </if>
  13575. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13576. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13577. </if>
  13578. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13579. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13580. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13581. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13582. </if>
  13583. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13584. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13585. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13586. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13587. </if>
  13588. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13589. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13590. </if>
  13591. <if test="qcResultShortPageVO.casesEntryId != null ">
  13592. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13593. </if>
  13594. <if test="qcResultShortPageVO.isReject != null">
  13595. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13596. </if>
  13597. <if test="qcResultShortPageVO.ruleType != null">
  13598. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13599. </if>
  13600. )be
  13601. left join med_check_info mci
  13602. on mci.is_deleted = 'N'
  13603. and mci.check_type = 0
  13604. and be.hospital_id = mci.hospital_id
  13605. and be.behospital_code = mci.behospital_code
  13606. left join med_check_info hm_mci
  13607. on hm_mci.is_deleted = 'N'
  13608. and hm_mci.check_type = 1
  13609. and be.hospital_id = hm_mci.hospital_id
  13610. and be.behospital_code = hm_mci.behospital_code
  13611. LEFT JOIN med_qcresult_cases e
  13612. on be.behospital_code = e.behospital_code
  13613. and be.hospital_id = e.hospital_id
  13614. AND e.is_deleted = 'N'
  13615. and e.cases_id = 243
  13616. ) t1
  13617. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13618. AND t1.behospital_code = t2.behospital_code
  13619. AND t2.is_deleted = 'N'
  13620. ) t
  13621. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13622. AND t.hospitalId = qi.hospital_id
  13623. AND t.behospitalCode = qi.behospital_code
  13624. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13625. AND t.hospitalId = qd.hospital_id
  13626. AND t.behospitalCode = qd.behospital_code
  13627. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13628. AND qd.cases_id = qc.id
  13629. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13630. AND qd.cases_id = qce.cases_id
  13631. AND qd.cases_entry_id = qce.id
  13632. where 1=1
  13633. <if test="qcResultShortPageVO.checkStatus != null">
  13634. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13635. </if>
  13636. <if test="qcResultShortPageVO.mrStatus != null">
  13637. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13638. </if>
  13639. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13640. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13641. </if>
  13642. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13643. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13644. </if>
  13645. <if test="qcResultShortPageVO.chTimeStart != null ">
  13646. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13647. </if>
  13648. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13649. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13650. </if>
  13651. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13652. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13653. </if>
  13654. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13655. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13656. </if>
  13657. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13658. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13659. </if>
  13660. <if test="qcResultShortPageVO.casesEntryId != null ">
  13661. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13662. </if>
  13663. )f1,
  13664. (SELECT
  13665. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13666. t.behDeptId,
  13667. t.behDeptName,
  13668. t.doctorId,
  13669. t.doctorName
  13670. FROM
  13671. (SELECT DISTINCT
  13672. t1.hospital_id AS hospitalId,
  13673. t1.behospital_code AS behospitalCode,
  13674. t1.bed_code AS bedCode,
  13675. t1.LEVEL AS LEVEL,
  13676. t1.grade_type AS gradeType,
  13677. t1.score_res AS scoreRes,
  13678. t1.NAME AS NAME,
  13679. t1.sex AS sex,
  13680. t1.beh_dept_id AS behDeptId,
  13681. t1.beh_dept_name AS behDeptName,
  13682. t1.doctor_id AS doctorId,
  13683. t1.doctor_name AS doctorName,
  13684. t1.beh_doctor_id AS behDoctorId,
  13685. t1.beh_doctor_name AS behDoctorName,
  13686. t1.director_doctor_id AS directorDoctorId,
  13687. t1.director_doctor_name AS directorDoctorName,
  13688. t1.birthday AS birthday,
  13689. t1.behospital_date AS behospitalDate,
  13690. t1.leave_hospital_date AS leaveHospitalDate,
  13691. t1.placefile_date AS placefileDate,
  13692. t1.gmt_create AS gradeTime,
  13693. t1.diagnose,
  13694. t1.ward_name AS wardName,
  13695. t2.age,
  13696. t1.file_code AS fileCode,
  13697. t1.checkStatus,
  13698. t1.mrStatus,
  13699. t1.chName,
  13700. t1.mrName,
  13701. t1.chTime,
  13702. t1.mrTime
  13703. FROM
  13704. (SELECT
  13705. be.*,
  13706. ifnull(mci.status,0) AS checkStatus,
  13707. ifnull(hm_mci.status,0) AS mrStatus,
  13708. mci.check_name as chName,
  13709. hm_mci.check_name as mrName,
  13710. mci.gmt_create as chTime,
  13711. hm_mci.gmt_create as mrTime
  13712. FROM
  13713. (
  13714. SELECT DISTINCT
  13715. a.hospital_id,
  13716. a.behospital_code,
  13717. a.bed_code,
  13718. a.file_code,
  13719. b.LEVEL,
  13720. b.grade_type,
  13721. b.score_res,
  13722. a.NAME,
  13723. a.sex,
  13724. a.beh_dept_id,
  13725. a.beh_dept_name,
  13726. a.birthday,
  13727. a.behospital_date,
  13728. a.leave_hospital_date,
  13729. a.doctor_id,
  13730. a.doctor_name,
  13731. a.beh_doctor_id,
  13732. a.beh_doctor_name,
  13733. a.director_doctor_id,
  13734. a.director_doctor_name,
  13735. a.diagnose,
  13736. a.placefile_date,
  13737. a.ward_name,
  13738. b.gmt_create
  13739. FROM
  13740. med_behospital_info a,
  13741. med_qcresult_info b,
  13742. med_qcresult_detail c,
  13743. qc_cases_entry d,
  13744. sys_user_dept f
  13745. WHERE
  13746. a.is_deleted = 'N'
  13747. AND b.is_deleted = 'N'
  13748. AND c.is_deleted = 'N'
  13749. AND d.is_deleted = 'N'
  13750. AND f.is_deleted = 'N'
  13751. AND a.hospital_id = b.hospital_id
  13752. AND a.hospital_id = c.hospital_id
  13753. AND a.hospital_id = f.hospital_id
  13754. AND a.behospital_code = b.behospital_code
  13755. AND a.behospital_code = c.behospital_code
  13756. AND c.cases_id = d.cases_id
  13757. AND c.cases_entry_id = d.id
  13758. AND a.beh_dept_id = f.dept_id
  13759. AND a.qc_type_id != 0
  13760. <if test="qcResultShortPageVO.userId!=null">
  13761. AND f.user_id = #{qcResultShortPageVO.userId}
  13762. </if>
  13763. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13764. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13765. </if>
  13766. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13767. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13768. </if>
  13769. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13770. <if test="qcResultShortPageVO.startDate != null ">
  13771. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13772. </if>
  13773. <if test="qcResultShortPageVO.endDate != null ">
  13774. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13775. </if>
  13776. </if>
  13777. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13778. <if test="qcResultShortPageVO.startDate != null ">
  13779. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13780. </if>
  13781. <if test="qcResultShortPageVO.endDate != null">
  13782. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13783. </if>
  13784. </if>
  13785. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13786. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13787. </if>
  13788. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13789. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13790. </if>
  13791. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13792. AND b.`level` = #{qcResultShortPageVO.level}
  13793. </if>
  13794. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13795. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13796. </if>
  13797. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13798. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13799. </if>
  13800. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13801. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13802. </if>
  13803. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13804. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13805. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13806. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13807. </if>
  13808. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13809. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13810. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13811. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13812. </if>
  13813. <if test="qcResultShortPageVO.casesEntryId != null ">
  13814. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13815. </if>
  13816. <if test="qcResultShortPageVO.isReject != null">
  13817. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13818. </if>
  13819. <if test="qcResultShortPageVO.ruleType != null">
  13820. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13821. </if>
  13822. )be
  13823. left join med_check_info mci
  13824. on mci.is_deleted = 'N'
  13825. and mci.check_type = 0
  13826. and be.hospital_id = mci.hospital_id
  13827. and be.behospital_code = mci.behospital_code
  13828. left join med_check_info hm_mci
  13829. on hm_mci.is_deleted = 'N'
  13830. and hm_mci.check_type = 1
  13831. and be.hospital_id = hm_mci.hospital_id
  13832. and be.behospital_code = hm_mci.behospital_code
  13833. ) t1
  13834. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13835. AND t1.behospital_code = t2.behospital_code
  13836. AND t2.is_deleted = 'N'
  13837. ) t
  13838. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13839. AND t.hospitalId = qi.hospital_id
  13840. AND t.behospitalCode = qi.behospital_code
  13841. where 1=1
  13842. <if test="qcResultShortPageVO.checkStatus != null">
  13843. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13844. </if>
  13845. <if test="qcResultShortPageVO.mrStatus != null">
  13846. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13847. </if>
  13848. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13849. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13850. </if>
  13851. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13852. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13853. </if>
  13854. <if test="qcResultShortPageVO.chTimeStart != null ">
  13855. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13856. </if>
  13857. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13858. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13859. </if>
  13860. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13861. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13862. </if>
  13863. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13864. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13865. </if>
  13866. GROUP BY
  13867. t.doctorId,
  13868. t.doctorName
  13869. )f2
  13870. WHERE
  13871. f1.doctorId = f2.doctorId
  13872. AND f1.doctorName = f2.doctorName
  13873. </select>
  13874. <!-- 31天再入院详情页-->
  13875. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  13876. SELECT
  13877. t.fileCode,
  13878. t.diagnose,
  13879. t.NAME,
  13880. t.sex,
  13881. t.hospitalId,
  13882. t.behDeptId,
  13883. t.behDeptName,
  13884. t.behospitalCode,
  13885. t.behospitalDate,
  13886. t.leaveHospitalDate,
  13887. t.lastBehDeptId,
  13888. t.lastBehDeptName,
  13889. t.lastBehospitalCode,
  13890. t.lastBehospitalDate,
  13891. t.lastLeaveHospitalDate,
  13892. t.diffDays,
  13893. mqi.score_res AS scoreRes,
  13894. mqi.LEVEL AS LEVEL,
  13895. mqi_last.score_res AS lastScoreRes,
  13896. mqi_last.LEVEL AS lastLevel,
  13897. mhp.total_fee AS totleFee,
  13898. mhp.behospital_day_num AS behospitalDayNum,
  13899. mhp_last.total_fee AS lastTotleFee,
  13900. mhp_last.behospital_day_num AS lastBehospitalDayNum
  13901. FROM
  13902. (
  13903. SELECT
  13904. be.fileCode,
  13905. be.diagnose,
  13906. be.NAME,
  13907. be.sex,
  13908. be.hospitalId,
  13909. be.behDeptId,
  13910. be.behDeptName,
  13911. be.behospitalCode,
  13912. be.behospitalDate,
  13913. be.leaveHospitalDate,
  13914. be.lastBehDeptId,
  13915. be.lastBehDeptName,
  13916. be.lastBehospitalCode,
  13917. be.lastBehospitalDate,
  13918. be.lastLeaveHospitalDate,
  13919. be.diffDays
  13920. FROM
  13921. (
  13922. SELECT
  13923. r1.file_code AS fileCode,
  13924. r1.diagnose,
  13925. r1.NAME,
  13926. r1.sex,
  13927. r1.hospital_id AS hospitalId,
  13928. r1.beh_dept_id AS behDeptId,
  13929. r1.beh_dept_name AS behDeptName,
  13930. r1.behospital_code AS behospitalCode,
  13931. r1.behospital_date AS behospitalDate,
  13932. r1.leave_hospital_date AS leaveHospitalDate,
  13933. r2.beh_dept_id AS lastBehDeptId,
  13934. r2.beh_dept_name AS lastBehDeptName,
  13935. r2.behospital_code AS lastBehospitalCode,
  13936. r2.behospital_date AS lastBehospitalDate,
  13937. r2.leave_hospital_date AS lastLeaveHospitalDate,
  13938. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  13939. FROM
  13940. (
  13941. SELECT
  13942. ( @rownum := @rownum + 1 ) AS rownum,
  13943. t1.file_code,
  13944. t1.diagnose,
  13945. t1.NAME,
  13946. t1.sex,
  13947. t1.hospital_id,
  13948. t1.beh_dept_id,
  13949. t1.beh_dept_name,
  13950. t1.behospital_code,
  13951. t1.behospital_date,
  13952. t1.leave_hospital_date
  13953. FROM
  13954. (
  13955. SELECT
  13956. tt1.file_code,
  13957. tt1.diagnose,
  13958. tt2.NAME,
  13959. tt2.sex,
  13960. tt2.hospital_id,
  13961. tt2.beh_dept_id,
  13962. tt2.beh_dept_name,
  13963. tt2.behospital_code,
  13964. tt2.behospital_date,
  13965. tt2.leave_hospital_date
  13966. FROM
  13967. (
  13968. SELECT
  13969. a.file_code,
  13970. a.diagnose
  13971. FROM
  13972. med_behospital_info a
  13973. WHERE
  13974. a.is_deleted = 'N'
  13975. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  13976. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  13977. </if>
  13978. AND a.qc_type_id != 0
  13979. AND IFNULL( a.diagnose, '' )!= ''
  13980. AND IFNULL( a.file_code, '' )!= ''
  13981. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  13982. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  13983. </if>
  13984. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  13985. <if test="reBeHosPageVO.startDate != null ">
  13986. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  13987. </if>
  13988. <if test="reBeHosPageVO.endDate != null ">
  13989. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  13990. </if>
  13991. </if>
  13992. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  13993. <if test="reBeHosPageVO.startDate != null ">
  13994. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  13995. </if>
  13996. <if test="reBeHosPageVO.endDate != null">
  13997. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  13998. </if>
  13999. </if>
  14000. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14001. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14002. </if>
  14003. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14004. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14005. </if>
  14006. GROUP BY
  14007. a.file_code,
  14008. a.diagnose
  14009. HAVING
  14010. count(*)> 1
  14011. ) tt1,
  14012. med_behospital_info tt2
  14013. WHERE
  14014. tt2.is_deleted = 'N'
  14015. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14016. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14017. </if>
  14018. AND tt2.qc_type_id != 0
  14019. AND tt1.file_code = tt2.file_code
  14020. AND tt1.diagnose = tt2.diagnose
  14021. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14022. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14023. </if>
  14024. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14025. <if test="reBeHosPageVO.startDate != null ">
  14026. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14027. </if>
  14028. <if test="reBeHosPageVO.endDate != null ">
  14029. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14030. </if>
  14031. </if>
  14032. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14033. <if test="reBeHosPageVO.startDate != null ">
  14034. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14035. </if>
  14036. <if test="reBeHosPageVO.endDate != null">
  14037. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14038. </if>
  14039. </if>
  14040. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14041. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14042. </if>
  14043. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14044. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14045. </if>
  14046. ORDER BY
  14047. tt1.file_code,
  14048. tt1.diagnose,
  14049. tt2.behospital_date DESC
  14050. ) t1,
  14051. ( SELECT @rownum := 0 ) r
  14052. ) r1
  14053. LEFT JOIN (
  14054. SELECT
  14055. ( @INDEX := @INDEX + 1 ) AS rownum,
  14056. t1.file_code,
  14057. t1.diagnose,
  14058. t1.NAME,
  14059. t1.sex,
  14060. t1.hospital_id,
  14061. t1.beh_dept_id,
  14062. t1.beh_dept_name,
  14063. t1.behospital_code,
  14064. t1.behospital_date,
  14065. t1.leave_hospital_date
  14066. FROM
  14067. (
  14068. SELECT
  14069. tt1.file_code,
  14070. tt1.diagnose,
  14071. tt2.NAME,
  14072. tt2.sex,
  14073. tt2.hospital_id,
  14074. tt2.beh_dept_id,
  14075. tt2.beh_dept_name,
  14076. tt2.behospital_code,
  14077. tt2.behospital_date,
  14078. tt2.leave_hospital_date
  14079. FROM
  14080. (
  14081. SELECT
  14082. a.file_code,
  14083. a.diagnose
  14084. FROM
  14085. med_behospital_info a
  14086. WHERE
  14087. a.is_deleted = 'N'
  14088. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14089. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14090. </if>
  14091. AND a.qc_type_id != 0
  14092. AND IFNULL( a.diagnose, '' )!= ''
  14093. AND IFNULL( a.file_code, '' )!= ''
  14094. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14095. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14096. </if>
  14097. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14098. <if test="reBeHosPageVO.startDate != null ">
  14099. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14100. </if>
  14101. <if test="reBeHosPageVO.endDate != null ">
  14102. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14103. </if>
  14104. </if>
  14105. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14106. <if test="reBeHosPageVO.startDate != null ">
  14107. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14108. </if>
  14109. <if test="reBeHosPageVO.endDate != null">
  14110. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14111. </if>
  14112. </if>
  14113. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14114. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14115. </if>
  14116. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14117. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14118. </if>
  14119. GROUP BY
  14120. a.file_code,
  14121. a.diagnose
  14122. HAVING
  14123. count(*)> 1
  14124. ) tt1,
  14125. med_behospital_info tt2
  14126. WHERE
  14127. tt2.is_deleted = 'N'
  14128. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14129. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14130. </if>
  14131. AND tt2.qc_type_id != 0
  14132. AND tt1.file_code = tt2.file_code
  14133. AND tt1.diagnose = tt2.diagnose
  14134. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14135. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14136. </if>
  14137. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14138. <if test="reBeHosPageVO.startDate != null ">
  14139. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14140. </if>
  14141. <if test="reBeHosPageVO.endDate != null ">
  14142. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14143. </if>
  14144. </if>
  14145. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14146. <if test="reBeHosPageVO.startDate != null ">
  14147. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14148. </if>
  14149. <if test="reBeHosPageVO.endDate != null">
  14150. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14151. </if>
  14152. </if>
  14153. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14154. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14155. </if>
  14156. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14157. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14158. </if>
  14159. ORDER BY
  14160. tt1.file_code,
  14161. tt1.diagnose,
  14162. tt2.behospital_date DESC
  14163. ) t1,(
  14164. SELECT
  14165. @INDEX := 0
  14166. ) r
  14167. ) r2 ON r1.file_code = r2.file_code
  14168. AND r1.rownum = r2.rownum - 1
  14169. ) be
  14170. WHERE
  14171. be.diffDays IS NOT NULL
  14172. AND be.diffDays BETWEEN 0
  14173. AND 31
  14174. ) t
  14175. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14176. AND t.hospitalId = mqi.hospital_id
  14177. AND t.behospitalCode = mqi.behospital_code
  14178. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14179. AND t.hospitalId = mqi_last.hospital_id
  14180. AND t.lastBehospitalCode = mqi_last.behospital_code
  14181. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14182. AND t.hospitalId = mhp.hospital_id
  14183. AND t.behospitalCode = mhp.behospital_code
  14184. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14185. AND t.hospitalId = mhp_last.hospital_id
  14186. AND t.lastBehospitalCode = mhp_last.behospital_code
  14187. </select>
  14188. <!-- 31天再入院详情页-科室-->
  14189. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14190. SELECT
  14191. t.fileCode,
  14192. t.diagnose,
  14193. t.NAME,
  14194. t.sex,
  14195. t.hospitalId,
  14196. t.behDeptId,
  14197. t.behDeptName,
  14198. t.doctorId,
  14199. t.doctorName,
  14200. t.behospitalCode,
  14201. t.behospitalDate,
  14202. t.leaveHospitalDate,
  14203. t.lastBehDeptId,
  14204. t.lastBehDeptName,
  14205. t.lastDoctorName,
  14206. t.lastBehospitalCode,
  14207. t.lastBehospitalDate,
  14208. t.lastLeaveHospitalDate,
  14209. t.diffDays,
  14210. mqi.score_res AS scoreRes,
  14211. mqi.LEVEL AS LEVEL,
  14212. mqi_last.score_res AS lastScoreRes,
  14213. mqi_last.LEVEL AS lastLevel,
  14214. mhp.total_fee AS totleFee,
  14215. mhp.behospital_day_num AS behospitalDayNum,
  14216. mhp_last.total_fee AS lastTotleFee,
  14217. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14218. FROM
  14219. (
  14220. SELECT
  14221. be.fileCode,
  14222. be.diagnose,
  14223. be.NAME,
  14224. be.sex,
  14225. be.hospitalId,
  14226. be.behDeptId,
  14227. be.behDeptName,
  14228. be.doctorId,
  14229. be.doctorName,
  14230. be.behospitalCode,
  14231. be.behospitalDate,
  14232. be.leaveHospitalDate,
  14233. be.lastBehDeptId,
  14234. be.lastBehDeptName,
  14235. be.lastDoctorId,
  14236. be.lastDoctorName,
  14237. be.lastBehospitalCode,
  14238. be.lastBehospitalDate,
  14239. be.lastLeaveHospitalDate,
  14240. be.diffDays
  14241. FROM
  14242. (
  14243. SELECT
  14244. r1.file_code AS fileCode,
  14245. r1.diagnose,
  14246. r1.NAME,
  14247. r1.sex,
  14248. r1.hospital_id AS hospitalId,
  14249. r1.beh_dept_id AS behDeptId,
  14250. r1.beh_dept_name AS behDeptName,
  14251. r1.doctor_id as doctorId,
  14252. r1.doctor_name as doctorName,
  14253. r1.behospital_code AS behospitalCode,
  14254. r1.behospital_date AS behospitalDate,
  14255. r1.leave_hospital_date AS leaveHospitalDate,
  14256. r2.beh_dept_id AS lastBehDeptId,
  14257. r2.beh_dept_name AS lastBehDeptName,
  14258. r2.behospital_code AS lastBehospitalCode,
  14259. r2.behospital_date AS lastBehospitalDate,
  14260. r2.doctor_id as lastDoctorId,
  14261. r2.doctor_name as lastDoctorName,
  14262. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14263. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14264. FROM
  14265. (
  14266. SELECT
  14267. ( @rownum := @rownum + 1 ) AS rownum,
  14268. t1.file_code,
  14269. t1.diagnose,
  14270. t1.NAME,
  14271. t1.sex,
  14272. t1.doctor_id,
  14273. t1.doctor_name,
  14274. t1.hospital_id,
  14275. t1.beh_dept_id,
  14276. t1.beh_dept_name,
  14277. t1.behospital_code,
  14278. t1.behospital_date,
  14279. t1.leave_hospital_date
  14280. FROM
  14281. (
  14282. SELECT
  14283. tt1.file_code,
  14284. tt1.diagnose,
  14285. tt2.doctor_id,
  14286. tt2.doctor_name,
  14287. tt2.NAME,
  14288. tt2.sex,
  14289. tt2.hospital_id,
  14290. tt2.beh_dept_id,
  14291. tt2.beh_dept_name,
  14292. tt2.behospital_code,
  14293. tt2.behospital_date,
  14294. tt2.leave_hospital_date
  14295. FROM
  14296. (
  14297. SELECT
  14298. a.file_code,
  14299. a.diagnose,
  14300. a.doctor_id,
  14301. a.doctor_name
  14302. FROM
  14303. med_behospital_info a,
  14304. sys_user_dept c
  14305. WHERE
  14306. a.is_deleted = 'N'
  14307. AND c.is_deleted = 'N'
  14308. AND a.hospital_id = c.hospital_id
  14309. AND a.beh_dept_id = c.dept_id
  14310. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14311. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14312. </if>
  14313. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14314. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14315. </if>
  14316. <if test="reBeHosPageVO.userId!=null">
  14317. AND c.user_id = #{reBeHosPageVO.userId}
  14318. </if>
  14319. AND a.qc_type_id != 0
  14320. AND IFNULL( a.diagnose, '' )!= ''
  14321. AND IFNULL( a.file_code, '' )!= ''
  14322. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14323. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14324. </if>
  14325. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14326. <if test="reBeHosPageVO.startDate != null ">
  14327. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14328. </if>
  14329. <if test="reBeHosPageVO.endDate != null ">
  14330. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14331. </if>
  14332. </if>
  14333. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14334. <if test="reBeHosPageVO.startDate != null ">
  14335. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14336. </if>
  14337. <if test="reBeHosPageVO.endDate != null">
  14338. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14339. </if>
  14340. </if>
  14341. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14342. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14343. </if>
  14344. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14345. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14346. </if>
  14347. GROUP BY
  14348. a.file_code,
  14349. a.diagnose
  14350. HAVING
  14351. count(*)> 1
  14352. ) tt1,
  14353. med_behospital_info tt2
  14354. WHERE
  14355. tt2.is_deleted = 'N'
  14356. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14357. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14358. </if>
  14359. AND tt2.qc_type_id != 0
  14360. AND tt1.file_code = tt2.file_code
  14361. AND tt1.diagnose = tt2.diagnose
  14362. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14363. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14364. </if>
  14365. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14366. <if test="reBeHosPageVO.startDate != null ">
  14367. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14368. </if>
  14369. <if test="reBeHosPageVO.endDate != null ">
  14370. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14371. </if>
  14372. </if>
  14373. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14374. <if test="reBeHosPageVO.startDate != null ">
  14375. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14376. </if>
  14377. <if test="reBeHosPageVO.endDate != null">
  14378. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14379. </if>
  14380. </if>
  14381. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14382. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14383. </if>
  14384. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14385. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14386. </if>
  14387. ORDER BY
  14388. tt1.file_code,
  14389. tt1.diagnose,
  14390. tt2.behospital_date DESC
  14391. ) t1,
  14392. ( SELECT @rownum := 0 ) r
  14393. ) r1
  14394. LEFT JOIN (
  14395. SELECT
  14396. ( @INDEX := @INDEX + 1 ) AS rownum,
  14397. t1.file_code,
  14398. t1.diagnose,
  14399. t1.NAME,
  14400. t1.sex,
  14401. t1.hospital_id,
  14402. t1.beh_dept_id,
  14403. t1.beh_dept_name,
  14404. t1.doctor_id,
  14405. t1.doctor_name,
  14406. t1.behospital_code,
  14407. t1.behospital_date,
  14408. t1.leave_hospital_date
  14409. FROM
  14410. (
  14411. SELECT
  14412. tt1.file_code,
  14413. tt1.diagnose,
  14414. tt2.doctor_id,
  14415. tt2.doctor_name,
  14416. tt2.NAME,
  14417. tt2.sex,
  14418. tt2.hospital_id,
  14419. tt2.beh_dept_id,
  14420. tt2.beh_dept_name,
  14421. tt2.behospital_code,
  14422. tt2.behospital_date,
  14423. tt2.leave_hospital_date
  14424. FROM
  14425. (
  14426. SELECT
  14427. a.file_code,
  14428. a.diagnose,
  14429. a.doctor_id ,
  14430. a.doctor_name
  14431. FROM
  14432. med_behospital_info a,
  14433. sys_user_dept c
  14434. WHERE
  14435. a.is_deleted = 'N'
  14436. AND c.is_deleted = 'N'
  14437. AND a.hospital_id = c.hospital_id
  14438. AND a.beh_dept_id = c.dept_id
  14439. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14440. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14441. </if>
  14442. <if test="reBeHosPageVO.userId!=null">
  14443. AND c.user_id = #{reBeHosPageVO.userId}
  14444. </if>
  14445. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14446. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14447. </if>
  14448. AND a.qc_type_id != 0
  14449. AND IFNULL( a.diagnose, '' )!= ''
  14450. AND IFNULL( a.file_code, '' )!= ''
  14451. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14452. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14453. </if>
  14454. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14455. <if test="reBeHosPageVO.startDate != null ">
  14456. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14457. </if>
  14458. <if test="reBeHosPageVO.endDate != null ">
  14459. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14460. </if>
  14461. </if>
  14462. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14463. <if test="reBeHosPageVO.startDate != null ">
  14464. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14465. </if>
  14466. <if test="reBeHosPageVO.endDate != null">
  14467. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14468. </if>
  14469. </if>
  14470. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14471. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14472. </if>
  14473. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14474. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14475. </if>
  14476. GROUP BY
  14477. a.file_code,
  14478. a.diagnose
  14479. HAVING
  14480. count(*)> 1
  14481. ) tt1,
  14482. med_behospital_info tt2
  14483. WHERE
  14484. tt2.is_deleted = 'N'
  14485. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14486. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14487. </if>
  14488. AND tt2.qc_type_id != 0
  14489. AND tt1.file_code = tt2.file_code
  14490. AND tt1.diagnose = tt2.diagnose
  14491. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14492. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14493. </if>
  14494. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14495. <if test="reBeHosPageVO.startDate != null ">
  14496. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14497. </if>
  14498. <if test="reBeHosPageVO.endDate != null ">
  14499. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14500. </if>
  14501. </if>
  14502. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14503. <if test="reBeHosPageVO.startDate != null ">
  14504. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14505. </if>
  14506. <if test="reBeHosPageVO.endDate != null">
  14507. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14508. </if>
  14509. </if>
  14510. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14511. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14512. </if>
  14513. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14514. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14515. </if>
  14516. ORDER BY
  14517. tt1.file_code,
  14518. tt1.diagnose,
  14519. tt2.behospital_date DESC
  14520. ) t1,(
  14521. SELECT
  14522. @INDEX := 0
  14523. ) r
  14524. ) r2 ON r1.file_code = r2.file_code
  14525. AND r1.rownum = r2.rownum - 1
  14526. ) be
  14527. WHERE
  14528. be.diffDays IS NOT NULL
  14529. AND be.diffDays BETWEEN 0
  14530. AND 31
  14531. ) t
  14532. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14533. AND t.hospitalId = mqi.hospital_id
  14534. AND t.behospitalCode = mqi.behospital_code
  14535. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14536. AND t.hospitalId = mqi_last.hospital_id
  14537. AND t.lastBehospitalCode = mqi_last.behospital_code
  14538. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14539. AND t.hospitalId = mhp.hospital_id
  14540. AND t.behospitalCode = mhp.behospital_code
  14541. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14542. AND t.hospitalId = mhp_last.hospital_id
  14543. AND t.lastBehospitalCode = mhp_last.behospital_code
  14544. </select>
  14545. <!-- 单条条目缺陷统计-->
  14546. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  14547. SELECT
  14548. a.beh_dept_id AS id,
  14549. a.beh_dept_name AS NAME,
  14550. count(*) AS num
  14551. FROM
  14552. med_behospital_info a,
  14553. med_qcresult_detail b
  14554. WHERE
  14555. a.is_deleted = 'N'
  14556. AND b.is_deleted = 'N'
  14557. AND a.hospital_id = b.hospital_id
  14558. AND a.behospital_code = b.behospital_code
  14559. AND a.qc_type_id != 0
  14560. and b.cases_entry_id=2658
  14561. <if test="isPlacefile != null and isPlacefile != ''">
  14562. and a.is_placefile = #{isPlacefile}
  14563. </if>
  14564. <if test="hospitalId != null and hospitalId != ''">
  14565. AND a.hospital_id = #{hospitalId}
  14566. </if>
  14567. <if test="isPlacefile != null and isPlacefile == 0">
  14568. <if test="startDate != null and startDate != ''">
  14569. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14570. </if>
  14571. <if test="endDate != null and endDate != ''">
  14572. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14573. </if>
  14574. </if>
  14575. <if test="isPlacefile != null and isPlacefile == 1">
  14576. <if test="startDate != null and startDate != ''">
  14577. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14578. </if>
  14579. <if test="endDate != null and endDate != ''">
  14580. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14581. </if>
  14582. </if>
  14583. GROUP BY
  14584. a.beh_dept_id,
  14585. a.beh_dept_name
  14586. </select>
  14587. <!-- 单条条目缺陷统计-->
  14588. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  14589. SELECT
  14590. a.beh_dept_id AS deptId,
  14591. a.beh_dept_name AS deptName,
  14592. a.doctor_id as doctorId,
  14593. a.doctor_name as doctorName,
  14594. count(*) AS num
  14595. FROM
  14596. med_behospital_info a,
  14597. med_qcresult_detail b,
  14598. sys_user_dept c
  14599. WHERE
  14600. a.is_deleted = 'N'
  14601. AND b.is_deleted = 'N'
  14602. AND c.is_deleted = 'N'
  14603. AND a.hospital_id = b.hospital_id
  14604. AND a.hospital_id = c.hospital_id
  14605. AND a.behospital_code = b.behospital_code
  14606. AND a.beh_dept_id = c.dept_id
  14607. AND a.qc_type_id != 0
  14608. and b.cases_entry_id=2658
  14609. <if test="isPlacefile != null and isPlacefile != ''">
  14610. and a.is_placefile = #{isPlacefile}
  14611. </if>
  14612. <if test="hospitalId != null and hospitalId != ''">
  14613. AND a.hospital_id = #{hospitalId}
  14614. </if>
  14615. <if test="userId!=null">
  14616. AND c.user_id = #{userId}
  14617. </if>
  14618. <if test="isPlacefile != null and isPlacefile == 0">
  14619. <if test="startDate != null and startDate != ''">
  14620. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14621. </if>
  14622. <if test="endDate != null and endDate != ''">
  14623. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14624. </if>
  14625. </if>
  14626. <if test="isPlacefile != null and isPlacefile == 1">
  14627. <if test="startDate != null and startDate != ''">
  14628. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14629. </if>
  14630. <if test="endDate != null and endDate != ''">
  14631. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14632. </if>
  14633. </if>
  14634. GROUP BY
  14635. a.beh_dept_id,
  14636. a.beh_dept_name,
  14637. a.doctor_id,
  14638. a.doctor_name
  14639. </select>
  14640. <!-- 病案首页改善率质控评分页(内页)-->
  14641. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  14642. SELECT
  14643. t.*
  14644. FROM
  14645. (
  14646. SELECT DISTINCT
  14647. t1.hospital_id AS hospitalId,
  14648. t1.behospital_code AS behospitalCode,
  14649. t1.bed_code AS bedCode,
  14650. t1.LEVEL AS LEVEL,
  14651. t1.grade_type AS gradeType,
  14652. t1.score_res AS scoreRes,
  14653. t1.NAME AS NAME,
  14654. t1.sex AS sex,
  14655. t1.beh_dept_id AS behDeptId,
  14656. t1.beh_dept_name AS behDeptName,
  14657. t1.doctor_id AS doctorId,
  14658. t1.doctor_name AS doctorName,
  14659. t1.beh_doctor_id AS behDoctorId,
  14660. t1.beh_doctor_name AS behDoctorName,
  14661. t1.director_doctor_id AS directorDoctorId,
  14662. t1.director_doctor_name AS directorDoctorName,
  14663. t1.birthday AS birthday,
  14664. t1.behospital_date AS behospitalDate,
  14665. t1.leave_hospital_date AS leaveHospitalDate,
  14666. t1.placefile_date AS placefileDate,
  14667. t1.gmt_create AS gradeTime,
  14668. t1.diagnose,
  14669. t1.ward_name AS wardName,
  14670. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  14671. t1.file_code AS fileCode,
  14672. t1.checkStatus,
  14673. t1.mrStatus,
  14674. t1.chName,
  14675. t1.mrName,
  14676. t1.chTime,
  14677. t1.mrTime
  14678. FROM
  14679. (
  14680. SELECT
  14681. be.*,
  14682. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14683. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14684. mci.check_name AS chName,
  14685. hm_mci.check_name AS mrName,
  14686. mci.gmt_create AS chTime,
  14687. hm_mci.gmt_create AS mrTime
  14688. FROM
  14689. (
  14690. SELECT DISTINCT
  14691. a.hospital_id,
  14692. a.behospital_code,
  14693. a.bed_code,
  14694. a.file_code,
  14695. c.LEVEL,
  14696. c.grade_type,
  14697. c.score_res,
  14698. a.NAME,
  14699. a.sex,
  14700. a.beh_dept_id,
  14701. a.beh_dept_name,
  14702. a.birthday,
  14703. a.behospital_date,
  14704. a.leave_hospital_date,
  14705. a.doctor_id,
  14706. a.doctor_name,
  14707. a.beh_doctor_id,
  14708. a.beh_doctor_name,
  14709. a.director_doctor_id,
  14710. a.director_doctor_name,
  14711. a.diagnose,
  14712. a.placefile_date,
  14713. a.ward_name,
  14714. c.gmt_create
  14715. FROM
  14716. med_behospital_info a,
  14717. med_home_page b,
  14718. med_qcresult_info c,
  14719. med_qcresult_cases d,
  14720. (
  14721. SELECT
  14722. m4.*
  14723. FROM
  14724. med_behospital_info m1,
  14725. med_home_page m2,
  14726. med_qcresult_info m3,
  14727. med_qcresult_cases m4
  14728. WHERE
  14729. m1.is_deleted = 'N'
  14730. AND m2.is_deleted = 'N'
  14731. AND m3.is_deleted = 'Y'
  14732. AND m4.is_deleted = 'Y'
  14733. AND m1.hospital_id = m2.hospital_id
  14734. AND m1.hospital_id = m3.hospital_id
  14735. AND m1.hospital_id = m4.hospital_id
  14736. AND m1.behospital_code = m2.behospital_code
  14737. AND m1.behospital_code = m3.behospital_code
  14738. AND m1.behospital_code = m4.behospital_code
  14739. AND m3.gmt_create = m4.gmt_create
  14740. AND m3.have_home_page = 1
  14741. AND m4.cases_id = 243
  14742. AND m1.qc_type_id != 0
  14743. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14744. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14745. </if>
  14746. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14747. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14748. </if>
  14749. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14750. <if test="qcResultShortPageVO.startDate != null ">
  14751. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14752. </if>
  14753. <if test="qcResultShortPageVO.endDate != null ">
  14754. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14755. </if>
  14756. </if>
  14757. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14758. <if test="qcResultShortPageVO.startDate != null">
  14759. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14760. </if>
  14761. <if test="qcResultShortPageVO.endDate != null ">
  14762. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14763. </if>
  14764. </if>
  14765. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14766. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  14767. </if>
  14768. GROUP BY
  14769. m1.behospital_code
  14770. ORDER BY
  14771. m1.behospital_code,
  14772. m4.gmt_create
  14773. ) e
  14774. WHERE
  14775. a.is_deleted = 'N'
  14776. AND b.is_deleted = 'N'
  14777. AND c.is_deleted = 'N'
  14778. AND d.is_deleted = 'N'
  14779. AND a.hospital_id = b.hospital_id
  14780. AND a.hospital_id = c.hospital_id
  14781. AND a.hospital_id = d.hospital_id
  14782. AND a.hospital_id = e.hospital_id
  14783. AND a.behospital_code = b.behospital_code
  14784. AND a.behospital_code = c.behospital_code
  14785. AND a.behospital_code = d.behospital_code
  14786. AND a.behospital_code = e.behospital_code
  14787. AND d.cases_id = 243
  14788. AND d.score_res > e.score_res
  14789. AND a.qc_type_id != 0
  14790. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14791. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14792. </if>
  14793. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14794. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14795. </if>
  14796. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14797. <if test="qcResultShortPageVO.startDate != null ">
  14798. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14799. </if>
  14800. <if test="qcResultShortPageVO.endDate != null ">
  14801. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14802. </if>
  14803. </if>
  14804. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14805. <if test="qcResultShortPageVO.startDate != null ">
  14806. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14807. </if>
  14808. <if test="qcResultShortPageVO.endDate != null">
  14809. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14810. </if>
  14811. </if>
  14812. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14813. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14814. </if>
  14815. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14816. AND c.`level` = #{qcResultShortPageVO.level}
  14817. </if>
  14818. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14819. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14820. </if>
  14821. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14822. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14823. </if>
  14824. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14825. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14826. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14827. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14828. </if>
  14829. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14830. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14831. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14832. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14833. </if>
  14834. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  14835. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  14836. </if>
  14837. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  14838. AND d.score_res = 20
  14839. </if>
  14840. ) be
  14841. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14842. AND mci.check_type = 0
  14843. AND be.hospital_id = mci.hospital_id
  14844. AND be.behospital_code = mci.behospital_code
  14845. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14846. AND hm_mci.check_type = 1
  14847. AND be.hospital_id = hm_mci.hospital_id
  14848. AND be.behospital_code = hm_mci.behospital_code
  14849. ) t1
  14850. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14851. AND t1.behospital_code = t2.behospital_code
  14852. AND t2.is_deleted = 'N'
  14853. ) t
  14854. WHERE
  14855. 1 = 1
  14856. <if test="qcResultShortPageVO.checkStatus != null">
  14857. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14858. </if>
  14859. <if test="qcResultShortPageVO.mrStatus != null">
  14860. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14861. </if>
  14862. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14863. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14864. </if>
  14865. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14866. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14867. </if>
  14868. <if test="qcResultShortPageVO.chTimeStart != null ">
  14869. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14870. </if>
  14871. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14872. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14873. </if>
  14874. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14875. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14876. </if>
  14877. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14878. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14879. </if>
  14880. </select>
  14881. <!-- 病案首页改善率质控评分页(内页)-科室-->
  14882. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  14883. SELECT
  14884. t.*
  14885. FROM
  14886. (
  14887. SELECT DISTINCT
  14888. t1.hospital_id AS hospitalId,
  14889. t1.behospital_code AS behospitalCode,
  14890. t1.bed_code AS bedCode,
  14891. t1.LEVEL AS LEVEL,
  14892. t1.grade_type AS gradeType,
  14893. t1.score_res AS scoreRes,
  14894. t1.NAME AS NAME,
  14895. t1.scoreBn,
  14896. t1.sex AS sex,
  14897. t1.beh_dept_id AS behDeptId,
  14898. t1.beh_dept_name AS behDeptName,
  14899. t1.doctor_id AS doctorId,
  14900. t1.doctor_name AS doctorName,
  14901. t1.beh_doctor_id AS behDoctorId,
  14902. t1.beh_doctor_name AS behDoctorName,
  14903. t1.director_doctor_id AS directorDoctorId,
  14904. t1.director_doctor_name AS directorDoctorName,
  14905. t1.birthday AS birthday,
  14906. t1.behospital_date AS behospitalDate,
  14907. t1.leave_hospital_date AS leaveHospitalDate,
  14908. t1.placefile_date AS placefileDate,
  14909. t1.gmt_create AS gradeTime,
  14910. t1.diagnose,
  14911. t1.ward_name AS wardName,
  14912. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  14913. t1.file_code AS fileCode,
  14914. t1.checkStatus,
  14915. t1.mrStatus,
  14916. t1.chName,
  14917. t1.mrName,
  14918. t1.chTime,
  14919. t1.mrTime
  14920. FROM
  14921. (
  14922. SELECT
  14923. be.*,
  14924. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14925. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14926. mci.check_name AS chName,
  14927. hm_mci.check_name AS mrName,
  14928. e.score_res as scoreBn,
  14929. mci.gmt_create AS chTime,
  14930. hm_mci.gmt_create AS mrTime
  14931. FROM
  14932. (
  14933. SELECT DISTINCT
  14934. a.hospital_id,
  14935. a.behospital_code,
  14936. a.bed_code,
  14937. a.file_code,
  14938. c.LEVEL,
  14939. c.grade_type,
  14940. c.score_res,
  14941. a.NAME,
  14942. a.sex,
  14943. a.beh_dept_id,
  14944. a.beh_dept_name,
  14945. a.birthday,
  14946. a.behospital_date,
  14947. a.leave_hospital_date,
  14948. a.doctor_id,
  14949. a.doctor_name,
  14950. a.beh_doctor_id,
  14951. a.beh_doctor_name,
  14952. a.director_doctor_id,
  14953. a.director_doctor_name,
  14954. a.diagnose,
  14955. a.placefile_date,
  14956. a.ward_name,
  14957. c.gmt_create
  14958. FROM
  14959. med_behospital_info a,
  14960. med_home_page b,
  14961. med_qcresult_info c,
  14962. med_qcresult_cases d,
  14963. sys_user_dept f,
  14964. (
  14965. SELECT
  14966. m4.*
  14967. FROM
  14968. med_behospital_info m1,
  14969. med_home_page m2,
  14970. med_qcresult_info m3,
  14971. med_qcresult_cases m4
  14972. WHERE
  14973. m1.is_deleted = 'N'
  14974. AND m2.is_deleted = 'N'
  14975. AND m3.is_deleted = 'Y'
  14976. AND m4.is_deleted = 'Y'
  14977. AND m1.hospital_id = m2.hospital_id
  14978. AND m1.hospital_id = m3.hospital_id
  14979. AND m1.hospital_id = m4.hospital_id
  14980. AND m1.behospital_code = m2.behospital_code
  14981. AND m1.behospital_code = m3.behospital_code
  14982. AND m1.behospital_code = m4.behospital_code
  14983. AND m3.gmt_create = m4.gmt_create
  14984. AND m3.have_home_page = 1
  14985. AND m4.cases_id = 243
  14986. AND m1.qc_type_id != 0
  14987. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14988. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14989. </if>
  14990. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14991. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14992. </if>
  14993. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14994. <if test="qcResultShortPageVO.startDate != null ">
  14995. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14996. </if>
  14997. <if test="qcResultShortPageVO.endDate != null ">
  14998. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14999. </if>
  15000. </if>
  15001. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15002. <if test="qcResultShortPageVO.startDate != null">
  15003. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15004. </if>
  15005. <if test="qcResultShortPageVO.endDate != null ">
  15006. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15007. </if>
  15008. </if>
  15009. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15010. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  15011. </if>
  15012. GROUP BY
  15013. m1.behospital_code
  15014. ORDER BY
  15015. m1.behospital_code,
  15016. m4.gmt_create
  15017. ) e
  15018. WHERE
  15019. a.is_deleted = 'N'
  15020. AND b.is_deleted = 'N'
  15021. AND c.is_deleted = 'N'
  15022. AND d.is_deleted = 'N'
  15023. AND f.is_deleted = 'N'
  15024. AND a.hospital_id = b.hospital_id
  15025. AND a.hospital_id = c.hospital_id
  15026. AND a.hospital_id = d.hospital_id
  15027. AND a.hospital_id = f.hospital_id
  15028. AND a.hospital_id = e.hospital_id
  15029. AND a.behospital_code = b.behospital_code
  15030. AND a.behospital_code = c.behospital_code
  15031. AND a.behospital_code = d.behospital_code
  15032. AND a.beh_dept_id = f.dept_id
  15033. AND a.behospital_code = e.behospital_code
  15034. AND d.cases_id = 243
  15035. AND d.score_res > e.score_res
  15036. AND a.qc_type_id != 0
  15037. <if test="qcResultShortPageVO.userId!=null">
  15038. AND f.user_id = #{qcResultShortPageVO.userId}
  15039. </if>
  15040. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15041. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15042. </if>
  15043. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15044. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15045. </if>
  15046. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15047. <if test="qcResultShortPageVO.startDate != null ">
  15048. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15049. </if>
  15050. <if test="qcResultShortPageVO.endDate != null ">
  15051. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15052. </if>
  15053. </if>
  15054. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15055. <if test="qcResultShortPageVO.startDate != null ">
  15056. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15057. </if>
  15058. <if test="qcResultShortPageVO.endDate != null">
  15059. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15060. </if>
  15061. </if>
  15062. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15063. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15064. </if>
  15065. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15066. AND c.`level` = #{qcResultShortPageVO.level}
  15067. </if>
  15068. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15069. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15070. </if>
  15071. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15072. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15073. </if>
  15074. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15075. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15076. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15077. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15078. </if>
  15079. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15080. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15081. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15082. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15083. </if>
  15084. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15085. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15086. </if>
  15087. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15088. AND d.score_res = 20
  15089. </if>
  15090. ) be
  15091. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15092. AND mci.check_type = 0
  15093. AND be.hospital_id = mci.hospital_id
  15094. AND be.behospital_code = mci.behospital_code
  15095. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15096. AND hm_mci.check_type = 1
  15097. AND be.hospital_id = hm_mci.hospital_id
  15098. AND be.behospital_code = hm_mci.behospital_code
  15099. LEFT JOIN med_qcresult_cases e
  15100. on be.behospital_code = e.behospital_code
  15101. and be.hospital_id = e.hospital_id
  15102. AND e.is_deleted = 'N'
  15103. and e.cases_id = 243
  15104. ) t1
  15105. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15106. AND t1.behospital_code = t2.behospital_code
  15107. AND t2.is_deleted = 'N'
  15108. ) t
  15109. WHERE
  15110. 1 = 1
  15111. <if test="qcResultShortPageVO.checkStatus != null">
  15112. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15113. </if>
  15114. <if test="qcResultShortPageVO.mrStatus != null">
  15115. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15116. </if>
  15117. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15118. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15119. </if>
  15120. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15121. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15122. </if>
  15123. <if test="qcResultShortPageVO.chTimeStart != null ">
  15124. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15125. </if>
  15126. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15127. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15128. </if>
  15129. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15130. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15131. </if>
  15132. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15133. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15134. </if>
  15135. </select>
  15136. <!-- 质控核查质控评分页(内页)-->
  15137. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  15138. SELECT
  15139. t.*
  15140. FROM
  15141. (
  15142. SELECT DISTINCT
  15143. t1.hospital_id AS hospitalId,
  15144. t1.behospital_code AS behospitalCode,
  15145. t1.bed_code AS bedCode,
  15146. t1.LEVEL AS LEVEL,
  15147. t1.grade_type AS gradeType,
  15148. t1.score_res AS scoreRes,
  15149. t1.scoreBn,
  15150. t1.NAME AS NAME,
  15151. t1.sex AS sex,
  15152. t1.beh_dept_id AS behDeptId,
  15153. t1.beh_dept_name AS behDeptName,
  15154. t1.doctor_id AS doctorId,
  15155. t1.doctor_name AS doctorName,
  15156. t1.beh_doctor_id AS behDoctorId,
  15157. t1.beh_doctor_name AS behDoctorName,
  15158. t1.director_doctor_id AS directorDoctorId,
  15159. t1.director_doctor_name AS directorDoctorName,
  15160. t1.birthday AS birthday,
  15161. t1.behospital_date AS behospitalDate,
  15162. t1.leave_hospital_date AS leaveHospitalDate,
  15163. t1.placefile_date AS placefileDate,
  15164. t1.gmt_create AS gradeTime,
  15165. t1.diagnose,
  15166. t1.ward_name AS wardName,
  15167. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15168. t1.file_code AS fileCode,
  15169. t1.checkStatus,
  15170. t1.mrStatus,
  15171. t1.chName,
  15172. t1.mrName,
  15173. t1.chTime,
  15174. t1.mrTime
  15175. FROM
  15176. (
  15177. SELECT
  15178. be.*,
  15179. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15180. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15181. mci.check_name AS chName,
  15182. e.score_res as scoreBn,
  15183. hm_mci.check_name AS mrName,
  15184. mci.gmt_create AS chTime,
  15185. hm_mci.gmt_create AS mrTime
  15186. FROM
  15187. (
  15188. SELECT DISTINCT
  15189. a.hospital_id,
  15190. a.behospital_code,
  15191. a.bed_code,
  15192. a.file_code,
  15193. b.LEVEL,
  15194. b.grade_type,
  15195. b.score_res,
  15196. a.NAME,
  15197. a.sex,
  15198. a.beh_dept_id,
  15199. a.beh_dept_name,
  15200. a.birthday,
  15201. a.behospital_date,
  15202. a.leave_hospital_date,
  15203. a.doctor_id,
  15204. a.doctor_name,
  15205. a.beh_doctor_id,
  15206. a.beh_doctor_name,
  15207. a.director_doctor_id,
  15208. a.director_doctor_name,
  15209. a.diagnose,
  15210. a.placefile_date,
  15211. a.ward_name,
  15212. b.gmt_create
  15213. FROM
  15214. med_behospital_info a,
  15215. med_qcresult_info b
  15216. WHERE
  15217. a.is_deleted = 'N'
  15218. AND b.is_deleted = 'N'
  15219. AND a.hospital_id = b.hospital_id
  15220. AND a.behospital_code = b.behospital_code
  15221. AND a.qc_type_id != 0
  15222. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15223. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15224. </if>
  15225. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15226. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15227. </if>
  15228. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15229. <if test="qcResultShortPageVO.startDate != null ">
  15230. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15231. </if>
  15232. <if test="qcResultShortPageVO.endDate != null ">
  15233. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15234. </if>
  15235. </if>
  15236. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15237. <if test="qcResultShortPageVO.startDate != null ">
  15238. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15239. </if>
  15240. <if test="qcResultShortPageVO.endDate != null">
  15241. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15242. </if>
  15243. </if>
  15244. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15245. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15246. </if>
  15247. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15248. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15249. </if>
  15250. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15251. AND b.`level` = #{qcResultShortPageVO.level}
  15252. </if>
  15253. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15254. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15255. </if>
  15256. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15257. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15258. </if>
  15259. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15260. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15261. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15262. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15263. </if>
  15264. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15265. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15266. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15267. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15268. </if>
  15269. ) be
  15270. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15271. AND mci.check_type = 0
  15272. AND be.hospital_id = mci.hospital_id
  15273. AND be.behospital_code = mci.behospital_code
  15274. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15275. AND hm_mci.check_type = 1
  15276. AND be.hospital_id = hm_mci.hospital_id
  15277. AND be.behospital_code = hm_mci.behospital_code
  15278. LEFT JOIN med_qcresult_cases e
  15279. on be.behospital_code = e.behospital_code
  15280. and be.hospital_id = e.hospital_id
  15281. AND e.is_deleted = 'N'
  15282. and e.cases_id = 243
  15283. ) t1
  15284. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15285. AND t1.behospital_code = t2.behospital_code
  15286. AND t2.is_deleted = 'N'
  15287. ) t
  15288. WHERE
  15289. 1 = 1
  15290. <if test="qcResultShortPageVO.checkStatus != null">
  15291. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15292. </if>
  15293. <if test="qcResultShortPageVO.mrStatus != null">
  15294. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15295. </if>
  15296. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15297. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15298. </if>
  15299. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15300. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15301. </if>
  15302. <if test="qcResultShortPageVO.chTimeStart != null ">
  15303. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15304. </if>
  15305. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15306. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15307. </if>
  15308. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15309. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15310. </if>
  15311. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15312. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15313. </if>
  15314. </select>
  15315. <!-- 质控核查质控评分页-科室(内页)-->
  15316. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  15317. SELECT
  15318. t.*
  15319. FROM
  15320. (
  15321. SELECT DISTINCT
  15322. t1.hospital_id AS hospitalId,
  15323. t1.behospital_code AS behospitalCode,
  15324. t1.bed_code AS bedCode,
  15325. t1.LEVEL AS LEVEL,
  15326. t1.grade_type AS gradeType,
  15327. t1.score_res AS scoreRes,
  15328. t1.scoreBn,
  15329. t1.NAME AS NAME,
  15330. t1.sex AS sex,
  15331. t1.beh_dept_id AS behDeptId,
  15332. t1.beh_dept_name AS behDeptName,
  15333. t1.doctor_id AS doctorId,
  15334. t1.doctor_name AS doctorName,
  15335. t1.beh_doctor_id AS behDoctorId,
  15336. t1.beh_doctor_name AS behDoctorName,
  15337. t1.director_doctor_id AS directorDoctorId,
  15338. t1.director_doctor_name AS directorDoctorName,
  15339. t1.birthday AS birthday,
  15340. t1.behospital_date AS behospitalDate,
  15341. t1.leave_hospital_date AS leaveHospitalDate,
  15342. t1.placefile_date AS placefileDate,
  15343. t1.gmt_create AS gradeTime,
  15344. t1.diagnose,
  15345. t1.ward_name AS wardName,
  15346. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15347. t1.file_code AS fileCode,
  15348. t1.checkStatus,
  15349. t1.mrStatus,
  15350. t1.chName,
  15351. t1.mrName,
  15352. t1.chTime,
  15353. t1.mrTime
  15354. FROM
  15355. (
  15356. SELECT
  15357. be.*,
  15358. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15359. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15360. mci.check_name AS chName,
  15361. e.score_res as scoreBn,
  15362. hm_mci.check_name AS mrName,
  15363. mci.gmt_create AS chTime,
  15364. hm_mci.gmt_create AS mrTime
  15365. FROM
  15366. (
  15367. SELECT DISTINCT
  15368. a.hospital_id,
  15369. a.behospital_code,
  15370. a.bed_code,
  15371. a.file_code,
  15372. b.LEVEL,
  15373. b.grade_type,
  15374. b.score_res,
  15375. a.NAME,
  15376. a.sex,
  15377. a.beh_dept_id,
  15378. a.beh_dept_name,
  15379. a.birthday,
  15380. a.behospital_date,
  15381. a.leave_hospital_date,
  15382. a.doctor_id,
  15383. a.doctor_name,
  15384. a.beh_doctor_id,
  15385. a.beh_doctor_name,
  15386. a.director_doctor_id,
  15387. a.director_doctor_name,
  15388. a.diagnose,
  15389. a.placefile_date,
  15390. a.ward_name,
  15391. b.gmt_create
  15392. FROM
  15393. med_behospital_info a,
  15394. med_qcresult_info b,
  15395. sys_user_dept c
  15396. WHERE
  15397. a.is_deleted = 'N'
  15398. AND b.is_deleted = 'N'
  15399. AND c.is_deleted = 'N'
  15400. AND a.hospital_id = b.hospital_id
  15401. AND a.hospital_id = c.hospital_id
  15402. AND a.beh_dept_id = c.dept_id
  15403. AND a.behospital_code = b.behospital_code
  15404. AND a.qc_type_id != 0
  15405. <if test="qcResultShortPageVO.userId!=null">
  15406. AND c.user_id = #{qcResultShortPageVO.userId}
  15407. </if>
  15408. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15409. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15410. </if>
  15411. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15412. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15413. </if>
  15414. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15415. <if test="qcResultShortPageVO.startDate != null ">
  15416. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15417. </if>
  15418. <if test="qcResultShortPageVO.endDate != null ">
  15419. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15420. </if>
  15421. </if>
  15422. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15423. <if test="qcResultShortPageVO.startDate != null ">
  15424. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15425. </if>
  15426. <if test="qcResultShortPageVO.endDate != null">
  15427. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15428. </if>
  15429. </if>
  15430. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15431. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15432. </if>
  15433. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15434. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15435. </if>
  15436. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15437. AND b.`level` = #{qcResultShortPageVO.level}
  15438. </if>
  15439. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15440. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15441. </if>
  15442. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15443. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15444. </if>
  15445. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15446. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15447. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15448. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15449. </if>
  15450. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15451. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15452. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15453. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15454. </if>
  15455. ) be
  15456. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15457. AND mci.check_type = 0
  15458. AND be.hospital_id = mci.hospital_id
  15459. AND be.behospital_code = mci.behospital_code
  15460. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15461. AND hm_mci.check_type = 1
  15462. AND be.hospital_id = hm_mci.hospital_id
  15463. AND be.behospital_code = hm_mci.behospital_code
  15464. LEFT JOIN med_qcresult_cases e
  15465. on be.behospital_code = e.behospital_code
  15466. and be.hospital_id = e.hospital_id
  15467. AND e.is_deleted = 'N'
  15468. and e.cases_id = 243
  15469. ) t1
  15470. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15471. AND t1.behospital_code = t2.behospital_code
  15472. AND t2.is_deleted = 'N'
  15473. ) t
  15474. WHERE
  15475. 1 = 1
  15476. <if test="qcResultShortPageVO.checkStatus != null">
  15477. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15478. </if>
  15479. <if test="qcResultShortPageVO.mrStatus != null">
  15480. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15481. </if>
  15482. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15483. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15484. </if>
  15485. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15486. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15487. </if>
  15488. <if test="qcResultShortPageVO.chTimeStart != null ">
  15489. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15490. </if>
  15491. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15492. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15493. </if>
  15494. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15495. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15496. </if>
  15497. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15498. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15499. </if>
  15500. </select>
  15501. <!-- 病案首页改善率质控评分页导出-->
  15502. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  15503. SELECT
  15504. f1.behDeptId,
  15505. f1.behDeptName,
  15506. f1.doctorName,
  15507. f1.patName,
  15508. f1.behospitalCode,
  15509. f1.hospitalId,
  15510. f1.behospitalDate,
  15511. f1.leaveHospitalDate,
  15512. f1.score,
  15513. f2.avgScore,
  15514. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15515. f1.msg,
  15516. f1.caseName,
  15517. </if>
  15518. f1.checkStatus,
  15519. f1.mrStatus,
  15520. f1.chName,
  15521. f1.mrName,
  15522. f1.chTime,
  15523. f1.mrTime
  15524. FROM
  15525. (SELECT
  15526. t.doctorName AS behDoctorName,
  15527. t.`name` AS patName,
  15528. t.behospitalCode AS behospitalCode,
  15529. t.behospitalDate AS behospitalDate,
  15530. t.leaveHospitalDate AS leaveHospitalDate,
  15531. qi.score_res AS score,
  15532. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15533. qd.msg AS msg,
  15534. qc.NAME AS caseName,
  15535. </if>
  15536. t.behDeptId,
  15537. t.behDeptName,
  15538. t.hospitalId,
  15539. t.checkStatus,
  15540. t.mrStatus,
  15541. t.chName,
  15542. t.mrName,
  15543. t.chTime,
  15544. t.mrTime
  15545. FROM
  15546. (
  15547. SELECT DISTINCT
  15548. t1.hospital_id AS hospitalId,
  15549. t1.behospital_code AS behospitalCode,
  15550. t1.bed_code AS bedCode,
  15551. t1.LEVEL AS LEVEL,
  15552. t1.grade_type AS gradeType,
  15553. t1.score_res AS scoreRes,
  15554. t1.NAME AS NAME,
  15555. t1.sex AS sex,
  15556. t1.beh_dept_id AS behDeptId,
  15557. t1.beh_dept_name AS behDeptName,
  15558. t1.doctor_id AS doctorId,
  15559. t1.doctor_name AS doctorName,
  15560. t1.beh_doctor_id AS behDoctorId,
  15561. t1.beh_doctor_name AS behDoctorName,
  15562. t1.director_doctor_id AS directorDoctorId,
  15563. t1.director_doctor_name AS directorDoctorName,
  15564. t1.birthday AS birthday,
  15565. t1.behospital_date AS behospitalDate,
  15566. t1.leave_hospital_date AS leaveHospitalDate,
  15567. t1.placefile_date AS placefileDate,
  15568. t1.gmt_create AS gradeTime,
  15569. t1.diagnose,
  15570. t1.ward_name AS wardName,
  15571. t2.age,
  15572. t1.file_code AS fileCode,
  15573. t1.checkStatus,
  15574. t1.mrStatus,
  15575. t1.chName,
  15576. t1.mrName,
  15577. t1.chTime,
  15578. t1.mrTime
  15579. FROM
  15580. (
  15581. SELECT
  15582. be.*,
  15583. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15584. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15585. mci.check_name AS chName,
  15586. hm_mci.check_name AS mrName,
  15587. mci.gmt_create AS chTime,
  15588. hm_mci.gmt_create AS mrTime
  15589. FROM
  15590. (
  15591. SELECT DISTINCT
  15592. a.hospital_id,
  15593. a.behospital_code,
  15594. a.bed_code,
  15595. a.file_code,
  15596. c.LEVEL,
  15597. c.grade_type,
  15598. c.score_res,
  15599. a.NAME,
  15600. a.sex,
  15601. a.beh_dept_id,
  15602. a.beh_dept_name,
  15603. a.birthday,
  15604. a.behospital_date,
  15605. a.leave_hospital_date,
  15606. a.doctor_id,
  15607. a.doctor_name,
  15608. a.beh_doctor_id,
  15609. a.beh_doctor_name,
  15610. a.director_doctor_id,
  15611. a.director_doctor_name,
  15612. a.diagnose,
  15613. a.placefile_date,
  15614. a.ward_name,
  15615. c.gmt_create
  15616. FROM
  15617. med_behospital_info a,
  15618. med_home_page b,
  15619. med_qcresult_info c,
  15620. med_qcresult_cases d,
  15621. (
  15622. SELECT
  15623. m4.*
  15624. FROM
  15625. med_behospital_info m1,
  15626. med_home_page m2,
  15627. med_qcresult_info m3,
  15628. med_qcresult_cases m4
  15629. WHERE
  15630. m1.is_deleted = 'N'
  15631. AND m2.is_deleted = 'N'
  15632. AND m3.is_deleted = 'Y'
  15633. AND m4.is_deleted = 'Y'
  15634. AND m1.hospital_id = m2.hospital_id
  15635. AND m1.hospital_id = m3.hospital_id
  15636. AND m1.hospital_id = m4.hospital_id
  15637. AND m1.behospital_code = m2.behospital_code
  15638. AND m1.behospital_code = m3.behospital_code
  15639. AND m1.behospital_code = m4.behospital_code
  15640. AND m3.gmt_create = m4.gmt_create
  15641. AND m3.have_home_page = 1
  15642. AND m4.cases_id = 243
  15643. AND m1.qc_type_id != 0
  15644. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15645. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15646. </if>
  15647. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15648. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15649. </if>
  15650. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15651. <if test="qcResultShortPageVO.startDate != null ">
  15652. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15653. </if>
  15654. <if test="qcResultShortPageVO.endDate != null ">
  15655. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15656. </if>
  15657. </if>
  15658. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15659. <if test="qcResultShortPageVO.startDate != null">
  15660. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15661. </if>
  15662. <if test="qcResultShortPageVO.endDate != null ">
  15663. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15664. </if>
  15665. </if>
  15666. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15667. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15668. </if>
  15669. GROUP BY
  15670. m1.behospital_code
  15671. ORDER BY
  15672. m1.behospital_code,
  15673. m4.gmt_create
  15674. ) e
  15675. WHERE
  15676. a.is_deleted = 'N'
  15677. AND b.is_deleted = 'N'
  15678. AND c.is_deleted = 'N'
  15679. AND d.is_deleted = 'N'
  15680. AND a.hospital_id = b.hospital_id
  15681. AND a.hospital_id = c.hospital_id
  15682. AND a.hospital_id = d.hospital_id
  15683. AND a.hospital_id = e.hospital_id
  15684. AND a.behospital_code = b.behospital_code
  15685. AND a.behospital_code = c.behospital_code
  15686. AND a.behospital_code = d.behospital_code
  15687. AND a.behospital_code = e.behospital_code
  15688. AND d.cases_id = 243
  15689. AND d.score_res > e.score_res
  15690. AND a.qc_type_id != 0
  15691. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15692. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15693. </if>
  15694. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15695. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15696. </if>
  15697. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15698. <if test="qcResultShortPageVO.startDate != null ">
  15699. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15700. </if>
  15701. <if test="qcResultShortPageVO.endDate != null ">
  15702. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15703. </if>
  15704. </if>
  15705. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15706. <if test="qcResultShortPageVO.startDate != null ">
  15707. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15708. </if>
  15709. <if test="qcResultShortPageVO.endDate != null">
  15710. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15711. </if>
  15712. </if>
  15713. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15714. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15715. </if>
  15716. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15717. AND c.`level` = #{qcResultShortPageVO.level}
  15718. </if>
  15719. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15720. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15721. </if>
  15722. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15723. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15724. </if>
  15725. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15726. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15727. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15728. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15729. </if>
  15730. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15731. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15732. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15733. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15734. </if>
  15735. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15736. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15737. </if>
  15738. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15739. AND d.score_res = 20
  15740. </if>
  15741. ) be
  15742. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15743. AND mci.check_type = 0
  15744. AND be.hospital_id = mci.hospital_id
  15745. AND be.behospital_code = mci.behospital_code
  15746. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15747. AND hm_mci.check_type = 1
  15748. AND be.hospital_id = hm_mci.hospital_id
  15749. AND be.behospital_code = hm_mci.behospital_code
  15750. ) t1
  15751. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15752. AND t1.behospital_code = t2.behospital_code
  15753. AND t2.is_deleted = 'N'
  15754. ) t
  15755. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15756. AND t.hospitalId = qi.hospital_id
  15757. AND t.behospitalCode = qi.behospital_code
  15758. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15759. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15760. AND t.hospitalId = qd.hospital_id
  15761. AND t.behospitalCode = qd.behospital_code
  15762. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15763. AND qd.cases_id = qc.id
  15764. </if>
  15765. where 1=1
  15766. <if test="qcResultShortPageVO.checkStatus != null">
  15767. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15768. </if>
  15769. <if test="qcResultShortPageVO.mrStatus != null">
  15770. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15771. </if>
  15772. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15773. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15774. </if>
  15775. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15776. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15777. </if>
  15778. <if test="qcResultShortPageVO.chTimeStart != null ">
  15779. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15780. </if>
  15781. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15782. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15783. </if>
  15784. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15785. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15786. </if>
  15787. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15788. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15789. </if>
  15790. )f1,
  15791. (SELECT
  15792. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15793. t.behDeptId,
  15794. t.behDeptName
  15795. FROM
  15796. (
  15797. SELECT DISTINCT
  15798. t1.hospital_id AS hospitalId,
  15799. t1.behospital_code AS behospitalCode,
  15800. t1.bed_code AS bedCode,
  15801. t1.LEVEL AS LEVEL,
  15802. t1.grade_type AS gradeType,
  15803. t1.score_res AS scoreRes,
  15804. t1.NAME AS NAME,
  15805. t1.sex AS sex,
  15806. t1.beh_dept_id AS behDeptId,
  15807. t1.beh_dept_name AS behDeptName,
  15808. t1.doctor_id AS doctorId,
  15809. t1.doctor_name AS doctorName,
  15810. t1.beh_doctor_id AS behDoctorId,
  15811. t1.beh_doctor_name AS behDoctorName,
  15812. t1.director_doctor_id AS directorDoctorId,
  15813. t1.director_doctor_name AS directorDoctorName,
  15814. t1.birthday AS birthday,
  15815. t1.behospital_date AS behospitalDate,
  15816. t1.leave_hospital_date AS leaveHospitalDate,
  15817. t1.placefile_date AS placefileDate,
  15818. t1.gmt_create AS gradeTime,
  15819. t1.diagnose,
  15820. t1.ward_name AS wardName,
  15821. t2.age,
  15822. t1.file_code AS fileCode,
  15823. t1.checkStatus,
  15824. t1.mrStatus,
  15825. t1.chName,
  15826. t1.mrName,
  15827. t1.chTime,
  15828. t1.mrTime
  15829. FROM
  15830. (
  15831. SELECT
  15832. be.*,
  15833. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15834. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15835. mci.check_name AS chName,
  15836. hm_mci.check_name AS mrName,
  15837. mci.gmt_create AS chTime,
  15838. hm_mci.gmt_create AS mrTime
  15839. FROM
  15840. (
  15841. SELECT DISTINCT
  15842. a.hospital_id,
  15843. a.behospital_code,
  15844. a.bed_code,
  15845. a.file_code,
  15846. c.LEVEL,
  15847. c.grade_type,
  15848. c.score_res,
  15849. a.NAME,
  15850. a.sex,
  15851. a.beh_dept_id,
  15852. a.beh_dept_name,
  15853. a.birthday,
  15854. a.behospital_date,
  15855. a.leave_hospital_date,
  15856. a.doctor_id,
  15857. a.doctor_name,
  15858. a.beh_doctor_id,
  15859. a.beh_doctor_name,
  15860. a.director_doctor_id,
  15861. a.director_doctor_name,
  15862. a.diagnose,
  15863. a.placefile_date,
  15864. a.ward_name,
  15865. c.gmt_create
  15866. FROM
  15867. med_behospital_info a,
  15868. med_home_page b,
  15869. med_qcresult_info c,
  15870. med_qcresult_cases d,
  15871. (
  15872. SELECT
  15873. m4.*
  15874. FROM
  15875. med_behospital_info m1,
  15876. med_home_page m2,
  15877. med_qcresult_info m3,
  15878. med_qcresult_cases m4
  15879. WHERE
  15880. m1.is_deleted = 'N'
  15881. AND m2.is_deleted = 'N'
  15882. AND m3.is_deleted = 'Y'
  15883. AND m4.is_deleted = 'Y'
  15884. AND m1.hospital_id = m2.hospital_id
  15885. AND m1.hospital_id = m3.hospital_id
  15886. AND m1.hospital_id = m4.hospital_id
  15887. AND m1.behospital_code = m2.behospital_code
  15888. AND m1.behospital_code = m3.behospital_code
  15889. AND m1.behospital_code = m4.behospital_code
  15890. AND m3.gmt_create = m4.gmt_create
  15891. AND m3.have_home_page = 1
  15892. AND m4.cases_id = 243
  15893. AND m1.qc_type_id != 0
  15894. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15895. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15896. </if>
  15897. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15898. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15899. </if>
  15900. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15901. <if test="qcResultShortPageVO.startDate != null ">
  15902. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15903. </if>
  15904. <if test="qcResultShortPageVO.endDate != null ">
  15905. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15906. </if>
  15907. </if>
  15908. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15909. <if test="qcResultShortPageVO.startDate != null">
  15910. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15911. </if>
  15912. <if test="qcResultShortPageVO.endDate != null ">
  15913. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15914. </if>
  15915. </if>
  15916. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15917. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15918. </if>
  15919. GROUP BY
  15920. m1.behospital_code
  15921. ORDER BY
  15922. m1.behospital_code,
  15923. m4.gmt_create
  15924. ) e
  15925. WHERE
  15926. a.is_deleted = 'N'
  15927. AND b.is_deleted = 'N'
  15928. AND c.is_deleted = 'N'
  15929. AND d.is_deleted = 'N'
  15930. AND a.hospital_id = b.hospital_id
  15931. AND a.hospital_id = c.hospital_id
  15932. AND a.hospital_id = d.hospital_id
  15933. AND a.hospital_id = e.hospital_id
  15934. AND a.behospital_code = b.behospital_code
  15935. AND a.behospital_code = c.behospital_code
  15936. AND a.behospital_code = d.behospital_code
  15937. AND a.behospital_code = e.behospital_code
  15938. AND d.cases_id = 243
  15939. AND d.score_res > e.score_res
  15940. AND a.qc_type_id != 0
  15941. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15942. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15943. </if>
  15944. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15945. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15946. </if>
  15947. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15948. <if test="qcResultShortPageVO.startDate != null ">
  15949. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15950. </if>
  15951. <if test="qcResultShortPageVO.endDate != null ">
  15952. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15953. </if>
  15954. </if>
  15955. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15956. <if test="qcResultShortPageVO.startDate != null ">
  15957. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15958. </if>
  15959. <if test="qcResultShortPageVO.endDate != null">
  15960. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15961. </if>
  15962. </if>
  15963. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15964. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15965. </if>
  15966. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15967. AND c.`level` = #{qcResultShortPageVO.level}
  15968. </if>
  15969. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15970. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15971. </if>
  15972. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15973. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15974. </if>
  15975. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15976. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15977. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15978. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15979. </if>
  15980. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15981. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15982. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15983. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15984. </if>
  15985. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15986. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15987. </if>
  15988. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15989. AND d.score_res = 20
  15990. </if>
  15991. ) be
  15992. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15993. AND mci.check_type = 0
  15994. AND be.hospital_id = mci.hospital_id
  15995. AND be.behospital_code = mci.behospital_code
  15996. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15997. AND hm_mci.check_type = 1
  15998. AND be.hospital_id = hm_mci.hospital_id
  15999. AND be.behospital_code = hm_mci.behospital_code
  16000. ) t1
  16001. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16002. AND t1.behospital_code = t2.behospital_code
  16003. AND t2.is_deleted = 'N'
  16004. ) t
  16005. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16006. AND t.hospitalId = qi.hospital_id
  16007. AND t.behospitalCode = qi.behospital_code
  16008. where 1=1
  16009. <if test="qcResultShortPageVO.checkStatus != null">
  16010. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16011. </if>
  16012. <if test="qcResultShortPageVO.mrStatus != null">
  16013. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16014. </if>
  16015. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16016. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16017. </if>
  16018. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16019. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16020. </if>
  16021. <if test="qcResultShortPageVO.chTimeStart != null ">
  16022. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16023. </if>
  16024. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16025. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16026. </if>
  16027. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16028. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16029. </if>
  16030. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16031. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16032. </if>
  16033. GROUP BY
  16034. t.behDeptId,
  16035. t.behDeptName
  16036. )f2
  16037. WHERE
  16038. f1.behDeptId = f2.behDeptId
  16039. AND f1.behDeptName = f2.behDeptName
  16040. </select>
  16041. <!-- 病案首页改善率质控评分页导出-->
  16042. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  16043. SELECT
  16044. f1.behDeptId,
  16045. f1.behDeptName,
  16046. f1.doctorId,
  16047. f1.doctorName,
  16048. f1.patName,
  16049. f1.behospitalCode,
  16050. f1.hospitalId,
  16051. f1.scoreBn,
  16052. f1.behospitalDate,
  16053. f1.leaveHospitalDate,
  16054. f1.score,
  16055. f2.avgScore,
  16056. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16057. f1.msg,
  16058. f1.caseName,
  16059. </if>
  16060. f1.checkStatus,
  16061. f1.mrStatus,
  16062. f1.chName,
  16063. f1.mrName,
  16064. f1.chTime,
  16065. f1.mrTime
  16066. FROM
  16067. (SELECT
  16068. t.doctorId,
  16069. t.doctorName,
  16070. t.`name` AS patName,
  16071. t.behospitalCode AS behospitalCode,
  16072. t.behospitalDate AS behospitalDate,
  16073. t.leaveHospitalDate AS leaveHospitalDate,
  16074. qi.score_res AS score,
  16075. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16076. qd.msg AS msg,
  16077. qc.NAME AS caseName,
  16078. </if>
  16079. t.behDeptId,
  16080. t.behDeptName,
  16081. t.hospitalId,
  16082. t.checkStatus,
  16083. t.mrStatus,
  16084. t.chName,
  16085. t.mrName,
  16086. t.chTime,
  16087. t.mrTime
  16088. FROM
  16089. (
  16090. SELECT DISTINCT
  16091. t1.hospital_id AS hospitalId,
  16092. t1.behospital_code AS behospitalCode,
  16093. t1.bed_code AS bedCode,
  16094. t1.LEVEL AS LEVEL,
  16095. t1.grade_type AS gradeType,
  16096. t1.score_res AS scoreRes,
  16097. t1.NAME AS NAME,
  16098. t1.sex AS sex,
  16099. t1.beh_dept_id AS behDeptId,
  16100. t1.beh_dept_name AS behDeptName,
  16101. t1.doctor_id AS doctorId,
  16102. t1.doctor_name AS doctorName,
  16103. t1.beh_doctor_id AS behDoctorId,
  16104. t1.beh_doctor_name AS behDoctorName,
  16105. t1.director_doctor_id AS directorDoctorId,
  16106. t1.director_doctor_name AS directorDoctorName,
  16107. t1.birthday AS birthday,
  16108. t1.behospital_date AS behospitalDate,
  16109. t1.leave_hospital_date AS leaveHospitalDate,
  16110. t1.placefile_date AS placefileDate,
  16111. t1.gmt_create AS gradeTime,
  16112. t1.diagnose,
  16113. t1.ward_name AS wardName,
  16114. t1.scoreBn,
  16115. t1.file_code AS fileCode,
  16116. t1.checkStatus,
  16117. t1.mrStatus,
  16118. t1.chName,
  16119. t1.mrName,
  16120. t1.chTime,
  16121. t1.mrTime
  16122. FROM
  16123. (
  16124. SELECT
  16125. be.*,
  16126. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16127. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16128. mci.check_name AS chName,
  16129. e.score_res as scoreBn,
  16130. hm_mci.check_name AS mrName,
  16131. mci.gmt_create AS chTime,
  16132. hm_mci.gmt_create AS mrTime
  16133. FROM
  16134. (
  16135. SELECT DISTINCT
  16136. a.hospital_id,
  16137. a.behospital_code,
  16138. a.bed_code,
  16139. a.file_code,
  16140. c.LEVEL,
  16141. c.grade_type,
  16142. c.score_res,
  16143. a.NAME,
  16144. a.sex,
  16145. a.beh_dept_id,
  16146. a.beh_dept_name,
  16147. a.birthday,
  16148. a.behospital_date,
  16149. a.leave_hospital_date,
  16150. a.doctor_id,
  16151. a.doctor_name,
  16152. a.beh_doctor_id,
  16153. a.beh_doctor_name,
  16154. a.director_doctor_id,
  16155. a.director_doctor_name,
  16156. a.diagnose,
  16157. a.placefile_date,
  16158. a.ward_name,
  16159. c.gmt_create
  16160. FROM
  16161. med_behospital_info a,
  16162. med_home_page b,
  16163. med_qcresult_info c,
  16164. med_qcresult_cases d,
  16165. sys_user_dept f,
  16166. (
  16167. SELECT
  16168. m4.*
  16169. FROM
  16170. med_behospital_info m1,
  16171. med_home_page m2,
  16172. med_qcresult_info m3,
  16173. med_qcresult_cases m4
  16174. WHERE
  16175. m1.is_deleted = 'N'
  16176. AND m2.is_deleted = 'N'
  16177. AND m3.is_deleted = 'Y'
  16178. AND m4.is_deleted = 'Y'
  16179. AND m1.hospital_id = m2.hospital_id
  16180. AND m1.hospital_id = m3.hospital_id
  16181. AND m1.hospital_id = m4.hospital_id
  16182. AND m1.behospital_code = m2.behospital_code
  16183. AND m1.behospital_code = m3.behospital_code
  16184. AND m1.behospital_code = m4.behospital_code
  16185. AND m3.gmt_create = m4.gmt_create
  16186. AND m3.have_home_page = 1
  16187. AND m4.cases_id = 243
  16188. AND m1.qc_type_id != 0
  16189. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16190. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16191. </if>
  16192. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16193. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16194. </if>
  16195. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16196. <if test="qcResultShortPageVO.startDate != null ">
  16197. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16198. </if>
  16199. <if test="qcResultShortPageVO.endDate != null ">
  16200. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16201. </if>
  16202. </if>
  16203. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16204. <if test="qcResultShortPageVO.startDate != null">
  16205. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16206. </if>
  16207. <if test="qcResultShortPageVO.endDate != null ">
  16208. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16209. </if>
  16210. </if>
  16211. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16212. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16213. </if>
  16214. GROUP BY
  16215. m1.behospital_code
  16216. ORDER BY
  16217. m1.behospital_code,
  16218. m4.gmt_create
  16219. ) e
  16220. WHERE
  16221. a.is_deleted = 'N'
  16222. AND b.is_deleted = 'N'
  16223. AND c.is_deleted = 'N'
  16224. AND d.is_deleted = 'N'
  16225. AND f.is_deleted = 'N'
  16226. AND a.hospital_id = b.hospital_id
  16227. AND a.hospital_id = c.hospital_id
  16228. AND a.hospital_id = d.hospital_id
  16229. AND a.hospital_id = e.hospital_id
  16230. AND a.hospital_id = f.hospital_id
  16231. AND a.behospital_code = b.behospital_code
  16232. AND a.behospital_code = c.behospital_code
  16233. AND a.behospital_code = d.behospital_code
  16234. AND a.behospital_code = e.behospital_code
  16235. AND a.beh_dept_id = f.dept_id
  16236. AND d.cases_id = 243
  16237. AND d.score_res > e.score_res
  16238. AND a.qc_type_id != 0
  16239. <if test="qcResultShortPageVO.userId!=null">
  16240. AND f.user_id = #{qcResultShortPageVO.userId}
  16241. </if>
  16242. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16243. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16244. </if>
  16245. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16246. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16247. </if>
  16248. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16249. <if test="qcResultShortPageVO.startDate != null ">
  16250. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16251. </if>
  16252. <if test="qcResultShortPageVO.endDate != null ">
  16253. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16254. </if>
  16255. </if>
  16256. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16257. <if test="qcResultShortPageVO.startDate != null ">
  16258. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16259. </if>
  16260. <if test="qcResultShortPageVO.endDate != null">
  16261. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16262. </if>
  16263. </if>
  16264. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16265. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16266. </if>
  16267. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16268. AND c.`level` = #{qcResultShortPageVO.level}
  16269. </if>
  16270. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16271. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16272. </if>
  16273. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16274. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16275. </if>
  16276. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16277. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16278. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16279. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16280. </if>
  16281. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16282. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16283. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16284. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16285. </if>
  16286. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16287. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16288. </if>
  16289. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16290. AND d.score_res = 20
  16291. </if>
  16292. ) be
  16293. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16294. AND mci.check_type = 0
  16295. AND be.hospital_id = mci.hospital_id
  16296. AND be.behospital_code = mci.behospital_code
  16297. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16298. AND hm_mci.check_type = 1
  16299. AND be.hospital_id = hm_mci.hospital_id
  16300. AND be.behospital_code = hm_mci.behospital_code
  16301. LEFT JOIN med_qcresult_cases e
  16302. on be.behospital_code = e.behospital_code
  16303. and be.hospital_id = e.hospital_id
  16304. AND e.is_deleted = 'N'
  16305. and e.cases_id = 243
  16306. ) t1
  16307. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16308. AND t1.behospital_code = t2.behospital_code
  16309. AND t2.is_deleted = 'N'
  16310. ) t
  16311. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16312. AND t.hospitalId = qi.hospital_id
  16313. AND t.behospitalCode = qi.behospital_code
  16314. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16315. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16316. AND t.hospitalId = qd.hospital_id
  16317. AND t.behospitalCode = qd.behospital_code
  16318. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16319. AND qd.cases_id = qc.id
  16320. </if>
  16321. where 1=1
  16322. <if test="qcResultShortPageVO.checkStatus != null">
  16323. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16324. </if>
  16325. <if test="qcResultShortPageVO.mrStatus != null">
  16326. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16327. </if>
  16328. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16329. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16330. </if>
  16331. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16332. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16333. </if>
  16334. <if test="qcResultShortPageVO.chTimeStart != null ">
  16335. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16336. </if>
  16337. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16338. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16339. </if>
  16340. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16341. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16342. </if>
  16343. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16344. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16345. </if>
  16346. )f1,
  16347. (SELECT
  16348. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16349. t.behDeptId,
  16350. t.behDeptName,
  16351. t.doctorId,
  16352. t.doctorName
  16353. FROM
  16354. (
  16355. SELECT DISTINCT
  16356. t1.hospital_id AS hospitalId,
  16357. t1.behospital_code AS behospitalCode,
  16358. t1.bed_code AS bedCode,
  16359. t1.LEVEL AS LEVEL,
  16360. t1.grade_type AS gradeType,
  16361. t1.score_res AS scoreRes,
  16362. t1.NAME AS NAME,
  16363. t1.sex AS sex,
  16364. t1.beh_dept_id AS behDeptId,
  16365. t1.beh_dept_name AS behDeptName,
  16366. t1.doctor_id AS doctorId,
  16367. t1.doctor_name AS doctorName,
  16368. t1.beh_doctor_id AS behDoctorId,
  16369. t1.beh_doctor_name AS behDoctorName,
  16370. t1.director_doctor_id AS directorDoctorId,
  16371. t1.director_doctor_name AS directorDoctorName,
  16372. t1.birthday AS birthday,
  16373. t1.behospital_date AS behospitalDate,
  16374. t1.leave_hospital_date AS leaveHospitalDate,
  16375. t1.placefile_date AS placefileDate,
  16376. t1.gmt_create AS gradeTime,
  16377. t1.diagnose,
  16378. t1.ward_name AS wardName,
  16379. t2.age,
  16380. t1.file_code AS fileCode,
  16381. t1.checkStatus,
  16382. t1.mrStatus,
  16383. t1.chName,
  16384. t1.mrName,
  16385. t1.chTime,
  16386. t1.mrTime
  16387. FROM
  16388. (
  16389. SELECT
  16390. be.*,
  16391. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16392. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16393. mci.check_name AS chName,
  16394. hm_mci.check_name AS mrName,
  16395. mci.gmt_create AS chTime,
  16396. hm_mci.gmt_create AS mrTime
  16397. FROM
  16398. (
  16399. SELECT DISTINCT
  16400. a.hospital_id,
  16401. a.behospital_code,
  16402. a.bed_code,
  16403. a.file_code,
  16404. c.LEVEL,
  16405. c.grade_type,
  16406. c.score_res,
  16407. a.NAME,
  16408. a.sex,
  16409. a.beh_dept_id,
  16410. a.beh_dept_name,
  16411. a.birthday,
  16412. a.behospital_date,
  16413. a.leave_hospital_date,
  16414. a.doctor_id,
  16415. a.doctor_name,
  16416. a.beh_doctor_id,
  16417. a.beh_doctor_name,
  16418. a.director_doctor_id,
  16419. a.director_doctor_name,
  16420. a.diagnose,
  16421. a.placefile_date,
  16422. a.ward_name,
  16423. c.gmt_create
  16424. FROM
  16425. med_behospital_info a,
  16426. med_home_page b,
  16427. med_qcresult_info c,
  16428. med_qcresult_cases d,
  16429. sys_user_dept f,
  16430. (
  16431. SELECT
  16432. m4.*
  16433. FROM
  16434. med_behospital_info m1,
  16435. med_home_page m2,
  16436. med_qcresult_info m3,
  16437. med_qcresult_cases m4
  16438. WHERE
  16439. m1.is_deleted = 'N'
  16440. AND m2.is_deleted = 'N'
  16441. AND m3.is_deleted = 'Y'
  16442. AND m4.is_deleted = 'Y'
  16443. AND m1.hospital_id = m2.hospital_id
  16444. AND m1.hospital_id = m3.hospital_id
  16445. AND m1.hospital_id = m4.hospital_id
  16446. AND m1.behospital_code = m2.behospital_code
  16447. AND m1.behospital_code = m3.behospital_code
  16448. AND m1.behospital_code = m4.behospital_code
  16449. AND m3.gmt_create = m4.gmt_create
  16450. AND m3.have_home_page = 1
  16451. AND m4.cases_id = 243
  16452. AND m1.qc_type_id != 0
  16453. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16454. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16455. </if>
  16456. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16457. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16458. </if>
  16459. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16460. <if test="qcResultShortPageVO.startDate != null ">
  16461. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16462. </if>
  16463. <if test="qcResultShortPageVO.endDate != null ">
  16464. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16465. </if>
  16466. </if>
  16467. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16468. <if test="qcResultShortPageVO.startDate != null">
  16469. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16470. </if>
  16471. <if test="qcResultShortPageVO.endDate != null ">
  16472. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16473. </if>
  16474. </if>
  16475. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16476. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16477. </if>
  16478. GROUP BY
  16479. m1.behospital_code
  16480. ORDER BY
  16481. m1.behospital_code,
  16482. m4.gmt_create
  16483. ) e
  16484. WHERE
  16485. a.is_deleted = 'N'
  16486. AND b.is_deleted = 'N'
  16487. AND c.is_deleted = 'N'
  16488. AND d.is_deleted = 'N'
  16489. AND f.is_deleted = 'N'
  16490. AND a.hospital_id = b.hospital_id
  16491. AND a.hospital_id = c.hospital_id
  16492. AND a.hospital_id = d.hospital_id
  16493. AND a.hospital_id = e.hospital_id
  16494. AND a.hospital_id = f.hospital_id
  16495. AND a.behospital_code = b.behospital_code
  16496. AND a.behospital_code = c.behospital_code
  16497. AND a.behospital_code = d.behospital_code
  16498. AND a.behospital_code = e.behospital_code
  16499. AND a.beh_dept_id = f.dept_id
  16500. AND d.cases_id = 243
  16501. AND d.score_res > e.score_res
  16502. AND a.qc_type_id != 0
  16503. <if test="qcResultShortPageVO.userId!=null">
  16504. AND f.user_id = #{qcResultShortPageVO.userId}
  16505. </if>
  16506. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16507. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16508. </if>
  16509. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16510. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16511. </if>
  16512. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16513. <if test="qcResultShortPageVO.startDate != null ">
  16514. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16515. </if>
  16516. <if test="qcResultShortPageVO.endDate != null ">
  16517. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16518. </if>
  16519. </if>
  16520. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16521. <if test="qcResultShortPageVO.startDate != null ">
  16522. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16523. </if>
  16524. <if test="qcResultShortPageVO.endDate != null">
  16525. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16526. </if>
  16527. </if>
  16528. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16529. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16530. </if>
  16531. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16532. AND c.`level` = #{qcResultShortPageVO.level}
  16533. </if>
  16534. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16535. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16536. </if>
  16537. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16538. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16539. </if>
  16540. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16541. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16542. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16543. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16544. </if>
  16545. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16546. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16547. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16548. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16549. </if>
  16550. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16551. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16552. </if>
  16553. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16554. AND d.score_res = 20
  16555. </if>
  16556. ) be
  16557. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16558. AND mci.check_type = 0
  16559. AND be.hospital_id = mci.hospital_id
  16560. AND be.behospital_code = mci.behospital_code
  16561. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16562. AND hm_mci.check_type = 1
  16563. AND be.hospital_id = hm_mci.hospital_id
  16564. AND be.behospital_code = hm_mci.behospital_code
  16565. ) t1
  16566. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16567. AND t1.behospital_code = t2.behospital_code
  16568. AND t2.is_deleted = 'N'
  16569. ) t
  16570. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16571. AND t.hospitalId = qi.hospital_id
  16572. AND t.behospitalCode = qi.behospital_code
  16573. where 1=1
  16574. <if test="qcResultShortPageVO.checkStatus != null">
  16575. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16576. </if>
  16577. <if test="qcResultShortPageVO.mrStatus != null">
  16578. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16579. </if>
  16580. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16581. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16582. </if>
  16583. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16584. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16585. </if>
  16586. <if test="qcResultShortPageVO.chTimeStart != null ">
  16587. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16588. </if>
  16589. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16590. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16591. </if>
  16592. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16593. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16594. </if>
  16595. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16596. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16597. </if>
  16598. GROUP BY
  16599. t.doctorId,
  16600. t.doctorName
  16601. )f2
  16602. WHERE
  16603. f1.doctorId = f2.doctorId
  16604. AND f1.doctorName = f2.doctorName
  16605. </select>
  16606. <!-- 质控核查质控评分页导出-->
  16607. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  16608. SELECT
  16609. f1.behDeptId,
  16610. f1.behDeptName,
  16611. f1.doctorName,
  16612. f1.patName,
  16613. f1.behospitalCode,
  16614. f1.hospitalId,
  16615. f1.behospitalDate,
  16616. f1.leaveHospitalDate,
  16617. f1.score,
  16618. f1.scoreBn,
  16619. f2.avgScore,
  16620. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16621. f1.msg,
  16622. f1.caseName,
  16623. </if>
  16624. f1.checkStatus,
  16625. f1.mrStatus,
  16626. f1.chName,
  16627. f1.mrName,
  16628. f1.chTime,
  16629. f1.mrTime
  16630. FROM
  16631. (SELECT
  16632. t.doctorName,
  16633. t.`name` AS patName,
  16634. t.behospitalCode AS behospitalCode,
  16635. t.behospitalDate AS behospitalDate,
  16636. t.leaveHospitalDate AS leaveHospitalDate,
  16637. qi.score_res AS score,
  16638. t.scoreBn,
  16639. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16640. qd.msg AS msg,
  16641. qc.NAME AS caseName,
  16642. </if>
  16643. t.behDeptId,
  16644. t.behDeptName,
  16645. t.hospitalId,
  16646. t.checkStatus,
  16647. t.mrStatus,
  16648. t.chName,
  16649. t.mrName,
  16650. t.chTime,
  16651. t.mrTime
  16652. FROM
  16653. (
  16654. SELECT DISTINCT
  16655. t1.hospital_id AS hospitalId,
  16656. t1.behospital_code AS behospitalCode,
  16657. t1.bed_code AS bedCode,
  16658. t1.LEVEL AS LEVEL,
  16659. t1.grade_type AS gradeType,
  16660. t1.score_res AS scoreRes,
  16661. t1.scoreBn,
  16662. t1.NAME AS NAME,
  16663. t1.sex AS sex,
  16664. t1.beh_dept_id AS behDeptId,
  16665. t1.beh_dept_name AS behDeptName,
  16666. t1.doctor_id AS doctorId,
  16667. t1.doctor_name AS doctorName,
  16668. t1.beh_doctor_id AS behDoctorId,
  16669. t1.beh_doctor_name AS behDoctorName,
  16670. t1.director_doctor_id AS directorDoctorId,
  16671. t1.director_doctor_name AS directorDoctorName,
  16672. t1.birthday AS birthday,
  16673. t1.behospital_date AS behospitalDate,
  16674. t1.leave_hospital_date AS leaveHospitalDate,
  16675. t1.placefile_date AS placefileDate,
  16676. t1.gmt_create AS gradeTime,
  16677. t1.diagnose,
  16678. t1.ward_name AS wardName,
  16679. t2.age,
  16680. t1.file_code AS fileCode,
  16681. t1.checkStatus,
  16682. t1.mrStatus,
  16683. t1.chName,
  16684. t1.mrName,
  16685. t1.chTime,
  16686. t1.mrTime
  16687. FROM
  16688. (
  16689. SELECT
  16690. be.*,
  16691. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16692. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16693. mci.check_name AS chName,
  16694. e.score_res as scoreBn,
  16695. hm_mci.check_name AS mrName,
  16696. mci.gmt_create AS chTime,
  16697. hm_mci.gmt_create AS mrTime
  16698. FROM
  16699. (
  16700. SELECT DISTINCT
  16701. a.hospital_id,
  16702. a.behospital_code,
  16703. a.bed_code,
  16704. a.file_code,
  16705. b.LEVEL,
  16706. b.grade_type,
  16707. b.score_res,
  16708. a.NAME,
  16709. a.sex,
  16710. a.beh_dept_id,
  16711. a.beh_dept_name,
  16712. a.birthday,
  16713. a.behospital_date,
  16714. a.leave_hospital_date,
  16715. a.doctor_id,
  16716. a.doctor_name,
  16717. a.beh_doctor_id,
  16718. a.beh_doctor_name,
  16719. a.director_doctor_id,
  16720. a.director_doctor_name,
  16721. a.diagnose,
  16722. a.placefile_date,
  16723. a.ward_name,
  16724. b.gmt_create
  16725. FROM
  16726. med_behospital_info a,
  16727. med_qcresult_info b
  16728. WHERE
  16729. a.is_deleted = 'N'
  16730. AND b.is_deleted = 'N'
  16731. AND a.hospital_id = b.hospital_id
  16732. AND a.behospital_code = b.behospital_code
  16733. AND a.qc_type_id != 0
  16734. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16735. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16736. </if>
  16737. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16738. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16739. </if>
  16740. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16741. <if test="qcResultShortPageVO.startDate != null ">
  16742. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16743. </if>
  16744. <if test="qcResultShortPageVO.endDate != null ">
  16745. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16746. </if>
  16747. </if>
  16748. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16749. <if test="qcResultShortPageVO.startDate != null ">
  16750. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16751. </if>
  16752. <if test="qcResultShortPageVO.endDate != null">
  16753. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16754. </if>
  16755. </if>
  16756. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  16757. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  16758. </if>
  16759. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16760. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16761. </if>
  16762. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16763. AND c.`level` = #{qcResultShortPageVO.level}
  16764. </if>
  16765. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16766. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16767. </if>
  16768. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16769. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16770. </if>
  16771. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16772. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16773. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16774. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16775. </if>
  16776. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16777. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16778. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16779. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16780. </if>
  16781. ) be
  16782. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16783. AND mci.check_type = 0
  16784. AND be.hospital_id = mci.hospital_id
  16785. AND be.behospital_code = mci.behospital_code
  16786. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16787. AND hm_mci.check_type = 1
  16788. AND be.hospital_id = hm_mci.hospital_id
  16789. AND be.behospital_code = hm_mci.behospital_code
  16790. LEFT JOIN med_qcresult_cases e
  16791. on be.behospital_code = e.behospital_code
  16792. and be.hospital_id = e.hospital_id
  16793. AND e.is_deleted = 'N'
  16794. and e.cases_id = 243
  16795. ) t1
  16796. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16797. AND t1.behospital_code = t2.behospital_code
  16798. AND t2.is_deleted = 'N'
  16799. ) t
  16800. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16801. AND t.hospitalId = qi.hospital_id
  16802. AND t.behospitalCode = qi.behospital_code
  16803. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16804. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16805. AND t.hospitalId = qd.hospital_id
  16806. AND t.behospitalCode = qd.behospital_code
  16807. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16808. AND qd.cases_id = qc.id
  16809. </if>
  16810. where 1=1
  16811. <if test="qcResultShortPageVO.checkStatus != null">
  16812. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16813. </if>
  16814. <if test="qcResultShortPageVO.mrStatus != null">
  16815. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16816. </if>
  16817. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16818. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16819. </if>
  16820. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16821. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16822. </if>
  16823. <if test="qcResultShortPageVO.chTimeStart != null ">
  16824. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16825. </if>
  16826. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16827. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16828. </if>
  16829. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16830. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16831. </if>
  16832. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16833. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16834. </if>
  16835. )f1,
  16836. (SELECT
  16837. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16838. t.behDeptId,
  16839. t.behDeptName
  16840. FROM
  16841. (
  16842. SELECT DISTINCT
  16843. t1.hospital_id AS hospitalId,
  16844. t1.behospital_code AS behospitalCode,
  16845. t1.bed_code AS bedCode,
  16846. t1.LEVEL AS LEVEL,
  16847. t1.grade_type AS gradeType,
  16848. t1.score_res AS scoreRes,
  16849. t1.NAME AS NAME,
  16850. t1.sex AS sex,
  16851. t1.beh_dept_id AS behDeptId,
  16852. t1.beh_dept_name AS behDeptName,
  16853. t1.doctor_id AS doctorId,
  16854. t1.doctor_name AS doctorName,
  16855. t1.beh_doctor_id AS behDoctorId,
  16856. t1.beh_doctor_name AS behDoctorName,
  16857. t1.director_doctor_id AS directorDoctorId,
  16858. t1.director_doctor_name AS directorDoctorName,
  16859. t1.birthday AS birthday,
  16860. t1.behospital_date AS behospitalDate,
  16861. t1.leave_hospital_date AS leaveHospitalDate,
  16862. t1.placefile_date AS placefileDate,
  16863. t1.gmt_create AS gradeTime,
  16864. t1.diagnose,
  16865. t1.ward_name AS wardName,
  16866. t2.age,
  16867. t1.file_code AS fileCode,
  16868. t1.checkStatus,
  16869. t1.mrStatus,
  16870. t1.chName,
  16871. t1.mrName,
  16872. t1.chTime,
  16873. t1.mrTime
  16874. FROM
  16875. (
  16876. SELECT
  16877. be.*,
  16878. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16879. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16880. mci.check_name AS chName,
  16881. hm_mci.check_name AS mrName,
  16882. mci.gmt_create AS chTime,
  16883. hm_mci.gmt_create AS mrTime
  16884. FROM
  16885. (
  16886. SELECT DISTINCT
  16887. a.hospital_id,
  16888. a.behospital_code,
  16889. a.bed_code,
  16890. a.file_code,
  16891. b.LEVEL,
  16892. b.grade_type,
  16893. b.score_res,
  16894. a.NAME,
  16895. a.sex,
  16896. a.beh_dept_id,
  16897. a.beh_dept_name,
  16898. a.birthday,
  16899. a.behospital_date,
  16900. a.leave_hospital_date,
  16901. a.doctor_id,
  16902. a.doctor_name,
  16903. a.beh_doctor_id,
  16904. a.beh_doctor_name,
  16905. a.director_doctor_id,
  16906. a.director_doctor_name,
  16907. a.diagnose,
  16908. a.placefile_date,
  16909. a.ward_name,
  16910. b.gmt_create
  16911. FROM
  16912. med_behospital_info a,
  16913. med_qcresult_info b
  16914. WHERE
  16915. a.is_deleted = 'N'
  16916. AND b.is_deleted = 'N'
  16917. AND a.hospital_id = b.hospital_id
  16918. AND a.behospital_code = b.behospital_code
  16919. AND a.qc_type_id != 0
  16920. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16921. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16922. </if>
  16923. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16924. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16925. </if>
  16926. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16927. <if test="qcResultShortPageVO.startDate != null ">
  16928. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16929. </if>
  16930. <if test="qcResultShortPageVO.endDate != null ">
  16931. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16932. </if>
  16933. </if>
  16934. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16935. <if test="qcResultShortPageVO.startDate != null ">
  16936. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16937. </if>
  16938. <if test="qcResultShortPageVO.endDate != null">
  16939. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16940. </if>
  16941. </if>
  16942. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  16943. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  16944. </if>
  16945. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16946. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16947. </if>
  16948. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16949. AND c.`level` = #{qcResultShortPageVO.level}
  16950. </if>
  16951. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16952. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16953. </if>
  16954. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16955. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16956. </if>
  16957. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16958. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16959. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16960. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16961. </if>
  16962. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16963. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16964. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16965. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16966. </if>
  16967. ) be
  16968. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16969. AND mci.check_type = 0
  16970. AND be.hospital_id = mci.hospital_id
  16971. AND be.behospital_code = mci.behospital_code
  16972. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16973. AND hm_mci.check_type = 1
  16974. AND be.hospital_id = hm_mci.hospital_id
  16975. AND be.behospital_code = hm_mci.behospital_code
  16976. ) t1
  16977. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16978. AND t1.behospital_code = t2.behospital_code
  16979. AND t2.is_deleted = 'N'
  16980. ) t
  16981. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16982. AND t.hospitalId = qi.hospital_id
  16983. AND t.behospitalCode = qi.behospital_code
  16984. where 1=1
  16985. <if test="qcResultShortPageVO.checkStatus != null">
  16986. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16987. </if>
  16988. <if test="qcResultShortPageVO.mrStatus != null">
  16989. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16990. </if>
  16991. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16992. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16993. </if>
  16994. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16995. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16996. </if>
  16997. <if test="qcResultShortPageVO.chTimeStart != null ">
  16998. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16999. </if>
  17000. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17001. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17002. </if>
  17003. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17004. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17005. </if>
  17006. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17007. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17008. </if>
  17009. GROUP BY
  17010. t.behDeptId,
  17011. t.behDeptName
  17012. )f2
  17013. WHERE
  17014. f1.behDeptId = f2.behDeptId
  17015. AND f1.behDeptName = f2.behDeptName
  17016. </select>
  17017. <!-- 质控核查质控评分页导出 -科室-->
  17018. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  17019. SELECT
  17020. f1.behDeptId,
  17021. f1.behDeptName,
  17022. f1.doctorName,
  17023. f1.doctorId,
  17024. f1.patName,
  17025. f1.behospitalCode,
  17026. f1.hospitalId,
  17027. f1.behospitalDate,
  17028. f1.leaveHospitalDate,
  17029. f1.score,
  17030. f1.scoreBn,
  17031. f2.avgScore,
  17032. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17033. f1.msg,
  17034. f1.caseName,
  17035. </if>
  17036. f1.checkStatus,
  17037. f1.mrStatus,
  17038. f1.chName,
  17039. f1.mrName,
  17040. f1.chTime,
  17041. f1.mrTime
  17042. FROM
  17043. (SELECT
  17044. t.doctorName,
  17045. t.doctorId,
  17046. t.`name` AS patName,
  17047. t.behospitalCode AS behospitalCode,
  17048. t.behospitalDate AS behospitalDate,
  17049. t.leaveHospitalDate AS leaveHospitalDate,
  17050. qi.score_res AS score,
  17051. t.scoreBn,
  17052. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17053. qd.msg AS msg,
  17054. qc.NAME AS caseName,
  17055. </if>
  17056. t.behDeptId,
  17057. t.behDeptName,
  17058. t.hospitalId,
  17059. t.checkStatus,
  17060. t.mrStatus,
  17061. t.chName,
  17062. t.mrName,
  17063. t.chTime,
  17064. t.mrTime
  17065. FROM
  17066. (
  17067. SELECT DISTINCT
  17068. t1.hospital_id AS hospitalId,
  17069. t1.behospital_code AS behospitalCode,
  17070. t1.bed_code AS bedCode,
  17071. t1.LEVEL AS LEVEL,
  17072. t1.grade_type AS gradeType,
  17073. t1.score_res AS scoreRes,
  17074. t1.scoreBn,
  17075. t1.NAME AS NAME,
  17076. t1.sex AS sex,
  17077. t1.beh_dept_id AS behDeptId,
  17078. t1.beh_dept_name AS behDeptName,
  17079. t1.doctor_id AS doctorId,
  17080. t1.doctor_name AS doctorName,
  17081. t1.beh_doctor_id AS behDoctorId,
  17082. t1.beh_doctor_name AS behDoctorName,
  17083. t1.director_doctor_id AS directorDoctorId,
  17084. t1.director_doctor_name AS directorDoctorName,
  17085. t1.birthday AS birthday,
  17086. t1.behospital_date AS behospitalDate,
  17087. t1.leave_hospital_date AS leaveHospitalDate,
  17088. t1.placefile_date AS placefileDate,
  17089. t1.gmt_create AS gradeTime,
  17090. t1.diagnose,
  17091. t1.ward_name AS wardName,
  17092. t2.age,
  17093. t1.file_code AS fileCode,
  17094. t1.checkStatus,
  17095. t1.mrStatus,
  17096. t1.chName,
  17097. t1.mrName,
  17098. t1.chTime,
  17099. t1.mrTime
  17100. FROM
  17101. (
  17102. SELECT
  17103. be.*,
  17104. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17105. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17106. mci.check_name AS chName,
  17107. e.score_res as scoreBn,
  17108. hm_mci.check_name AS mrName,
  17109. mci.gmt_create AS chTime,
  17110. hm_mci.gmt_create AS mrTime
  17111. FROM
  17112. (
  17113. SELECT DISTINCT
  17114. a.hospital_id,
  17115. a.behospital_code,
  17116. a.bed_code,
  17117. a.file_code,
  17118. b.LEVEL,
  17119. b.grade_type,
  17120. b.score_res,
  17121. a.NAME,
  17122. a.sex,
  17123. a.beh_dept_id,
  17124. a.beh_dept_name,
  17125. a.birthday,
  17126. a.behospital_date,
  17127. a.leave_hospital_date,
  17128. a.doctor_id,
  17129. a.doctor_name,
  17130. a.beh_doctor_id,
  17131. a.beh_doctor_name,
  17132. a.director_doctor_id,
  17133. a.director_doctor_name,
  17134. a.diagnose,
  17135. a.placefile_date,
  17136. a.ward_name,
  17137. b.gmt_create
  17138. FROM
  17139. med_behospital_info a,
  17140. med_qcresult_info b,
  17141. sys_user_dept c
  17142. WHERE
  17143. a.is_deleted = 'N'
  17144. AND b.is_deleted = 'N'
  17145. AND c.is_deleted = 'N'
  17146. AND a.hospital_id = b.hospital_id
  17147. AND a.hospital_id = c.hospital_id
  17148. AND a.behospital_code = b.behospital_code
  17149. AND a.beh_dept_id = c.dept_id
  17150. AND a.qc_type_id != 0
  17151. <if test="qcResultShortPageVO.userId!=null">
  17152. AND c.user_id = #{qcResultShortPageVO.userId}
  17153. </if>
  17154. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17155. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17156. </if>
  17157. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17158. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17159. </if>
  17160. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17161. <if test="qcResultShortPageVO.startDate != null ">
  17162. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17163. </if>
  17164. <if test="qcResultShortPageVO.endDate != null ">
  17165. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17166. </if>
  17167. </if>
  17168. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17169. <if test="qcResultShortPageVO.startDate != null ">
  17170. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17171. </if>
  17172. <if test="qcResultShortPageVO.endDate != null">
  17173. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17174. </if>
  17175. </if>
  17176. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17177. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17178. </if>
  17179. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17180. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17181. </if>
  17182. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17183. AND c.`level` = #{qcResultShortPageVO.level}
  17184. </if>
  17185. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17186. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17187. </if>
  17188. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17189. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17190. </if>
  17191. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17192. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17193. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17194. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17195. </if>
  17196. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17197. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17198. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17199. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17200. </if>
  17201. ) be
  17202. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17203. AND mci.check_type = 0
  17204. AND be.hospital_id = mci.hospital_id
  17205. AND be.behospital_code = mci.behospital_code
  17206. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17207. AND hm_mci.check_type = 1
  17208. AND be.hospital_id = hm_mci.hospital_id
  17209. AND be.behospital_code = hm_mci.behospital_code
  17210. LEFT JOIN med_qcresult_cases e
  17211. on be.behospital_code = e.behospital_code
  17212. and be.hospital_id = e.hospital_id
  17213. AND e.is_deleted = 'N'
  17214. and e.cases_id = 243
  17215. ) t1
  17216. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17217. AND t1.behospital_code = t2.behospital_code
  17218. AND t2.is_deleted = 'N'
  17219. ) t
  17220. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17221. AND t.hospitalId = qi.hospital_id
  17222. AND t.behospitalCode = qi.behospital_code
  17223. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17224. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17225. AND t.hospitalId = qd.hospital_id
  17226. AND t.behospitalCode = qd.behospital_code
  17227. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17228. AND qd.cases_id = qc.id
  17229. </if>
  17230. where 1=1
  17231. <if test="qcResultShortPageVO.checkStatus != null">
  17232. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17233. </if>
  17234. <if test="qcResultShortPageVO.mrStatus != null">
  17235. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17236. </if>
  17237. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17238. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17239. </if>
  17240. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17241. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17242. </if>
  17243. <if test="qcResultShortPageVO.chTimeStart != null ">
  17244. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17245. </if>
  17246. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17247. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17248. </if>
  17249. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17250. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17251. </if>
  17252. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17253. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17254. </if>
  17255. )f1,
  17256. (SELECT
  17257. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17258. t.behDeptId,
  17259. t.behDeptName,
  17260. t.doctorId,
  17261. t.doctorName
  17262. FROM
  17263. (
  17264. SELECT DISTINCT
  17265. t1.hospital_id AS hospitalId,
  17266. t1.behospital_code AS behospitalCode,
  17267. t1.bed_code AS bedCode,
  17268. t1.LEVEL AS LEVEL,
  17269. t1.grade_type AS gradeType,
  17270. t1.score_res AS scoreRes,
  17271. t1.NAME AS NAME,
  17272. t1.sex AS sex,
  17273. t1.beh_dept_id AS behDeptId,
  17274. t1.beh_dept_name AS behDeptName,
  17275. t1.doctor_id AS doctorId,
  17276. t1.doctor_name AS doctorName,
  17277. t1.beh_doctor_id AS behDoctorId,
  17278. t1.beh_doctor_name AS behDoctorName,
  17279. t1.director_doctor_id AS directorDoctorId,
  17280. t1.director_doctor_name AS directorDoctorName,
  17281. t1.birthday AS birthday,
  17282. t1.behospital_date AS behospitalDate,
  17283. t1.leave_hospital_date AS leaveHospitalDate,
  17284. t1.placefile_date AS placefileDate,
  17285. t1.gmt_create AS gradeTime,
  17286. t1.diagnose,
  17287. t1.ward_name AS wardName,
  17288. t2.age,
  17289. t1.file_code AS fileCode,
  17290. t1.checkStatus,
  17291. t1.mrStatus,
  17292. t1.chName,
  17293. t1.mrName,
  17294. t1.chTime,
  17295. t1.mrTime
  17296. FROM
  17297. (
  17298. SELECT
  17299. be.*,
  17300. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17301. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17302. mci.check_name AS chName,
  17303. hm_mci.check_name AS mrName,
  17304. mci.gmt_create AS chTime,
  17305. hm_mci.gmt_create AS mrTime
  17306. FROM
  17307. (
  17308. SELECT DISTINCT
  17309. a.hospital_id,
  17310. a.behospital_code,
  17311. a.bed_code,
  17312. a.file_code,
  17313. b.LEVEL,
  17314. b.grade_type,
  17315. b.score_res,
  17316. a.NAME,
  17317. a.sex,
  17318. a.beh_dept_id,
  17319. a.beh_dept_name,
  17320. a.birthday,
  17321. a.behospital_date,
  17322. a.leave_hospital_date,
  17323. a.doctor_id,
  17324. a.doctor_name,
  17325. a.beh_doctor_id,
  17326. a.beh_doctor_name,
  17327. a.director_doctor_id,
  17328. a.director_doctor_name,
  17329. a.diagnose,
  17330. a.placefile_date,
  17331. a.ward_name,
  17332. b.gmt_create
  17333. FROM
  17334. med_behospital_info a,
  17335. med_qcresult_info b,
  17336. sys_user_dept c
  17337. WHERE
  17338. a.is_deleted = 'N'
  17339. AND b.is_deleted = 'N'
  17340. AND c.is_deleted = 'N'
  17341. AND a.hospital_id = b.hospital_id
  17342. AND a.hospital_id = c.hospital_id
  17343. AND a.behospital_code = b.behospital_code
  17344. AND a.beh_dept_id = c.dept_id
  17345. AND a.qc_type_id != 0
  17346. <if test="qcResultShortPageVO.userId!=null">
  17347. AND c.user_id = #{qcResultShortPageVO.userId}
  17348. </if>
  17349. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17350. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17351. </if>
  17352. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17353. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17354. </if>
  17355. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17356. <if test="qcResultShortPageVO.startDate != null ">
  17357. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17358. </if>
  17359. <if test="qcResultShortPageVO.endDate != null ">
  17360. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17361. </if>
  17362. </if>
  17363. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17364. <if test="qcResultShortPageVO.startDate != null ">
  17365. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17366. </if>
  17367. <if test="qcResultShortPageVO.endDate != null">
  17368. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17369. </if>
  17370. </if>
  17371. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17372. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17373. </if>
  17374. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17375. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17376. </if>
  17377. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17378. AND c.`level` = #{qcResultShortPageVO.level}
  17379. </if>
  17380. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17381. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17382. </if>
  17383. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17384. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17385. </if>
  17386. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17387. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17388. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17389. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17390. </if>
  17391. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17392. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17393. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17394. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17395. </if>
  17396. ) be
  17397. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17398. AND mci.check_type = 0
  17399. AND be.hospital_id = mci.hospital_id
  17400. AND be.behospital_code = mci.behospital_code
  17401. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17402. AND hm_mci.check_type = 1
  17403. AND be.hospital_id = hm_mci.hospital_id
  17404. AND be.behospital_code = hm_mci.behospital_code
  17405. ) t1
  17406. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17407. AND t1.behospital_code = t2.behospital_code
  17408. AND t2.is_deleted = 'N'
  17409. ) t
  17410. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17411. AND t.hospitalId = qi.hospital_id
  17412. AND t.behospitalCode = qi.behospital_code
  17413. where 1=1
  17414. <if test="qcResultShortPageVO.checkStatus != null">
  17415. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17416. </if>
  17417. <if test="qcResultShortPageVO.mrStatus != null">
  17418. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17419. </if>
  17420. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17421. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17422. </if>
  17423. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17424. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17425. </if>
  17426. <if test="qcResultShortPageVO.chTimeStart != null ">
  17427. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17428. </if>
  17429. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17430. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17431. </if>
  17432. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17433. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17434. </if>
  17435. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17436. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17437. </if>
  17438. GROUP BY
  17439. t.doctorId,
  17440. t.doctorName
  17441. )f2
  17442. WHERE
  17443. f1.doctorId = f2.doctorId
  17444. AND f1.doctorName = f2.doctorName
  17445. </select>
  17446. </mapper>