BehospitalInfoMapper.xml 731 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209
  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. <result column="linkman" property="linkman"/>
  40. </resultMap>
  41. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  42. SELECT * FROM (
  43. select t.*,
  44. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  45. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  46. g.check_type AS ch_type,
  47. h.check_type AS mr_type,
  48. g.check_name AS ch_name,
  49. h.check_name AS mr_name,
  50. g.check_time AS ch_time,
  51. h.check_time AS mr_time
  52. from (
  53. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  54. 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
  55. LEFT JOIN med_qcresult_info b
  56. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  57. left join med_home_page c
  58. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  59. LEFT JOIN med_qcresult_cases e
  60. on a.behospital_code = e.behospital_code
  61. AND e.is_deleted = 'N'
  62. and e.cases_id = 243
  63. ) t
  64. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  65. ON t.behospital_code = g.behospital_code
  66. AND t.hospital_id = g.hospital_id
  67. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  68. ON t.behospital_code = h.behospital_code
  69. AND t.hospital_id = h.hospital_id
  70. where t.is_deleted = 'N'
  71. <if test="diagnose != null and diagnose != ''">
  72. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  73. </if>
  74. <if test="deptName != null and deptName != ''">
  75. and t.beh_dept_name= #{deptName}
  76. </if>
  77. <if test="doctorName != null and doctorName != ''">
  78. and CONCAT(
  79. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  80. like CONCAT('%',#{doctorName},'%')
  81. </if>
  82. <if test="name != null and name != ''">
  83. and t.name like CONCAT('%',#{name},'%')
  84. </if>
  85. <if test="doctorCode != null and doctorCode != ''">
  86. and (t.doctor_id = #{doctorCode}
  87. or t.beh_doctor_id = #{doctorCode}
  88. or t.director_doctor_id = #{doctorCode})
  89. </if>
  90. <if test="fileCode != null and fileCode != ''">
  91. and t.file_code like CONCAT('%',#{fileCode},'%')
  92. </if>
  93. <if test="hospitalId != null">
  94. and t.hospital_id = #{hospitalId}
  95. </if>
  96. <if test="behospitalCode != null and behospitalCode != ''">
  97. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  98. </if>
  99. <if test="behosDateStart != null">
  100. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  101. </if>
  102. <if test="behosDateEnd != null">
  103. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  104. </if>
  105. <if test="leaveHosDateStart != null">
  106. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  107. </if>
  108. <if test="leaveHosDateEnd != null">
  109. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  110. </if>
  111. <if test="level != null and level != ''">
  112. and t.level = #{level}
  113. </if>
  114. <if test="isPlacefile != null and isPlacefile != ''">
  115. and t.is_placefile = #{isPlacefile}
  116. </if>
  117. and t.qc_type_id != 0) p
  118. where p.is_deleted="N"
  119. <if test="checkStatus != null ">
  120. and p.check_status = #{checkStatus}
  121. </if>
  122. <if test="mrStatus != null ">
  123. AND p.mr_status = #{mrStatus}
  124. </if>
  125. <if test="chName != null and chName !=''">
  126. AND p.ch_name like CONCAT('%',#{chName},'%')
  127. </if>
  128. <if test="mrName != null and mrName !=''">
  129. AND p.mr_name like CONCAT('%',#{mrName},'%')
  130. </if>
  131. <if test="chTimeStart != null">
  132. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  133. </if>
  134. <if test="chTimeEnd != null">
  135. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  136. </if>
  137. <if test="mrTimeStart != null">
  138. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  139. </if>
  140. <if test="mrTimeEnd != null">
  141. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  142. </if>
  143. </select>
  144. <select id="getQualityCaseSorce" resultType="com.diagbot.dto.CaseScoreDTO">
  145. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  146. FROM med_qcresult_detail c,med_behospital_info e
  147. where c.is_deleted = 'N'AND e.is_deleted = 'N'
  148. AND c.behospital_code = e.behospital_code
  149. AND c.hospital_id = e.hospital_id
  150. and c.hospital_id = #{hospitalId}
  151. <if test="deptName != null and deptName != ''">
  152. and e.beh_dept_name= #{deptName}
  153. </if>
  154. <if test="behospitalCode != null and behospitalCode != ''">
  155. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  156. </if>
  157. <if test="isPlacefile != null and isPlacefile != ''">
  158. and e.is_placefile = #{isPlacefile}
  159. </if>
  160. <if test="behosDateStart != null">
  161. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  162. </if>
  163. <if test="behosDateEnd != null">
  164. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  165. </if>
  166. <if test="leaveHosDateStart != null">
  167. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  168. </if>
  169. <if test="leaveHosDateEnd != null">
  170. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  171. </if>
  172. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  173. order by c.behospital_code
  174. </select>
  175. <select id="getQualityCaseSorceByDept" resultType="com.diagbot.dto.CaseScoreDTO">
  176. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  177. FROM med_qcresult_detail c,sys_user_dept d,med_behospital_info e
  178. where c.is_deleted = 'N' AND d.is_deleted = 'N' AND e.is_deleted = 'N'
  179. AND c.behospital_code = e.behospital_code
  180. ON d.hospital_id = e.hospital_id
  181. AND e.beh_dept_id = d.dept_id
  182. AND c.hospital_id = e.hospital_id
  183. and c.hospital_id = #{hospitalId}
  184. <if test="deptName != null and deptName != ''">
  185. and e.beh_dept_name= #{deptName}
  186. </if>
  187. <if test="userId != null and userId != ''">
  188. and d.user_id = #{userId}
  189. </if>
  190. <if test="behospitalCode != null and behospitalCode != ''">
  191. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  192. </if>
  193. <if test="isPlacefile != null and isPlacefile != ''">
  194. and e.is_placefile = #{isPlacefile}
  195. </if>
  196. <if test="behosDateStart != null">
  197. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  198. </if>
  199. <if test="behosDateEnd != null">
  200. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  201. </if>
  202. <if test="leaveHosDateStart != null">
  203. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  204. </if>
  205. <if test="leaveHosDateEnd != null">
  206. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  207. </if>
  208. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  209. order by c.behospital_code
  210. </select>
  211. <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  212. SELECT * FROM (
  213. select
  214. distinct
  215. t.name AS NAME,
  216. t.behospital_code AS behospitalCode,
  217. t.doctor_name AS doctorName,
  218. t.beh_dept_name AS deptName,
  219. t.beh_dept_id AS deptId,
  220. t.leave_hospital_date AS leaveHospitalDate,
  221. t.level,
  222. t.age,
  223. t.score_res as totalScore,
  224. t.is_deleted,
  225. g.check_name AS chName,
  226. h.check_name AS mrName
  227. from (
  228. select a.*,
  229. ifnull(b.level,'未评分') as level,
  230. b.grade_type,
  231. IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,
  232. b.score_res
  233. from med_behospital_info a
  234. LEFT JOIN med_qcresult_info b
  235. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  236. left join med_home_page c
  237. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  238. ) t
  239. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  240. ON t.behospital_code = g.behospital_code
  241. AND t.hospital_id = g.hospital_id
  242. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  243. ON t.behospital_code = h.behospital_code
  244. AND t.hospital_id = h.hospital_id
  245. where t.is_deleted = 'N'
  246. <if test="diagnose != null and diagnose != ''">
  247. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  248. </if>
  249. <if test="deptName != null and deptName != ''">
  250. and t.beh_dept_name= #{deptName}
  251. </if>
  252. <if test="doctorName != null and doctorName != ''">
  253. and CONCAT(
  254. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  255. like CONCAT('%',#{doctorName},'%')
  256. </if>
  257. <if test="name != null and name != ''">
  258. and t.name like CONCAT('%',#{name},'%')
  259. </if>
  260. <if test="doctorCode != null and doctorCode != ''">
  261. and (t.doctor_id = #{doctorCode}
  262. or t.beh_doctor_id = #{doctorCode}
  263. or t.director_doctor_id = #{doctorCode})
  264. </if>
  265. <if test="fileCode != null and fileCode != ''">
  266. and t.file_code like CONCAT('%',#{fileCode},'%')
  267. </if>
  268. <if test="hospitalId != null">
  269. and t.hospital_id = #{hospitalId}
  270. </if>
  271. <if test="behospitalCode != null and behospitalCode != ''">
  272. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  273. </if>
  274. <if test="behosDateStart != null">
  275. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  276. </if>
  277. <if test="behosDateEnd != null">
  278. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  279. </if>
  280. <if test="leaveHosDateStart != null">
  281. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  282. </if>
  283. <if test="leaveHosDateEnd != null">
  284. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  285. </if>
  286. <if test="level != null and level != ''">
  287. and t.level = #{level}
  288. </if>
  289. <if test="isPlacefile != null and isPlacefile != ''">
  290. and t.is_placefile = #{isPlacefile}
  291. </if>
  292. and t.qc_type_id != 0) p
  293. where p.is_deleted="N"
  294. <if test="chName != null and chName !=''">
  295. AND p.chName like CONCAT('%',#{chName},'%')
  296. </if>
  297. <if test="mrName != null and mrName !=''">
  298. AND p.mrName like CONCAT('%',#{mrName},'%')
  299. </if>
  300. </select>
  301. <select id="qualityControlByDept" resultType="com.diagbot.dto.QualityControlDeptDTO">
  302. SELECT * FROM (
  303. select
  304. distinct
  305. t.name AS NAME,
  306. t.behospital_code AS behospitalCode,
  307. t.doctor_name AS doctorName,
  308. t.beh_dept_name AS deptName,
  309. t.beh_dept_id AS deptId,
  310. t.leave_hospital_date AS leaveHospitalDate,
  311. t.level,
  312. t.age,
  313. t.score_res as totalScore,
  314. t.is_deleted,
  315. g.check_name AS chName,
  316. h.check_name AS mrName
  317. from (
  318. select a.*, ifnull(b.level,'未评分') as level, IF(c.age is null, null,CONCAT( ifnull(c.age,''),ifnull(c.age_unit,'') ))as age, b.grade_type,d.user_id, b.score_res, b.gmt_create as
  319. grade_time from med_behospital_info a
  320. LEFT JOIN med_qcresult_info b
  321. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  322. left join med_home_page c
  323. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  324. LEFT JOIN sys_user_dept d
  325. ON a.hospital_id = d.hospital_id
  326. AND a.beh_dept_id = d.dept_id
  327. ) t
  328. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  329. ON t.behospital_code = g.behospital_code
  330. AND t.hospital_id = g.hospital_id
  331. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  332. ON t.behospital_code = h.behospital_code
  333. AND t.hospital_id = h.hospital_id
  334. where t.is_deleted = 'N'
  335. AND t.user_id = #{userId}
  336. <if test="diagnose != null and diagnose != ''">
  337. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  338. </if>
  339. <if test="deptName != null and deptName != ''">
  340. and t.beh_dept_name= #{deptName}
  341. </if>
  342. <if test="doctorName != null and doctorName != ''">
  343. and CONCAT(
  344. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  345. like CONCAT('%',#{doctorName},'%')
  346. </if>
  347. <if test="name != null and name != ''">
  348. and t.name like CONCAT('%',#{name},'%')
  349. </if>
  350. <if test="doctorCode != null and doctorCode != ''">
  351. and (t.doctor_id = #{doctorCode}
  352. or t.beh_doctor_id = #{doctorCode}
  353. or t.director_doctor_id = #{doctorCode})
  354. </if>
  355. <if test="fileCode != null and fileCode != ''">
  356. and t.file_code like CONCAT('%',#{fileCode},'%')
  357. </if>
  358. <if test="hospitalId != null">
  359. and t.hospital_id = #{hospitalId}
  360. </if>
  361. <if test="behospitalCode != null and behospitalCode != ''">
  362. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  363. </if>
  364. <if test="behosDateStart != null">
  365. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  366. </if>
  367. <if test="behosDateEnd != null">
  368. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  369. </if>
  370. <if test="leaveHosDateStart != null">
  371. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  372. </if>
  373. <if test="leaveHosDateEnd != null">
  374. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  375. </if>
  376. <if test="level != null and level != ''">
  377. and t.level = #{level}
  378. </if>
  379. <if test="isPlacefile != null and isPlacefile != ''">
  380. and t.is_placefile = #{isPlacefile}
  381. </if>
  382. and t.qc_type_id != 0) p
  383. where p.is_deleted="N"
  384. <if test="chName != null and chName !=''">
  385. AND p.chName like CONCAT('%',#{chName},'%')
  386. </if>
  387. <if test="mrName != null and mrName !=''">
  388. AND p.mrName like CONCAT('%',#{mrName},'%')
  389. </if>
  390. </select>
  391. <!-- <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  392. SELECT m.* FROM(
  393. SELECT
  394. a.name AS NAME,
  395. a.behospital_code AS behospitalCode,
  396. a.doctor_name AS doctorName,
  397. a.beh_dept_name AS deptName,
  398. a.beh_dept_id AS deptId,
  399. a.leave_hospital_date AS leaveHospitalDate,
  400. c.behospital_code,
  401. c.hospital_id,
  402. c.admissionNote,
  403. c.firstCourseNote,
  404. c.medHomePage,
  405. c.docAdviceNote,
  406. c.courseRecord,
  407. c.operationInfo,
  408. c.dischargeNote,
  409. c.admissionNoteScore,
  410. c.firstCourseNoteScore,
  411. c. medHomePageScore,
  412. c.docAdviceNoteScore,
  413. c.courseRecordScore,
  414. c.operationInfoScore,
  415. c.dischargeNoteScore,
  416. c.otherCase,
  417. (100.0-c.score_res) AS otherCaseScore,
  418. IFNULL(b.level,'未评分') AS `level`,
  419. g.check_name AS ch_name,
  420. h.check_name AS mr_name
  421. FROM
  422. med_behospital_info a LEFT JOIN med_qcresult_info b
  423. ON a.behospital_code = b.behospital_code AND b.is_deleted = 'N'
  424. LEFT JOIN (
  425. SELECT
  426. t.behospital_code,
  427. t.hospital_id,
  428. t.admissionNote,
  429. t.firstCourseNote,
  430. t.medHomePage,
  431. t.docAdviceNote,
  432. t.courseRecord,
  433. t.operationInfo,
  434. t.dischargeNote,
  435. t.otherCase,
  436. t.score_res,
  437. if(t.admissionNoteScoreOn >= t.admissionNoteTolScore, (t.admissionNoteTolScore + t.admissionNoteScoreTh),(t.admissionNoteScoreOn + t.admissionNoteScoreTh)) AS admissionNoteScore,
  438. if(t.firstCourseNoteScoreOn >= t.firstCourseNoteTolScore, (t.firstCourseNoteTolScore + t.firstCourseNoteScoreTh),(t.firstCourseNoteScoreOn + t.firstCourseNoteScoreTh)) AS firstCourseNoteScore,
  439. if(t.medHomePageScoreOn >= t.medHomePageTolScore, (t.medHomePageTolScore + t.medHomePageScoreTh),(t.medHomePageScoreOn + t.medHomePageScoreTh)) AS medHomePageScore,
  440. if(t.docAdviceNoteScoreOn >= t.docAdviceNoteTolScore, (t.docAdviceNoteTolScore + t.docAdviceNoteScoreTh),(t.docAdviceNoteScoreOn + t.docAdviceNoteScoreTh)) AS docAdviceNoteScore,
  441. if(t.courseRecordScoreOn >= t.courseRecordTolScore, (t.courseRecordTolScore + t.courseRecordScoreTh),(t.courseRecordScoreOn + t.courseRecordScoreTh)) AS courseRecordScore,
  442. if(t.operationInfoScoreOn >= t.operationInfoTolScore, (t.operationInfoTolScore + t.operationInfoScoreTh),(t.operationInfoScoreOn + t.operationInfoScoreTh)) AS operationInfoScore,
  443. if(t.dischargeNoteScoreOn >= t.dischargeNoteTolScore, (t.dischargeNoteTolScore + t.dischargeNoteScoreTh),(t.dischargeNoteScoreOn + t.dischargeNoteScoreTh)) AS dischargeNoteScore
  444. from(
  445. select
  446. t1.*,
  447. t2.admissionNoteTolScore,
  448. t2.firstCourseNoteTolScore,
  449. t2.medHomePageTolScore,
  450. t2.docAdviceNoteTolScore,
  451. t2.courseRecordTolScore,
  452. t2.operationInfoTolScore,
  453. t2.dischargeNoteTolScore,
  454. t2.score_res FROM (
  455. SELECT
  456. t1.behospital_code,
  457. t1.hospital_id,
  458. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  459. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  460. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  461. (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,
  462. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  463. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  464. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  465. (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,
  466. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  467. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  468. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  469. (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,
  470. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  471. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  472. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  473. (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,
  474. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  475. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  476. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  477. (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,
  478. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  479. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  480. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  481. (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,
  482. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  483. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  484. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  485. (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,
  486. 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
  487. FROM (
  488. SELECT
  489. c.behospital_code,
  490. c.hospital_id,
  491. a.mode_id,
  492. c.cases_score,
  493. c.score,
  494. c.msg,
  495. c.is_reject,
  496. c.cases_id
  497. FROM
  498. `qc_cases_entry` a,
  499. qc_mode b,
  500. med_qcresult_detail c,
  501. qc_cases_hospital d,
  502. med_behospital_info e
  503. 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'
  504. AND a.id = c.cases_entry_id
  505. AND a.mode_id = b.id
  506. AND c.cases_id = d.cases_id
  507. AND c.hospital_id = d.hospital_id
  508. AND c.behospital_code = e.behospital_code
  509. AND c.hospital_id = e.hospital_id
  510. <if test="hospitalId != null">
  511. and c.hospital_id = #{hospitalId}
  512. </if>
  513. <if test="deptName != null and deptName != ''">
  514. and e.beh_dept_name= #{deptName}
  515. </if>
  516. <if test="behospitalCode != null and behospitalCode != ''">
  517. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  518. </if>
  519. <if test="isPlacefile != null and isPlacefile != ''">
  520. and e.is_placefile = #{isPlacefile}
  521. </if>
  522. <if test="behosDateStart != null">
  523. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  524. </if>
  525. <if test="behosDateEnd != null">
  526. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  527. </if>
  528. <if test="leaveHosDateStart != null">
  529. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  530. </if>
  531. <if test="leaveHosDateEnd != null">
  532. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  533. </if>
  534. <if test="level != null and level != ''">
  535. and e.level = #{level}
  536. </if>
  537. <if test="level != null and level != ''">
  538. and e.level = #{level}
  539. </if>
  540. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  541. )t1 GROUP BY behospital_code)t1
  542. LEFT JOIN (
  543. SELECT m1.*, m2.score_res FROM(
  544. SELECT
  545. m1.hospital_id,
  546. m1.behospital_code,
  547. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  548. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  549. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  550. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  551. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  552. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  553. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  554. FROM (
  555. SELECT
  556. c.behospital_code,
  557. a.mode_id,
  558. c.cases_score,
  559. c.cases_id,
  560. c.hospital_id
  561. FROM
  562. `qc_cases_entry` a,
  563. qc_mode b,
  564. med_qcresult_detail c,
  565. qc_cases_hospital d,
  566. med_behospital_info e
  567. 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'
  568. AND a.id = c.cases_entry_id
  569. AND a.mode_id = b.id
  570. AND c.cases_id = d.cases_id
  571. AND c.hospital_id = d.hospital_id
  572. AND c.behospital_code = e.behospital_code
  573. AND c.hospital_id = e.hospital_id
  574. <if test="hospitalId != null">
  575. and c.hospital_id = #{hospitalId}
  576. </if>
  577. <if test="deptName != null and deptName != ''">
  578. and e.beh_dept_name= #{deptName}
  579. </if>
  580. <if test="behospitalCode != null and behospitalCode != ''">
  581. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  582. </if>
  583. <if test="isPlacefile != null and isPlacefile != ''">
  584. and e.is_placefile = #{isPlacefile}
  585. </if>
  586. <if test="behosDateStart != null">
  587. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  588. </if>
  589. <if test="behosDateEnd != null">
  590. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  591. </if>
  592. <if test="leaveHosDateStart != null">
  593. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  594. </if>
  595. <if test="leaveHosDateEnd != null">
  596. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  597. </if>
  598. <if test="level != null and level != ''">
  599. and e.level = #{level}
  600. </if>
  601. <if test="level != null and level != ''">
  602. and e.level = #{level}
  603. </if>
  604. GROUP BY mode_id
  605. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  606. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  607. ON m2.is_deleted = 'N'
  608. AND m1.hospital_id = m2.hospital_id
  609. AND m1.behospital_code = m2.behospital_code
  610. )t2
  611. ON t1.hospital_id = t2.hospital_id
  612. AND t1.behospital_code = t2.behospital_code)t)c
  613. ON a.behospital_code = c.behospital_code
  614. AND a.hospital_id = c.hospital_id
  615. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  616. ON a.behospital_code = g.behospital_code
  617. AND a.hospital_id = g.hospital_id
  618. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  619. ON a.behospital_code = h.behospital_code
  620. AND a.hospital_id = h.hospital_id
  621. where
  622. a.is_deleted = 'N'
  623. <if test="deptName != null and deptName != ''">
  624. and a.beh_dept_name= #{deptName}
  625. </if>
  626. <if test="doctorName != null and doctorName != ''">
  627. and CONCAT(
  628. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  629. like CONCAT('%',#{doctorName},'%')
  630. </if>
  631. <if test="name != null and name != ''">
  632. and a.name like CONCAT('%',#{name},'%')
  633. </if>
  634. <if test="doctorCode != null and doctorCode != ''">
  635. and (a.doctor_id = #{doctorCode}
  636. or a.beh_doctor_id = #{doctorCode}
  637. or a.director_doctor_id = #{doctorCode})
  638. </if>
  639. <if test="fileCode != null and fileCode != ''">
  640. and a.file_code like CONCAT('%',#{fileCode},'%')
  641. </if>
  642. <if test="hospitalId != null">
  643. and a.hospital_id = #{hospitalId}
  644. </if>
  645. <if test="behospitalCode != null and behospitalCode != ''">
  646. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  647. </if>
  648. <if test="behosDateStart != null">
  649. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  650. </if>
  651. <if test="behosDateEnd != null">
  652. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  653. </if>
  654. <if test="leaveHosDateStart != null">
  655. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  656. </if>
  657. <if test="leaveHosDateEnd != null">
  658. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  659. </if>
  660. <if test="level != null and level != ''">
  661. and a.level = #{level}
  662. </if>
  663. <if test="isPlacefile != null and isPlacefile != ''">
  664. and a.is_placefile = #{isPlacefile}
  665. </if>
  666. and a.qc_type_id != 0
  667. <if test="chName != null and chName !=''">
  668. AND g.ch_name like CONCAT('%',#{chName},'%')
  669. </if>
  670. <if test="mrName != null and mrName !=''">
  671. AND h.mr_name like CONCAT('%',#{mrName},'%')
  672. </if>)m
  673. </select>-->
  674. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  675. SELECT a.*, u.linkman
  676. FROM
  677. (
  678. SELECT DISTINCT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info, a.cases_id cases_id, d.score cases_score,
  679. b.id model_id, a.name standard_msg, c.opt_type, c.grade_type,
  680. c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,c.explain_info as explainInfo,
  681. a.type, a.drgs
  682. FROM
  683. `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  684. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  685. and a.id = c.cases_entry_id and a.mode_id = b.id
  686. AND c.cases_id = d.cases_id and c.hospital_id = d.hospital_id
  687. and c.hospital_id = #{hospitalId}
  688. <if test="qcresultInfoId != null">
  689. AND c.qcresult_info_id = #{qcresultInfoId}
  690. </if>
  691. and c.behospital_code = #{behospitalCode}
  692. order by b.order_no, c.grade_type desc, a.order_no) a
  693. LEFT JOIN sys_user u on u.id = a.modifier and u.is_deleted = 'N'
  694. </select>
  695. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  696. SELECT b.id model_id,b.`name` model_name,
  697. d.score,d.msg,d.cases_entry_id,d.is_reject,
  698. a.cases_id cases_id, a.name standard_msg,a.code
  699. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  700. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  701. and a.mode_id = b.id
  702. and a.id = d.cases_entry_id
  703. and d.is_used = 1
  704. and d.hospital_id = #{hospitalId}
  705. and a.code in
  706. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  707. #{item}
  708. </foreach>
  709. <if test="modeId != null">
  710. and a.mode_id = #{modeId}
  711. </if>
  712. order by b.order_no, a.order_no;
  713. </select>
  714. <!--病案管理指标基础sql明细-->
  715. <select id="getBaseIndex" parameterType="com.diagbot.vo.MedIndexFilterVO" resultType="java.util.Map">
  716. select
  717. f1.firWorkNum,
  718. f2.secWorkNum,
  719. f3.thrWorkNum,
  720. f3.forWorkNum,
  721. f3.sixWorkNum,
  722. f4.sevenWorkNum
  723. from (
  724. SELECT count(DISTINCT a.behospital_code) as firWorkNum
  725. FROM
  726. med_behospital_info a
  727. WHERE
  728. a.is_deleted = 'N'
  729. AND a.is_placefile = 1
  730. <if test="hospitalId != null and hospitalId != ''">
  731. AND a.hospital_id = #{hospitalId}
  732. </if>
  733. <![CDATA[AND a.qc_type_id <>0 ]]>
  734. <if test="startDate != null and startDate != ''">
  735. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  736. </if>
  737. <if test="endDate != null and endDate != ''">
  738. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  739. </if>)f1,
  740. ( SELECT count(DISTINCT a.behospital_code) AS secWorkNum
  741. FROM
  742. med_outpatient_info a
  743. WHERE
  744. a.is_deleted = 'N'
  745. <if test="startDate != null and startDate != ''">
  746. <![CDATA[ AND a.visit_date >= #{lastStartDate}]]>
  747. </if>
  748. <if test="endDate != null and endDate != ''">
  749. <![CDATA[ AND a.visit_date <= #{lastEndDate}]]>
  750. </if>
  751. <if test="hospitalId != null and hospitalId != ''">
  752. AND a.hospital_id = #{hospitalId}
  753. </if>)f2,(
  754. select
  755. count(DISTINCT case when <![CDATA[m.behospital_date >= #{startDate}]]> and <![CDATA[m.behospital_date <= #{endDate}]]>
  756. and m.is_placefile = 0 then m.behospital_code else null end) as thrWorkNum,
  757. count(DISTINCT case when <![CDATA[m.leave_hospital_date >= #{startDate}]]> and <![CDATA[m.leave_hospital_date <= #{endDate}]]> and m.is_placefile = 1 then m.behospital_code else null end) as forWorkNum,
  758. count(DISTINCT case when <![CDATA[m.leave_hospital_date >= #{startDate}]]> and <![CDATA[m.leave_hospital_date <= #{endDate}]]> and m.is_placefile = 1 and m.level = '甲' then m.behospital_code else null end) as sixWorkNum
  759. from(
  760. SELECT DISTINCT a.*,b.level
  761. FROM
  762. med_behospital_info a,
  763. med_qcresult_info b
  764. WHERE
  765. a.is_deleted = 'N'
  766. AND b.is_deleted = 'N'
  767. AND a.hospital_id = b.hospital_id
  768. AND a.behospital_code = b.behospital_code
  769. <![CDATA[AND a.qc_type_id <>0 ]]>
  770. <if test="hospitalId != null and hospitalId != ''">
  771. AND a.hospital_id = #{hospitalId}
  772. </if>)m
  773. )f3,(
  774. SELECT count(DISTINCT a.behospital_code) as sevenWorkNum
  775. FROM
  776. med_behospital_info a
  777. WHERE
  778. a.is_deleted = 'N'
  779. AND a.is_placefile = 1
  780. <if test="hospitalId != null and hospitalId != ''">
  781. AND a.hospital_id = #{hospitalId}
  782. </if>
  783. <![CDATA[AND a.qc_type_id <>0 ]]>
  784. <if test="startDate != null and startDate != ''">
  785. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  786. </if>
  787. <if test="endDate != null and endDate != ''">
  788. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  789. </if>)f4
  790. </select>
  791. <!-- 病案管理规则质控缺陷病历总数查询-->
  792. <select id="getMedManageParams" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.MedManageParamsDTO">
  793. SELECT
  794. f1.behospitalCode,
  795. <if test="flagStr != null and flagStr == 1 ">
  796. f2.rep_name as repName,
  797. </if>
  798. <if test="flagStr != null and flagStr == 2">
  799. f3.da_item_name as daItemName,
  800. f3.da_status AS daStatus,
  801. f3.doctor_advice_type as doctorAdviceType,
  802. </if>
  803. f1.hospitalId
  804. from(
  805. SELECT DISTINCT
  806. a.hospital_id as hospitalId,
  807. a.behospital_code as behospitalCode
  808. FROM
  809. med_behospital_info a,
  810. med_qcresult_info b
  811. WHERE
  812. a.is_deleted = 'N'
  813. AND b.is_deleted = 'N'
  814. AND a.hospital_id = b.hospital_id
  815. AND a.behospital_code = b.behospital_code
  816. AND <![CDATA[a.leave_hospital_date >= #{startDate}]]>
  817. AND <![CDATA[a.leave_hospital_date <= #{endDate}]]>
  818. AND a.is_placefile = 1
  819. <![CDATA[AND a.qc_type_id <>0 ]]>
  820. <if test="hospitalId != null and hospitalId != ''">
  821. AND a.hospital_id = #{hospitalId}
  822. </if>)f1
  823. <if test="flagStr != null and flagStr == 1 ">
  824. join med_lis_info f2
  825. on f2.is_deleted = 'N'
  826. AND f1.hospitalId = f2.hospital_id
  827. AND f1.behospitalCode = f2.behospital_code
  828. </if>
  829. <if test="flagStr != null and flagStr == 2">
  830. join med_doctor_advice f3
  831. on f3.is_deleted = 'N'
  832. AND f1.hospitalId = f3.hospital_id
  833. AND f1.behospitalCode = f3.behospital_code
  834. </if>
  835. </select>
  836. <!-- 各科室缺陷占比-全院-首页 -->
  837. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  838. resultType="com.diagbot.dto.NumDTO">
  839. SELECT
  840. a.beh_dept_id as id,
  841. a.beh_dept_name as name,
  842. count(*) AS num
  843. FROM
  844. med_behospital_info a,
  845. med_qcresult_info c,
  846. med_qcresult_detail d
  847. WHERE
  848. a.behospital_code = c.behospital_code
  849. AND a.hospital_id = c.hospital_id
  850. AND a.behospital_code = d.behospital_code
  851. AND a.hospital_id = d.hospital_id
  852. AND a.is_deleted = 'N'
  853. AND c.is_deleted = 'N'
  854. AND d.is_deleted = 'N'
  855. <if test="isPlacefile != null and isPlacefile != ''">
  856. and a.is_placefile = #{isPlacefile}
  857. </if>
  858. <![CDATA[AND a.qc_type_id <>0 ]]>
  859. <if test="hospitalId != null and hospitalId != ''">
  860. AND a.hospital_id = #{hospitalId}
  861. </if>
  862. <if test="isPlacefile != null and isPlacefile == 0">
  863. <if test="startDate != null and startDate != ''">
  864. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  865. </if>
  866. <if test="endDate != null and endDate != ''">
  867. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  868. </if>
  869. </if>
  870. <if test="isPlacefile != null and isPlacefile == 1">
  871. <if test="startDate != null and startDate != ''">
  872. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  873. </if>
  874. <if test="endDate != null and endDate != ''">
  875. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  876. </if>
  877. </if>
  878. GROUP BY
  879. a.beh_dept_id,
  880. a.beh_dept_name
  881. ORDER BY
  882. count(*) DESC
  883. </select>
  884. <!-- 质控结果缺陷总数查询-->
  885. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  886. SELECT
  887. count(*) AS totle
  888. FROM
  889. med_behospital_info a,
  890. med_qcresult_info c,
  891. med_qcresult_detail d
  892. WHERE
  893. a.behospital_code = c.behospital_code
  894. AND a.hospital_id = c.hospital_id
  895. AND a.behospital_code = d.behospital_code
  896. AND a.hospital_id = d.hospital_id
  897. AND a.is_deleted = 'N'
  898. AND c.is_deleted = 'N'
  899. AND d.is_deleted = 'N'
  900. <if test="isPlacefile != null and isPlacefile != ''">
  901. and a.is_placefile = #{isPlacefile}
  902. </if>
  903. <![CDATA[AND a.qc_type_id <>0 ]]>
  904. <if test="hospitalId != null and hospitalId != ''">
  905. AND a.hospital_id = #{hospitalId}
  906. </if>
  907. <if test="isPlacefile != null and isPlacefile == 0">
  908. <if test="startDate != null and startDate != ''">
  909. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  910. </if>
  911. <if test="endDate != null and endDate != ''">
  912. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  913. </if>
  914. </if>
  915. <if test="isPlacefile != null and isPlacefile == 1">
  916. <if test="startDate != null and startDate != ''">
  917. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  918. </if>
  919. <if test="endDate != null and endDate != ''">
  920. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  921. </if>
  922. </if>
  923. </select>
  924. <!--获取病历-->
  925. <select id="getNoGrade" resultMap="BaseResultMap">
  926. select * from med_behospital_info a
  927. where a.is_deleted = 'N'
  928. and a.qc_type_id != 0
  929. <if test="isPlacefile != null and isPlacefile != ''">
  930. and a.is_placefile = #{isPlacefile}
  931. </if>
  932. <if test="filterFlag != null and filterFlag == 0">
  933. and
  934. not EXISTS (
  935. SELECT
  936. 1
  937. FROM
  938. med_qcresult_info b
  939. WHERE
  940. b.is_deleted = 'N'
  941. AND a.hospital_id = b.hospital_id
  942. AND a.behospital_code = b.behospital_code
  943. )
  944. </if>
  945. <if test="leaveDate != null">
  946. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  947. </if>
  948. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  949. and a.hospital_id in
  950. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  951. #{item}
  952. </foreach>
  953. </if>
  954. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  955. and a.behospital_code in
  956. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  957. #{item}
  958. </foreach>
  959. </if>
  960. <if test="individuation != null and individuation.contains(1)">
  961. union
  962. select * from med_behospital_info b
  963. where b.is_deleted = 'N'
  964. and b.qc_type_id != 0
  965. <if test="isPlacefile != null and isPlacefile != ''">
  966. and b.is_placefile = #{isPlacefile}
  967. </if>
  968. <if test="startLeaveDate != null">
  969. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  970. </if>
  971. <if test="endLeaveDate != null">
  972. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  973. </if>
  974. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  975. and b.hospital_id in
  976. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  977. #{item}
  978. </foreach>
  979. </if>
  980. </if>
  981. </select>
  982. <!--质控评分(科室)分页-->
  983. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDeptDTO">
  984. SELECT * from (
  985. SELECT
  986. t.*,
  987. t3.name as medoup_name,
  988. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  989. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  990. g.check_type as ch_type,
  991. h.check_type AS mr_type,
  992. g.check_name as ch_name,
  993. h.check_name as mr_name,
  994. g.check_time as ch_time,
  995. h.check_time AS mr_time
  996. FROM
  997. ( SELECT
  998. a.*,
  999. IFNULL(b.level, '未评分') AS `level`,
  1000. b.grade_type,
  1001. b.score_res,
  1002. e.score_res as score_bn,
  1003. b.gmt_create AS grade_time,
  1004. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1005. FROM
  1006. med_behospital_info a
  1007. JOIN sys_user_dept d
  1008. ON a.hospital_id = d.hospital_id
  1009. AND a.beh_dept_id = d.dept_id
  1010. LEFT JOIN med_qcresult_info b
  1011. ON a.behospital_code = b.behospital_code
  1012. AND b.is_deleted = 'N'
  1013. LEFT JOIN med_qcresult_cases e
  1014. on a.behospital_code = e.behospital_code
  1015. AND e.is_deleted = 'N'
  1016. and e.cases_id = 243
  1017. LEFT JOIN med_home_page c
  1018. ON a.behospital_code = c.behospital_code
  1019. AND c.is_deleted = 'N'
  1020. WHERE d.is_deleted = 'N'
  1021. AND d.user_id = #{userId}
  1022. ) t
  1023. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1024. ON t.behospital_code = g.behospital_code
  1025. AND t.hospital_id = g.hospital_id
  1026. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1027. ON t.behospital_code = h.behospital_code
  1028. AND t.hospital_id = h.hospital_id
  1029. LEFT JOIN bas_doctor_info t2 ON t.doctor_id = t2.doctor_id
  1030. AND t.hospital_id = t2.hospital_id
  1031. AND t2.is_deleted = 'N'
  1032. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  1033. AND t3.is_deleted = 'N'
  1034. where t.is_deleted = 'N'
  1035. <if test="medoupName != null and medoupName != ''">
  1036. AND t3.name = #{medoupName}
  1037. </if>
  1038. <if test="wardName != null and wardName != ''">
  1039. AND t.ward_name = #{wardName}
  1040. </if>
  1041. <if test="diagnose != null and diagnose != ''">
  1042. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1043. </if>
  1044. <if test="deptName != null and deptName != ''">
  1045. and t.beh_dept_name = #{deptName}
  1046. </if>
  1047. <if test="deptId != null and deptId != ''">
  1048. and t.beh_dept_Id = #{deptId}
  1049. </if>
  1050. <if test="doctorName != null and doctorName != ''">
  1051. and CONCAT(
  1052. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  1053. like CONCAT('%',#{doctorName},'%')
  1054. </if>
  1055. <if test="doctorCode != null and doctorCode != ''">
  1056. and t.doctor_id = #{doctorCode}
  1057. </if>
  1058. <if test="doctorId != null and doctorId != ''">
  1059. and t.doctor_id = #{doctorId}
  1060. </if>
  1061. <if test="name != null and name != ''">
  1062. and t.name like CONCAT('%',#{name},'%')
  1063. </if>
  1064. <if test="fileCode != null and fileCode != ''">
  1065. and t.file_code like CONCAT('%',#{fileCode},'%')
  1066. </if>
  1067. <if test="hospitalId != null">
  1068. and t.hospital_id = #{hospitalId}
  1069. </if>
  1070. <if test="behospitalCode != null and behospitalCode != ''">
  1071. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1072. </if>
  1073. <if test="behosDateStart != null">
  1074. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1075. </if>
  1076. <if test="behosDateEnd != null">
  1077. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1078. </if>
  1079. <if test="leaveHosDateStart != null">
  1080. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1081. </if>
  1082. <if test="leaveHosDateEnd != null">
  1083. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1084. </if>
  1085. <if test="level != null and level != ''">
  1086. and t.level = #{level}
  1087. </if>
  1088. <if test="isPlacefile != null and isPlacefile != ''">
  1089. and t.is_placefile = #{isPlacefile}
  1090. </if>
  1091. and t.qc_type_id != 0) p
  1092. where p.is_deleted="N"
  1093. <if test="checkStatus != null ">
  1094. and p.check_status = #{checkStatus}
  1095. </if>
  1096. <if test="mrStatus != null ">
  1097. AND p.mr_status = #{mrStatus}
  1098. </if>
  1099. <if test="chName != null and chName !=''">
  1100. AND p.ch_name like CONCAT('%',#{chName},'%')
  1101. </if>
  1102. <if test="mrName != null and mrName !=''">
  1103. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1104. </if>
  1105. <if test="chTimeStart != null">
  1106. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1107. </if>
  1108. <if test="chTimeEnd != null">
  1109. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1110. </if>
  1111. <if test="mrTimeStart != null">
  1112. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1113. </if>
  1114. <if test="mrTimeEnd != null">
  1115. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1116. </if>
  1117. </select>
  1118. <!--质控评分(个人)分页-->
  1119. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1120. Select * from (
  1121. select t.*,
  1122. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1123. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1124. g.check_type as ch_type,
  1125. h.check_type AS mr_type,
  1126. g.check_name as ch_name,
  1127. h.check_name as mr_name,
  1128. g.check_time as ch_time,
  1129. h.check_time AS mr_time
  1130. from (SELECT
  1131. a.*,
  1132. IFNULL(b.level, '未评分') AS `level`,
  1133. b.grade_type,
  1134. b.score_res,
  1135. e.score_res as score_bn,
  1136. b.gmt_create AS grade_time,
  1137. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1138. FROM
  1139. med_behospital_info a
  1140. JOIN
  1141. (SELECT
  1142. u.id,
  1143. u.linkman AS linkman,
  1144. uh.hospital_id
  1145. FROM
  1146. sys_user u
  1147. JOIN sys_user_hospital uh
  1148. ON u.id = uh.user_id
  1149. WHERE u.is_deleted = "N"
  1150. AND u.id = #{userId}
  1151. AND uh.hospital_id = #{hospitalId}) u1
  1152. ON a.hospital_id = u1.hospital_id
  1153. LEFT JOIN med_qcresult_info b
  1154. ON a.behospital_code = b.behospital_code
  1155. AND b.is_deleted = 'N'
  1156. LEFT JOIN med_qcresult_cases e
  1157. on a.behospital_code = e.behospital_code
  1158. AND e.is_deleted = 'N'
  1159. and e.cases_id = 243
  1160. LEFT JOIN med_home_page c
  1161. ON a.behospital_code = c.behospital_code
  1162. AND c.is_deleted = 'N'
  1163. WHERE
  1164. a.is_deleted = 'N'
  1165. and a.doctor_name = u1.linkman
  1166. or a.beh_doctor_name = u1.linkman
  1167. or a.director_doctor_name = u1.linkman
  1168. ) t
  1169. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1170. ON t.behospital_code = g.behospital_code
  1171. AND t.hospital_id = g.hospital_id
  1172. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1173. ON t.behospital_code = h.behospital_code
  1174. AND t.hospital_id = h.hospital_id
  1175. WHERE t.is_deleted = 'N'
  1176. <if test="diagnose != null and diagnose != ''">
  1177. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1178. </if>
  1179. <if test="deptName != null and deptName != ''">
  1180. and t.beh_dept_name = #{deptName}
  1181. </if>
  1182. <if test="name != null and name != ''">
  1183. and t.name like CONCAT('%',#{name},'%')
  1184. </if>
  1185. <if test="fileCode != null and fileCode != ''">
  1186. and t.file_code like CONCAT('%',#{fileCode},'%')
  1187. </if>
  1188. <if test="behospitalCode != null and behospitalCode != ''">
  1189. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1190. </if>
  1191. <if test="behosDateStart != null">
  1192. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1193. </if>
  1194. <if test="behosDateEnd != null">
  1195. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1196. </if>
  1197. <if test="leaveHosDateStart != null">
  1198. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1199. </if>
  1200. <if test="leaveHosDateEnd != null">
  1201. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1202. </if>
  1203. <if test="level != null and level != ''">
  1204. and t.level = #{level}
  1205. </if>
  1206. <if test="isPlacefile != null and isPlacefile != ''">
  1207. and t.is_placefile = #{isPlacefile}
  1208. </if>
  1209. and t.qc_type_id != 0) p
  1210. where p.is_deleted="N"
  1211. <if test="checkStatus != null ">
  1212. and p.check_status = #{checkStatus}
  1213. </if>
  1214. <if test="mrStatus != null ">
  1215. AND p.mr_status = #{mrStatus}
  1216. </if>
  1217. <if test="chName != null and chName !=''">
  1218. AND p.ch_name like CONCAT('%',#{chName},'%')
  1219. </if>
  1220. <if test="mrName != null and mrName !=''">
  1221. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1222. </if>
  1223. <if test="chTimeStart != null">
  1224. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1225. </if>
  1226. <if test="chTimeEnd != null">
  1227. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1228. </if>
  1229. <if test="mrTimeStart != null">
  1230. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1231. </if>
  1232. <if test="mrTimeEnd != null">
  1233. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1234. </if>
  1235. </select>
  1236. <!--质控评分(医疗组)分页-->
  1237. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1238. select * from (
  1239. select t.*,
  1240. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1241. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1242. g.check_type as ch_type,
  1243. h.check_type AS mr_type,
  1244. g.check_name as ch_name,
  1245. h.check_name as mr_name,
  1246. g.check_time as ch_time,
  1247. h.check_time AS mr_time
  1248. from (
  1249. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  1250. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  1251. LEFT JOIN med_qcresult_info b
  1252. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  1253. LEFT JOIN med_qcresult_cases e
  1254. on a.behospital_code = e.behospital_code
  1255. AND e.is_deleted = 'N'
  1256. and e.cases_id = 243
  1257. left join med_home_page c
  1258. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  1259. ) t
  1260. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1261. ON t.behospital_code = g.behospital_code
  1262. AND t.hospital_id = g.hospital_id
  1263. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1264. ON t.behospital_code = h.behospital_code
  1265. AND t.hospital_id = h.hospital_id
  1266. WHERE t.is_deleted = 'N'
  1267. and
  1268. t.doctor_id in (
  1269. SELECT doctor_id FROM `bas_doctor_info`
  1270. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  1271. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  1272. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  1273. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  1274. and c1.username = c3.doctor_id
  1275. and c2.hospital_id = #{hospitalId}
  1276. and c1.id = #{userId}
  1277. )
  1278. )
  1279. <if test="diagnose != null and diagnose != ''">
  1280. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1281. </if>
  1282. <if test="doctorName != null and doctorName != ''">
  1283. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  1284. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  1285. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  1286. </if>
  1287. <if test="name != null and name != ''">
  1288. and t.name like CONCAT('%',#{name},'%')
  1289. </if>
  1290. <if test="doctorCode != null and doctorCode != ''">
  1291. and (t.doctor_id = #{doctorCode}
  1292. or t.beh_doctor_id = #{doctorCode}
  1293. or t.director_doctor_id = #{doctorCode})
  1294. </if>
  1295. <if test="fileCode != null and fileCode != ''">
  1296. and t.file_code like CONCAT('%',#{fileCode},'%')
  1297. </if>
  1298. <if test="hospitalId != null">
  1299. and t.hospital_id = #{hospitalId}
  1300. </if>
  1301. <if test="behospitalCode != null and behospitalCode != ''">
  1302. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1303. </if>
  1304. <if test="behosDateStart != null">
  1305. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1306. </if>
  1307. <if test="behosDateEnd != null">
  1308. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1309. </if>
  1310. <if test="leaveHosDateStart != null">
  1311. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1312. </if>
  1313. <if test="leaveHosDateEnd != null">
  1314. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1315. </if>
  1316. <if test="level != null and level != ''">
  1317. and t.level = #{level}
  1318. </if>
  1319. <if test="isPlacefile != null and isPlacefile != ''">
  1320. and t.is_placefile = #{isPlacefile}
  1321. </if>
  1322. and t.qc_type_id != 0) p
  1323. where p.is_deleted="N"
  1324. <if test="checkStatus != null ">
  1325. and p.check_status = #{checkStatus}
  1326. </if>
  1327. <if test="mrStatus != null ">
  1328. AND p.mr_status = #{mrStatus}
  1329. </if>
  1330. <if test="chName != null and chName !=''">
  1331. AND p.ch_name like CONCAT('%',#{chName},'%')
  1332. </if>
  1333. <if test="mrName != null and mrName !=''">
  1334. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1335. </if>
  1336. <if test="chTimeStart != null">
  1337. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1338. </if>
  1339. <if test="chTimeEnd != null">
  1340. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1341. </if>
  1342. <if test="mrTimeStart != null">
  1343. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1344. </if>
  1345. <if test="mrTimeEnd != null">
  1346. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1347. </if>
  1348. </select>
  1349. <!-- 出院总人数统计-全院-首页 -->
  1350. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1351. SELECT
  1352. COUNT(*)
  1353. FROM
  1354. med_behospital_info a
  1355. WHERE
  1356. a.is_deleted = 'N'
  1357. <if test="isPlacefile != null and isPlacefile != ''">
  1358. and a.is_placefile = #{isPlacefile}
  1359. </if>
  1360. <if test="hospitalId != null and hospitalId != ''">
  1361. AND a.hospital_id = #{hospitalId}
  1362. </if>
  1363. <if test="isPlacefile != null and isPlacefile == 0">
  1364. <if test="startDate != null and startDate != ''">
  1365. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1366. </if>
  1367. <if test="endDate != null and endDate != ''">
  1368. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1369. </if>
  1370. </if>
  1371. <if test="isPlacefile != null and isPlacefile == 1">
  1372. <if test="startDate != null and startDate != ''">
  1373. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1374. </if>
  1375. <if test="endDate != null and endDate != ''">
  1376. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1377. </if>
  1378. </if>
  1379. </select>
  1380. <!-- 新生儿出院人数统计-全院-首页 -->
  1381. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1382. SELECT
  1383. COUNT(*)
  1384. FROM
  1385. med_behospital_info a,
  1386. med_home_page b
  1387. WHERE
  1388. a.is_deleted = 'N'
  1389. AND b.is_deleted = 'N'
  1390. AND a.hospital_id = b.hospital_id
  1391. AND a.behospital_code = b.behospital_code
  1392. <if test="isPlacefile != null and isPlacefile != ''">
  1393. and a.is_placefile = #{isPlacefile}
  1394. </if>
  1395. AND (
  1396. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  1397. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1398. )
  1399. <![CDATA[AND a.qc_type_id <>0 ]]>
  1400. <if test="hospitalId != null and hospitalId != ''">
  1401. AND a.hospital_id = #{hospitalId}
  1402. </if>
  1403. <if test="isPlacefile != null and isPlacefile == 0">
  1404. <if test="startDate != null and startDate != ''">
  1405. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1406. </if>
  1407. <if test="endDate != null and endDate != ''">
  1408. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1409. </if>
  1410. </if>
  1411. <if test="isPlacefile != null and isPlacefile == 1">
  1412. <if test="startDate != null and startDate != ''">
  1413. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1414. </if>
  1415. <if test="endDate != null and endDate != ''">
  1416. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1417. </if>
  1418. </if>
  1419. </select>
  1420. <!-- 死亡人数统计-全院-首页 -->
  1421. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1422. select COUNT(*) from(
  1423. SELECT distinct a.*
  1424. FROM
  1425. med_behospital_info a,
  1426. med_medical_record b,
  1427. med_medical_record_content c
  1428. WHERE
  1429. a.is_deleted = 'N'
  1430. AND b.is_deleted = 'N'
  1431. AND c.is_deleted = 'N'
  1432. AND a.hospital_id = b.hospital_id
  1433. AND a.hospital_id = c.hospital_id
  1434. AND a.behospital_code = b.behospital_code
  1435. AND b.rec_id = c.rec_id
  1436. and b.mode_id = '24'
  1437. <if test="isPlacefile != null and isPlacefile != ''">
  1438. and a.is_placefile = #{isPlacefile}
  1439. </if>
  1440. <![CDATA[AND a.qc_type_id <>0 ]]>
  1441. <if test="hospitalId != null and hospitalId != ''">
  1442. AND a.hospital_id = #{hospitalId}
  1443. </if>
  1444. <if test="isPlacefile != null and isPlacefile == 0">
  1445. <if test="startDate != null and startDate != ''">
  1446. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1447. </if>
  1448. <if test="endDate != null and endDate != ''">
  1449. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1450. </if>
  1451. </if>
  1452. <if test="isPlacefile != null and isPlacefile == 1">
  1453. <if test="startDate != null and startDate != ''">
  1454. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1455. </if>
  1456. <if test="endDate != null and endDate != ''">
  1457. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1458. </if>
  1459. </if>)m
  1460. </select>
  1461. <!-- 手术人数统计-全院-首页 -->
  1462. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1463. SELECT
  1464. COUNT( DISTINCT a.behospital_code )
  1465. FROM
  1466. med_behospital_info a,
  1467. med_medical_record c,
  1468. qc_mode d
  1469. WHERE
  1470. a.is_deleted = 'N'
  1471. AND c.is_deleted = 'N'
  1472. AND d.is_deleted = 'N'
  1473. AND a.hospital_id = c.hospital_id
  1474. AND a.behospital_code = c.behospital_code
  1475. AND c.mode_id = d.id
  1476. <if test="isPlacefile != null and isPlacefile != ''">
  1477. and a.is_placefile = #{isPlacefile}
  1478. </if>
  1479. AND d.`name` = '手术记录'
  1480. <![CDATA[AND a.qc_type_id <>0 ]]>
  1481. <if test="hospitalId != null and hospitalId != ''">
  1482. AND a.hospital_id = #{hospitalId}
  1483. </if>
  1484. <if test="isPlacefile != null and isPlacefile == 0">
  1485. <if test="startDate != null and startDate != ''">
  1486. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1487. </if>
  1488. <if test="endDate != null and endDate != ''">
  1489. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1490. </if>
  1491. </if>
  1492. <if test="isPlacefile != null and isPlacefile == 1">
  1493. <if test="startDate != null and startDate != ''">
  1494. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1495. </if>
  1496. <if test="endDate != null and endDate != ''">
  1497. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1498. </if>
  1499. </if>
  1500. </select>
  1501. <!-- 入院人数统计-首页 -->
  1502. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  1503. resultType="com.diagbot.dto.NumDTO">
  1504. SELECT
  1505. a.beh_dept_id AS id,
  1506. a.beh_dept_name AS NAME,
  1507. COUNT(*) AS num
  1508. FROM
  1509. med_behospital_info a
  1510. WHERE
  1511. a.is_deleted = 'N'
  1512. <if test="isPlacefile != null and isPlacefile != ''">
  1513. and a.is_placefile = #{isPlacefile}
  1514. </if>
  1515. <if test="hospitalId != null and hospitalId != ''">
  1516. AND a.hospital_id = #{hospitalId}
  1517. </if>
  1518. <if test="isPlacefile != null and isPlacefile == 0">
  1519. <if test="startDate != null and startDate != ''">
  1520. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1521. </if>
  1522. <if test="endDate != null and endDate != ''">
  1523. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1524. </if>
  1525. </if>
  1526. <if test="isPlacefile != null and isPlacefile == 1">
  1527. <if test="startDate != null and startDate != ''">
  1528. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1529. </if>
  1530. <if test="endDate != null and endDate != ''">
  1531. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1532. </if>
  1533. </if>
  1534. GROUP BY
  1535. a.beh_dept_id,
  1536. a.beh_dept_name
  1537. </select>
  1538. <!-- 出院总人数统计-科室-首页 -->
  1539. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1540. resultType="com.diagbot.dto.NumDTO">
  1541. SELECT
  1542. a.beh_dept_id AS id,
  1543. a.beh_dept_name AS NAME,
  1544. COUNT(*) AS num
  1545. FROM
  1546. med_behospital_info a,
  1547. sys_user_dept c
  1548. WHERE
  1549. a.is_deleted = 'N'
  1550. AND c.is_deleted = 'N'
  1551. AND a.hospital_id = c.hospital_id
  1552. AND a.beh_dept_id = c.dept_id
  1553. <if test="isPlacefile != null and isPlacefile != ''">
  1554. and a.is_placefile = #{isPlacefile}
  1555. </if>
  1556. <if test="userId!=null">
  1557. AND c.user_id = #{userId}
  1558. </if>
  1559. <if test="hospitalId != null and hospitalId != ''">
  1560. AND a.hospital_id = #{hospitalId}
  1561. </if>
  1562. <if test="isPlacefile != null and isPlacefile == 0">
  1563. <if test="startDate != null and startDate != ''">
  1564. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1565. </if>
  1566. <if test="endDate != null and endDate != ''">
  1567. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1568. </if>
  1569. </if>
  1570. <if test="isPlacefile != null and isPlacefile == 1">
  1571. <if test="startDate != null and startDate != ''">
  1572. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1573. </if>
  1574. <if test="endDate != null and endDate != ''">
  1575. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1576. </if>
  1577. </if>
  1578. GROUP BY
  1579. a.beh_dept_id,
  1580. a.beh_dept_name
  1581. </select>
  1582. <!-- 入院总人数统计-科室-首页 -->
  1583. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1584. resultType="com.diagbot.dto.AdmissionCountDTO">
  1585. SELECT
  1586. a.beh_dept_id as deptId,
  1587. a.beh_dept_name as deptName,
  1588. a.doctor_id as doctorId,
  1589. a.doctor_name as doctorName,
  1590. COUNT(*) AS num
  1591. FROM
  1592. med_behospital_info a,
  1593. sys_user_dept c
  1594. WHERE
  1595. a.is_deleted = 'N'
  1596. AND c.is_deleted = 'N'
  1597. AND a.hospital_id = c.hospital_id
  1598. AND a.beh_dept_id = c.dept_id
  1599. <if test="isPlacefile != null and isPlacefile != ''">
  1600. and a.is_placefile = #{isPlacefile}
  1601. </if>
  1602. <if test="userId!=null">
  1603. AND c.user_id = #{userId}
  1604. </if>
  1605. <if test="hospitalId != null and hospitalId != ''">
  1606. AND a.hospital_id = #{hospitalId}
  1607. </if>
  1608. <if test="isPlacefile != null and isPlacefile == 0">
  1609. <if test="startDate != null and startDate != ''">
  1610. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1611. </if>
  1612. <if test="endDate != null and endDate != ''">
  1613. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1614. </if>
  1615. </if>
  1616. <if test="isPlacefile != null and isPlacefile == 1">
  1617. <if test="startDate != null and startDate != ''">
  1618. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1619. </if>
  1620. <if test="endDate != null and endDate != ''">
  1621. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1622. </if>
  1623. </if>
  1624. GROUP BY
  1625. a.beh_dept_id,
  1626. a.beh_dept_name,
  1627. a.doctor_id,
  1628. a.doctor_name
  1629. </select>
  1630. <!-- 新生儿出院人数统计-科室-首页 -->
  1631. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1632. resultType="com.diagbot.dto.NumDTO">
  1633. SELECT
  1634. a.beh_dept_id AS id,
  1635. a.beh_dept_name AS NAME,
  1636. COUNT(*) AS num
  1637. FROM
  1638. med_behospital_info a,
  1639. med_home_page b,
  1640. sys_user_dept c
  1641. WHERE
  1642. a.is_deleted = 'N'
  1643. AND b.is_deleted = 'N'
  1644. AND c.is_deleted = 'N'
  1645. AND a.hospital_id = b.hospital_id
  1646. AND a.hospital_id = c.hospital_id
  1647. AND a.behospital_code = b.behospital_code
  1648. AND a.beh_dept_id = c.dept_id
  1649. AND (
  1650. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  1651. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1652. )
  1653. <if test="isPlacefile != null and isPlacefile != ''">
  1654. and a.is_placefile = #{isPlacefile}
  1655. </if>
  1656. <![CDATA[AND a.qc_type_id <>0 ]]>
  1657. <if test="userId!=null">
  1658. AND c.user_id = #{userId}
  1659. </if>
  1660. <if test="hospitalId != null and hospitalId != ''">
  1661. AND a.hospital_id = #{hospitalId}
  1662. </if>
  1663. <if test="isPlacefile != null and isPlacefile == 0">
  1664. <if test="startDate != null and startDate != ''">
  1665. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1666. </if>
  1667. <if test="endDate != null and endDate != ''">
  1668. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1669. </if>
  1670. </if>
  1671. <if test="isPlacefile != null and isPlacefile == 1">
  1672. <if test="startDate != null and startDate != ''">
  1673. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1674. </if>
  1675. <if test="endDate != null and endDate != ''">
  1676. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1677. </if>
  1678. </if>
  1679. GROUP BY
  1680. a.beh_dept_id,
  1681. a.beh_dept_name
  1682. </select>
  1683. <!-- 死亡人数统计-科室-首页 -->
  1684. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1685. resultType="com.diagbot.dto.NumDTO">
  1686. SELECT
  1687. a.beh_dept_id AS id,
  1688. a.beh_dept_name AS NAME,
  1689. COUNT(*) AS num
  1690. FROM
  1691. med_behospital_info a,
  1692. sys_user_dept c,
  1693. med_medical_record d,
  1694. med_medical_record_content e
  1695. WHERE
  1696. a.is_deleted = 'N'
  1697. AND c.is_deleted = 'N'
  1698. AND d.is_deleted = 'N'
  1699. AND e.is_deleted = 'N'
  1700. AND a.hospital_id = c.hospital_id
  1701. AND a.hospital_id = d.hospital_id
  1702. AND a.hospital_id = e.hospital_id
  1703. AND a.behospital_code = d.behospital_code
  1704. AND a.beh_dept_id = c.dept_id
  1705. AND d.rec_id = e.rec_id
  1706. AND d.mode_id = '24'
  1707. <if test="isPlacefile != null and isPlacefile != ''">
  1708. and a.is_placefile = #{isPlacefile}
  1709. </if>
  1710. <![CDATA[AND a.qc_type_id <>0 ]]>
  1711. <if test="userId!=null">
  1712. AND c.user_id = #{userId}
  1713. </if>
  1714. <if test="hospitalId != null and hospitalId != ''">
  1715. AND a.hospital_id = #{hospitalId}
  1716. </if>
  1717. <if test="isPlacefile != null and isPlacefile == 0">
  1718. <if test="startDate != null and startDate != ''">
  1719. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1720. </if>
  1721. <if test="endDate != null and endDate != ''">
  1722. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1723. </if>
  1724. </if>
  1725. <if test="isPlacefile != null and isPlacefile == 1">
  1726. <if test="startDate != null and startDate != ''">
  1727. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1728. </if>
  1729. <if test="endDate != null and endDate != ''">
  1730. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1731. </if>
  1732. </if>
  1733. GROUP BY
  1734. a.beh_dept_id,
  1735. a.beh_dept_name
  1736. </select>
  1737. <!-- 手术人数统计-科室-首页 -->
  1738. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1739. resultType="com.diagbot.dto.NumDTO">
  1740. SELECT
  1741. a.beh_dept_id AS id,
  1742. a.beh_dept_name AS NAME,
  1743. COUNT( DISTINCT a.behospital_code ) AS num
  1744. FROM
  1745. med_behospital_info a,
  1746. sys_user_dept c,
  1747. med_medical_record d,
  1748. qc_mode e
  1749. WHERE
  1750. a.is_deleted = 'N'
  1751. AND c.is_deleted = 'N'
  1752. AND d.is_deleted = 'N'
  1753. AND e.is_deleted = 'N'
  1754. AND a.hospital_id = c.hospital_id
  1755. AND a.hospital_id = d.hospital_id
  1756. AND a.behospital_code = d.behospital_code
  1757. AND a.beh_dept_id = c.dept_id
  1758. AND d.mode_id = e.id
  1759. AND e.`name` = '手术记录'
  1760. <if test="isPlacefile != null and isPlacefile != ''">
  1761. and a.is_placefile = #{isPlacefile}
  1762. </if>
  1763. <![CDATA[AND a.qc_type_id <>0 ]]>
  1764. <if test="userId!=null">
  1765. AND c.user_id = #{userId}
  1766. </if>
  1767. <if test="hospitalId != null and hospitalId != ''">
  1768. AND a.hospital_id = #{hospitalId}
  1769. </if>
  1770. <if test="isPlacefile != null and isPlacefile == 0">
  1771. <if test="startDate != null and startDate != ''">
  1772. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1773. </if>
  1774. <if test="endDate != null and endDate != ''">
  1775. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1776. </if>
  1777. </if>
  1778. <if test="isPlacefile != null and isPlacefile == 1">
  1779. <if test="startDate != null and startDate != ''">
  1780. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1781. </if>
  1782. <if test="endDate != null and endDate != ''">
  1783. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1784. </if>
  1785. </if>
  1786. GROUP BY
  1787. a.beh_dept_id,
  1788. a.beh_dept_name
  1789. </select>
  1790. <!-- 各科室缺陷占比排行(分页) -->
  1791. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1792. SELECT t.*
  1793. FROM
  1794. (SELECT
  1795. t1.beh_dept_name AS NAME,
  1796. t1.num AS num,
  1797. t2.totle AS totleNum,
  1798. round( t1.num / t2.totle, 4 ) AS percent,
  1799. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1800. FROM
  1801. (
  1802. SELECT
  1803. a.beh_dept_id,
  1804. a.beh_dept_name,
  1805. count(*) AS num
  1806. FROM
  1807. med_behospital_info a,
  1808. med_qcresult_info c,
  1809. med_qcresult_detail d
  1810. WHERE
  1811. a.behospital_code = c.behospital_code
  1812. AND a.hospital_id = c.hospital_id
  1813. AND a.behospital_code = d.behospital_code
  1814. AND a.hospital_id = d.hospital_id
  1815. AND a.is_deleted = 'N'
  1816. AND c.is_deleted = 'N'
  1817. AND d.is_deleted = 'N'
  1818. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1819. and a.is_placefile = #{filterPageVO.isPlacefile}
  1820. </if>
  1821. <![CDATA[AND a.qc_type_id <>0 ]]>
  1822. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1823. AND a.hospital_id = #{filterPageVO.hospitalId}
  1824. </if>
  1825. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1826. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1827. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1828. </if>
  1829. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1830. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1831. </if>
  1832. </if>
  1833. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1834. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1835. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1836. </if>
  1837. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1838. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1839. </if>
  1840. </if>
  1841. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1842. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1843. </if>
  1844. GROUP BY
  1845. a.beh_dept_id,
  1846. a.beh_dept_name
  1847. ORDER BY
  1848. count(*) DESC
  1849. ) t1,
  1850. (
  1851. SELECT
  1852. count(*) AS totle
  1853. FROM
  1854. med_behospital_info a,
  1855. med_qcresult_info c,
  1856. med_qcresult_detail d
  1857. WHERE
  1858. a.behospital_code = c.behospital_code
  1859. AND a.hospital_id = c.hospital_id
  1860. AND a.behospital_code = d.behospital_code
  1861. AND a.hospital_id = d.hospital_id
  1862. AND a.is_deleted = 'N'
  1863. AND c.is_deleted = 'N'
  1864. AND d.is_deleted = 'N'
  1865. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1866. and a.is_placefile = #{filterPageVO.isPlacefile}
  1867. </if>
  1868. <![CDATA[AND a.qc_type_id <>0 ]]>
  1869. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1870. AND a.hospital_id = #{filterPageVO.hospitalId}
  1871. </if>
  1872. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1873. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1874. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1875. </if>
  1876. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1877. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1878. </if>
  1879. </if>
  1880. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1881. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1882. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1883. </if>
  1884. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1885. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1886. </if>
  1887. </if>
  1888. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1889. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1890. </if>
  1891. ) t2
  1892. )t
  1893. </select>
  1894. <!-- 科室缺陷占比(主任医生) -->
  1895. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  1896. SELECT
  1897. t.*
  1898. FROM
  1899. (
  1900. SELECT
  1901. t1.NAME,
  1902. t1.num AS num,
  1903. t2.totle AS totleNum,
  1904. round( t1.num / t2.totle, 4 ) AS percent,
  1905. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1906. FROM
  1907. (
  1908. SELECT
  1909. d.msg as name,
  1910. count(*) AS num
  1911. FROM
  1912. med_behospital_info a,
  1913. med_qcresult_info c,
  1914. med_qcresult_detail d,
  1915. sys_user_dept e
  1916. WHERE
  1917. a.behospital_code = c.behospital_code
  1918. AND a.hospital_id = c.hospital_id
  1919. AND a.behospital_code = d.behospital_code
  1920. AND a.hospital_id = d.hospital_id
  1921. AND a.is_deleted = 'N'
  1922. AND c.is_deleted = 'N'
  1923. AND d.is_deleted = 'N'
  1924. AND e.is_deleted = 'N'
  1925. AND a.beh_dept_id = e.dept_id
  1926. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1927. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1928. </if>
  1929. <![CDATA[AND a.qc_type_id <>0 ]]>
  1930. <if test="filterPageByDeptVO.userId!=null">
  1931. AND e.user_id = #{filterPageByDeptVO.userId}
  1932. </if>
  1933. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1934. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1935. </if>
  1936. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1937. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1938. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1939. </if>
  1940. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1941. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1942. </if>
  1943. </if>
  1944. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1945. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1946. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1947. </if>
  1948. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1949. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1950. </if>
  1951. </if>
  1952. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1953. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1954. </if>
  1955. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1956. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1957. </if>
  1958. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1959. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1960. </if>
  1961. GROUP BY
  1962. d.msg
  1963. ORDER BY
  1964. count(*) DESC
  1965. ) t1,
  1966. (
  1967. SELECT
  1968. count(*) AS totle
  1969. FROM
  1970. med_behospital_info a,
  1971. med_qcresult_info c,
  1972. med_qcresult_detail d,
  1973. sys_user_dept e
  1974. WHERE
  1975. a.behospital_code = c.behospital_code
  1976. AND a.hospital_id = c.hospital_id
  1977. AND a.behospital_code = d.behospital_code
  1978. AND a.hospital_id = d.hospital_id
  1979. AND a.is_deleted = 'N'
  1980. AND c.is_deleted = 'N'
  1981. AND d.is_deleted = 'N'
  1982. AND e.is_deleted = 'N'
  1983. AND a.beh_dept_id = e.dept_id
  1984. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1985. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1986. </if>
  1987. <![CDATA[AND a.qc_type_id <>0 ]]>
  1988. <if test="filterPageByDeptVO.userId!=null">
  1989. AND e.user_id = #{filterPageByDeptVO.userId}
  1990. </if>
  1991. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1992. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1993. </if>
  1994. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1995. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1996. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1997. </if>
  1998. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1999. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  2000. </if>
  2001. </if>
  2002. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  2003. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2004. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  2005. </if>
  2006. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2007. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  2008. </if>
  2009. </if>
  2010. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  2011. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  2012. </if>
  2013. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  2014. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  2015. </if>
  2016. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  2017. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  2018. </if>
  2019. ) t2
  2020. )t
  2021. </select>
  2022. <!-- 各科室缺陷占比(组合)-全院 -->
  2023. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2024. resultType="com.diagbot.dto.LevelStatisticsDTO">
  2025. SELECT
  2026. m1.deptId,
  2027. m1.deptName,
  2028. m1.entryNum,
  2029. m2.sameNum,
  2030. m1.mrNum,
  2031. m2.sameMrNum,
  2032. m1.totleValue,
  2033. m2.sameTotleValue,
  2034. m1.averageValue,
  2035. m2.sameAvgValue,
  2036. m1.firstLevelNum,
  2037. m2.sameFirstLevelNum,
  2038. m1.secondLevelNum,
  2039. m2.sameSecondLevelNum,
  2040. m1.thirdLevelNum,
  2041. m2.sameThirdLevelNum,
  2042. m1.firstLevelPercent,
  2043. m2.sameFirstLevelPercent,
  2044. m1.secondLevelPercent,
  2045. m2.sameSecondLevelPercent,
  2046. m1.thirdLevelPercent,
  2047. m2.sameThirdLevelPercent,
  2048. m1.firstLevelPercentStr,
  2049. m2.sameFirstLevelPercentStr,
  2050. m1.secondLevelPercentStr,
  2051. m2.sameSecondLevelPercentStr,
  2052. m1.thirdLevelPercentStr,
  2053. m2.sameThirdLevelPercentStr
  2054. FROM
  2055. (
  2056. SELECT
  2057. t1.deptId,
  2058. t1.deptName,
  2059. t2.entryNum,
  2060. t1.mrNum,
  2061. t1.totleValue,
  2062. t1.averageValue,
  2063. t1.firstLevelNum,
  2064. t1.secondLevelNum,
  2065. t1.thirdLevelNum,
  2066. t1.firstLevelPercent,
  2067. t1.secondLevelPercent,
  2068. t1.thirdLevelPercent,
  2069. t1.firstLevelPercentStr,
  2070. t1.secondLevelPercentStr,
  2071. t1.thirdLevelPercentStr
  2072. FROM
  2073. (
  2074. SELECT
  2075. a.beh_dept_id AS deptId,
  2076. a.beh_dept_name AS deptName,
  2077. count(*) AS mrNum,
  2078. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2079. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2080. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2081. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2082. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2083. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2084. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2085. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2086. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2087. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2088. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2089. FROM
  2090. med_behospital_info a,
  2091. med_qcresult_info c
  2092. WHERE
  2093. a.is_deleted = 'N'
  2094. AND c.is_deleted = 'N'
  2095. AND a.hospital_id = c.hospital_id
  2096. AND a.behospital_code = c.behospital_code
  2097. <if test="isPlacefile != null and isPlacefile != ''">
  2098. and a.is_placefile = #{isPlacefile}
  2099. </if>
  2100. AND a.qc_type_id != 0
  2101. <if test="hospitalId != null and hospitalId != ''">
  2102. AND a.hospital_id = #{hospitalId}
  2103. </if>
  2104. <if test="isPlacefile != null and isPlacefile == 0">
  2105. <if test="startDate != null and startDate != ''">
  2106. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2107. </if>
  2108. <if test="endDate != null and endDate != ''">
  2109. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2110. </if>
  2111. </if>
  2112. <if test="isPlacefile != null and isPlacefile == 1">
  2113. <if test="startDate != null and startDate != ''">
  2114. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2115. </if>
  2116. <if test="endDate != null and endDate != ''">
  2117. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2118. </if>
  2119. </if>
  2120. <if test="level != null and level != ''">
  2121. and c.level = #{level}
  2122. </if>
  2123. <if test="deptName != null and deptName != ''">
  2124. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2125. </if>
  2126. GROUP BY
  2127. a.beh_dept_id,
  2128. a.beh_dept_name
  2129. ) t1,
  2130. (
  2131. SELECT
  2132. a.beh_dept_id AS deptId,
  2133. a.beh_dept_name AS deptName,
  2134. count( * ) AS entryNum
  2135. FROM
  2136. med_behospital_info a,
  2137. med_qcresult_info c,
  2138. med_qcresult_detail d,
  2139. qc_cases_entry e
  2140. WHERE
  2141. a.is_deleted = 'N'
  2142. AND c.is_deleted = 'N'
  2143. AND d.is_deleted = 'N'
  2144. AND e.is_deleted = 'N'
  2145. AND a.hospital_id = c.hospital_id
  2146. AND a.hospital_id = d.hospital_id
  2147. AND a.behospital_code = c.behospital_code
  2148. AND a.behospital_code = d.behospital_code
  2149. AND d.cases_id = e.cases_id
  2150. AND d.cases_entry_id = e.id
  2151. <if test="isPlacefile != null and isPlacefile != ''">
  2152. and a.is_placefile = #{isPlacefile}
  2153. </if>
  2154. AND a.qc_type_id != 0
  2155. <if test="hospitalId != null and hospitalId != ''">
  2156. AND a.hospital_id = #{hospitalId}
  2157. </if>
  2158. <if test="isPlacefile != null and isPlacefile == 0">
  2159. <if test="startDate != null and startDate != ''">
  2160. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2161. </if>
  2162. <if test="endDate != null and endDate != ''">
  2163. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2164. </if>
  2165. </if>
  2166. <if test="isPlacefile != null and isPlacefile == 1">
  2167. <if test="startDate != null and startDate != ''">
  2168. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2169. </if>
  2170. <if test="endDate != null and endDate != ''">
  2171. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2172. </if>
  2173. </if>
  2174. <if test="level != null and level != ''">
  2175. and c.level = #{level}
  2176. </if>
  2177. <if test="deptName != null and deptName != ''">
  2178. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2179. </if>
  2180. GROUP BY
  2181. a.beh_dept_id,
  2182. a.beh_dept_name
  2183. ) t2
  2184. WHERE
  2185. t1.deptId = t2.deptId
  2186. AND t1.deptName = t2.deptName)m1 left join
  2187. ( SELECT
  2188. t1.deptId,
  2189. t1.deptName,
  2190. t2.entryNum as sameNum,
  2191. t1.mrNum as sameMrNum,
  2192. t1.totleValue as sameTotleValue,
  2193. t1.averageValue as sameAvgValue,
  2194. t1.firstLevelNum as sameFirstLevelNum,
  2195. t1.secondLevelNum as sameSecondLevelNum,
  2196. t1.thirdLevelNum as sameThirdLevelNum,
  2197. t1.firstLevelPercent as sameFirstLevelPercent,
  2198. t1.secondLevelPercent as sameSecondLevelPercent,
  2199. t1.thirdLevelPercent as sameThirdLevelPercent,
  2200. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2201. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2202. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2203. FROM
  2204. (
  2205. SELECT
  2206. a.beh_dept_id AS deptId,
  2207. a.beh_dept_name AS deptName,
  2208. count(*) AS mrNum,
  2209. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2210. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2211. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2212. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2213. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2214. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2215. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2216. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2217. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2218. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2219. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2220. FROM
  2221. med_behospital_info a,
  2222. med_qcresult_info c
  2223. WHERE
  2224. a.is_deleted = 'N'
  2225. AND c.is_deleted = 'N'
  2226. AND a.hospital_id = c.hospital_id
  2227. AND a.behospital_code = c.behospital_code
  2228. <if test="isPlacefile != null and isPlacefile != ''">
  2229. and a.is_placefile = #{isPlacefile}
  2230. </if>
  2231. AND a.qc_type_id != 0
  2232. <if test="hospitalId != null and hospitalId != ''">
  2233. AND a.hospital_id = #{hospitalId}
  2234. </if>
  2235. <if test="isPlacefile != null and isPlacefile == 0">
  2236. <if test="lastStartDate != null and lastStartDate != ''">
  2237. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2238. </if>
  2239. <if test="lastEndDate != null and lastEndDate != ''">
  2240. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2241. </if>
  2242. </if>
  2243. <if test="isPlacefile != null and isPlacefile == 1">
  2244. <if test="lastStartDate != null and lastStartDate != ''">
  2245. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2246. </if>
  2247. <if test="lastEndDate != null and lastEndDate != ''">
  2248. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2249. </if>
  2250. </if>
  2251. <if test="level != null and level != ''">
  2252. and c.level = #{level}
  2253. </if>
  2254. <if test="deptName != null and deptName != ''">
  2255. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2256. </if>
  2257. GROUP BY
  2258. a.beh_dept_id,
  2259. a.beh_dept_name
  2260. ) t1,
  2261. (
  2262. SELECT
  2263. a.beh_dept_id AS deptId,
  2264. a.beh_dept_name AS deptName,
  2265. count( * ) AS entryNum
  2266. FROM
  2267. med_behospital_info a,
  2268. med_qcresult_info c,
  2269. med_qcresult_detail d,
  2270. qc_cases_entry e
  2271. WHERE
  2272. a.is_deleted = 'N'
  2273. AND c.is_deleted = 'N'
  2274. AND d.is_deleted = 'N'
  2275. AND e.is_deleted = 'N'
  2276. AND a.hospital_id = c.hospital_id
  2277. AND a.hospital_id = d.hospital_id
  2278. AND a.behospital_code = c.behospital_code
  2279. AND a.behospital_code = d.behospital_code
  2280. AND d.cases_id = e.cases_id
  2281. AND d.cases_entry_id = e.id
  2282. <if test="isPlacefile != null and isPlacefile != ''">
  2283. and a.is_placefile = #{isPlacefile}
  2284. </if>
  2285. AND a.qc_type_id != 0
  2286. <if test="hospitalId != null and hospitalId != ''">
  2287. AND a.hospital_id = #{hospitalId}
  2288. </if>
  2289. <if test="isPlacefile != null and isPlacefile == 0">
  2290. <if test="lastStartDate != null and lastStartDate != ''">
  2291. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2292. </if>
  2293. <if test="lastEndDate != null and lastEndDate != ''">
  2294. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2295. </if>
  2296. </if>
  2297. <if test="isPlacefile != null and isPlacefile == 1">
  2298. <if test="lastStartDate != null and lastStartDate != ''">
  2299. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2300. </if>
  2301. <if test="lastEndDate != null and lastEndDate != ''">
  2302. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2303. </if>
  2304. </if>
  2305. <if test="level != null and level != ''">
  2306. and c.level = #{level}
  2307. </if>
  2308. <if test="deptName != null and deptName != ''">
  2309. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2310. </if>
  2311. GROUP BY
  2312. a.beh_dept_id,
  2313. a.beh_dept_name
  2314. ) t2
  2315. WHERE
  2316. t1.deptId = t2.deptId
  2317. AND t1.deptName = t2.deptName)m2
  2318. on
  2319. m1.deptId = m2.deptId
  2320. AND m1.deptName = m2.deptName
  2321. <if test="asc != null and asc !=''">
  2322. order by
  2323. <choose>
  2324. <when test='asc=="deptId"'>m1.deptId asc</when>
  2325. <when test='asc=="deptName"'>m1.deptName asc</when>
  2326. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2327. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2328. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2329. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2330. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2331. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2332. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2333. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2334. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2335. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2336. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2337. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2338. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2339. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2340. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2341. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2342. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2343. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2344. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2345. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2346. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2347. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2348. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2349. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2350. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2351. <otherwise>deptName asc</otherwise>
  2352. </choose>
  2353. </if>
  2354. <if test="desc != null and desc!=''">
  2355. order by
  2356. <choose>
  2357. <when test='desc=="deptId"'>m1.deptId desc</when>
  2358. <when test='desc=="deptName"'>m1.deptName desc</when>
  2359. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2360. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2361. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2362. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2363. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2364. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2365. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2366. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2367. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2368. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2369. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2370. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2371. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2372. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2373. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2374. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2375. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2376. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2377. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2378. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2379. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2380. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2381. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2382. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2383. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2384. <otherwise>deptName desc</otherwise>
  2385. </choose>
  2386. </if>
  2387. </select>
  2388. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  2389. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  2390. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2391. SELECT
  2392. t1.deptId,
  2393. t1.deptName,
  2394. t1.deptClassId,
  2395. t1.deptClass,
  2396. t2.entryNum,
  2397. t1.mrNum,
  2398. t1.totleValue,
  2399. t1.averageValue,
  2400. t1.firstLevelNum,
  2401. t1.secondLevelNum,
  2402. t1.thirdLevelNum,
  2403. t1.firstLevelPercent,
  2404. t1.secondLevelPercent,
  2405. t1.thirdLevelPercent,
  2406. t1.firstLevelPercentStr,
  2407. t1.secondLevelPercentStr,
  2408. t1.thirdLevelPercentStr
  2409. FROM
  2410. (
  2411. SELECT
  2412. a.beh_dept_id AS deptId,
  2413. a.beh_dept_name AS deptName,
  2414. e.dept_id AS deptClassId,
  2415. e.dept_name AS deptClass,
  2416. count( DISTINCT c.id ) AS mrNum,
  2417. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2418. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  2419. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  2420. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  2421. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  2422. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  2423. ) AS firstLevelPercent,
  2424. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2425. ) AS secondLevelPercent,
  2426. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2427. ) AS thirdLevelPercent,
  2428. concat(
  2429. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  2430. 100, 2 ),
  2431. '%'
  2432. ) AS firstLevelPercentStr,
  2433. concat(
  2434. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  2435. 100, 2 ),
  2436. '%'
  2437. ) AS secondLevelPercentStr,
  2438. concat(
  2439. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  2440. 100, 2 ),
  2441. '%'
  2442. ) AS thirdLevelPercentStr
  2443. FROM
  2444. med_behospital_info a,
  2445. med_qcresult_info c,
  2446. bas_dept_info d,
  2447. bas_dept_info e
  2448. WHERE
  2449. a.is_deleted = 'N'
  2450. AND c.is_deleted = 'N'
  2451. AND d.is_deleted = 'N'
  2452. AND e.is_deleted = 'N'
  2453. AND a.hospital_id = c.hospital_id
  2454. AND a.hospital_id = d.hospital_id
  2455. AND a.hospital_id = e.hospital_id
  2456. AND a.behospital_code = c.behospital_code
  2457. AND a.beh_dept_id = d.dept_id
  2458. AND d.parent_dept_id = e.dept_id
  2459. <if test="isPlacefile != null and isPlacefile != ''">
  2460. and a.is_placefile = #{isPlacefile}
  2461. </if>
  2462. <![CDATA[AND a.qc_type_id <>0 ]]>
  2463. <if test="hospitalId != null and hospitalId != ''">
  2464. AND a.hospital_id = #{hospitalId}
  2465. </if>
  2466. <if test="isPlacefile != null and isPlacefile == 0">
  2467. <if test="startDate != null and startDate != ''">
  2468. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2469. </if>
  2470. <if test="endDate != null and endDate != ''">
  2471. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2472. </if>
  2473. </if>
  2474. <if test="isPlacefile != null and isPlacefile == 1">
  2475. <if test="startDate != null and startDate != ''">
  2476. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2477. </if>
  2478. <if test="endDate != null and endDate != ''">
  2479. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2480. </if>
  2481. </if>
  2482. <if test="level != null and level != ''">
  2483. and c.level = #{level}
  2484. </if>
  2485. <if test="deptName != null and deptName != ''">
  2486. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2487. </if>
  2488. <if test="deptClass != null and deptClass != ''">
  2489. and e.dept_name = #{deptClass}
  2490. </if>
  2491. GROUP BY
  2492. a.beh_dept_id,
  2493. a.beh_dept_name,
  2494. e.dept_id,
  2495. e.dept_name
  2496. ) t1,
  2497. (
  2498. SELECT
  2499. a.beh_dept_id AS deptId,
  2500. a.beh_dept_name AS deptName,
  2501. g.dept_id AS deptClassId,
  2502. g.dept_name AS deptClass,
  2503. count( * ) AS entryNum
  2504. FROM
  2505. med_behospital_info a,
  2506. med_qcresult_info c,
  2507. med_qcresult_detail d,
  2508. qc_cases_entry e,
  2509. bas_dept_info f,
  2510. bas_dept_info g
  2511. WHERE
  2512. a.is_deleted = 'N'
  2513. AND c.is_deleted = 'N'
  2514. AND d.is_deleted = 'N'
  2515. AND e.is_deleted = 'N'
  2516. AND f.is_deleted = 'N'
  2517. AND g.is_deleted = 'N'
  2518. AND a.hospital_id = c.hospital_id
  2519. AND a.hospital_id = d.hospital_id
  2520. AND a.hospital_id = f.hospital_id
  2521. AND a.hospital_id = g.hospital_id
  2522. AND a.behospital_code = c.behospital_code
  2523. AND a.behospital_code = d.behospital_code
  2524. AND d.cases_id = e.cases_id
  2525. AND d.cases_entry_id = e.id
  2526. AND a.beh_dept_id = f.dept_id
  2527. AND f.parent_dept_id = g.dept_id
  2528. <if test="isPlacefile != null and isPlacefile != ''">
  2529. and a.is_placefile = #{isPlacefile}
  2530. </if>
  2531. <![CDATA[AND a.qc_type_id <>0 ]]>
  2532. <if test="hospitalId != null and hospitalId != ''">
  2533. AND a.hospital_id = #{hospitalId}
  2534. </if>
  2535. <if test="isPlacefile != null and isPlacefile == 0">
  2536. <if test="startDate != null and startDate != ''">
  2537. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2538. </if>
  2539. <if test="endDate != null and endDate != ''">
  2540. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2541. </if>
  2542. </if>
  2543. <if test="isPlacefile != null and isPlacefile == 1">
  2544. <if test="startDate != null and startDate != ''">
  2545. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2546. </if>
  2547. <if test="endDate != null and endDate != ''">
  2548. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2549. </if>
  2550. </if>
  2551. <if test="level != null and level != ''">
  2552. and c.level = #{level}
  2553. </if>
  2554. <if test="deptName != null and deptName != ''">
  2555. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2556. </if>
  2557. <if test="deptClass != null and deptClass != ''">
  2558. and g.dept_name = #{deptClass}
  2559. </if>
  2560. GROUP BY
  2561. a.beh_dept_id,
  2562. a.beh_dept_name,
  2563. g.dept_id,
  2564. g.dept_name
  2565. ) t2
  2566. WHERE
  2567. t1.deptId = t2.deptId
  2568. AND t1.deptName = t2.deptName
  2569. AND t1.deptClassId = t2.deptClassId
  2570. AND t1.deptClass = t2.deptClass
  2571. <if test="asc != null and asc !=''">
  2572. order by
  2573. <choose>
  2574. <when test='asc=="deptId"'>deptId asc</when>
  2575. <when test='asc=="deptName"'>deptName asc</when>
  2576. <when test='asc=="deptClassId"'>deptClassId asc</when>
  2577. <when test='asc=="deptClass"'>deptClass asc</when>
  2578. <when test='asc=="entryNum"'>entryNum asc</when>
  2579. <when test='asc=="mrNum"'>mrNum asc</when>
  2580. <when test='asc=="totleValue"'>totleValue asc</when>
  2581. <when test='asc=="averageValue"'>averageValue asc</when>
  2582. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2583. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2584. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2585. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2586. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2587. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2588. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2589. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2590. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2591. <otherwise>deptName asc</otherwise>
  2592. </choose>
  2593. </if>
  2594. <if test="desc != null and desc!=''">
  2595. order by
  2596. <choose>
  2597. <when test='desc=="deptId"'>deptId desc</when>
  2598. <when test='desc=="deptName"'>deptName desc</when>
  2599. <when test='desc=="deptClassId"'>deptClassId desc</when>
  2600. <when test='desc=="deptClass"'>deptClass desc</when>
  2601. <when test='desc=="entryNum"'>entryNum desc</when>
  2602. <when test='desc=="mrNum"'>mrNum desc</when>
  2603. <when test='desc=="totleValue"'>totleValue desc</when>
  2604. <when test='desc=="averageValue"'>averageValue desc</when>
  2605. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2606. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2607. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2608. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2609. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2610. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2611. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2612. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2613. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2614. <otherwise>deptName desc</otherwise>
  2615. </choose>
  2616. </if>
  2617. </select>
  2618. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  2619. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2620. select
  2621. m1.deptId,
  2622. m1.deptName,
  2623. m1.deptClassId,
  2624. m1.deptClass,
  2625. m1.entryNum,
  2626. m2.sameNum,
  2627. m1.mrNum,
  2628. m2.sameMrNum,
  2629. m1.totleValue,
  2630. m2.sameTotleValue,
  2631. m1.averageValue,
  2632. m2.sameAvgValue,
  2633. m1.firstLevelNum,
  2634. m2.sameFirstLevelNum,
  2635. m1.secondLevelNum,
  2636. m2.sameSecondLevelNum,
  2637. m1.thirdLevelNum,
  2638. m2.sameThirdLevelNum,
  2639. m1.firstLevelPercent,
  2640. m2.sameFirstLevelPercent,
  2641. m1.secondLevelPercent,
  2642. m2.sameSecondLevelPercent,
  2643. m1.thirdLevelPercent,
  2644. m2.sameThirdLevelPercent,
  2645. m1.firstLevelPercentStr,
  2646. m2.sameFirstLevelPercentStr,
  2647. m1.secondLevelPercentStr,
  2648. m2.sameSecondLevelPercentStr,
  2649. m1.thirdLevelPercentStr,
  2650. m2.sameThirdLevelPercentStr
  2651. from (
  2652. SELECT
  2653. t1.deptId,
  2654. t1.deptName,
  2655. t1.deptClassId,
  2656. t1.deptClass,
  2657. t2.entryNum,
  2658. t1.mrNum,
  2659. t1.totleValue,
  2660. t1.averageValue,
  2661. t1.firstLevelNum,
  2662. t1.secondLevelNum,
  2663. t1.thirdLevelNum,
  2664. t1.firstLevelPercent,
  2665. t1.secondLevelPercent,
  2666. t1.thirdLevelPercent,
  2667. t1.firstLevelPercentStr,
  2668. t1.secondLevelPercentStr,
  2669. t1.thirdLevelPercentStr
  2670. FROM
  2671. (
  2672. SELECT
  2673. tt1.deptId,
  2674. tt1.deptName,
  2675. e.dept_id AS deptClassId,
  2676. e.dept_name AS deptClass,
  2677. count(*) AS mrNum,
  2678. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2679. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2680. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2681. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2682. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2683. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2684. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2685. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2686. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2687. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2688. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2689. FROM
  2690. (
  2691. SELECT
  2692. a.beh_dept_id AS deptId,
  2693. a.beh_dept_name AS deptName,
  2694. d.parent_dept_id AS parentDeptId,
  2695. a.hospital_id AS hospitalId,
  2696. a.behospital_code AS behospitalCode,
  2697. c.score_res AS score,
  2698. c.LEVEL
  2699. FROM
  2700. med_behospital_info a,
  2701. med_qcresult_info c,
  2702. bas_dept_info d
  2703. WHERE
  2704. a.is_deleted = 'N'
  2705. AND c.is_deleted = 'N'
  2706. AND d.is_deleted = 'N'
  2707. AND a.hospital_id = c.hospital_id
  2708. AND a.hospital_id = d.hospital_id
  2709. AND a.behospital_code = c.behospital_code
  2710. AND a.beh_dept_id = d.dept_id
  2711. <if test="isPlacefile != null and isPlacefile != ''">
  2712. and a.is_placefile = #{isPlacefile}
  2713. </if>
  2714. AND a.qc_type_id != 0
  2715. <if test="hospitalId != null and hospitalId != ''">
  2716. AND a.hospital_id = #{hospitalId}
  2717. </if>
  2718. <if test="isPlacefile != null and isPlacefile == 0">
  2719. <if test="startDate != null and startDate != ''">
  2720. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2721. </if>
  2722. <if test="endDate != null and endDate != ''">
  2723. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2724. </if>
  2725. </if>
  2726. <if test="isPlacefile != null and isPlacefile == 1">
  2727. <if test="startDate != null and startDate != ''">
  2728. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2729. </if>
  2730. <if test="endDate != null and endDate != ''">
  2731. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2732. </if>
  2733. </if>
  2734. <if test="level != null and level != ''">
  2735. and c.level = #{level}
  2736. </if>
  2737. <if test="deptName != null and deptName != ''">
  2738. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2739. </if>
  2740. ) tt1
  2741. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2742. AND e.is_deleted = 'N'
  2743. AND tt1.hospitalId = e.hospital_id
  2744. <if test="deptClass != null and deptClass != ''">
  2745. WHERE e.dept_name = #{deptClass}
  2746. </if>
  2747. GROUP BY
  2748. tt1.deptId,
  2749. tt1.deptName,
  2750. e.dept_id,
  2751. e.dept_name
  2752. ) t1,
  2753. (
  2754. SELECT
  2755. tt2.deptId,
  2756. tt2.deptName,
  2757. g.dept_id AS deptClassId,
  2758. g.dept_name AS deptClass,
  2759. count( * ) AS entryNum
  2760. FROM
  2761. (
  2762. SELECT
  2763. a.beh_dept_id AS deptId,
  2764. a.beh_dept_name AS deptName,
  2765. f.parent_dept_id AS parentDeptId,
  2766. a.hospital_id AS hospitalId,
  2767. a.behospital_code AS behospitalCode
  2768. FROM
  2769. med_behospital_info a,
  2770. med_qcresult_info c,
  2771. med_qcresult_detail d,
  2772. qc_cases_entry e,
  2773. bas_dept_info f
  2774. WHERE
  2775. a.is_deleted = 'N'
  2776. AND c.is_deleted = 'N'
  2777. AND d.is_deleted = 'N'
  2778. AND e.is_deleted = 'N'
  2779. AND f.is_deleted = 'N'
  2780. AND a.hospital_id = c.hospital_id
  2781. AND a.hospital_id = d.hospital_id
  2782. AND a.hospital_id = f.hospital_id
  2783. AND a.behospital_code = c.behospital_code
  2784. AND a.behospital_code = d.behospital_code
  2785. AND d.cases_id = e.cases_id
  2786. AND d.cases_entry_id = e.id
  2787. AND a.beh_dept_id = f.dept_id
  2788. <if test="isPlacefile != null and isPlacefile != ''">
  2789. and a.is_placefile = #{isPlacefile}
  2790. </if>
  2791. AND a.qc_type_id != 0
  2792. <if test="hospitalId != null and hospitalId != ''">
  2793. AND a.hospital_id = #{hospitalId}
  2794. </if>
  2795. <if test="isPlacefile != null and isPlacefile == 0">
  2796. <if test="startDate != null and startDate != ''">
  2797. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2798. </if>
  2799. <if test="endDate != null and endDate != ''">
  2800. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2801. </if>
  2802. </if>
  2803. <if test="isPlacefile != null and isPlacefile == 1">
  2804. <if test="startDate != null and startDate != ''">
  2805. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2806. </if>
  2807. <if test="endDate != null and endDate != ''">
  2808. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2809. </if>
  2810. </if>
  2811. <if test="level != null and level != ''">
  2812. and c.level = #{level}
  2813. </if>
  2814. <if test="deptName != null and deptName != ''">
  2815. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2816. </if>
  2817. ) tt2
  2818. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2819. AND g.is_deleted = 'N'
  2820. AND tt2.hospitalId = g.hospital_id
  2821. <if test="deptClass != null and deptClass != ''">
  2822. WHERE g.dept_name = #{deptClass}
  2823. </if>
  2824. GROUP BY
  2825. tt2.deptId,
  2826. tt2.deptName,
  2827. g.dept_id,
  2828. g.dept_name
  2829. ) t2
  2830. WHERE
  2831. t1.deptId = t2.deptId
  2832. AND t1.deptName = t2.deptName)m1 left join
  2833. ( SELECT
  2834. t1.deptId,
  2835. t1.deptName,
  2836. t1.deptClassId,
  2837. t1.deptClass,
  2838. t2.entryNum as sameNum,
  2839. t1.mrNum as sameMrNum,
  2840. t1.totleValue as sameTotleValue,
  2841. t1.averageValue as sameAvgValue,
  2842. t1.firstLevelNum as sameFirstLevelNum,
  2843. t1.secondLevelNum as sameSecondLevelNum,
  2844. t1.thirdLevelNum as sameThirdLevelNum,
  2845. t1.firstLevelPercent as sameFirstLevelPercent,
  2846. t1.secondLevelPercent as sameSecondLevelPercent,
  2847. t1.thirdLevelPercent as sameThirdLevelPercent,
  2848. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2849. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2850. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2851. FROM
  2852. (
  2853. SELECT
  2854. tt1.deptId,
  2855. tt1.deptName,
  2856. e.dept_id AS deptClassId,
  2857. e.dept_name AS deptClass,
  2858. count(*) AS mrNum,
  2859. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2860. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2861. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2862. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2863. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2864. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2865. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2866. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2867. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2868. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2869. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2870. FROM
  2871. (
  2872. SELECT
  2873. a.beh_dept_id AS deptId,
  2874. a.beh_dept_name AS deptName,
  2875. d.parent_dept_id AS parentDeptId,
  2876. a.hospital_id AS hospitalId,
  2877. a.behospital_code AS behospitalCode,
  2878. c.score_res AS score,
  2879. c.LEVEL
  2880. FROM
  2881. med_behospital_info a,
  2882. med_qcresult_info c,
  2883. bas_dept_info d
  2884. WHERE
  2885. a.is_deleted = 'N'
  2886. AND c.is_deleted = 'N'
  2887. AND d.is_deleted = 'N'
  2888. AND a.hospital_id = c.hospital_id
  2889. AND a.hospital_id = d.hospital_id
  2890. AND a.behospital_code = c.behospital_code
  2891. AND a.beh_dept_id = d.dept_id
  2892. <if test="isPlacefile != null and isPlacefile != ''">
  2893. and a.is_placefile = #{isPlacefile}
  2894. </if>
  2895. AND a.qc_type_id != 0
  2896. <if test="hospitalId != null and hospitalId != ''">
  2897. AND a.hospital_id = #{hospitalId}
  2898. </if>
  2899. <if test="isPlacefile != null and isPlacefile == 0">
  2900. <if test="lastStartDate != null and lastStartDate != ''">
  2901. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2902. </if>
  2903. <if test="lastEndDate != null and lastEndDate != ''">
  2904. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2905. </if>
  2906. </if>
  2907. <if test="isPlacefile != null and isPlacefile == 1">
  2908. <if test="lastStartDate != null and lastStartDate != ''">
  2909. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2910. </if>
  2911. <if test="lastEndDate != null and lastEndDate != ''">
  2912. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2913. </if>
  2914. </if>
  2915. <if test="level != null and level != ''">
  2916. and c.level = #{level}
  2917. </if>
  2918. <if test="deptName != null and deptName != ''">
  2919. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2920. </if>
  2921. ) tt1
  2922. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2923. AND e.is_deleted = 'N'
  2924. AND tt1.hospitalId = e.hospital_id
  2925. <if test="deptClass != null and deptClass != ''">
  2926. WHERE e.dept_name = #{deptClass}
  2927. </if>
  2928. GROUP BY
  2929. tt1.deptId,
  2930. tt1.deptName,
  2931. e.dept_id,
  2932. e.dept_name
  2933. ) t1,
  2934. (
  2935. SELECT
  2936. tt2.deptId,
  2937. tt2.deptName,
  2938. g.dept_id AS deptClassId,
  2939. g.dept_name AS deptClass,
  2940. count( * ) AS entryNum
  2941. FROM
  2942. (
  2943. SELECT
  2944. a.beh_dept_id AS deptId,
  2945. a.beh_dept_name AS deptName,
  2946. f.parent_dept_id AS parentDeptId,
  2947. a.hospital_id AS hospitalId,
  2948. a.behospital_code AS behospitalCode
  2949. FROM
  2950. med_behospital_info a,
  2951. med_qcresult_info c,
  2952. med_qcresult_detail d,
  2953. qc_cases_entry e,
  2954. bas_dept_info f
  2955. WHERE
  2956. a.is_deleted = 'N'
  2957. AND c.is_deleted = 'N'
  2958. AND d.is_deleted = 'N'
  2959. AND e.is_deleted = 'N'
  2960. AND f.is_deleted = 'N'
  2961. AND a.hospital_id = c.hospital_id
  2962. AND a.hospital_id = d.hospital_id
  2963. AND a.hospital_id = f.hospital_id
  2964. AND a.behospital_code = c.behospital_code
  2965. AND a.behospital_code = d.behospital_code
  2966. AND d.cases_id = e.cases_id
  2967. AND d.cases_entry_id = e.id
  2968. AND a.beh_dept_id = f.dept_id
  2969. <if test="isPlacefile != null and isPlacefile != ''">
  2970. and a.is_placefile = #{isPlacefile}
  2971. </if>
  2972. AND a.qc_type_id != 0
  2973. <if test="hospitalId != null and hospitalId != ''">
  2974. AND a.hospital_id = #{hospitalId}
  2975. </if>
  2976. <if test="isPlacefile != null and isPlacefile == 0">
  2977. <if test="lastStartDate != null and lastStartDate != ''">
  2978. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2979. </if>
  2980. <if test="lastEndDate != null and lastEndDate != ''">
  2981. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2982. </if>
  2983. </if>
  2984. <if test="isPlacefile != null and isPlacefile == 1">
  2985. <if test="lastStartDate != null and lastStartDate != ''">
  2986. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2987. </if>
  2988. <if test="lastEndDate != null and lastEndDate != ''">
  2989. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2990. </if>
  2991. </if>
  2992. <if test="level != null and level != ''">
  2993. and c.level = #{level}
  2994. </if>
  2995. <if test="deptName != null and deptName != ''">
  2996. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2997. </if>
  2998. ) tt2
  2999. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  3000. AND g.is_deleted = 'N'
  3001. AND tt2.hospitalId = g.hospital_id
  3002. <if test="deptClass != null and deptClass != ''">
  3003. WHERE g.dept_name = #{deptClass}
  3004. </if>
  3005. GROUP BY
  3006. tt2.deptId,
  3007. tt2.deptName,
  3008. g.dept_id,
  3009. g.dept_name
  3010. ) t2
  3011. WHERE
  3012. t1.deptId = t2.deptId
  3013. AND t1.deptName = t2.deptName)m2
  3014. on
  3015. m1.deptId = m2.deptId
  3016. and m1.deptName = m2.deptName
  3017. <if test="asc != null and asc !=''">
  3018. order by
  3019. <choose>
  3020. <when test='asc=="deptId"'>m1.deptId asc</when>
  3021. <when test='asc=="deptName"'>m1.deptName asc</when>
  3022. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  3023. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  3024. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3025. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3026. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3027. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3028. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3029. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3030. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3031. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3032. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3033. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3034. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3035. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3036. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3037. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3038. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3039. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3040. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3041. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3042. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3043. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3044. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3045. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3046. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3047. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3048. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3049. <otherwise>deptName asc</otherwise>
  3050. </choose>
  3051. </if>
  3052. <if test="desc != null and desc!=''">
  3053. order by
  3054. <choose>
  3055. <when test='desc=="deptId"'>m1.deptId desc</when>
  3056. <when test='desc=="deptName"'>m1.deptName desc</when>
  3057. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  3058. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  3059. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3060. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3061. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3062. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3063. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3064. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3065. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3066. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3067. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3068. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3069. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3070. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3071. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3072. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3073. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3074. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3075. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3076. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3077. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3078. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3079. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3080. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3081. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3082. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3083. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3084. <otherwise>deptName desc</otherwise>
  3085. </choose>
  3086. </if>
  3087. </select>
  3088. <!-- 病案首页合格率占比 -全院-->
  3089. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  3090. resultType="com.diagbot.dto.HomePageNumDTO">
  3091. SELECT
  3092. t1.deptId,
  3093. t1.deptName,
  3094. t2.entryNum,
  3095. t1.mrNum,
  3096. t1.totleValue,
  3097. t1.averageValue,
  3098. t1.firstLevelNum,
  3099. t1.secondLevelNum,
  3100. t1.firstLevelPercent,
  3101. t1.secondLevelPercent,
  3102. t1.firstLevelPercentStr,
  3103. t1.secondLevelPercentStr,
  3104. t3.emptyNum,
  3105. t3.errorNum,
  3106. t3.entryTotleNum,
  3107. t3.emptyPercent,
  3108. t3.errorPercent,
  3109. t3.emptyPercentStr,
  3110. t3.errorPercentStr
  3111. FROM
  3112. (
  3113. SELECT
  3114. a.beh_dept_id AS deptId,
  3115. a.beh_dept_name AS deptName,
  3116. count( * ) AS mrNum,
  3117. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3118. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3119. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3120. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3121. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3122. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3123. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3124. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3125. FROM
  3126. med_behospital_info a,
  3127. med_qcresult_cases c
  3128. WHERE
  3129. a.is_deleted = 'N'
  3130. AND c.is_deleted = 'N'
  3131. AND a.hospital_id = c.hospital_id
  3132. AND a.behospital_code = c.behospital_code
  3133. AND c.cases_id = 243
  3134. <if test="isPlacefile != null and isPlacefile != ''">
  3135. and a.is_placefile = #{isPlacefile}
  3136. </if>
  3137. AND a.qc_type_id != 0
  3138. <if test="hospitalId != null and hospitalId != ''">
  3139. AND a.hospital_id = #{hospitalId}
  3140. </if>
  3141. <if test="isPlacefile != null and isPlacefile == 0">
  3142. <if test="startDate != null and startDate != ''">
  3143. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3144. </if>
  3145. <if test="endDate != null and endDate != ''">
  3146. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3147. </if>
  3148. </if>
  3149. <if test="isPlacefile != null and isPlacefile == 1">
  3150. <if test="startDate != null and startDate != ''">
  3151. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3152. </if>
  3153. <if test="endDate != null and endDate != ''">
  3154. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3155. </if>
  3156. </if>
  3157. <if test="level != null and level != ''">
  3158. and c.level = #{level}
  3159. </if>
  3160. <if test="deptName != null and deptName != ''">
  3161. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3162. </if>
  3163. GROUP BY
  3164. a.beh_dept_id,
  3165. a.beh_dept_name
  3166. ) t1,
  3167. (
  3168. SELECT
  3169. a.beh_dept_id AS deptId,
  3170. a.beh_dept_name AS deptName,
  3171. count( * ) AS entryNum
  3172. FROM
  3173. med_behospital_info a,
  3174. med_qcresult_cases c,
  3175. med_qcresult_detail d,
  3176. qc_cases_entry e
  3177. WHERE
  3178. a.is_deleted = 'N'
  3179. AND c.is_deleted = 'N'
  3180. AND d.is_deleted = 'N'
  3181. AND e.is_deleted = 'N'
  3182. AND a.hospital_id = c.hospital_id
  3183. AND a.hospital_id = d.hospital_id
  3184. AND a.behospital_code = c.behospital_code
  3185. AND a.behospital_code = d.behospital_code
  3186. AND c.cases_id = d.cases_id
  3187. AND d.cases_id = e.cases_id
  3188. AND d.cases_entry_id = e.id
  3189. AND d.cases_id = 243
  3190. <if test="isPlacefile != null and isPlacefile != ''">
  3191. and a.is_placefile = #{isPlacefile}
  3192. </if>
  3193. AND a.qc_type_id != 0
  3194. <if test="hospitalId != null and hospitalId != ''">
  3195. AND a.hospital_id = #{hospitalId}
  3196. </if>
  3197. <if test="isPlacefile != null and isPlacefile == 0">
  3198. <if test="startDate != null and startDate != ''">
  3199. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3200. </if>
  3201. <if test="endDate != null and endDate != ''">
  3202. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3203. </if>
  3204. </if>
  3205. <if test="isPlacefile != null and isPlacefile == 1">
  3206. <if test="startDate != null and startDate != ''">
  3207. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3208. </if>
  3209. <if test="endDate != null and endDate != ''">
  3210. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3211. </if>
  3212. </if>
  3213. <if test="level != null and level != ''">
  3214. and c.level = #{level}
  3215. </if>
  3216. <if test="deptName != null and deptName != ''">
  3217. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3218. </if>
  3219. GROUP BY
  3220. a.beh_dept_id,
  3221. a.beh_dept_name
  3222. ) t2,(
  3223. SELECT
  3224. h1.deptId,
  3225. h1.deptName,
  3226. h1.emptyNum,
  3227. h1.errorNum,
  3228. h1.mrNum,
  3229. h2.entryNum,
  3230. h1.mrNum * h2.entryNum AS entryTotleNum,
  3231. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3232. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3233. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3234. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3235. FROM
  3236. (
  3237. SELECT
  3238. a.beh_dept_id AS deptId,
  3239. a.beh_dept_name AS deptName,
  3240. sum( d.rule_type = 1 ) AS emptyNum,
  3241. sum( d.rule_type = 2 ) AS errorNum,
  3242. count( DISTINCT a.behospital_code ) AS mrNum
  3243. FROM
  3244. med_behospital_info a,
  3245. med_qcresult_cases b,
  3246. med_qcresult_detail c,
  3247. qc_cases_entry d
  3248. WHERE
  3249. a.is_deleted = 'N'
  3250. AND b.is_deleted = 'N'
  3251. AND c.is_deleted = 'N'
  3252. AND d.is_deleted = 'N'
  3253. AND a.hospital_id = b.hospital_id
  3254. AND a.hospital_id = c.hospital_id
  3255. AND a.behospital_code = b.behospital_code
  3256. AND a.behospital_code = c.behospital_code
  3257. AND b.cases_id = c.cases_id
  3258. AND c.cases_id = d.cases_id
  3259. AND c.cases_entry_id = d.id
  3260. <if test="isPlacefile != null and isPlacefile != ''">
  3261. and a.is_placefile = #{isPlacefile}
  3262. </if>
  3263. AND d.cases_id = 243
  3264. AND a.qc_type_id != 0
  3265. <if test="hospitalId != null and hospitalId != ''">
  3266. AND a.hospital_id = #{hospitalId}
  3267. </if>
  3268. <if test="isPlacefile != null and isPlacefile == 0">
  3269. <if test="startDate != null and startDate != ''">
  3270. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3271. </if>
  3272. <if test="endDate != null and endDate != ''">
  3273. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3274. </if>
  3275. </if>
  3276. <if test="isPlacefile != null and isPlacefile == 1">
  3277. <if test="startDate != null and startDate != ''">
  3278. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3279. </if>
  3280. <if test="endDate != null and endDate != ''">
  3281. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3282. </if>
  3283. </if>
  3284. <if test="level != null and level != ''">
  3285. and b.level = #{level}
  3286. </if>
  3287. <if test="deptName != null and deptName != ''">
  3288. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3289. </if>
  3290. GROUP BY
  3291. a.beh_dept_id,
  3292. a.beh_dept_name
  3293. ) h1,(
  3294. SELECT
  3295. count(*) AS entryNum
  3296. FROM
  3297. qc_cases_entry
  3298. WHERE
  3299. is_deleted = 'N'
  3300. AND cases_id = 243
  3301. ) h2
  3302. ) t3
  3303. WHERE
  3304. t1.deptId = t2.deptId
  3305. AND t1.deptId = t3.deptId
  3306. AND t1.deptName = t2.deptName
  3307. AND t1.deptName = t3.deptName
  3308. <if test="asc != null and asc !=''">
  3309. order by
  3310. <choose>
  3311. <when test='asc=="deptId"'>deptId asc</when>
  3312. <when test='asc=="deptName"'>deptName asc</when>
  3313. <when test='asc=="entryNum"'>entryNum asc</when>
  3314. <when test='asc=="mrNum"'>mrNum asc</when>
  3315. <when test='asc=="totleValue"'>totleValue asc</when>
  3316. <when test='asc=="averageValue"'>averageValue asc</when>
  3317. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3318. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3319. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3320. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3321. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3322. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3323. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3324. <when test='asc=="errorNum"'>errorNum asc</when>
  3325. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3326. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3327. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3328. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3329. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3330. <otherwise>deptName asc</otherwise>
  3331. </choose>
  3332. </if>
  3333. <if test="desc != null and desc!=''">
  3334. order by
  3335. <choose>
  3336. <when test='desc=="deptId"'>deptId desc</when>
  3337. <when test='desc=="deptName"'>deptName desc</when>
  3338. <when test='desc=="entryNum"'>entryNum desc</when>
  3339. <when test='desc=="mrNum"'>mrNum desc</when>
  3340. <when test='desc=="totleValue"'>totleValue desc</when>
  3341. <when test='desc=="averageValue"'>averageValue desc</when>
  3342. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3343. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3344. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3345. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3346. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3347. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3348. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3349. <when test='desc=="errorNum"'>errorNum desc</when>
  3350. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3351. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3352. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3353. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3354. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3355. <otherwise>deptName desc</otherwise>
  3356. </choose>
  3357. </if>
  3358. </select>
  3359. <!-- 各科室缺陷占比-科室 -->
  3360. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3361. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3362. SELECT
  3363. m1.doctorId,
  3364. m1.doctorName,
  3365. m1.entryNum,
  3366. m2.sameNum,
  3367. m1.mrNum,
  3368. m2.sameMrNum,
  3369. m1.totleValue,
  3370. m2.sameTotleValue,
  3371. m1.averageValue,
  3372. m2.sameAvgValue,
  3373. m1.firstLevelNum,
  3374. m2.sameFirstLevelNum,
  3375. m1.secondLevelNum,
  3376. m2.sameSecondLevelNum,
  3377. m1.thirdLevelNum,
  3378. m2.sameThirdLevelNum,
  3379. m1.firstLevelPercent,
  3380. m2.sameFirstLevelPercent,
  3381. m1.secondLevelPercent,
  3382. m2.sameSecondLevelPercent,
  3383. m1.thirdLevelPercent,
  3384. m2.sameThirdLevelPercent,
  3385. m1.firstLevelPercentStr,
  3386. m2.sameFirstLevelPercentStr,
  3387. m1.secondLevelPercentStr,
  3388. m2.sameSecondLevelPercentStr,
  3389. m1.thirdLevelPercentStr,
  3390. m2.sameThirdLevelPercentStr
  3391. FROM
  3392. (
  3393. SELECT
  3394. t1.doctorId,
  3395. t1.doctorName,
  3396. t2.entryNum,
  3397. t1.mrNum,
  3398. t1.totleValue,
  3399. t1.averageValue,
  3400. t1.firstLevelNum,
  3401. t1.secondLevelNum,
  3402. t1.thirdLevelNum,
  3403. t1.firstLevelPercent,
  3404. t1.secondLevelPercent,
  3405. t1.thirdLevelPercent,
  3406. t1.firstLevelPercentStr,
  3407. t1.secondLevelPercentStr,
  3408. t1.thirdLevelPercentStr
  3409. FROM
  3410. (
  3411. SELECT
  3412. a.doctor_id AS doctorId,
  3413. a.doctor_name AS doctorName,
  3414. count(*) AS mrNum,
  3415. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3416. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3417. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3418. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3419. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3420. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3421. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3422. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3423. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3424. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3425. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3426. FROM
  3427. med_behospital_info a,
  3428. med_qcresult_info c,
  3429. sys_user_dept e
  3430. WHERE
  3431. a.is_deleted = 'N'
  3432. AND c.is_deleted = 'N'
  3433. AND e.is_deleted = 'N'
  3434. AND a.hospital_id = c.hospital_id
  3435. AND a.behospital_code = c.behospital_code
  3436. AND a.beh_dept_id = e.dept_id
  3437. <if test="isPlacefile != null and isPlacefile != ''">
  3438. and a.is_placefile = #{isPlacefile}
  3439. </if>
  3440. AND a.qc_type_id != 0
  3441. <if test="hospitalId != null and hospitalId != ''">
  3442. AND a.hospital_id = #{hospitalId}
  3443. </if>
  3444. <if test="isPlacefile != null and isPlacefile == 0">
  3445. <if test="startDate != null and startDate != ''">
  3446. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3447. </if>
  3448. <if test="endDate != null and endDate != ''">
  3449. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3450. </if>
  3451. </if>
  3452. <if test="isPlacefile != null and isPlacefile == 1">
  3453. <if test="startDate != null and startDate != ''">
  3454. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3455. </if>
  3456. <if test="endDate != null and endDate != ''">
  3457. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3458. </if>
  3459. </if>
  3460. <if test="level != null and level != ''">
  3461. and c.level = #{level}
  3462. </if>
  3463. <if test="doctorName != null and doctorName != ''">
  3464. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3465. </if>
  3466. <if test="userId!=null and userId !=''">
  3467. AND e.user_id = #{userId}
  3468. </if>
  3469. <if test="deptName != null and deptName != ''">
  3470. and a.beh_dept_name = #{deptName}
  3471. </if>
  3472. GROUP BY
  3473. a.doctor_id,
  3474. a.doctor_name
  3475. ) t1,
  3476. (
  3477. SELECT
  3478. a.doctor_id AS doctorId,
  3479. a.doctor_name AS doctorName,
  3480. count( * ) AS entryNum
  3481. FROM
  3482. med_behospital_info a,
  3483. med_qcresult_info c,
  3484. med_qcresult_detail d,
  3485. qc_cases_entry e,
  3486. sys_user_dept f
  3487. WHERE
  3488. a.is_deleted = 'N'
  3489. AND c.is_deleted = 'N'
  3490. AND d.is_deleted = 'N'
  3491. AND e.is_deleted = 'N'
  3492. AND f.is_deleted = 'N'
  3493. AND a.hospital_id = c.hospital_id
  3494. AND a.hospital_id = d.hospital_id
  3495. AND a.behospital_code = c.behospital_code
  3496. AND a.behospital_code = d.behospital_code
  3497. AND d.cases_id = e.cases_id
  3498. AND d.cases_entry_id = e.id
  3499. AND a.beh_dept_id = f.dept_id
  3500. <if test="isPlacefile != null and isPlacefile != ''">
  3501. and a.is_placefile = #{isPlacefile}
  3502. </if>
  3503. AND a.qc_type_id != 0
  3504. <if test="hospitalId != null and hospitalId != ''">
  3505. AND a.hospital_id = #{hospitalId}
  3506. </if>
  3507. <if test="isPlacefile != null and isPlacefile == 0">
  3508. <if test="startDate != null and startDate != ''">
  3509. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3510. </if>
  3511. <if test="endDate != null and endDate != ''">
  3512. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3513. </if>
  3514. </if>
  3515. <if test="isPlacefile != null and isPlacefile == 1">
  3516. <if test="startDate != null and startDate != ''">
  3517. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3518. </if>
  3519. <if test="endDate != null and endDate != ''">
  3520. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3521. </if>
  3522. </if>
  3523. <if test="level != null and level != ''">
  3524. and c.level = #{level}
  3525. </if>
  3526. <if test="doctorName != null and doctorName != ''">
  3527. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3528. </if>
  3529. <if test="userId!=null and userId !=''">
  3530. AND f.user_id = #{userId}
  3531. </if>
  3532. <if test="deptName != null and deptName != ''">
  3533. and a.beh_dept_name = #{deptName}
  3534. </if>
  3535. GROUP BY
  3536. a.doctor_id,
  3537. a.doctor_name
  3538. ) t2
  3539. WHERE
  3540. t1.doctorId = t2.doctorId
  3541. AND t1.doctorName = t2.doctorName
  3542. )m1 left join
  3543. ( SELECT
  3544. t1.doctorId,
  3545. t1.doctorName,
  3546. t2.entryNum as sameNum,
  3547. t1.mrNum as sameMrNum,
  3548. t1.totleValue as sameTotleValue,
  3549. t1.averageValue as sameAvgValue,
  3550. t1.firstLevelNum as sameFirstLevelNum,
  3551. t1.secondLevelNum as sameSecondLevelNum,
  3552. t1.thirdLevelNum as sameThirdLevelNum,
  3553. t1.firstLevelPercent as sameFirstLevelPercent,
  3554. t1.secondLevelPercent as sameSecondLevelPercent,
  3555. t1.thirdLevelPercent as sameThirdLevelPercent,
  3556. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3557. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3558. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3559. FROM
  3560. (
  3561. SELECT
  3562. a.doctor_id AS doctorId,
  3563. a.doctor_name AS doctorName,
  3564. count(*) AS mrNum,
  3565. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3566. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3567. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3568. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3569. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3570. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3571. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3572. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3573. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3574. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3575. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3576. FROM
  3577. med_behospital_info a,
  3578. med_qcresult_info c,
  3579. sys_user_dept e
  3580. WHERE
  3581. a.is_deleted = 'N'
  3582. AND c.is_deleted = 'N'
  3583. AND e.is_deleted = 'N'
  3584. AND a.hospital_id = c.hospital_id
  3585. AND a.behospital_code = c.behospital_code
  3586. AND a.beh_dept_id = e.dept_id
  3587. <if test="isPlacefile != null and isPlacefile != ''">
  3588. and a.is_placefile = #{isPlacefile}
  3589. </if>
  3590. AND a.qc_type_id != 0
  3591. <if test="hospitalId != null and hospitalId != ''">
  3592. AND a.hospital_id = #{hospitalId}
  3593. </if>
  3594. <if test="isPlacefile != null and isPlacefile == 0">
  3595. <if test="lastStartDate != null and lastStartDate != ''">
  3596. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3597. </if>
  3598. <if test="lastEndDate != null and lastEndDate != ''">
  3599. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3600. </if>
  3601. </if>
  3602. <if test="isPlacefile != null and isPlacefile == 1">
  3603. <if test="lastStartDate != null and lastStartDate != ''">
  3604. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3605. </if>
  3606. <if test="lastEndDate != null and lastEndDate != ''">
  3607. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3608. </if>
  3609. </if>
  3610. <if test="level != null and level != ''">
  3611. and c.level = #{level}
  3612. </if>
  3613. <if test="doctorName != null and doctorName != ''">
  3614. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3615. </if>
  3616. <if test="userId!=null and userId !=''">
  3617. AND e.user_id = #{userId}
  3618. </if>
  3619. <if test="deptName != null and deptName != ''">
  3620. and a.beh_dept_name = #{deptName}
  3621. </if>
  3622. GROUP BY
  3623. a.doctor_id,
  3624. a.doctor_name
  3625. ) t1,
  3626. (
  3627. SELECT
  3628. a.doctor_id AS doctorId,
  3629. a.doctor_name AS doctorName,
  3630. count( * ) AS entryNum
  3631. FROM
  3632. med_behospital_info a,
  3633. med_qcresult_info c,
  3634. med_qcresult_detail d,
  3635. qc_cases_entry e,
  3636. sys_user_dept f
  3637. WHERE
  3638. a.is_deleted = 'N'
  3639. AND c.is_deleted = 'N'
  3640. AND d.is_deleted = 'N'
  3641. AND e.is_deleted = 'N'
  3642. AND f.is_deleted = 'N'
  3643. AND a.hospital_id = c.hospital_id
  3644. AND a.hospital_id = d.hospital_id
  3645. AND a.behospital_code = c.behospital_code
  3646. AND a.behospital_code = d.behospital_code
  3647. AND d.cases_id = e.cases_id
  3648. AND d.cases_entry_id = e.id
  3649. AND a.beh_dept_id = f.dept_id
  3650. <if test="isPlacefile != null and isPlacefile != ''">
  3651. and a.is_placefile = #{isPlacefile}
  3652. </if>
  3653. AND a.qc_type_id != 0
  3654. <if test="hospitalId != null and hospitalId != ''">
  3655. AND a.hospital_id = #{hospitalId}
  3656. </if>
  3657. <if test="isPlacefile != null and isPlacefile == 0">
  3658. <if test="lastStartDate != null and lastStartDate != ''">
  3659. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3660. </if>
  3661. <if test="lastEndDate != null and lastEndDate != ''">
  3662. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3663. </if>
  3664. </if>
  3665. <if test="isPlacefile != null and isPlacefile == 1">
  3666. <if test="lastStartDate != null and lastStartDate != ''">
  3667. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3668. </if>
  3669. <if test="lastEndDate != null and lastEndDate != ''">
  3670. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3671. </if>
  3672. </if>
  3673. <if test="level != null and level != ''">
  3674. and c.level = #{level}
  3675. </if>
  3676. <if test="doctorName != null and doctorName != ''">
  3677. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3678. </if>
  3679. <if test="userId!=null and userId !=''">
  3680. AND f.user_id = #{userId}
  3681. </if>
  3682. <if test="deptName != null and deptName != ''">
  3683. and a.beh_dept_name = #{deptName}
  3684. </if>
  3685. GROUP BY
  3686. a.doctor_id,
  3687. a.doctor_name
  3688. ) t2
  3689. WHERE
  3690. t1.doctorId = t2.doctorId
  3691. AND t1.doctorName = t2.doctorName
  3692. )m2
  3693. on
  3694. m1.doctorId = m2.doctorId
  3695. AND m1.doctorName = m2.doctorName
  3696. <if test="asc != null and asc !=''">
  3697. order by
  3698. <choose>
  3699. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3700. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3701. <when test='asc=="name"'>m1.doctorName asc</when>
  3702. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3703. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3704. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3705. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3706. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3707. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3708. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3709. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3710. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3711. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3712. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3713. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3714. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3715. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3716. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3717. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3718. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3719. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3720. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3721. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3722. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3723. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3724. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3725. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3726. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3727. <otherwise>doctorName asc</otherwise>
  3728. </choose>
  3729. </if>
  3730. <if test="desc != null and desc!=''">
  3731. order by
  3732. <choose>
  3733. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3734. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3735. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3736. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3737. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3738. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3739. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3740. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3741. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3742. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3743. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3744. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3745. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3746. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3747. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3748. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3749. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3750. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3751. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3752. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3753. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3754. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3755. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3756. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3757. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3758. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3759. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3760. <otherwise>doctorName desc</otherwise>
  3761. </choose>
  3762. </if>
  3763. </select>
  3764. <!-- 病案首页合格率占比-科室 -->
  3765. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3766. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3767. SELECT
  3768. t1.doctorId,
  3769. t1.doctorName,
  3770. t2.entryNum,
  3771. t1.mrNum,
  3772. t1.totleValue,
  3773. t1.averageValue,
  3774. t1.firstLevelNum,
  3775. t1.secondLevelNum,
  3776. t1.firstLevelPercent,
  3777. t1.secondLevelPercent,
  3778. t1.firstLevelPercentStr,
  3779. t1.secondLevelPercentStr,
  3780. t3.emptyNum,
  3781. t3.errorNum,
  3782. t3.entryTotleNum,
  3783. t3.emptyPercent,
  3784. t3.errorPercent,
  3785. t3.emptyPercentStr,
  3786. t3.errorPercentStr
  3787. FROM
  3788. (
  3789. SELECT
  3790. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3791. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3792. count( * ) AS mrNum,
  3793. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3794. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3795. sum( c.`level` = '合格' ) AS firstLevelNum,
  3796. sum( c.`level` = '不合格' ) AS secondLevelNum,
  3797. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  3798. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3799. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3800. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3801. FROM
  3802. med_behospital_info a,
  3803. med_qcresult_cases c,
  3804. sys_user_dept f
  3805. WHERE
  3806. a.is_deleted = 'N'
  3807. AND c.is_deleted = 'N'
  3808. AND f.is_deleted = 'N'
  3809. AND a.hospital_id = c.hospital_id
  3810. AND a.behospital_code = c.behospital_code
  3811. AND a.beh_dept_id = f.dept_id
  3812. AND c.cases_id = 243
  3813. <if test="isPlacefile != null and isPlacefile != ''">
  3814. and a.is_placefile = #{isPlacefile}
  3815. </if>
  3816. <![CDATA[AND a.qc_type_id <>0 ]]>
  3817. <if test="hospitalId != null and hospitalId != ''">
  3818. AND a.hospital_id = #{hospitalId}
  3819. </if>
  3820. <if test="isPlacefile != null and isPlacefile == 0">
  3821. <if test="startDate != null and startDate != ''">
  3822. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3823. </if>
  3824. <if test="endDate != null and endDate != ''">
  3825. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3826. </if>
  3827. </if>
  3828. <if test="isPlacefile != null and isPlacefile == 1">
  3829. <if test="startDate != null and startDate != ''">
  3830. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3831. </if>
  3832. <if test="endDate != null and endDate != ''">
  3833. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3834. </if>
  3835. </if>
  3836. <if test="level != null and level != ''">
  3837. and c.level = #{level}
  3838. </if>
  3839. <if test="name != null and name != ''">
  3840. <if test="name == '未知'">
  3841. and (a.doctor_name is null or a.doctor_name='')
  3842. </if>
  3843. <if test="name != '未知'">
  3844. and a.doctor_name like CONCAT('%',#{name},'%')
  3845. </if>
  3846. </if>
  3847. <if test="userId!=null and userId !=''">
  3848. AND f.user_id = #{userId}
  3849. </if>
  3850. <if test="deptName!=null and deptName !=''">
  3851. AND a.beh_dept_name = #{deptName}
  3852. </if>
  3853. <if test="name != null and name != ''">
  3854. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3855. </if>
  3856. GROUP BY
  3857. a.doctor_id,
  3858. a.doctor_name
  3859. ) t1,
  3860. (
  3861. SELECT
  3862. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3863. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3864. count( * ) AS entryNum
  3865. FROM
  3866. med_behospital_info a,
  3867. med_qcresult_cases c,
  3868. med_qcresult_detail d,
  3869. qc_cases_entry e,
  3870. sys_user_dept f
  3871. WHERE
  3872. a.is_deleted = 'N'
  3873. AND c.is_deleted = 'N'
  3874. AND d.is_deleted = 'N'
  3875. AND e.is_deleted = 'N'
  3876. AND f.is_deleted = 'N'
  3877. AND a.hospital_id = c.hospital_id
  3878. AND a.hospital_id = d.hospital_id
  3879. AND a.behospital_code = c.behospital_code
  3880. AND a.behospital_code = d.behospital_code
  3881. AND a.beh_dept_id = f.dept_id
  3882. AND c.cases_id = d.cases_id
  3883. AND d.cases_id = e.cases_id
  3884. AND d.cases_entry_id = e.id
  3885. AND c.cases_id = 243
  3886. <if test="isPlacefile != null and isPlacefile != ''">
  3887. and a.is_placefile = #{isPlacefile}
  3888. </if>
  3889. <![CDATA[AND a.qc_type_id <>0 ]]>
  3890. <if test="hospitalId != null and hospitalId != ''">
  3891. AND a.hospital_id = #{hospitalId}
  3892. </if>
  3893. <if test="isPlacefile != null and isPlacefile == 0">
  3894. <if test="startDate != null and startDate != ''">
  3895. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3896. </if>
  3897. <if test="endDate != null and endDate != ''">
  3898. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3899. </if>
  3900. </if>
  3901. <if test="isPlacefile != null and isPlacefile == 1">
  3902. <if test="startDate != null and startDate != ''">
  3903. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3904. </if>
  3905. <if test="endDate != null and endDate != ''">
  3906. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3907. </if>
  3908. </if>
  3909. <if test="level != null and level != ''">
  3910. and c.level = #{level}
  3911. </if>
  3912. <if test="name != null and name != ''">
  3913. <if test="name == '未知'">
  3914. and (a.doctor_name is null or a.doctor_name='')
  3915. </if>
  3916. <if test="name != '未知'">
  3917. and a.doctor_name like CONCAT('%',#{name},'%')
  3918. </if>
  3919. </if>
  3920. <if test="userId!=null and userId !=''">
  3921. AND f.user_id = #{userId}
  3922. </if>
  3923. <if test="deptName!=null and deptName !=''">
  3924. AND a.beh_dept_name = #{deptName}
  3925. </if>
  3926. <if test="name != null and name != ''">
  3927. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3928. </if>
  3929. GROUP BY
  3930. a.doctor_id,
  3931. a.doctor_name
  3932. ) t2,(
  3933. SELECT
  3934. h1.doctorId,
  3935. h1.doctorName,
  3936. h1.emptyNum,
  3937. h1.errorNum,
  3938. h1.mrNum,
  3939. h2.entryNum,
  3940. h1.mrNum * h2.entryNum AS entryTotleNum,
  3941. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3942. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3943. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3944. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3945. FROM
  3946. (
  3947. SELECT
  3948. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3949. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3950. sum( d.rule_type = 1 ) AS emptyNum,
  3951. sum( d.rule_type = 2 ) AS errorNum,
  3952. count( DISTINCT a.behospital_code ) AS mrNum
  3953. FROM
  3954. med_behospital_info a,
  3955. med_qcresult_cases b,
  3956. med_qcresult_detail c,
  3957. qc_cases_entry d,
  3958. sys_user_dept e
  3959. WHERE
  3960. a.is_deleted = 'N'
  3961. AND b.is_deleted = 'N'
  3962. AND c.is_deleted = 'N'
  3963. AND d.is_deleted = 'N'
  3964. AND e.is_deleted = 'N'
  3965. AND a.hospital_id = b.hospital_id
  3966. AND a.hospital_id = c.hospital_id
  3967. AND a.hospital_id = e.hospital_id
  3968. AND a.behospital_code = b.behospital_code
  3969. AND a.behospital_code = c.behospital_code
  3970. AND b.cases_id = c.cases_id
  3971. AND c.cases_id = d.cases_id
  3972. AND c.cases_entry_id = d.id
  3973. AND a.beh_dept_id = e.dept_id
  3974. <if test="isPlacefile != null and isPlacefile != ''">
  3975. and a.is_placefile = #{isPlacefile}
  3976. </if>
  3977. AND d.cases_id = 243
  3978. <![CDATA[AND a.qc_type_id <>0 ]]>
  3979. <if test="hospitalId != null and hospitalId != ''">
  3980. AND a.hospital_id = #{hospitalId}
  3981. </if>
  3982. <if test="isPlacefile != null and isPlacefile == 0">
  3983. <if test="startDate != null and startDate != ''">
  3984. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3985. </if>
  3986. <if test="endDate != null and endDate != ''">
  3987. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3988. </if>
  3989. </if>
  3990. <if test="isPlacefile != null and isPlacefile == 1">
  3991. <if test="startDate != null and startDate != ''">
  3992. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3993. </if>
  3994. <if test="endDate != null and endDate != ''">
  3995. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3996. </if>
  3997. </if>
  3998. <if test="level != null and level != ''">
  3999. and b.level = #{level}
  4000. </if>
  4001. <if test="name != null and name != ''">
  4002. <if test="name == '未知'">
  4003. and (a.doctor_name is null or a.doctor_name='')
  4004. </if>
  4005. <if test="name != '未知'">
  4006. and a.doctor_name like CONCAT('%',#{name},'%')
  4007. </if>
  4008. </if>
  4009. <if test="userId!=null and userId !=''">
  4010. AND e.user_id = #{userId}
  4011. </if>
  4012. <if test="deptName!=null and deptName !=''">
  4013. AND a.beh_dept_name = #{deptName}
  4014. </if>
  4015. <if test="name != null and name != ''">
  4016. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4017. </if>
  4018. GROUP BY
  4019. a.doctor_id,
  4020. a.doctor_name
  4021. ) h1,(
  4022. SELECT
  4023. count(*) AS entryNum
  4024. FROM
  4025. qc_cases_entry
  4026. WHERE
  4027. is_deleted = 'N'
  4028. AND cases_id = 243
  4029. ) h2
  4030. ) t3
  4031. WHERE
  4032. t1.doctorId = t2.doctorId
  4033. AND t1.doctorId = t3.doctorId
  4034. AND t1.doctorName = t2.doctorName
  4035. AND t1.doctorName = t3.doctorName
  4036. <if test="asc != null and asc !=''">
  4037. order by
  4038. <choose>
  4039. <when test='asc=="doctorId"'>doctorId asc</when>
  4040. <when test='asc=="doctorName"'>doctorName asc</when>
  4041. <when test='asc=="entryNum"'>entryNum asc</when>
  4042. <when test='asc=="mrNum"'>mrNum asc</when>
  4043. <when test='asc=="totleValue"'>totleValue asc</when>
  4044. <when test='asc=="averageValue"'>averageValue asc</when>
  4045. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4046. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4047. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4048. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4049. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4050. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4051. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4052. <when test='asc=="errorNum"'>errorNum asc</when>
  4053. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4054. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4055. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4056. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4057. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4058. <otherwise>doctorName asc</otherwise>
  4059. </choose>
  4060. </if>
  4061. <if test="desc != null and desc!=''">
  4062. order by
  4063. <choose>
  4064. <when test='desc=="doctorId"'>doctorId desc</when>
  4065. <when test='desc=="doctorName"'>doctorName desc</when>
  4066. <when test='desc=="entryNum"'>entryNum desc</when>
  4067. <when test='desc=="mrNum"'>mrNum desc</when>
  4068. <when test='desc=="totleValue"'>totleValue desc</when>
  4069. <when test='desc=="averageValue"'>averageValue desc</when>
  4070. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4071. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4072. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4073. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4074. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4075. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4076. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4077. <when test='desc=="errorNum"'>errorNum desc</when>
  4078. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4079. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4080. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4081. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4082. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4083. <otherwise>doctorName desc</otherwise>
  4084. </choose>
  4085. </if>
  4086. </select>
  4087. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4088. <result column="behDeptName" property="behDeptName"/>
  4089. <result column="wardName" property="wardName"/>
  4090. <result column="medoup_name" property="medoupName"/>
  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="fileCode" property="fileCode"/>
  4119. <result column="behospitalDate" property="behospitalDate"/>
  4120. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4121. <result column="score" property="score"/>
  4122. <result column="scoreBn" property="scoreBn"/>
  4123. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4124. <result column="caseName" property="caseName"/>
  4125. <collection property="exportExcelMsgDTOS"
  4126. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4127. <result column="msg" property="msg"/>
  4128. </collection>
  4129. </collection>
  4130. </collection>
  4131. </resultMap>
  4132. <select id="exportExcel" resultMap="ExportExcelMap">
  4133. SELECT DISTINCT
  4134. t1.beh_dept_name AS behDeptName,
  4135. t1.beh_doctor_name AS doctorName,
  4136. t1.`name` AS patName,
  4137. t1.behospital_code AS behospitalCode,
  4138. t1.behospital_date AS behospitalDate,
  4139. t1.leave_hospital_date AS leaveHospitalDate,
  4140. t2.score_res AS score,
  4141. "1" AS avgScore,
  4142. t4.`name` AS caseName,
  4143. t3.msg AS msg
  4144. FROM
  4145. med_behospital_info t1,
  4146. med_qcresult_info t2,
  4147. med_qcresult_detail t3,
  4148. qc_cases t4
  4149. WHERE
  4150. t1.is_deleted = 'N'
  4151. AND t2.is_deleted = 'N'
  4152. AND t3.is_deleted = 'N'
  4153. AND t4.is_deleted = 'N'
  4154. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4155. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4156. AND t1.hospital_id = t2.hospital_id
  4157. AND t1.behospital_code = t2.behospital_code
  4158. AND t1.hospital_id = t3.hospital_id
  4159. AND t1.behospital_code = t3.behospital_code
  4160. AND t3.cases_id = t4.id
  4161. ORDER BY
  4162. t1.beh_dept_id ASC,
  4163. t1.leave_hospital_date DESC,
  4164. t1.behospital_code ASC,
  4165. t4.`name` ASC
  4166. </select>
  4167. <!-- 质控评分导出到excel-->
  4168. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4169. SELECT * FROM (
  4170. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4171. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4172. g.check_type AS ch_type,
  4173. h.check_type AS mr_type,
  4174. g.check_name AS ch_name,
  4175. h.check_name AS mr_name,
  4176. g.check_time AS ch_time,
  4177. h.check_time AS mr_time
  4178. FROM (
  4179. SELECT
  4180. t1.behDeptId,
  4181. t1.behDeptName,
  4182. t1.doctorName,
  4183. t1.patName,
  4184. t1.fileCode,
  4185. t1.behospitalCode,
  4186. t1.hospitalId,
  4187. t1.behospitalDate,
  4188. t1.leaveHospitalDate,
  4189. t1.score,
  4190. <if test="radioCheck !=null and radioCheck == 1">
  4191. t1.msg,
  4192. t1.caseName,
  4193. </if>
  4194. t1.scoreBn,
  4195. t2.avgScore
  4196. FROM
  4197. (
  4198. SELECT
  4199. a.doctor_name AS doctorName,
  4200. a.`name` AS patName,
  4201. a.`file_code` AS fileCode,
  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="ExportExcelMapByDept" parameterType="com.diagbot.vo.ExportQcresultVO">
  4393. SELECT * FROM (
  4394. SELECT tp.*,t3.name as medoup_name,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.doctor_id as doctorId,
  4408. t1.patName,
  4409. t1.wardName,
  4410. t1.behospitalCode,
  4411. t1.fileCode,
  4412. t1.hospitalId,
  4413. t1.behospitalDate,
  4414. t1.leaveHospitalDate,
  4415. t1.score,
  4416. t2.avgScore,
  4417. <if test="radioCheck !=null and radioCheck == 1">
  4418. c.msg AS msg,
  4419. t1.caseName,
  4420. </if>
  4421. e.score_res as scoreBn
  4422. FROM
  4423. (
  4424. SELECT
  4425. a.doctor_name AS doctorName,
  4426. a.doctor_id,
  4427. a.`name` AS patName,
  4428. a.ward_name as wardName,
  4429. a.file_code as fileCode,
  4430. a.behospital_code AS behospitalCode,
  4431. a.hospital_id AS hospital_id,
  4432. d.id,
  4433. a.behospital_date AS behospitalDate,
  4434. a.leave_hospital_date AS leaveHospitalDate,
  4435. b.score_res AS score,
  4436. <if test="radioCheck !=null and radioCheck == 1">
  4437. d.NAME AS caseName,
  4438. </if>
  4439. a.beh_dept_id AS behDeptId,
  4440. a.beh_dept_name AS behDeptName,
  4441. a.hospital_id AS hospitalId
  4442. FROM
  4443. med_behospital_info a,
  4444. med_qcresult_info b,
  4445. qc_cases d,
  4446. sys_user_dept e
  4447. WHERE
  4448. a.is_deleted = 'N'
  4449. AND b.is_deleted = 'N'
  4450. AND d.is_deleted = 'N'
  4451. AND e.is_deleted = 'N'
  4452. AND a.hospital_id = b.hospital_id
  4453. AND a.hospital_id = e.hospital_id
  4454. AND a.behospital_code = b.behospital_code
  4455. AND a.beh_dept_id = e.dept_id
  4456. <if test="diagnose != null and diagnose != ''">
  4457. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4458. </if>
  4459. <if test="isPlacefile != null and isPlacefile != ''">
  4460. and a.is_placefile = #{isPlacefile}
  4461. </if>
  4462. <if test="wardName != null and wardName != ''">
  4463. AND a.ward_name = #{wardName}
  4464. </if>
  4465. <![CDATA[AND a.qc_type_id <>0 ]]>
  4466. <if test="hospitalId != null and hospitalId != ''">
  4467. AND a.hospital_id = #{hospitalId}
  4468. </if>
  4469. <if test="userId != null ">
  4470. AND e.user_id = #{userId}
  4471. </if>
  4472. <if test="behosDateStart != null">
  4473. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4474. </if>
  4475. <if test="behosDateEnd != null">
  4476. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4477. </if>
  4478. <if test="leaveHosDateStart != null ">
  4479. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4480. </if>
  4481. <if test="leaveHosDateEnd != null ">
  4482. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4483. </if>
  4484. <if test="behospitalCode != null and behospitalCode != ''">
  4485. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4486. </if>
  4487. <if test="level != null and level != ''">
  4488. AND b.level = #{level}
  4489. </if>
  4490. <if test="doctorName != null and doctorName != ''">
  4491. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4492. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4493. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4494. </if>
  4495. <if test="doctorCode != null and doctorCode != ''">
  4496. AND a.doctor_id = #{doctorCode}
  4497. </if>
  4498. <if test="deptName != null and deptName != ''">
  4499. and a.beh_dept_name = #{deptName}
  4500. </if>
  4501. <if test="deptId != null and deptId != ''">
  4502. and a.beh_dept_id = #{deptId}
  4503. </if>
  4504. <if test="name != null and name != ''">
  4505. AND a.name like CONCAT('%',#{name},'%')
  4506. </if>
  4507. ) t1
  4508. LEFT JOIN med_qcresult_cases e
  4509. on t1.behospitalCode = e.behospital_code
  4510. and t1.hospital_id = e.hospital_id
  4511. AND e.is_deleted = 'N'
  4512. and e.cases_id = 243
  4513. LEFT JOIN med_qcresult_detail c
  4514. on t1.behospitalCode = c.behospital_code
  4515. and t1.hospital_id = c.hospital_id
  4516. AND c.cases_id = t1.id
  4517. AND c.is_deleted = 'N',
  4518. (
  4519. SELECT
  4520. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4521. a.beh_dept_id AS behDeptId,
  4522. a.beh_dept_name AS behDeptName,
  4523. a.doctor_id AS doctorId,
  4524. a.doctor_name AS doctorName
  4525. FROM
  4526. med_behospital_info a,
  4527. med_qcresult_info b,
  4528. sys_user_dept c
  4529. WHERE
  4530. a.is_deleted = 'N'
  4531. AND b.is_deleted = 'N'
  4532. AND c.is_deleted = 'N'
  4533. AND a.hospital_id = b.hospital_id
  4534. AND a.hospital_id = c.hospital_id
  4535. AND a.behospital_code = b.behospital_code
  4536. AND a.beh_dept_id = c.dept_id
  4537. <if test="diagnose != null and diagnose != ''">
  4538. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4539. </if>
  4540. <if test="wardName != null and wardName != ''">
  4541. AND a.ward_name = #{wardName}
  4542. </if>
  4543. <if test="isPlacefile != null and isPlacefile != ''">
  4544. and a.is_placefile = #{isPlacefile}
  4545. </if>
  4546. <![CDATA[AND a.qc_type_id <>0 ]]>
  4547. <if test="hospitalId != null and hospitalId != ''">
  4548. AND a.hospital_id = #{hospitalId}
  4549. </if>
  4550. <if test="userId != null ">
  4551. AND c.user_id = #{userId}
  4552. </if>
  4553. <if test="behosDateStart != null">
  4554. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4555. </if>
  4556. <if test="behosDateEnd != null">
  4557. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4558. </if>
  4559. <if test="leaveHosDateStart != null ">
  4560. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4561. </if>
  4562. <if test="leaveHosDateEnd != null ">
  4563. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4564. </if>
  4565. <if test="behospitalCode != null and behospitalCode != ''">
  4566. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4567. </if>
  4568. <if test="level != null and level != ''">
  4569. AND b.level = #{level}
  4570. </if>
  4571. <if test="doctorName != null and doctorName != ''">
  4572. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4573. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4574. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4575. </if>
  4576. <if test="doctorCode != null and doctorCode != ''">
  4577. and a.doctor_id = #{doctorCode}
  4578. </if>
  4579. <if test="deptName != null and deptName != ''">
  4580. and a.beh_dept_name = #{deptName}
  4581. </if>
  4582. <if test="deptId != null and deptId != ''">
  4583. and a.beh_dept_id = #{deptId}
  4584. </if>
  4585. <if test="name != null and name != ''">
  4586. AND a.name like CONCAT('%',#{name},'%')
  4587. </if>
  4588. GROUP BY
  4589. a.beh_dept_id,
  4590. a.beh_dept_name,
  4591. a.doctor_id,
  4592. a.doctor_name
  4593. ) t2
  4594. WHERE
  4595. t1.behDeptId = t2.behDeptId
  4596. AND t1.behDeptName = t2.behDeptName
  4597. AND t1.doctor_id = t2.doctorId
  4598. AND t1.doctorName = t2.doctorName
  4599. ORDER BY
  4600. t1.behDeptName,
  4601. t1.doctorName,
  4602. t1.patName,
  4603. <if test="radioCheck !=null and radioCheck == 1">
  4604. t1.caseName,
  4605. </if>
  4606. t1.behospitalCode
  4607. )tp
  4608. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4609. ON tp.behospitalCode = g.behospital_code
  4610. AND tp.hospitalId = g.hospital_id
  4611. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4612. ON tp.behospitalCode = h.behospital_code
  4613. AND tp.hospitalId = h.hospital_id
  4614. LEFT JOIN bas_doctor_info t2 ON tp.doctorId = t2.doctor_id
  4615. AND tp.hospitalId = t2.hospital_id
  4616. AND t2.is_deleted = 'N'
  4617. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  4618. AND t3.is_deleted = 'N'
  4619. where 1=1
  4620. <if test="medoupName != null and medoupName != ''">
  4621. AND t3.name = #{medoupName}
  4622. </if>
  4623. ) tu
  4624. WHERE tu.behospitalCode IS NOT NULL
  4625. <if test="checkStatus != null ">
  4626. and tu.check_status = #{checkStatus}
  4627. </if>
  4628. <if test="mrStatus != null ">
  4629. AND tu.mr_status = #{mrStatus}
  4630. </if>
  4631. <if test="chName != null and chName !=''">
  4632. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4633. </if>
  4634. <if test="mrName != null and mrName !=''">
  4635. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4636. </if>
  4637. <if test="chTimeStart != null">
  4638. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4639. </if>
  4640. <if test="chTimeEnd != null">
  4641. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4642. </if>
  4643. <if test="mrTimeStart != null">
  4644. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4645. </if>
  4646. <if test="mrTimeEnd != null">
  4647. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4648. </if>
  4649. </select>
  4650. <!-- 个人质控评分导出到excel-->
  4651. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4652. SELECT * FROM (
  4653. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4654. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4655. g.check_type AS ch_type,
  4656. h.check_type AS mr_type,
  4657. g.check_name AS ch_name,
  4658. h.check_name AS mr_name,
  4659. g.check_time AS ch_time,
  4660. h.check_time AS mr_time
  4661. FROM (
  4662. SELECT
  4663. t1.behDeptId,
  4664. t1.behDeptName,
  4665. t1.doctorName,
  4666. t1.patName,
  4667. t1.behospitalCode,
  4668. t1.hospitalId,
  4669. t1.behospitalDate,
  4670. t1.leaveHospitalDate,
  4671. t1.score,
  4672. t2.avgScore,
  4673. <if test="radioCheck !=null and radioCheck == 1">
  4674. t1.msg,
  4675. t1.caseName,
  4676. </if>
  4677. e.score_res as scoreBn
  4678. FROM
  4679. (
  4680. SELECT
  4681. a.doctor_name AS doctorName,
  4682. a.beh_doctor_name,
  4683. a.director_doctor_name,
  4684. a.`name` AS patName,
  4685. a.behospital_code AS behospitalCode,
  4686. a.behospital_date AS behospitalDate,
  4687. a.leave_hospital_date AS leaveHospitalDate,
  4688. b.score_res AS score,
  4689. <if test="radioCheck !=null and radioCheck == 1">
  4690. c.msg AS msg,
  4691. d.NAME AS caseName,
  4692. </if>
  4693. a.beh_dept_id AS behDeptId,
  4694. a.beh_dept_name AS behDeptName,
  4695. a.hospital_id AS hospitalId
  4696. FROM
  4697. med_behospital_info a,
  4698. med_qcresult_info b,
  4699. med_qcresult_detail c,
  4700. qc_cases d,
  4701. sys_user u,
  4702. sys_user_hospital uh
  4703. WHERE
  4704. a.is_deleted = 'N'
  4705. AND b.is_deleted = 'N'
  4706. AND c.is_deleted = 'N'
  4707. AND d.is_deleted = 'N'
  4708. AND u.is_deleted = 'N'
  4709. AND uh.is_deleted = 'N'
  4710. AND a.hospital_id = b.hospital_id
  4711. AND a.hospital_id = c.hospital_id
  4712. AND a.behospital_code = b.behospital_code
  4713. AND a.behospital_code = c.behospital_code
  4714. AND u.id = uh.user_id
  4715. AND a.hospital_id = uh.hospital_id
  4716. <if test="userId != null and userId != ''">
  4717. AND u.id = #{userId}
  4718. </if>
  4719. <if test="isPlacefile != null and isPlacefile != ''">
  4720. and a.is_placefile = #{isPlacefile}
  4721. </if>
  4722. <![CDATA[AND a.qc_type_id <>0 ]]>
  4723. <if test="hospitalId != null and hospitalId != ''">
  4724. AND a.hospital_id = #{hospitalId}
  4725. </if>
  4726. <if test="diagnose != null and diagnose != ''">
  4727. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4728. </if>
  4729. <if test="behosDateStart != null">
  4730. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4731. </if>
  4732. <if test="behosDateEnd != null">
  4733. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4734. </if>
  4735. <if test="leaveHosDateStart != null ">
  4736. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4737. </if>
  4738. <if test="leaveHosDateEnd != null ">
  4739. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4740. </if>
  4741. <if test="behospitalCode != null and behospitalCode != ''">
  4742. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4743. </if>
  4744. <if test="level != null and level != ''">
  4745. AND b.level = #{level}
  4746. </if>
  4747. <if test="doctorName != null and doctorName != ''">
  4748. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4749. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4750. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4751. </if>
  4752. <if test="doctorCode != null and doctorCode != ''">
  4753. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4754. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4755. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4756. </if>
  4757. <if test="deptId != null and deptId != ''">
  4758. AND a.beh_dept_id = #{deptId}
  4759. </if>
  4760. <if test="deptName != null and deptName != ''">
  4761. and a.beh_dept_name = #{deptName}
  4762. </if>
  4763. <if test="name != null and name != ''">
  4764. AND a.name like CONCAT('%',#{name},'%')
  4765. </if>
  4766. ) t1 LEFT JOIN med_qcresult_cases e
  4767. on t1.behospitalCode = e.behospital_code
  4768. and t1.hospitalId = e.hospital_id
  4769. AND e.is_deleted = 'N'
  4770. and e.cases_id = 243,
  4771. (
  4772. SELECT
  4773. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4774. a.beh_dept_id AS behDeptId,
  4775. a.beh_dept_name AS behDeptName
  4776. FROM
  4777. med_behospital_info a,
  4778. med_qcresult_info b,
  4779. sys_user u,
  4780. sys_user_hospital uh
  4781. WHERE
  4782. a.is_deleted = 'N'
  4783. AND b.is_deleted = 'N'
  4784. AND u.is_deleted = 'N'
  4785. AND uh.is_deleted = 'N'
  4786. AND a.hospital_id = b.hospital_id
  4787. AND a.behospital_code = b.behospital_code
  4788. AND u.id = uh.user_id
  4789. AND a.hospital_id = uh.hospital_id
  4790. and (a.doctor_name = u.linkman
  4791. or a.beh_doctor_name = u.linkman
  4792. or a.director_doctor_name = u.linkman)
  4793. <if test="userId != null and userId != ''">
  4794. AND u.id = #{userId}
  4795. </if>
  4796. <if test="diagnose != null and diagnose != ''">
  4797. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4798. </if>
  4799. <if test="isPlacefile != null and isPlacefile != ''">
  4800. and a.is_placefile = #{isPlacefile}
  4801. </if>
  4802. <![CDATA[AND a.qc_type_id <>0 ]]>
  4803. <if test="hospitalId != null and hospitalId != ''">
  4804. AND a.hospital_id = #{hospitalId}
  4805. </if>
  4806. <if test="behosDateStart != null">
  4807. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4808. </if>
  4809. <if test="behosDateEnd != null">
  4810. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4811. </if>
  4812. <if test="leaveHosDateStart != null ">
  4813. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4814. </if>
  4815. <if test="leaveHosDateEnd != null ">
  4816. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4817. </if>
  4818. <if test="behospitalCode != null and behospitalCode != ''">
  4819. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4820. </if>
  4821. <if test="level != null and level != ''">
  4822. AND b.level = #{level}
  4823. </if>
  4824. <if test="doctorName != null and doctorName != ''">
  4825. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4826. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4827. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4828. </if>
  4829. <if test="doctorCode != null and doctorCode != ''">
  4830. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4831. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4832. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4833. </if>
  4834. <if test="deptId != null and deptId != ''">
  4835. AND a.beh_dept_id = #{deptId}
  4836. </if>
  4837. <if test="deptName != null and deptName != ''">
  4838. and a.beh_dept_name = #{deptName}
  4839. </if>
  4840. <if test="name != null and name != ''">
  4841. AND a.name like CONCAT('%',#{name},'%')
  4842. </if>
  4843. ) t2
  4844. WHERE
  4845. t1.behDeptId = t2.behDeptId
  4846. AND t1.behDeptName = t2.behDeptName
  4847. ORDER BY
  4848. t1.behDeptName,
  4849. t1.doctorName,
  4850. t1.patName,
  4851. <if test="radioCheck !=null and radioCheck == 1">
  4852. t1.caseName,
  4853. </if>
  4854. t1.behospitalCode
  4855. )tp
  4856. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4857. ON tp.behospitalCode = g.behospital_code
  4858. AND tp.hospitalId = g.hospital_id
  4859. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4860. ON tp.behospitalCode = h.behospital_code
  4861. AND tp.hospitalId = h.hospital_id
  4862. ) tu
  4863. WHERE tu.behospitalCode IS NOT NULL
  4864. <if test="checkStatus != null ">
  4865. and tu.check_status = #{checkStatus}
  4866. </if>
  4867. <if test="mrStatus != null ">
  4868. AND tu.mr_status = #{mrStatus}
  4869. </if>
  4870. <if test="chName != null and chName !=''">
  4871. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4872. </if>
  4873. <if test="mrName != null and mrName !=''">
  4874. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4875. </if>
  4876. <if test="chTimeStart != null">
  4877. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4878. </if>
  4879. <if test="chTimeEnd != null">
  4880. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4881. </if>
  4882. <if test="mrTimeStart != null">
  4883. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4884. </if>
  4885. <if test="mrTimeEnd != null">
  4886. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4887. </if>
  4888. </select>
  4889. <!-- 医疗组质控评分导出到excel-->
  4890. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4891. SELECT * FROM (
  4892. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4893. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4894. g.check_type AS ch_type,
  4895. h.check_type AS mr_type,
  4896. g.check_name AS ch_name,
  4897. h.check_name AS mr_name,
  4898. g.check_time AS ch_time,
  4899. h.check_time AS mr_time
  4900. FROM (
  4901. SELECT
  4902. t1.behDeptId,
  4903. t1.behDeptName,
  4904. t1.doctorName,
  4905. t1.patName,
  4906. t1.behospitalCode,
  4907. t1.hospitalId,
  4908. t1.behospitalDate,
  4909. t1.leaveHospitalDate,
  4910. t1.score,
  4911. t2.avgScore,
  4912. <if test="radioCheck !=null and radioCheck == 1">
  4913. t1.msg,
  4914. t1.caseName,
  4915. </if>
  4916. e.score_res as scoreBn
  4917. FROM
  4918. (
  4919. SELECT
  4920. a.doctor_name AS doctorName,
  4921. a.`name` AS patName,
  4922. a.behospital_code AS behospitalCode,
  4923. a.behospital_date AS behospitalDate,
  4924. a.leave_hospital_date AS leaveHospitalDate,
  4925. b.score_res AS score,
  4926. <if test="radioCheck !=null and radioCheck == 1">
  4927. c.msg AS msg,
  4928. d.NAME AS caseName,
  4929. </if>
  4930. a.beh_dept_id AS behDeptId,
  4931. a.beh_dept_name AS behDeptName,
  4932. a.hospital_id AS hospitalId
  4933. FROM
  4934. med_behospital_info a,
  4935. med_qcresult_info b,
  4936. med_qcresult_detail c,
  4937. qc_cases d
  4938. WHERE
  4939. a.is_deleted = 'N'
  4940. AND b.is_deleted = 'N'
  4941. AND c.is_deleted = 'N'
  4942. AND d.is_deleted = 'N'
  4943. AND a.hospital_id = b.hospital_id
  4944. AND a.hospital_id = c.hospital_id
  4945. AND a.behospital_code = b.behospital_code
  4946. AND a.behospital_code = c.behospital_code
  4947. AND c.cases_id = d.id
  4948. <if test="isPlacefile != null and isPlacefile != ''">
  4949. and a.is_placefile = #{isPlacefile}
  4950. </if>
  4951. AND a.doctor_id in
  4952. (SELECT doctor_id FROM `bas_doctor_info`
  4953. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4954. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4955. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4956. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4957. and c1.username = c3.doctor_id
  4958. and c2.hospital_id = #{hospitalId}
  4959. and c1.id = #{userId}
  4960. ))
  4961. <![CDATA[AND a.qc_type_id <>0 ]]>
  4962. <if test="hospitalId != null and hospitalId != ''">
  4963. AND a.hospital_id = #{hospitalId}
  4964. </if>
  4965. <if test="diagnose != null and diagnose != ''">
  4966. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4967. </if>
  4968. <if test="behosDateStart != null">
  4969. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4970. </if>
  4971. <if test="behosDateEnd != null">
  4972. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4973. </if>
  4974. <if test="leaveHosDateStart != null ">
  4975. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4976. </if>
  4977. <if test="leaveHosDateEnd != null ">
  4978. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4979. </if>
  4980. <if test="behospitalCode != null and behospitalCode != ''">
  4981. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4982. </if>
  4983. <if test="level != null and level != ''">
  4984. AND b.level = #{level}
  4985. </if>
  4986. <if test="doctorName != null and doctorName != ''">
  4987. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4988. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4989. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4990. </if>
  4991. <if test="doctorCode != null and doctorCode != ''">
  4992. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4993. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4994. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4995. </if>
  4996. <if test="deptId != null and deptId != ''">
  4997. AND a.beh_dept_id = #{deptId}
  4998. </if>
  4999. <if test="name != null and name != ''">
  5000. AND a.name like CONCAT('%',#{name},'%')
  5001. </if>
  5002. ) t1 LEFT JOIN med_qcresult_cases e
  5003. on t1.behospitalCode = e.behospital_code
  5004. and t1.hospitalId = e.hospital_id
  5005. AND e.is_deleted = 'N'
  5006. and e.cases_id = 243,
  5007. (
  5008. SELECT
  5009. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5010. a.beh_dept_id AS behDeptId,
  5011. a.beh_dept_name AS behDeptName
  5012. FROM
  5013. med_behospital_info a,
  5014. med_qcresult_info b
  5015. WHERE
  5016. a.is_deleted = 'N'
  5017. AND a.doctor_id in
  5018. (SELECT doctor_id FROM `bas_doctor_info`
  5019. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5020. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5021. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5022. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5023. and c1.username = c3.doctor_id
  5024. and c2.hospital_id = #{hospitalId}
  5025. and c1.id = #{userId}
  5026. ))
  5027. AND b.is_deleted = 'N'
  5028. AND a.hospital_id = b.hospital_id
  5029. AND a.behospital_code = b.behospital_code
  5030. <if test="diagnose != null and diagnose != ''">
  5031. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5032. </if>
  5033. <if test="isPlacefile != null and isPlacefile != ''">
  5034. and a.is_placefile = #{isPlacefile}
  5035. </if>
  5036. <![CDATA[AND a.qc_type_id <>0 ]]>
  5037. <if test="hospitalId != null and hospitalId != ''">
  5038. AND a.hospital_id = #{hospitalId}
  5039. </if>
  5040. <if test="behosDateStart != null">
  5041. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5042. </if>
  5043. <if test="behosDateEnd != null">
  5044. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5045. </if>
  5046. <if test="leaveHosDateStart != null ">
  5047. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5048. </if>
  5049. <if test="leaveHosDateEnd != null ">
  5050. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5051. </if>
  5052. <if test="behospitalCode != null and behospitalCode != ''">
  5053. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5054. </if>
  5055. <if test="level != null and level != ''">
  5056. AND b.level = #{level}
  5057. </if>
  5058. <if test="doctorName != null and doctorName != ''">
  5059. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5060. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5061. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5062. </if>
  5063. <if test="doctorCode != null and doctorCode != ''">
  5064. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5065. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5066. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5067. </if>
  5068. <if test="deptId != null and deptId != ''">
  5069. AND a.beh_dept_id = #{deptId}
  5070. </if>
  5071. <if test="name != null and name != ''">
  5072. AND a.name like CONCAT('%',#{name},'%')
  5073. </if>
  5074. GROUP BY
  5075. a.beh_dept_id,
  5076. a.beh_dept_name
  5077. ) t2
  5078. WHERE
  5079. t1.behDeptId = t2.behDeptId
  5080. AND t1.behDeptName = t2.behDeptName
  5081. ORDER BY
  5082. t1.behDeptName,
  5083. t1.doctorName,
  5084. t1.patName,
  5085. <if test="radioCheck !=null and radioCheck == 1">
  5086. t1.caseName,
  5087. </if>
  5088. t1.behospitalCode
  5089. )tp
  5090. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5091. ON tp.behospitalCode = g.behospital_code
  5092. AND tp.hospitalId = g.hospital_id
  5093. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5094. ON tp.behospitalCode = h.behospital_code
  5095. AND tp.hospitalId = h.hospital_id
  5096. ) tu
  5097. WHERE tu.behospitalCode IS NOT NULL
  5098. <if test="checkStatus != null ">
  5099. and tu.check_status = #{checkStatus}
  5100. </if>
  5101. <if test="mrStatus != null ">
  5102. AND tu.mr_status = #{mrStatus}
  5103. </if>
  5104. <if test="chName != null and chName !=''">
  5105. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5106. </if>
  5107. <if test="mrName != null and mrName !=''">
  5108. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5109. </if>
  5110. <if test="chTimeStart != null">
  5111. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5112. </if>
  5113. <if test="chTimeEnd != null">
  5114. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5115. </if>
  5116. <if test="mrTimeStart != null">
  5117. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5118. </if>
  5119. <if test="mrTimeEnd != null">
  5120. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5121. </if>
  5122. </select>
  5123. <!-- 条目缺陷质控评分页(内页)-->
  5124. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5125. SELECT t.*
  5126. FROM
  5127. (SELECT DISTINCT
  5128. t1.hospital_id AS hospitalId,
  5129. t1.behospital_code AS behospitalCode,
  5130. t1.bed_code AS bedCode,
  5131. t1.LEVEL AS LEVEL,
  5132. t1.grade_type AS gradeType,
  5133. t1.score_res AS scoreRes,
  5134. t1.scoreBn,
  5135. t1.NAME AS NAME,
  5136. t1.sex AS sex,
  5137. t1.beh_dept_id AS behDeptId,
  5138. t1.beh_dept_name AS behDeptName,
  5139. t1.doctor_id AS doctorId,
  5140. t1.doctor_name AS doctorName,
  5141. t1.beh_doctor_id AS behDoctorId,
  5142. t1.beh_doctor_name AS behDoctorName,
  5143. t1.director_doctor_id AS directorDoctorId,
  5144. t1.director_doctor_name AS directorDoctorName,
  5145. t1.birthday AS birthday,
  5146. t1.behospital_date AS behospitalDate,
  5147. t1.leave_hospital_date AS leaveHospitalDate,
  5148. t1.placefile_date AS placefileDate,
  5149. t1.gmt_create AS gradeTime,
  5150. t1.diagnose,
  5151. t1.ward_name AS wardName,
  5152. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5153. t1.file_code AS fileCode,
  5154. t1.checkStatus,
  5155. t1.mrStatus,
  5156. t1.chName,
  5157. t1.mrName,
  5158. t1.chTime,
  5159. t1.mrTime
  5160. FROM
  5161. (
  5162. SELECT DISTINCT
  5163. tt1.*
  5164. FROM
  5165. (SELECT
  5166. be.*,
  5167. ifnull(mci.status,0) AS checkStatus,
  5168. ifnull(hm_mci.status,0) AS mrStatus,
  5169. mci.check_name as chName,
  5170. e.score_res as scoreBn,
  5171. hm_mci.check_name as mrName,
  5172. mci.gmt_create as chTime,
  5173. hm_mci.gmt_create as mrTime
  5174. FROM
  5175. (
  5176. SELECT DISTINCT
  5177. a.hospital_id,
  5178. a.behospital_code,
  5179. a.bed_code,
  5180. a.file_code,
  5181. b.LEVEL,
  5182. b.grade_type,
  5183. b.score_res,
  5184. a.NAME,
  5185. a.sex,
  5186. a.beh_dept_id,
  5187. a.beh_dept_name,
  5188. a.birthday,
  5189. a.behospital_date,
  5190. a.leave_hospital_date,
  5191. a.doctor_id,
  5192. a.doctor_name,
  5193. a.beh_doctor_id,
  5194. a.beh_doctor_name,
  5195. a.director_doctor_id,
  5196. a.director_doctor_name,
  5197. a.diagnose,
  5198. a.placefile_date,
  5199. a.ward_name,
  5200. b.gmt_create
  5201. FROM
  5202. med_behospital_info a,
  5203. med_qcresult_info b,
  5204. med_qcresult_detail c,
  5205. qc_cases_entry d
  5206. WHERE
  5207. a.is_deleted = 'N'
  5208. AND b.is_deleted = 'N'
  5209. AND c.is_deleted = 'N'
  5210. AND d.is_deleted = 'N'
  5211. AND a.hospital_id = b.hospital_id
  5212. AND a.hospital_id = c.hospital_id
  5213. AND a.behospital_code = b.behospital_code
  5214. AND a.behospital_code = c.behospital_code
  5215. AND c.cases_id = d.cases_id
  5216. AND c.cases_entry_id = d.id
  5217. AND a.qc_type_id != 0
  5218. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5219. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5220. </if>
  5221. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5222. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5223. </if>
  5224. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5225. <if test="qcResultShortPageVO.startDate != null ">
  5226. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5227. </if>
  5228. <if test="qcResultShortPageVO.endDate != null ">
  5229. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5230. </if>
  5231. </if>
  5232. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5233. <if test="qcResultShortPageVO.startDate != null ">
  5234. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5235. </if>
  5236. <if test="qcResultShortPageVO.endDate != null">
  5237. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5238. </if>
  5239. </if>
  5240. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5241. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5242. </if>
  5243. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5244. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5245. </if>
  5246. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5247. AND b.`level` = #{qcResultShortPageVO.level}
  5248. </if>
  5249. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5250. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5251. </if>
  5252. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5253. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5254. </if>
  5255. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5256. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5257. </if>
  5258. <if test="qcResultShortPageVO.casesEntryId != null ">
  5259. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5260. </if>
  5261. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5262. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5263. </if>
  5264. <if test="qcResultShortPageVO.casesId != null">
  5265. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5266. </if>
  5267. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5268. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5269. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5270. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5271. </if>
  5272. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5273. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5274. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5275. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5276. </if>
  5277. <if test="qcResultShortPageVO.isReject != null">
  5278. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5279. </if>
  5280. <if test="qcResultShortPageVO.ruleType != null">
  5281. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5282. </if>
  5283. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5284. AND TIMESTAMPDIFF(
  5285. DAY,
  5286. DATE( a.behospital_date ),
  5287. DATE( a.leave_hospital_date ))> 30
  5288. </if>
  5289. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5290. AND TIMESTAMPDIFF(
  5291. DAY,
  5292. DATE( a.behospital_date ),
  5293. DATE( a.leave_hospital_date ))> 31
  5294. </if>
  5295. )be
  5296. left join med_check_info mci
  5297. on mci.is_deleted = 'N'
  5298. and mci.check_type = 0
  5299. and be.hospital_id = mci.hospital_id
  5300. and be.behospital_code = mci.behospital_code
  5301. left join med_check_info hm_mci
  5302. on hm_mci.is_deleted = 'N'
  5303. and hm_mci.check_type = 1
  5304. and be.hospital_id = hm_mci.hospital_id
  5305. and be.behospital_code = hm_mci.behospital_code
  5306. LEFT JOIN med_qcresult_cases e
  5307. on be.behospital_code = e.behospital_code
  5308. and be.hospital_id = e.hospital_id
  5309. AND e.is_deleted = 'N'
  5310. and e.cases_id = 243
  5311. )tt1
  5312. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5313. ,med_medical_record tt2
  5314. WHERE
  5315. tt2.is_deleted = 'N'
  5316. AND tt1.hospital_id = tt2.hospital_id
  5317. AND tt1.behospital_code = tt2.behospital_code
  5318. AND tt2.mode_id = 30
  5319. </if>
  5320. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5321. ,med_crisis_info tt2
  5322. WHERE
  5323. tt2.is_deleted = 'N'
  5324. AND tt1.hospital_id = tt2.hospital_id
  5325. AND tt1.behospital_code = tt2.behospital_code
  5326. </if>
  5327. ) t1
  5328. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5329. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5330. AND t1.behospital_code = t2.behospital_code
  5331. AND t2.is_deleted = 'N'
  5332. </if>
  5333. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5334. , med_home_page t2
  5335. , med_home_operation_info t3
  5336. WHERE t1.hospital_id = t2.hospital_id
  5337. AND t1.behospital_code = t2.behospital_code
  5338. AND t2.home_page_id = t3.home_page_id
  5339. AND t2.is_deleted = 'N'
  5340. AND t3.is_deleted = 'N'
  5341. </if>
  5342. ) t
  5343. where 1=1
  5344. <if test="qcResultShortPageVO.checkStatus != null">
  5345. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5346. </if>
  5347. <if test="qcResultShortPageVO.mrStatus != null">
  5348. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5349. </if>
  5350. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5351. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5352. </if>
  5353. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5354. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5355. </if>
  5356. <if test="qcResultShortPageVO.chTimeStart != null ">
  5357. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5358. </if>
  5359. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5360. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5361. </if>
  5362. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5363. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5364. </if>
  5365. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5366. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5367. </if>
  5368. </select>
  5369. <!-- 条目缺陷质控评分页-科室(内页)-->
  5370. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  5371. SELECT t.*
  5372. FROM
  5373. (SELECT DISTINCT
  5374. t1.hospital_id AS hospitalId,
  5375. t1.behospital_code AS behospitalCode,
  5376. t1.bed_code AS bedCode,
  5377. t1.LEVEL AS LEVEL,
  5378. t1.grade_type AS gradeType,
  5379. t1.score_res AS scoreRes,
  5380. t1.scoreBn,
  5381. t1.medoupName,
  5382. t1.NAME AS NAME,
  5383. t1.sex AS sex,
  5384. t1.beh_dept_id AS behDeptId,
  5385. t1.beh_dept_name AS behDeptName,
  5386. t1.doctor_id AS doctorId,
  5387. t1.doctor_name AS doctorName,
  5388. t1.beh_doctor_id AS behDoctorId,
  5389. t1.beh_doctor_name AS behDoctorName,
  5390. t1.director_doctor_id AS directorDoctorId,
  5391. t1.director_doctor_name AS directorDoctorName,
  5392. t1.birthday AS birthday,
  5393. t1.behospital_date AS behospitalDate,
  5394. t1.leave_hospital_date AS leaveHospitalDate,
  5395. t1.placefile_date AS placefileDate,
  5396. t1.gmt_create AS gradeTime,
  5397. t1.diagnose,
  5398. t1.ward_name AS wardName,
  5399. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5400. t1.file_code AS fileCode,
  5401. t1.checkStatus,
  5402. t1.mrStatus,
  5403. t1.chName,
  5404. t1.mrName,
  5405. t1.chTime,
  5406. t1.mrTime
  5407. FROM
  5408. (
  5409. SELECT DISTINCT
  5410. tt1.*
  5411. FROM
  5412. (SELECT
  5413. be.*,
  5414. t3.name as medoupName,
  5415. ifnull(mci.status,0) AS checkStatus,
  5416. ifnull(hm_mci.status,0) AS mrStatus,
  5417. mci.check_name as chName,
  5418. e.score_res as scoreBn,
  5419. hm_mci.check_name as mrName,
  5420. mci.gmt_create as chTime,
  5421. hm_mci.gmt_create as mrTime
  5422. FROM
  5423. (
  5424. SELECT DISTINCT
  5425. a.hospital_id,
  5426. a.behospital_code,
  5427. a.bed_code,
  5428. a.file_code,
  5429. b.LEVEL,
  5430. b.grade_type,
  5431. b.score_res,
  5432. a.NAME,
  5433. a.sex,
  5434. a.beh_dept_id,
  5435. a.beh_dept_name,
  5436. a.birthday,
  5437. a.behospital_date,
  5438. a.leave_hospital_date,
  5439. a.doctor_id,
  5440. a.doctor_name,
  5441. a.beh_doctor_id,
  5442. a.beh_doctor_name,
  5443. a.director_doctor_id,
  5444. a.director_doctor_name,
  5445. a.diagnose,
  5446. a.placefile_date,
  5447. a.ward_name,
  5448. b.gmt_create
  5449. FROM
  5450. med_behospital_info a,
  5451. med_qcresult_info b,
  5452. med_qcresult_detail c,
  5453. qc_cases_entry d,
  5454. sys_user_dept e
  5455. WHERE
  5456. a.is_deleted = 'N'
  5457. AND b.is_deleted = 'N'
  5458. AND c.is_deleted = 'N'
  5459. AND d.is_deleted = 'N'
  5460. AND e.is_deleted = 'N'
  5461. AND a.hospital_id = b.hospital_id
  5462. AND a.hospital_id = c.hospital_id
  5463. AND a.hospital_id = e.hospital_id
  5464. AND a.behospital_code = b.behospital_code
  5465. AND a.behospital_code = c.behospital_code
  5466. AND a.beh_dept_id = e.dept_id
  5467. AND c.cases_id = d.cases_id
  5468. AND c.cases_entry_id = d.id
  5469. AND a.qc_type_id != 0
  5470. <if test="qcResultShortPageVO.userId!=null">
  5471. AND e.user_id = #{qcResultShortPageVO.userId}
  5472. </if>
  5473. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5474. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5475. </if>
  5476. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5477. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5478. </if>
  5479. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5480. <if test="qcResultShortPageVO.startDate != null ">
  5481. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5482. </if>
  5483. <if test="qcResultShortPageVO.endDate != null ">
  5484. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5485. </if>
  5486. </if>
  5487. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5488. <if test="qcResultShortPageVO.startDate != null ">
  5489. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5490. </if>
  5491. <if test="qcResultShortPageVO.endDate != null">
  5492. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5493. </if>
  5494. </if>
  5495. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5496. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5497. </if>
  5498. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  5499. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  5500. </if>
  5501. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5502. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5503. </if>
  5504. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  5505. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  5506. </if>
  5507. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5508. AND b.`level` = #{qcResultShortPageVO.level}
  5509. </if>
  5510. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5511. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5512. </if>
  5513. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5514. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5515. </if>
  5516. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5517. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5518. </if>
  5519. <if test="qcResultShortPageVO.casesEntryId != null ">
  5520. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5521. </if>
  5522. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5523. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5524. </if>
  5525. <if test="qcResultShortPageVO.casesId != null">
  5526. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5527. </if>
  5528. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5529. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  5530. </if>
  5531. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5532. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5533. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5534. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5535. </if>
  5536. <if test="qcResultShortPageVO.isReject != null">
  5537. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5538. </if>
  5539. <if test="qcResultShortPageVO.ruleType != null">
  5540. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5541. </if>
  5542. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5543. AND TIMESTAMPDIFF(
  5544. DAY,
  5545. DATE( a.behospital_date ),
  5546. DATE( a.leave_hospital_date ))> 30
  5547. </if>
  5548. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5549. AND TIMESTAMPDIFF(
  5550. DAY,
  5551. DATE( a.behospital_date ),
  5552. DATE( a.leave_hospital_date ))> 31
  5553. </if>
  5554. )be
  5555. left join med_check_info mci
  5556. on mci.is_deleted = 'N'
  5557. and mci.check_type = 0
  5558. and be.hospital_id = mci.hospital_id
  5559. and be.behospital_code = mci.behospital_code
  5560. left join med_check_info hm_mci
  5561. on hm_mci.is_deleted = 'N'
  5562. and hm_mci.check_type = 1
  5563. and be.hospital_id = hm_mci.hospital_id
  5564. and be.behospital_code = hm_mci.behospital_code
  5565. LEFT JOIN med_qcresult_cases e
  5566. on be.behospital_code = e.behospital_code
  5567. and be.hospital_id = e.hospital_id
  5568. AND e.is_deleted = 'N'
  5569. and e.cases_id = 243
  5570. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  5571. and be.hospital_id = t2.hospital_id
  5572. AND t2.is_deleted = 'N'
  5573. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  5574. AND t3.is_deleted = 'N'
  5575. )tt1
  5576. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5577. ,med_medical_record tt2
  5578. WHERE
  5579. tt2.is_deleted = 'N'
  5580. AND tt1.hospital_id = tt2.hospital_id
  5581. AND tt1.behospital_code = tt2.behospital_code
  5582. AND tt2.mode_id = 30
  5583. </if>
  5584. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5585. ,med_crisis_info tt2
  5586. WHERE
  5587. tt2.is_deleted = 'N'
  5588. AND tt1.hospital_id = tt2.hospital_id
  5589. AND tt1.behospital_code = tt2.behospital_code
  5590. </if>
  5591. ) t1
  5592. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5593. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5594. AND t1.behospital_code = t2.behospital_code
  5595. AND t2.is_deleted = 'N'
  5596. </if>
  5597. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5598. , med_home_page t2
  5599. , med_home_operation_info t3
  5600. WHERE t1.hospital_id = t2.hospital_id
  5601. AND t1.behospital_code = t2.behospital_code
  5602. AND t2.home_page_id = t3.home_page_id
  5603. AND t2.is_deleted = 'N'
  5604. AND t3.is_deleted = 'N'
  5605. </if>
  5606. ) t
  5607. where
  5608. 1=1
  5609. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  5610. and t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  5611. </if>
  5612. <if test="qcResultShortPageVO.checkStatus != null">
  5613. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5614. </if>
  5615. <if test="qcResultShortPageVO.mrStatus != null">
  5616. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5617. </if>
  5618. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5619. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5620. </if>
  5621. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5622. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5623. </if>
  5624. <if test="qcResultShortPageVO.chTimeStart != null ">
  5625. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5626. </if>
  5627. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5628. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5629. </if>
  5630. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5631. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5632. </if>
  5633. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5634. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5635. </if>
  5636. </select>
  5637. <update id="updateBatchByKey">
  5638. <foreach collection="list" item="item" separator=";">
  5639. update med_behospital_info
  5640. <set>
  5641. <if test="item.name != null">
  5642. name = #{item.name},
  5643. </if>
  5644. <if test="item.sex != null">
  5645. sex = #{item.sex},
  5646. </if>
  5647. <if test="item.birthday != null">
  5648. birthday = #{item.birthday},
  5649. </if>
  5650. <if test="item.fileCode != null">
  5651. file_code = #{item.fileCode},
  5652. </if>
  5653. <if test="item.qcTypeId != null">
  5654. qc_type_id = #{item.qcTypeId},
  5655. </if>
  5656. <if test="item.wardCode != null">
  5657. ward_code = #{item.wardCode},
  5658. </if>
  5659. <if test="item.wardName != null">
  5660. ward_name = #{item.wardName},
  5661. </if>
  5662. <if test="item.behDeptId != null">
  5663. beh_dept_id = #{item.behDeptId},
  5664. </if>
  5665. <if test="item.behDeptName != null">
  5666. beh_dept_name = #{item.behDeptName},
  5667. </if>
  5668. <if test="item.bedCode != null">
  5669. bed_code = #{item.bedCode},
  5670. </if>
  5671. <if test="item.bedName != null">
  5672. bed_name = #{item.bedName},
  5673. </if>
  5674. <if test="item.insuranceName != null">
  5675. insurance_name = #{item.insuranceName},
  5676. </if>
  5677. <if test="item.jobType != null">
  5678. job_type = #{item.jobType},
  5679. </if>
  5680. <if test="item.behospitalDate != null">
  5681. behospital_date = #{item.behospitalDate},
  5682. </if>
  5683. <if test="item.leaveHospitalDate != null">
  5684. leave_hospital_date = #{item.leaveHospitalDate},
  5685. </if>
  5686. <if test="item.diagnoseIcd != null">
  5687. diagnose_icd = #{item.diagnoseIcd},
  5688. </if>
  5689. <if test="item.diagnose != null">
  5690. diagnose = #{item.diagnose},
  5691. </if>
  5692. <if test="item.behDoctorId != null">
  5693. beh_doctor_id = #{item.behDoctorId},
  5694. </if>
  5695. <if test="item.behDoctorName != null">
  5696. beh_doctor_name = #{item.behDoctorName},
  5697. </if>
  5698. <if test="item.doctorId != null">
  5699. doctor_id = #{item.doctorId},
  5700. </if>
  5701. <if test="item.doctorName != null">
  5702. doctor_name = #{item.doctorName},
  5703. </if>
  5704. <if test="item.directorDoctorId != null">
  5705. director_doctor_id = #{item.directorDoctorId},
  5706. </if>
  5707. <if test="item.directorDoctorName != null">
  5708. director_doctor_name = #{item.directorDoctorName},
  5709. </if>
  5710. <if test="item.placefileDate != null">
  5711. placefile_date = #{item.placefileDate},
  5712. </if>
  5713. <if test="item.isPlacefile != null">
  5714. is_placefile = #{item.isPlacefile},
  5715. </if>
  5716. <if test="item.gmtModified != null">
  5717. gmt_modified = #{item.gmtModified},
  5718. </if>
  5719. <if test="item.modifier != null">
  5720. modifier = #{item.modifier},
  5721. </if>
  5722. </set>
  5723. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  5724. </foreach>
  5725. </update>
  5726. <!-- 关键条目缺陷统计报表-->
  5727. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  5728. SELECT
  5729. deptId,
  5730. deptName,
  5731. consultationMRNum,
  5732. consultationNum,
  5733. 2511 AS consultationEntryId,
  5734. '普通会诊未在24小时内完成' AS consultationEntryName,
  5735. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  5736. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  5737. operationMRNum,
  5738. 2594 AS operationNameEntryId,
  5739. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  5740. operationNameNum,
  5741. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  5742. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  5743. 2973 AS operationTimeEntryId,
  5744. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  5745. operationTimeNum,
  5746. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  5747. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  5748. 2930 AS operation15MinuteEntryId,
  5749. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  5750. operation15MinuteNum,
  5751. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  5752. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  5753. 2419 AS crisisEntryId,
  5754. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  5755. crisisMRNum,
  5756. crisisNum,
  5757. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  5758. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  5759. 2495 AS stageSummaryEntryId,
  5760. '无阶段小结' AS stageSummaryEntryName,
  5761. stageSummaryMRNum,
  5762. stageSummaryNum,
  5763. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  5764. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  5765. beHosGT31DaysMRNum
  5766. FROM
  5767. (
  5768. SELECT
  5769. tt.deptId,
  5770. tt.deptName,
  5771. sum( tt.consultationNum ) AS consultationNum,
  5772. sum( tt.consultationMRNum ) AS consultationMRNum,
  5773. sum( tt.operationNameNum ) AS operationNameNum,
  5774. sum( tt.operationTimeNum ) AS operationTimeNum,
  5775. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  5776. sum( tt.operationMRNum ) AS operationMRNum,
  5777. sum( tt.crisisNum ) AS crisisNum,
  5778. sum( tt.crisisMRNum ) AS crisisMRNum,
  5779. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  5780. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  5781. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  5782. FROM
  5783. (
  5784. (
  5785. SELECT
  5786. c.beh_dept_id AS deptId,
  5787. c.beh_dept_name AS deptName,
  5788. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  5789. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  5790. 0 AS operationNameNum,
  5791. 0 AS operationTimeNum,
  5792. 0 AS operation15MinuteNum,
  5793. 0 AS operationMRNum,
  5794. 0 AS crisisNum,
  5795. 0 AS crisisMRNum,
  5796. 0 AS stageSummaryNum,
  5797. 0 AS stageSummaryMRNum,
  5798. 0 AS beHosGT31DaysMRNum
  5799. FROM
  5800. (
  5801. SELECT DISTINCT
  5802. a.hospital_id,
  5803. a.behospital_code,
  5804. a.beh_dept_name,
  5805. a.beh_dept_id
  5806. FROM
  5807. med_behospital_info a,
  5808. med_medical_record b
  5809. WHERE
  5810. a.is_deleted = 'N'
  5811. AND b.is_deleted = 'N'
  5812. AND a.hospital_id = b.hospital_id
  5813. AND a.behospital_code = b.behospital_code
  5814. AND b.mode_id = 30
  5815. <if test="isPlacefile != null and isPlacefile != ''">
  5816. and a.is_placefile = #{isPlacefile}
  5817. </if>
  5818. AND a.qc_type_id != 0
  5819. <if test="hospitalId != null and hospitalId != ''">
  5820. AND a.hospital_id = #{hospitalId}
  5821. </if>
  5822. <if test="isPlacefile != null and isPlacefile == 0">
  5823. <if test="startDate != null ">
  5824. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5825. </if>
  5826. <if test="endDate != null ">
  5827. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5828. </if>
  5829. </if>
  5830. <if test="isPlacefile != null and isPlacefile == 1">
  5831. <if test="startDate != null ">
  5832. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5833. </if>
  5834. <if test="endDate != null ">
  5835. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5836. </if>
  5837. </if>
  5838. <if test="deptName != null and deptName != ''">
  5839. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5840. </if>
  5841. ) c
  5842. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5843. AND c.hospital_id = d.hospital_id
  5844. AND c.behospital_code = d.behospital_code
  5845. GROUP BY
  5846. c.beh_dept_id,
  5847. c.beh_dept_name
  5848. ) UNION
  5849. (
  5850. SELECT
  5851. d.beh_dept_id AS deptId,
  5852. d.beh_dept_name AS deptName,
  5853. 0 AS consultationNum,
  5854. 0 AS consultationMRNum,
  5855. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  5856. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  5857. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  5858. count( DISTINCT d.behospital_code ) AS operationMRNum,
  5859. 0 AS crisisNum,
  5860. 0 AS crisisMRNum,
  5861. 0 AS stageSummaryNum,
  5862. 0 AS stageSummaryMRNum,
  5863. 0 AS beHosGT31DaysMRNum
  5864. FROM
  5865. (
  5866. SELECT DISTINCT
  5867. a.hospital_id,
  5868. a.behospital_code,
  5869. a.beh_dept_name,
  5870. a.beh_dept_id
  5871. FROM
  5872. med_behospital_info a,
  5873. med_home_page b,
  5874. med_home_operation_info c
  5875. WHERE
  5876. a.is_deleted = 'N'
  5877. AND b.is_deleted = 'N'
  5878. AND c.is_deleted = 'N'
  5879. AND a.hospital_id = b.hospital_id
  5880. AND a.hospital_id = c.hospital_id
  5881. AND a.behospital_code = b.behospital_code
  5882. AND b.home_page_id = c.home_page_id
  5883. <if test="isPlacefile != null and isPlacefile != ''">
  5884. and a.is_placefile = #{isPlacefile}
  5885. </if>
  5886. AND a.qc_type_id != 0
  5887. <if test="hospitalId != null and hospitalId != ''">
  5888. AND a.hospital_id = #{hospitalId}
  5889. </if>
  5890. <if test="isPlacefile != null and isPlacefile == 0">
  5891. <if test="startDate != null ">
  5892. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5893. </if>
  5894. <if test="endDate != null ">
  5895. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5896. </if>
  5897. </if>
  5898. <if test="isPlacefile != null and isPlacefile == 1">
  5899. <if test="startDate != null ">
  5900. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5901. </if>
  5902. <if test="endDate != null ">
  5903. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5904. </if>
  5905. </if>
  5906. <if test="deptName != null and deptName != ''">
  5907. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5908. </if>
  5909. ) d
  5910. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  5911. AND d.hospital_id = e.hospital_id
  5912. AND d.behospital_code = e.behospital_code
  5913. GROUP BY
  5914. d.beh_dept_id,
  5915. d.beh_dept_name
  5916. ) UNION
  5917. (
  5918. SELECT
  5919. c.beh_dept_id AS deptId,
  5920. c.beh_dept_name AS deptName,
  5921. 0 AS consultationNum,
  5922. 0 AS consultationMRNum,
  5923. 0 AS operationNameNum,
  5924. 0 AS operationTimeNum,
  5925. 0 AS operation15MinuteNum,
  5926. 0 AS operationMRNum,
  5927. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  5928. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  5929. 0 AS stageSummaryNum,
  5930. 0 AS stageSummaryMRNum,
  5931. 0 AS beHosGT31DaysMRNum
  5932. FROM
  5933. (
  5934. SELECT DISTINCT
  5935. a.hospital_id,
  5936. a.behospital_code,
  5937. a.beh_dept_name,
  5938. a.beh_dept_id
  5939. FROM
  5940. med_behospital_info a,
  5941. med_crisis_info b
  5942. WHERE
  5943. a.is_deleted = 'N'
  5944. AND b.is_deleted = 'N'
  5945. AND a.hospital_id = b.hospital_id
  5946. AND a.behospital_code = b.behospital_code
  5947. <if test="isPlacefile != null and isPlacefile != ''">
  5948. and a.is_placefile = #{isPlacefile}
  5949. </if>
  5950. AND a.qc_type_id != 0
  5951. <if test="hospitalId != null and hospitalId != ''">
  5952. AND a.hospital_id = #{hospitalId}
  5953. </if>
  5954. <if test="isPlacefile != null and isPlacefile == 0">
  5955. <if test="startDate != null ">
  5956. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5957. </if>
  5958. <if test="endDate != null ">
  5959. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5960. </if>
  5961. </if>
  5962. <if test="isPlacefile != null and isPlacefile == 1">
  5963. <if test="startDate != null ">
  5964. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5965. </if>
  5966. <if test="endDate != null ">
  5967. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5968. </if>
  5969. </if>
  5970. <if test="deptName != null and deptName != ''">
  5971. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5972. </if>
  5973. ) c
  5974. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5975. AND c.hospital_id = d.hospital_id
  5976. AND c.behospital_code = d.behospital_code
  5977. GROUP BY
  5978. c.beh_dept_id,
  5979. c.beh_dept_name
  5980. ) UNION
  5981. (
  5982. SELECT
  5983. b.beh_dept_id AS deptId,
  5984. b.beh_dept_name AS deptName,
  5985. 0 AS consultationNum,
  5986. 0 AS consultationMRNum,
  5987. 0 AS operationNameNum,
  5988. 0 AS operationTimeNum,
  5989. 0 AS operation15MinuteNum,
  5990. 0 AS operationMRNum,
  5991. 0 AS crisisNum,
  5992. 0 AS crisisMRNum,
  5993. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  5994. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  5995. 0 AS beHosGT31DaysMRNum
  5996. FROM
  5997. (
  5998. SELECT DISTINCT
  5999. a.hospital_id,
  6000. a.behospital_code,
  6001. a.beh_dept_name,
  6002. a.beh_dept_id
  6003. FROM
  6004. med_behospital_info a
  6005. WHERE
  6006. a.is_deleted = 'N'
  6007. AND TIMESTAMPDIFF(
  6008. DAY,
  6009. DATE( behospital_date ),
  6010. DATE( leave_hospital_date ))> 30
  6011. <if test="isPlacefile != null and isPlacefile != ''">
  6012. and a.is_placefile = #{isPlacefile}
  6013. </if>
  6014. AND a.qc_type_id != 0
  6015. <if test="hospitalId != null and hospitalId != ''">
  6016. AND a.hospital_id = #{hospitalId}
  6017. </if>
  6018. <if test="isPlacefile != null and isPlacefile == 0">
  6019. <if test="startDate != null ">
  6020. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6021. </if>
  6022. <if test="endDate != null ">
  6023. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6024. </if>
  6025. </if>
  6026. <if test="isPlacefile != null and isPlacefile == 1">
  6027. <if test="startDate != null ">
  6028. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6029. </if>
  6030. <if test="endDate != null ">
  6031. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6032. </if>
  6033. </if>
  6034. <if test="deptName != null and deptName != ''">
  6035. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6036. </if>
  6037. ) b
  6038. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6039. AND b.hospital_id = c.hospital_id
  6040. AND b.behospital_code = c.behospital_code
  6041. GROUP BY
  6042. b.beh_dept_id,
  6043. b.beh_dept_name
  6044. ) UNION
  6045. (
  6046. SELECT
  6047. b.beh_dept_id AS deptId,
  6048. b.beh_dept_name AS deptName,
  6049. 0 AS consultationNum,
  6050. 0 AS consultationMRNum,
  6051. 0 AS operationNameNum,
  6052. 0 AS operationTimeNum,
  6053. 0 AS operation15MinuteNum,
  6054. 0 AS operationMRNum,
  6055. 0 AS crisisNum,
  6056. 0 AS crisisMRNum,
  6057. 0 AS stageSummaryNum,
  6058. 0 AS stageSummaryMRNum,
  6059. count(*) AS beHosGT31DaysMRNum
  6060. FROM
  6061. (
  6062. SELECT DISTINCT
  6063. a.hospital_id,
  6064. a.behospital_code,
  6065. a.beh_dept_name,
  6066. a.beh_dept_id
  6067. FROM
  6068. med_behospital_info a
  6069. WHERE
  6070. a.is_deleted = 'N'
  6071. AND TIMESTAMPDIFF(
  6072. DAY,
  6073. DATE( behospital_date ),
  6074. DATE( leave_hospital_date ))> 31
  6075. <if test="isPlacefile != null and isPlacefile != ''">
  6076. and a.is_placefile = #{isPlacefile}
  6077. </if>
  6078. AND a.qc_type_id != 0
  6079. <if test="hospitalId != null and hospitalId != ''">
  6080. AND a.hospital_id = #{hospitalId}
  6081. </if>
  6082. <if test="isPlacefile != null and isPlacefile == 0">
  6083. <if test="startDate != null ">
  6084. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6085. </if>
  6086. <if test="endDate != null ">
  6087. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6088. </if>
  6089. </if>
  6090. <if test="isPlacefile != null and isPlacefile == 1">
  6091. <if test="startDate != null ">
  6092. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6093. </if>
  6094. <if test="endDate != null ">
  6095. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6096. </if>
  6097. </if>
  6098. <if test="deptName != null and deptName != ''">
  6099. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6100. </if>
  6101. ) b
  6102. GROUP BY
  6103. b.beh_dept_id,
  6104. b.beh_dept_name
  6105. )
  6106. ) tt
  6107. GROUP BY
  6108. tt.deptId,
  6109. tt.deptName
  6110. ) t
  6111. <if test="asc != null and asc !=''">
  6112. order by
  6113. <choose>
  6114. <when test='asc=="deptId"'>deptId asc</when>
  6115. <when test='asc=="deptName"'>deptName asc</when>
  6116. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6117. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6118. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6119. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6120. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6121. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6122. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6123. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6124. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6125. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6126. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6127. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6128. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6129. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6130. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6131. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6132. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6133. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6134. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6135. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6136. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6137. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6138. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6139. <otherwise>deptName asc</otherwise>
  6140. </choose>
  6141. </if>
  6142. <if test="desc != null and desc!=''">
  6143. order by
  6144. <choose>
  6145. <when test='desc=="deptId"'>deptId desc</when>
  6146. <when test='desc=="deptName"'>deptName desc</when>
  6147. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6148. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6149. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6150. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6151. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6152. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6153. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6154. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6155. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6156. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6157. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6158. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6159. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6160. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6161. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6162. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6163. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6164. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6165. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6166. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6167. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6168. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6169. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6170. <otherwise>deptName desc</otherwise>
  6171. </choose>
  6172. </if>
  6173. </select>
  6174. <!-- 关键条目缺陷统计报表-科室-->
  6175. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6176. SELECT
  6177. deptId,
  6178. deptName,
  6179. doctorName,
  6180. consultationMRNum,
  6181. consultationNum,
  6182. 2511 AS consultationEntryId,
  6183. '普通会诊未在24小时内完成' AS consultationEntryName,
  6184. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6185. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6186. operationMRNum,
  6187. 2594 AS operationNameEntryId,
  6188. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6189. operationNameNum,
  6190. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6191. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6192. 2973 AS operationTimeEntryId,
  6193. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6194. operationTimeNum,
  6195. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6196. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6197. 2930 AS operation15MinuteEntryId,
  6198. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6199. operation15MinuteNum,
  6200. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6201. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6202. 2419 AS crisisEntryId,
  6203. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6204. crisisMRNum,
  6205. crisisNum,
  6206. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6207. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6208. 2495 AS stageSummaryEntryId,
  6209. '无阶段小结' AS stageSummaryEntryName,
  6210. stageSummaryMRNum,
  6211. stageSummaryNum,
  6212. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6213. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6214. beHosGT31DaysMRNum
  6215. FROM
  6216. (
  6217. SELECT
  6218. tt.deptId,
  6219. tt.deptName,
  6220. tt.doctorId,
  6221. tt.doctorName,
  6222. sum( tt.consultationNum ) AS consultationNum,
  6223. sum( tt.consultationMRNum ) AS consultationMRNum,
  6224. sum( tt.operationNameNum ) AS operationNameNum,
  6225. sum( tt.operationTimeNum ) AS operationTimeNum,
  6226. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6227. sum( tt.operationMRNum ) AS operationMRNum,
  6228. sum( tt.crisisNum ) AS crisisNum,
  6229. sum( tt.crisisMRNum ) AS crisisMRNum,
  6230. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6231. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6232. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6233. FROM
  6234. (
  6235. (
  6236. SELECT
  6237. c.beh_dept_id AS deptId,
  6238. c.beh_dept_name AS deptName,
  6239. c.doctorId,
  6240. c.doctorName,
  6241. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6242. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6243. 0 AS operationNameNum,
  6244. 0 AS operationTimeNum,
  6245. 0 AS operation15MinuteNum,
  6246. 0 AS operationMRNum,
  6247. 0 AS crisisNum,
  6248. 0 AS crisisMRNum,
  6249. 0 AS stageSummaryNum,
  6250. 0 AS stageSummaryMRNum,
  6251. 0 AS beHosGT31DaysMRNum
  6252. FROM
  6253. (
  6254. SELECT DISTINCT
  6255. a.hospital_id,
  6256. a.behospital_code,
  6257. a.beh_dept_name,
  6258. a.beh_dept_id,
  6259. a.doctor_id as doctorId,
  6260. a.doctor_name as doctorName
  6261. FROM
  6262. med_behospital_info a,
  6263. med_medical_record b,
  6264. sys_user_dept c
  6265. WHERE
  6266. a.is_deleted = 'N'
  6267. AND b.is_deleted = 'N'
  6268. AND c.is_deleted = 'N'
  6269. AND a.hospital_id = b.hospital_id
  6270. AND a.hospital_id = c.hospital_id
  6271. AND a.behospital_code = b.behospital_code
  6272. AND a.beh_dept_id = c.dept_id
  6273. AND b.mode_id = 30
  6274. <if test="userId!=null">
  6275. AND c.user_id = #{userId}
  6276. </if>
  6277. <if test="isPlacefile != null and isPlacefile != ''">
  6278. and a.is_placefile = #{isPlacefile}
  6279. </if>
  6280. AND a.qc_type_id != 0
  6281. <if test="hospitalId != null and hospitalId != ''">
  6282. AND a.hospital_id = #{hospitalId}
  6283. </if>
  6284. <if test="isPlacefile != null and isPlacefile == 0">
  6285. <if test="startDate != null ">
  6286. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6287. </if>
  6288. <if test="endDate != null ">
  6289. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6290. </if>
  6291. </if>
  6292. <if test="isPlacefile != null and isPlacefile == 1">
  6293. <if test="startDate != null ">
  6294. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6295. </if>
  6296. <if test="endDate != null ">
  6297. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6298. </if>
  6299. </if>
  6300. <if test="doctorName != null and doctorName != ''">
  6301. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6302. </if>
  6303. <if test="deptName != null and deptName != ''">
  6304. AND a.beh_dept_name = #{deptName}
  6305. </if>
  6306. ) c
  6307. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6308. AND c.hospital_id = d.hospital_id
  6309. AND c.behospital_code = d.behospital_code
  6310. GROUP BY
  6311. c.doctorId,
  6312. c.doctorName
  6313. ) UNION
  6314. (
  6315. SELECT
  6316. d.beh_dept_id AS deptId,
  6317. d.beh_dept_name AS deptName,
  6318. d.doctor_id as doctorId,
  6319. d.doctor_name as doctorName,
  6320. 0 AS consultationNum,
  6321. 0 AS consultationMRNum,
  6322. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6323. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6324. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6325. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6326. 0 AS crisisNum,
  6327. 0 AS crisisMRNum,
  6328. 0 AS stageSummaryNum,
  6329. 0 AS stageSummaryMRNum,
  6330. 0 AS beHosGT31DaysMRNum
  6331. FROM
  6332. (
  6333. SELECT DISTINCT
  6334. a.hospital_id,
  6335. a.behospital_code,
  6336. a.beh_dept_name,
  6337. a.beh_dept_id,
  6338. a.doctor_id,
  6339. a.doctor_name
  6340. FROM
  6341. med_behospital_info a,
  6342. med_home_page b,
  6343. med_home_operation_info c,
  6344. sys_user_dept d
  6345. WHERE
  6346. a.is_deleted = 'N'
  6347. AND b.is_deleted = 'N'
  6348. AND c.is_deleted = 'N'
  6349. AND d.is_deleted = 'N'
  6350. AND a.hospital_id = b.hospital_id
  6351. AND a.hospital_id = c.hospital_id
  6352. AND a.hospital_id = d.hospital_id
  6353. AND a.behospital_code = b.behospital_code
  6354. AND b.home_page_id = c.home_page_id
  6355. AND a.beh_dept_id = d.dept_id
  6356. <if test="userId!=null">
  6357. AND d.user_id = #{userId}
  6358. </if>
  6359. <if test="isPlacefile != null and isPlacefile != ''">
  6360. and a.is_placefile = #{isPlacefile}
  6361. </if>
  6362. AND a.qc_type_id != 0
  6363. <if test="hospitalId != null and hospitalId != ''">
  6364. AND a.hospital_id = #{hospitalId}
  6365. </if>
  6366. <if test="isPlacefile != null and isPlacefile == 0">
  6367. <if test="startDate != null ">
  6368. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6369. </if>
  6370. <if test="endDate != null ">
  6371. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6372. </if>
  6373. </if>
  6374. <if test="isPlacefile != null and isPlacefile == 1">
  6375. <if test="startDate != null ">
  6376. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6377. </if>
  6378. <if test="endDate != null ">
  6379. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6380. </if>
  6381. </if>
  6382. <if test="doctorName != null and doctorName != ''">
  6383. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6384. </if>
  6385. <if test="deptName != null and deptName != ''">
  6386. AND a.beh_dept_name = #{deptName}
  6387. </if>
  6388. ) d
  6389. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6390. AND d.hospital_id = e.hospital_id
  6391. AND d.behospital_code = e.behospital_code
  6392. GROUP BY
  6393. d.doctor_id,
  6394. d.doctor_name
  6395. ) UNION
  6396. (
  6397. SELECT
  6398. c.beh_dept_id AS deptId,
  6399. c.beh_dept_name AS deptName,
  6400. c.doctor_id as doctorId,
  6401. c.doctor_name as doctorName,
  6402. 0 AS consultationNum,
  6403. 0 AS consultationMRNum,
  6404. 0 AS operationNameNum,
  6405. 0 AS operationTimeNum,
  6406. 0 AS operation15MinuteNum,
  6407. 0 AS operationMRNum,
  6408. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6409. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6410. 0 AS stageSummaryNum,
  6411. 0 AS stageSummaryMRNum,
  6412. 0 AS beHosGT31DaysMRNum
  6413. FROM
  6414. (
  6415. SELECT DISTINCT
  6416. a.hospital_id,
  6417. a.behospital_code,
  6418. a.beh_dept_name,
  6419. a.beh_dept_id,
  6420. a.doctor_id,
  6421. a.doctor_name
  6422. FROM
  6423. med_behospital_info a,
  6424. med_crisis_info b,
  6425. sys_user_dept c
  6426. WHERE
  6427. a.is_deleted = 'N'
  6428. AND b.is_deleted = 'N'
  6429. AND c.is_deleted = 'N'
  6430. AND a.hospital_id = b.hospital_id
  6431. AND a.hospital_id = c.hospital_id
  6432. AND a.behospital_code = b.behospital_code
  6433. AND a.beh_dept_id = c.dept_id
  6434. <if test="userId!=null">
  6435. AND c.user_id = #{userId}
  6436. </if>
  6437. <if test="isPlacefile != null and isPlacefile != ''">
  6438. and a.is_placefile = #{isPlacefile}
  6439. </if>
  6440. AND a.qc_type_id != 0
  6441. <if test="hospitalId != null and hospitalId != ''">
  6442. AND a.hospital_id = #{hospitalId}
  6443. </if>
  6444. <if test="isPlacefile != null and isPlacefile == 0">
  6445. <if test="startDate != null ">
  6446. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6447. </if>
  6448. <if test="endDate != null ">
  6449. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6450. </if>
  6451. </if>
  6452. <if test="isPlacefile != null and isPlacefile == 1">
  6453. <if test="startDate != null ">
  6454. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6455. </if>
  6456. <if test="endDate != null ">
  6457. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6458. </if>
  6459. </if>
  6460. <if test="doctorName != null and doctorName != ''">
  6461. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6462. </if>
  6463. <if test="deptName != null and deptName != ''">
  6464. AND a.beh_dept_name = #{deptName}
  6465. </if>
  6466. ) c
  6467. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6468. AND c.hospital_id = d.hospital_id
  6469. AND c.behospital_code = d.behospital_code
  6470. GROUP BY
  6471. c.doctor_id,
  6472. c.doctor_name
  6473. ) UNION
  6474. (
  6475. SELECT
  6476. b.beh_dept_id AS deptId,
  6477. b.beh_dept_name AS deptName,
  6478. b.doctor_id as doctorId,
  6479. b.doctor_name as doctorName,
  6480. 0 AS consultationNum,
  6481. 0 AS consultationMRNum,
  6482. 0 AS operationNameNum,
  6483. 0 AS operationTimeNum,
  6484. 0 AS operation15MinuteNum,
  6485. 0 AS operationMRNum,
  6486. 0 AS crisisNum,
  6487. 0 AS crisisMRNum,
  6488. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6489. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6490. 0 AS beHosGT31DaysMRNum
  6491. FROM
  6492. (
  6493. SELECT DISTINCT
  6494. a.hospital_id,
  6495. a.behospital_code,
  6496. a.beh_dept_name,
  6497. a.beh_dept_id,
  6498. a.doctor_id,
  6499. a.doctor_name
  6500. FROM
  6501. med_behospital_info a,
  6502. sys_user_dept b
  6503. WHERE
  6504. a.is_deleted = 'N'
  6505. AND b.is_deleted = 'N'
  6506. AND a.hospital_id = b.hospital_id
  6507. AND a.beh_dept_id = b.dept_id
  6508. AND TIMESTAMPDIFF(
  6509. DAY,
  6510. DATE( behospital_date ),
  6511. DATE( leave_hospital_date ))> 30
  6512. <if test="userId!=null">
  6513. AND b.user_id = #{userId}
  6514. </if>
  6515. <if test="isPlacefile != null and isPlacefile != ''">
  6516. and a.is_placefile = #{isPlacefile}
  6517. </if>
  6518. AND a.qc_type_id != 0
  6519. <if test="hospitalId != null and hospitalId != ''">
  6520. AND a.hospital_id = #{hospitalId}
  6521. </if>
  6522. <if test="isPlacefile != null and isPlacefile == 0">
  6523. <if test="startDate != null ">
  6524. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6525. </if>
  6526. <if test="endDate != null ">
  6527. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6528. </if>
  6529. </if>
  6530. <if test="isPlacefile != null and isPlacefile == 1">
  6531. <if test="startDate != null ">
  6532. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6533. </if>
  6534. <if test="endDate != null ">
  6535. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6536. </if>
  6537. </if>
  6538. <if test="doctorName != null and doctorName != ''">
  6539. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6540. </if>
  6541. <if test="deptName != null and deptName != ''">
  6542. AND a.beh_dept_name = #{deptName}
  6543. </if>
  6544. ) b
  6545. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6546. AND b.hospital_id = c.hospital_id
  6547. AND b.behospital_code = c.behospital_code
  6548. GROUP BY
  6549. b.doctor_id,
  6550. b.doctor_name
  6551. ) UNION
  6552. (
  6553. SELECT
  6554. b.beh_dept_id AS deptId,
  6555. b.beh_dept_name AS deptName,
  6556. b.doctor_id as doctorId,
  6557. b.doctor_name as doctorName,
  6558. 0 AS consultationNum,
  6559. 0 AS consultationMRNum,
  6560. 0 AS operationNameNum,
  6561. 0 AS operationTimeNum,
  6562. 0 AS operation15MinuteNum,
  6563. 0 AS operationMRNum,
  6564. 0 AS crisisNum,
  6565. 0 AS crisisMRNum,
  6566. 0 AS stageSummaryNum,
  6567. 0 AS stageSummaryMRNum,
  6568. count(*) AS beHosGT31DaysMRNum
  6569. FROM
  6570. (
  6571. SELECT DISTINCT
  6572. a.hospital_id,
  6573. a.behospital_code,
  6574. a.beh_dept_name,
  6575. a.beh_dept_id,
  6576. a.doctor_id,
  6577. a.doctor_name
  6578. FROM
  6579. med_behospital_info a,
  6580. sys_user_dept b
  6581. WHERE
  6582. a.is_deleted = 'N'
  6583. AND b.is_deleted = 'N'
  6584. AND a.hospital_id = b.hospital_id
  6585. AND a.beh_dept_id = b.dept_id
  6586. AND TIMESTAMPDIFF(
  6587. DAY,
  6588. DATE( behospital_date ),
  6589. DATE( leave_hospital_date ))> 31
  6590. <if test="userId!=null">
  6591. AND b.user_id = #{userId}
  6592. </if>
  6593. <if test="isPlacefile != null and isPlacefile != ''">
  6594. and a.is_placefile = #{isPlacefile}
  6595. </if>
  6596. AND a.qc_type_id != 0
  6597. <if test="hospitalId != null and hospitalId != ''">
  6598. AND a.hospital_id = #{hospitalId}
  6599. </if>
  6600. <if test="isPlacefile != null and isPlacefile == 0">
  6601. <if test="startDate != null ">
  6602. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6603. </if>
  6604. <if test="endDate != null ">
  6605. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6606. </if>
  6607. </if>
  6608. <if test="isPlacefile != null and isPlacefile == 1">
  6609. <if test="startDate != null ">
  6610. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6611. </if>
  6612. <if test="endDate != null ">
  6613. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6614. </if>
  6615. </if>
  6616. <if test="doctorName != null and doctorName != ''">
  6617. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6618. </if>
  6619. <if test="deptName != null and deptName != ''">
  6620. AND a.beh_dept_name = #{deptName}
  6621. </if>
  6622. ) b
  6623. GROUP BY
  6624. b.doctor_id,
  6625. b.doctor_name
  6626. )
  6627. ) tt
  6628. GROUP BY
  6629. tt.doctorName
  6630. ) t
  6631. <if test="asc != null and asc !=''">
  6632. order by
  6633. <choose>
  6634. <when test='asc=="deptId"'>deptId asc</when>
  6635. <when test='asc=="deptName"'>deptName asc</when>
  6636. <when test='asc=="doctorName"'>doctorName asc</when>
  6637. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6638. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6639. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6640. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6641. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6642. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6643. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6644. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6645. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6646. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6647. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6648. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6649. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6650. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6651. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6652. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6653. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6654. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6655. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6656. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6657. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6658. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6659. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6660. <otherwise>doctorName asc</otherwise>
  6661. </choose>
  6662. </if>
  6663. <if test="desc != null and desc!=''">
  6664. order by
  6665. <choose>
  6666. <when test='desc=="deptId"'>deptId desc</when>
  6667. <when test='desc=="doctorName"'>doctorName desc</when>
  6668. <when test='desc=="deptName"'>deptName desc</when>
  6669. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6670. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6671. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6672. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6673. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6674. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6675. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6676. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6677. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6678. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6679. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6680. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6681. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6682. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6683. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6684. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6685. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6686. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6687. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6688. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6689. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6690. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6691. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6692. <otherwise>doctorName desc</otherwise>
  6693. </choose>
  6694. </if>
  6695. </select>
  6696. <!-- 非医嘱离院病人记录-->
  6697. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6698. SELECT
  6699. count(*)
  6700. FROM
  6701. med_behospital_info a,
  6702. med_home_page b
  6703. WHERE
  6704. a.is_deleted = 'N'
  6705. AND b.is_deleted = 'N'
  6706. AND a.hospital_id = b.hospital_id
  6707. AND a.behospital_code = b.behospital_code
  6708. AND b.leave_hospital_type = '非医嘱离院'
  6709. <if test="isPlacefile != null and isPlacefile != ''">
  6710. and a.is_placefile = #{isPlacefile}
  6711. </if>
  6712. AND a.qc_type_id != 0
  6713. <if test="hospitalId != null and hospitalId != ''">
  6714. AND a.hospital_id = #{hospitalId}
  6715. </if>
  6716. <if test="isPlacefile != null and isPlacefile == 0">
  6717. <if test="startDate != null and startDate != ''">
  6718. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6719. </if>
  6720. <if test="endDate != null and endDate != ''">
  6721. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6722. </if>
  6723. </if>
  6724. <if test="isPlacefile != null and isPlacefile == 1">
  6725. <if test="startDate != null and startDate != ''">
  6726. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6727. </if>
  6728. <if test="endDate != null and endDate != ''">
  6729. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6730. </if>
  6731. </if>
  6732. </select>
  6733. <!-- 31天内再入院记录-->
  6734. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6735. SELECT
  6736. count(*)
  6737. FROM
  6738. (
  6739. SELECT
  6740. r1.file_code,
  6741. r1.diagnose,
  6742. r1.behospital_code AS behospitalCode,
  6743. r1.behospital_date AS behospitalDate,
  6744. r1.leave_hospital_date AS leaveHospitalDate,
  6745. r2.behospital_code AS lastBehospitalCode,
  6746. r2.behospital_date AS lastBehospitalDate,
  6747. r2.leave_hospital_date AS lastLeaveHospitalDate,
  6748. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  6749. FROM
  6750. (
  6751. SELECT
  6752. ( @rownum := @rownum + 1 ) AS rownum,
  6753. t1.file_code,
  6754. t1.diagnose,
  6755. t1.behospital_code,
  6756. t1.behospital_date,
  6757. t1.leave_hospital_date
  6758. FROM
  6759. (
  6760. SELECT
  6761. tt1.file_code,
  6762. tt1.diagnose,
  6763. tt2.behospital_code,
  6764. tt2.behospital_date,
  6765. tt2.leave_hospital_date
  6766. FROM
  6767. (
  6768. SELECT
  6769. a.file_code,
  6770. a.diagnose
  6771. FROM
  6772. med_behospital_info a
  6773. WHERE
  6774. a.is_deleted = 'N'
  6775. <if test="isPlacefile != null and isPlacefile != ''">
  6776. and a.is_placefile = #{isPlacefile}
  6777. </if>
  6778. AND a.qc_type_id != 0
  6779. AND IFNULL( a.diagnose, '' )!= ''
  6780. AND IFNULL( a.file_code, '' )!= ''
  6781. <if test="hospitalId != null and hospitalId != ''">
  6782. AND a.hospital_id = #{hospitalId}
  6783. </if>
  6784. <if test="isPlacefile != null and isPlacefile == 0">
  6785. <if test="startDate != null and startDate != ''">
  6786. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6787. </if>
  6788. <if test="endDate != null and endDate != ''">
  6789. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6790. </if>
  6791. </if>
  6792. <if test="isPlacefile != null and isPlacefile == 1">
  6793. <if test="startDate != null and startDate != ''">
  6794. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6795. </if>
  6796. <if test="endDate != null and endDate != ''">
  6797. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6798. </if>
  6799. </if>
  6800. GROUP BY
  6801. a.file_code,
  6802. a.diagnose
  6803. HAVING
  6804. count(*)> 1
  6805. ) tt1,
  6806. med_behospital_info tt2
  6807. WHERE
  6808. tt2.is_deleted = 'N'
  6809. <if test="isPlacefile != null and isPlacefile != ''">
  6810. and tt2.is_placefile = #{isPlacefile}
  6811. </if>
  6812. AND tt2.qc_type_id != 0
  6813. AND tt1.file_code = tt2.file_code
  6814. AND tt1.diagnose = tt2.diagnose
  6815. <if test="hospitalId != null and hospitalId != ''">
  6816. AND tt2.hospital_id = #{hospitalId}
  6817. </if>
  6818. <if test="isPlacefile != null and isPlacefile == 0">
  6819. <if test="startDate != null and startDate != ''">
  6820. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6821. </if>
  6822. <if test="endDate != null and endDate != ''">
  6823. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6824. </if>
  6825. </if>
  6826. <if test="isPlacefile != null and isPlacefile == 1">
  6827. <if test="startDate != null and startDate != ''">
  6828. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6829. </if>
  6830. <if test="endDate != null and endDate != ''">
  6831. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6832. </if>
  6833. </if>
  6834. ORDER BY
  6835. tt1.file_code,
  6836. tt1.diagnose,
  6837. tt2.behospital_date DESC
  6838. ) t1,
  6839. ( SELECT @rownum := 0 ) r
  6840. ) r1
  6841. LEFT JOIN (
  6842. SELECT
  6843. ( @INDEX := @INDEX + 1 ) AS rownum,
  6844. t2.file_code,
  6845. t2.diagnose,
  6846. t2.behospital_code,
  6847. t2.behospital_date,
  6848. t2.leave_hospital_date
  6849. FROM
  6850. (
  6851. SELECT
  6852. tt1.file_code,
  6853. tt1.diagnose,
  6854. tt2.behospital_code,
  6855. tt2.behospital_date,
  6856. tt2.leave_hospital_date
  6857. FROM
  6858. (
  6859. SELECT
  6860. a.file_code,
  6861. a.diagnose
  6862. FROM
  6863. med_behospital_info a
  6864. WHERE
  6865. a.is_deleted = 'N'
  6866. <if test="isPlacefile != null and isPlacefile != ''">
  6867. and a.is_placefile = #{isPlacefile}
  6868. </if>
  6869. AND a.qc_type_id != 0
  6870. AND IFNULL( a.diagnose, '' )!= ''
  6871. AND IFNULL( a.file_code, '' )!= ''
  6872. <if test="hospitalId != null and hospitalId != ''">
  6873. AND a.hospital_id = #{hospitalId}
  6874. </if>
  6875. <if test="isPlacefile != null and isPlacefile == 0">
  6876. <if test="startDate != null and startDate != ''">
  6877. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6878. </if>
  6879. <if test="endDate != null and endDate != ''">
  6880. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6881. </if>
  6882. </if>
  6883. <if test="isPlacefile != null and isPlacefile == 1">
  6884. <if test="startDate != null and startDate != ''">
  6885. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6886. </if>
  6887. <if test="endDate != null and endDate != ''">
  6888. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6889. </if>
  6890. </if>
  6891. GROUP BY
  6892. a.file_code,
  6893. a.diagnose
  6894. HAVING
  6895. count(*)> 1
  6896. ) tt1,
  6897. med_behospital_info tt2
  6898. WHERE
  6899. tt2.is_deleted = 'N'
  6900. <if test="isPlacefile != null and isPlacefile != ''">
  6901. and tt2.is_placefile = #{isPlacefile}
  6902. </if>
  6903. AND tt2.qc_type_id != 0
  6904. AND tt1.file_code = tt2.file_code
  6905. AND tt1.diagnose = tt2.diagnose
  6906. <if test="hospitalId != null and hospitalId != ''">
  6907. AND tt2.hospital_id = #{hospitalId}
  6908. </if>
  6909. <if test="isPlacefile != null and isPlacefile == 0">
  6910. <if test="startDate != null and startDate != ''">
  6911. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6912. </if>
  6913. <if test="endDate != null and endDate != ''">
  6914. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6915. </if>
  6916. </if>
  6917. <if test="isPlacefile != null and isPlacefile == 1">
  6918. <if test="startDate != null and startDate != ''">
  6919. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6920. </if>
  6921. <if test="endDate != null and endDate != ''">
  6922. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6923. </if>
  6924. </if>
  6925. ORDER BY
  6926. tt1.file_code,
  6927. tt1.diagnose,
  6928. tt2.behospital_date DESC
  6929. ) t2,(
  6930. SELECT
  6931. @INDEX := 0
  6932. ) r
  6933. ) r2 ON r1.file_code = r2.file_code
  6934. AND r1.rownum = r2.rownum - 1
  6935. ) t
  6936. WHERE
  6937. t.diffDays IS NOT NULL
  6938. AND t.diffDays BETWEEN 0
  6939. AND 31
  6940. </select>
  6941. <!-- 病案首页质控病历数统计-全院(首页)-->
  6942. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  6943. SELECT
  6944. count( * ) AS mrNum,
  6945. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  6946. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  6947. SUM( c.`level` = '合格' ) AS firstLevelNum,
  6948. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  6949. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  6950. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  6951. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  6952. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  6953. FROM
  6954. med_behospital_info a,
  6955. med_qcresult_cases c
  6956. WHERE
  6957. a.is_deleted = 'N'
  6958. AND c.is_deleted = 'N'
  6959. AND a.hospital_id = c.hospital_id
  6960. AND a.behospital_code = c.behospital_code
  6961. AND c.cases_id = 243
  6962. <if test="isPlacefile != null and isPlacefile != ''">
  6963. and a.is_placefile = #{isPlacefile}
  6964. </if>
  6965. AND a.qc_type_id != 0
  6966. <if test="hospitalId != null and hospitalId != ''">
  6967. AND a.hospital_id = #{hospitalId}
  6968. </if>
  6969. <if test="isPlacefile != null and isPlacefile == 0">
  6970. <if test="startDate != null and startDate != ''">
  6971. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6972. </if>
  6973. <if test="endDate != null and endDate != ''">
  6974. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6975. </if>
  6976. </if>
  6977. <if test="isPlacefile != null and isPlacefile == 1">
  6978. <if test="startDate != null and startDate != ''">
  6979. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6980. </if>
  6981. <if test="endDate != null and endDate != ''">
  6982. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6983. </if>
  6984. </if>
  6985. </select>
  6986. <!-- 病案首页完整率统计-全院(首页)-->
  6987. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  6988. SELECT
  6989. h1.emptyNum,
  6990. h1.mrNum,
  6991. h2.entryNum,
  6992. h1.mrNum * h2.entryNum AS entryTotleNum,
  6993. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  6994. CONCAT(
  6995. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  6996. '%'
  6997. ) AS emptyPercentStr
  6998. FROM
  6999. (
  7000. SELECT
  7001. sum( d.rule_type = 1 ) AS emptyNum,
  7002. count( DISTINCT a.behospital_code ) AS mrNum
  7003. FROM
  7004. med_behospital_info a,
  7005. med_qcresult_cases b,
  7006. med_qcresult_detail c,
  7007. qc_cases_entry d
  7008. WHERE
  7009. a.is_deleted = 'N'
  7010. AND b.is_deleted = 'N'
  7011. AND c.is_deleted = 'N'
  7012. AND d.is_deleted = 'N'
  7013. AND a.hospital_id = b.hospital_id
  7014. AND a.hospital_id = c.hospital_id
  7015. AND a.behospital_code = b.behospital_code
  7016. AND a.behospital_code = c.behospital_code
  7017. AND b.cases_id = c.cases_id
  7018. AND c.cases_id = d.cases_id
  7019. AND c.cases_entry_id = d.id
  7020. <if test="isPlacefile != null and isPlacefile != ''">
  7021. and a.is_placefile = #{isPlacefile}
  7022. </if>
  7023. AND d.cases_id = 243
  7024. AND a.qc_type_id != 0
  7025. <if test="hospitalId != null and hospitalId != ''">
  7026. AND a.hospital_id = #{hospitalId}
  7027. </if>
  7028. <if test="isPlacefile != null and isPlacefile == 0">
  7029. <if test="startDate != null and startDate != ''">
  7030. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7031. </if>
  7032. <if test="endDate != null and endDate != ''">
  7033. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7034. </if>
  7035. </if>
  7036. <if test="isPlacefile != null and isPlacefile == 1">
  7037. <if test="startDate != null and startDate != ''">
  7038. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7039. </if>
  7040. <if test="endDate != null and endDate != ''">
  7041. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7042. </if>
  7043. </if>
  7044. ) h1,(
  7045. SELECT
  7046. count(*) AS entryNum
  7047. FROM
  7048. qc_cases_entry
  7049. WHERE
  7050. is_deleted = 'N'
  7051. AND cases_id = 243
  7052. ) h2
  7053. </select>
  7054. <!-- 离院病人评分详情页-->
  7055. <select id="getAge" resultType="java.util.Map">
  7056. SELECT
  7057. a.behospital_code as behospitalCode,
  7058. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  7059. FROM
  7060. med_home_page a
  7061. WHERE
  7062. a.is_deleted = 'N'
  7063. AND a.hospital_id = #{hospitalId}
  7064. AND a.behospital_code IN
  7065. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  7066. '${item}'
  7067. </foreach>
  7068. </select>
  7069. <!-- 离院病人评分详情页-->
  7070. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7071. SELECT
  7072. t.*
  7073. FROM
  7074. (SELECT DISTINCT
  7075. t1.hospital_id AS hospitalId,
  7076. t1.behospital_code AS behospitalCode,
  7077. t1.bed_code AS bedCode,
  7078. t1.LEVEL AS LEVEL,
  7079. t1.grade_type AS gradeType,
  7080. t1.score_res AS scoreRes,
  7081. t1.scoreBn,
  7082. t1.NAME AS NAME,
  7083. t1.sex AS sex,
  7084. t1.beh_dept_id AS behDeptId,
  7085. t1.beh_dept_name AS behDeptName,
  7086. t1.doctor_id AS doctorId,
  7087. t1.doctor_name AS doctorName,
  7088. t1.beh_doctor_id AS behDoctorId,
  7089. t1.beh_doctor_name AS behDoctorName,
  7090. t1.director_doctor_id AS directorDoctorId,
  7091. t1.director_doctor_name AS directorDoctorName,
  7092. t1.birthday AS birthday,
  7093. t1.behospital_date AS behospitalDate,
  7094. t1.leave_hospital_date AS leaveHospitalDate,
  7095. t1.placefile_date AS placefileDate,
  7096. t1.gmt_create AS gradeTime,
  7097. t1.diagnose,
  7098. t1.ward_name AS wardName,
  7099. t1.checkStatus,
  7100. t1.mrStatus,
  7101. t1.chName,
  7102. t1.mrName,
  7103. t1.chTime,
  7104. t1.mrTime,
  7105. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7106. t1.file_code AS fileCode
  7107. FROM
  7108. (
  7109. SELECT be.*,
  7110. ifnull(mci.status,0) AS checkStatus,
  7111. ifnull(hm_mci.status,0) AS mrStatus,
  7112. mci.check_name as chName,
  7113. e.score_res as scoreBn,
  7114. hm_mci.check_name as mrName,
  7115. mci.gmt_create as chTime,
  7116. hm_mci.gmt_create as mrTime
  7117. FROM
  7118. (
  7119. SELECT DISTINCT
  7120. tt1.*
  7121. FROM
  7122. (
  7123. SELECT
  7124. b.*,
  7125. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7126. c.grade_type,
  7127. c.score_res,
  7128. c.gmt_create
  7129. FROM
  7130. (
  7131. SELECT DISTINCT
  7132. a.hospital_id,
  7133. a.behospital_code,
  7134. a.bed_code,
  7135. a.NAME,
  7136. a.sex,
  7137. a.beh_dept_id,
  7138. a.beh_dept_name,
  7139. a.birthday,
  7140. a.behospital_date,
  7141. a.leave_hospital_date,
  7142. a.doctor_id,
  7143. a.doctor_name,
  7144. a.beh_doctor_id,
  7145. a.beh_doctor_name,
  7146. a.director_doctor_id,
  7147. a.director_doctor_name,
  7148. a.diagnose,
  7149. a.placefile_date,
  7150. a.ward_name,
  7151. a.file_code
  7152. FROM
  7153. med_behospital_info a
  7154. WHERE
  7155. a.is_deleted = 'N'
  7156. AND a.qc_type_id != 0
  7157. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7158. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7159. </if>
  7160. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7161. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7162. </if>
  7163. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7164. <if test="qcResultShortPageVO.startDate != null ">
  7165. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7166. </if>
  7167. <if test="qcResultShortPageVO.endDate != null ">
  7168. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7169. </if>
  7170. </if>
  7171. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7172. <if test="qcResultShortPageVO.startDate != null ">
  7173. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7174. </if>
  7175. <if test="qcResultShortPageVO.endDate != null">
  7176. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7177. </if>
  7178. </if>
  7179. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7180. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7181. </if>
  7182. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7183. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7184. </if>
  7185. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7186. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7187. </if>
  7188. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7189. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7190. </if>
  7191. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7192. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7193. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7194. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7195. </if>
  7196. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7197. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7198. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7199. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7200. </if>
  7201. ) b
  7202. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7203. AND b.hospital_id = c.hospital_id
  7204. AND b.behospital_code = c.behospital_code
  7205. ) tt1
  7206. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7207. ,med_medical_record tt2,
  7208. qc_mode tt3
  7209. WHERE
  7210. tt2.is_deleted = 'N'
  7211. AND tt3.is_deleted = 'N'
  7212. AND tt1.hospital_id = tt2.hospital_id
  7213. AND tt1.behospital_code = tt2.behospital_code
  7214. AND tt2.mode_id = tt3.id
  7215. AND tt3.`name` = '手术记录'
  7216. </if>
  7217. ) be
  7218. left join med_check_info mci
  7219. on mci.is_deleted = 'N'
  7220. and mci.check_type = 0
  7221. and be.hospital_id = mci.hospital_id
  7222. and be.behospital_code = mci.behospital_code
  7223. left join med_check_info hm_mci
  7224. on hm_mci.is_deleted = 'N'
  7225. and hm_mci.check_type = 1
  7226. and be.hospital_id = hm_mci.hospital_id
  7227. and be.behospital_code = hm_mci.behospital_code
  7228. LEFT JOIN med_qcresult_cases e
  7229. on be.behospital_code = e.behospital_code
  7230. and be.hospital_id = e.hospital_id
  7231. AND e.is_deleted = 'N'
  7232. and e.cases_id = 243
  7233. )t1
  7234. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7235. ,med_home_page t2
  7236. WHERE
  7237. t2.is_deleted = 'N'
  7238. AND t1.hospital_id = t2.hospital_id
  7239. AND t1.behospital_code = t2.behospital_code
  7240. AND (
  7241. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7242. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7243. )
  7244. </if>
  7245. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7246. , med_medical_record b,
  7247. med_medical_record_content c,
  7248. med_home_page t2
  7249. WHERE
  7250. b.is_deleted = 'N'
  7251. and c.is_deleted = 'N'
  7252. and t2.is_deleted = 'N'
  7253. and t1.hospital_id = b.hospital_id
  7254. and t1.hospital_id = c.hospital_id
  7255. and t1.hospital_id = t2.hospital_id
  7256. AND t1.behospital_code = b.behospital_code
  7257. AND t1.behospital_code = t2.behospital_code
  7258. AND b.rec_id = c.rec_id
  7259. and b.mode_id = '24'
  7260. </if>
  7261. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7262. ,med_home_page t2
  7263. WHERE
  7264. t2.is_deleted = 'N'
  7265. AND t1.hospital_id = t2.hospital_id
  7266. AND t1.behospital_code = t2.behospital_code
  7267. AND t2.leave_hospital_type = '非医嘱离院'
  7268. </if>
  7269. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7270. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7271. AND t1.hospital_id = t2.hospital_id
  7272. AND t1.behospital_code = t2.behospital_code
  7273. </if>
  7274. )t
  7275. where 1=1
  7276. <if test="qcResultShortPageVO.checkStatus != null">
  7277. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7278. </if>
  7279. <if test="qcResultShortPageVO.mrStatus != null">
  7280. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7281. </if>
  7282. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7283. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7284. </if>
  7285. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7286. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7287. </if>
  7288. <if test="qcResultShortPageVO.chTimeStart != null ">
  7289. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7290. </if>
  7291. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7292. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7293. </if>
  7294. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7295. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7296. </if>
  7297. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7298. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7299. </if>
  7300. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7301. AND t.`level` = #{qcResultShortPageVO.level}
  7302. </if>
  7303. </select>
  7304. <!-- 离院病人评分详情页-科室-->
  7305. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  7306. SELECT
  7307. t.*
  7308. FROM
  7309. (SELECT DISTINCT
  7310. t1.hospital_id AS hospitalId,
  7311. t1.behospital_code AS behospitalCode,
  7312. t1.bed_code AS bedCode,
  7313. t1.LEVEL AS LEVEL,
  7314. t1.grade_type AS gradeType,
  7315. t1.score_res AS scoreRes,
  7316. t1.scoreBn,
  7317. t1.NAME AS NAME,
  7318. t1.sex AS sex,
  7319. t1.beh_dept_id AS behDeptId,
  7320. t1.beh_dept_name AS behDeptName,
  7321. t1.doctor_id AS doctorId,
  7322. t1.doctor_name AS doctorName,
  7323. t1.beh_doctor_id AS behDoctorId,
  7324. t1.beh_doctor_name AS behDoctorName,
  7325. t1.director_doctor_id AS directorDoctorId,
  7326. t1.director_doctor_name AS directorDoctorName,
  7327. t1.birthday AS birthday,
  7328. t1.behospital_date AS behospitalDate,
  7329. t1.leave_hospital_date AS leaveHospitalDate,
  7330. t1.placefile_date AS placefileDate,
  7331. t1.gmt_create AS gradeTime,
  7332. t1.diagnose,
  7333. t1.medoupName,
  7334. t1.ward_name AS wardName,
  7335. t1.checkStatus,
  7336. t1.mrStatus,
  7337. t1.chName,
  7338. t1.mrName,
  7339. t1.chTime,
  7340. t1.mrTime,
  7341. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7342. t1.file_code AS fileCode
  7343. FROM
  7344. (
  7345. SELECT be.*,
  7346. t3.name as medoupName,
  7347. ifnull(mci.status,0) AS checkStatus,
  7348. ifnull(hm_mci.status,0) AS mrStatus,
  7349. mci.check_name as chName,
  7350. e.score_res as scoreBn,
  7351. hm_mci.check_name as mrName,
  7352. mci.gmt_create as chTime,
  7353. hm_mci.gmt_create as mrTime
  7354. FROM
  7355. (
  7356. SELECT DISTINCT
  7357. tt1.*
  7358. FROM
  7359. (
  7360. SELECT
  7361. b.*,
  7362. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7363. c.grade_type,
  7364. c.score_res,
  7365. c.gmt_create
  7366. FROM
  7367. (
  7368. SELECT DISTINCT
  7369. a.hospital_id,
  7370. a.behospital_code,
  7371. a.bed_code,
  7372. a.NAME,
  7373. a.sex,
  7374. a.beh_dept_id,
  7375. a.beh_dept_name,
  7376. a.birthday,
  7377. a.behospital_date,
  7378. a.leave_hospital_date,
  7379. a.doctor_id,
  7380. a.doctor_name,
  7381. a.beh_doctor_id,
  7382. a.beh_doctor_name,
  7383. a.director_doctor_id,
  7384. a.director_doctor_name,
  7385. a.diagnose,
  7386. a.placefile_date,
  7387. a.ward_name,
  7388. a.file_code
  7389. FROM
  7390. med_behospital_info a,
  7391. sys_user_dept b
  7392. WHERE
  7393. a.is_deleted = 'N'
  7394. AND b.is_deleted = 'N'
  7395. AND a.hospital_id = b.hospital_id
  7396. AND a.beh_dept_id = b.dept_id
  7397. AND a.qc_type_id != 0
  7398. <if test="qcResultShortPageVO.userId!=null">
  7399. AND b.user_id = #{qcResultShortPageVO.userId}
  7400. </if>
  7401. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7402. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7403. </if>
  7404. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7405. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7406. </if>
  7407. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7408. <if test="qcResultShortPageVO.startDate != null ">
  7409. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7410. </if>
  7411. <if test="qcResultShortPageVO.endDate != null ">
  7412. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7413. </if>
  7414. </if>
  7415. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7416. <if test="qcResultShortPageVO.startDate != null ">
  7417. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7418. </if>
  7419. <if test="qcResultShortPageVO.endDate != null">
  7420. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7421. </if>
  7422. </if>
  7423. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7424. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7425. </if>
  7426. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  7427. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  7428. </if>
  7429. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7430. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7431. </if>
  7432. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  7433. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  7434. </if>
  7435. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7436. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7437. </if>
  7438. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7439. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7440. </if>
  7441. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7442. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  7443. </if>
  7444. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7445. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7446. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7447. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7448. </if>
  7449. ) b
  7450. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7451. AND b.hospital_id = c.hospital_id
  7452. AND b.behospital_code = c.behospital_code
  7453. ) tt1
  7454. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7455. ,med_medical_record tt2,
  7456. qc_mode tt3
  7457. WHERE
  7458. tt2.is_deleted = 'N'
  7459. AND tt3.is_deleted = 'N'
  7460. AND tt1.hospital_id = tt2.hospital_id
  7461. AND tt1.behospital_code = tt2.behospital_code
  7462. AND tt2.mode_id = tt3.id
  7463. AND tt3.`name` = '手术记录'
  7464. </if>
  7465. ) be
  7466. left join med_check_info mci
  7467. on mci.is_deleted = 'N'
  7468. and mci.check_type = 0
  7469. and be.hospital_id = mci.hospital_id
  7470. and be.behospital_code = mci.behospital_code
  7471. left join med_check_info hm_mci
  7472. on hm_mci.is_deleted = 'N'
  7473. and hm_mci.check_type = 1
  7474. and be.hospital_id = hm_mci.hospital_id
  7475. and be.behospital_code = hm_mci.behospital_code
  7476. LEFT JOIN med_qcresult_cases e
  7477. on be.behospital_code = e.behospital_code
  7478. and be.hospital_id = e.hospital_id
  7479. AND e.is_deleted = 'N'
  7480. and e.cases_id = 243
  7481. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  7482. and be.hospital_id = t2.hospital_id
  7483. AND t2.is_deleted = 'N'
  7484. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  7485. AND t3.is_deleted = 'N'
  7486. )t1
  7487. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7488. ,med_home_page t2
  7489. WHERE
  7490. t2.is_deleted = 'N'
  7491. AND t1.hospital_id = t2.hospital_id
  7492. AND t1.behospital_code = t2.behospital_code
  7493. AND (
  7494. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7495. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7496. )
  7497. </if>
  7498. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7499. , med_medical_record b,
  7500. med_medical_record_content c,
  7501. med_home_page t2
  7502. WHERE
  7503. b.is_deleted = 'N'
  7504. and c.is_deleted = 'N'
  7505. and t2.is_deleted = 'N'
  7506. and t1.hospital_id = b.hospital_id
  7507. and t1.hospital_id = c.hospital_id
  7508. and t1.hospital_id = t2.hospital_id
  7509. AND t1.behospital_code = b.behospital_code
  7510. AND t1.behospital_code = t2.behospital_code
  7511. AND b.rec_id = c.rec_id
  7512. and b.mode_id = '24'
  7513. </if>
  7514. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7515. ,med_home_page t2
  7516. WHERE
  7517. t2.is_deleted = 'N'
  7518. AND t1.hospital_id = t2.hospital_id
  7519. AND t1.behospital_code = t2.behospital_code
  7520. AND t2.leave_hospital_type = '非医嘱离院'
  7521. </if>
  7522. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7523. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7524. AND t1.hospital_id = t2.hospital_id
  7525. AND t1.behospital_code = t2.behospital_code
  7526. </if>
  7527. )t
  7528. where 1=1
  7529. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  7530. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  7531. </if>
  7532. <if test="qcResultShortPageVO.checkStatus != null">
  7533. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7534. </if>
  7535. <if test="qcResultShortPageVO.mrStatus != null">
  7536. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7537. </if>
  7538. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7539. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7540. </if>
  7541. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7542. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7543. </if>
  7544. <if test="qcResultShortPageVO.chTimeStart != null ">
  7545. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7546. </if>
  7547. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7548. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7549. </if>
  7550. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7551. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7552. </if>
  7553. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7554. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7555. </if>
  7556. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7557. AND t.`level` = #{qcResultShortPageVO.level}
  7558. </if>
  7559. </select>
  7560. <!-- 病案首页改善率统计(首页)-->
  7561. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7562. SELECT
  7563. t2.homePageMRNum,
  7564. t1.improveNum,
  7565. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  7566. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7567. t1.improveToPassNum,
  7568. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  7569. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7570. t1.improveToFullNum,
  7571. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  7572. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7573. FROM
  7574. (
  7575. SELECT
  7576. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7577. sum( d.score_res = 20 ) AS improveToFullNum,
  7578. count(*) AS improveNum
  7579. FROM
  7580. med_behospital_info a,
  7581. med_home_page b,
  7582. med_qcresult_info c,
  7583. med_qcresult_cases d,
  7584. (
  7585. SELECT
  7586. m4.*
  7587. FROM
  7588. med_behospital_info m1,
  7589. med_home_page m2,
  7590. med_qcresult_info m3,
  7591. med_qcresult_cases m4
  7592. WHERE
  7593. m1.is_deleted = 'N'
  7594. AND m2.is_deleted = 'N'
  7595. AND m3.is_deleted = 'Y'
  7596. AND m4.is_deleted = 'Y'
  7597. AND m1.hospital_id = m2.hospital_id
  7598. AND m1.hospital_id = m3.hospital_id
  7599. AND m1.hospital_id = m4.hospital_id
  7600. AND m1.behospital_code = m2.behospital_code
  7601. AND m1.behospital_code = m3.behospital_code
  7602. AND m1.behospital_code = m4.behospital_code
  7603. AND m3.gmt_create = m4.gmt_create
  7604. AND m3.have_home_page = 1
  7605. AND m4.cases_id = 243
  7606. <if test="isPlacefile != null and isPlacefile != ''">
  7607. and m1.is_placefile = #{isPlacefile}
  7608. </if>
  7609. AND m1.qc_type_id != 0
  7610. <if test="hospitalId != null and hospitalId != ''">
  7611. AND m1.hospital_id = #{hospitalId}
  7612. </if>
  7613. <if test="isPlacefile != null and isPlacefile == 0">
  7614. <if test="startDate != null and startDate != ''">
  7615. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7616. </if>
  7617. <if test="endDate != null and endDate != ''">
  7618. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7619. </if>
  7620. </if>
  7621. <if test="isPlacefile != null and isPlacefile == 1">
  7622. <if test="startDate != null and startDate != ''">
  7623. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7624. </if>
  7625. <if test="endDate != null and endDate != ''">
  7626. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7627. </if>
  7628. </if>
  7629. GROUP BY
  7630. m1.behospital_code
  7631. ORDER BY
  7632. m1.behospital_code,
  7633. m4.gmt_create
  7634. ) e
  7635. WHERE
  7636. a.is_deleted = 'N'
  7637. AND b.is_deleted = 'N'
  7638. AND c.is_deleted = 'N'
  7639. AND d.is_deleted = 'N'
  7640. AND a.hospital_id = b.hospital_id
  7641. AND a.hospital_id = c.hospital_id
  7642. AND a.hospital_id = d.hospital_id
  7643. AND a.hospital_id = e.hospital_id
  7644. AND a.behospital_code = b.behospital_code
  7645. AND a.behospital_code = c.behospital_code
  7646. AND a.behospital_code = d.behospital_code
  7647. AND a.behospital_code = e.behospital_code
  7648. AND d.cases_id = 243
  7649. AND d.score_res > e.score_res
  7650. <if test="isPlacefile != null and isPlacefile != ''">
  7651. and a.is_placefile = #{isPlacefile}
  7652. </if>
  7653. AND a.qc_type_id != 0
  7654. <if test="hospitalId != null and hospitalId != ''">
  7655. AND a.hospital_id = #{hospitalId}
  7656. </if>
  7657. <if test="isPlacefile != null and isPlacefile == 0">
  7658. <if test="startDate != null and startDate != ''">
  7659. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7660. </if>
  7661. <if test="endDate != null and endDate != ''">
  7662. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7663. </if>
  7664. </if>
  7665. <if test="isPlacefile != null and isPlacefile == 1">
  7666. <if test="startDate != null and startDate != ''">
  7667. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7668. </if>
  7669. <if test="endDate != null and endDate != ''">
  7670. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7671. </if>
  7672. </if>
  7673. ) t1,
  7674. (
  7675. SELECT
  7676. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7677. FROM
  7678. med_behospital_info a,
  7679. med_home_page b,
  7680. med_qcresult_info c
  7681. WHERE
  7682. a.is_deleted = 'N'
  7683. AND b.is_deleted = 'N'
  7684. AND a.hospital_id = b.hospital_id
  7685. AND a.hospital_id = c.hospital_id
  7686. AND a.behospital_code = b.behospital_code
  7687. AND a.behospital_code = c.behospital_code
  7688. AND a.qc_type_id != 0
  7689. <if test="isPlacefile != null and isPlacefile != ''">
  7690. and a.is_placefile = #{isPlacefile}
  7691. </if>
  7692. <if test="hospitalId != null and hospitalId != ''">
  7693. AND a.hospital_id = #{hospitalId}
  7694. </if>
  7695. <if test="isPlacefile != null and isPlacefile == 0">
  7696. <if test="startDate != null and startDate != ''">
  7697. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7698. </if>
  7699. <if test="endDate != null and endDate != ''">
  7700. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7701. </if>
  7702. </if>
  7703. <if test="isPlacefile != null and isPlacefile == 1">
  7704. <if test="startDate != null and startDate != ''">
  7705. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7706. </if>
  7707. <if test="endDate != null and endDate != ''">
  7708. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7709. </if>
  7710. </if>
  7711. ) t2
  7712. </select>
  7713. <!-- 质控核查统计(内页)-->
  7714. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7715. SELECT
  7716. t.*
  7717. FROM
  7718. (SELECT
  7719. mr.beh_dept_id AS deptId,
  7720. mr.beh_dept_name AS deptName,
  7721. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7722. ck.checkedNum AS checkedNum,
  7723. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7724. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7725. hmmr_t.homePageMRNum,
  7726. improve_t.improveNum,
  7727. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7728. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7729. improve_t.improveToPassNum,
  7730. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7731. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7732. improve_t.improveToFullNum,
  7733. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7734. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7735. FROM
  7736. (
  7737. SELECT
  7738. a.beh_dept_id,
  7739. a.beh_dept_name,
  7740. count(*) AS mrNum
  7741. FROM
  7742. med_behospital_info a,
  7743. med_qcresult_info b
  7744. WHERE
  7745. a.is_deleted = 'N'
  7746. AND b.is_deleted = 'N'
  7747. AND a.hospital_id = b.hospital_id
  7748. AND a.behospital_code = b.behospital_code
  7749. AND a.qc_type_id != 0
  7750. <if test="isPlacefile != null and isPlacefile != ''">
  7751. and a.is_placefile = #{isPlacefile}
  7752. </if>
  7753. <if test="hospitalId != null and hospitalId != ''">
  7754. AND a.hospital_id = #{hospitalId}
  7755. </if>
  7756. <if test="isPlacefile != null and isPlacefile == 0">
  7757. <if test="startDate != null and startDate != ''">
  7758. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7759. </if>
  7760. <if test="endDate != null and endDate != ''">
  7761. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7762. </if>
  7763. </if>
  7764. <if test="isPlacefile != null and isPlacefile == 1">
  7765. <if test="startDate != null and startDate != ''">
  7766. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7767. </if>
  7768. <if test="endDate != null and endDate != ''">
  7769. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7770. </if>
  7771. </if>
  7772. <if test="deptName != null and deptName != ''">
  7773. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7774. </if>
  7775. GROUP BY
  7776. a.beh_dept_id,
  7777. a.beh_dept_name
  7778. ) mr
  7779. LEFT JOIN (
  7780. SELECT
  7781. a.beh_dept_id,
  7782. a.beh_dept_name,
  7783. count(*) AS checkedNum
  7784. FROM
  7785. med_behospital_info a,
  7786. med_qcresult_info b,
  7787. med_check_info c
  7788. WHERE
  7789. a.is_deleted = 'N'
  7790. AND b.is_deleted = 'N'
  7791. AND c.is_deleted = 'N'
  7792. AND a.hospital_id = b.hospital_id
  7793. AND a.hospital_id = c.hospital_id
  7794. AND a.behospital_code = b.behospital_code
  7795. AND a.behospital_code = c.behospital_code
  7796. AND a.qc_type_id != 0
  7797. AND ifnull(c.`status`,0) = 1
  7798. AND c.check_type in (0,2)
  7799. <if test="isPlacefile != null and isPlacefile != ''">
  7800. and a.is_placefile = #{isPlacefile}
  7801. </if>
  7802. <if test="hospitalId != null and hospitalId != ''">
  7803. AND a.hospital_id = #{hospitalId}
  7804. </if>
  7805. <if test="isPlacefile != null and isPlacefile == 0">
  7806. <if test="startDate != null and startDate != ''">
  7807. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7808. </if>
  7809. <if test="endDate != null and endDate != ''">
  7810. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7811. </if>
  7812. </if>
  7813. <if test="isPlacefile != null and isPlacefile == 1">
  7814. <if test="startDate != null and startDate != ''">
  7815. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7816. </if>
  7817. <if test="endDate != null and endDate != ''">
  7818. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7819. </if>
  7820. </if>
  7821. <if test="deptName != null and deptName != ''">
  7822. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7823. </if>
  7824. GROUP BY
  7825. a.beh_dept_id,
  7826. a.beh_dept_name
  7827. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  7828. AND mr.beh_dept_name = ck.beh_dept_name
  7829. LEFT JOIN (
  7830. SELECT
  7831. a.beh_dept_id,
  7832. a.beh_dept_name,
  7833. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7834. FROM
  7835. med_behospital_info a,
  7836. med_home_page b,
  7837. med_qcresult_info c
  7838. WHERE
  7839. a.is_deleted = 'N'
  7840. AND b.is_deleted = 'N'
  7841. AND a.hospital_id = b.hospital_id
  7842. AND a.hospital_id = c.hospital_id
  7843. AND a.behospital_code = b.behospital_code
  7844. AND a.behospital_code = c.behospital_code
  7845. AND a.qc_type_id != 0
  7846. <if test="isPlacefile != null and isPlacefile != ''">
  7847. and a.is_placefile = #{isPlacefile}
  7848. </if>
  7849. <if test="hospitalId != null and hospitalId != ''">
  7850. AND a.hospital_id = #{hospitalId}
  7851. </if>
  7852. <if test="isPlacefile != null and isPlacefile == 0">
  7853. <if test="startDate != null and startDate != ''">
  7854. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7855. </if>
  7856. <if test="endDate != null and endDate != ''">
  7857. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7858. </if>
  7859. </if>
  7860. <if test="isPlacefile != null and isPlacefile == 1">
  7861. <if test="startDate != null and startDate != ''">
  7862. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7863. </if>
  7864. <if test="endDate != null and endDate != ''">
  7865. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7866. </if>
  7867. </if>
  7868. <if test="deptName != null and deptName != ''">
  7869. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7870. </if>
  7871. GROUP BY
  7872. a.beh_dept_id,
  7873. a.beh_dept_name
  7874. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  7875. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  7876. LEFT JOIN (
  7877. SELECT
  7878. a.beh_dept_id,
  7879. a.beh_dept_name,
  7880. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7881. sum( d.score_res = 20 ) AS improveToFullNum,
  7882. count(*) AS improveNum
  7883. FROM
  7884. med_behospital_info a,
  7885. med_home_page b,
  7886. med_qcresult_info c,
  7887. med_qcresult_cases d,
  7888. (
  7889. SELECT
  7890. m4.*
  7891. FROM
  7892. med_behospital_info m1,
  7893. med_home_page m2,
  7894. med_qcresult_info m3,
  7895. med_qcresult_cases m4
  7896. WHERE
  7897. m1.is_deleted = 'N'
  7898. AND m2.is_deleted = 'N'
  7899. AND m3.is_deleted = 'Y'
  7900. AND m4.is_deleted = 'Y'
  7901. AND m1.hospital_id = m2.hospital_id
  7902. AND m1.hospital_id = m3.hospital_id
  7903. AND m1.hospital_id = m4.hospital_id
  7904. AND m1.behospital_code = m2.behospital_code
  7905. AND m1.behospital_code = m3.behospital_code
  7906. AND m1.behospital_code = m4.behospital_code
  7907. AND m3.gmt_create = m4.gmt_create
  7908. AND m3.have_home_page = 1
  7909. AND m4.cases_id = 243
  7910. <if test="isPlacefile != null and isPlacefile != ''">
  7911. and m1.is_placefile = #{isPlacefile}
  7912. </if>
  7913. AND m1.qc_type_id != 0
  7914. <if test="hospitalId != null and hospitalId != ''">
  7915. AND m1.hospital_id = #{hospitalId}
  7916. </if>
  7917. <if test="isPlacefile != null and isPlacefile == 0">
  7918. <if test="startDate != null and startDate != ''">
  7919. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7920. </if>
  7921. <if test="endDate != null and endDate != ''">
  7922. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7923. </if>
  7924. </if>
  7925. <if test="isPlacefile != null and isPlacefile == 1">
  7926. <if test="startDate != null and startDate != ''">
  7927. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7928. </if>
  7929. <if test="endDate != null and endDate != ''">
  7930. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7931. </if>
  7932. </if>
  7933. <if test="deptName != null and deptName != ''">
  7934. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7935. </if>
  7936. GROUP BY
  7937. m1.behospital_code
  7938. ORDER BY
  7939. m1.behospital_code,
  7940. m4.gmt_create
  7941. ) e
  7942. WHERE
  7943. a.is_deleted = 'N'
  7944. AND b.is_deleted = 'N'
  7945. AND c.is_deleted = 'N'
  7946. AND d.is_deleted = 'N'
  7947. AND a.hospital_id = b.hospital_id
  7948. AND a.hospital_id = c.hospital_id
  7949. AND a.hospital_id = d.hospital_id
  7950. AND a.hospital_id = e.hospital_id
  7951. AND a.behospital_code = b.behospital_code
  7952. AND a.behospital_code = c.behospital_code
  7953. AND a.behospital_code = d.behospital_code
  7954. AND a.behospital_code = e.behospital_code
  7955. AND d.cases_id = 243
  7956. AND d.score_res > e.score_res
  7957. <if test="hospitalId != null and hospitalId != ''">
  7958. AND a.hospital_id = #{hospitalId}
  7959. </if>
  7960. <if test="isPlacefile != null and isPlacefile == 0">
  7961. <if test="startDate != null and startDate != ''">
  7962. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7963. </if>
  7964. <if test="endDate != null and endDate != ''">
  7965. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7966. </if>
  7967. </if>
  7968. <if test="isPlacefile != null and isPlacefile == 1">
  7969. <if test="startDate != null and startDate != ''">
  7970. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7971. </if>
  7972. <if test="endDate != null and endDate != ''">
  7973. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7974. </if>
  7975. </if>
  7976. <if test="deptName != null and deptName != ''">
  7977. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7978. </if>
  7979. GROUP BY
  7980. a.beh_dept_id,
  7981. a.beh_dept_name
  7982. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  7983. AND mr.beh_dept_name = improve_t.beh_dept_name
  7984. ) t
  7985. <if test="asc != null and asc !=''">
  7986. order by
  7987. <choose>
  7988. <when test='asc=="deptId"'>deptId asc</when>
  7989. <when test='asc=="deptName"'>deptName asc</when>
  7990. <when test='asc=="mrNum"'>mrNum asc</when>
  7991. <when test='asc=="checkedNum"'>checkedNum asc</when>
  7992. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  7993. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  7994. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  7995. <when test='asc=="improveNum"'>improveNum asc</when>
  7996. <when test='asc=="improvePercent"'>improvePercent asc</when>
  7997. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  7998. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  7999. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8000. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8001. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8002. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8003. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8004. <otherwise>deptName asc</otherwise>
  8005. </choose>
  8006. </if>
  8007. <if test="desc != null and desc!=''">
  8008. order by
  8009. <choose>
  8010. <when test='desc=="deptId"'>deptId desc</when>
  8011. <when test='desc=="deptName"'>deptName desc</when>
  8012. <when test='desc=="mrNum"'>mrNum desc</when>
  8013. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8014. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8015. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8016. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8017. <when test='desc=="improveNum"'>improveNum desc</when>
  8018. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8019. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8020. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8021. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8022. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8023. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8024. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8025. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8026. <otherwise>deptName desc</otherwise>
  8027. </choose>
  8028. </if>
  8029. </select>
  8030. <!-- 质控核查统计-科室(内页)-->
  8031. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  8032. SELECT
  8033. t.*
  8034. FROM
  8035. (SELECT
  8036. mr.beh_dept_id AS deptId,
  8037. mr.beh_dept_name AS deptName,
  8038. mr.doctorId,
  8039. mr.doctorName,
  8040. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8041. ck.checkedNum AS checkedNum,
  8042. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8043. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8044. hmmr_t.homePageMRNum,
  8045. improve_t.improveNum,
  8046. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8047. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8048. improve_t.improveToPassNum,
  8049. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8050. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8051. improve_t.improveToFullNum,
  8052. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8053. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8054. FROM
  8055. (
  8056. SELECT
  8057. a.beh_dept_id,
  8058. a.beh_dept_name,
  8059. a.doctor_id as doctorId,
  8060. a.doctor_name as doctorName,
  8061. count(*) AS mrNum
  8062. FROM
  8063. med_behospital_info a,
  8064. med_qcresult_info b,
  8065. sys_user_dept c
  8066. WHERE
  8067. a.is_deleted = 'N'
  8068. AND b.is_deleted = 'N'
  8069. AND c.is_deleted = 'N'
  8070. AND a.hospital_id = b.hospital_id
  8071. AND a.hospital_id = c.hospital_id
  8072. AND a.beh_dept_id = c.dept_id
  8073. AND a.behospital_code = b.behospital_code
  8074. AND a.qc_type_id != 0
  8075. <if test="userId!=null">
  8076. AND c.user_id = #{userId}
  8077. </if>
  8078. <if test="isPlacefile != null and isPlacefile != ''">
  8079. and a.is_placefile = #{isPlacefile}
  8080. </if>
  8081. <if test="hospitalId != null and hospitalId != ''">
  8082. AND a.hospital_id = #{hospitalId}
  8083. </if>
  8084. <if test="isPlacefile != null and isPlacefile == 0">
  8085. <if test="startDate != null and startDate != ''">
  8086. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8087. </if>
  8088. <if test="endDate != null and endDate != ''">
  8089. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8090. </if>
  8091. </if>
  8092. <if test="isPlacefile != null and isPlacefile == 1">
  8093. <if test="startDate != null and startDate != ''">
  8094. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8095. </if>
  8096. <if test="endDate != null and endDate != ''">
  8097. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8098. </if>
  8099. </if>
  8100. <if test="deptName != null and deptName != ''">
  8101. and a.beh_dept_name = #{deptName}
  8102. </if>
  8103. <if test="doctorName != null and doctorName != ''">
  8104. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8105. </if>
  8106. GROUP BY
  8107. a.doctor_id,
  8108. a.doctor_name
  8109. ) mr
  8110. LEFT JOIN (
  8111. SELECT
  8112. a.beh_dept_id,
  8113. a.beh_dept_name,
  8114. a.doctor_id as doctorId,
  8115. a.doctor_name as doctorName,
  8116. count(*) AS checkedNum
  8117. FROM
  8118. med_behospital_info a,
  8119. med_qcresult_info b,
  8120. med_check_info c,
  8121. sys_user_dept d
  8122. WHERE
  8123. a.is_deleted = 'N'
  8124. AND b.is_deleted = 'N'
  8125. AND c.is_deleted = 'N'
  8126. AND d.is_deleted = 'N'
  8127. AND a.hospital_id = b.hospital_id
  8128. AND a.hospital_id = c.hospital_id
  8129. AND a.hospital_id = d.hospital_id
  8130. AND a.behospital_code = b.behospital_code
  8131. AND a.behospital_code = c.behospital_code
  8132. AND a.beh_dept_id = d.dept_id
  8133. AND a.qc_type_id != 0
  8134. AND ifnull(c.`status`,0) = 1
  8135. AND c.check_type = 0
  8136. <if test="userId!=null">
  8137. AND d.user_id = #{userId}
  8138. </if>
  8139. <if test="isPlacefile != null and isPlacefile != ''">
  8140. and a.is_placefile = #{isPlacefile}
  8141. </if>
  8142. <if test="hospitalId != null and hospitalId != ''">
  8143. AND a.hospital_id = #{hospitalId}
  8144. </if>
  8145. <if test="isPlacefile != null and isPlacefile == 0">
  8146. <if test="startDate != null and startDate != ''">
  8147. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8148. </if>
  8149. <if test="endDate != null and endDate != ''">
  8150. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8151. </if>
  8152. </if>
  8153. <if test="isPlacefile != null and isPlacefile == 1">
  8154. <if test="startDate != null and startDate != ''">
  8155. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8156. </if>
  8157. <if test="endDate != null and endDate != ''">
  8158. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8159. </if>
  8160. </if>
  8161. <if test="deptName != null and deptName != ''">
  8162. and a.beh_dept_name = #{deptName}
  8163. </if>
  8164. <if test="doctorName != null and doctorName != ''">
  8165. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8166. </if>
  8167. GROUP BY
  8168. a.doctor_id,
  8169. a.doctor_name
  8170. ) ck ON mr.doctorId = ck.doctorId
  8171. AND mr.doctorName = ck.doctorName
  8172. LEFT JOIN (
  8173. SELECT
  8174. a.beh_dept_id,
  8175. a.beh_dept_name,
  8176. a.doctor_id as doctorId,
  8177. a.doctor_name as doctorName,
  8178. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8179. FROM
  8180. med_behospital_info a,
  8181. med_home_page b,
  8182. med_qcresult_info c,
  8183. sys_user_dept d
  8184. WHERE
  8185. a.is_deleted = 'N'
  8186. AND b.is_deleted = 'N'
  8187. AND c.is_deleted = 'N'
  8188. AND d.is_deleted = 'N'
  8189. AND a.hospital_id = b.hospital_id
  8190. AND a.hospital_id = c.hospital_id
  8191. AND a.hospital_id = d.hospital_id
  8192. AND a.behospital_code = b.behospital_code
  8193. AND a.behospital_code = c.behospital_code
  8194. AND a.beh_dept_id = d.dept_id
  8195. AND a.qc_type_id != 0
  8196. <if test="userId!=null">
  8197. AND d.user_id = #{userId}
  8198. </if>
  8199. <if test="isPlacefile != null and isPlacefile != ''">
  8200. and a.is_placefile = #{isPlacefile}
  8201. </if>
  8202. <if test="hospitalId != null and hospitalId != ''">
  8203. AND a.hospital_id = #{hospitalId}
  8204. </if>
  8205. <if test="isPlacefile != null and isPlacefile == 0">
  8206. <if test="startDate != null and startDate != ''">
  8207. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8208. </if>
  8209. <if test="endDate != null and endDate != ''">
  8210. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8211. </if>
  8212. </if>
  8213. <if test="isPlacefile != null and isPlacefile == 1">
  8214. <if test="startDate != null and startDate != ''">
  8215. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8216. </if>
  8217. <if test="endDate != null and endDate != ''">
  8218. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8219. </if>
  8220. </if>
  8221. <if test="deptName != null and deptName != ''">
  8222. and a.beh_dept_name = #{deptName}
  8223. </if>
  8224. <if test="doctorName != null and doctorName != ''">
  8225. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8226. </if>
  8227. GROUP BY
  8228. a.doctor_id,
  8229. a.doctor_name
  8230. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8231. AND mr.doctorName = hmmr_t.doctorName
  8232. LEFT JOIN (
  8233. SELECT
  8234. a.beh_dept_id,
  8235. a.beh_dept_name,
  8236. a.doctor_id as doctorId,
  8237. a.doctor_name as doctorName,
  8238. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8239. sum( d.score_res = 20 ) AS improveToFullNum,
  8240. count(*) AS improveNum
  8241. FROM
  8242. med_behospital_info a,
  8243. med_home_page b,
  8244. med_qcresult_info c,
  8245. med_qcresult_cases d,
  8246. sys_user_dept f,
  8247. (
  8248. SELECT
  8249. m4.*
  8250. FROM
  8251. med_behospital_info m1,
  8252. med_home_page m2,
  8253. med_qcresult_info m3,
  8254. med_qcresult_cases m4
  8255. WHERE
  8256. m1.is_deleted = 'N'
  8257. AND m2.is_deleted = 'N'
  8258. AND m3.is_deleted = 'Y'
  8259. AND m4.is_deleted = 'Y'
  8260. AND m1.hospital_id = m2.hospital_id
  8261. AND m1.hospital_id = m3.hospital_id
  8262. AND m1.hospital_id = m4.hospital_id
  8263. AND m1.behospital_code = m2.behospital_code
  8264. AND m1.behospital_code = m3.behospital_code
  8265. AND m1.behospital_code = m4.behospital_code
  8266. AND m3.gmt_create = m4.gmt_create
  8267. AND m3.have_home_page = 1
  8268. AND m4.cases_id = 243
  8269. <if test="isPlacefile != null and isPlacefile != ''">
  8270. and m1.is_placefile = #{isPlacefile}
  8271. </if>
  8272. AND m1.qc_type_id != 0
  8273. <if test="hospitalId != null and hospitalId != ''">
  8274. AND m1.hospital_id = #{hospitalId}
  8275. </if>
  8276. <if test="isPlacefile != null and isPlacefile == 0">
  8277. <if test="startDate != null and startDate != ''">
  8278. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8279. </if>
  8280. <if test="endDate != null and endDate != ''">
  8281. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8282. </if>
  8283. </if>
  8284. <if test="isPlacefile != null and isPlacefile == 1">
  8285. <if test="startDate != null and startDate != ''">
  8286. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8287. </if>
  8288. <if test="endDate != null and endDate != ''">
  8289. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8290. </if>
  8291. </if>
  8292. <if test="deptName != null and deptName != ''">
  8293. and m1.beh_dept_name = #{deptName}
  8294. </if>
  8295. GROUP BY
  8296. m1.behospital_code
  8297. ORDER BY
  8298. m1.behospital_code,
  8299. m4.gmt_create
  8300. ) e
  8301. WHERE
  8302. a.is_deleted = 'N'
  8303. AND b.is_deleted = 'N'
  8304. AND c.is_deleted = 'N'
  8305. AND d.is_deleted = 'N'
  8306. AND f.is_deleted = 'N'
  8307. AND a.hospital_id = b.hospital_id
  8308. AND a.hospital_id = c.hospital_id
  8309. AND a.hospital_id = d.hospital_id
  8310. AND a.hospital_id = e.hospital_id
  8311. AND a.hospital_id = f.hospital_id
  8312. AND a.behospital_code = b.behospital_code
  8313. AND a.behospital_code = c.behospital_code
  8314. AND a.behospital_code = d.behospital_code
  8315. AND a.behospital_code = e.behospital_code
  8316. AND a.beh_dept_id = f.dept_id
  8317. <if test="userId!=null">
  8318. AND f.user_id = #{userId}
  8319. </if>
  8320. AND d.cases_id = 243
  8321. AND d.score_res > e.score_res
  8322. <if test="hospitalId != null and hospitalId != ''">
  8323. AND a.hospital_id = #{hospitalId}
  8324. </if>
  8325. <if test="isPlacefile != null and isPlacefile == 0">
  8326. <if test="startDate != null and startDate != ''">
  8327. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8328. </if>
  8329. <if test="endDate != null and endDate != ''">
  8330. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8331. </if>
  8332. </if>
  8333. <if test="isPlacefile != null and isPlacefile == 1">
  8334. <if test="startDate != null and startDate != ''">
  8335. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8336. </if>
  8337. <if test="endDate != null and endDate != ''">
  8338. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8339. </if>
  8340. </if>
  8341. <if test="doctorName != null and doctorName != ''">
  8342. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8343. </if>
  8344. <if test="deptName != null and deptName != ''">
  8345. and a.beh_dept_name = #{deptName}
  8346. </if>
  8347. GROUP BY
  8348. a.doctor_id,
  8349. a.doctor_name
  8350. ) improve_t ON mr.doctorId = improve_t.doctorId
  8351. AND mr.doctorName = improve_t.doctorName
  8352. ) t
  8353. <if test="asc != null and asc !=''">
  8354. order by
  8355. <choose>
  8356. <when test='asc=="deptId"'>deptId asc</when>
  8357. <when test='asc=="deptName"'>deptName asc</when>
  8358. <when test='asc=="doctorName"'>doctorName asc</when>
  8359. <when test='asc=="mrNum"'>mrNum asc</when>
  8360. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8361. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8362. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8363. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8364. <when test='asc=="improveNum"'>improveNum asc</when>
  8365. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8366. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8367. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8368. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8369. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8370. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8371. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8372. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8373. <otherwise>doctorName asc</otherwise>
  8374. </choose>
  8375. </if>
  8376. <if test="desc != null and desc!=''">
  8377. order by
  8378. <choose>
  8379. <when test='desc=="deptId"'>deptId desc</when>
  8380. <when test='desc=="deptName"'>deptName desc</when>
  8381. <when test='desc=="doctorName"'>doctorName desc</when>
  8382. <when test='desc=="mrNum"'>mrNum desc</when>
  8383. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8384. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8385. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8386. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8387. <when test='desc=="improveNum"'>improveNum desc</when>
  8388. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8389. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8390. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8391. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8392. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8393. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8394. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8395. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8396. <otherwise>deptName desc</otherwise>
  8397. </choose>
  8398. </if>
  8399. </select>
  8400. <!-- 离院病人评分详情页导出-->
  8401. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  8402. SELECT
  8403. f1.behDeptId,
  8404. f1.behDeptName,
  8405. f1.doctorName,
  8406. f1.patName,
  8407. f1.behospitalCode,
  8408. f1.hospitalId,
  8409. f1.behospitalDate,
  8410. f1.leaveHospitalDate,
  8411. f1.score,
  8412. f2.avgScore,
  8413. f1.scoreBn,
  8414. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8415. f1.msg,
  8416. f1.caseName,
  8417. </if>
  8418. f1.checkStatus,
  8419. f1.mrStatus,
  8420. f1.chName,
  8421. f1.mrName,
  8422. f1.chTime,
  8423. f1.mrTime
  8424. FROM
  8425. (SELECT
  8426. t.doctorName,
  8427. t.`name` AS patName,
  8428. t.behospitalCode AS behospitalCode,
  8429. t.behospitalDate AS behospitalDate,
  8430. t.leaveHospitalDate AS leaveHospitalDate,
  8431. qi.score_res AS score,
  8432. t.scoreBn,
  8433. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8434. qd.msg AS msg,
  8435. qc.NAME AS caseName,
  8436. </if>
  8437. t.behDeptId,
  8438. t.behDeptName,
  8439. t.hospitalId,
  8440. t.checkStatus,
  8441. t.mrStatus,
  8442. t.chName,
  8443. t.mrName,
  8444. t.chTime,
  8445. t.mrTime
  8446. FROM
  8447. (SELECT DISTINCT
  8448. t1.hospital_id AS hospitalId,
  8449. t1.behospital_code AS behospitalCode,
  8450. t1.bed_code AS bedCode,
  8451. t1.LEVEL AS LEVEL,
  8452. t1.grade_type AS gradeType,
  8453. t1.score_res AS scoreRes,
  8454. t1.scoreBn,
  8455. t1.NAME AS NAME,
  8456. t1.sex AS sex,
  8457. t1.beh_dept_id AS behDeptId,
  8458. t1.beh_dept_name AS behDeptName,
  8459. t1.doctor_id AS doctorId,
  8460. t1.doctor_name AS doctorName,
  8461. t1.beh_doctor_id AS behDoctorId,
  8462. t1.beh_doctor_name AS behDoctorName,
  8463. t1.director_doctor_id AS directorDoctorId,
  8464. t1.director_doctor_name AS directorDoctorName,
  8465. t1.birthday AS birthday,
  8466. t1.behospital_date AS behospitalDate,
  8467. t1.leave_hospital_date AS leaveHospitalDate,
  8468. t1.placefile_date AS placefileDate,
  8469. t1.gmt_create AS gradeTime,
  8470. t1.diagnose,
  8471. t1.ward_name AS wardName,
  8472. t1.checkStatus,
  8473. t1.mrStatus,
  8474. t1.chName,
  8475. t1.mrName,
  8476. t1.chTime,
  8477. t1.mrTime,
  8478. t2.age,
  8479. t1.file_code AS fileCode
  8480. FROM
  8481. (
  8482. SELECT be.*,
  8483. ifnull(mci.status,0) AS checkStatus,
  8484. ifnull(hm_mci.status,0) AS mrStatus,
  8485. mci.check_name as chName,
  8486. e.score_res as scoreBn,
  8487. hm_mci.check_name as mrName,
  8488. mci.gmt_create as chTime,
  8489. hm_mci.gmt_create as mrTime
  8490. FROM
  8491. (
  8492. SELECT DISTINCT
  8493. tt1.*
  8494. FROM
  8495. (
  8496. SELECT
  8497. b.*,
  8498. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8499. c.grade_type,
  8500. c.score_res,
  8501. c.gmt_create
  8502. FROM
  8503. (
  8504. SELECT DISTINCT
  8505. a.hospital_id,
  8506. a.behospital_code,
  8507. a.bed_code,
  8508. a.NAME,
  8509. a.sex,
  8510. a.beh_dept_id,
  8511. a.beh_dept_name,
  8512. a.birthday,
  8513. a.behospital_date,
  8514. a.leave_hospital_date,
  8515. a.doctor_id,
  8516. a.doctor_name,
  8517. a.beh_doctor_id,
  8518. a.beh_doctor_name,
  8519. a.director_doctor_id,
  8520. a.director_doctor_name,
  8521. a.diagnose,
  8522. a.placefile_date,
  8523. a.ward_name,
  8524. a.file_code
  8525. FROM
  8526. med_behospital_info a
  8527. WHERE
  8528. a.is_deleted = 'N'
  8529. AND a.qc_type_id != 0
  8530. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8531. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8532. </if>
  8533. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8534. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8535. </if>
  8536. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8537. <if test="qcResultShortPageVO.startDate != null ">
  8538. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8539. </if>
  8540. <if test="qcResultShortPageVO.endDate != null ">
  8541. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8542. </if>
  8543. </if>
  8544. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8545. <if test="qcResultShortPageVO.startDate != null ">
  8546. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8547. </if>
  8548. <if test="qcResultShortPageVO.endDate != null">
  8549. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8550. </if>
  8551. </if>
  8552. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8553. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8554. </if>
  8555. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8556. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8557. </if>
  8558. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8559. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8560. </if>
  8561. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8562. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8563. </if>
  8564. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8565. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8566. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8567. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8568. </if>
  8569. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8570. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8571. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8572. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8573. </if>
  8574. ) b
  8575. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8576. AND b.hospital_id = c.hospital_id
  8577. AND b.behospital_code = c.behospital_code
  8578. ) tt1
  8579. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8580. ,med_medical_record tt2,
  8581. qc_mode tt3
  8582. WHERE
  8583. tt2.is_deleted = 'N'
  8584. AND tt3.is_deleted = 'N'
  8585. AND tt1.hospital_id = tt2.hospital_id
  8586. AND tt1.behospital_code = tt2.behospital_code
  8587. AND tt2.mode_id = tt3.id
  8588. AND tt3.`name` = '手术记录'
  8589. </if>
  8590. ) be
  8591. left join med_check_info mci
  8592. on mci.is_deleted = 'N'
  8593. and mci.check_type = 0
  8594. and be.hospital_id = mci.hospital_id
  8595. and be.behospital_code = mci.behospital_code
  8596. left join med_check_info hm_mci
  8597. on hm_mci.is_deleted = 'N'
  8598. and hm_mci.check_type = 1
  8599. and be.hospital_id = hm_mci.hospital_id
  8600. and be.behospital_code = hm_mci.behospital_code
  8601. LEFT JOIN med_qcresult_cases e
  8602. on be.behospital_code = e.behospital_code
  8603. and be.hospital_id = e.hospital_id
  8604. AND e.is_deleted = 'N'
  8605. and e.cases_id = 243
  8606. )t1
  8607. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8608. ,med_home_page t2
  8609. WHERE
  8610. t2.is_deleted = 'N'
  8611. AND t1.hospital_id = t2.hospital_id
  8612. AND t1.behospital_code = t2.behospital_code
  8613. AND (
  8614. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  8615. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8616. )
  8617. </if>
  8618. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8619. ,med_home_page t2
  8620. WHERE
  8621. t2.is_deleted = 'N'
  8622. AND t1.hospital_id = t2.hospital_id
  8623. AND t1.behospital_code = t2.behospital_code
  8624. AND t2.return_to_type = '死亡'
  8625. </if>
  8626. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8627. ,med_home_page t2
  8628. WHERE
  8629. t2.is_deleted = 'N'
  8630. AND t1.hospital_id = t2.hospital_id
  8631. AND t1.behospital_code = t2.behospital_code
  8632. AND t2.leave_hospital_type = '非医嘱离院'
  8633. </if>
  8634. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8635. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8636. AND t1.hospital_id = t2.hospital_id
  8637. AND t1.behospital_code = t2.behospital_code
  8638. </if>
  8639. )t
  8640. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8641. AND t.hospitalId = qi.hospital_id
  8642. AND t.behospitalCode = qi.behospital_code
  8643. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8644. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  8645. AND t.hospitalId = qd.hospital_id
  8646. AND t.behospitalCode = qd.behospital_code
  8647. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  8648. AND qd.cases_id = qc.id
  8649. </if>
  8650. where 1=1
  8651. <if test="qcResultShortPageVO.checkStatus != null">
  8652. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8653. </if>
  8654. <if test="qcResultShortPageVO.mrStatus != null">
  8655. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8656. </if>
  8657. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8658. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8659. </if>
  8660. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8661. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8662. </if>
  8663. <if test="qcResultShortPageVO.chTimeStart != null ">
  8664. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8665. </if>
  8666. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8667. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8668. </if>
  8669. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8670. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8671. </if>
  8672. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8673. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8674. </if>
  8675. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8676. AND t.`level` = #{qcResultShortPageVO.level}
  8677. </if>)f1,(SELECT
  8678. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8679. t.behDeptId,
  8680. t.behDeptName
  8681. FROM
  8682. (SELECT DISTINCT
  8683. t1.hospital_id AS hospitalId,
  8684. t1.behospital_code AS behospitalCode,
  8685. t1.bed_code AS bedCode,
  8686. t1.LEVEL AS LEVEL,
  8687. t1.grade_type AS gradeType,
  8688. t1.score_res AS scoreRes,
  8689. t1.NAME AS NAME,
  8690. t1.sex AS sex,
  8691. t1.beh_dept_id AS behDeptId,
  8692. t1.beh_dept_name AS behDeptName,
  8693. t1.doctor_id AS doctorId,
  8694. t1.doctor_name AS doctorName,
  8695. t1.beh_doctor_id AS behDoctorId,
  8696. t1.beh_doctor_name AS behDoctorName,
  8697. t1.director_doctor_id AS directorDoctorId,
  8698. t1.director_doctor_name AS directorDoctorName,
  8699. t1.birthday AS birthday,
  8700. t1.behospital_date AS behospitalDate,
  8701. t1.leave_hospital_date AS leaveHospitalDate,
  8702. t1.placefile_date AS placefileDate,
  8703. t1.gmt_create AS gradeTime,
  8704. t1.diagnose,
  8705. t1.ward_name AS wardName,
  8706. t1.checkStatus,
  8707. t1.mrStatus,
  8708. t1.chName,
  8709. t1.mrName,
  8710. t1.chTime,
  8711. t1.mrTime,
  8712. t2.age,
  8713. t1.file_code AS fileCode
  8714. FROM
  8715. (
  8716. SELECT be.*,
  8717. ifnull(mci.status,0) AS checkStatus,
  8718. ifnull(hm_mci.status,0) AS mrStatus,
  8719. mci.check_name as chName,
  8720. hm_mci.check_name as mrName,
  8721. mci.gmt_create as chTime,
  8722. hm_mci.gmt_create as mrTime
  8723. FROM
  8724. (
  8725. SELECT DISTINCT
  8726. tt1.*
  8727. FROM
  8728. (
  8729. SELECT
  8730. b.*,
  8731. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8732. c.grade_type,
  8733. c.score_res,
  8734. c.gmt_create
  8735. FROM
  8736. (
  8737. SELECT DISTINCT
  8738. a.hospital_id,
  8739. a.behospital_code,
  8740. a.bed_code,
  8741. a.NAME,
  8742. a.sex,
  8743. a.beh_dept_id,
  8744. a.beh_dept_name,
  8745. a.birthday,
  8746. a.behospital_date,
  8747. a.leave_hospital_date,
  8748. a.doctor_id,
  8749. a.doctor_name,
  8750. a.beh_doctor_id,
  8751. a.beh_doctor_name,
  8752. a.director_doctor_id,
  8753. a.director_doctor_name,
  8754. a.diagnose,
  8755. a.placefile_date,
  8756. a.ward_name,
  8757. a.file_code
  8758. FROM
  8759. med_behospital_info a
  8760. WHERE
  8761. a.is_deleted = 'N'
  8762. AND a.qc_type_id != 0
  8763. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8764. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8765. </if>
  8766. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8767. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8768. </if>
  8769. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8770. <if test="qcResultShortPageVO.startDate != null ">
  8771. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8772. </if>
  8773. <if test="qcResultShortPageVO.endDate != null ">
  8774. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8775. </if>
  8776. </if>
  8777. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8778. <if test="qcResultShortPageVO.startDate != null ">
  8779. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8780. </if>
  8781. <if test="qcResultShortPageVO.endDate != null">
  8782. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8783. </if>
  8784. </if>
  8785. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8786. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8787. </if>
  8788. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8789. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8790. </if>
  8791. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8792. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8793. </if>
  8794. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8795. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8796. </if>
  8797. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8798. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8799. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8800. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8801. </if>
  8802. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8803. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8804. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8805. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8806. </if>
  8807. ) b
  8808. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8809. AND b.hospital_id = c.hospital_id
  8810. AND b.behospital_code = c.behospital_code
  8811. ) tt1
  8812. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8813. ,med_medical_record tt2,
  8814. qc_mode tt3
  8815. WHERE
  8816. tt2.is_deleted = 'N'
  8817. AND tt3.is_deleted = 'N'
  8818. AND tt1.hospital_id = tt2.hospital_id
  8819. AND tt1.behospital_code = tt2.behospital_code
  8820. AND tt2.mode_id = tt3.id
  8821. AND tt3.`name` = '手术记录'
  8822. </if>
  8823. ) be
  8824. left join med_check_info mci
  8825. on mci.is_deleted = 'N'
  8826. and mci.check_type = 0
  8827. and be.hospital_id = mci.hospital_id
  8828. and be.behospital_code = mci.behospital_code
  8829. left join med_check_info hm_mci
  8830. on hm_mci.is_deleted = 'N'
  8831. and hm_mci.check_type = 1
  8832. and be.hospital_id = hm_mci.hospital_id
  8833. and be.behospital_code = hm_mci.behospital_code
  8834. )t1
  8835. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8836. ,med_home_page t2
  8837. WHERE
  8838. t2.is_deleted = 'N'
  8839. AND t1.hospital_id = t2.hospital_id
  8840. AND t1.behospital_code = t2.behospital_code
  8841. AND (
  8842. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  8843. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8844. )
  8845. </if>
  8846. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8847. ,med_home_page t2
  8848. WHERE
  8849. t2.is_deleted = 'N'
  8850. AND t1.hospital_id = t2.hospital_id
  8851. AND t1.behospital_code = t2.behospital_code
  8852. AND t2.return_to_type = '死亡'
  8853. </if>
  8854. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8855. ,med_home_page t2
  8856. WHERE
  8857. t2.is_deleted = 'N'
  8858. AND t1.hospital_id = t2.hospital_id
  8859. AND t1.behospital_code = t2.behospital_code
  8860. AND t2.leave_hospital_type = '非医嘱离院'
  8861. </if>
  8862. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8863. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8864. AND t1.hospital_id = t2.hospital_id
  8865. AND t1.behospital_code = t2.behospital_code
  8866. </if>
  8867. )t
  8868. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8869. AND t.hospitalId = qi.hospital_id
  8870. AND t.behospitalCode = qi.behospital_code
  8871. where 1=1
  8872. <if test="qcResultShortPageVO.checkStatus != null">
  8873. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8874. </if>
  8875. <if test="qcResultShortPageVO.mrStatus != null">
  8876. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8877. </if>
  8878. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8879. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8880. </if>
  8881. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8882. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8883. </if>
  8884. <if test="qcResultShortPageVO.chTimeStart != null ">
  8885. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8886. </if>
  8887. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8888. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8889. </if>
  8890. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8891. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8892. </if>
  8893. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8894. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8895. </if>
  8896. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8897. AND t.`level` = #{qcResultShortPageVO.level}
  8898. </if>
  8899. GROUP BY
  8900. t.behDeptId,
  8901. t.behDeptName
  8902. )f2
  8903. WHERE
  8904. f1.behDeptId = f2.behDeptId
  8905. AND f1.behDeptName = f2.behDeptName
  8906. </select>
  8907. <!-- 离院病人评分详情页导出-科室-->
  8908. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  8909. SELECT
  8910. f1.behDeptId,
  8911. f1.behDeptName,
  8912. f1.doctorName,
  8913. f1.patName,
  8914. f1.behospitalCode,
  8915. f1.hospitalId,
  8916. f1.behospitalDate,
  8917. f1.leaveHospitalDate,
  8918. f1.score,
  8919. f1.medoupName,
  8920. f1.wardName,
  8921. f2.avgScore,
  8922. f1.scoreBn,
  8923. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8924. f1.msg,
  8925. f1.caseName,
  8926. </if>
  8927. f1.checkStatus,
  8928. f1.mrStatus,
  8929. f1.chName,
  8930. f1.mrName,
  8931. f1.chTime,
  8932. f1.mrTime
  8933. FROM
  8934. (SELECT
  8935. t.doctorName,
  8936. t.doctorId,
  8937. t.`name` AS patName,
  8938. t3.name as medoupName,
  8939. t.behospitalCode AS behospitalCode,
  8940. t.behospitalDate AS behospitalDate,
  8941. t.leaveHospitalDate AS leaveHospitalDate,
  8942. qi.score_res AS score,
  8943. t.scoreBn,
  8944. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8945. qd.msg AS msg,
  8946. qc.NAME AS caseName,
  8947. </if>
  8948. t.behDeptId,
  8949. t.behDeptName,
  8950. t.wardName,
  8951. t.hospitalId,
  8952. t.checkStatus,
  8953. t.mrStatus,
  8954. t.chName,
  8955. t.mrName,
  8956. t.chTime,
  8957. t.mrTime
  8958. FROM
  8959. (SELECT DISTINCT
  8960. t1.hospital_id AS hospitalId,
  8961. t1.behospital_code AS behospitalCode,
  8962. t1.bed_code AS bedCode,
  8963. t1.LEVEL AS LEVEL,
  8964. t1.grade_type AS gradeType,
  8965. t1.score_res AS scoreRes,
  8966. t1.scoreBn,
  8967. t1.NAME AS NAME,
  8968. t1.sex AS sex,
  8969. t1.beh_dept_id AS behDeptId,
  8970. t1.beh_dept_name AS behDeptName,
  8971. t1.doctor_id AS doctorId,
  8972. t1.doctor_name AS doctorName,
  8973. t1.beh_doctor_id AS behDoctorId,
  8974. t1.beh_doctor_name AS behDoctorName,
  8975. t1.director_doctor_id AS directorDoctorId,
  8976. t1.director_doctor_name AS directorDoctorName,
  8977. t1.birthday AS birthday,
  8978. t1.behospital_date AS behospitalDate,
  8979. t1.leave_hospital_date AS leaveHospitalDate,
  8980. t1.placefile_date AS placefileDate,
  8981. t1.gmt_create AS gradeTime,
  8982. t1.diagnose,
  8983. t1.ward_name AS wardName,
  8984. t1.checkStatus,
  8985. t1.mrStatus,
  8986. t1.chName,
  8987. t1.mrName,
  8988. t1.chTime,
  8989. t1.mrTime,
  8990. t2.age,
  8991. t1.file_code AS fileCode
  8992. FROM
  8993. (
  8994. SELECT be.*,
  8995. ifnull(mci.status,0) AS checkStatus,
  8996. ifnull(hm_mci.status,0) AS mrStatus,
  8997. mci.check_name as chName,
  8998. e.score_res as scoreBn,
  8999. hm_mci.check_name as mrName,
  9000. mci.gmt_create as chTime,
  9001. hm_mci.gmt_create as mrTime
  9002. FROM
  9003. (
  9004. SELECT DISTINCT
  9005. tt1.*
  9006. FROM
  9007. (
  9008. SELECT
  9009. b.*,
  9010. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9011. c.grade_type,
  9012. c.score_res,
  9013. c.gmt_create
  9014. FROM
  9015. (
  9016. SELECT DISTINCT
  9017. a.hospital_id,
  9018. a.behospital_code,
  9019. a.bed_code,
  9020. a.NAME,
  9021. a.sex,
  9022. a.beh_dept_id,
  9023. a.beh_dept_name,
  9024. a.birthday,
  9025. a.behospital_date,
  9026. a.leave_hospital_date,
  9027. a.doctor_id,
  9028. a.doctor_name,
  9029. a.beh_doctor_id,
  9030. a.beh_doctor_name,
  9031. a.director_doctor_id,
  9032. a.director_doctor_name,
  9033. a.diagnose,
  9034. a.placefile_date,
  9035. a.ward_name,
  9036. a.file_code
  9037. FROM
  9038. med_behospital_info a,
  9039. sys_user_dept b
  9040. WHERE
  9041. a.is_deleted = 'N'
  9042. AND b.is_deleted = 'N'
  9043. AND a.hospital_id = b.hospital_id
  9044. AND a.beh_dept_id = b.dept_id
  9045. AND a.qc_type_id != 0
  9046. <if test="qcResultShortPageVO.userId!=null">
  9047. AND b.user_id = #{qcResultShortPageVO.userId}
  9048. </if>
  9049. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9050. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9051. </if>
  9052. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9053. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9054. </if>
  9055. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9056. <if test="qcResultShortPageVO.startDate != null ">
  9057. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9058. </if>
  9059. <if test="qcResultShortPageVO.endDate != null ">
  9060. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9061. </if>
  9062. </if>
  9063. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9064. <if test="qcResultShortPageVO.startDate != null ">
  9065. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9066. </if>
  9067. <if test="qcResultShortPageVO.endDate != null">
  9068. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9069. </if>
  9070. </if>
  9071. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9072. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9073. </if>
  9074. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9075. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  9076. </if>
  9077. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9078. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9079. </if>
  9080. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  9081. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9082. </if>
  9083. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9084. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9085. </if>
  9086. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9087. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9088. </if>
  9089. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9090. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9091. </if>
  9092. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9093. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9094. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9095. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9096. </if>
  9097. ) b
  9098. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9099. AND b.hospital_id = c.hospital_id
  9100. AND b.behospital_code = c.behospital_code
  9101. ) tt1
  9102. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9103. ,med_medical_record tt2,
  9104. qc_mode tt3
  9105. WHERE
  9106. tt2.is_deleted = 'N'
  9107. AND tt3.is_deleted = 'N'
  9108. AND tt1.hospital_id = tt2.hospital_id
  9109. AND tt1.behospital_code = tt2.behospital_code
  9110. AND tt2.mode_id = tt3.id
  9111. AND tt3.`name` = '手术记录'
  9112. </if>
  9113. ) be
  9114. left join med_check_info mci
  9115. on mci.is_deleted = 'N'
  9116. and mci.check_type = 0
  9117. and be.hospital_id = mci.hospital_id
  9118. and be.behospital_code = mci.behospital_code
  9119. left join med_check_info hm_mci
  9120. on hm_mci.is_deleted = 'N'
  9121. and hm_mci.check_type = 1
  9122. and be.hospital_id = hm_mci.hospital_id
  9123. and be.behospital_code = hm_mci.behospital_code
  9124. LEFT JOIN med_qcresult_cases e
  9125. on be.behospital_code = e.behospital_code
  9126. and be.hospital_id = e.hospital_id
  9127. AND e.is_deleted = 'N'
  9128. and e.cases_id = 243
  9129. )t1
  9130. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9131. ,med_home_page t2
  9132. WHERE
  9133. t2.is_deleted = 'N'
  9134. AND t1.hospital_id = t2.hospital_id
  9135. AND t1.behospital_code = t2.behospital_code
  9136. AND (
  9137. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9138. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9139. )
  9140. </if>
  9141. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9142. ,med_home_page t2
  9143. WHERE
  9144. t2.is_deleted = 'N'
  9145. AND t1.hospital_id = t2.hospital_id
  9146. AND t1.behospital_code = t2.behospital_code
  9147. AND t2.return_to_type = '死亡'
  9148. </if>
  9149. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9150. ,med_home_page t2
  9151. WHERE
  9152. t2.is_deleted = 'N'
  9153. AND t1.hospital_id = t2.hospital_id
  9154. AND t1.behospital_code = t2.behospital_code
  9155. AND t2.leave_hospital_type = '非医嘱离院'
  9156. </if>
  9157. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9158. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9159. AND t1.hospital_id = t2.hospital_id
  9160. AND t1.behospital_code = t2.behospital_code
  9161. </if>
  9162. )t
  9163. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9164. AND t.hospitalId = qi.hospital_id
  9165. AND t.behospitalCode = qi.behospital_code
  9166. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  9167. AND t.hospitalId = t2.hospital_id
  9168. AND t2.is_deleted = 'N'
  9169. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9170. AND t3.is_deleted = 'N'
  9171. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9172. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9173. AND t.hospitalId = qd.hospital_id
  9174. AND t.behospitalCode = qd.behospital_code
  9175. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9176. AND qd.cases_id = qc.id
  9177. </if>
  9178. where 1=1
  9179. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  9180. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  9181. </if>
  9182. <if test="qcResultShortPageVO.checkStatus != null">
  9183. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9184. </if>
  9185. <if test="qcResultShortPageVO.mrStatus != null">
  9186. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9187. </if>
  9188. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9189. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9190. </if>
  9191. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9192. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9193. </if>
  9194. <if test="qcResultShortPageVO.chTimeStart != null ">
  9195. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9196. </if>
  9197. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9198. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9199. </if>
  9200. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9201. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9202. </if>
  9203. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9204. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9205. </if>
  9206. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9207. AND t.`level` = #{qcResultShortPageVO.level}
  9208. </if>)f1,(SELECT
  9209. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9210. t.behDeptId,
  9211. t.behDeptName,
  9212. t.doctorId,
  9213. t.doctorName
  9214. FROM
  9215. (SELECT DISTINCT
  9216. t1.hospital_id AS hospitalId,
  9217. t1.behospital_code AS behospitalCode,
  9218. t1.bed_code AS bedCode,
  9219. t1.LEVEL AS LEVEL,
  9220. t1.grade_type AS gradeType,
  9221. t1.score_res AS scoreRes,
  9222. t1.NAME AS NAME,
  9223. t1.sex AS sex,
  9224. t1.beh_dept_id AS behDeptId,
  9225. t1.beh_dept_name AS behDeptName,
  9226. t1.doctor_id AS doctorId,
  9227. t1.doctor_name AS doctorName,
  9228. t1.beh_doctor_id AS behDoctorId,
  9229. t1.beh_doctor_name AS behDoctorName,
  9230. t1.director_doctor_id AS directorDoctorId,
  9231. t1.director_doctor_name AS directorDoctorName,
  9232. t1.birthday AS birthday,
  9233. t1.behospital_date AS behospitalDate,
  9234. t1.leave_hospital_date AS leaveHospitalDate,
  9235. t1.placefile_date AS placefileDate,
  9236. t1.gmt_create AS gradeTime,
  9237. t1.diagnose,
  9238. t1.ward_name AS wardName,
  9239. t1.checkStatus,
  9240. t1.mrStatus,
  9241. t1.chName,
  9242. t1.mrName,
  9243. t1.chTime,
  9244. t1.mrTime,
  9245. t2.age,
  9246. t1.file_code AS fileCode
  9247. FROM
  9248. (
  9249. SELECT be.*,
  9250. ifnull(mci.status,0) AS checkStatus,
  9251. ifnull(hm_mci.status,0) AS mrStatus,
  9252. mci.check_name as chName,
  9253. hm_mci.check_name as mrName,
  9254. mci.gmt_create as chTime,
  9255. hm_mci.gmt_create as mrTime
  9256. FROM
  9257. (
  9258. SELECT DISTINCT
  9259. tt1.*
  9260. FROM
  9261. (
  9262. SELECT
  9263. b.*,
  9264. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9265. c.grade_type,
  9266. c.score_res,
  9267. c.gmt_create
  9268. FROM
  9269. (
  9270. SELECT DISTINCT
  9271. a.hospital_id,
  9272. a.behospital_code,
  9273. a.bed_code,
  9274. a.NAME,
  9275. a.sex,
  9276. a.beh_dept_id,
  9277. a.beh_dept_name,
  9278. a.birthday,
  9279. a.behospital_date,
  9280. a.leave_hospital_date,
  9281. a.doctor_id,
  9282. a.doctor_name,
  9283. a.beh_doctor_id,
  9284. a.beh_doctor_name,
  9285. a.director_doctor_id,
  9286. a.director_doctor_name,
  9287. a.diagnose,
  9288. a.placefile_date,
  9289. a.ward_name,
  9290. a.file_code
  9291. FROM
  9292. med_behospital_info a,
  9293. sys_user_dept b
  9294. WHERE
  9295. a.is_deleted = 'N'
  9296. AND b.is_deleted = 'N'
  9297. AND a.hospital_id = b.hospital_id
  9298. AND a.beh_dept_id = b.dept_id
  9299. AND a.qc_type_id != 0
  9300. <if test="qcResultShortPageVO.userId!=null">
  9301. AND b.user_id = #{qcResultShortPageVO.userId}
  9302. </if>
  9303. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9304. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9305. </if>
  9306. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9307. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9308. </if>
  9309. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9310. <if test="qcResultShortPageVO.startDate != null ">
  9311. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9312. </if>
  9313. <if test="qcResultShortPageVO.endDate != null ">
  9314. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9315. </if>
  9316. </if>
  9317. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9318. <if test="qcResultShortPageVO.startDate != null ">
  9319. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9320. </if>
  9321. <if test="qcResultShortPageVO.endDate != null">
  9322. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9323. </if>
  9324. </if>
  9325. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9326. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9327. </if>
  9328. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9329. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  9330. </if>
  9331. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9332. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9333. </if>
  9334. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  9335. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9336. </if>
  9337. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9338. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9339. </if>
  9340. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9341. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9342. </if>
  9343. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9344. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9345. </if>
  9346. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9347. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9348. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9349. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9350. </if>
  9351. ) b
  9352. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9353. AND b.hospital_id = c.hospital_id
  9354. AND b.behospital_code = c.behospital_code
  9355. ) tt1
  9356. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9357. ,med_medical_record tt2,
  9358. qc_mode tt3
  9359. WHERE
  9360. tt2.is_deleted = 'N'
  9361. AND tt3.is_deleted = 'N'
  9362. AND tt1.hospital_id = tt2.hospital_id
  9363. AND tt1.behospital_code = tt2.behospital_code
  9364. AND tt2.mode_id = tt3.id
  9365. AND tt3.`name` = '手术记录'
  9366. </if>
  9367. ) be
  9368. left join med_check_info mci
  9369. on mci.is_deleted = 'N'
  9370. and mci.check_type = 0
  9371. and be.hospital_id = mci.hospital_id
  9372. and be.behospital_code = mci.behospital_code
  9373. left join med_check_info hm_mci
  9374. on hm_mci.is_deleted = 'N'
  9375. and hm_mci.check_type = 1
  9376. and be.hospital_id = hm_mci.hospital_id
  9377. and be.behospital_code = hm_mci.behospital_code
  9378. )t1
  9379. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9380. ,med_home_page t2
  9381. WHERE
  9382. t2.is_deleted = 'N'
  9383. AND t1.hospital_id = t2.hospital_id
  9384. AND t1.behospital_code = t2.behospital_code
  9385. AND (
  9386. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9387. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9388. )
  9389. </if>
  9390. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9391. ,med_home_page t2
  9392. WHERE
  9393. t2.is_deleted = 'N'
  9394. AND t1.hospital_id = t2.hospital_id
  9395. AND t1.behospital_code = t2.behospital_code
  9396. AND t2.return_to_type = '死亡'
  9397. </if>
  9398. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9399. ,med_home_page t2
  9400. WHERE
  9401. t2.is_deleted = 'N'
  9402. AND t1.hospital_id = t2.hospital_id
  9403. AND t1.behospital_code = t2.behospital_code
  9404. AND t2.leave_hospital_type = '非医嘱离院'
  9405. </if>
  9406. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9407. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9408. AND t1.hospital_id = t2.hospital_id
  9409. AND t1.behospital_code = t2.behospital_code
  9410. </if>
  9411. )t
  9412. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9413. AND t.hospitalId = qi.hospital_id
  9414. AND t.behospitalCode = qi.behospital_code
  9415. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  9416. AND t.hospitalId = t2.hospital_id
  9417. AND t2.is_deleted = 'N'
  9418. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9419. AND t3.is_deleted = 'N'
  9420. where 1=1
  9421. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  9422. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  9423. </if>
  9424. <if test="qcResultShortPageVO.checkStatus != null">
  9425. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9426. </if>
  9427. <if test="qcResultShortPageVO.mrStatus != null">
  9428. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9429. </if>
  9430. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9431. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9432. </if>
  9433. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9434. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9435. </if>
  9436. <if test="qcResultShortPageVO.chTimeStart != null ">
  9437. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9438. </if>
  9439. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9440. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9441. </if>
  9442. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9443. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9444. </if>
  9445. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9446. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9447. </if>
  9448. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9449. AND t.`level` = #{qcResultShortPageVO.level}
  9450. </if>
  9451. GROUP BY
  9452. t.behDeptId,
  9453. t.behDeptName,
  9454. t.doctorId,
  9455. t.doctorName
  9456. )f2
  9457. WHERE
  9458. f1.doctorId = f2.doctorId
  9459. AND f1.doctorName = f2.doctorName
  9460. </select>
  9461. <!--缺陷详情质控评分页导出-科室-->
  9462. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  9463. SELECT
  9464. f1.*,
  9465. f2.avgScore
  9466. FROM
  9467. (SELECT
  9468. t.*,
  9469. qi.score_res AS score,
  9470. qd.msg AS msg,
  9471. qc.NAME AS caseName
  9472. FROM
  9473. (SELECT DISTINCT
  9474. t1.hospital_id AS hospitalId,
  9475. t1.behospital_code AS behospitalCode,
  9476. t1.bed_code AS bedCode,
  9477. t1.LEVEL AS LEVEL,
  9478. t1.grade_type AS gradeType,
  9479. t1.score_res AS scoreRes,
  9480. t1.scoreBn AS scoreBn,
  9481. t1.NAME AS patName,
  9482. t1.medoupName,
  9483. t1.sex AS sex,
  9484. t1.beh_dept_id AS behDeptId,
  9485. t1.beh_dept_name AS behDeptName,
  9486. t1.doctor_id AS doctorId,
  9487. t1.doctor_name AS doctorName,
  9488. t1.beh_doctor_id AS behDoctorId,
  9489. t1.beh_doctor_name AS behDoctorName,
  9490. t1.director_doctor_id AS directorDoctorId,
  9491. t1.director_doctor_name AS directorDoctorName,
  9492. t1.birthday AS birthday,
  9493. t1.behospital_date AS behospitalDate,
  9494. t1.leave_hospital_date AS leaveHospitalDate,
  9495. t1.placefile_date AS placefileDate,
  9496. t1.gmt_create AS gradeTime,
  9497. t1.diagnose AS diagnose,
  9498. t1.ward_name AS wardName,
  9499. t1.file_code AS fileCode,
  9500. t1.checkStatus AS checkStatus,
  9501. t1.mrStatus AS mrStatus,
  9502. t1.chName AS chName,
  9503. t1.mrName AS mrName,
  9504. t1.chTime AS chTime,
  9505. t1.mrTime AS mrTime
  9506. FROM
  9507. (
  9508. SELECT DISTINCT
  9509. tt1.*
  9510. FROM
  9511. (SELECT
  9512. be.*,
  9513. t3.name as medoupName,
  9514. ifnull(mci.status,0) AS checkStatus,
  9515. ifnull(hm_mci.status,0) AS mrStatus,
  9516. mci.check_name as chName,
  9517. hm_mci.check_name as mrName,
  9518. mci.gmt_create as chTime,
  9519. e.score_res as scoreBn,
  9520. hm_mci.gmt_create as mrTime
  9521. FROM
  9522. (
  9523. SELECT DISTINCT
  9524. a.hospital_id,
  9525. a.behospital_code,
  9526. a.bed_code,
  9527. a.file_code,
  9528. b.LEVEL,
  9529. b.grade_type,
  9530. b.score_res,
  9531. a.NAME,
  9532. a.sex,
  9533. a.beh_dept_id,
  9534. a.beh_dept_name,
  9535. a.birthday,
  9536. a.behospital_date,
  9537. a.leave_hospital_date,
  9538. a.doctor_id,
  9539. a.doctor_name,
  9540. a.beh_doctor_id,
  9541. a.beh_doctor_name,
  9542. a.director_doctor_id,
  9543. a.director_doctor_name,
  9544. a.diagnose,
  9545. a.placefile_date,
  9546. a.ward_name,
  9547. b.gmt_create
  9548. FROM
  9549. med_behospital_info a,
  9550. med_qcresult_info b,
  9551. med_qcresult_detail c,
  9552. qc_cases_entry d,
  9553. sys_user_dept e
  9554. WHERE
  9555. a.is_deleted = 'N'
  9556. AND b.is_deleted = 'N'
  9557. AND c.is_deleted = 'N'
  9558. AND d.is_deleted = 'N'
  9559. AND e.is_deleted = 'N'
  9560. AND a.hospital_id = b.hospital_id
  9561. AND a.hospital_id = c.hospital_id
  9562. AND a.hospital_id = e.hospital_id
  9563. AND a.behospital_code = b.behospital_code
  9564. AND a.behospital_code = c.behospital_code
  9565. AND a.beh_dept_id = e.dept_id
  9566. AND c.cases_id = d.cases_id
  9567. AND c.cases_entry_id = d.id
  9568. AND a.qc_type_id != 0
  9569. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9570. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9571. </if>
  9572. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  9573. AND e.user_id = #{qcResultShortPageVO.userId}
  9574. </if>
  9575. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9576. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9577. </if>
  9578. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9579. <if test="qcResultShortPageVO.startDate != null ">
  9580. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9581. </if>
  9582. <if test="qcResultShortPageVO.endDate != null ">
  9583. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9584. </if>
  9585. </if>
  9586. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9587. <if test="qcResultShortPageVO.startDate != null ">
  9588. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9589. </if>
  9590. <if test="qcResultShortPageVO.endDate != null">
  9591. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9592. </if>
  9593. </if>
  9594. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9595. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9596. </if>
  9597. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9598. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  9599. </if>
  9600. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9601. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9602. </if>
  9603. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  9604. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9605. </if>
  9606. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9607. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9608. </if>
  9609. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9610. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9611. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9612. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9613. </if>
  9614. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9615. AND b.`level` = #{qcResultShortPageVO.level}
  9616. </if>
  9617. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9618. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9619. </if>
  9620. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9621. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9622. </if>
  9623. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9624. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  9625. </if>
  9626. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  9627. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9628. </if>
  9629. <if test="qcResultShortPageVO.isReject != null">
  9630. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9631. </if>
  9632. <if test="qcResultShortPageVO.ruleType != null">
  9633. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9634. </if>
  9635. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9636. AND TIMESTAMPDIFF(
  9637. DAY,
  9638. DATE( a.behospital_date ),
  9639. DATE( a.leave_hospital_date ))> 30
  9640. </if>
  9641. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9642. AND TIMESTAMPDIFF(
  9643. DAY,
  9644. DATE( a.behospital_date ),
  9645. DATE( a.leave_hospital_date ))> 31
  9646. </if>
  9647. )be
  9648. left join med_check_info mci
  9649. on mci.is_deleted = 'N'
  9650. and mci.check_type = 0
  9651. and be.hospital_id = mci.hospital_id
  9652. and be.behospital_code = mci.behospital_code
  9653. left join med_check_info hm_mci
  9654. on hm_mci.is_deleted = 'N'
  9655. and hm_mci.check_type = 1
  9656. and be.hospital_id = hm_mci.hospital_id
  9657. and be.behospital_code = hm_mci.behospital_code
  9658. LEFT JOIN med_qcresult_cases e
  9659. on be.behospital_code = e.behospital_code
  9660. and be.hospital_id = e.hospital_id
  9661. AND e.is_deleted = 'N'
  9662. and e.cases_id = 243
  9663. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  9664. and be.hospital_id = t2.hospital_id
  9665. AND t2.is_deleted = 'N'
  9666. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9667. AND t3.is_deleted = 'N'
  9668. )tt1
  9669. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9670. ,med_medical_record tt2
  9671. WHERE
  9672. tt2.is_deleted = 'N'
  9673. AND tt1.hospital_id = tt2.hospital_id
  9674. AND tt1.behospital_code = tt2.behospital_code
  9675. AND tt2.mode_id = 30
  9676. </if>
  9677. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9678. ,med_crisis_info tt2
  9679. WHERE
  9680. tt2.is_deleted = 'N'
  9681. AND tt1.hospital_id = tt2.hospital_id
  9682. AND tt1.behospital_code = tt2.behospital_code
  9683. </if>
  9684. ) t1
  9685. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9686. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9687. AND t1.behospital_code = t2.behospital_code
  9688. AND t2.is_deleted = 'N'
  9689. </if>
  9690. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9691. , med_home_page t2
  9692. , med_home_operation_info t3
  9693. WHERE t1.hospital_id = t2.hospital_id
  9694. AND t1.behospital_code = t2.behospital_code
  9695. AND t2.home_page_id = t3.home_page_id
  9696. AND t2.is_deleted = 'N'
  9697. AND t3.is_deleted = 'N'
  9698. </if>
  9699. ) t
  9700. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9701. AND t.hospitalId = qi.hospital_id
  9702. AND t.behospitalCode = qi.behospital_code
  9703. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9704. AND t.hospitalId = qd.hospital_id
  9705. AND t.behospitalCode = qd.behospital_code
  9706. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9707. AND qd.cases_id = qc.id
  9708. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  9709. AND qd.cases_id = qce.cases_id
  9710. AND qd.cases_entry_id = qce.id
  9711. where 1=1
  9712. <if test="qcResultShortPageVO.checkStatus != null">
  9713. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9714. </if>
  9715. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  9716. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  9717. </if>
  9718. <if test="qcResultShortPageVO.mrStatus != null">
  9719. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9720. </if>
  9721. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9722. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9723. </if>
  9724. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9725. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9726. </if>
  9727. <if test="qcResultShortPageVO.chTimeStart != null ">
  9728. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9729. </if>
  9730. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9731. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9732. </if>
  9733. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9734. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9735. </if>
  9736. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9737. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9738. </if>
  9739. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9740. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  9741. </if>
  9742. <if test="qcResultShortPageVO.casesEntryId != null ">
  9743. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  9744. </if>
  9745. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9746. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  9747. </if>
  9748. <if test="qcResultShortPageVO.casesId != null">
  9749. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  9750. </if>
  9751. )f1,
  9752. (SELECT
  9753. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9754. t.behDeptId,
  9755. t.behDeptName,
  9756. t.doctorId,
  9757. t.doctorName
  9758. FROM
  9759. (SELECT DISTINCT
  9760. t1.hospital_id AS hospitalId,
  9761. t1.behospital_code AS behospitalCode,
  9762. t1.bed_code AS bedCode,
  9763. t1.LEVEL AS LEVEL,
  9764. t1.grade_type AS gradeType,
  9765. t1.score_res AS scoreRes,
  9766. t1.NAME AS NAME,
  9767. t1.medoupName,
  9768. t1.sex AS sex,
  9769. t1.beh_dept_id AS behDeptId,
  9770. t1.beh_dept_name AS behDeptName,
  9771. t1.doctor_id AS doctorId,
  9772. t1.doctor_name AS doctorName,
  9773. t1.beh_doctor_id AS behDoctorId,
  9774. t1.beh_doctor_name AS behDoctorName,
  9775. t1.director_doctor_id AS directorDoctorId,
  9776. t1.director_doctor_name AS directorDoctorName,
  9777. t1.birthday AS birthday,
  9778. t1.behospital_date AS behospitalDate,
  9779. t1.leave_hospital_date AS leaveHospitalDate,
  9780. t1.placefile_date AS placefileDate,
  9781. t1.gmt_create AS gradeTime,
  9782. t1.diagnose,
  9783. t1.ward_name AS wardName,
  9784. t2.age,
  9785. t1.file_code AS fileCode,
  9786. t1.checkStatus,
  9787. t1.mrStatus,
  9788. t1.chName,
  9789. t1.mrName,
  9790. t1.chTime,
  9791. t1.mrTime
  9792. FROM
  9793. (
  9794. SELECT DISTINCT
  9795. tt1.*
  9796. FROM
  9797. (SELECT
  9798. be.*,
  9799. t3.name as medoupName,
  9800. ifnull(mci.status,0) AS checkStatus,
  9801. ifnull(hm_mci.status,0) AS mrStatus,
  9802. mci.check_name as chName,
  9803. hm_mci.check_name as mrName,
  9804. mci.gmt_create as chTime,
  9805. hm_mci.gmt_create as mrTime
  9806. FROM
  9807. (
  9808. SELECT DISTINCT
  9809. a.hospital_id,
  9810. a.behospital_code,
  9811. a.bed_code,
  9812. a.file_code,
  9813. b.LEVEL,
  9814. b.grade_type,
  9815. b.score_res,
  9816. a.NAME,
  9817. a.sex,
  9818. a.beh_dept_id,
  9819. a.beh_dept_name,
  9820. a.birthday,
  9821. a.behospital_date,
  9822. a.leave_hospital_date,
  9823. a.doctor_id,
  9824. a.doctor_name,
  9825. a.beh_doctor_id,
  9826. a.beh_doctor_name,
  9827. a.director_doctor_id,
  9828. a.director_doctor_name,
  9829. a.diagnose,
  9830. a.placefile_date,
  9831. a.ward_name,
  9832. b.gmt_create
  9833. FROM
  9834. med_behospital_info a,
  9835. med_qcresult_info b,
  9836. med_qcresult_detail c,
  9837. qc_cases_entry d,
  9838. sys_user_dept e
  9839. WHERE
  9840. a.is_deleted = 'N'
  9841. AND b.is_deleted = 'N'
  9842. AND c.is_deleted = 'N'
  9843. AND d.is_deleted = 'N'
  9844. AND e.is_deleted = 'N'
  9845. AND a.hospital_id = b.hospital_id
  9846. AND a.hospital_id = c.hospital_id
  9847. AND a.hospital_id = e.hospital_id
  9848. AND a.behospital_code = b.behospital_code
  9849. AND a.behospital_code = c.behospital_code
  9850. AND a.beh_dept_id = e.dept_id
  9851. AND c.cases_id = d.cases_id
  9852. AND c.cases_entry_id = d.id
  9853. AND a.qc_type_id != 0
  9854. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9855. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9856. </if>
  9857. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9858. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9859. </if>
  9860. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9861. <if test="qcResultShortPageVO.startDate != null ">
  9862. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9863. </if>
  9864. <if test="qcResultShortPageVO.endDate != null ">
  9865. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9866. </if>
  9867. </if>
  9868. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9869. <if test="qcResultShortPageVO.startDate != null ">
  9870. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9871. </if>
  9872. <if test="qcResultShortPageVO.endDate != null">
  9873. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9874. </if>
  9875. </if>
  9876. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9877. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9878. </if>
  9879. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9880. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  9881. </if>
  9882. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9883. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9884. </if>
  9885. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  9886. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9887. </if>
  9888. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9889. AND b.`level` = #{qcResultShortPageVO.level}
  9890. </if>
  9891. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9892. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9893. </if>
  9894. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9895. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9896. </if>
  9897. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9898. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9899. </if>
  9900. <if test="qcResultShortPageVO.casesEntryId != null ">
  9901. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9902. </if>
  9903. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9904. AND d.cases_name = #{qcResultShortPageVO.casesName}
  9905. </if>
  9906. <if test="qcResultShortPageVO.casesId != null">
  9907. AND d.cases_id = #{qcResultShortPageVO.casesId}
  9908. </if>
  9909. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9910. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9911. </if>
  9912. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9913. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9914. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9915. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9916. </if>
  9917. <if test="qcResultShortPageVO.isReject != null">
  9918. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9919. </if>
  9920. <if test="qcResultShortPageVO.ruleType != null">
  9921. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9922. </if>
  9923. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9924. AND TIMESTAMPDIFF(
  9925. DAY,
  9926. DATE( a.behospital_date ),
  9927. DATE( a.leave_hospital_date ))> 30
  9928. </if>
  9929. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9930. AND TIMESTAMPDIFF(
  9931. DAY,
  9932. DATE( a.behospital_date ),
  9933. DATE( a.leave_hospital_date ))> 31
  9934. </if>
  9935. )be
  9936. left join med_check_info mci
  9937. on mci.is_deleted = 'N'
  9938. and mci.check_type = 0
  9939. and be.hospital_id = mci.hospital_id
  9940. and be.behospital_code = mci.behospital_code
  9941. left join med_check_info hm_mci
  9942. on hm_mci.is_deleted = 'N'
  9943. and hm_mci.check_type = 1
  9944. and be.hospital_id = hm_mci.hospital_id
  9945. and be.behospital_code = hm_mci.behospital_code
  9946. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  9947. and be.hospital_id = t2.hospital_id
  9948. AND t2.is_deleted = 'N'
  9949. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9950. AND t3.is_deleted = 'N'
  9951. )tt1
  9952. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9953. ,med_medical_record tt2
  9954. WHERE
  9955. tt2.is_deleted = 'N'
  9956. AND tt1.hospital_id = tt2.hospital_id
  9957. AND tt1.behospital_code = tt2.behospital_code
  9958. AND tt2.mode_id = 30
  9959. </if>
  9960. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9961. ,med_crisis_info tt2
  9962. WHERE
  9963. tt2.is_deleted = 'N'
  9964. AND tt1.hospital_id = tt2.hospital_id
  9965. AND tt1.behospital_code = tt2.behospital_code
  9966. </if>
  9967. ) t1
  9968. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9969. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9970. AND t1.behospital_code = t2.behospital_code
  9971. AND t2.is_deleted = 'N'
  9972. </if>
  9973. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9974. , med_home_page t2
  9975. , med_home_operation_info t3
  9976. WHERE t1.hospital_id = t2.hospital_id
  9977. AND t1.behospital_code = t2.behospital_code
  9978. AND t2.home_page_id = t3.home_page_id
  9979. AND t2.is_deleted = 'N'
  9980. AND t3.is_deleted = 'N'
  9981. </if>
  9982. ) t
  9983. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9984. AND t.hospitalId = qi.hospital_id
  9985. AND t.behospitalCode = qi.behospital_code
  9986. where 1=1
  9987. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  9988. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  9989. </if>
  9990. <if test="qcResultShortPageVO.checkStatus != null">
  9991. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9992. </if>
  9993. <if test="qcResultShortPageVO.mrStatus != null">
  9994. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9995. </if>
  9996. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9997. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9998. </if>
  9999. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10000. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10001. </if>
  10002. <if test="qcResultShortPageVO.chTimeStart != null ">
  10003. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10004. </if>
  10005. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10006. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10007. </if>
  10008. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10009. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10010. </if>
  10011. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10012. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10013. </if>
  10014. GROUP BY
  10015. t.behDeptId,
  10016. t.behDeptName,
  10017. t.doctorId,
  10018. t.doctorName
  10019. )f2
  10020. WHERE
  10021. f1.doctorId = f2.doctorId
  10022. AND f1.doctorName = f2.doctorName
  10023. AND f1.doctorName = f2.doctorName
  10024. </select>
  10025. <!-- 条目缺陷评分详情页导出-->
  10026. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  10027. SELECT * from(
  10028. SELECT
  10029. f1.*,
  10030. f2.avgScore
  10031. FROM
  10032. (SELECT
  10033. t.*,
  10034. qi.score_res AS score,
  10035. qd.msg AS msg,
  10036. qc.NAME AS caseName
  10037. FROM
  10038. (SELECT DISTINCT
  10039. t1.hospital_id AS hospitalId,
  10040. t1.behospital_code AS behospitalCode,
  10041. t1.bed_code AS bedCode,
  10042. t1.LEVEL AS LEVEL,
  10043. t1.grade_type AS gradeType,
  10044. t1.score_res AS scoreRes,
  10045. t1.scoreBn AS scoreBn,
  10046. t1.NAME AS patName,
  10047. t1.sex AS sex,
  10048. t1.beh_dept_id AS behDeptId,
  10049. t1.beh_dept_name AS behDeptName,
  10050. t1.doctor_id AS doctorId,
  10051. t1.doctor_name AS doctorName,
  10052. t1.beh_doctor_id AS behDoctorId,
  10053. t1.beh_doctor_name AS behDoctorName,
  10054. t1.director_doctor_id AS directorDoctorId,
  10055. t1.director_doctor_name AS directorDoctorName,
  10056. t1.birthday AS birthday,
  10057. t1.behospital_date AS behospitalDate,
  10058. t1.leave_hospital_date AS leaveHospitalDate,
  10059. t1.placefile_date AS placefileDate,
  10060. t1.gmt_create AS gradeTime,
  10061. t1.diagnose AS diagnose,
  10062. t1.ward_name AS wardName,
  10063. t1.file_code AS fileCode,
  10064. t1.checkStatus AS checkStatus,
  10065. t1.mrStatus AS mrStatus,
  10066. t1.chName AS chName,
  10067. t1.mrName AS mrName,
  10068. t1.chTime AS chTime,
  10069. t1.mrTime AS mrTime
  10070. FROM
  10071. (
  10072. SELECT DISTINCT
  10073. tt1.*
  10074. FROM
  10075. (SELECT
  10076. be.*,
  10077. ifnull(mci.status,0) AS checkStatus,
  10078. ifnull(hm_mci.status,0) AS mrStatus,
  10079. mci.check_name as chName,
  10080. hm_mci.check_name as mrName,
  10081. mci.gmt_create as chTime,
  10082. e.score_res as scoreBn,
  10083. hm_mci.gmt_create as mrTime
  10084. FROM
  10085. (
  10086. SELECT DISTINCT
  10087. a.hospital_id,
  10088. a.behospital_code,
  10089. a.bed_code,
  10090. a.file_code,
  10091. b.LEVEL,
  10092. b.grade_type,
  10093. b.score_res,
  10094. a.NAME,
  10095. a.sex,
  10096. a.beh_dept_id,
  10097. a.beh_dept_name,
  10098. a.birthday,
  10099. a.behospital_date,
  10100. a.leave_hospital_date,
  10101. a.doctor_id,
  10102. a.doctor_name,
  10103. a.beh_doctor_id,
  10104. a.beh_doctor_name,
  10105. a.director_doctor_id,
  10106. a.director_doctor_name,
  10107. a.diagnose,
  10108. a.placefile_date,
  10109. a.ward_name,
  10110. b.gmt_create
  10111. FROM
  10112. med_behospital_info a,
  10113. med_qcresult_info b,
  10114. med_qcresult_detail c,
  10115. qc_cases_entry d
  10116. WHERE
  10117. a.is_deleted = 'N'
  10118. AND b.is_deleted = 'N'
  10119. AND c.is_deleted = 'N'
  10120. AND d.is_deleted = 'N'
  10121. AND a.hospital_id = b.hospital_id
  10122. AND a.hospital_id = c.hospital_id
  10123. AND a.behospital_code = b.behospital_code
  10124. AND a.behospital_code = c.behospital_code
  10125. AND c.cases_id = d.cases_id
  10126. AND c.cases_entry_id = d.id
  10127. AND a.qc_type_id != 0
  10128. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10129. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10130. </if>
  10131. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10132. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10133. </if>
  10134. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10135. <if test="qcResultShortPageVO.startDate != null ">
  10136. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10137. </if>
  10138. <if test="qcResultShortPageVO.endDate != null ">
  10139. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10140. </if>
  10141. </if>
  10142. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10143. <if test="qcResultShortPageVO.startDate != null ">
  10144. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10145. </if>
  10146. <if test="qcResultShortPageVO.endDate != null">
  10147. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10148. </if>
  10149. </if>
  10150. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10151. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10152. </if>
  10153. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10154. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10155. </if>
  10156. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10157. AND b.`level` = #{qcResultShortPageVO.level}
  10158. </if>
  10159. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10160. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10161. </if>
  10162. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10163. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10164. </if>
  10165. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10166. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10167. </if>
  10168. <if test="qcResultShortPageVO.casesEntryId != null ">
  10169. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10170. </if>
  10171. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10172. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10173. </if>
  10174. <if test="qcResultShortPageVO.casesId != null">
  10175. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10176. </if>
  10177. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10178. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10179. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10180. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10181. </if>
  10182. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10183. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10184. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10185. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10186. </if>
  10187. <if test="qcResultShortPageVO.isReject != null">
  10188. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10189. </if>
  10190. <if test="qcResultShortPageVO.ruleType != null">
  10191. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10192. </if>
  10193. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10194. AND TIMESTAMPDIFF(
  10195. DAY,
  10196. DATE( a.behospital_date ),
  10197. DATE( a.leave_hospital_date ))> 30
  10198. </if>
  10199. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10200. AND TIMESTAMPDIFF(
  10201. DAY,
  10202. DATE( a.behospital_date ),
  10203. DATE( a.leave_hospital_date ))> 31
  10204. </if>
  10205. )be
  10206. left join med_check_info mci
  10207. on mci.is_deleted = 'N'
  10208. and mci.check_type = 0
  10209. and be.hospital_id = mci.hospital_id
  10210. and be.behospital_code = mci.behospital_code
  10211. left join med_check_info hm_mci
  10212. on hm_mci.is_deleted = 'N'
  10213. and hm_mci.check_type = 1
  10214. and be.hospital_id = hm_mci.hospital_id
  10215. and be.behospital_code = hm_mci.behospital_code
  10216. LEFT JOIN med_qcresult_cases e
  10217. on be.behospital_code = e.behospital_code
  10218. and be.hospital_id = e.hospital_id
  10219. AND e.is_deleted = 'N'
  10220. and e.cases_id = 243
  10221. )tt1
  10222. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10223. ,med_medical_record tt2
  10224. WHERE
  10225. tt2.is_deleted = 'N'
  10226. AND tt1.hospital_id = tt2.hospital_id
  10227. AND tt1.behospital_code = tt2.behospital_code
  10228. AND tt2.mode_id = 30
  10229. </if>
  10230. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10231. ,med_crisis_info tt2
  10232. WHERE
  10233. tt2.is_deleted = 'N'
  10234. AND tt1.hospital_id = tt2.hospital_id
  10235. AND tt1.behospital_code = tt2.behospital_code
  10236. </if>
  10237. ) t1
  10238. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10239. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10240. AND t1.behospital_code = t2.behospital_code
  10241. AND t2.is_deleted = 'N'
  10242. </if>
  10243. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10244. , med_home_page t2
  10245. , med_home_operation_info t3
  10246. WHERE t1.hospital_id = t2.hospital_id
  10247. AND t1.behospital_code = t2.behospital_code
  10248. AND t2.home_page_id = t3.home_page_id
  10249. AND t2.is_deleted = 'N'
  10250. AND t3.is_deleted = 'N'
  10251. </if>
  10252. ) t
  10253. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10254. AND t.hospitalId = qi.hospital_id
  10255. AND t.behospitalCode = qi.behospital_code
  10256. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10257. AND t.hospitalId = qd.hospital_id
  10258. AND t.behospitalCode = qd.behospital_code
  10259. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10260. AND qd.cases_id = qc.id
  10261. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10262. AND qd.cases_id = qce.cases_id
  10263. AND qd.cases_entry_id = qce.id
  10264. where 1=1
  10265. <if test="qcResultShortPageVO.checkStatus != null">
  10266. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10267. </if>
  10268. <if test="qcResultShortPageVO.mrStatus != null">
  10269. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10270. </if>
  10271. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10272. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10273. </if>
  10274. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10275. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10276. </if>
  10277. <if test="qcResultShortPageVO.chTimeStart != null ">
  10278. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10279. </if>
  10280. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10281. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10282. </if>
  10283. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10284. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10285. </if>
  10286. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10287. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10288. </if>
  10289. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10290. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10291. </if>
  10292. <if test="qcResultShortPageVO.casesEntryId != null ">
  10293. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10294. </if>
  10295. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10296. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10297. </if>
  10298. <if test="qcResultShortPageVO.casesId != null">
  10299. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10300. </if>
  10301. )f1,
  10302. (SELECT
  10303. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10304. t.behDeptId,
  10305. t.behDeptName
  10306. FROM
  10307. (SELECT DISTINCT
  10308. t1.hospital_id AS hospitalId,
  10309. t1.behospital_code AS behospitalCode,
  10310. t1.bed_code AS bedCode,
  10311. t1.LEVEL AS LEVEL,
  10312. t1.grade_type AS gradeType,
  10313. t1.score_res AS scoreRes,
  10314. t1.NAME AS NAME,
  10315. t1.sex AS sex,
  10316. t1.beh_dept_id AS behDeptId,
  10317. t1.beh_dept_name AS behDeptName,
  10318. t1.doctor_id AS doctorId,
  10319. t1.doctor_name AS doctorName,
  10320. t1.beh_doctor_id AS behDoctorId,
  10321. t1.beh_doctor_name AS behDoctorName,
  10322. t1.director_doctor_id AS directorDoctorId,
  10323. t1.director_doctor_name AS directorDoctorName,
  10324. t1.birthday AS birthday,
  10325. t1.behospital_date AS behospitalDate,
  10326. t1.leave_hospital_date AS leaveHospitalDate,
  10327. t1.placefile_date AS placefileDate,
  10328. t1.gmt_create AS gradeTime,
  10329. t1.diagnose,
  10330. t1.ward_name AS wardName,
  10331. t2.age,
  10332. t1.file_code AS fileCode,
  10333. t1.checkStatus,
  10334. t1.mrStatus,
  10335. t1.chName,
  10336. t1.mrName,
  10337. t1.chTime,
  10338. t1.mrTime
  10339. FROM
  10340. (
  10341. SELECT DISTINCT
  10342. tt1.*
  10343. FROM
  10344. (SELECT
  10345. be.*,
  10346. ifnull(mci.status,0) AS checkStatus,
  10347. ifnull(hm_mci.status,0) AS mrStatus,
  10348. mci.check_name as chName,
  10349. hm_mci.check_name as mrName,
  10350. mci.gmt_create as chTime,
  10351. hm_mci.gmt_create as mrTime
  10352. FROM
  10353. (
  10354. SELECT DISTINCT
  10355. a.hospital_id,
  10356. a.behospital_code,
  10357. a.bed_code,
  10358. a.file_code,
  10359. b.LEVEL,
  10360. b.grade_type,
  10361. b.score_res,
  10362. a.NAME,
  10363. a.sex,
  10364. a.beh_dept_id,
  10365. a.beh_dept_name,
  10366. a.birthday,
  10367. a.behospital_date,
  10368. a.leave_hospital_date,
  10369. a.doctor_id,
  10370. a.doctor_name,
  10371. a.beh_doctor_id,
  10372. a.beh_doctor_name,
  10373. a.director_doctor_id,
  10374. a.director_doctor_name,
  10375. a.diagnose,
  10376. a.placefile_date,
  10377. a.ward_name,
  10378. b.gmt_create
  10379. FROM
  10380. med_behospital_info a,
  10381. med_qcresult_info b,
  10382. med_qcresult_detail c,
  10383. qc_cases_entry d
  10384. WHERE
  10385. a.is_deleted = 'N'
  10386. AND b.is_deleted = 'N'
  10387. AND c.is_deleted = 'N'
  10388. AND d.is_deleted = 'N'
  10389. AND a.hospital_id = b.hospital_id
  10390. AND a.hospital_id = c.hospital_id
  10391. AND a.behospital_code = b.behospital_code
  10392. AND a.behospital_code = c.behospital_code
  10393. AND c.cases_id = d.cases_id
  10394. AND c.cases_entry_id = d.id
  10395. AND a.qc_type_id != 0
  10396. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10397. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10398. </if>
  10399. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10400. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10401. </if>
  10402. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10403. <if test="qcResultShortPageVO.startDate != null ">
  10404. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10405. </if>
  10406. <if test="qcResultShortPageVO.endDate != null ">
  10407. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10408. </if>
  10409. </if>
  10410. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10411. <if test="qcResultShortPageVO.startDate != null ">
  10412. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10413. </if>
  10414. <if test="qcResultShortPageVO.endDate != null">
  10415. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10416. </if>
  10417. </if>
  10418. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10419. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10420. </if>
  10421. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10422. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10423. </if>
  10424. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10425. AND b.`level` = #{qcResultShortPageVO.level}
  10426. </if>
  10427. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10428. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10429. </if>
  10430. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10431. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10432. </if>
  10433. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10434. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10435. </if>
  10436. <if test="qcResultShortPageVO.casesEntryId != null ">
  10437. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10438. </if>
  10439. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10440. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10441. </if>
  10442. <if test="qcResultShortPageVO.casesId != null">
  10443. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10444. </if>
  10445. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10446. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10447. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10448. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10449. </if>
  10450. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10451. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10452. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10453. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10454. </if>
  10455. <if test="qcResultShortPageVO.isReject != null">
  10456. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10457. </if>
  10458. <if test="qcResultShortPageVO.ruleType != null">
  10459. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10460. </if>
  10461. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10462. AND TIMESTAMPDIFF(
  10463. DAY,
  10464. DATE( a.behospital_date ),
  10465. DATE( a.leave_hospital_date ))> 30
  10466. </if>
  10467. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10468. AND TIMESTAMPDIFF(
  10469. DAY,
  10470. DATE( a.behospital_date ),
  10471. DATE( a.leave_hospital_date ))> 31
  10472. </if>
  10473. )be
  10474. left join med_check_info mci
  10475. on mci.is_deleted = 'N'
  10476. and mci.check_type = 0
  10477. and be.hospital_id = mci.hospital_id
  10478. and be.behospital_code = mci.behospital_code
  10479. left join med_check_info hm_mci
  10480. on hm_mci.is_deleted = 'N'
  10481. and hm_mci.check_type = 1
  10482. and be.hospital_id = hm_mci.hospital_id
  10483. and be.behospital_code = hm_mci.behospital_code
  10484. )tt1
  10485. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10486. ,med_medical_record tt2
  10487. WHERE
  10488. tt2.is_deleted = 'N'
  10489. AND tt1.hospital_id = tt2.hospital_id
  10490. AND tt1.behospital_code = tt2.behospital_code
  10491. AND tt2.mode_id = 30
  10492. </if>
  10493. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10494. ,med_crisis_info tt2
  10495. WHERE
  10496. tt2.is_deleted = 'N'
  10497. AND tt1.hospital_id = tt2.hospital_id
  10498. AND tt1.behospital_code = tt2.behospital_code
  10499. </if>
  10500. ) t1
  10501. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10502. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10503. AND t1.behospital_code = t2.behospital_code
  10504. AND t2.is_deleted = 'N'
  10505. </if>
  10506. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10507. , med_home_page t2
  10508. , med_home_operation_info t3
  10509. WHERE t1.hospital_id = t2.hospital_id
  10510. AND t1.behospital_code = t2.behospital_code
  10511. AND t2.home_page_id = t3.home_page_id
  10512. AND t2.is_deleted = 'N'
  10513. AND t3.is_deleted = 'N'
  10514. </if>
  10515. ) t
  10516. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10517. AND t.hospitalId = qi.hospital_id
  10518. AND t.behospitalCode = qi.behospital_code
  10519. where 1=1
  10520. <if test="qcResultShortPageVO.checkStatus != null">
  10521. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10522. </if>
  10523. <if test="qcResultShortPageVO.mrStatus != null">
  10524. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10525. </if>
  10526. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10527. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10528. </if>
  10529. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10530. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10531. </if>
  10532. <if test="qcResultShortPageVO.chTimeStart != null ">
  10533. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10534. </if>
  10535. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10536. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10537. </if>
  10538. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10539. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10540. </if>
  10541. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10542. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10543. </if>
  10544. GROUP BY
  10545. t.behDeptId,
  10546. t.behDeptName
  10547. )f2
  10548. WHERE
  10549. f1.behDeptId = f2.behDeptId
  10550. AND f1.behDeptName = f2.behDeptName
  10551. )m
  10552. </select>
  10553. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  10554. <result column="deptName" property="deptName"/>
  10555. <result column="deptId" property="deptId"/>
  10556. <result column="doctorGroup" property="doctorGroup"/>
  10557. <result column="doctorName" property="doctorName"/>
  10558. <result column="entry_2658_num" property="entry_2658_num"/>
  10559. <result column="entry_2686_num" property="entry_2686_num"/>
  10560. <result column="entry_2657_num" property="entry_2657_num"/>
  10561. <result column="entry_3010_num" property="entry_3010_num"/>
  10562. <result column="entry_2655_num" property="entry_2655_num"/>
  10563. <result column="entry_2654_num" property="entry_2654_num"/>
  10564. <result column="entry_2852_num" property="entry_2852_num"/>
  10565. <result column="entry_2287_num" property="entry_2287_num"/>
  10566. <result column="entry_3025_num" property="entry_3025_num"/>
  10567. <result column="entry_2170_num" property="entry_2170_num"/>
  10568. <result column="entry_2930_num" property="entry_2930_num"/>
  10569. <result column="entry_2900_num" property="entry_2900_num"/>
  10570. <result column="entry_2229_num" property="entry_2229_num"/>
  10571. <result column="entry_2217_num" property="entry_2217_num"/>
  10572. <result column="entry_2218_num" property="entry_2218_num"/>
  10573. <result column="entry_2220_num" property="entry_2220_num"/>
  10574. <result column="entry_2486_num" property="entry_2486_num"/>
  10575. <result column="entry_3063_num" property="entry_3063_num"/>
  10576. <result column="entry_3062_num" property="entry_3062_num"/>
  10577. <result column="entry_2495_num" property="entry_2495_num"/>
  10578. </resultMap>
  10579. <!-- 病历稽查表-->
  10580. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  10581. SELECT
  10582. a.beh_dept_id AS deptId,
  10583. a.beh_dept_name AS deptName,
  10584. a.doctor_name as doctorGroup,
  10585. a.doctor_name as doctorName,
  10586. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10587. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10588. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10589. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10590. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10591. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10592. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10593. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10594. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10595. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10596. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10597. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10598. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10599. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10600. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10601. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10602. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10603. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10604. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10605. sum(c.cases_entry_id = 2495) as entry_2495_num
  10606. FROM
  10607. med_behospital_info a,
  10608. med_qcresult_info b,
  10609. med_qcresult_detail c,
  10610. qc_cases_entry d,
  10611. bas_doctor_info e
  10612. WHERE
  10613. a.is_deleted = 'N'
  10614. AND b.is_deleted = 'N'
  10615. AND c.is_deleted = 'N'
  10616. AND d.is_deleted = 'N'
  10617. AND e.is_deleted = 'N'
  10618. AND a.hospital_id = b.hospital_id
  10619. AND a.hospital_id = c.hospital_id
  10620. AND a.hospital_id = e.hospital_id
  10621. AND a.behospital_code = b.behospital_code
  10622. AND a.behospital_code = c.behospital_code
  10623. AND a.beh_dept_id = e.dept_id
  10624. AND c.cases_entry_id = d.id
  10625. and a.doctor_id=e.doctor_id
  10626. and e.group_id is not NULL
  10627. AND LENGTH(e.group_id)>0
  10628. AND a.qc_type_id != 0
  10629. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10630. and a.is_placefile = #{filterVO.isPlacefile}
  10631. </if>
  10632. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10633. AND a.hospital_id = #{filterVO.hospitalId}
  10634. </if>
  10635. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10636. <if test="filterVO.startDate != null ">
  10637. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10638. </if>
  10639. <if test="filterVO.endDate != null ">
  10640. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10641. </if>
  10642. </if>
  10643. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10644. <if test="filterVO.startDate != null ">
  10645. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10646. </if>
  10647. <if test="filterVO.endDate != null ">
  10648. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10649. </if>
  10650. </if>
  10651. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10652. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10653. </if>
  10654. GROUP BY
  10655. a.beh_dept_id,
  10656. e.group_id,
  10657. a.doctor_id
  10658. </select>
  10659. <!-- 病历稽查表-科室-->
  10660. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  10661. SELECT
  10662. a.beh_dept_id AS deptId,
  10663. a.beh_dept_name AS deptName,
  10664. a.doctor_name as doctorName,
  10665. a.doctor_name as doctorGroup,
  10666. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10667. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10668. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10669. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10670. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10671. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10672. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10673. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10674. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10675. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10676. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10677. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10678. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10679. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10680. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10681. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10682. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10683. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10684. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10685. sum(c.cases_entry_id = 2495) as entry_2495_num
  10686. FROM
  10687. med_behospital_info a,
  10688. med_qcresult_info b,
  10689. med_qcresult_detail c,
  10690. qc_cases_entry d,
  10691. bas_doctor_info e,
  10692. sys_user_dept f
  10693. WHERE
  10694. a.is_deleted = 'N'
  10695. AND b.is_deleted = 'N'
  10696. AND c.is_deleted = 'N'
  10697. AND d.is_deleted = 'N'
  10698. AND e.is_deleted = 'N'
  10699. AND f.is_deleted = 'N'
  10700. AND a.hospital_id = b.hospital_id
  10701. AND a.hospital_id = c.hospital_id
  10702. AND a.hospital_id = e.hospital_id
  10703. AND a.hospital_id = f.hospital_id
  10704. AND a.behospital_code = b.behospital_code
  10705. AND a.behospital_code = c.behospital_code
  10706. AND a.beh_dept_id = f.dept_id
  10707. AND c.cases_entry_id = d.id
  10708. and a.doctor_id=e.doctor_id
  10709. and e.group_id is not NULL
  10710. AND LENGTH(e.group_id)>0
  10711. AND a.qc_type_id != 0
  10712. <if test="filterVO.userId!=null">
  10713. AND f.user_id = #{filterVO.userId}
  10714. </if>
  10715. <if test="filterVO.name != null and filterVO.name != ''">
  10716. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  10717. </if>
  10718. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10719. and a.is_placefile = #{filterVO.isPlacefile}
  10720. </if>
  10721. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10722. AND a.hospital_id = #{filterVO.hospitalId}
  10723. </if>
  10724. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10725. <if test="filterVO.startDate != null ">
  10726. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10727. </if>
  10728. <if test="filterVO.endDate != null ">
  10729. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10730. </if>
  10731. </if>
  10732. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10733. <if test="filterVO.startDate != null ">
  10734. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10735. </if>
  10736. <if test="filterVO.endDate != null ">
  10737. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10738. </if>
  10739. </if>
  10740. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10741. AND a.beh_dept_name = #{filterVO.deptName}
  10742. </if>
  10743. GROUP BY
  10744. a.beh_dept_id,
  10745. e.group_id,
  10746. a.doctor_name
  10747. </select>
  10748. <!-- 病历稽查表最新sql、id&&name-->
  10749. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  10750. SELECT
  10751. d.id,
  10752. d.name
  10753. from
  10754. qc_cases_entry d
  10755. where
  10756. 1=1
  10757. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  10758. and d.id in
  10759. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  10760. '${item}'
  10761. </foreach>
  10762. </if>
  10763. </select>
  10764. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  10765. <result column="deptName" property="deptName"/>
  10766. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10767. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  10768. <result column="doctorName" property="doctorName"/>
  10769. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10770. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  10771. <result column="RYJLW_24" property="ryjlw_24"/>
  10772. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10773. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10774. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10775. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10776. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10777. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10778. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10779. <result column="SQTLXJW" property="sqtlxjw"/>
  10780. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10781. <result column="XHSCW_30M" property="xhscw_30m"/>
  10782. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10783. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10784. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10785. <result column="ZKJLW_24" property="zkjlw_24"/>
  10786. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10787. <result column="SXHWJL" property="sxhwjl"/>
  10788. <result column="SXPJW_24" property="sxpjw_24"/>
  10789. <result column="WJZWJL" property="wjzwjl"/>
  10790. <result column="WYWWCXJ" property="wywwcxj"/>
  10791. </collection>
  10792. </collection>
  10793. </resultMap>
  10794. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  10795. <result column="deptName" property="deptName"/>
  10796. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10797. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  10798. <result column="doctorGroup" property="doctorGroup"/>
  10799. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10800. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  10801. <result column="doctorName" property="doctorName"/>
  10802. <result column="RYJLW_24" property="ryjlw_24"/>
  10803. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10804. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10805. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10806. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10807. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10808. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10809. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10810. <result column="SQTLXJW" property="sqtlxjw"/>
  10811. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10812. <result column="XHSCW_30M" property="xhscw_30m"/>
  10813. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10814. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10815. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10816. <result column="ZKJLW_24" property="zkjlw_24"/>
  10817. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10818. <result column="SXHWJL" property="sxhwjl"/>
  10819. <result column="SXPJW_24" property="sxpjw_24"/>
  10820. <result column="WJZWJL" property="wjzwjl"/>
  10821. <result column="WYWWCXJ" property="wywwcxj"/>
  10822. </collection>
  10823. </collection>
  10824. </resultMap>
  10825. <!-- 病历稽查表最新导出-->
  10826. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  10827. SELECT
  10828. a.beh_dept_id AS deptId,
  10829. a.beh_dept_name AS deptName,
  10830. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  10831. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10832. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10833. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10834. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10835. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10836. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10837. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10838. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10839. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10840. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10841. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10842. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10843. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10844. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10845. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10846. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10847. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10848. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10849. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10850. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10851. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  10852. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  10853. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  10854. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  10855. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  10856. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  10857. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  10858. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  10859. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  10860. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  10861. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  10862. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  10863. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  10864. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  10865. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  10866. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  10867. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  10868. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  10869. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  10870. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  10871. FROM
  10872. med_behospital_info a,
  10873. med_qcresult_info b,
  10874. med_qcresult_detail c,
  10875. qc_cases_entry d,
  10876. bas_doctor_info e
  10877. WHERE
  10878. a.is_deleted = 'N'
  10879. AND b.is_deleted = 'N'
  10880. AND c.is_deleted = 'N'
  10881. AND d.is_deleted = 'N'
  10882. AND e.is_deleted = 'N'
  10883. AND a.hospital_id = b.hospital_id
  10884. AND a.hospital_id = c.hospital_id
  10885. AND a.hospital_id = e.hospital_id
  10886. AND a.behospital_code = b.behospital_code
  10887. AND a.behospital_code = c.behospital_code
  10888. AND a.beh_dept_id = e.dept_id
  10889. AND c.cases_entry_id = d.id
  10890. and a.doctor_id=e.doctor_id
  10891. and e.group_id is not NULL
  10892. AND LENGTH(e.group_id)>0
  10893. AND a.qc_type_id != 0
  10894. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10895. and a.is_placefile = #{filterVO.isPlacefile}
  10896. </if>
  10897. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10898. AND a.hospital_id = #{filterVO.hospitalId}
  10899. </if>
  10900. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10901. <if test="filterVO.startDate != null ">
  10902. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10903. </if>
  10904. <if test="filterVO.endDate != null ">
  10905. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10906. </if>
  10907. </if>
  10908. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10909. <if test="filterVO.startDate != null ">
  10910. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10911. </if>
  10912. <if test="filterVO.endDate != null ">
  10913. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10914. </if>
  10915. </if>
  10916. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10917. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10918. </if>
  10919. GROUP BY
  10920. a.beh_dept_id,
  10921. e.group_id
  10922. </select>
  10923. <!-- 病历稽查表最新导出-->
  10924. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  10925. SELECT
  10926. a.beh_dept_id AS deptId,
  10927. a.beh_dept_name AS deptName,
  10928. a.doctor_name as doctorGroup,
  10929. a.doctor_name as doctorName,
  10930. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10931. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10932. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10933. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10934. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10935. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10936. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10937. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10938. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10939. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10940. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10941. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10942. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10943. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10944. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10945. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10946. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10947. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10948. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10949. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10950. FROM
  10951. med_behospital_info a,
  10952. med_qcresult_info b,
  10953. med_qcresult_detail c,
  10954. qc_cases_entry d,
  10955. bas_doctor_info e,
  10956. sys_user_dept f
  10957. WHERE
  10958. a.is_deleted = 'N'
  10959. AND b.is_deleted = 'N'
  10960. AND c.is_deleted = 'N'
  10961. AND d.is_deleted = 'N'
  10962. AND e.is_deleted = 'N'
  10963. AND f.is_deleted = 'N'
  10964. AND a.hospital_id = b.hospital_id
  10965. AND a.hospital_id = c.hospital_id
  10966. AND a.hospital_id = e.hospital_id
  10967. AND a.hospital_id = f.hospital_id
  10968. AND a.behospital_code = b.behospital_code
  10969. AND a.behospital_code = c.behospital_code
  10970. AND a.beh_dept_id = f.dept_id
  10971. AND c.cases_entry_id = d.id
  10972. and a.doctor_id=e.doctor_id
  10973. and e.group_id is not NULL
  10974. AND LENGTH(e.group_id)>0
  10975. AND a.qc_type_id != 0
  10976. <if test="filterVO.userId!=null">
  10977. AND f.user_id = #{filterVO.userId}
  10978. </if>
  10979. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10980. and a.is_placefile = #{filterVO.isPlacefile}
  10981. </if>
  10982. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10983. AND a.hospital_id = #{filterVO.hospitalId}
  10984. </if>
  10985. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10986. <if test="filterVO.startDate != null ">
  10987. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10988. </if>
  10989. <if test="filterVO.endDate != null ">
  10990. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10991. </if>
  10992. </if>
  10993. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10994. <if test="filterVO.startDate != null ">
  10995. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10996. </if>
  10997. <if test="filterVO.endDate != null ">
  10998. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10999. </if>
  11000. </if>
  11001. <if test="filterVO.name != null and filterVO.name != ''">
  11002. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11003. </if>
  11004. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11005. AND a.beh_dept_name = #{filterVO.deptName}
  11006. </if>
  11007. GROUP BY
  11008. a.beh_dept_id,
  11009. e.group_id,
  11010. a.doctor_name
  11011. </select>
  11012. <!-- 未整改病历统计-->
  11013. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11014. SELECT
  11015. a.beh_dept_id AS deptId,
  11016. a.beh_dept_name AS deptName,
  11017. d.id AS casesEntryId,
  11018. d.NAME AS casesEntryName,
  11019. count(*) AS casesEntryNum
  11020. FROM
  11021. med_behospital_info a,
  11022. med_qcresult_info b,
  11023. med_qcresult_detail c,
  11024. qc_cases_entry d
  11025. WHERE
  11026. a.is_deleted = 'N'
  11027. AND b.is_deleted = 'N'
  11028. AND c.is_deleted = 'N'
  11029. AND d.is_deleted = 'N'
  11030. AND a.hospital_id = b.hospital_id
  11031. AND a.hospital_id = c.hospital_id
  11032. AND a.behospital_code = b.behospital_code
  11033. AND a.behospital_code = c.behospital_code
  11034. AND c.cases_entry_id = d.id
  11035. AND a.qc_type_id != 0
  11036. <if test="isPlacefile != null and isPlacefile != ''">
  11037. and a.is_placefile = #{isPlacefile}
  11038. </if>
  11039. <if test="hospitalId != null and hospitalId != ''">
  11040. AND a.hospital_id = #{hospitalId}
  11041. </if>
  11042. <if test="isPlacefile != null and isPlacefile == 0">
  11043. <if test="startDate != null ">
  11044. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11045. </if>
  11046. <if test="endDate != null ">
  11047. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11048. </if>
  11049. </if>
  11050. <if test="isPlacefile != null and isPlacefile == 1">
  11051. <if test="startDate != null ">
  11052. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11053. </if>
  11054. <if test="endDate != null ">
  11055. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11056. </if>
  11057. </if>
  11058. <if test="deptName != null and deptName != ''">
  11059. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  11060. </if>
  11061. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11062. AND c.cases_entry_id IN
  11063. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11064. #{item}
  11065. </foreach>
  11066. </if>
  11067. GROUP BY
  11068. a.beh_dept_id,
  11069. a.beh_dept_name,
  11070. c.cases_entry_id,
  11071. d.NAME
  11072. </select>
  11073. <!-- 未整改病历统计-科室-->
  11074. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11075. SELECT
  11076. a.beh_dept_id AS deptId,
  11077. a.beh_dept_name AS deptName,
  11078. a.doctor_id as doctorId,
  11079. a.doctor_name as doctorName,
  11080. d.id AS casesEntryId,
  11081. d.NAME AS casesEntryName,
  11082. count(*) AS casesEntryNum
  11083. FROM
  11084. med_behospital_info a,
  11085. med_qcresult_info b,
  11086. med_qcresult_detail c,
  11087. qc_cases_entry d,
  11088. sys_user_dept f
  11089. WHERE
  11090. a.is_deleted = 'N'
  11091. AND b.is_deleted = 'N'
  11092. AND c.is_deleted = 'N'
  11093. AND d.is_deleted = 'N'
  11094. AND f.is_deleted = 'N'
  11095. AND a.hospital_id = b.hospital_id
  11096. AND a.hospital_id = c.hospital_id
  11097. AND a.hospital_id = f.hospital_id
  11098. AND a.behospital_code = b.behospital_code
  11099. AND a.behospital_code = c.behospital_code
  11100. AND a.beh_dept_id = f.dept_id
  11101. AND c.cases_entry_id = d.id
  11102. AND a.qc_type_id != 0
  11103. <if test="userId!=null">
  11104. AND f.user_id = #{userId}
  11105. </if>
  11106. <if test="isPlacefile != null and isPlacefile != ''">
  11107. and a.is_placefile = #{isPlacefile}
  11108. </if>
  11109. <if test="hospitalId != null and hospitalId != ''">
  11110. AND a.hospital_id = #{hospitalId}
  11111. </if>
  11112. <if test="isPlacefile != null and isPlacefile == 0">
  11113. <if test="startDate != null ">
  11114. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11115. </if>
  11116. <if test="endDate != null ">
  11117. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11118. </if>
  11119. </if>
  11120. <if test="isPlacefile != null and isPlacefile == 1">
  11121. <if test="startDate != null ">
  11122. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11123. </if>
  11124. <if test="endDate != null ">
  11125. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11126. </if>
  11127. </if>
  11128. <if test="deptName != null and deptName != ''">
  11129. AND a.beh_dept_name= #{deptName}
  11130. </if>
  11131. <if test="doctorName != null and doctorName != ''">
  11132. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11133. </if>
  11134. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11135. AND c.cases_entry_id IN
  11136. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11137. #{item}
  11138. </foreach>
  11139. </if>
  11140. GROUP BY
  11141. a.doctor_id,
  11142. a.doctor_name,
  11143. c.cases_entry_id,
  11144. d.NAME
  11145. </select>
  11146. <!-- 不合格/合格数病历号(内页)科室-->
  11147. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  11148. SELECT t.*
  11149. FROM
  11150. (SELECT DISTINCT
  11151. t1.hospital_id AS hospitalId,
  11152. t1.behospital_code AS behospitalCode,
  11153. t1.bed_code AS bedCode,
  11154. t1.LEVEL AS LEVEL,
  11155. t1.grade_type AS gradeType,
  11156. t1.score_res AS scoreRes,
  11157. t1.scoreBn,
  11158. t1.NAME AS NAME,
  11159. t1.sex AS sex,
  11160. t1.medoupName,
  11161. t1.beh_dept_id AS behDeptId,
  11162. t1.beh_dept_name AS behDeptName,
  11163. t1.doctor_id AS doctorId,
  11164. t1.doctor_name AS doctorName,
  11165. t1.beh_doctor_id AS behDoctorId,
  11166. t1.beh_doctor_name AS behDoctorName,
  11167. t1.director_doctor_id AS directorDoctorId,
  11168. t1.director_doctor_name AS directorDoctorName,
  11169. t1.birthday AS birthday,
  11170. t1.behospital_date AS behospitalDate,
  11171. t1.leave_hospital_date AS leaveHospitalDate,
  11172. t1.placefile_date AS placefileDate,
  11173. t1.gmt_create AS gradeTime,
  11174. t1.diagnose,
  11175. t1.ward_name AS wardName,
  11176. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11177. t1.file_code AS fileCode,
  11178. t1.checkStatus,
  11179. t1.mrStatus,
  11180. t1.chName,
  11181. t1.mrName,
  11182. t1.chTime,
  11183. t1.mrTime
  11184. FROM
  11185. (SELECT
  11186. be.*,
  11187. t3.name as medoupName,
  11188. b.LEVEL,
  11189. b.grade_type,
  11190. b.score_res,
  11191. b.gmt_create,
  11192. ifnull(mci.status,0) AS checkStatus,
  11193. ifnull(hm_mci.status,0) AS mrStatus,
  11194. mci.check_name as chName,
  11195. hm_mci.check_name as mrName,
  11196. mci.gmt_create as chTime,
  11197. hm_mci.gmt_create as mrTime
  11198. FROM
  11199. (
  11200. SELECT DISTINCT
  11201. a.hospital_id,
  11202. a.behospital_code,
  11203. a.bed_code,
  11204. a.file_code,
  11205. e.score_res as scoreBn,
  11206. a.NAME,
  11207. a.sex,
  11208. a.beh_dept_id,
  11209. a.beh_dept_name,
  11210. a.birthday,
  11211. a.behospital_date,
  11212. a.leave_hospital_date,
  11213. a.doctor_id,
  11214. a.doctor_name,
  11215. a.beh_doctor_id,
  11216. a.beh_doctor_name,
  11217. a.director_doctor_id,
  11218. a.director_doctor_name,
  11219. a.diagnose,
  11220. a.placefile_date,
  11221. a.ward_name
  11222. FROM
  11223. med_behospital_info a,
  11224. sys_user_dept c,
  11225. med_qcresult_cases e
  11226. WHERE
  11227. a.is_deleted = 'N'
  11228. AND c.is_deleted = 'N'
  11229. AND e.is_deleted = 'N'
  11230. AND a.hospital_id = c.hospital_id
  11231. AND a.hospital_id = e.hospital_id
  11232. AND a.beh_dept_id = c.dept_id
  11233. AND a.behospital_code = e.behospital_code
  11234. AND a.qc_type_id != 0
  11235. AND e.cases_id = 243
  11236. <if test="userId!=null">
  11237. AND c.user_id = #{userId}
  11238. </if>
  11239. <if test="deptName != null and deptName != ''">
  11240. and a.beh_dept_name = #{deptName}
  11241. </if>
  11242. <if test="deptClass != null and deptClass != ''">
  11243. and a.beh_dept_id = #{deptClass}
  11244. </if>
  11245. <if test="deptId != null and deptId != ''">
  11246. and a.beh_dept_id = #{deptId}
  11247. </if>
  11248. <if test="titleName != null and titleName != '' ">
  11249. <if test="titleName == '不合格数'">
  11250. AND e.`level`='不合格'
  11251. </if>
  11252. <if test="titleName == '合格数'">
  11253. AND e.`level`='合格'
  11254. </if>
  11255. </if>
  11256. <if test="isPlacefile != null and isPlacefile != ''">
  11257. and a.is_placefile = #{isPlacefile}
  11258. </if>
  11259. <if test="doctorId != null and doctorId != ''">
  11260. AND a.doctor_id = #{doctorId}
  11261. </if>
  11262. <if test="doctorName != null and doctorName != ''">
  11263. AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  11264. OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  11265. OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' ))
  11266. </if>
  11267. <if test="hospitalId != null and hospitalId != ''">
  11268. AND a.hospital_id = #{hospitalId}
  11269. </if>
  11270. <if test="isPlacefile != null and isPlacefile == 0">
  11271. <if test="startDate != null ">
  11272. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11273. </if>
  11274. <if test="endDate != null ">
  11275. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11276. </if>
  11277. </if>
  11278. <if test="isPlacefile != null and isPlacefile == 1">
  11279. <if test="startDate != null ">
  11280. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11281. </if>
  11282. <if test="endDate != null">
  11283. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11284. </if>
  11285. </if>
  11286. <if test="diagnose != null and diagnose != ''">
  11287. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11288. </if>
  11289. <if test="wardName != null and wardName != ''">
  11290. AND a.ward_name LIKE CONCAT( '%', #{wardName}, '%' )
  11291. </if>
  11292. <if test="behospitalCode != null and behospitalCode != ''">
  11293. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11294. </if>
  11295. <if test="patName != null and patName != ''">
  11296. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11297. </if>
  11298. )be
  11299. left join med_check_info mci
  11300. on mci.is_deleted = 'N'
  11301. and mci.check_type = 0
  11302. and be.hospital_id = mci.hospital_id
  11303. and be.behospital_code = mci.behospital_code
  11304. left join med_check_info hm_mci
  11305. on hm_mci.is_deleted = 'N'
  11306. and hm_mci.check_type = 1
  11307. and be.hospital_id = hm_mci.hospital_id
  11308. and be.behospital_code = hm_mci.behospital_code
  11309. left join med_qcresult_info b
  11310. on b.is_deleted = 'N'
  11311. AND be.hospital_id = b.hospital_id
  11312. AND be.behospital_code = b.behospital_code
  11313. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  11314. and be.hospital_id = t2.hospital_id
  11315. AND t2.is_deleted = 'N'
  11316. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  11317. AND t3.is_deleted = 'N'
  11318. where
  11319. 1=1
  11320. <if test="level != null and level != ''">
  11321. AND b.`level` = #{level}
  11322. </if>
  11323. <if test="medoupName != null and medoupName != ''">
  11324. AND t3.name LIKE CONCAT( '%', #{medoupName}, '%' )
  11325. </if>
  11326. ) t1
  11327. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11328. AND t1.behospital_code = t2.behospital_code
  11329. AND t2.is_deleted = 'N'
  11330. ) t,
  11331. (
  11332. SELECT
  11333. a.doctor_id as doctorId,
  11334. a.doctor_name as doctorName
  11335. FROM
  11336. med_behospital_info a,
  11337. sys_user_dept b,
  11338. med_qcresult_cases c,
  11339. med_qcresult_detail d,
  11340. qc_cases_entry e
  11341. WHERE
  11342. a.is_deleted = 'N'
  11343. AND b.is_deleted = 'N'
  11344. AND c.is_deleted = 'N'
  11345. AND d.is_deleted = 'N'
  11346. AND e.is_deleted = 'N'
  11347. AND a.hospital_id = b.hospital_id
  11348. AND a.hospital_id = c.hospital_id
  11349. AND a.hospital_id = d.hospital_id
  11350. AND a.behospital_code = c.behospital_code
  11351. AND a.behospital_code = d.behospital_code
  11352. AND a.beh_dept_id = b.dept_id
  11353. AND c.cases_id = d.cases_id
  11354. AND d.cases_id = e.cases_id
  11355. AND d.cases_entry_id = e.id
  11356. AND d.cases_id = 243
  11357. AND a.qc_type_id != 0
  11358. <if test="userId!=null">
  11359. AND b.user_id = #{userId}
  11360. </if>
  11361. <if test="deptName != null and deptName != ''">
  11362. and a.beh_dept_name = #{deptName}
  11363. </if>
  11364. <if test="doctorName != null and doctorName != ''">
  11365. AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  11366. OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  11367. OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' ))
  11368. </if>
  11369. <if test="doctorId != null and doctorId != ''">
  11370. AND a.doctor_id = #{doctorId}
  11371. </if>
  11372. <if test="deptClass != null and deptClass != ''">
  11373. and a.beh_dept_id = #{deptClass}
  11374. </if>
  11375. <if test="deptId != null and deptId != ''">
  11376. and a.beh_dept_id = #{deptId}
  11377. </if>
  11378. <if test="isPlacefile != null and isPlacefile != ''">
  11379. and a.is_placefile = #{isPlacefile}
  11380. </if>
  11381. <if test="hospitalId != null and hospitalId != ''">
  11382. AND a.hospital_id = #{hospitalId}
  11383. </if>
  11384. <if test="isPlacefile != null and isPlacefile == 0">
  11385. <if test="startDate != null ">
  11386. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11387. </if>
  11388. <if test="endDate != null ">
  11389. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11390. </if>
  11391. </if>
  11392. <if test="isPlacefile != null and isPlacefile == 1">
  11393. <if test="startDate != null ">
  11394. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11395. </if>
  11396. <if test="endDate != null">
  11397. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11398. </if>
  11399. </if>
  11400. <if test="diagnose != null and diagnose != ''">
  11401. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11402. </if>
  11403. <if test="wardName != null and wardName != ''">
  11404. AND a.ward_name LIKE CONCAT( '%', #{wardName}, '%' )
  11405. </if>
  11406. <if test="behospitalCode != null and behospitalCode != ''">
  11407. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11408. </if>
  11409. <if test="patName != null and patName != ''">
  11410. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11411. </if>
  11412. GROUP BY
  11413. a.doctor_id,
  11414. a.doctor_name
  11415. ) t2
  11416. where
  11417. t.doctorId = t2.doctorId
  11418. AND t.doctorName = t2.doctorName
  11419. <if test="checkStatus != null">
  11420. AND t.checkStatus = #{checkStatus}
  11421. </if>
  11422. <if test="mrStatus != null">
  11423. AND t.mrStatus = #{mrStatus}
  11424. </if>
  11425. <if test="chName != null and chName!=''">
  11426. AND t.chName like concat('%', #{chName}, '%')
  11427. </if>
  11428. <if test="mrName != null and mrName!=''">
  11429. AND t.mrName like concat('%', #{mrName}, '%')
  11430. </if>
  11431. <if test="chTimeStart != null ">
  11432. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  11433. </if>
  11434. <if test="chTimeEnd != null ">
  11435. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  11436. </if>
  11437. <if test="mrTimeStart != null ">
  11438. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  11439. </if>
  11440. <if test="mrTimeEnd != null ">
  11441. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  11442. </if>
  11443. </select>
  11444. <!-- 不合格/合格数病历号(内页)全院-->
  11445. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11446. SELECT t.*
  11447. FROM
  11448. (SELECT DISTINCT
  11449. t1.hospital_id AS hospitalId,
  11450. t1.behospital_code AS behospitalCode,
  11451. t1.bed_code AS bedCode,
  11452. t1.LEVEL AS LEVEL,
  11453. t1.grade_type AS gradeType,
  11454. t1.score_res AS scoreRes,
  11455. t1.scoreBn,
  11456. t1.NAME AS NAME,
  11457. t1.sex AS sex,
  11458. t1.beh_dept_id AS behDeptId,
  11459. t1.beh_dept_name AS behDeptName,
  11460. t1.doctor_id AS doctorId,
  11461. t1.doctor_name AS doctorName,
  11462. t1.beh_doctor_id AS behDoctorId,
  11463. t1.beh_doctor_name AS behDoctorName,
  11464. t1.director_doctor_id AS directorDoctorId,
  11465. t1.director_doctor_name AS directorDoctorName,
  11466. t1.birthday AS birthday,
  11467. t1.behospital_date AS behospitalDate,
  11468. t1.leave_hospital_date AS leaveHospitalDate,
  11469. t1.placefile_date AS placefileDate,
  11470. t1.gmt_create AS gradeTime,
  11471. t1.diagnose,
  11472. t1.ward_name AS wardName,
  11473. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11474. t1.file_code AS fileCode,
  11475. t1.checkStatus,
  11476. t1.mrStatus,
  11477. t1.chName,
  11478. t1.mrName,
  11479. t1.chTime,
  11480. t1.mrTime
  11481. FROM
  11482. (SELECT
  11483. be.*,
  11484. b.LEVEL,
  11485. b.grade_type,
  11486. b.score_res,
  11487. b.gmt_create,
  11488. ifnull(mci.status,0) AS checkStatus,
  11489. ifnull(hm_mci.status,0) AS mrStatus,
  11490. mci.check_name as chName,
  11491. hm_mci.check_name as mrName,
  11492. mci.gmt_create as chTime,
  11493. hm_mci.gmt_create as mrTime
  11494. FROM
  11495. (
  11496. SELECT DISTINCT
  11497. a.hospital_id,
  11498. a.behospital_code,
  11499. a.bed_code,
  11500. a.file_code,
  11501. e.score_res as scoreBn,
  11502. a.NAME,
  11503. a.sex,
  11504. a.beh_dept_id,
  11505. a.beh_dept_name,
  11506. a.birthday,
  11507. a.behospital_date,
  11508. a.leave_hospital_date,
  11509. a.doctor_id,
  11510. a.doctor_name,
  11511. a.beh_doctor_id,
  11512. a.beh_doctor_name,
  11513. a.director_doctor_id,
  11514. a.director_doctor_name,
  11515. a.diagnose,
  11516. a.placefile_date,
  11517. a.ward_name
  11518. FROM
  11519. med_behospital_info a,
  11520. med_qcresult_cases e
  11521. WHERE
  11522. a.is_deleted = 'N'
  11523. AND e.is_deleted = 'N'
  11524. AND a.hospital_id = e.hospital_id
  11525. AND a.behospital_code = e.behospital_code
  11526. AND a.qc_type_id != 0
  11527. AND e.cases_id = 243
  11528. <if test="qcResultPageVO.titleName != null ">
  11529. <if test="qcResultPageVO.titleName == '不合格数'">
  11530. AND e.`level`='不合格'
  11531. </if>
  11532. <if test="qcResultPageVO.titleName == '合格数'">
  11533. AND e.`level`='合格'
  11534. </if>
  11535. </if>
  11536. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11537. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11538. </if>
  11539. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11540. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11541. </if>
  11542. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11543. <if test="qcResultPageVO.startDate != null ">
  11544. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11545. </if>
  11546. <if test="qcResultPageVO.endDate != null ">
  11547. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11548. </if>
  11549. </if>
  11550. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11551. <if test="qcResultPageVO.startDate != null ">
  11552. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11553. </if>
  11554. <if test="qcResultPageVO.endDate != null">
  11555. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11556. </if>
  11557. </if>
  11558. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11559. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11560. </if>
  11561. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11562. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  11563. </if>
  11564. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11565. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11566. </if>
  11567. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11568. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11569. </if>
  11570. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11571. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11572. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11573. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11574. </if>
  11575. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11576. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11577. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11578. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11579. </if>
  11580. )be
  11581. left join med_check_info mci
  11582. on mci.is_deleted = 'N'
  11583. and mci.check_type = 0
  11584. and be.hospital_id = mci.hospital_id
  11585. and be.behospital_code = mci.behospital_code
  11586. left join med_check_info hm_mci
  11587. on hm_mci.is_deleted = 'N'
  11588. and hm_mci.check_type = 1
  11589. and be.hospital_id = hm_mci.hospital_id
  11590. and be.behospital_code = hm_mci.behospital_code
  11591. left join med_qcresult_info b
  11592. on b.is_deleted = 'N'
  11593. AND be.hospital_id = b.hospital_id
  11594. AND be.behospital_code = b.behospital_code
  11595. where
  11596. 1=1
  11597. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  11598. AND b.`level` = #{qcResultPageVO.level}
  11599. </if>
  11600. ) t1
  11601. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11602. AND t1.behospital_code = t2.behospital_code
  11603. AND t2.is_deleted = 'N'
  11604. ) t,
  11605. (
  11606. SELECT
  11607. a.beh_dept_id AS deptId,
  11608. a.beh_dept_name AS deptName
  11609. FROM
  11610. med_behospital_info a,
  11611. med_qcresult_cases c,
  11612. med_qcresult_detail d,
  11613. qc_cases_entry e
  11614. WHERE
  11615. a.is_deleted = 'N'
  11616. AND c.is_deleted = 'N'
  11617. AND d.is_deleted = 'N'
  11618. AND e.is_deleted = 'N'
  11619. AND a.hospital_id = c.hospital_id
  11620. AND a.hospital_id = d.hospital_id
  11621. AND a.behospital_code = c.behospital_code
  11622. AND a.behospital_code = d.behospital_code
  11623. AND c.cases_id = d.cases_id
  11624. AND d.cases_id = e.cases_id
  11625. AND d.cases_entry_id = e.id
  11626. AND d.cases_id = 243
  11627. AND a.qc_type_id != 0
  11628. <!-- <if test="qcResultPageVO.titleName != null ">-->
  11629. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  11630. <!-- AND c.`level`='不合格'-->
  11631. <!-- </if>-->
  11632. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  11633. <!-- AND c.`level`='合格'-->
  11634. <!-- </if>-->
  11635. <!-- </if>-->
  11636. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11637. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11638. </if>
  11639. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11640. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11641. </if>
  11642. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11643. <if test="qcResultPageVO.startDate != null ">
  11644. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11645. </if>
  11646. <if test="qcResultPageVO.endDate != null ">
  11647. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11648. </if>
  11649. </if>
  11650. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11651. <if test="qcResultPageVO.startDate != null ">
  11652. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11653. </if>
  11654. <if test="qcResultPageVO.endDate != null">
  11655. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11656. </if>
  11657. </if>
  11658. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11659. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11660. </if>
  11661. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11662. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  11663. </if>
  11664. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11665. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11666. </if>
  11667. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11668. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11669. </if>
  11670. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11671. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11672. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11673. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11674. </if>
  11675. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11676. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11677. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11678. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11679. </if>
  11680. GROUP BY
  11681. a.beh_dept_id,
  11682. a.beh_dept_name
  11683. ) t2
  11684. where
  11685. t.behDeptId = t2.deptId
  11686. AND t.behDeptName = t2.deptName
  11687. <if test="qcResultPageVO.checkStatus != null">
  11688. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  11689. </if>
  11690. <if test="qcResultPageVO.mrStatus != null">
  11691. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  11692. </if>
  11693. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  11694. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  11695. </if>
  11696. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  11697. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  11698. </if>
  11699. <if test="qcResultPageVO.chTimeStart != null ">
  11700. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  11701. </if>
  11702. <if test="qcResultPageVO.chTimeEnd != null ">
  11703. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  11704. </if>
  11705. <if test="qcResultPageVO.mrTimeStart != null ">
  11706. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  11707. </if>
  11708. <if test="qcResultPageVO.mrTimeEnd != null ">
  11709. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  11710. </if>
  11711. </select>
  11712. <!-- 未整改病历质控评分页(内页)-->
  11713. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11714. SELECT t.*
  11715. FROM
  11716. (SELECT DISTINCT
  11717. t1.hospital_id AS hospitalId,
  11718. t1.behospital_code AS behospitalCode,
  11719. t1.bed_code AS bedCode,
  11720. t1.LEVEL AS LEVEL,
  11721. t1.grade_type AS gradeType,
  11722. t1.score_res AS scoreRes,
  11723. t1.scoreBn,
  11724. t1.NAME AS NAME,
  11725. t1.sex AS sex,
  11726. t1.beh_dept_id AS behDeptId,
  11727. t1.beh_dept_name AS behDeptName,
  11728. t1.doctor_id AS doctorId,
  11729. t1.doctor_name AS doctorName,
  11730. t1.beh_doctor_id AS behDoctorId,
  11731. t1.beh_doctor_name AS behDoctorName,
  11732. t1.director_doctor_id AS directorDoctorId,
  11733. t1.director_doctor_name AS directorDoctorName,
  11734. t1.birthday AS birthday,
  11735. t1.behospital_date AS behospitalDate,
  11736. t1.leave_hospital_date AS leaveHospitalDate,
  11737. t1.placefile_date AS placefileDate,
  11738. t1.gmt_create AS gradeTime,
  11739. t1.diagnose,
  11740. t1.ward_name AS wardName,
  11741. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11742. t1.file_code AS fileCode,
  11743. t1.checkStatus,
  11744. t1.mrStatus,
  11745. t1.chName,
  11746. t1.mrName,
  11747. t1.chTime,
  11748. t1.mrTime
  11749. FROM
  11750. (SELECT
  11751. be.*,
  11752. ifnull(mci.status,0) AS checkStatus,
  11753. ifnull(hm_mci.status,0) AS mrStatus,
  11754. mci.check_name as chName,
  11755. e.score_res as scoreBn,
  11756. hm_mci.check_name as mrName,
  11757. mci.gmt_create as chTime,
  11758. hm_mci.gmt_create as mrTime
  11759. FROM
  11760. (
  11761. SELECT DISTINCT
  11762. a.hospital_id,
  11763. a.behospital_code,
  11764. a.bed_code,
  11765. a.file_code,
  11766. b.LEVEL,
  11767. b.grade_type,
  11768. b.score_res,
  11769. a.NAME,
  11770. a.sex,
  11771. a.beh_dept_id,
  11772. a.beh_dept_name,
  11773. a.birthday,
  11774. a.behospital_date,
  11775. a.leave_hospital_date,
  11776. a.doctor_id,
  11777. a.doctor_name,
  11778. a.beh_doctor_id,
  11779. a.beh_doctor_name,
  11780. a.director_doctor_id,
  11781. a.director_doctor_name,
  11782. a.diagnose,
  11783. a.placefile_date,
  11784. a.ward_name,
  11785. b.gmt_create
  11786. FROM
  11787. med_behospital_info a,
  11788. med_qcresult_info b,
  11789. med_qcresult_detail c,
  11790. qc_cases_entry d
  11791. WHERE
  11792. a.is_deleted = 'N'
  11793. AND b.is_deleted = 'N'
  11794. AND c.is_deleted = 'N'
  11795. AND d.is_deleted = 'N'
  11796. AND a.hospital_id = b.hospital_id
  11797. AND a.hospital_id = c.hospital_id
  11798. AND a.behospital_code = b.behospital_code
  11799. AND a.behospital_code = c.behospital_code
  11800. AND c.cases_id = d.cases_id
  11801. AND c.cases_entry_id = d.id
  11802. AND a.qc_type_id != 0
  11803. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11804. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11805. </if>
  11806. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11807. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11808. </if>
  11809. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11810. <if test="qcResultShortPageVO.startDate != null ">
  11811. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11812. </if>
  11813. <if test="qcResultShortPageVO.endDate != null ">
  11814. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11815. </if>
  11816. </if>
  11817. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11818. <if test="qcResultShortPageVO.startDate != null ">
  11819. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11820. </if>
  11821. <if test="qcResultShortPageVO.endDate != null">
  11822. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11823. </if>
  11824. </if>
  11825. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11826. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11827. </if>
  11828. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11829. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11830. </if>
  11831. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11832. AND b.`level` = #{qcResultShortPageVO.level}
  11833. </if>
  11834. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11835. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11836. </if>
  11837. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11838. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11839. </if>
  11840. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11841. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11842. </if>
  11843. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11844. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11845. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11846. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11847. </if>
  11848. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11849. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11850. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11851. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11852. </if>
  11853. <if test="qcResultShortPageVO.casesEntryId != null ">
  11854. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11855. </if>
  11856. <if test="qcResultShortPageVO.isReject != null">
  11857. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11858. </if>
  11859. <if test="qcResultShortPageVO.ruleType != null">
  11860. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11861. </if>
  11862. )be
  11863. left join med_check_info mci
  11864. on mci.is_deleted = 'N'
  11865. and mci.check_type = 0
  11866. and be.hospital_id = mci.hospital_id
  11867. and be.behospital_code = mci.behospital_code
  11868. left join med_check_info hm_mci
  11869. on hm_mci.is_deleted = 'N'
  11870. and hm_mci.check_type = 1
  11871. and be.hospital_id = hm_mci.hospital_id
  11872. and be.behospital_code = hm_mci.behospital_code
  11873. LEFT JOIN med_qcresult_cases e
  11874. on be.behospital_code = e.behospital_code
  11875. and be.hospital_id = e.hospital_id
  11876. AND e.is_deleted = 'N'
  11877. and e.cases_id = 243
  11878. ) t1
  11879. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11880. AND t1.behospital_code = t2.behospital_code
  11881. AND t2.is_deleted = 'N'
  11882. ) t
  11883. where 1=1
  11884. <if test="qcResultShortPageVO.checkStatus != null">
  11885. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11886. </if>
  11887. <if test="qcResultShortPageVO.mrStatus != null">
  11888. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11889. </if>
  11890. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11891. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11892. </if>
  11893. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11894. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11895. </if>
  11896. <if test="qcResultShortPageVO.chTimeStart != null ">
  11897. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11898. </if>
  11899. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11900. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11901. </if>
  11902. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11903. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11904. </if>
  11905. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11906. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11907. </if>
  11908. </select>
  11909. <!-- 未整改病历质控评分页-科室(内页)-->
  11910. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  11911. SELECT t.*
  11912. FROM
  11913. (SELECT DISTINCT
  11914. t1.hospital_id AS hospitalId,
  11915. t1.behospital_code AS behospitalCode,
  11916. t1.bed_code AS bedCode,
  11917. t1.LEVEL AS LEVEL,
  11918. t1.grade_type AS gradeType,
  11919. t1.score_res AS scoreRes,
  11920. t1.scoreBn,
  11921. t1.NAME AS NAME,
  11922. t1.sex AS sex,
  11923. t1.beh_dept_id AS behDeptId,
  11924. t1.beh_dept_name AS behDeptName,
  11925. t1.doctor_id AS doctorId,
  11926. t1.doctor_name AS doctorName,
  11927. t1.beh_doctor_id AS behDoctorId,
  11928. t1.beh_doctor_name AS behDoctorName,
  11929. t1.director_doctor_id AS directorDoctorId,
  11930. t1.director_doctor_name AS directorDoctorName,
  11931. t1.birthday AS birthday,
  11932. t1.behospital_date AS behospitalDate,
  11933. t1.leave_hospital_date AS leaveHospitalDate,
  11934. t1.placefile_date AS placefileDate,
  11935. t1.gmt_create AS gradeTime,
  11936. t1.diagnose,
  11937. t1.medoupName,
  11938. t1.ward_name AS wardName,
  11939. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11940. t1.file_code AS fileCode,
  11941. t1.checkStatus,
  11942. t1.mrStatus,
  11943. t1.chName,
  11944. t1.mrName,
  11945. t1.chTime,
  11946. t1.mrTime
  11947. FROM
  11948. (SELECT
  11949. be.*,
  11950. t3.name as medoupName,
  11951. ifnull(mci.status,0) AS checkStatus,
  11952. ifnull(hm_mci.status,0) AS mrStatus,
  11953. mci.check_name as chName,
  11954. e.score_res as scoreBn,
  11955. hm_mci.check_name as mrName,
  11956. mci.gmt_create as chTime,
  11957. hm_mci.gmt_create as mrTime
  11958. FROM
  11959. (
  11960. SELECT DISTINCT
  11961. a.hospital_id,
  11962. a.behospital_code,
  11963. a.bed_code,
  11964. a.file_code,
  11965. b.LEVEL,
  11966. b.grade_type,
  11967. b.score_res,
  11968. a.NAME,
  11969. a.sex,
  11970. a.beh_dept_id,
  11971. a.beh_dept_name,
  11972. a.birthday,
  11973. a.behospital_date,
  11974. a.leave_hospital_date,
  11975. a.doctor_id,
  11976. a.doctor_name,
  11977. a.beh_doctor_id,
  11978. a.beh_doctor_name,
  11979. a.director_doctor_id,
  11980. a.director_doctor_name,
  11981. a.diagnose,
  11982. a.placefile_date,
  11983. a.ward_name,
  11984. b.gmt_create
  11985. FROM
  11986. med_behospital_info a,
  11987. med_qcresult_info b,
  11988. med_qcresult_detail c,
  11989. qc_cases_entry d,
  11990. sys_user_dept f
  11991. WHERE
  11992. a.is_deleted = 'N'
  11993. AND b.is_deleted = 'N'
  11994. AND c.is_deleted = 'N'
  11995. AND d.is_deleted = 'N'
  11996. AND f.is_deleted = 'N'
  11997. AND a.hospital_id = b.hospital_id
  11998. AND a.hospital_id = c.hospital_id
  11999. AND a.hospital_id = f.hospital_id
  12000. AND a.behospital_code = b.behospital_code
  12001. AND a.behospital_code = c.behospital_code
  12002. AND c.cases_id = d.cases_id
  12003. AND a.beh_dept_id = f.dept_id
  12004. AND c.cases_entry_id = d.id
  12005. AND a.qc_type_id != 0
  12006. <if test="qcResultShortPageVO.userId!=null">
  12007. AND f.user_id = #{qcResultShortPageVO.userId}
  12008. </if>
  12009. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12010. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12011. </if>
  12012. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  12013. and a.ward_name LIKE CONCAT( '%',#{qcResultShortPageVO.wardName}, '%' )
  12014. </if>
  12015. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12016. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12017. </if>
  12018. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12019. <if test="qcResultShortPageVO.startDate != null ">
  12020. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12021. </if>
  12022. <if test="qcResultShortPageVO.endDate != null ">
  12023. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12024. </if>
  12025. </if>
  12026. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12027. <if test="qcResultShortPageVO.startDate != null ">
  12028. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12029. </if>
  12030. <if test="qcResultShortPageVO.endDate != null">
  12031. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12032. </if>
  12033. </if>
  12034. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12035. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12036. </if>
  12037. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12038. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12039. </if>
  12040. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  12041. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  12042. </if>
  12043. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12044. AND b.`level` = #{qcResultShortPageVO.level}
  12045. </if>
  12046. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12047. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12048. </if>
  12049. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12050. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12051. </if>
  12052. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12053. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12054. </if>
  12055. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12056. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  12057. </if>
  12058. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12059. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12060. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12061. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12062. </if>
  12063. <if test="qcResultShortPageVO.casesEntryId != null ">
  12064. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12065. </if>
  12066. <if test="qcResultShortPageVO.isReject != null">
  12067. AND c.is_reject = #{qcResultShortPageVO.isReject}
  12068. </if>
  12069. <if test="qcResultShortPageVO.ruleType != null">
  12070. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12071. </if>
  12072. )be
  12073. left join med_check_info mci
  12074. on mci.is_deleted = 'N'
  12075. and mci.check_type = 0
  12076. and be.hospital_id = mci.hospital_id
  12077. and be.behospital_code = mci.behospital_code
  12078. left join med_check_info hm_mci
  12079. on hm_mci.is_deleted = 'N'
  12080. and hm_mci.check_type = 1
  12081. and be.hospital_id = hm_mci.hospital_id
  12082. and be.behospital_code = hm_mci.behospital_code
  12083. LEFT JOIN med_qcresult_cases e
  12084. on be.behospital_code = e.behospital_code
  12085. and be.hospital_id = e.hospital_id
  12086. AND e.is_deleted = 'N'
  12087. and e.cases_id = 243
  12088. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  12089. and be.hospital_id = t2.hospital_id
  12090. AND t2.is_deleted = 'N'
  12091. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  12092. AND t3.is_deleted = 'N'
  12093. ) t1
  12094. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12095. AND t1.behospital_code = t2.behospital_code
  12096. AND t2.is_deleted = 'N'
  12097. ) t
  12098. where 1=1
  12099. <if test="qcResultShortPageVO.checkStatus != null">
  12100. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12101. </if>
  12102. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  12103. AND t.medoupName like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  12104. </if>
  12105. <if test="qcResultShortPageVO.mrStatus != null">
  12106. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12107. </if>
  12108. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12109. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12110. </if>
  12111. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12112. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12113. </if>
  12114. <if test="qcResultShortPageVO.chTimeStart != null ">
  12115. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12116. </if>
  12117. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12118. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12119. </if>
  12120. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12121. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12122. </if>
  12123. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12124. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12125. </if>
  12126. </select>
  12127. <!-- 病案首页不合格/合格数病历详情页导出-->
  12128. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  12129. SELECT
  12130. f1.behDeptId,
  12131. f1.behDeptName,
  12132. f1.doctorName,
  12133. f1.patName,
  12134. f1.behospitalCode,
  12135. f1.hospitalId,
  12136. f1.behospitalDate,
  12137. f1.leaveHospitalDate,
  12138. f1.score,
  12139. f1.scoreBn,
  12140. f2.avgScore,
  12141. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12142. f1.msg,
  12143. f1.caseName,
  12144. </if>
  12145. f1.checkStatus,
  12146. f1.mrStatus,
  12147. f1.chName,
  12148. f1.mrName,
  12149. f1.chTime,
  12150. f1.mrTime
  12151. FROM
  12152. (SELECT
  12153. t.doctorName,
  12154. t.`name` AS patName,
  12155. t.behospitalCode AS behospitalCode,
  12156. t.behospitalDate AS behospitalDate,
  12157. t.leaveHospitalDate AS leaveHospitalDate,
  12158. qi.score_res AS score,
  12159. t.scoreBn,
  12160. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12161. qd.msg AS msg,
  12162. qc.NAME AS caseName,
  12163. </if>
  12164. t.behDeptId,
  12165. t.behDeptName,
  12166. t.hospitalId,
  12167. t.checkStatus,
  12168. t.mrStatus,
  12169. t.chName,
  12170. t.mrName,
  12171. t.chTime,
  12172. t.mrTime
  12173. FROM
  12174. (SELECT DISTINCT
  12175. t1.hospital_id AS hospitalId,
  12176. t1.behospital_code AS behospitalCode,
  12177. t1.bed_code AS bedCode,
  12178. t1.LEVEL AS LEVEL,
  12179. t1.grade_type AS gradeType,
  12180. t1.score_res AS scoreRes,
  12181. t1.scoreBn,
  12182. t1.NAME AS NAME,
  12183. t1.sex AS sex,
  12184. t1.beh_dept_id AS behDeptId,
  12185. t1.beh_dept_name AS behDeptName,
  12186. t1.doctor_id AS doctorId,
  12187. t1.doctor_name AS doctorName,
  12188. t1.beh_doctor_id AS behDoctorId,
  12189. t1.beh_doctor_name AS behDoctorName,
  12190. t1.director_doctor_id AS directorDoctorId,
  12191. t1.director_doctor_name AS directorDoctorName,
  12192. t1.birthday AS birthday,
  12193. t1.behospital_date AS behospitalDate,
  12194. t1.leave_hospital_date AS leaveHospitalDate,
  12195. t1.placefile_date AS placefileDate,
  12196. t1.gmt_create AS gradeTime,
  12197. t1.diagnose,
  12198. t1.ward_name AS wardName,
  12199. t2.age,
  12200. t1.file_code AS fileCode,
  12201. t1.checkStatus,
  12202. t1.mrStatus,
  12203. t1.chName,
  12204. t1.mrName,
  12205. t1.chTime,
  12206. t1.mrTime
  12207. FROM
  12208. (SELECT
  12209. be.*,
  12210. b.LEVEL,
  12211. b.grade_type,
  12212. b.score_res,
  12213. b.gmt_create,
  12214. ifnull(mci.status,0) AS checkStatus,
  12215. ifnull(hm_mci.status,0) AS mrStatus,
  12216. mci.check_name as chName,
  12217. hm_mci.check_name as mrName,
  12218. mci.gmt_create as chTime,
  12219. hm_mci.gmt_create as mrTime
  12220. FROM
  12221. (
  12222. SELECT DISTINCT
  12223. a.hospital_id,
  12224. a.behospital_code,
  12225. a.bed_code,
  12226. a.file_code,
  12227. c.score_res as scoreBn,
  12228. c.cases_id,
  12229. a.NAME,
  12230. a.sex,
  12231. a.beh_dept_id,
  12232. a.beh_dept_name,
  12233. a.birthday,
  12234. a.behospital_date,
  12235. a.leave_hospital_date,
  12236. a.doctor_id,
  12237. a.doctor_name,
  12238. a.beh_doctor_id,
  12239. a.beh_doctor_name,
  12240. a.director_doctor_id,
  12241. a.director_doctor_name,
  12242. a.diagnose,
  12243. a.placefile_date,
  12244. a.ward_name
  12245. FROM
  12246. med_behospital_info a,
  12247. med_qcresult_cases c
  12248. WHERE
  12249. a.is_deleted = 'N'
  12250. AND c.is_deleted = 'N'
  12251. AND a.hospital_id = c.hospital_id
  12252. AND a.behospital_code = c.behospital_code
  12253. AND a.qc_type_id != 0
  12254. AND c.cases_id = 243
  12255. <if test="qcResultShortPageVO.titleName != null ">
  12256. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12257. AND c.`level`='不合格'
  12258. </if>
  12259. <if test="qcResultShortPageVO.titleName == '合格数'">
  12260. AND c.`level`='合格'
  12261. </if>
  12262. </if>
  12263. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12264. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12265. </if>
  12266. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12267. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12268. </if>
  12269. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12270. <if test="qcResultShortPageVO.startDate != null ">
  12271. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12272. </if>
  12273. <if test="qcResultShortPageVO.endDate != null ">
  12274. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12275. </if>
  12276. </if>
  12277. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12278. <if test="qcResultShortPageVO.startDate != null ">
  12279. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12280. </if>
  12281. <if test="qcResultShortPageVO.endDate != null">
  12282. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12283. </if>
  12284. </if>
  12285. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12286. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12287. </if>
  12288. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12289. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12290. </if>
  12291. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12292. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12293. </if>
  12294. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12295. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12296. </if>
  12297. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12298. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12299. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12300. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12301. </if>
  12302. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12303. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12304. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12305. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12306. </if>
  12307. )be
  12308. left join med_check_info mci
  12309. on mci.is_deleted = 'N'
  12310. and mci.check_type = 0
  12311. and be.hospital_id = mci.hospital_id
  12312. and be.behospital_code = mci.behospital_code
  12313. left join med_check_info hm_mci
  12314. on hm_mci.is_deleted = 'N'
  12315. and hm_mci.check_type = 1
  12316. and be.hospital_id = hm_mci.hospital_id
  12317. and be.behospital_code = hm_mci.behospital_code
  12318. left join med_qcresult_info b
  12319. on b.is_deleted = 'N'
  12320. AND be.hospital_id = b.hospital_id
  12321. AND be.behospital_code = b.behospital_code
  12322. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12323. AND b.`level` = #{qcResultPageVO.level}
  12324. </if>
  12325. left join qc_cases_entry d
  12326. on d.is_deleted = 'N'
  12327. AND be.cases_id = d.cases_id
  12328. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12329. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12330. </if>
  12331. <if test="qcResultShortPageVO.casesEntryId != null ">
  12332. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12333. </if>
  12334. <if test="qcResultShortPageVO.ruleType != null">
  12335. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12336. </if>
  12337. ) t1
  12338. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12339. AND t1.behospital_code = t2.behospital_code
  12340. AND t2.is_deleted = 'N'
  12341. ) t
  12342. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12343. AND t.hospitalId = qi.hospital_id
  12344. AND t.behospitalCode = qi.behospital_code
  12345. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12346. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12347. AND t.hospitalId = qd.hospital_id
  12348. AND t.behospitalCode = qd.behospital_code
  12349. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12350. AND qd.cases_id = qc.id
  12351. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12352. AND qd.cases_id = qce.cases_id
  12353. AND qd.cases_entry_id = qce.id
  12354. </if>
  12355. where 1=1
  12356. <if test="qcResultShortPageVO.checkStatus != null">
  12357. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12358. </if>
  12359. <if test="qcResultShortPageVO.mrStatus != null">
  12360. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12361. </if>
  12362. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12363. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12364. </if>
  12365. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12366. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12367. </if>
  12368. <if test="qcResultShortPageVO.chTimeStart != null ">
  12369. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12370. </if>
  12371. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12372. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12373. </if>
  12374. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12375. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12376. </if>
  12377. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12378. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12379. </if>
  12380. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12381. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12382. </if>
  12383. <if test="qcResultShortPageVO.casesEntryId != null ">
  12384. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12385. </if>
  12386. )f1,
  12387. (SELECT
  12388. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12389. t.behDeptId,
  12390. t.behDeptName
  12391. FROM
  12392. (SELECT DISTINCT
  12393. t1.hospital_id AS hospitalId,
  12394. t1.behospital_code AS behospitalCode,
  12395. t1.bed_code AS bedCode,
  12396. t1.LEVEL AS LEVEL,
  12397. t1.grade_type AS gradeType,
  12398. t1.score_res AS scoreRes,
  12399. t1.NAME AS NAME,
  12400. t1.sex AS sex,
  12401. t1.beh_dept_id AS behDeptId,
  12402. t1.beh_dept_name AS behDeptName,
  12403. t1.doctor_id AS doctorId,
  12404. t1.doctor_name AS doctorName,
  12405. t1.beh_doctor_id AS behDoctorId,
  12406. t1.beh_doctor_name AS behDoctorName,
  12407. t1.director_doctor_id AS directorDoctorId,
  12408. t1.director_doctor_name AS directorDoctorName,
  12409. t1.birthday AS birthday,
  12410. t1.behospital_date AS behospitalDate,
  12411. t1.leave_hospital_date AS leaveHospitalDate,
  12412. t1.placefile_date AS placefileDate,
  12413. t1.gmt_create AS gradeTime,
  12414. t1.diagnose,
  12415. t1.ward_name AS wardName,
  12416. t2.age,
  12417. t1.file_code AS fileCode,
  12418. t1.checkStatus,
  12419. t1.mrStatus,
  12420. t1.chName,
  12421. t1.mrName,
  12422. t1.chTime,
  12423. t1.mrTime
  12424. FROM
  12425. (SELECT
  12426. be.*,
  12427. b.grade_type,
  12428. b.score_res,
  12429. b.gmt_create,
  12430. b.LEVEL,
  12431. ifnull(mci.status,0) AS checkStatus,
  12432. ifnull(hm_mci.status,0) AS mrStatus,
  12433. mci.check_name as chName,
  12434. hm_mci.check_name as mrName,
  12435. mci.gmt_create as chTime,
  12436. hm_mci.gmt_create as mrTime
  12437. FROM
  12438. (
  12439. SELECT DISTINCT
  12440. a.hospital_id,
  12441. a.behospital_code,
  12442. a.bed_code,
  12443. a.file_code,
  12444. a.NAME,
  12445. a.sex,
  12446. a.beh_dept_id,
  12447. a.beh_dept_name,
  12448. a.birthday,
  12449. a.behospital_date,
  12450. a.leave_hospital_date,
  12451. a.doctor_id,
  12452. a.doctor_name,
  12453. a.beh_doctor_id,
  12454. a.beh_doctor_name,
  12455. a.director_doctor_id,
  12456. a.director_doctor_name,
  12457. a.diagnose,
  12458. a.placefile_date,
  12459. a.ward_name
  12460. FROM
  12461. med_behospital_info a,
  12462. med_qcresult_detail k,
  12463. med_qcresult_cases c,
  12464. qc_cases_entry d
  12465. WHERE
  12466. a.is_deleted = 'N'
  12467. AND c.is_deleted = 'N'
  12468. AND d.is_deleted = 'N'
  12469. AND a.hospital_id = c.hospital_id
  12470. AND a.behospital_code = c.behospital_code
  12471. AND c.cases_id = d.cases_id
  12472. AND a.hospital_id = k.hospital_id
  12473. AND a.behospital_code = k.behospital_code
  12474. AND c.cases_id = k.cases_id
  12475. AND k.cases_id = d.cases_id
  12476. AND k.cases_entry_id = d.id
  12477. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12478. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12479. <!-- AND c.`level`='不合格'-->
  12480. <!-- </if>-->
  12481. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12482. <!-- AND c.`level`='合格'-->
  12483. <!-- </if>-->
  12484. <!-- </if>-->
  12485. AND a.qc_type_id != 0
  12486. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12487. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12488. </if>
  12489. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12490. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12491. </if>
  12492. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12493. <if test="qcResultShortPageVO.startDate != null ">
  12494. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12495. </if>
  12496. <if test="qcResultShortPageVO.endDate != null ">
  12497. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12498. </if>
  12499. </if>
  12500. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12501. <if test="qcResultShortPageVO.startDate != null ">
  12502. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12503. </if>
  12504. <if test="qcResultShortPageVO.endDate != null">
  12505. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12506. </if>
  12507. </if>
  12508. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12509. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12510. </if>
  12511. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12512. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12513. </if>
  12514. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12515. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12516. </if>
  12517. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12518. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12519. </if>
  12520. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12521. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12522. </if>
  12523. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12524. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12525. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12526. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12527. </if>
  12528. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12529. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12530. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12531. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12532. </if>
  12533. <if test="qcResultShortPageVO.casesEntryId != null ">
  12534. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12535. </if>
  12536. <if test="qcResultShortPageVO.ruleType != null">
  12537. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12538. </if>
  12539. )be
  12540. left join med_check_info mci
  12541. on mci.is_deleted = 'N'
  12542. and mci.check_type = 0
  12543. and be.hospital_id = mci.hospital_id
  12544. and be.behospital_code = mci.behospital_code
  12545. left join med_check_info hm_mci
  12546. on hm_mci.is_deleted = 'N'
  12547. and hm_mci.check_type = 1
  12548. and be.hospital_id = hm_mci.hospital_id
  12549. and be.behospital_code = hm_mci.behospital_code
  12550. left join med_qcresult_info b
  12551. on b.is_deleted = 'N'
  12552. AND be.hospital_id = b.hospital_id
  12553. AND be.behospital_code = b.behospital_code
  12554. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12555. AND b.`level` = #{qcResultPageVO.level}
  12556. </if>
  12557. ) t1
  12558. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12559. AND t1.behospital_code = t2.behospital_code
  12560. AND t2.is_deleted = 'N'
  12561. ) t
  12562. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12563. AND t.hospitalId = qi.hospital_id
  12564. AND t.behospitalCode = qi.behospital_code
  12565. where 1=1
  12566. <if test="qcResultShortPageVO.checkStatus != null">
  12567. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12568. </if>
  12569. <if test="qcResultShortPageVO.mrStatus != null">
  12570. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12571. </if>
  12572. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12573. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12574. </if>
  12575. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12576. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12577. </if>
  12578. <if test="qcResultShortPageVO.chTimeStart != null ">
  12579. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12580. </if>
  12581. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12582. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12583. </if>
  12584. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12585. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12586. </if>
  12587. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12588. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12589. </if>
  12590. GROUP BY
  12591. t.behDeptId,
  12592. t.behDeptName
  12593. )f2
  12594. WHERE
  12595. f1.behDeptId = f2.behDeptId
  12596. AND f1.behDeptName = f2.behDeptName
  12597. </select>
  12598. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  12599. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  12600. SELECT
  12601. f1.behDeptId,
  12602. f1.behDeptName,
  12603. f1.doctorName,
  12604. f1.patName,
  12605. f1.behospitalCode,
  12606. f1.hospitalId,
  12607. f1.wardName,
  12608. f1.medoupName,
  12609. f1.behospitalDate,
  12610. f1.leaveHospitalDate,
  12611. f1.score,
  12612. f1.scoreBn,
  12613. f2.avgScore,
  12614. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12615. f1.msg,
  12616. f1.caseName,
  12617. </if>
  12618. f1.checkStatus,
  12619. f1.mrStatus,
  12620. f1.chName,
  12621. f1.mrName,
  12622. f1.chTime,
  12623. f1.mrTime
  12624. FROM
  12625. (SELECT
  12626. t.doctorName AS doctorName,
  12627. t.doctorId,
  12628. t.`name` AS patName,
  12629. t.wardName,
  12630. t.behospitalCode AS behospitalCode,
  12631. t.behospitalDate AS behospitalDate,
  12632. t.leaveHospitalDate AS leaveHospitalDate,
  12633. qi.score_res AS score,
  12634. t.scoreBn,
  12635. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12636. qd.msg AS msg,
  12637. qc.NAME AS caseName,
  12638. </if>
  12639. t.behDeptId,
  12640. t.behDeptName,
  12641. t.hospitalId,
  12642. t.checkStatus,
  12643. t.mrStatus,
  12644. t.chName,
  12645. t.mrName,
  12646. t.chTime,
  12647. t.mrTime,
  12648. t3.name as medoupName
  12649. FROM
  12650. (SELECT DISTINCT
  12651. t1.hospital_id AS hospitalId,
  12652. t1.behospital_code AS behospitalCode,
  12653. t1.bed_code AS bedCode,
  12654. t1.LEVEL AS LEVEL,
  12655. t1.grade_type AS gradeType,
  12656. t1.score_res AS scoreRes,
  12657. t1.scoreBn,
  12658. t1.NAME AS NAME,
  12659. t1.sex AS sex,
  12660. t1.beh_dept_id AS behDeptId,
  12661. t1.beh_dept_name AS behDeptName,
  12662. t1.doctor_id AS doctorId,
  12663. t1.doctor_name AS doctorName,
  12664. t1.beh_doctor_id AS behDoctorId,
  12665. t1.beh_doctor_name AS behDoctorName,
  12666. t1.director_doctor_id AS directorDoctorId,
  12667. t1.director_doctor_name AS directorDoctorName,
  12668. t1.birthday AS birthday,
  12669. t1.behospital_date AS behospitalDate,
  12670. t1.leave_hospital_date AS leaveHospitalDate,
  12671. t1.placefile_date AS placefileDate,
  12672. t1.gmt_create AS gradeTime,
  12673. t1.diagnose,
  12674. t1.ward_name AS wardName,
  12675. t2.age,
  12676. t1.file_code AS fileCode,
  12677. t1.checkStatus,
  12678. t1.mrStatus,
  12679. t1.chName,
  12680. t1.mrName,
  12681. t1.chTime,
  12682. t1.mrTime
  12683. FROM
  12684. (SELECT
  12685. be.*,
  12686. b.LEVEL,
  12687. b.grade_type,
  12688. b.score_res,
  12689. b.gmt_create,
  12690. ifnull(mci.status,0) AS checkStatus,
  12691. ifnull(hm_mci.status,0) AS mrStatus,
  12692. mci.check_name as chName,
  12693. hm_mci.check_name as mrName,
  12694. mci.gmt_create as chTime,
  12695. hm_mci.gmt_create as mrTime
  12696. FROM
  12697. (
  12698. SELECT DISTINCT
  12699. a.hospital_id,
  12700. a.behospital_code,
  12701. a.bed_code,
  12702. a.file_code,
  12703. c.score_res as scoreBn,
  12704. c.cases_id,
  12705. a.NAME,
  12706. a.sex,
  12707. a.beh_dept_id,
  12708. a.beh_dept_name,
  12709. a.birthday,
  12710. a.behospital_date,
  12711. a.leave_hospital_date,
  12712. a.doctor_id,
  12713. a.doctor_name,
  12714. a.beh_doctor_id,
  12715. a.beh_doctor_name,
  12716. a.director_doctor_id,
  12717. a.director_doctor_name,
  12718. a.diagnose,
  12719. a.placefile_date,
  12720. a.ward_name
  12721. FROM
  12722. med_behospital_info a,
  12723. sys_user_dept b,
  12724. med_qcresult_cases c
  12725. WHERE
  12726. a.is_deleted = 'N'
  12727. AND b.is_deleted = 'N'
  12728. AND c.is_deleted = 'N'
  12729. AND a.hospital_id = b.hospital_id
  12730. AND a.beh_dept_id = b.dept_id
  12731. AND a.hospital_id = c.hospital_id
  12732. AND a.behospital_code = c.behospital_code
  12733. AND a.qc_type_id != 0
  12734. AND c.cases_id = 243
  12735. <if test="qcResultShortPageVO.userId!=null">
  12736. AND b.user_id = #{qcResultShortPageVO.userId}
  12737. </if>
  12738. <if test="qcResultShortPageVO.titleName != null ">
  12739. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12740. AND c.`level`='不合格'
  12741. </if>
  12742. <if test="qcResultShortPageVO.titleName == '合格数'">
  12743. AND c.`level`='合格'
  12744. </if>
  12745. </if>
  12746. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12747. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12748. </if>
  12749. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12750. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12751. </if>
  12752. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12753. <if test="qcResultShortPageVO.startDate != null ">
  12754. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12755. </if>
  12756. <if test="qcResultShortPageVO.endDate != null ">
  12757. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12758. </if>
  12759. </if>
  12760. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12761. <if test="qcResultShortPageVO.startDate != null ">
  12762. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12763. </if>
  12764. <if test="qcResultShortPageVO.endDate != null">
  12765. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12766. </if>
  12767. </if>
  12768. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12769. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12770. </if>
  12771. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  12772. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  12773. </if>
  12774. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12775. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12776. </if>
  12777. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  12778. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  12779. </if>
  12780. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12781. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12782. </if>
  12783. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12784. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12785. </if>
  12786. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12787. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  12788. </if>
  12789. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12790. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12791. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12792. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12793. </if>
  12794. )be
  12795. left join med_check_info mci
  12796. on mci.is_deleted = 'N'
  12797. and mci.check_type = 0
  12798. and be.hospital_id = mci.hospital_id
  12799. and be.behospital_code = mci.behospital_code
  12800. left join med_check_info hm_mci
  12801. on hm_mci.is_deleted = 'N'
  12802. and hm_mci.check_type = 1
  12803. and be.hospital_id = hm_mci.hospital_id
  12804. and be.behospital_code = hm_mci.behospital_code
  12805. left join med_qcresult_info b
  12806. on b.is_deleted = 'N'
  12807. AND be.hospital_id = b.hospital_id
  12808. AND be.behospital_code = b.behospital_code
  12809. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12810. AND b.`level` = #{qcResultPageVO.level}
  12811. </if>
  12812. left join qc_cases_entry d
  12813. on d.is_deleted = 'N'
  12814. AND be.cases_id = d.cases_id
  12815. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12816. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12817. </if>
  12818. <if test="qcResultShortPageVO.casesEntryId != null ">
  12819. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12820. </if>
  12821. <if test="qcResultShortPageVO.ruleType != null">
  12822. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12823. </if>
  12824. ) t1
  12825. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12826. AND t1.behospital_code = t2.behospital_code
  12827. AND t2.is_deleted = 'N'
  12828. ) t
  12829. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12830. AND t.hospitalId = qi.hospital_id
  12831. AND t.behospitalCode = qi.behospital_code
  12832. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  12833. AND t.hospitalId = t2.hospital_id
  12834. AND t2.is_deleted = 'N'
  12835. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  12836. AND t3.is_deleted = 'N'
  12837. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12838. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12839. AND t.hospitalId = qd.hospital_id
  12840. AND t.behospitalCode = qd.behospital_code
  12841. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12842. AND qd.cases_id = qc.id
  12843. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12844. AND qd.cases_id = qce.cases_id
  12845. AND qd.cases_entry_id = qce.id
  12846. </if>
  12847. where 1=1
  12848. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  12849. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  12850. </if>
  12851. <if test="qcResultShortPageVO.checkStatus != null">
  12852. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12853. </if>
  12854. <if test="qcResultShortPageVO.mrStatus != null">
  12855. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12856. </if>
  12857. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12858. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12859. </if>
  12860. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12861. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12862. </if>
  12863. <if test="qcResultShortPageVO.chTimeStart != null ">
  12864. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12865. </if>
  12866. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12867. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12868. </if>
  12869. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12870. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12871. </if>
  12872. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12873. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12874. </if>
  12875. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12876. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12877. </if>
  12878. <if test="qcResultShortPageVO.casesEntryId != null ">
  12879. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12880. </if>
  12881. )f1,
  12882. (SELECT
  12883. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12884. t.doctorId,
  12885. t.doctorName
  12886. FROM
  12887. (SELECT DISTINCT
  12888. t1.hospital_id AS hospitalId,
  12889. t1.behospital_code AS behospitalCode,
  12890. t1.bed_code AS bedCode,
  12891. t1.LEVEL AS LEVEL,
  12892. t1.grade_type AS gradeType,
  12893. t1.score_res AS scoreRes,
  12894. t1.NAME AS NAME,
  12895. t1.sex AS sex,
  12896. t1.beh_dept_id AS behDeptId,
  12897. t1.beh_dept_name AS behDeptName,
  12898. t1.doctor_id AS doctorId,
  12899. t1.doctor_name AS doctorName,
  12900. t1.beh_doctor_id AS behDoctorId,
  12901. t1.beh_doctor_name AS behDoctorName,
  12902. t1.director_doctor_id AS directorDoctorId,
  12903. t1.director_doctor_name AS directorDoctorName,
  12904. t1.birthday AS birthday,
  12905. t1.behospital_date AS behospitalDate,
  12906. t1.leave_hospital_date AS leaveHospitalDate,
  12907. t1.placefile_date AS placefileDate,
  12908. t1.gmt_create AS gradeTime,
  12909. t1.diagnose,
  12910. t1.ward_name AS wardName,
  12911. t2.age,
  12912. t1.file_code AS fileCode,
  12913. t1.checkStatus,
  12914. t1.mrStatus,
  12915. t1.chName,
  12916. t1.mrName,
  12917. t1.chTime,
  12918. t1.mrTime
  12919. FROM
  12920. (SELECT
  12921. be.*,
  12922. b.grade_type,
  12923. b.score_res,
  12924. b.gmt_create,
  12925. b.LEVEL,
  12926. ifnull(mci.status,0) AS checkStatus,
  12927. ifnull(hm_mci.status,0) AS mrStatus,
  12928. mci.check_name as chName,
  12929. hm_mci.check_name as mrName,
  12930. mci.gmt_create as chTime,
  12931. hm_mci.gmt_create as mrTime
  12932. FROM
  12933. (
  12934. SELECT DISTINCT
  12935. a.hospital_id,
  12936. a.behospital_code,
  12937. a.bed_code,
  12938. a.file_code,
  12939. a.NAME,
  12940. a.sex,
  12941. a.beh_dept_id,
  12942. a.beh_dept_name,
  12943. a.birthday,
  12944. a.behospital_date,
  12945. a.leave_hospital_date,
  12946. a.doctor_id,
  12947. a.doctor_name,
  12948. a.beh_doctor_id,
  12949. a.beh_doctor_name,
  12950. a.director_doctor_id,
  12951. a.director_doctor_name,
  12952. a.diagnose,
  12953. a.placefile_date,
  12954. a.ward_name
  12955. FROM
  12956. med_behospital_info a,
  12957. med_qcresult_detail k,
  12958. sys_user_dept b,
  12959. med_qcresult_cases c,
  12960. qc_cases_entry d
  12961. WHERE
  12962. a.is_deleted = 'N'
  12963. AND b.is_deleted = 'N'
  12964. AND c.is_deleted = 'N'
  12965. AND d.is_deleted = 'N'
  12966. AND a.hospital_id = b.hospital_id
  12967. AND a.hospital_id = c.hospital_id
  12968. AND a.behospital_code = c.behospital_code
  12969. AND a.beh_dept_id = b.dept_id
  12970. AND c.cases_id = d.cases_id
  12971. AND a.hospital_id = k.hospital_id
  12972. AND a.behospital_code = k.behospital_code
  12973. AND c.cases_id = k.cases_id
  12974. AND k.cases_id = d.cases_id
  12975. AND k.cases_entry_id = d.id
  12976. AND a.qc_type_id != 0
  12977. <if test="qcResultShortPageVO.userId!=null">
  12978. AND b.user_id = #{qcResultShortPageVO.userId}
  12979. </if>
  12980. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12981. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12982. </if>
  12983. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12984. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12985. </if>
  12986. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12987. <if test="qcResultShortPageVO.startDate != null ">
  12988. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12989. </if>
  12990. <if test="qcResultShortPageVO.endDate != null ">
  12991. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12992. </if>
  12993. </if>
  12994. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12995. <if test="qcResultShortPageVO.startDate != null ">
  12996. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12997. </if>
  12998. <if test="qcResultShortPageVO.endDate != null">
  12999. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13000. </if>
  13001. </if>
  13002. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13003. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13004. </if>
  13005. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13006. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13007. </if>
  13008. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13009. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13010. </if>
  13011. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13012. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13013. </if>
  13014. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13015. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13016. </if>
  13017. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13018. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13019. </if>
  13020. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13021. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13022. </if>
  13023. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13024. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13025. </if>
  13026. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13027. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13028. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13029. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13030. </if>
  13031. <if test="qcResultShortPageVO.casesEntryId != null ">
  13032. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13033. </if>
  13034. <if test="qcResultShortPageVO.ruleType != null">
  13035. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13036. </if>
  13037. )be
  13038. left join med_check_info mci
  13039. on mci.is_deleted = 'N'
  13040. and mci.check_type = 0
  13041. and be.hospital_id = mci.hospital_id
  13042. and be.behospital_code = mci.behospital_code
  13043. left join med_check_info hm_mci
  13044. on hm_mci.is_deleted = 'N'
  13045. and hm_mci.check_type = 1
  13046. and be.hospital_id = hm_mci.hospital_id
  13047. and be.behospital_code = hm_mci.behospital_code
  13048. left join med_qcresult_info b
  13049. on b.is_deleted = 'N'
  13050. AND be.hospital_id = b.hospital_id
  13051. AND be.behospital_code = b.behospital_code
  13052. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13053. AND b.`level` = #{qcResultPageVO.level}
  13054. </if>
  13055. ) t1
  13056. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13057. AND t1.behospital_code = t2.behospital_code
  13058. AND t2.is_deleted = 'N'
  13059. ) t
  13060. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13061. AND t.hospitalId = qi.hospital_id
  13062. AND t.behospitalCode = qi.behospital_code
  13063. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  13064. AND t.hospitalId = t2.hospital_id
  13065. AND t2.is_deleted = 'N'
  13066. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  13067. AND t3.is_deleted = 'N'
  13068. where 1=1
  13069. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  13070. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  13071. </if>
  13072. <if test="qcResultShortPageVO.checkStatus != null">
  13073. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13074. </if>
  13075. <if test="qcResultShortPageVO.mrStatus != null">
  13076. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13077. </if>
  13078. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13079. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13080. </if>
  13081. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13082. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13083. </if>
  13084. <if test="qcResultShortPageVO.chTimeStart != null ">
  13085. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13086. </if>
  13087. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13088. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13089. </if>
  13090. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13091. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13092. </if>
  13093. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13094. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13095. </if>
  13096. GROUP BY
  13097. t.behDeptId,
  13098. t.behDeptName,
  13099. t.doctorId,
  13100. t.doctorName
  13101. )f2
  13102. WHERE
  13103. f1.doctorId = f2.doctorId
  13104. AND f1.doctorName = f2.doctorName
  13105. </select>
  13106. <!-- 未整改病历缺陷评分详情页导出-->
  13107. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  13108. SELECT
  13109. f1.behDeptId,
  13110. f1.behDeptName,
  13111. f1.doctorName,
  13112. f1.patName,
  13113. f1.behospitalCode,
  13114. f1.hospitalId,
  13115. f1.behospitalDate,
  13116. f1.leaveHospitalDate,
  13117. f1.score,
  13118. f1.scoreBn,
  13119. f2.avgScore,
  13120. f1.msg,
  13121. f1.caseName,
  13122. f1.checkStatus,
  13123. f1.mrStatus,
  13124. f1.chName,
  13125. f1.mrName,
  13126. f1.chTime,
  13127. f1.mrTime
  13128. FROM
  13129. (SELECT
  13130. t.doctorName,
  13131. t.`name` AS patName,
  13132. t.behospitalCode AS behospitalCode,
  13133. t.behospitalDate AS behospitalDate,
  13134. t.leaveHospitalDate AS leaveHospitalDate,
  13135. qi.score_res AS score,
  13136. t.scoreBn,
  13137. qd.msg AS msg,
  13138. qc.NAME AS caseName,
  13139. t.behDeptId,
  13140. t.behDeptName,
  13141. t.hospitalId,
  13142. t.checkStatus,
  13143. t.mrStatus,
  13144. t.chName,
  13145. t.mrName,
  13146. t.chTime,
  13147. t.mrTime
  13148. FROM
  13149. (SELECT DISTINCT
  13150. t1.hospital_id AS hospitalId,
  13151. t1.behospital_code AS behospitalCode,
  13152. t1.bed_code AS bedCode,
  13153. t1.LEVEL AS LEVEL,
  13154. t1.grade_type AS gradeType,
  13155. t1.score_res AS scoreRes,
  13156. t1.scoreBn,
  13157. t1.NAME AS NAME,
  13158. t1.sex AS sex,
  13159. t1.beh_dept_id AS behDeptId,
  13160. t1.beh_dept_name AS behDeptName,
  13161. t1.doctor_id AS doctorId,
  13162. t1.doctor_name AS doctorName,
  13163. t1.beh_doctor_id AS behDoctorId,
  13164. t1.beh_doctor_name AS behDoctorName,
  13165. t1.director_doctor_id AS directorDoctorId,
  13166. t1.director_doctor_name AS directorDoctorName,
  13167. t1.birthday AS birthday,
  13168. t1.behospital_date AS behospitalDate,
  13169. t1.leave_hospital_date AS leaveHospitalDate,
  13170. t1.placefile_date AS placefileDate,
  13171. t1.gmt_create AS gradeTime,
  13172. t1.diagnose,
  13173. t1.ward_name AS wardName,
  13174. t2.age,
  13175. t1.file_code AS fileCode,
  13176. t1.checkStatus,
  13177. t1.mrStatus,
  13178. t1.chName,
  13179. t1.mrName,
  13180. t1.chTime,
  13181. t1.mrTime
  13182. FROM
  13183. (SELECT
  13184. be.*,
  13185. ifnull(mci.status,0) AS checkStatus,
  13186. ifnull(hm_mci.status,0) AS mrStatus,
  13187. mci.check_name as chName,
  13188. e.score_res as scoreBn,
  13189. hm_mci.check_name as mrName,
  13190. mci.gmt_create as chTime,
  13191. hm_mci.gmt_create as mrTime
  13192. FROM
  13193. (
  13194. SELECT DISTINCT
  13195. a.hospital_id,
  13196. a.behospital_code,
  13197. a.bed_code,
  13198. a.file_code,
  13199. b.LEVEL,
  13200. b.grade_type,
  13201. b.score_res,
  13202. a.NAME,
  13203. a.sex,
  13204. a.beh_dept_id,
  13205. a.beh_dept_name,
  13206. a.birthday,
  13207. a.behospital_date,
  13208. a.leave_hospital_date,
  13209. a.doctor_id,
  13210. a.doctor_name,
  13211. a.beh_doctor_id,
  13212. a.beh_doctor_name,
  13213. a.director_doctor_id,
  13214. a.director_doctor_name,
  13215. a.diagnose,
  13216. a.placefile_date,
  13217. a.ward_name,
  13218. b.gmt_create
  13219. FROM
  13220. med_behospital_info a,
  13221. med_qcresult_info b,
  13222. med_qcresult_detail c,
  13223. qc_cases_entry d
  13224. WHERE
  13225. a.is_deleted = 'N'
  13226. AND b.is_deleted = 'N'
  13227. AND c.is_deleted = 'N'
  13228. AND d.is_deleted = 'N'
  13229. AND a.hospital_id = b.hospital_id
  13230. AND a.hospital_id = c.hospital_id
  13231. AND a.behospital_code = b.behospital_code
  13232. AND a.behospital_code = c.behospital_code
  13233. AND c.cases_id = d.cases_id
  13234. AND c.cases_entry_id = d.id
  13235. AND a.qc_type_id != 0
  13236. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13237. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13238. </if>
  13239. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13240. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13241. </if>
  13242. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13243. <if test="qcResultShortPageVO.startDate != null ">
  13244. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13245. </if>
  13246. <if test="qcResultShortPageVO.endDate != null ">
  13247. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13248. </if>
  13249. </if>
  13250. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13251. <if test="qcResultShortPageVO.startDate != null ">
  13252. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13253. </if>
  13254. <if test="qcResultShortPageVO.endDate != null">
  13255. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13256. </if>
  13257. </if>
  13258. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13259. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13260. </if>
  13261. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13262. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13263. </if>
  13264. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13265. AND b.`level` = #{qcResultShortPageVO.level}
  13266. </if>
  13267. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13268. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13269. </if>
  13270. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13271. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13272. </if>
  13273. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13274. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13275. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13276. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13277. </if>
  13278. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13279. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13280. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13281. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13282. </if>
  13283. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13284. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13285. </if>
  13286. <if test="qcResultShortPageVO.casesEntryId != null ">
  13287. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13288. </if>
  13289. <if test="qcResultShortPageVO.isReject != null">
  13290. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13291. </if>
  13292. <if test="qcResultShortPageVO.ruleType != null">
  13293. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13294. </if>
  13295. )be
  13296. left join med_check_info mci
  13297. on mci.is_deleted = 'N'
  13298. and mci.check_type = 0
  13299. and be.hospital_id = mci.hospital_id
  13300. and be.behospital_code = mci.behospital_code
  13301. left join med_check_info hm_mci
  13302. on hm_mci.is_deleted = 'N'
  13303. and hm_mci.check_type = 1
  13304. and be.hospital_id = hm_mci.hospital_id
  13305. and be.behospital_code = hm_mci.behospital_code
  13306. LEFT JOIN med_qcresult_cases e
  13307. on be.behospital_code = e.behospital_code
  13308. and be.hospital_id = e.hospital_id
  13309. AND e.is_deleted = 'N'
  13310. and e.cases_id = 243
  13311. ) t1
  13312. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13313. AND t1.behospital_code = t2.behospital_code
  13314. AND t2.is_deleted = 'N'
  13315. ) t
  13316. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13317. AND t.hospitalId = qi.hospital_id
  13318. AND t.behospitalCode = qi.behospital_code
  13319. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13320. AND t.hospitalId = qd.hospital_id
  13321. AND t.behospitalCode = qd.behospital_code
  13322. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13323. AND qd.cases_id = qc.id
  13324. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13325. AND qd.cases_id = qce.cases_id
  13326. AND qd.cases_entry_id = qce.id
  13327. where 1=1
  13328. <if test="qcResultShortPageVO.checkStatus != null">
  13329. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13330. </if>
  13331. <if test="qcResultShortPageVO.mrStatus != null">
  13332. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13333. </if>
  13334. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13335. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13336. </if>
  13337. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13338. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13339. </if>
  13340. <if test="qcResultShortPageVO.chTimeStart != null ">
  13341. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13342. </if>
  13343. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13344. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13345. </if>
  13346. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13347. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13348. </if>
  13349. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13350. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13351. </if>
  13352. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13353. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13354. </if>
  13355. <if test="qcResultShortPageVO.casesEntryId != null ">
  13356. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13357. </if>
  13358. )f1,
  13359. (SELECT
  13360. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13361. t.behDeptId,
  13362. t.behDeptName
  13363. FROM
  13364. (SELECT DISTINCT
  13365. t1.hospital_id AS hospitalId,
  13366. t1.behospital_code AS behospitalCode,
  13367. t1.bed_code AS bedCode,
  13368. t1.LEVEL AS LEVEL,
  13369. t1.grade_type AS gradeType,
  13370. t1.score_res AS scoreRes,
  13371. t1.NAME AS NAME,
  13372. t1.sex AS sex,
  13373. t1.beh_dept_id AS behDeptId,
  13374. t1.beh_dept_name AS behDeptName,
  13375. t1.doctor_id AS doctorId,
  13376. t1.doctor_name AS doctorName,
  13377. t1.beh_doctor_id AS behDoctorId,
  13378. t1.beh_doctor_name AS behDoctorName,
  13379. t1.director_doctor_id AS directorDoctorId,
  13380. t1.director_doctor_name AS directorDoctorName,
  13381. t1.birthday AS birthday,
  13382. t1.behospital_date AS behospitalDate,
  13383. t1.leave_hospital_date AS leaveHospitalDate,
  13384. t1.placefile_date AS placefileDate,
  13385. t1.gmt_create AS gradeTime,
  13386. t1.diagnose,
  13387. t1.ward_name AS wardName,
  13388. t2.age,
  13389. t1.file_code AS fileCode,
  13390. t1.checkStatus,
  13391. t1.mrStatus,
  13392. t1.chName,
  13393. t1.mrName,
  13394. t1.chTime,
  13395. t1.mrTime
  13396. FROM
  13397. (SELECT
  13398. be.*,
  13399. ifnull(mci.status,0) AS checkStatus,
  13400. ifnull(hm_mci.status,0) AS mrStatus,
  13401. mci.check_name as chName,
  13402. hm_mci.check_name as mrName,
  13403. mci.gmt_create as chTime,
  13404. hm_mci.gmt_create as mrTime
  13405. FROM
  13406. (
  13407. SELECT DISTINCT
  13408. a.hospital_id,
  13409. a.behospital_code,
  13410. a.bed_code,
  13411. a.file_code,
  13412. b.LEVEL,
  13413. b.grade_type,
  13414. b.score_res,
  13415. a.NAME,
  13416. a.sex,
  13417. a.beh_dept_id,
  13418. a.beh_dept_name,
  13419. a.birthday,
  13420. a.behospital_date,
  13421. a.leave_hospital_date,
  13422. a.doctor_id,
  13423. a.doctor_name,
  13424. a.beh_doctor_id,
  13425. a.beh_doctor_name,
  13426. a.director_doctor_id,
  13427. a.director_doctor_name,
  13428. a.diagnose,
  13429. a.placefile_date,
  13430. a.ward_name,
  13431. b.gmt_create
  13432. FROM
  13433. med_behospital_info a,
  13434. med_qcresult_info b,
  13435. med_qcresult_detail c,
  13436. qc_cases_entry d
  13437. WHERE
  13438. a.is_deleted = 'N'
  13439. AND b.is_deleted = 'N'
  13440. AND c.is_deleted = 'N'
  13441. AND d.is_deleted = 'N'
  13442. AND a.hospital_id = b.hospital_id
  13443. AND a.hospital_id = c.hospital_id
  13444. AND a.behospital_code = b.behospital_code
  13445. AND a.behospital_code = c.behospital_code
  13446. AND c.cases_id = d.cases_id
  13447. AND c.cases_entry_id = d.id
  13448. AND a.qc_type_id != 0
  13449. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13450. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13451. </if>
  13452. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13453. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13454. </if>
  13455. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13456. <if test="qcResultShortPageVO.startDate != null ">
  13457. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13458. </if>
  13459. <if test="qcResultShortPageVO.endDate != null ">
  13460. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13461. </if>
  13462. </if>
  13463. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13464. <if test="qcResultShortPageVO.startDate != null ">
  13465. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13466. </if>
  13467. <if test="qcResultShortPageVO.endDate != null">
  13468. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13469. </if>
  13470. </if>
  13471. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13472. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13473. </if>
  13474. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13475. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13476. </if>
  13477. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13478. AND b.`level` = #{qcResultShortPageVO.level}
  13479. </if>
  13480. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13481. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13482. </if>
  13483. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13484. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13485. </if>
  13486. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13487. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13488. </if>
  13489. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13490. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13491. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13492. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13493. </if>
  13494. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13495. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13496. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13497. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13498. </if>
  13499. <if test="qcResultShortPageVO.casesEntryId != null ">
  13500. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13501. </if>
  13502. <if test="qcResultShortPageVO.isReject != null">
  13503. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13504. </if>
  13505. <if test="qcResultShortPageVO.ruleType != null">
  13506. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13507. </if>
  13508. )be
  13509. left join med_check_info mci
  13510. on mci.is_deleted = 'N'
  13511. and mci.check_type = 0
  13512. and be.hospital_id = mci.hospital_id
  13513. and be.behospital_code = mci.behospital_code
  13514. left join med_check_info hm_mci
  13515. on hm_mci.is_deleted = 'N'
  13516. and hm_mci.check_type = 1
  13517. and be.hospital_id = hm_mci.hospital_id
  13518. and be.behospital_code = hm_mci.behospital_code
  13519. ) t1
  13520. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13521. AND t1.behospital_code = t2.behospital_code
  13522. AND t2.is_deleted = 'N'
  13523. ) t
  13524. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13525. AND t.hospitalId = qi.hospital_id
  13526. AND t.behospitalCode = qi.behospital_code
  13527. where 1=1
  13528. <if test="qcResultShortPageVO.checkStatus != null">
  13529. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13530. </if>
  13531. <if test="qcResultShortPageVO.mrStatus != null">
  13532. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13533. </if>
  13534. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13535. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13536. </if>
  13537. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13538. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13539. </if>
  13540. <if test="qcResultShortPageVO.chTimeStart != null ">
  13541. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13542. </if>
  13543. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13544. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13545. </if>
  13546. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13547. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13548. </if>
  13549. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13550. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13551. </if>
  13552. GROUP BY
  13553. t.behDeptId,
  13554. t.behDeptName
  13555. )f2
  13556. WHERE
  13557. f1.behDeptId = f2.behDeptId
  13558. AND f1.behDeptName = f2.behDeptName
  13559. </select>
  13560. <!-- 未整改病历缺陷评分详情页导出-科室-->
  13561. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  13562. SELECT
  13563. f1.behDeptId,
  13564. f1.behDeptName,
  13565. f1.wardName,
  13566. f1.medoupName,
  13567. f1.doctorName,
  13568. f1.patName,
  13569. f1.behospitalCode,
  13570. f1.hospitalId,
  13571. f1.behospitalDate,
  13572. f1.leaveHospitalDate,
  13573. f1.score,
  13574. f1.scoreBn,
  13575. f2.avgScore,
  13576. f1.msg,
  13577. f1.caseName,
  13578. f1.checkStatus,
  13579. f1.mrStatus,
  13580. f1.chName,
  13581. f1.mrName,
  13582. f1.chTime,
  13583. f1.mrTime
  13584. FROM
  13585. (SELECT
  13586. t.doctorName,
  13587. t.doctorId,
  13588. t.wardName,
  13589. t3.name as medoupName,
  13590. t.`name` AS patName,
  13591. t.behospitalCode AS behospitalCode,
  13592. t.behospitalDate AS behospitalDate,
  13593. t.leaveHospitalDate AS leaveHospitalDate,
  13594. qi.score_res AS score,
  13595. t.scoreBn,
  13596. qd.msg AS msg,
  13597. qc.NAME AS caseName,
  13598. t.behDeptId,
  13599. t.behDeptName,
  13600. t.hospitalId,
  13601. t.checkStatus,
  13602. t.mrStatus,
  13603. t.chName,
  13604. t.mrName,
  13605. t.chTime,
  13606. t.mrTime
  13607. FROM
  13608. (SELECT DISTINCT
  13609. t1.hospital_id AS hospitalId,
  13610. t1.behospital_code AS behospitalCode,
  13611. t1.bed_code AS bedCode,
  13612. t1.LEVEL AS LEVEL,
  13613. t1.grade_type AS gradeType,
  13614. t1.score_res AS scoreRes,
  13615. t1.scoreBn,
  13616. t1.NAME AS NAME,
  13617. t1.sex AS sex,
  13618. t1.beh_dept_id AS behDeptId,
  13619. t1.beh_dept_name AS behDeptName,
  13620. t1.doctor_id AS doctorId,
  13621. t1.doctor_name AS doctorName,
  13622. t1.beh_doctor_id AS behDoctorId,
  13623. t1.beh_doctor_name AS behDoctorName,
  13624. t1.director_doctor_id AS directorDoctorId,
  13625. t1.director_doctor_name AS directorDoctorName,
  13626. t1.birthday AS birthday,
  13627. t1.behospital_date AS behospitalDate,
  13628. t1.leave_hospital_date AS leaveHospitalDate,
  13629. t1.placefile_date AS placefileDate,
  13630. t1.gmt_create AS gradeTime,
  13631. t1.diagnose,
  13632. t1.ward_name AS wardName,
  13633. t2.age,
  13634. t1.file_code AS fileCode,
  13635. t1.checkStatus,
  13636. t1.mrStatus,
  13637. t1.chName,
  13638. t1.mrName,
  13639. t1.chTime,
  13640. t1.mrTime
  13641. FROM
  13642. (SELECT
  13643. be.*,
  13644. ifnull(mci.status,0) AS checkStatus,
  13645. ifnull(hm_mci.status,0) AS mrStatus,
  13646. mci.check_name as chName,
  13647. e.score_res as scoreBn,
  13648. hm_mci.check_name as mrName,
  13649. mci.gmt_create as chTime,
  13650. hm_mci.gmt_create as mrTime
  13651. FROM
  13652. (
  13653. SELECT DISTINCT
  13654. a.hospital_id,
  13655. a.behospital_code,
  13656. a.bed_code,
  13657. a.file_code,
  13658. b.LEVEL,
  13659. b.grade_type,
  13660. b.score_res,
  13661. a.NAME,
  13662. a.sex,
  13663. a.beh_dept_id,
  13664. a.beh_dept_name,
  13665. a.birthday,
  13666. a.behospital_date,
  13667. a.leave_hospital_date,
  13668. a.doctor_id,
  13669. a.doctor_name,
  13670. a.beh_doctor_id,
  13671. a.beh_doctor_name,
  13672. a.director_doctor_id,
  13673. a.director_doctor_name,
  13674. a.diagnose,
  13675. a.placefile_date,
  13676. a.ward_name,
  13677. b.gmt_create
  13678. FROM
  13679. med_behospital_info a,
  13680. med_qcresult_info b,
  13681. med_qcresult_detail c,
  13682. qc_cases_entry d,
  13683. sys_user_dept f
  13684. WHERE
  13685. a.is_deleted = 'N'
  13686. AND b.is_deleted = 'N'
  13687. AND c.is_deleted = 'N'
  13688. AND d.is_deleted = 'N'
  13689. AND f.is_deleted = 'N'
  13690. AND a.hospital_id = b.hospital_id
  13691. AND a.hospital_id = c.hospital_id
  13692. AND a.hospital_id = f.hospital_id
  13693. AND a.behospital_code = b.behospital_code
  13694. AND a.behospital_code = c.behospital_code
  13695. AND c.cases_id = d.cases_id
  13696. AND c.cases_entry_id = d.id
  13697. AND a.beh_dept_id = f.dept_id
  13698. AND a.qc_type_id != 0
  13699. <if test="qcResultShortPageVO.userId!=null">
  13700. AND f.user_id = #{qcResultShortPageVO.userId}
  13701. </if>
  13702. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13703. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13704. </if>
  13705. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13706. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13707. </if>
  13708. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13709. <if test="qcResultShortPageVO.startDate != null ">
  13710. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13711. </if>
  13712. <if test="qcResultShortPageVO.endDate != null ">
  13713. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13714. </if>
  13715. </if>
  13716. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13717. <if test="qcResultShortPageVO.startDate != null ">
  13718. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13719. </if>
  13720. <if test="qcResultShortPageVO.endDate != null">
  13721. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13722. </if>
  13723. </if>
  13724. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13725. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13726. </if>
  13727. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13728. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13729. </if>
  13730. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13731. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13732. </if>
  13733. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13734. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13735. </if>
  13736. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13737. AND b.`level` = #{qcResultShortPageVO.level}
  13738. </if>
  13739. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13740. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13741. </if>
  13742. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13743. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13744. </if>
  13745. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13746. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13747. </if>
  13748. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13749. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13750. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13751. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13752. </if>
  13753. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13754. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13755. </if>
  13756. <if test="qcResultShortPageVO.casesEntryId != null ">
  13757. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13758. </if>
  13759. <if test="qcResultShortPageVO.isReject != null">
  13760. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13761. </if>
  13762. <if test="qcResultShortPageVO.ruleType != null">
  13763. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13764. </if>
  13765. )be
  13766. left join med_check_info mci
  13767. on mci.is_deleted = 'N'
  13768. and mci.check_type = 0
  13769. and be.hospital_id = mci.hospital_id
  13770. and be.behospital_code = mci.behospital_code
  13771. left join med_check_info hm_mci
  13772. on hm_mci.is_deleted = 'N'
  13773. and hm_mci.check_type = 1
  13774. and be.hospital_id = hm_mci.hospital_id
  13775. and be.behospital_code = hm_mci.behospital_code
  13776. LEFT JOIN med_qcresult_cases e
  13777. on be.behospital_code = e.behospital_code
  13778. and be.hospital_id = e.hospital_id
  13779. AND e.is_deleted = 'N'
  13780. and e.cases_id = 243
  13781. ) t1
  13782. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13783. AND t1.behospital_code = t2.behospital_code
  13784. AND t2.is_deleted = 'N'
  13785. ) t
  13786. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13787. AND t.hospitalId = qi.hospital_id
  13788. AND t.behospitalCode = qi.behospital_code
  13789. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13790. AND t.hospitalId = qd.hospital_id
  13791. AND t.behospitalCode = qd.behospital_code
  13792. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13793. AND qd.cases_id = qc.id
  13794. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13795. AND qd.cases_id = qce.cases_id
  13796. AND qd.cases_entry_id = qce.id
  13797. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  13798. AND t.hospitalId = t2.hospital_id
  13799. AND t2.is_deleted = 'N'
  13800. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  13801. AND t3.is_deleted = 'N'
  13802. where 1=1
  13803. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  13804. AND t3.name like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  13805. </if>
  13806. <if test="qcResultShortPageVO.checkStatus != null">
  13807. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13808. </if>
  13809. <if test="qcResultShortPageVO.mrStatus != null">
  13810. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13811. </if>
  13812. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13813. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13814. </if>
  13815. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13816. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13817. </if>
  13818. <if test="qcResultShortPageVO.chTimeStart != null ">
  13819. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13820. </if>
  13821. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13822. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13823. </if>
  13824. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13825. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13826. </if>
  13827. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13828. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13829. </if>
  13830. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13831. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13832. </if>
  13833. <if test="qcResultShortPageVO.casesEntryId != null ">
  13834. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13835. </if>
  13836. )f1,
  13837. (SELECT
  13838. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13839. t.behDeptId,
  13840. t.behDeptName,
  13841. t.doctorId,
  13842. t.doctorName
  13843. FROM
  13844. (SELECT DISTINCT
  13845. t1.hospital_id AS hospitalId,
  13846. t1.behospital_code AS behospitalCode,
  13847. t1.bed_code AS bedCode,
  13848. t1.LEVEL AS LEVEL,
  13849. t1.grade_type AS gradeType,
  13850. t1.score_res AS scoreRes,
  13851. t1.NAME AS NAME,
  13852. t1.sex AS sex,
  13853. t1.beh_dept_id AS behDeptId,
  13854. t1.beh_dept_name AS behDeptName,
  13855. t1.doctor_id AS doctorId,
  13856. t1.doctor_name AS doctorName,
  13857. t1.beh_doctor_id AS behDoctorId,
  13858. t1.beh_doctor_name AS behDoctorName,
  13859. t1.director_doctor_id AS directorDoctorId,
  13860. t1.director_doctor_name AS directorDoctorName,
  13861. t1.birthday AS birthday,
  13862. t1.behospital_date AS behospitalDate,
  13863. t1.leave_hospital_date AS leaveHospitalDate,
  13864. t1.placefile_date AS placefileDate,
  13865. t1.gmt_create AS gradeTime,
  13866. t1.diagnose,
  13867. t1.ward_name AS wardName,
  13868. t2.age,
  13869. t1.file_code AS fileCode,
  13870. t1.checkStatus,
  13871. t1.mrStatus,
  13872. t1.chName,
  13873. t1.mrName,
  13874. t1.chTime,
  13875. t1.mrTime
  13876. FROM
  13877. (SELECT
  13878. be.*,
  13879. ifnull(mci.status,0) AS checkStatus,
  13880. ifnull(hm_mci.status,0) AS mrStatus,
  13881. mci.check_name as chName,
  13882. hm_mci.check_name as mrName,
  13883. mci.gmt_create as chTime,
  13884. hm_mci.gmt_create as mrTime
  13885. FROM
  13886. (
  13887. SELECT DISTINCT
  13888. a.hospital_id,
  13889. a.behospital_code,
  13890. a.bed_code,
  13891. a.file_code,
  13892. b.LEVEL,
  13893. b.grade_type,
  13894. b.score_res,
  13895. a.NAME,
  13896. a.sex,
  13897. a.beh_dept_id,
  13898. a.beh_dept_name,
  13899. a.birthday,
  13900. a.behospital_date,
  13901. a.leave_hospital_date,
  13902. a.doctor_id,
  13903. a.doctor_name,
  13904. a.beh_doctor_id,
  13905. a.beh_doctor_name,
  13906. a.director_doctor_id,
  13907. a.director_doctor_name,
  13908. a.diagnose,
  13909. a.placefile_date,
  13910. a.ward_name,
  13911. b.gmt_create
  13912. FROM
  13913. med_behospital_info a,
  13914. med_qcresult_info b,
  13915. med_qcresult_detail c,
  13916. qc_cases_entry d,
  13917. sys_user_dept f
  13918. WHERE
  13919. a.is_deleted = 'N'
  13920. AND b.is_deleted = 'N'
  13921. AND c.is_deleted = 'N'
  13922. AND d.is_deleted = 'N'
  13923. AND f.is_deleted = 'N'
  13924. AND a.hospital_id = b.hospital_id
  13925. AND a.hospital_id = c.hospital_id
  13926. AND a.hospital_id = f.hospital_id
  13927. AND a.behospital_code = b.behospital_code
  13928. AND a.behospital_code = c.behospital_code
  13929. AND c.cases_id = d.cases_id
  13930. AND c.cases_entry_id = d.id
  13931. AND a.beh_dept_id = f.dept_id
  13932. AND a.qc_type_id != 0
  13933. <if test="qcResultShortPageVO.userId!=null">
  13934. AND f.user_id = #{qcResultShortPageVO.userId}
  13935. </if>
  13936. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13937. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13938. </if>
  13939. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13940. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13941. </if>
  13942. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13943. <if test="qcResultShortPageVO.startDate != null ">
  13944. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13945. </if>
  13946. <if test="qcResultShortPageVO.endDate != null ">
  13947. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13948. </if>
  13949. </if>
  13950. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13951. <if test="qcResultShortPageVO.startDate != null ">
  13952. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13953. </if>
  13954. <if test="qcResultShortPageVO.endDate != null">
  13955. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13956. </if>
  13957. </if>
  13958. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13959. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13960. </if>
  13961. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13962. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13963. </if>
  13964. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13965. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13966. </if>
  13967. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13968. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13969. </if>
  13970. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13971. AND b.`level` = #{qcResultShortPageVO.level}
  13972. </if>
  13973. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13974. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13975. </if>
  13976. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13977. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13978. </if>
  13979. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13980. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13981. </if>
  13982. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13983. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13984. </if>
  13985. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13986. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13987. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13988. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13989. </if>
  13990. <if test="qcResultShortPageVO.casesEntryId != null ">
  13991. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13992. </if>
  13993. <if test="qcResultShortPageVO.isReject != null">
  13994. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13995. </if>
  13996. <if test="qcResultShortPageVO.ruleType != null">
  13997. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13998. </if>
  13999. )be
  14000. left join med_check_info mci
  14001. on mci.is_deleted = 'N'
  14002. and mci.check_type = 0
  14003. and be.hospital_id = mci.hospital_id
  14004. and be.behospital_code = mci.behospital_code
  14005. left join med_check_info hm_mci
  14006. on hm_mci.is_deleted = 'N'
  14007. and hm_mci.check_type = 1
  14008. and be.hospital_id = hm_mci.hospital_id
  14009. and be.behospital_code = hm_mci.behospital_code
  14010. ) t1
  14011. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14012. AND t1.behospital_code = t2.behospital_code
  14013. AND t2.is_deleted = 'N'
  14014. ) t
  14015. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14016. AND t.hospitalId = qi.hospital_id
  14017. AND t.behospitalCode = qi.behospital_code
  14018. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  14019. AND t.hospitalId = t2.hospital_id
  14020. AND t2.is_deleted = 'N'
  14021. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  14022. AND t3.is_deleted = 'N'
  14023. where 1=1
  14024. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  14025. AND t3.name like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  14026. </if>
  14027. <if test="qcResultShortPageVO.checkStatus != null">
  14028. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14029. </if>
  14030. <if test="qcResultShortPageVO.mrStatus != null">
  14031. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14032. </if>
  14033. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14034. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14035. </if>
  14036. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14037. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14038. </if>
  14039. <if test="qcResultShortPageVO.chTimeStart != null ">
  14040. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14041. </if>
  14042. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14043. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14044. </if>
  14045. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14046. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14047. </if>
  14048. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14049. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14050. </if>
  14051. GROUP BY
  14052. t.doctorId,
  14053. t.doctorName
  14054. )f2
  14055. WHERE
  14056. f1.doctorId = f2.doctorId
  14057. AND f1.doctorName = f2.doctorName
  14058. </select>
  14059. <!-- 31天再入院详情页-->
  14060. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14061. SELECT
  14062. t.fileCode,
  14063. t.diagnose,
  14064. t.NAME,
  14065. t.sex,
  14066. t.hospitalId,
  14067. t.behDeptId,
  14068. t.behDeptName,
  14069. t.behospitalCode,
  14070. t.behospitalDate,
  14071. t.leaveHospitalDate,
  14072. t.lastBehDeptId,
  14073. t.lastBehDeptName,
  14074. t.lastBehospitalCode,
  14075. t.lastBehospitalDate,
  14076. t.lastLeaveHospitalDate,
  14077. t.diffDays,
  14078. mqi.score_res AS scoreRes,
  14079. mqi.LEVEL AS LEVEL,
  14080. mqi_last.score_res AS lastScoreRes,
  14081. mqi_last.LEVEL AS lastLevel,
  14082. mhp.total_fee AS totleFee,
  14083. mhp.behospital_day_num AS behospitalDayNum,
  14084. mhp_last.total_fee AS lastTotleFee,
  14085. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14086. FROM
  14087. (
  14088. SELECT
  14089. be.fileCode,
  14090. be.diagnose,
  14091. be.NAME,
  14092. be.sex,
  14093. be.hospitalId,
  14094. be.behDeptId,
  14095. be.behDeptName,
  14096. be.behospitalCode,
  14097. be.behospitalDate,
  14098. be.leaveHospitalDate,
  14099. be.lastBehDeptId,
  14100. be.lastBehDeptName,
  14101. be.lastBehospitalCode,
  14102. be.lastBehospitalDate,
  14103. be.lastLeaveHospitalDate,
  14104. be.diffDays
  14105. FROM
  14106. (
  14107. SELECT
  14108. r1.file_code AS fileCode,
  14109. r1.diagnose,
  14110. r1.NAME,
  14111. r1.sex,
  14112. r1.hospital_id AS hospitalId,
  14113. r1.beh_dept_id AS behDeptId,
  14114. r1.beh_dept_name AS behDeptName,
  14115. r1.behospital_code AS behospitalCode,
  14116. r1.behospital_date AS behospitalDate,
  14117. r1.leave_hospital_date AS leaveHospitalDate,
  14118. r2.beh_dept_id AS lastBehDeptId,
  14119. r2.beh_dept_name AS lastBehDeptName,
  14120. r2.behospital_code AS lastBehospitalCode,
  14121. r2.behospital_date AS lastBehospitalDate,
  14122. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14123. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14124. FROM
  14125. (
  14126. SELECT
  14127. ( @rownum := @rownum + 1 ) AS rownum,
  14128. t1.file_code,
  14129. t1.diagnose,
  14130. t1.NAME,
  14131. t1.sex,
  14132. t1.hospital_id,
  14133. t1.beh_dept_id,
  14134. t1.beh_dept_name,
  14135. t1.behospital_code,
  14136. t1.behospital_date,
  14137. t1.leave_hospital_date
  14138. FROM
  14139. (
  14140. SELECT
  14141. tt1.file_code,
  14142. tt1.diagnose,
  14143. tt2.NAME,
  14144. tt2.sex,
  14145. tt2.hospital_id,
  14146. tt2.beh_dept_id,
  14147. tt2.beh_dept_name,
  14148. tt2.behospital_code,
  14149. tt2.behospital_date,
  14150. tt2.leave_hospital_date
  14151. FROM
  14152. (
  14153. SELECT
  14154. a.file_code,
  14155. a.diagnose
  14156. FROM
  14157. med_behospital_info a
  14158. WHERE
  14159. a.is_deleted = 'N'
  14160. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14161. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14162. </if>
  14163. AND a.qc_type_id != 0
  14164. AND IFNULL( a.diagnose, '' )!= ''
  14165. AND IFNULL( a.file_code, '' )!= ''
  14166. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14167. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14168. </if>
  14169. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14170. <if test="reBeHosPageVO.startDate != null ">
  14171. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14172. </if>
  14173. <if test="reBeHosPageVO.endDate != null ">
  14174. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14175. </if>
  14176. </if>
  14177. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14178. <if test="reBeHosPageVO.startDate != null ">
  14179. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14180. </if>
  14181. <if test="reBeHosPageVO.endDate != null">
  14182. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14183. </if>
  14184. </if>
  14185. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14186. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14187. </if>
  14188. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14189. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14190. </if>
  14191. GROUP BY
  14192. a.file_code,
  14193. a.diagnose
  14194. HAVING
  14195. count(*)> 1
  14196. ) tt1,
  14197. med_behospital_info tt2
  14198. WHERE
  14199. tt2.is_deleted = 'N'
  14200. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14201. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14202. </if>
  14203. AND tt2.qc_type_id != 0
  14204. AND tt1.file_code = tt2.file_code
  14205. AND tt1.diagnose = tt2.diagnose
  14206. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14207. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14208. </if>
  14209. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14210. <if test="reBeHosPageVO.startDate != null ">
  14211. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14212. </if>
  14213. <if test="reBeHosPageVO.endDate != null ">
  14214. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14215. </if>
  14216. </if>
  14217. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14218. <if test="reBeHosPageVO.startDate != null ">
  14219. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14220. </if>
  14221. <if test="reBeHosPageVO.endDate != null">
  14222. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14223. </if>
  14224. </if>
  14225. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14226. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14227. </if>
  14228. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14229. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14230. </if>
  14231. ORDER BY
  14232. tt1.file_code,
  14233. tt1.diagnose,
  14234. tt2.behospital_date DESC
  14235. ) t1,
  14236. ( SELECT @rownum := 0 ) r
  14237. ) r1
  14238. LEFT JOIN (
  14239. SELECT
  14240. ( @INDEX := @INDEX + 1 ) AS rownum,
  14241. t1.file_code,
  14242. t1.diagnose,
  14243. t1.NAME,
  14244. t1.sex,
  14245. t1.hospital_id,
  14246. t1.beh_dept_id,
  14247. t1.beh_dept_name,
  14248. t1.behospital_code,
  14249. t1.behospital_date,
  14250. t1.leave_hospital_date
  14251. FROM
  14252. (
  14253. SELECT
  14254. tt1.file_code,
  14255. tt1.diagnose,
  14256. tt2.NAME,
  14257. tt2.sex,
  14258. tt2.hospital_id,
  14259. tt2.beh_dept_id,
  14260. tt2.beh_dept_name,
  14261. tt2.behospital_code,
  14262. tt2.behospital_date,
  14263. tt2.leave_hospital_date
  14264. FROM
  14265. (
  14266. SELECT
  14267. a.file_code,
  14268. a.diagnose
  14269. FROM
  14270. med_behospital_info a
  14271. WHERE
  14272. a.is_deleted = 'N'
  14273. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14274. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14275. </if>
  14276. AND a.qc_type_id != 0
  14277. AND IFNULL( a.diagnose, '' )!= ''
  14278. AND IFNULL( a.file_code, '' )!= ''
  14279. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14280. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14281. </if>
  14282. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14283. <if test="reBeHosPageVO.startDate != null ">
  14284. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14285. </if>
  14286. <if test="reBeHosPageVO.endDate != null ">
  14287. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14288. </if>
  14289. </if>
  14290. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14291. <if test="reBeHosPageVO.startDate != null ">
  14292. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14293. </if>
  14294. <if test="reBeHosPageVO.endDate != null">
  14295. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14296. </if>
  14297. </if>
  14298. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14299. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14300. </if>
  14301. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14302. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14303. </if>
  14304. GROUP BY
  14305. a.file_code,
  14306. a.diagnose
  14307. HAVING
  14308. count(*)> 1
  14309. ) tt1,
  14310. med_behospital_info tt2
  14311. WHERE
  14312. tt2.is_deleted = 'N'
  14313. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14314. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14315. </if>
  14316. AND tt2.qc_type_id != 0
  14317. AND tt1.file_code = tt2.file_code
  14318. AND tt1.diagnose = tt2.diagnose
  14319. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14320. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14321. </if>
  14322. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14323. <if test="reBeHosPageVO.startDate != null ">
  14324. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14325. </if>
  14326. <if test="reBeHosPageVO.endDate != null ">
  14327. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14328. </if>
  14329. </if>
  14330. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14331. <if test="reBeHosPageVO.startDate != null ">
  14332. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14333. </if>
  14334. <if test="reBeHosPageVO.endDate != null">
  14335. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14336. </if>
  14337. </if>
  14338. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14339. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14340. </if>
  14341. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14342. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14343. </if>
  14344. ORDER BY
  14345. tt1.file_code,
  14346. tt1.diagnose,
  14347. tt2.behospital_date DESC
  14348. ) t1,(
  14349. SELECT
  14350. @INDEX := 0
  14351. ) r
  14352. ) r2 ON r1.file_code = r2.file_code
  14353. AND r1.rownum = r2.rownum - 1
  14354. ) be
  14355. WHERE
  14356. be.diffDays IS NOT NULL
  14357. AND be.diffDays BETWEEN 0
  14358. AND 31
  14359. ) t
  14360. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14361. AND t.hospitalId = mqi.hospital_id
  14362. AND t.behospitalCode = mqi.behospital_code
  14363. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14364. AND t.hospitalId = mqi_last.hospital_id
  14365. AND t.lastBehospitalCode = mqi_last.behospital_code
  14366. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14367. AND t.hospitalId = mhp.hospital_id
  14368. AND t.behospitalCode = mhp.behospital_code
  14369. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14370. AND t.hospitalId = mhp_last.hospital_id
  14371. AND t.lastBehospitalCode = mhp_last.behospital_code
  14372. </select>
  14373. <!-- 31天再入院详情页-科室-->
  14374. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14375. SELECT
  14376. t.fileCode,
  14377. t.diagnose,
  14378. t.NAME,
  14379. t.sex,
  14380. t.hospitalId,
  14381. t.behDeptId,
  14382. t.behDeptName,
  14383. t.doctorId,
  14384. t.doctorName,
  14385. t.behospitalCode,
  14386. t.behospitalDate,
  14387. t.leaveHospitalDate,
  14388. t.lastBehDeptId,
  14389. t.lastBehDeptName,
  14390. t.lastDoctorName,
  14391. t.lastBehospitalCode,
  14392. t.lastBehospitalDate,
  14393. t.lastLeaveHospitalDate,
  14394. t.diffDays,
  14395. mqi.score_res AS scoreRes,
  14396. mqi.LEVEL AS LEVEL,
  14397. mqi_last.score_res AS lastScoreRes,
  14398. mqi_last.LEVEL AS lastLevel,
  14399. mhp.total_fee AS totleFee,
  14400. mhp.behospital_day_num AS behospitalDayNum,
  14401. mhp_last.total_fee AS lastTotleFee,
  14402. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14403. FROM
  14404. (
  14405. SELECT
  14406. be.fileCode,
  14407. be.diagnose,
  14408. be.NAME,
  14409. be.sex,
  14410. be.hospitalId,
  14411. be.behDeptId,
  14412. be.behDeptName,
  14413. be.doctorId,
  14414. be.doctorName,
  14415. be.behospitalCode,
  14416. be.behospitalDate,
  14417. be.leaveHospitalDate,
  14418. be.lastBehDeptId,
  14419. be.lastBehDeptName,
  14420. be.lastDoctorId,
  14421. be.lastDoctorName,
  14422. be.lastBehospitalCode,
  14423. be.lastBehospitalDate,
  14424. be.lastLeaveHospitalDate,
  14425. be.diffDays
  14426. FROM
  14427. (
  14428. SELECT
  14429. r1.file_code AS fileCode,
  14430. r1.diagnose,
  14431. r1.NAME,
  14432. r1.sex,
  14433. r1.hospital_id AS hospitalId,
  14434. r1.beh_dept_id AS behDeptId,
  14435. r1.beh_dept_name AS behDeptName,
  14436. r1.doctor_id as doctorId,
  14437. r1.doctor_name as doctorName,
  14438. r1.behospital_code AS behospitalCode,
  14439. r1.behospital_date AS behospitalDate,
  14440. r1.leave_hospital_date AS leaveHospitalDate,
  14441. r2.beh_dept_id AS lastBehDeptId,
  14442. r2.beh_dept_name AS lastBehDeptName,
  14443. r2.behospital_code AS lastBehospitalCode,
  14444. r2.behospital_date AS lastBehospitalDate,
  14445. r2.doctor_id as lastDoctorId,
  14446. r2.doctor_name as lastDoctorName,
  14447. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14448. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14449. FROM
  14450. (
  14451. SELECT
  14452. ( @rownum := @rownum + 1 ) AS rownum,
  14453. t1.file_code,
  14454. t1.diagnose,
  14455. t1.NAME,
  14456. t1.sex,
  14457. t1.doctor_id,
  14458. t1.doctor_name,
  14459. t1.hospital_id,
  14460. t1.beh_dept_id,
  14461. t1.beh_dept_name,
  14462. t1.behospital_code,
  14463. t1.behospital_date,
  14464. t1.leave_hospital_date
  14465. FROM
  14466. (
  14467. SELECT
  14468. tt1.file_code,
  14469. tt1.diagnose,
  14470. tt2.doctor_id,
  14471. tt2.doctor_name,
  14472. tt2.NAME,
  14473. tt2.sex,
  14474. tt2.hospital_id,
  14475. tt2.beh_dept_id,
  14476. tt2.beh_dept_name,
  14477. tt2.behospital_code,
  14478. tt2.behospital_date,
  14479. tt2.leave_hospital_date
  14480. FROM
  14481. (
  14482. SELECT
  14483. a.file_code,
  14484. a.diagnose,
  14485. a.doctor_id,
  14486. a.doctor_name
  14487. FROM
  14488. med_behospital_info a,
  14489. sys_user_dept c
  14490. WHERE
  14491. a.is_deleted = 'N'
  14492. AND c.is_deleted = 'N'
  14493. AND a.hospital_id = c.hospital_id
  14494. AND a.beh_dept_id = c.dept_id
  14495. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14496. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14497. </if>
  14498. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14499. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14500. </if>
  14501. <if test="reBeHosPageVO.userId!=null">
  14502. AND c.user_id = #{reBeHosPageVO.userId}
  14503. </if>
  14504. AND a.qc_type_id != 0
  14505. AND IFNULL( a.diagnose, '' )!= ''
  14506. AND IFNULL( a.file_code, '' )!= ''
  14507. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14508. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14509. </if>
  14510. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14511. <if test="reBeHosPageVO.startDate != null ">
  14512. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14513. </if>
  14514. <if test="reBeHosPageVO.endDate != null ">
  14515. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14516. </if>
  14517. </if>
  14518. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14519. <if test="reBeHosPageVO.startDate != null ">
  14520. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14521. </if>
  14522. <if test="reBeHosPageVO.endDate != null">
  14523. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14524. </if>
  14525. </if>
  14526. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14527. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14528. </if>
  14529. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14530. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14531. </if>
  14532. GROUP BY
  14533. a.file_code,
  14534. a.diagnose
  14535. HAVING
  14536. count(*)> 1
  14537. ) tt1,
  14538. med_behospital_info tt2
  14539. WHERE
  14540. tt2.is_deleted = 'N'
  14541. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14542. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14543. </if>
  14544. AND tt2.qc_type_id != 0
  14545. AND tt1.file_code = tt2.file_code
  14546. AND tt1.diagnose = tt2.diagnose
  14547. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14548. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14549. </if>
  14550. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14551. <if test="reBeHosPageVO.startDate != null ">
  14552. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14553. </if>
  14554. <if test="reBeHosPageVO.endDate != null ">
  14555. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14556. </if>
  14557. </if>
  14558. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14559. <if test="reBeHosPageVO.startDate != null ">
  14560. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14561. </if>
  14562. <if test="reBeHosPageVO.endDate != null">
  14563. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14564. </if>
  14565. </if>
  14566. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14567. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14568. </if>
  14569. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14570. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14571. </if>
  14572. ORDER BY
  14573. tt1.file_code,
  14574. tt1.diagnose,
  14575. tt2.behospital_date DESC
  14576. ) t1,
  14577. ( SELECT @rownum := 0 ) r
  14578. ) r1
  14579. LEFT JOIN (
  14580. SELECT
  14581. ( @INDEX := @INDEX + 1 ) AS rownum,
  14582. t1.file_code,
  14583. t1.diagnose,
  14584. t1.NAME,
  14585. t1.sex,
  14586. t1.hospital_id,
  14587. t1.beh_dept_id,
  14588. t1.beh_dept_name,
  14589. t1.doctor_id,
  14590. t1.doctor_name,
  14591. t1.behospital_code,
  14592. t1.behospital_date,
  14593. t1.leave_hospital_date
  14594. FROM
  14595. (
  14596. SELECT
  14597. tt1.file_code,
  14598. tt1.diagnose,
  14599. tt2.doctor_id,
  14600. tt2.doctor_name,
  14601. tt2.NAME,
  14602. tt2.sex,
  14603. tt2.hospital_id,
  14604. tt2.beh_dept_id,
  14605. tt2.beh_dept_name,
  14606. tt2.behospital_code,
  14607. tt2.behospital_date,
  14608. tt2.leave_hospital_date
  14609. FROM
  14610. (
  14611. SELECT
  14612. a.file_code,
  14613. a.diagnose,
  14614. a.doctor_id ,
  14615. a.doctor_name
  14616. FROM
  14617. med_behospital_info a,
  14618. sys_user_dept c
  14619. WHERE
  14620. a.is_deleted = 'N'
  14621. AND c.is_deleted = 'N'
  14622. AND a.hospital_id = c.hospital_id
  14623. AND a.beh_dept_id = c.dept_id
  14624. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14625. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14626. </if>
  14627. <if test="reBeHosPageVO.userId!=null">
  14628. AND c.user_id = #{reBeHosPageVO.userId}
  14629. </if>
  14630. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14631. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14632. </if>
  14633. AND a.qc_type_id != 0
  14634. AND IFNULL( a.diagnose, '' )!= ''
  14635. AND IFNULL( a.file_code, '' )!= ''
  14636. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14637. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14638. </if>
  14639. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14640. <if test="reBeHosPageVO.startDate != null ">
  14641. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14642. </if>
  14643. <if test="reBeHosPageVO.endDate != null ">
  14644. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14645. </if>
  14646. </if>
  14647. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14648. <if test="reBeHosPageVO.startDate != null ">
  14649. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14650. </if>
  14651. <if test="reBeHosPageVO.endDate != null">
  14652. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14653. </if>
  14654. </if>
  14655. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14656. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14657. </if>
  14658. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14659. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14660. </if>
  14661. GROUP BY
  14662. a.file_code,
  14663. a.diagnose
  14664. HAVING
  14665. count(*)> 1
  14666. ) tt1,
  14667. med_behospital_info tt2
  14668. WHERE
  14669. tt2.is_deleted = 'N'
  14670. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14671. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14672. </if>
  14673. AND tt2.qc_type_id != 0
  14674. AND tt1.file_code = tt2.file_code
  14675. AND tt1.diagnose = tt2.diagnose
  14676. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14677. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14678. </if>
  14679. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14680. <if test="reBeHosPageVO.startDate != null ">
  14681. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14682. </if>
  14683. <if test="reBeHosPageVO.endDate != null ">
  14684. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14685. </if>
  14686. </if>
  14687. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14688. <if test="reBeHosPageVO.startDate != null ">
  14689. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14690. </if>
  14691. <if test="reBeHosPageVO.endDate != null">
  14692. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14693. </if>
  14694. </if>
  14695. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14696. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14697. </if>
  14698. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14699. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14700. </if>
  14701. ORDER BY
  14702. tt1.file_code,
  14703. tt1.diagnose,
  14704. tt2.behospital_date DESC
  14705. ) t1,(
  14706. SELECT
  14707. @INDEX := 0
  14708. ) r
  14709. ) r2 ON r1.file_code = r2.file_code
  14710. AND r1.rownum = r2.rownum - 1
  14711. ) be
  14712. WHERE
  14713. be.diffDays IS NOT NULL
  14714. AND be.diffDays BETWEEN 0
  14715. AND 31
  14716. ) t
  14717. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14718. AND t.hospitalId = mqi.hospital_id
  14719. AND t.behospitalCode = mqi.behospital_code
  14720. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14721. AND t.hospitalId = mqi_last.hospital_id
  14722. AND t.lastBehospitalCode = mqi_last.behospital_code
  14723. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14724. AND t.hospitalId = mhp.hospital_id
  14725. AND t.behospitalCode = mhp.behospital_code
  14726. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14727. AND t.hospitalId = mhp_last.hospital_id
  14728. AND t.lastBehospitalCode = mhp_last.behospital_code
  14729. </select>
  14730. <!-- 单条条目缺陷统计-->
  14731. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  14732. SELECT
  14733. a.beh_dept_id AS id,
  14734. a.beh_dept_name AS NAME,
  14735. count(*) AS num
  14736. FROM
  14737. med_behospital_info a,
  14738. med_qcresult_detail b
  14739. WHERE
  14740. a.is_deleted = 'N'
  14741. AND b.is_deleted = 'N'
  14742. AND a.hospital_id = b.hospital_id
  14743. AND a.behospital_code = b.behospital_code
  14744. AND a.qc_type_id != 0
  14745. and b.cases_entry_id=2658
  14746. <if test="isPlacefile != null and isPlacefile != ''">
  14747. and a.is_placefile = #{isPlacefile}
  14748. </if>
  14749. <if test="hospitalId != null and hospitalId != ''">
  14750. AND a.hospital_id = #{hospitalId}
  14751. </if>
  14752. <if test="isPlacefile != null and isPlacefile == 0">
  14753. <if test="startDate != null and startDate != ''">
  14754. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14755. </if>
  14756. <if test="endDate != null and endDate != ''">
  14757. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14758. </if>
  14759. </if>
  14760. <if test="isPlacefile != null and isPlacefile == 1">
  14761. <if test="startDate != null and startDate != ''">
  14762. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14763. </if>
  14764. <if test="endDate != null and endDate != ''">
  14765. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14766. </if>
  14767. </if>
  14768. GROUP BY
  14769. a.beh_dept_id,
  14770. a.beh_dept_name
  14771. </select>
  14772. <!-- 单条条目缺陷统计-->
  14773. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  14774. SELECT
  14775. a.beh_dept_id AS deptId,
  14776. a.beh_dept_name AS deptName,
  14777. a.doctor_id as doctorId,
  14778. a.doctor_name as doctorName,
  14779. count(*) AS num
  14780. FROM
  14781. med_behospital_info a,
  14782. med_qcresult_detail b,
  14783. sys_user_dept c
  14784. WHERE
  14785. a.is_deleted = 'N'
  14786. AND b.is_deleted = 'N'
  14787. AND c.is_deleted = 'N'
  14788. AND a.hospital_id = b.hospital_id
  14789. AND a.hospital_id = c.hospital_id
  14790. AND a.behospital_code = b.behospital_code
  14791. AND a.beh_dept_id = c.dept_id
  14792. AND a.qc_type_id != 0
  14793. and b.cases_entry_id=2658
  14794. <if test="isPlacefile != null and isPlacefile != ''">
  14795. and a.is_placefile = #{isPlacefile}
  14796. </if>
  14797. <if test="hospitalId != null and hospitalId != ''">
  14798. AND a.hospital_id = #{hospitalId}
  14799. </if>
  14800. <if test="userId!=null">
  14801. AND c.user_id = #{userId}
  14802. </if>
  14803. <if test="isPlacefile != null and isPlacefile == 0">
  14804. <if test="startDate != null and startDate != ''">
  14805. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14806. </if>
  14807. <if test="endDate != null and endDate != ''">
  14808. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14809. </if>
  14810. </if>
  14811. <if test="isPlacefile != null and isPlacefile == 1">
  14812. <if test="startDate != null and startDate != ''">
  14813. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14814. </if>
  14815. <if test="endDate != null and endDate != ''">
  14816. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14817. </if>
  14818. </if>
  14819. GROUP BY
  14820. a.beh_dept_id,
  14821. a.beh_dept_name,
  14822. a.doctor_id,
  14823. a.doctor_name
  14824. </select>
  14825. <!-- 病案首页改善率质控评分页(内页)-->
  14826. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  14827. SELECT
  14828. t.*
  14829. FROM
  14830. (
  14831. SELECT DISTINCT
  14832. t1.hospital_id AS hospitalId,
  14833. t1.behospital_code AS behospitalCode,
  14834. t1.bed_code AS bedCode,
  14835. t1.LEVEL AS LEVEL,
  14836. t1.grade_type AS gradeType,
  14837. t1.score_res AS scoreRes,
  14838. t1.NAME AS NAME,
  14839. t1.sex AS sex,
  14840. t1.beh_dept_id AS behDeptId,
  14841. t1.beh_dept_name AS behDeptName,
  14842. t1.doctor_id AS doctorId,
  14843. t1.doctor_name AS doctorName,
  14844. t1.beh_doctor_id AS behDoctorId,
  14845. t1.beh_doctor_name AS behDoctorName,
  14846. t1.director_doctor_id AS directorDoctorId,
  14847. t1.director_doctor_name AS directorDoctorName,
  14848. t1.birthday AS birthday,
  14849. t1.behospital_date AS behospitalDate,
  14850. t1.leave_hospital_date AS leaveHospitalDate,
  14851. t1.placefile_date AS placefileDate,
  14852. t1.gmt_create AS gradeTime,
  14853. t1.diagnose,
  14854. t1.ward_name AS wardName,
  14855. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  14856. t1.file_code AS fileCode,
  14857. t1.checkStatus,
  14858. t1.mrStatus,
  14859. t1.chName,
  14860. t1.mrName,
  14861. t1.chTime,
  14862. t1.mrTime
  14863. FROM
  14864. (
  14865. SELECT
  14866. be.*,
  14867. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14868. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14869. mci.check_name AS chName,
  14870. hm_mci.check_name AS mrName,
  14871. mci.gmt_create AS chTime,
  14872. hm_mci.gmt_create AS mrTime
  14873. FROM
  14874. (
  14875. SELECT DISTINCT
  14876. a.hospital_id,
  14877. a.behospital_code,
  14878. a.bed_code,
  14879. a.file_code,
  14880. c.LEVEL,
  14881. c.grade_type,
  14882. c.score_res,
  14883. a.NAME,
  14884. a.sex,
  14885. a.beh_dept_id,
  14886. a.beh_dept_name,
  14887. a.birthday,
  14888. a.behospital_date,
  14889. a.leave_hospital_date,
  14890. a.doctor_id,
  14891. a.doctor_name,
  14892. a.beh_doctor_id,
  14893. a.beh_doctor_name,
  14894. a.director_doctor_id,
  14895. a.director_doctor_name,
  14896. a.diagnose,
  14897. a.placefile_date,
  14898. a.ward_name,
  14899. c.gmt_create
  14900. FROM
  14901. med_behospital_info a,
  14902. med_home_page b,
  14903. med_qcresult_info c,
  14904. med_qcresult_cases d,
  14905. (
  14906. SELECT
  14907. m4.*
  14908. FROM
  14909. med_behospital_info m1,
  14910. med_home_page m2,
  14911. med_qcresult_info m3,
  14912. med_qcresult_cases m4
  14913. WHERE
  14914. m1.is_deleted = 'N'
  14915. AND m2.is_deleted = 'N'
  14916. AND m3.is_deleted = 'Y'
  14917. AND m4.is_deleted = 'Y'
  14918. AND m1.hospital_id = m2.hospital_id
  14919. AND m1.hospital_id = m3.hospital_id
  14920. AND m1.hospital_id = m4.hospital_id
  14921. AND m1.behospital_code = m2.behospital_code
  14922. AND m1.behospital_code = m3.behospital_code
  14923. AND m1.behospital_code = m4.behospital_code
  14924. AND m3.gmt_create = m4.gmt_create
  14925. AND m3.have_home_page = 1
  14926. AND m4.cases_id = 243
  14927. AND m1.qc_type_id != 0
  14928. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14929. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14930. </if>
  14931. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14932. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14933. </if>
  14934. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14935. <if test="qcResultShortPageVO.startDate != null ">
  14936. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14937. </if>
  14938. <if test="qcResultShortPageVO.endDate != null ">
  14939. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14940. </if>
  14941. </if>
  14942. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14943. <if test="qcResultShortPageVO.startDate != null">
  14944. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14945. </if>
  14946. <if test="qcResultShortPageVO.endDate != null ">
  14947. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14948. </if>
  14949. </if>
  14950. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14951. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  14952. </if>
  14953. GROUP BY
  14954. m1.behospital_code
  14955. ORDER BY
  14956. m1.behospital_code,
  14957. m4.gmt_create
  14958. ) e
  14959. WHERE
  14960. a.is_deleted = 'N'
  14961. AND b.is_deleted = 'N'
  14962. AND c.is_deleted = 'N'
  14963. AND d.is_deleted = 'N'
  14964. AND a.hospital_id = b.hospital_id
  14965. AND a.hospital_id = c.hospital_id
  14966. AND a.hospital_id = d.hospital_id
  14967. AND a.hospital_id = e.hospital_id
  14968. AND a.behospital_code = b.behospital_code
  14969. AND a.behospital_code = c.behospital_code
  14970. AND a.behospital_code = d.behospital_code
  14971. AND a.behospital_code = e.behospital_code
  14972. AND d.cases_id = 243
  14973. AND d.score_res > e.score_res
  14974. AND a.qc_type_id != 0
  14975. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14976. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14977. </if>
  14978. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14979. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14980. </if>
  14981. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14982. <if test="qcResultShortPageVO.startDate != null ">
  14983. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14984. </if>
  14985. <if test="qcResultShortPageVO.endDate != null ">
  14986. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14987. </if>
  14988. </if>
  14989. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14990. <if test="qcResultShortPageVO.startDate != null ">
  14991. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14992. </if>
  14993. <if test="qcResultShortPageVO.endDate != null">
  14994. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14995. </if>
  14996. </if>
  14997. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14998. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14999. </if>
  15000. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15001. AND c.`level` = #{qcResultShortPageVO.level}
  15002. </if>
  15003. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15004. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15005. </if>
  15006. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15007. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15008. </if>
  15009. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15010. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15011. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15012. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15013. </if>
  15014. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15015. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15016. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15017. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15018. </if>
  15019. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15020. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15021. </if>
  15022. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15023. AND d.score_res = 20
  15024. </if>
  15025. ) be
  15026. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15027. AND mci.check_type = 0
  15028. AND be.hospital_id = mci.hospital_id
  15029. AND be.behospital_code = mci.behospital_code
  15030. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15031. AND hm_mci.check_type = 1
  15032. AND be.hospital_id = hm_mci.hospital_id
  15033. AND be.behospital_code = hm_mci.behospital_code
  15034. ) t1
  15035. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15036. AND t1.behospital_code = t2.behospital_code
  15037. AND t2.is_deleted = 'N'
  15038. ) t
  15039. WHERE
  15040. 1 = 1
  15041. <if test="qcResultShortPageVO.checkStatus != null">
  15042. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15043. </if>
  15044. <if test="qcResultShortPageVO.mrStatus != null">
  15045. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15046. </if>
  15047. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15048. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15049. </if>
  15050. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15051. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15052. </if>
  15053. <if test="qcResultShortPageVO.chTimeStart != null ">
  15054. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15055. </if>
  15056. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15057. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15058. </if>
  15059. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15060. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15061. </if>
  15062. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15063. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15064. </if>
  15065. </select>
  15066. <!-- 病案首页改善率质控评分页(内页)-科室-->
  15067. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  15068. SELECT
  15069. t.*
  15070. FROM
  15071. (
  15072. SELECT DISTINCT
  15073. t1.hospital_id AS hospitalId,
  15074. t1.behospital_code AS behospitalCode,
  15075. t1.bed_code AS bedCode,
  15076. t1.LEVEL AS LEVEL,
  15077. t1.grade_type AS gradeType,
  15078. t1.score_res AS scoreRes,
  15079. t1.NAME AS NAME,
  15080. t1.scoreBn,
  15081. t1.medoupName,
  15082. t1.sex AS sex,
  15083. t1.beh_dept_id AS behDeptId,
  15084. t1.beh_dept_name AS behDeptName,
  15085. t1.doctor_id AS doctorId,
  15086. t1.doctor_name AS doctorName,
  15087. t1.beh_doctor_id AS behDoctorId,
  15088. t1.beh_doctor_name AS behDoctorName,
  15089. t1.director_doctor_id AS directorDoctorId,
  15090. t1.director_doctor_name AS directorDoctorName,
  15091. t1.birthday AS birthday,
  15092. t1.behospital_date AS behospitalDate,
  15093. t1.leave_hospital_date AS leaveHospitalDate,
  15094. t1.placefile_date AS placefileDate,
  15095. t1.gmt_create AS gradeTime,
  15096. t1.diagnose,
  15097. t1.ward_name AS wardName,
  15098. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15099. t1.file_code AS fileCode,
  15100. t1.checkStatus,
  15101. t1.mrStatus,
  15102. t1.chName,
  15103. t1.mrName,
  15104. t1.chTime,
  15105. t1.mrTime
  15106. FROM
  15107. (
  15108. SELECT
  15109. be.*,
  15110. t3.name as medoupName,
  15111. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15112. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15113. mci.check_name AS chName,
  15114. hm_mci.check_name AS mrName,
  15115. e.score_res as scoreBn,
  15116. mci.gmt_create AS chTime,
  15117. hm_mci.gmt_create AS mrTime
  15118. FROM
  15119. (
  15120. SELECT DISTINCT
  15121. a.hospital_id,
  15122. a.behospital_code,
  15123. a.bed_code,
  15124. a.file_code,
  15125. c.LEVEL,
  15126. c.grade_type,
  15127. c.score_res,
  15128. a.NAME,
  15129. a.sex,
  15130. a.beh_dept_id,
  15131. a.beh_dept_name,
  15132. a.birthday,
  15133. a.behospital_date,
  15134. a.leave_hospital_date,
  15135. a.doctor_id,
  15136. a.doctor_name,
  15137. a.beh_doctor_id,
  15138. a.beh_doctor_name,
  15139. a.director_doctor_id,
  15140. a.director_doctor_name,
  15141. a.diagnose,
  15142. a.placefile_date,
  15143. a.ward_name,
  15144. c.gmt_create
  15145. FROM
  15146. med_behospital_info a,
  15147. med_home_page b,
  15148. med_qcresult_info c,
  15149. med_qcresult_cases d,
  15150. sys_user_dept f,
  15151. (
  15152. SELECT
  15153. m4.*
  15154. FROM
  15155. med_behospital_info m1,
  15156. med_home_page m2,
  15157. med_qcresult_info m3,
  15158. med_qcresult_cases m4
  15159. WHERE
  15160. m1.is_deleted = 'N'
  15161. AND m2.is_deleted = 'N'
  15162. AND m3.is_deleted = 'Y'
  15163. AND m4.is_deleted = 'Y'
  15164. AND m1.hospital_id = m2.hospital_id
  15165. AND m1.hospital_id = m3.hospital_id
  15166. AND m1.hospital_id = m4.hospital_id
  15167. AND m1.behospital_code = m2.behospital_code
  15168. AND m1.behospital_code = m3.behospital_code
  15169. AND m1.behospital_code = m4.behospital_code
  15170. AND m3.gmt_create = m4.gmt_create
  15171. AND m3.have_home_page = 1
  15172. AND m4.cases_id = 243
  15173. AND m1.qc_type_id != 0
  15174. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15175. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15176. </if>
  15177. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  15178. AND m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  15179. </if>
  15180. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15181. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15182. </if>
  15183. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15184. <if test="qcResultShortPageVO.startDate != null ">
  15185. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15186. </if>
  15187. <if test="qcResultShortPageVO.endDate != null ">
  15188. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15189. </if>
  15190. </if>
  15191. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15192. <if test="qcResultShortPageVO.startDate != null">
  15193. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15194. </if>
  15195. <if test="qcResultShortPageVO.endDate != null ">
  15196. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15197. </if>
  15198. </if>
  15199. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15200. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15201. </if>
  15202. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  15203. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  15204. </if>
  15205. GROUP BY
  15206. m1.behospital_code
  15207. ORDER BY
  15208. m1.behospital_code,
  15209. m4.gmt_create
  15210. ) e
  15211. WHERE
  15212. a.is_deleted = 'N'
  15213. AND b.is_deleted = 'N'
  15214. AND c.is_deleted = 'N'
  15215. AND d.is_deleted = 'N'
  15216. AND f.is_deleted = 'N'
  15217. AND a.hospital_id = b.hospital_id
  15218. AND a.hospital_id = c.hospital_id
  15219. AND a.hospital_id = d.hospital_id
  15220. AND a.hospital_id = f.hospital_id
  15221. AND a.hospital_id = e.hospital_id
  15222. AND a.behospital_code = b.behospital_code
  15223. AND a.behospital_code = c.behospital_code
  15224. AND a.behospital_code = d.behospital_code
  15225. AND a.beh_dept_id = f.dept_id
  15226. AND a.behospital_code = e.behospital_code
  15227. AND d.cases_id = 243
  15228. AND d.score_res > e.score_res
  15229. AND a.qc_type_id != 0
  15230. <if test="qcResultShortPageVO.userId!=null">
  15231. AND f.user_id = #{qcResultShortPageVO.userId}
  15232. </if>
  15233. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15234. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15235. </if>
  15236. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15237. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15238. </if>
  15239. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  15240. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  15241. </if>
  15242. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15243. <if test="qcResultShortPageVO.startDate != null ">
  15244. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15245. </if>
  15246. <if test="qcResultShortPageVO.endDate != null ">
  15247. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15248. </if>
  15249. </if>
  15250. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15251. <if test="qcResultShortPageVO.startDate != null ">
  15252. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15253. </if>
  15254. <if test="qcResultShortPageVO.endDate != null">
  15255. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15256. </if>
  15257. </if>
  15258. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15259. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15260. </if>
  15261. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  15262. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  15263. </if>
  15264. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15265. AND c.`level` = #{qcResultShortPageVO.level}
  15266. </if>
  15267. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15268. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15269. </if>
  15270. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15271. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15272. </if>
  15273. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15274. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  15275. </if>
  15276. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15277. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15278. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15279. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15280. </if>
  15281. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15282. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15283. </if>
  15284. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15285. AND d.score_res = 20
  15286. </if>
  15287. ) be
  15288. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15289. AND mci.check_type = 0
  15290. AND be.hospital_id = mci.hospital_id
  15291. AND be.behospital_code = mci.behospital_code
  15292. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15293. AND hm_mci.check_type = 1
  15294. AND be.hospital_id = hm_mci.hospital_id
  15295. AND be.behospital_code = hm_mci.behospital_code
  15296. LEFT JOIN med_qcresult_cases e
  15297. on be.behospital_code = e.behospital_code
  15298. and be.hospital_id = e.hospital_id
  15299. AND e.is_deleted = 'N'
  15300. and e.cases_id = 243
  15301. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  15302. and be.hospital_id = t2.hospital_id
  15303. AND t2.is_deleted = 'N'
  15304. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  15305. AND t3.is_deleted = 'N'
  15306. ) t1
  15307. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15308. AND t1.behospital_code = t2.behospital_code
  15309. AND t2.is_deleted = 'N'
  15310. ) t
  15311. WHERE
  15312. 1 = 1
  15313. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  15314. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  15315. </if>
  15316. <if test="qcResultShortPageVO.checkStatus != null">
  15317. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15318. </if>
  15319. <if test="qcResultShortPageVO.mrStatus != null">
  15320. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15321. </if>
  15322. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15323. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15324. </if>
  15325. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15326. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15327. </if>
  15328. <if test="qcResultShortPageVO.chTimeStart != null ">
  15329. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15330. </if>
  15331. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15332. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15333. </if>
  15334. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15335. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15336. </if>
  15337. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15338. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15339. </if>
  15340. </select>
  15341. <!-- 质控核查质控评分页(内页)-->
  15342. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  15343. SELECT
  15344. t.*
  15345. FROM
  15346. (
  15347. SELECT DISTINCT
  15348. t1.hospital_id AS hospitalId,
  15349. t1.behospital_code AS behospitalCode,
  15350. t1.bed_code AS bedCode,
  15351. t1.LEVEL AS LEVEL,
  15352. t1.grade_type AS gradeType,
  15353. t1.score_res AS scoreRes,
  15354. t1.scoreBn,
  15355. t1.NAME AS NAME,
  15356. t1.sex AS sex,
  15357. t1.beh_dept_id AS behDeptId,
  15358. t1.beh_dept_name AS behDeptName,
  15359. t1.doctor_id AS doctorId,
  15360. t1.doctor_name AS doctorName,
  15361. t1.beh_doctor_id AS behDoctorId,
  15362. t1.beh_doctor_name AS behDoctorName,
  15363. t1.director_doctor_id AS directorDoctorId,
  15364. t1.director_doctor_name AS directorDoctorName,
  15365. t1.birthday AS birthday,
  15366. t1.behospital_date AS behospitalDate,
  15367. t1.leave_hospital_date AS leaveHospitalDate,
  15368. t1.placefile_date AS placefileDate,
  15369. t1.gmt_create AS gradeTime,
  15370. t1.diagnose,
  15371. t1.ward_name AS wardName,
  15372. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15373. t1.file_code AS fileCode,
  15374. t1.checkStatus,
  15375. t1.mrStatus,
  15376. t1.chName,
  15377. t1.mrName,
  15378. t1.chTime,
  15379. t1.mrTime
  15380. FROM
  15381. (
  15382. SELECT
  15383. be.*,
  15384. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15385. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15386. mci.check_name AS chName,
  15387. e.score_res as scoreBn,
  15388. hm_mci.check_name AS mrName,
  15389. mci.gmt_create AS chTime,
  15390. hm_mci.gmt_create AS mrTime
  15391. FROM
  15392. (
  15393. SELECT DISTINCT
  15394. a.hospital_id,
  15395. a.behospital_code,
  15396. a.bed_code,
  15397. a.file_code,
  15398. b.LEVEL,
  15399. b.grade_type,
  15400. b.score_res,
  15401. a.NAME,
  15402. a.sex,
  15403. a.beh_dept_id,
  15404. a.beh_dept_name,
  15405. a.birthday,
  15406. a.behospital_date,
  15407. a.leave_hospital_date,
  15408. a.doctor_id,
  15409. a.doctor_name,
  15410. a.beh_doctor_id,
  15411. a.beh_doctor_name,
  15412. a.director_doctor_id,
  15413. a.director_doctor_name,
  15414. a.diagnose,
  15415. a.placefile_date,
  15416. a.ward_name,
  15417. b.gmt_create
  15418. FROM
  15419. med_behospital_info a,
  15420. med_qcresult_info b
  15421. WHERE
  15422. a.is_deleted = 'N'
  15423. AND b.is_deleted = 'N'
  15424. AND a.hospital_id = b.hospital_id
  15425. AND a.behospital_code = b.behospital_code
  15426. AND a.qc_type_id != 0
  15427. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15428. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15429. </if>
  15430. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15431. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15432. </if>
  15433. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15434. <if test="qcResultShortPageVO.startDate != null ">
  15435. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15436. </if>
  15437. <if test="qcResultShortPageVO.endDate != null ">
  15438. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15439. </if>
  15440. </if>
  15441. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15442. <if test="qcResultShortPageVO.startDate != null ">
  15443. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15444. </if>
  15445. <if test="qcResultShortPageVO.endDate != null">
  15446. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15447. </if>
  15448. </if>
  15449. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15450. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15451. </if>
  15452. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15453. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15454. </if>
  15455. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15456. AND b.`level` = #{qcResultShortPageVO.level}
  15457. </if>
  15458. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15459. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15460. </if>
  15461. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15462. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15463. </if>
  15464. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15465. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15466. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15467. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15468. </if>
  15469. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15470. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15471. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15472. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15473. </if>
  15474. ) be
  15475. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15476. AND mci.check_type = 0
  15477. AND be.hospital_id = mci.hospital_id
  15478. AND be.behospital_code = mci.behospital_code
  15479. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15480. AND hm_mci.check_type = 1
  15481. AND be.hospital_id = hm_mci.hospital_id
  15482. AND be.behospital_code = hm_mci.behospital_code
  15483. LEFT JOIN med_qcresult_cases e
  15484. on be.behospital_code = e.behospital_code
  15485. and be.hospital_id = e.hospital_id
  15486. AND e.is_deleted = 'N'
  15487. and e.cases_id = 243
  15488. ) t1
  15489. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15490. AND t1.behospital_code = t2.behospital_code
  15491. AND t2.is_deleted = 'N'
  15492. ) t
  15493. WHERE
  15494. 1 = 1
  15495. <if test="qcResultShortPageVO.checkStatus != null">
  15496. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15497. </if>
  15498. <if test="qcResultShortPageVO.mrStatus != null">
  15499. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15500. </if>
  15501. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15502. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15503. </if>
  15504. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15505. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15506. </if>
  15507. <if test="qcResultShortPageVO.chTimeStart != null ">
  15508. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15509. </if>
  15510. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15511. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15512. </if>
  15513. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15514. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15515. </if>
  15516. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15517. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15518. </if>
  15519. </select>
  15520. <!-- 质控核查质控评分页-科室(内页)-->
  15521. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  15522. SELECT
  15523. t.*
  15524. FROM
  15525. (
  15526. SELECT DISTINCT
  15527. t1.hospital_id AS hospitalId,
  15528. t1.behospital_code AS behospitalCode,
  15529. t1.bed_code AS bedCode,
  15530. t1.LEVEL AS LEVEL,
  15531. t1.grade_type AS gradeType,
  15532. t1.score_res AS scoreRes,
  15533. t1.scoreBn,
  15534. t1.medoupName,
  15535. t1.NAME AS NAME,
  15536. t1.sex AS sex,
  15537. t1.beh_dept_id AS behDeptId,
  15538. t1.beh_dept_name AS behDeptName,
  15539. t1.doctor_id AS doctorId,
  15540. t1.doctor_name AS doctorName,
  15541. t1.beh_doctor_id AS behDoctorId,
  15542. t1.beh_doctor_name AS behDoctorName,
  15543. t1.director_doctor_id AS directorDoctorId,
  15544. t1.director_doctor_name AS directorDoctorName,
  15545. t1.birthday AS birthday,
  15546. t1.behospital_date AS behospitalDate,
  15547. t1.leave_hospital_date AS leaveHospitalDate,
  15548. t1.placefile_date AS placefileDate,
  15549. t1.gmt_create AS gradeTime,
  15550. t1.diagnose,
  15551. t1.ward_name AS wardName,
  15552. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15553. t1.file_code AS fileCode,
  15554. t1.checkStatus,
  15555. t1.mrStatus,
  15556. t1.chName,
  15557. t1.mrName,
  15558. t1.chTime,
  15559. t1.mrTime
  15560. FROM
  15561. (
  15562. SELECT
  15563. be.*,
  15564. t3.name as medoupName,
  15565. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15566. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15567. mci.check_name AS chName,
  15568. e.score_res as scoreBn,
  15569. hm_mci.check_name AS mrName,
  15570. mci.gmt_create AS chTime,
  15571. hm_mci.gmt_create AS mrTime
  15572. FROM
  15573. (
  15574. SELECT DISTINCT
  15575. a.hospital_id,
  15576. a.behospital_code,
  15577. a.bed_code,
  15578. a.file_code,
  15579. b.LEVEL,
  15580. b.grade_type,
  15581. b.score_res,
  15582. a.NAME,
  15583. a.sex,
  15584. a.beh_dept_id,
  15585. a.beh_dept_name,
  15586. a.birthday,
  15587. a.behospital_date,
  15588. a.leave_hospital_date,
  15589. a.doctor_id,
  15590. a.doctor_name,
  15591. a.beh_doctor_id,
  15592. a.beh_doctor_name,
  15593. a.director_doctor_id,
  15594. a.director_doctor_name,
  15595. a.diagnose,
  15596. a.placefile_date,
  15597. a.ward_name,
  15598. b.gmt_create
  15599. FROM
  15600. med_behospital_info a,
  15601. med_qcresult_info b,
  15602. sys_user_dept c
  15603. WHERE
  15604. a.is_deleted = 'N'
  15605. AND b.is_deleted = 'N'
  15606. AND c.is_deleted = 'N'
  15607. AND a.hospital_id = b.hospital_id
  15608. AND a.hospital_id = c.hospital_id
  15609. AND a.beh_dept_id = c.dept_id
  15610. AND a.behospital_code = b.behospital_code
  15611. AND a.qc_type_id != 0
  15612. <if test="qcResultShortPageVO.userId!=null">
  15613. AND c.user_id = #{qcResultShortPageVO.userId}
  15614. </if>
  15615. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15616. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15617. </if>
  15618. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  15619. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  15620. </if>
  15621. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15622. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15623. </if>
  15624. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15625. <if test="qcResultShortPageVO.startDate != null ">
  15626. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15627. </if>
  15628. <if test="qcResultShortPageVO.endDate != null ">
  15629. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15630. </if>
  15631. </if>
  15632. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15633. <if test="qcResultShortPageVO.startDate != null ">
  15634. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15635. </if>
  15636. <if test="qcResultShortPageVO.endDate != null">
  15637. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15638. </if>
  15639. </if>
  15640. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15641. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15642. </if>
  15643. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15644. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15645. </if>
  15646. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  15647. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  15648. </if>
  15649. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15650. AND b.`level` = #{qcResultShortPageVO.level}
  15651. </if>
  15652. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15653. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15654. </if>
  15655. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15656. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15657. </if>
  15658. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15659. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  15660. </if>
  15661. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15662. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15663. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15664. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15665. </if>
  15666. ) be
  15667. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15668. AND mci.check_type = 0
  15669. AND be.hospital_id = mci.hospital_id
  15670. AND be.behospital_code = mci.behospital_code
  15671. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15672. AND hm_mci.check_type = 1
  15673. AND be.hospital_id = hm_mci.hospital_id
  15674. AND be.behospital_code = hm_mci.behospital_code
  15675. LEFT JOIN med_qcresult_cases e
  15676. on be.behospital_code = e.behospital_code
  15677. and be.hospital_id = e.hospital_id
  15678. AND e.is_deleted = 'N'
  15679. and e.cases_id = 243
  15680. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  15681. and be.hospital_id = t2.hospital_id
  15682. AND t2.is_deleted = 'N'
  15683. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  15684. AND t3.is_deleted = 'N'
  15685. ) t1
  15686. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15687. AND t1.behospital_code = t2.behospital_code
  15688. AND t2.is_deleted = 'N'
  15689. ) t
  15690. WHERE
  15691. 1 = 1
  15692. <if test="qcResultShortPageVO.checkStatus != null">
  15693. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15694. </if>
  15695. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  15696. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  15697. </if>
  15698. <if test="qcResultShortPageVO.mrStatus != null">
  15699. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15700. </if>
  15701. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15702. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15703. </if>
  15704. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15705. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15706. </if>
  15707. <if test="qcResultShortPageVO.chTimeStart != null ">
  15708. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15709. </if>
  15710. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15711. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15712. </if>
  15713. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15714. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15715. </if>
  15716. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15717. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15718. </if>
  15719. </select>
  15720. <!-- 病案首页改善率质控评分页导出-->
  15721. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  15722. SELECT
  15723. f1.behDeptId,
  15724. f1.behDeptName,
  15725. f1.doctorName,
  15726. f1.patName,
  15727. f1.behospitalCode,
  15728. f1.hospitalId,
  15729. f1.behospitalDate,
  15730. f1.leaveHospitalDate,
  15731. f1.score,
  15732. f2.avgScore,
  15733. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15734. f1.msg,
  15735. f1.caseName,
  15736. </if>
  15737. f1.checkStatus,
  15738. f1.mrStatus,
  15739. f1.chName,
  15740. f1.mrName,
  15741. f1.chTime,
  15742. f1.mrTime
  15743. FROM
  15744. (SELECT
  15745. t.doctorName AS behDoctorName,
  15746. t.`name` AS patName,
  15747. t.behospitalCode AS behospitalCode,
  15748. t.behospitalDate AS behospitalDate,
  15749. t.leaveHospitalDate AS leaveHospitalDate,
  15750. qi.score_res AS score,
  15751. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15752. qd.msg AS msg,
  15753. qc.NAME AS caseName,
  15754. </if>
  15755. t.behDeptId,
  15756. t.behDeptName,
  15757. t.hospitalId,
  15758. t.checkStatus,
  15759. t.mrStatus,
  15760. t.chName,
  15761. t.mrName,
  15762. t.chTime,
  15763. t.mrTime
  15764. FROM
  15765. (
  15766. SELECT DISTINCT
  15767. t1.hospital_id AS hospitalId,
  15768. t1.behospital_code AS behospitalCode,
  15769. t1.bed_code AS bedCode,
  15770. t1.LEVEL AS LEVEL,
  15771. t1.grade_type AS gradeType,
  15772. t1.score_res AS scoreRes,
  15773. t1.NAME AS NAME,
  15774. t1.sex AS sex,
  15775. t1.beh_dept_id AS behDeptId,
  15776. t1.beh_dept_name AS behDeptName,
  15777. t1.doctor_id AS doctorId,
  15778. t1.doctor_name AS doctorName,
  15779. t1.beh_doctor_id AS behDoctorId,
  15780. t1.beh_doctor_name AS behDoctorName,
  15781. t1.director_doctor_id AS directorDoctorId,
  15782. t1.director_doctor_name AS directorDoctorName,
  15783. t1.birthday AS birthday,
  15784. t1.behospital_date AS behospitalDate,
  15785. t1.leave_hospital_date AS leaveHospitalDate,
  15786. t1.placefile_date AS placefileDate,
  15787. t1.gmt_create AS gradeTime,
  15788. t1.diagnose,
  15789. t1.ward_name AS wardName,
  15790. t2.age,
  15791. t1.file_code AS fileCode,
  15792. t1.checkStatus,
  15793. t1.mrStatus,
  15794. t1.chName,
  15795. t1.mrName,
  15796. t1.chTime,
  15797. t1.mrTime
  15798. FROM
  15799. (
  15800. SELECT
  15801. be.*,
  15802. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15803. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15804. mci.check_name AS chName,
  15805. hm_mci.check_name AS mrName,
  15806. mci.gmt_create AS chTime,
  15807. hm_mci.gmt_create AS mrTime
  15808. FROM
  15809. (
  15810. SELECT DISTINCT
  15811. a.hospital_id,
  15812. a.behospital_code,
  15813. a.bed_code,
  15814. a.file_code,
  15815. c.LEVEL,
  15816. c.grade_type,
  15817. c.score_res,
  15818. a.NAME,
  15819. a.sex,
  15820. a.beh_dept_id,
  15821. a.beh_dept_name,
  15822. a.birthday,
  15823. a.behospital_date,
  15824. a.leave_hospital_date,
  15825. a.doctor_id,
  15826. a.doctor_name,
  15827. a.beh_doctor_id,
  15828. a.beh_doctor_name,
  15829. a.director_doctor_id,
  15830. a.director_doctor_name,
  15831. a.diagnose,
  15832. a.placefile_date,
  15833. a.ward_name,
  15834. c.gmt_create
  15835. FROM
  15836. med_behospital_info a,
  15837. med_home_page b,
  15838. med_qcresult_info c,
  15839. med_qcresult_cases d,
  15840. (
  15841. SELECT
  15842. m4.*
  15843. FROM
  15844. med_behospital_info m1,
  15845. med_home_page m2,
  15846. med_qcresult_info m3,
  15847. med_qcresult_cases m4
  15848. WHERE
  15849. m1.is_deleted = 'N'
  15850. AND m2.is_deleted = 'N'
  15851. AND m3.is_deleted = 'Y'
  15852. AND m4.is_deleted = 'Y'
  15853. AND m1.hospital_id = m2.hospital_id
  15854. AND m1.hospital_id = m3.hospital_id
  15855. AND m1.hospital_id = m4.hospital_id
  15856. AND m1.behospital_code = m2.behospital_code
  15857. AND m1.behospital_code = m3.behospital_code
  15858. AND m1.behospital_code = m4.behospital_code
  15859. AND m3.gmt_create = m4.gmt_create
  15860. AND m3.have_home_page = 1
  15861. AND m4.cases_id = 243
  15862. AND m1.qc_type_id != 0
  15863. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15864. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15865. </if>
  15866. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15867. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15868. </if>
  15869. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15870. <if test="qcResultShortPageVO.startDate != null ">
  15871. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15872. </if>
  15873. <if test="qcResultShortPageVO.endDate != null ">
  15874. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15875. </if>
  15876. </if>
  15877. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15878. <if test="qcResultShortPageVO.startDate != null">
  15879. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15880. </if>
  15881. <if test="qcResultShortPageVO.endDate != null ">
  15882. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15883. </if>
  15884. </if>
  15885. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15886. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15887. </if>
  15888. GROUP BY
  15889. m1.behospital_code
  15890. ORDER BY
  15891. m1.behospital_code,
  15892. m4.gmt_create
  15893. ) e
  15894. WHERE
  15895. a.is_deleted = 'N'
  15896. AND b.is_deleted = 'N'
  15897. AND c.is_deleted = 'N'
  15898. AND d.is_deleted = 'N'
  15899. AND a.hospital_id = b.hospital_id
  15900. AND a.hospital_id = c.hospital_id
  15901. AND a.hospital_id = d.hospital_id
  15902. AND a.hospital_id = e.hospital_id
  15903. AND a.behospital_code = b.behospital_code
  15904. AND a.behospital_code = c.behospital_code
  15905. AND a.behospital_code = d.behospital_code
  15906. AND a.behospital_code = e.behospital_code
  15907. AND d.cases_id = 243
  15908. AND d.score_res > e.score_res
  15909. AND a.qc_type_id != 0
  15910. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15911. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15912. </if>
  15913. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15914. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15915. </if>
  15916. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15917. <if test="qcResultShortPageVO.startDate != null ">
  15918. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15919. </if>
  15920. <if test="qcResultShortPageVO.endDate != null ">
  15921. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15922. </if>
  15923. </if>
  15924. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15925. <if test="qcResultShortPageVO.startDate != null ">
  15926. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15927. </if>
  15928. <if test="qcResultShortPageVO.endDate != null">
  15929. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15930. </if>
  15931. </if>
  15932. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15933. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15934. </if>
  15935. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15936. AND c.`level` = #{qcResultShortPageVO.level}
  15937. </if>
  15938. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15939. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15940. </if>
  15941. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15942. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15943. </if>
  15944. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15945. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15946. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15947. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15948. </if>
  15949. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15950. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15951. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15952. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15953. </if>
  15954. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15955. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15956. </if>
  15957. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15958. AND d.score_res = 20
  15959. </if>
  15960. ) be
  15961. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15962. AND mci.check_type = 0
  15963. AND be.hospital_id = mci.hospital_id
  15964. AND be.behospital_code = mci.behospital_code
  15965. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15966. AND hm_mci.check_type = 1
  15967. AND be.hospital_id = hm_mci.hospital_id
  15968. AND be.behospital_code = hm_mci.behospital_code
  15969. ) t1
  15970. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15971. AND t1.behospital_code = t2.behospital_code
  15972. AND t2.is_deleted = 'N'
  15973. ) t
  15974. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15975. AND t.hospitalId = qi.hospital_id
  15976. AND t.behospitalCode = qi.behospital_code
  15977. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15978. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15979. AND t.hospitalId = qd.hospital_id
  15980. AND t.behospitalCode = qd.behospital_code
  15981. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15982. AND qd.cases_id = qc.id
  15983. </if>
  15984. where 1=1
  15985. <if test="qcResultShortPageVO.checkStatus != null">
  15986. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15987. </if>
  15988. <if test="qcResultShortPageVO.mrStatus != null">
  15989. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15990. </if>
  15991. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15992. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15993. </if>
  15994. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15995. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15996. </if>
  15997. <if test="qcResultShortPageVO.chTimeStart != null ">
  15998. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15999. </if>
  16000. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16001. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16002. </if>
  16003. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16004. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16005. </if>
  16006. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16007. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16008. </if>
  16009. )f1,
  16010. (SELECT
  16011. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16012. t.behDeptId,
  16013. t.behDeptName
  16014. FROM
  16015. (
  16016. SELECT DISTINCT
  16017. t1.hospital_id AS hospitalId,
  16018. t1.behospital_code AS behospitalCode,
  16019. t1.bed_code AS bedCode,
  16020. t1.LEVEL AS LEVEL,
  16021. t1.grade_type AS gradeType,
  16022. t1.score_res AS scoreRes,
  16023. t1.NAME AS NAME,
  16024. t1.sex AS sex,
  16025. t1.beh_dept_id AS behDeptId,
  16026. t1.beh_dept_name AS behDeptName,
  16027. t1.doctor_id AS doctorId,
  16028. t1.doctor_name AS doctorName,
  16029. t1.beh_doctor_id AS behDoctorId,
  16030. t1.beh_doctor_name AS behDoctorName,
  16031. t1.director_doctor_id AS directorDoctorId,
  16032. t1.director_doctor_name AS directorDoctorName,
  16033. t1.birthday AS birthday,
  16034. t1.behospital_date AS behospitalDate,
  16035. t1.leave_hospital_date AS leaveHospitalDate,
  16036. t1.placefile_date AS placefileDate,
  16037. t1.gmt_create AS gradeTime,
  16038. t1.diagnose,
  16039. t1.ward_name AS wardName,
  16040. t2.age,
  16041. t1.file_code AS fileCode,
  16042. t1.checkStatus,
  16043. t1.mrStatus,
  16044. t1.chName,
  16045. t1.mrName,
  16046. t1.chTime,
  16047. t1.mrTime
  16048. FROM
  16049. (
  16050. SELECT
  16051. be.*,
  16052. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16053. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16054. mci.check_name AS chName,
  16055. hm_mci.check_name AS mrName,
  16056. mci.gmt_create AS chTime,
  16057. hm_mci.gmt_create AS mrTime
  16058. FROM
  16059. (
  16060. SELECT DISTINCT
  16061. a.hospital_id,
  16062. a.behospital_code,
  16063. a.bed_code,
  16064. a.file_code,
  16065. c.LEVEL,
  16066. c.grade_type,
  16067. c.score_res,
  16068. a.NAME,
  16069. a.sex,
  16070. a.beh_dept_id,
  16071. a.beh_dept_name,
  16072. a.birthday,
  16073. a.behospital_date,
  16074. a.leave_hospital_date,
  16075. a.doctor_id,
  16076. a.doctor_name,
  16077. a.beh_doctor_id,
  16078. a.beh_doctor_name,
  16079. a.director_doctor_id,
  16080. a.director_doctor_name,
  16081. a.diagnose,
  16082. a.placefile_date,
  16083. a.ward_name,
  16084. c.gmt_create
  16085. FROM
  16086. med_behospital_info a,
  16087. med_home_page b,
  16088. med_qcresult_info c,
  16089. med_qcresult_cases d,
  16090. (
  16091. SELECT
  16092. m4.*
  16093. FROM
  16094. med_behospital_info m1,
  16095. med_home_page m2,
  16096. med_qcresult_info m3,
  16097. med_qcresult_cases m4
  16098. WHERE
  16099. m1.is_deleted = 'N'
  16100. AND m2.is_deleted = 'N'
  16101. AND m3.is_deleted = 'Y'
  16102. AND m4.is_deleted = 'Y'
  16103. AND m1.hospital_id = m2.hospital_id
  16104. AND m1.hospital_id = m3.hospital_id
  16105. AND m1.hospital_id = m4.hospital_id
  16106. AND m1.behospital_code = m2.behospital_code
  16107. AND m1.behospital_code = m3.behospital_code
  16108. AND m1.behospital_code = m4.behospital_code
  16109. AND m3.gmt_create = m4.gmt_create
  16110. AND m3.have_home_page = 1
  16111. AND m4.cases_id = 243
  16112. AND m1.qc_type_id != 0
  16113. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16114. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16115. </if>
  16116. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16117. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16118. </if>
  16119. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16120. <if test="qcResultShortPageVO.startDate != null ">
  16121. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16122. </if>
  16123. <if test="qcResultShortPageVO.endDate != null ">
  16124. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16125. </if>
  16126. </if>
  16127. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16128. <if test="qcResultShortPageVO.startDate != null">
  16129. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16130. </if>
  16131. <if test="qcResultShortPageVO.endDate != null ">
  16132. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16133. </if>
  16134. </if>
  16135. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16136. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16137. </if>
  16138. GROUP BY
  16139. m1.behospital_code
  16140. ORDER BY
  16141. m1.behospital_code,
  16142. m4.gmt_create
  16143. ) e
  16144. WHERE
  16145. a.is_deleted = 'N'
  16146. AND b.is_deleted = 'N'
  16147. AND c.is_deleted = 'N'
  16148. AND d.is_deleted = 'N'
  16149. AND a.hospital_id = b.hospital_id
  16150. AND a.hospital_id = c.hospital_id
  16151. AND a.hospital_id = d.hospital_id
  16152. AND a.hospital_id = e.hospital_id
  16153. AND a.behospital_code = b.behospital_code
  16154. AND a.behospital_code = c.behospital_code
  16155. AND a.behospital_code = d.behospital_code
  16156. AND a.behospital_code = e.behospital_code
  16157. AND d.cases_id = 243
  16158. AND d.score_res > e.score_res
  16159. AND a.qc_type_id != 0
  16160. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16161. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16162. </if>
  16163. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16164. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16165. </if>
  16166. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16167. <if test="qcResultShortPageVO.startDate != null ">
  16168. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16169. </if>
  16170. <if test="qcResultShortPageVO.endDate != null ">
  16171. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16172. </if>
  16173. </if>
  16174. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16175. <if test="qcResultShortPageVO.startDate != null ">
  16176. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16177. </if>
  16178. <if test="qcResultShortPageVO.endDate != null">
  16179. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16180. </if>
  16181. </if>
  16182. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16183. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16184. </if>
  16185. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16186. AND c.`level` = #{qcResultShortPageVO.level}
  16187. </if>
  16188. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16189. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16190. </if>
  16191. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16192. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16193. </if>
  16194. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16195. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16196. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16197. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16198. </if>
  16199. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16200. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16201. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16202. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16203. </if>
  16204. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16205. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16206. </if>
  16207. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16208. AND d.score_res = 20
  16209. </if>
  16210. ) be
  16211. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16212. AND mci.check_type = 0
  16213. AND be.hospital_id = mci.hospital_id
  16214. AND be.behospital_code = mci.behospital_code
  16215. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16216. AND hm_mci.check_type = 1
  16217. AND be.hospital_id = hm_mci.hospital_id
  16218. AND be.behospital_code = hm_mci.behospital_code
  16219. ) t1
  16220. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16221. AND t1.behospital_code = t2.behospital_code
  16222. AND t2.is_deleted = 'N'
  16223. ) t
  16224. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16225. AND t.hospitalId = qi.hospital_id
  16226. AND t.behospitalCode = qi.behospital_code
  16227. where 1=1
  16228. <if test="qcResultShortPageVO.checkStatus != null">
  16229. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16230. </if>
  16231. <if test="qcResultShortPageVO.mrStatus != null">
  16232. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16233. </if>
  16234. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16235. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16236. </if>
  16237. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16238. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16239. </if>
  16240. <if test="qcResultShortPageVO.chTimeStart != null ">
  16241. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16242. </if>
  16243. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16244. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16245. </if>
  16246. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16247. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16248. </if>
  16249. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16250. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16251. </if>
  16252. GROUP BY
  16253. t.behDeptId,
  16254. t.behDeptName
  16255. )f2
  16256. WHERE
  16257. f1.behDeptId = f2.behDeptId
  16258. AND f1.behDeptName = f2.behDeptName
  16259. </select>
  16260. <!-- 病案首页改善率质控评分页导出-->
  16261. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  16262. SELECT
  16263. f1.behDeptId,
  16264. f1.behDeptName,
  16265. f1.wardName,
  16266. f1.medoupName,
  16267. f1.doctorId,
  16268. f1.doctorName,
  16269. f1.patName,
  16270. f1.behospitalCode,
  16271. f1.hospitalId,
  16272. f1.scoreBn,
  16273. f1.behospitalDate,
  16274. f1.leaveHospitalDate,
  16275. f1.score,
  16276. f2.avgScore,
  16277. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16278. f1.msg,
  16279. f1.caseName,
  16280. </if>
  16281. f1.checkStatus,
  16282. f1.mrStatus,
  16283. f1.chName,
  16284. f1.mrName,
  16285. f1.chTime,
  16286. f1.mrTime
  16287. FROM
  16288. (SELECT
  16289. t.doctorId,
  16290. t.doctorName,
  16291. t.`name` AS patName,
  16292. t.behospitalCode AS behospitalCode,
  16293. t.behospitalDate AS behospitalDate,
  16294. t.leaveHospitalDate AS leaveHospitalDate,
  16295. qi.score_res AS score,
  16296. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16297. qd.msg AS msg,
  16298. qc.NAME AS caseName,
  16299. </if>
  16300. t.behDeptId,
  16301. t.behDeptName,
  16302. t.wardName,
  16303. t.scoreBn,
  16304. t3.name as medoupName,
  16305. t.hospitalId,
  16306. t.checkStatus,
  16307. t.mrStatus,
  16308. t.chName,
  16309. t.mrName,
  16310. t.chTime,
  16311. t.mrTime
  16312. FROM
  16313. (
  16314. SELECT DISTINCT
  16315. t1.hospital_id AS hospitalId,
  16316. t1.behospital_code AS behospitalCode,
  16317. t1.bed_code AS bedCode,
  16318. t1.LEVEL AS LEVEL,
  16319. t1.grade_type AS gradeType,
  16320. t1.score_res AS scoreRes,
  16321. t1.NAME AS NAME,
  16322. t1.sex AS sex,
  16323. t1.beh_dept_id AS behDeptId,
  16324. t1.beh_dept_name AS behDeptName,
  16325. t1.doctor_id AS doctorId,
  16326. t1.doctor_name AS doctorName,
  16327. t1.beh_doctor_id AS behDoctorId,
  16328. t1.beh_doctor_name AS behDoctorName,
  16329. t1.director_doctor_id AS directorDoctorId,
  16330. t1.director_doctor_name AS directorDoctorName,
  16331. t1.birthday AS birthday,
  16332. t1.behospital_date AS behospitalDate,
  16333. t1.leave_hospital_date AS leaveHospitalDate,
  16334. t1.placefile_date AS placefileDate,
  16335. t1.gmt_create AS gradeTime,
  16336. t1.diagnose,
  16337. t1.ward_name AS wardName,
  16338. t1.scoreBn,
  16339. t1.file_code AS fileCode,
  16340. t1.checkStatus,
  16341. t1.mrStatus,
  16342. t1.chName,
  16343. t1.mrName,
  16344. t1.chTime,
  16345. t1.mrTime
  16346. FROM
  16347. (
  16348. SELECT
  16349. be.*,
  16350. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16351. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16352. mci.check_name AS chName,
  16353. e.score_res as scoreBn,
  16354. hm_mci.check_name AS mrName,
  16355. mci.gmt_create AS chTime,
  16356. hm_mci.gmt_create AS mrTime
  16357. FROM
  16358. (
  16359. SELECT DISTINCT
  16360. a.hospital_id,
  16361. a.behospital_code,
  16362. a.bed_code,
  16363. a.file_code,
  16364. c.LEVEL,
  16365. c.grade_type,
  16366. c.score_res,
  16367. a.NAME,
  16368. a.sex,
  16369. a.beh_dept_id,
  16370. a.beh_dept_name,
  16371. a.birthday,
  16372. a.behospital_date,
  16373. a.leave_hospital_date,
  16374. a.doctor_id,
  16375. a.doctor_name,
  16376. a.beh_doctor_id,
  16377. a.beh_doctor_name,
  16378. a.director_doctor_id,
  16379. a.director_doctor_name,
  16380. a.diagnose,
  16381. a.placefile_date,
  16382. a.ward_name,
  16383. c.gmt_create
  16384. FROM
  16385. med_behospital_info a,
  16386. med_home_page b,
  16387. med_qcresult_info c,
  16388. med_qcresult_cases d,
  16389. sys_user_dept f,
  16390. (
  16391. SELECT
  16392. m4.*
  16393. FROM
  16394. med_behospital_info m1,
  16395. med_home_page m2,
  16396. med_qcresult_info m3,
  16397. med_qcresult_cases m4
  16398. WHERE
  16399. m1.is_deleted = 'N'
  16400. AND m2.is_deleted = 'N'
  16401. AND m3.is_deleted = 'Y'
  16402. AND m4.is_deleted = 'Y'
  16403. AND m1.hospital_id = m2.hospital_id
  16404. AND m1.hospital_id = m3.hospital_id
  16405. AND m1.hospital_id = m4.hospital_id
  16406. AND m1.behospital_code = m2.behospital_code
  16407. AND m1.behospital_code = m3.behospital_code
  16408. AND m1.behospital_code = m4.behospital_code
  16409. AND m3.gmt_create = m4.gmt_create
  16410. AND m3.have_home_page = 1
  16411. AND m4.cases_id = 243
  16412. AND m1.qc_type_id != 0
  16413. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16414. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16415. </if>
  16416. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16417. and m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16418. </if>
  16419. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16420. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16421. </if>
  16422. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16423. <if test="qcResultShortPageVO.startDate != null ">
  16424. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16425. </if>
  16426. <if test="qcResultShortPageVO.endDate != null ">
  16427. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16428. </if>
  16429. </if>
  16430. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16431. <if test="qcResultShortPageVO.startDate != null">
  16432. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16433. </if>
  16434. <if test="qcResultShortPageVO.endDate != null ">
  16435. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16436. </if>
  16437. </if>
  16438. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16439. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16440. </if>
  16441. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16442. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  16443. </if>
  16444. GROUP BY
  16445. m1.behospital_code
  16446. ORDER BY
  16447. m1.behospital_code,
  16448. m4.gmt_create
  16449. ) e
  16450. WHERE
  16451. a.is_deleted = 'N'
  16452. AND b.is_deleted = 'N'
  16453. AND c.is_deleted = 'N'
  16454. AND d.is_deleted = 'N'
  16455. AND f.is_deleted = 'N'
  16456. AND a.hospital_id = b.hospital_id
  16457. AND a.hospital_id = c.hospital_id
  16458. AND a.hospital_id = d.hospital_id
  16459. AND a.hospital_id = e.hospital_id
  16460. AND a.hospital_id = f.hospital_id
  16461. AND a.behospital_code = b.behospital_code
  16462. AND a.behospital_code = c.behospital_code
  16463. AND a.behospital_code = d.behospital_code
  16464. AND a.behospital_code = e.behospital_code
  16465. AND a.beh_dept_id = f.dept_id
  16466. AND d.cases_id = 243
  16467. AND d.score_res > e.score_res
  16468. AND a.qc_type_id != 0
  16469. <if test="qcResultShortPageVO.userId!=null">
  16470. AND f.user_id = #{qcResultShortPageVO.userId}
  16471. </if>
  16472. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16473. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16474. </if>
  16475. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16476. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16477. </if>
  16478. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16479. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16480. </if>
  16481. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16482. <if test="qcResultShortPageVO.startDate != null ">
  16483. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16484. </if>
  16485. <if test="qcResultShortPageVO.endDate != null ">
  16486. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16487. </if>
  16488. </if>
  16489. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16490. <if test="qcResultShortPageVO.startDate != null ">
  16491. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16492. </if>
  16493. <if test="qcResultShortPageVO.endDate != null">
  16494. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16495. </if>
  16496. </if>
  16497. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16498. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16499. </if>
  16500. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16501. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  16502. </if>
  16503. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16504. AND c.`level` = #{qcResultShortPageVO.level}
  16505. </if>
  16506. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16507. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16508. </if>
  16509. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16510. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16511. </if>
  16512. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16513. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  16514. </if>
  16515. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16516. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16517. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16518. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16519. </if>
  16520. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16521. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16522. </if>
  16523. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16524. AND d.score_res = 20
  16525. </if>
  16526. ) be
  16527. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16528. AND mci.check_type = 0
  16529. AND be.hospital_id = mci.hospital_id
  16530. AND be.behospital_code = mci.behospital_code
  16531. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16532. AND hm_mci.check_type = 1
  16533. AND be.hospital_id = hm_mci.hospital_id
  16534. AND be.behospital_code = hm_mci.behospital_code
  16535. LEFT JOIN med_qcresult_cases e
  16536. on be.behospital_code = e.behospital_code
  16537. and be.hospital_id = e.hospital_id
  16538. AND e.is_deleted = 'N'
  16539. and e.cases_id = 243
  16540. ) t1
  16541. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16542. AND t1.behospital_code = t2.behospital_code
  16543. AND t2.is_deleted = 'N'
  16544. ) t
  16545. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16546. AND t.hospitalId = qi.hospital_id
  16547. AND t.behospitalCode = qi.behospital_code
  16548. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  16549. AND t.hospitalId = t2.hospital_id
  16550. AND t2.is_deleted = 'N'
  16551. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  16552. AND t3.is_deleted = 'N'
  16553. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16554. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16555. AND t.hospitalId = qd.hospital_id
  16556. AND t.behospitalCode = qd.behospital_code
  16557. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16558. AND qd.cases_id = qc.id
  16559. </if>
  16560. where 1=1
  16561. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  16562. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  16563. </if>
  16564. <if test="qcResultShortPageVO.checkStatus != null">
  16565. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16566. </if>
  16567. <if test="qcResultShortPageVO.mrStatus != null">
  16568. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16569. </if>
  16570. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16571. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16572. </if>
  16573. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16574. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16575. </if>
  16576. <if test="qcResultShortPageVO.chTimeStart != null ">
  16577. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16578. </if>
  16579. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16580. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16581. </if>
  16582. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16583. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16584. </if>
  16585. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16586. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16587. </if>
  16588. )f1,
  16589. (SELECT
  16590. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16591. t.behDeptId,
  16592. t.behDeptName,
  16593. t.doctorId,
  16594. t.doctorName
  16595. FROM
  16596. (
  16597. SELECT DISTINCT
  16598. t1.hospital_id AS hospitalId,
  16599. t1.behospital_code AS behospitalCode,
  16600. t1.bed_code AS bedCode,
  16601. t1.LEVEL AS LEVEL,
  16602. t1.grade_type AS gradeType,
  16603. t1.score_res AS scoreRes,
  16604. t1.NAME AS NAME,
  16605. t1.sex AS sex,
  16606. t1.beh_dept_id AS behDeptId,
  16607. t1.beh_dept_name AS behDeptName,
  16608. t1.doctor_id AS doctorId,
  16609. t1.doctor_name AS doctorName,
  16610. t1.beh_doctor_id AS behDoctorId,
  16611. t1.beh_doctor_name AS behDoctorName,
  16612. t1.director_doctor_id AS directorDoctorId,
  16613. t1.director_doctor_name AS directorDoctorName,
  16614. t1.birthday AS birthday,
  16615. t1.behospital_date AS behospitalDate,
  16616. t1.leave_hospital_date AS leaveHospitalDate,
  16617. t1.placefile_date AS placefileDate,
  16618. t1.gmt_create AS gradeTime,
  16619. t1.diagnose,
  16620. t1.ward_name AS wardName,
  16621. t2.age,
  16622. t1.file_code AS fileCode,
  16623. t1.checkStatus,
  16624. t1.mrStatus,
  16625. t1.chName,
  16626. t1.mrName,
  16627. t1.chTime,
  16628. t1.mrTime
  16629. FROM
  16630. (
  16631. SELECT
  16632. be.*,
  16633. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16634. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16635. mci.check_name AS chName,
  16636. hm_mci.check_name AS mrName,
  16637. mci.gmt_create AS chTime,
  16638. hm_mci.gmt_create AS mrTime
  16639. FROM
  16640. (
  16641. SELECT DISTINCT
  16642. a.hospital_id,
  16643. a.behospital_code,
  16644. a.bed_code,
  16645. a.file_code,
  16646. c.LEVEL,
  16647. c.grade_type,
  16648. c.score_res,
  16649. a.NAME,
  16650. a.sex,
  16651. a.beh_dept_id,
  16652. a.beh_dept_name,
  16653. a.birthday,
  16654. a.behospital_date,
  16655. a.leave_hospital_date,
  16656. a.doctor_id,
  16657. a.doctor_name,
  16658. a.beh_doctor_id,
  16659. a.beh_doctor_name,
  16660. a.director_doctor_id,
  16661. a.director_doctor_name,
  16662. a.diagnose,
  16663. a.placefile_date,
  16664. a.ward_name,
  16665. c.gmt_create
  16666. FROM
  16667. med_behospital_info a,
  16668. med_home_page b,
  16669. med_qcresult_info c,
  16670. med_qcresult_cases d,
  16671. sys_user_dept f,
  16672. (
  16673. SELECT
  16674. m4.*
  16675. FROM
  16676. med_behospital_info m1,
  16677. med_home_page m2,
  16678. med_qcresult_info m3,
  16679. med_qcresult_cases m4
  16680. WHERE
  16681. m1.is_deleted = 'N'
  16682. AND m2.is_deleted = 'N'
  16683. AND m3.is_deleted = 'Y'
  16684. AND m4.is_deleted = 'Y'
  16685. AND m1.hospital_id = m2.hospital_id
  16686. AND m1.hospital_id = m3.hospital_id
  16687. AND m1.hospital_id = m4.hospital_id
  16688. AND m1.behospital_code = m2.behospital_code
  16689. AND m1.behospital_code = m3.behospital_code
  16690. AND m1.behospital_code = m4.behospital_code
  16691. AND m3.gmt_create = m4.gmt_create
  16692. AND m3.have_home_page = 1
  16693. AND m4.cases_id = 243
  16694. AND m1.qc_type_id != 0
  16695. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16696. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16697. </if>
  16698. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16699. and m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16700. </if>
  16701. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16702. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16703. </if>
  16704. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16705. <if test="qcResultShortPageVO.startDate != null ">
  16706. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16707. </if>
  16708. <if test="qcResultShortPageVO.endDate != null ">
  16709. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16710. </if>
  16711. </if>
  16712. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16713. <if test="qcResultShortPageVO.startDate != null">
  16714. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16715. </if>
  16716. <if test="qcResultShortPageVO.endDate != null ">
  16717. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16718. </if>
  16719. </if>
  16720. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16721. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16722. </if>
  16723. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16724. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  16725. </if>
  16726. GROUP BY
  16727. m1.behospital_code
  16728. ORDER BY
  16729. m1.behospital_code,
  16730. m4.gmt_create
  16731. ) e
  16732. WHERE
  16733. a.is_deleted = 'N'
  16734. AND b.is_deleted = 'N'
  16735. AND c.is_deleted = 'N'
  16736. AND d.is_deleted = 'N'
  16737. AND f.is_deleted = 'N'
  16738. AND a.hospital_id = b.hospital_id
  16739. AND a.hospital_id = c.hospital_id
  16740. AND a.hospital_id = d.hospital_id
  16741. AND a.hospital_id = e.hospital_id
  16742. AND a.hospital_id = f.hospital_id
  16743. AND a.behospital_code = b.behospital_code
  16744. AND a.behospital_code = c.behospital_code
  16745. AND a.behospital_code = d.behospital_code
  16746. AND a.behospital_code = e.behospital_code
  16747. AND a.beh_dept_id = f.dept_id
  16748. AND d.cases_id = 243
  16749. AND d.score_res > e.score_res
  16750. AND a.qc_type_id != 0
  16751. <if test="qcResultShortPageVO.userId!=null">
  16752. AND f.user_id = #{qcResultShortPageVO.userId}
  16753. </if>
  16754. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16755. and a.ward_nameLIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16756. </if>
  16757. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16758. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16759. </if>
  16760. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16761. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16762. </if>
  16763. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16764. <if test="qcResultShortPageVO.startDate != null ">
  16765. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16766. </if>
  16767. <if test="qcResultShortPageVO.endDate != null ">
  16768. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16769. </if>
  16770. </if>
  16771. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16772. <if test="qcResultShortPageVO.startDate != null ">
  16773. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16774. </if>
  16775. <if test="qcResultShortPageVO.endDate != null">
  16776. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16777. </if>
  16778. </if>
  16779. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16780. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16781. </if>
  16782. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16783. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  16784. </if>
  16785. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16786. AND c.`level` = #{qcResultShortPageVO.level}
  16787. </if>
  16788. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16789. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16790. </if>
  16791. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16792. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16793. </if>
  16794. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16795. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  16796. </if>
  16797. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16798. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16799. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16800. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16801. </if>
  16802. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16803. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16804. </if>
  16805. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16806. AND d.score_res = 20
  16807. </if>
  16808. ) be
  16809. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16810. AND mci.check_type = 0
  16811. AND be.hospital_id = mci.hospital_id
  16812. AND be.behospital_code = mci.behospital_code
  16813. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16814. AND hm_mci.check_type = 1
  16815. AND be.hospital_id = hm_mci.hospital_id
  16816. AND be.behospital_code = hm_mci.behospital_code
  16817. ) t1
  16818. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16819. AND t1.behospital_code = t2.behospital_code
  16820. AND t2.is_deleted = 'N'
  16821. ) t
  16822. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16823. AND t.hospitalId = qi.hospital_id
  16824. AND t.behospitalCode = qi.behospital_code
  16825. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  16826. AND t.hospitalId = t2.hospital_id
  16827. AND t2.is_deleted = 'N'
  16828. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  16829. AND t3.is_deleted = 'N'
  16830. where 1=1
  16831. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  16832. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  16833. </if>
  16834. <if test="qcResultShortPageVO.checkStatus != null">
  16835. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16836. </if>
  16837. <if test="qcResultShortPageVO.mrStatus != null">
  16838. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16839. </if>
  16840. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16841. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16842. </if>
  16843. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16844. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16845. </if>
  16846. <if test="qcResultShortPageVO.chTimeStart != null ">
  16847. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16848. </if>
  16849. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16850. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16851. </if>
  16852. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16853. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16854. </if>
  16855. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16856. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16857. </if>
  16858. GROUP BY
  16859. t.doctorId,
  16860. t.doctorName
  16861. )f2
  16862. WHERE
  16863. f1.doctorId = f2.doctorId
  16864. AND f1.doctorName = f2.doctorName
  16865. </select>
  16866. <!-- 质控核查质控评分页导出-->
  16867. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  16868. SELECT
  16869. f1.behDeptId,
  16870. f1.behDeptName,
  16871. f1.doctorName,
  16872. f1.patName,
  16873. f1.behospitalCode,
  16874. f1.hospitalId,
  16875. f1.behospitalDate,
  16876. f1.leaveHospitalDate,
  16877. f1.score,
  16878. f1.scoreBn,
  16879. f2.avgScore,
  16880. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16881. f1.msg,
  16882. f1.caseName,
  16883. </if>
  16884. f1.checkStatus,
  16885. f1.mrStatus,
  16886. f1.chName,
  16887. f1.mrName,
  16888. f1.chTime,
  16889. f1.mrTime
  16890. FROM
  16891. (SELECT
  16892. t.doctorName,
  16893. t.`name` AS patName,
  16894. t.behospitalCode AS behospitalCode,
  16895. t.behospitalDate AS behospitalDate,
  16896. t.leaveHospitalDate AS leaveHospitalDate,
  16897. qi.score_res AS score,
  16898. t.scoreBn,
  16899. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16900. qd.msg AS msg,
  16901. qc.NAME AS caseName,
  16902. </if>
  16903. t.behDeptId,
  16904. t.behDeptName,
  16905. t.hospitalId,
  16906. t.checkStatus,
  16907. t.mrStatus,
  16908. t.chName,
  16909. t.mrName,
  16910. t.chTime,
  16911. t.mrTime
  16912. FROM
  16913. (
  16914. SELECT DISTINCT
  16915. t1.hospital_id AS hospitalId,
  16916. t1.behospital_code AS behospitalCode,
  16917. t1.bed_code AS bedCode,
  16918. t1.LEVEL AS LEVEL,
  16919. t1.grade_type AS gradeType,
  16920. t1.score_res AS scoreRes,
  16921. t1.scoreBn,
  16922. t1.NAME AS NAME,
  16923. t1.sex AS sex,
  16924. t1.beh_dept_id AS behDeptId,
  16925. t1.beh_dept_name AS behDeptName,
  16926. t1.doctor_id AS doctorId,
  16927. t1.doctor_name AS doctorName,
  16928. t1.beh_doctor_id AS behDoctorId,
  16929. t1.beh_doctor_name AS behDoctorName,
  16930. t1.director_doctor_id AS directorDoctorId,
  16931. t1.director_doctor_name AS directorDoctorName,
  16932. t1.birthday AS birthday,
  16933. t1.behospital_date AS behospitalDate,
  16934. t1.leave_hospital_date AS leaveHospitalDate,
  16935. t1.placefile_date AS placefileDate,
  16936. t1.gmt_create AS gradeTime,
  16937. t1.diagnose,
  16938. t1.ward_name AS wardName,
  16939. t2.age,
  16940. t1.file_code AS fileCode,
  16941. t1.checkStatus,
  16942. t1.mrStatus,
  16943. t1.chName,
  16944. t1.mrName,
  16945. t1.chTime,
  16946. t1.mrTime
  16947. FROM
  16948. (
  16949. SELECT
  16950. be.*,
  16951. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16952. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16953. mci.check_name AS chName,
  16954. e.score_res as scoreBn,
  16955. hm_mci.check_name AS mrName,
  16956. mci.gmt_create AS chTime,
  16957. hm_mci.gmt_create AS mrTime
  16958. FROM
  16959. (
  16960. SELECT DISTINCT
  16961. a.hospital_id,
  16962. a.behospital_code,
  16963. a.bed_code,
  16964. a.file_code,
  16965. b.LEVEL,
  16966. b.grade_type,
  16967. b.score_res,
  16968. a.NAME,
  16969. a.sex,
  16970. a.beh_dept_id,
  16971. a.beh_dept_name,
  16972. a.birthday,
  16973. a.behospital_date,
  16974. a.leave_hospital_date,
  16975. a.doctor_id,
  16976. a.doctor_name,
  16977. a.beh_doctor_id,
  16978. a.beh_doctor_name,
  16979. a.director_doctor_id,
  16980. a.director_doctor_name,
  16981. a.diagnose,
  16982. a.placefile_date,
  16983. a.ward_name,
  16984. b.gmt_create
  16985. FROM
  16986. med_behospital_info a,
  16987. med_qcresult_info b
  16988. WHERE
  16989. a.is_deleted = 'N'
  16990. AND b.is_deleted = 'N'
  16991. AND a.hospital_id = b.hospital_id
  16992. AND a.behospital_code = b.behospital_code
  16993. AND a.qc_type_id != 0
  16994. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16995. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16996. </if>
  16997. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16998. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16999. </if>
  17000. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17001. <if test="qcResultShortPageVO.startDate != null ">
  17002. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17003. </if>
  17004. <if test="qcResultShortPageVO.endDate != null ">
  17005. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17006. </if>
  17007. </if>
  17008. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17009. <if test="qcResultShortPageVO.startDate != null ">
  17010. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17011. </if>
  17012. <if test="qcResultShortPageVO.endDate != null">
  17013. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17014. </if>
  17015. </if>
  17016. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17017. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17018. </if>
  17019. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17020. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17021. </if>
  17022. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17023. AND c.`level` = #{qcResultShortPageVO.level}
  17024. </if>
  17025. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17026. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17027. </if>
  17028. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17029. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17030. </if>
  17031. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17032. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17033. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17034. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17035. </if>
  17036. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17037. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17038. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17039. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17040. </if>
  17041. ) be
  17042. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17043. AND mci.check_type = 0
  17044. AND be.hospital_id = mci.hospital_id
  17045. AND be.behospital_code = mci.behospital_code
  17046. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17047. AND hm_mci.check_type = 1
  17048. AND be.hospital_id = hm_mci.hospital_id
  17049. AND be.behospital_code = hm_mci.behospital_code
  17050. LEFT JOIN med_qcresult_cases e
  17051. on be.behospital_code = e.behospital_code
  17052. and be.hospital_id = e.hospital_id
  17053. AND e.is_deleted = 'N'
  17054. and e.cases_id = 243
  17055. ) t1
  17056. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17057. AND t1.behospital_code = t2.behospital_code
  17058. AND t2.is_deleted = 'N'
  17059. ) t
  17060. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17061. AND t.hospitalId = qi.hospital_id
  17062. AND t.behospitalCode = qi.behospital_code
  17063. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17064. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17065. AND t.hospitalId = qd.hospital_id
  17066. AND t.behospitalCode = qd.behospital_code
  17067. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17068. AND qd.cases_id = qc.id
  17069. </if>
  17070. where 1=1
  17071. <if test="qcResultShortPageVO.checkStatus != null">
  17072. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17073. </if>
  17074. <if test="qcResultShortPageVO.mrStatus != null">
  17075. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17076. </if>
  17077. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17078. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17079. </if>
  17080. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17081. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17082. </if>
  17083. <if test="qcResultShortPageVO.chTimeStart != null ">
  17084. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17085. </if>
  17086. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17087. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17088. </if>
  17089. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17090. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17091. </if>
  17092. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17093. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17094. </if>
  17095. )f1,
  17096. (SELECT
  17097. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17098. t.behDeptId,
  17099. t.behDeptName
  17100. FROM
  17101. (
  17102. SELECT DISTINCT
  17103. t1.hospital_id AS hospitalId,
  17104. t1.behospital_code AS behospitalCode,
  17105. t1.bed_code AS bedCode,
  17106. t1.LEVEL AS LEVEL,
  17107. t1.grade_type AS gradeType,
  17108. t1.score_res AS scoreRes,
  17109. t1.NAME AS NAME,
  17110. t1.sex AS sex,
  17111. t1.beh_dept_id AS behDeptId,
  17112. t1.beh_dept_name AS behDeptName,
  17113. t1.doctor_id AS doctorId,
  17114. t1.doctor_name AS doctorName,
  17115. t1.beh_doctor_id AS behDoctorId,
  17116. t1.beh_doctor_name AS behDoctorName,
  17117. t1.director_doctor_id AS directorDoctorId,
  17118. t1.director_doctor_name AS directorDoctorName,
  17119. t1.birthday AS birthday,
  17120. t1.behospital_date AS behospitalDate,
  17121. t1.leave_hospital_date AS leaveHospitalDate,
  17122. t1.placefile_date AS placefileDate,
  17123. t1.gmt_create AS gradeTime,
  17124. t1.diagnose,
  17125. t1.ward_name AS wardName,
  17126. t2.age,
  17127. t1.file_code AS fileCode,
  17128. t1.checkStatus,
  17129. t1.mrStatus,
  17130. t1.chName,
  17131. t1.mrName,
  17132. t1.chTime,
  17133. t1.mrTime
  17134. FROM
  17135. (
  17136. SELECT
  17137. be.*,
  17138. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17139. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17140. mci.check_name AS chName,
  17141. hm_mci.check_name AS mrName,
  17142. mci.gmt_create AS chTime,
  17143. hm_mci.gmt_create AS mrTime
  17144. FROM
  17145. (
  17146. SELECT DISTINCT
  17147. a.hospital_id,
  17148. a.behospital_code,
  17149. a.bed_code,
  17150. a.file_code,
  17151. b.LEVEL,
  17152. b.grade_type,
  17153. b.score_res,
  17154. a.NAME,
  17155. a.sex,
  17156. a.beh_dept_id,
  17157. a.beh_dept_name,
  17158. a.birthday,
  17159. a.behospital_date,
  17160. a.leave_hospital_date,
  17161. a.doctor_id,
  17162. a.doctor_name,
  17163. a.beh_doctor_id,
  17164. a.beh_doctor_name,
  17165. a.director_doctor_id,
  17166. a.director_doctor_name,
  17167. a.diagnose,
  17168. a.placefile_date,
  17169. a.ward_name,
  17170. b.gmt_create
  17171. FROM
  17172. med_behospital_info a,
  17173. med_qcresult_info b
  17174. WHERE
  17175. a.is_deleted = 'N'
  17176. AND b.is_deleted = 'N'
  17177. AND a.hospital_id = b.hospital_id
  17178. AND a.behospital_code = b.behospital_code
  17179. AND a.qc_type_id != 0
  17180. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17181. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17182. </if>
  17183. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17184. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17185. </if>
  17186. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17187. <if test="qcResultShortPageVO.startDate != null ">
  17188. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17189. </if>
  17190. <if test="qcResultShortPageVO.endDate != null ">
  17191. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17192. </if>
  17193. </if>
  17194. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17195. <if test="qcResultShortPageVO.startDate != null ">
  17196. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17197. </if>
  17198. <if test="qcResultShortPageVO.endDate != null">
  17199. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17200. </if>
  17201. </if>
  17202. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17203. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17204. </if>
  17205. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17206. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17207. </if>
  17208. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17209. AND c.`level` = #{qcResultShortPageVO.level}
  17210. </if>
  17211. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17212. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17213. </if>
  17214. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17215. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17216. </if>
  17217. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17218. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17219. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17220. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17221. </if>
  17222. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17223. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17224. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17225. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17226. </if>
  17227. ) be
  17228. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17229. AND mci.check_type = 0
  17230. AND be.hospital_id = mci.hospital_id
  17231. AND be.behospital_code = mci.behospital_code
  17232. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17233. AND hm_mci.check_type = 1
  17234. AND be.hospital_id = hm_mci.hospital_id
  17235. AND be.behospital_code = hm_mci.behospital_code
  17236. ) t1
  17237. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17238. AND t1.behospital_code = t2.behospital_code
  17239. AND t2.is_deleted = 'N'
  17240. ) t
  17241. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17242. AND t.hospitalId = qi.hospital_id
  17243. AND t.behospitalCode = qi.behospital_code
  17244. where 1=1
  17245. <if test="qcResultShortPageVO.checkStatus != null">
  17246. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17247. </if>
  17248. <if test="qcResultShortPageVO.mrStatus != null">
  17249. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17250. </if>
  17251. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17252. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17253. </if>
  17254. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17255. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17256. </if>
  17257. <if test="qcResultShortPageVO.chTimeStart != null ">
  17258. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17259. </if>
  17260. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17261. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17262. </if>
  17263. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17264. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17265. </if>
  17266. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17267. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17268. </if>
  17269. GROUP BY
  17270. t.behDeptId,
  17271. t.behDeptName
  17272. )f2
  17273. WHERE
  17274. f1.behDeptId = f2.behDeptId
  17275. AND f1.behDeptName = f2.behDeptName
  17276. </select>
  17277. <!-- 质控核查质控评分页导出 -科室-->
  17278. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  17279. SELECT
  17280. f1.behDeptId,
  17281. f1.behDeptName,
  17282. f1.doctorName,
  17283. f1.doctorId,
  17284. f1.patName,
  17285. f1.behospitalCode,
  17286. f1.hospitalId,
  17287. f1.behospitalDate,
  17288. f1.leaveHospitalDate,
  17289. f1.score,
  17290. f1.scoreBn,
  17291. f2.avgScore,
  17292. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17293. f1.msg,
  17294. f1.caseName,
  17295. f1.medoupName,
  17296. f1.wardName,
  17297. </if>
  17298. f1.checkStatus,
  17299. f1.mrStatus,
  17300. f1.chName,
  17301. f1.mrName,
  17302. f1.chTime,
  17303. f1.mrTime
  17304. FROM
  17305. (SELECT
  17306. t.doctorName,
  17307. t.doctorId,
  17308. t.`name` AS patName,
  17309. t.behospitalCode AS behospitalCode,
  17310. t.behospitalDate AS behospitalDate,
  17311. t.leaveHospitalDate AS leaveHospitalDate,
  17312. qi.score_res AS score,
  17313. t.scoreBn,
  17314. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17315. qd.msg AS msg,
  17316. qc.NAME AS caseName,
  17317. </if>
  17318. t.behDeptId,
  17319. t.behDeptName,
  17320. t.wardName,
  17321. t.hospitalId,
  17322. t.checkStatus,
  17323. t.mrStatus,
  17324. t.chName,
  17325. t.mrName,
  17326. t.chTime,
  17327. t.mrTime,
  17328. t3.name as medoupName
  17329. FROM
  17330. (
  17331. SELECT DISTINCT
  17332. t1.hospital_id AS hospitalId,
  17333. t1.behospital_code AS behospitalCode,
  17334. t1.bed_code AS bedCode,
  17335. t1.LEVEL AS LEVEL,
  17336. t1.grade_type AS gradeType,
  17337. t1.score_res AS scoreRes,
  17338. t1.scoreBn,
  17339. t1.NAME AS NAME,
  17340. t1.sex AS sex,
  17341. t1.beh_dept_id AS behDeptId,
  17342. t1.beh_dept_name AS behDeptName,
  17343. t1.doctor_id AS doctorId,
  17344. t1.doctor_name AS doctorName,
  17345. t1.beh_doctor_id AS behDoctorId,
  17346. t1.beh_doctor_name AS behDoctorName,
  17347. t1.director_doctor_id AS directorDoctorId,
  17348. t1.director_doctor_name AS directorDoctorName,
  17349. t1.birthday AS birthday,
  17350. t1.behospital_date AS behospitalDate,
  17351. t1.leave_hospital_date AS leaveHospitalDate,
  17352. t1.placefile_date AS placefileDate,
  17353. t1.gmt_create AS gradeTime,
  17354. t1.diagnose,
  17355. t1.ward_name AS wardName,
  17356. t2.age,
  17357. t1.file_code AS fileCode,
  17358. t1.checkStatus,
  17359. t1.mrStatus,
  17360. t1.chName,
  17361. t1.mrName,
  17362. t1.chTime,
  17363. t1.mrTime
  17364. FROM
  17365. (
  17366. SELECT
  17367. be.*,
  17368. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17369. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17370. mci.check_name AS chName,
  17371. e.score_res as scoreBn,
  17372. hm_mci.check_name AS mrName,
  17373. mci.gmt_create AS chTime,
  17374. hm_mci.gmt_create AS mrTime
  17375. FROM
  17376. (
  17377. SELECT DISTINCT
  17378. a.hospital_id,
  17379. a.behospital_code,
  17380. a.bed_code,
  17381. a.file_code,
  17382. b.LEVEL,
  17383. b.grade_type,
  17384. b.score_res,
  17385. a.NAME,
  17386. a.sex,
  17387. a.beh_dept_id,
  17388. a.beh_dept_name,
  17389. a.birthday,
  17390. a.behospital_date,
  17391. a.leave_hospital_date,
  17392. a.doctor_id,
  17393. a.doctor_name,
  17394. a.beh_doctor_id,
  17395. a.beh_doctor_name,
  17396. a.director_doctor_id,
  17397. a.director_doctor_name,
  17398. a.diagnose,
  17399. a.placefile_date,
  17400. a.ward_name,
  17401. b.gmt_create
  17402. FROM
  17403. med_behospital_info a,
  17404. med_qcresult_info b,
  17405. sys_user_dept c
  17406. WHERE
  17407. a.is_deleted = 'N'
  17408. AND b.is_deleted = 'N'
  17409. AND c.is_deleted = 'N'
  17410. AND a.hospital_id = b.hospital_id
  17411. AND a.hospital_id = c.hospital_id
  17412. AND a.behospital_code = b.behospital_code
  17413. AND a.beh_dept_id = c.dept_id
  17414. AND a.qc_type_id != 0
  17415. <if test="qcResultShortPageVO.userId!=null">
  17416. AND c.user_id = #{qcResultShortPageVO.userId}
  17417. </if>
  17418. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17419. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17420. </if>
  17421. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17422. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17423. </if>
  17424. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17425. <if test="qcResultShortPageVO.startDate != null ">
  17426. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17427. </if>
  17428. <if test="qcResultShortPageVO.endDate != null ">
  17429. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17430. </if>
  17431. </if>
  17432. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17433. <if test="qcResultShortPageVO.startDate != null ">
  17434. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17435. </if>
  17436. <if test="qcResultShortPageVO.endDate != null">
  17437. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17438. </if>
  17439. </if>
  17440. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17441. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17442. </if>
  17443. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  17444. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  17445. </if>
  17446. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17447. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17448. </if>
  17449. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  17450. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  17451. </if>
  17452. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17453. AND c.`level` = #{qcResultShortPageVO.level}
  17454. </if>
  17455. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17456. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17457. </if>
  17458. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17459. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17460. </if>
  17461. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17462. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  17463. </if>
  17464. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17465. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17466. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17467. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17468. </if>
  17469. ) be
  17470. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17471. AND mci.check_type = 0
  17472. AND be.hospital_id = mci.hospital_id
  17473. AND be.behospital_code = mci.behospital_code
  17474. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17475. AND hm_mci.check_type = 1
  17476. AND be.hospital_id = hm_mci.hospital_id
  17477. AND be.behospital_code = hm_mci.behospital_code
  17478. LEFT JOIN med_qcresult_cases e
  17479. on be.behospital_code = e.behospital_code
  17480. and be.hospital_id = e.hospital_id
  17481. AND e.is_deleted = 'N'
  17482. and e.cases_id = 243
  17483. ) t1
  17484. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17485. AND t1.behospital_code = t2.behospital_code
  17486. AND t2.is_deleted = 'N'
  17487. ) t
  17488. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17489. AND t.hospitalId = qi.hospital_id
  17490. AND t.behospitalCode = qi.behospital_code
  17491. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17492. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17493. AND t.hospitalId = qd.hospital_id
  17494. AND t.behospitalCode = qd.behospital_code
  17495. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17496. AND qd.cases_id = qc.id
  17497. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  17498. AND t.hospitalId = t2.hospital_id
  17499. AND t2.is_deleted = 'N'
  17500. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  17501. AND t3.is_deleted = 'N'
  17502. </if>
  17503. where 1=1
  17504. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  17505. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  17506. </if>
  17507. <if test="qcResultShortPageVO.checkStatus != null">
  17508. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17509. </if>
  17510. <if test="qcResultShortPageVO.mrStatus != null">
  17511. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17512. </if>
  17513. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17514. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17515. </if>
  17516. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17517. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17518. </if>
  17519. <if test="qcResultShortPageVO.chTimeStart != null ">
  17520. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17521. </if>
  17522. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17523. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17524. </if>
  17525. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17526. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17527. </if>
  17528. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17529. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17530. </if>
  17531. )f1,
  17532. (SELECT
  17533. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17534. t.behDeptId,
  17535. t.behDeptName,
  17536. t.doctorId,
  17537. t.doctorName
  17538. FROM
  17539. (
  17540. SELECT DISTINCT
  17541. t1.hospital_id AS hospitalId,
  17542. t1.behospital_code AS behospitalCode,
  17543. t1.bed_code AS bedCode,
  17544. t1.LEVEL AS LEVEL,
  17545. t1.grade_type AS gradeType,
  17546. t1.score_res AS scoreRes,
  17547. t1.NAME AS NAME,
  17548. t1.sex AS sex,
  17549. t1.beh_dept_id AS behDeptId,
  17550. t1.beh_dept_name AS behDeptName,
  17551. t1.doctor_id AS doctorId,
  17552. t1.doctor_name AS doctorName,
  17553. t1.beh_doctor_id AS behDoctorId,
  17554. t1.beh_doctor_name AS behDoctorName,
  17555. t1.director_doctor_id AS directorDoctorId,
  17556. t1.director_doctor_name AS directorDoctorName,
  17557. t1.birthday AS birthday,
  17558. t1.behospital_date AS behospitalDate,
  17559. t1.leave_hospital_date AS leaveHospitalDate,
  17560. t1.placefile_date AS placefileDate,
  17561. t1.gmt_create AS gradeTime,
  17562. t1.diagnose,
  17563. t1.ward_name AS wardName,
  17564. t2.age,
  17565. t1.file_code AS fileCode,
  17566. t1.checkStatus,
  17567. t1.mrStatus,
  17568. t1.chName,
  17569. t1.mrName,
  17570. t1.chTime,
  17571. t1.mrTime
  17572. FROM
  17573. (
  17574. SELECT
  17575. be.*,
  17576. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17577. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17578. mci.check_name AS chName,
  17579. hm_mci.check_name AS mrName,
  17580. mci.gmt_create AS chTime,
  17581. hm_mci.gmt_create AS mrTime
  17582. FROM
  17583. (
  17584. SELECT DISTINCT
  17585. a.hospital_id,
  17586. a.behospital_code,
  17587. a.bed_code,
  17588. a.file_code,
  17589. b.LEVEL,
  17590. b.grade_type,
  17591. b.score_res,
  17592. a.NAME,
  17593. a.sex,
  17594. a.beh_dept_id,
  17595. a.beh_dept_name,
  17596. a.birthday,
  17597. a.behospital_date,
  17598. a.leave_hospital_date,
  17599. a.doctor_id,
  17600. a.doctor_name,
  17601. a.beh_doctor_id,
  17602. a.beh_doctor_name,
  17603. a.director_doctor_id,
  17604. a.director_doctor_name,
  17605. a.diagnose,
  17606. a.placefile_date,
  17607. a.ward_name,
  17608. b.gmt_create
  17609. FROM
  17610. med_behospital_info a,
  17611. med_qcresult_info b,
  17612. sys_user_dept c
  17613. WHERE
  17614. a.is_deleted = 'N'
  17615. AND b.is_deleted = 'N'
  17616. AND c.is_deleted = 'N'
  17617. AND a.hospital_id = b.hospital_id
  17618. AND a.hospital_id = c.hospital_id
  17619. AND a.behospital_code = b.behospital_code
  17620. AND a.beh_dept_id = c.dept_id
  17621. AND a.qc_type_id != 0
  17622. <if test="qcResultShortPageVO.userId!=null">
  17623. AND c.user_id = #{qcResultShortPageVO.userId}
  17624. </if>
  17625. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17626. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17627. </if>
  17628. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  17629. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  17630. </if>
  17631. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17632. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17633. </if>
  17634. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17635. <if test="qcResultShortPageVO.startDate != null ">
  17636. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17637. </if>
  17638. <if test="qcResultShortPageVO.endDate != null ">
  17639. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17640. </if>
  17641. </if>
  17642. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17643. <if test="qcResultShortPageVO.startDate != null ">
  17644. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17645. </if>
  17646. <if test="qcResultShortPageVO.endDate != null">
  17647. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17648. </if>
  17649. </if>
  17650. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17651. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17652. </if>
  17653. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17654. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17655. </if>
  17656. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  17657. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  17658. </if>
  17659. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17660. AND c.`level` = #{qcResultShortPageVO.level}
  17661. </if>
  17662. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17663. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17664. </if>
  17665. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17666. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17667. </if>
  17668. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17669. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  17670. </if>
  17671. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17672. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17673. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17674. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17675. </if>
  17676. ) be
  17677. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17678. AND mci.check_type = 0
  17679. AND be.hospital_id = mci.hospital_id
  17680. AND be.behospital_code = mci.behospital_code
  17681. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17682. AND hm_mci.check_type = 1
  17683. AND be.hospital_id = hm_mci.hospital_id
  17684. AND be.behospital_code = hm_mci.behospital_code
  17685. ) t1
  17686. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17687. AND t1.behospital_code = t2.behospital_code
  17688. AND t2.is_deleted = 'N'
  17689. ) t
  17690. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17691. AND t.hospitalId = qi.hospital_id
  17692. AND t.behospitalCode = qi.behospital_code
  17693. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  17694. AND t.hospitalId = t2.hospital_id
  17695. AND t2.is_deleted = 'N'
  17696. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  17697. AND t3.is_deleted = 'N'
  17698. where 1=1
  17699. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  17700. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  17701. </if>
  17702. <if test="qcResultShortPageVO.checkStatus != null">
  17703. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17704. </if>
  17705. <if test="qcResultShortPageVO.mrStatus != null">
  17706. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17707. </if>
  17708. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17709. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17710. </if>
  17711. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17712. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17713. </if>
  17714. <if test="qcResultShortPageVO.chTimeStart != null ">
  17715. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17716. </if>
  17717. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17718. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17719. </if>
  17720. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17721. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17722. </if>
  17723. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17724. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17725. </if>
  17726. GROUP BY
  17727. t.doctorId,
  17728. t.doctorName
  17729. )f2
  17730. WHERE
  17731. f1.doctorId = f2.doctorId
  17732. AND f1.doctorName = f2.doctorName
  17733. </select>
  17734. <!-- 入院,手术,出院病案情况-->
  17735. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17736. SELECT
  17737. count(
  17738. DISTINCT
  17739. CASE
  17740. WHEN q.type=5 THEN
  17741. a.behospital_code
  17742. ELSE
  17743. NULL
  17744. END
  17745. ) AS 'operationNote',
  17746. count(
  17747. DISTINCT
  17748. CASE
  17749. WHEN q.type = 4 THEN
  17750. a.behospital_code
  17751. ELSE
  17752. NULL
  17753. END
  17754. ) AS 'residentAdmitNote',
  17755. count(
  17756. DISTINCT
  17757. CASE
  17758. WHEN q.type = 6 THEN
  17759. a.behospital_code
  17760. ELSE
  17761. NULL
  17762. END
  17763. ) AS 'dischargeRecord',
  17764. count(
  17765. DISTINCT
  17766. CASE
  17767. WHEN q.type = 7 THEN
  17768. a.behospital_code
  17769. ELSE
  17770. NULL
  17771. END
  17772. ) AS 'medicalRecord'
  17773. FROM
  17774. (
  17775. SELECT
  17776. a.behospital_code,
  17777. a.cases_entry_id,
  17778. a.hospital_id
  17779. FROM
  17780. (
  17781. SELECT
  17782. a.behospital_code,
  17783. c.cases_entry_id,
  17784. a.hospital_id
  17785. FROM
  17786. (
  17787. SELECT
  17788. a.behospital_code,
  17789. a.hospital_id
  17790. FROM
  17791. med_behospital_info a,
  17792. med_qcresult_info c
  17793. WHERE
  17794. a.is_deleted = 'N'
  17795. AND c.is_deleted = 'N'
  17796. AND a.is_placefile = #{filterVO.isPlacefile}
  17797. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17798. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17799. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17800. </if>
  17801. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17802. AND a.behospital_code = c.behospital_code
  17803. AND a.hospital_id = #{filterVO.hospitalId}
  17804. AND a.hospital_id = c.hospital_id
  17805. ) a
  17806. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  17807. AND a.behospital_code = c.behospital_code
  17808. AND a.hospital_id = c.hospital_id
  17809. ) a
  17810. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  17811. AND d.is_deleted = 'N'
  17812. ) a
  17813. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  17814. AND a.hospital_id = q.hospital_id
  17815. </select>
  17816. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  17817. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17818. select
  17819. d.behospital_code behospitalCode,
  17820. b.operation_fee operationFee,
  17821. b.pathology_fee pathologyFee,
  17822. b.antibiosis_fee antibiosisFee
  17823. FROM
  17824. (
  17825. SELECT
  17826. a.behospital_code,
  17827. a.hospital_id,
  17828. a.behospital_date,
  17829. a.leave_hospital_date
  17830. FROM
  17831. med_behospital_info a,
  17832. med_qcresult_info c
  17833. WHERE
  17834. a.is_deleted = 'N'
  17835. AND c.is_deleted = 'N'
  17836. AND a.is_placefile = #{filterVO.isPlacefile}
  17837. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17838. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17839. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17840. </if>
  17841. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17842. AND a.hospital_id = c.hospital_id
  17843. AND a.hospital_id = #{filterVO.hospitalId}
  17844. and a.behospital_code = c.behospital_code
  17845. ) d
  17846. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  17847. AND d.hospital_id = b.hospital_id
  17848. AND b.is_deleted = 'N'
  17849. </select>
  17850. <!-- 关于触发规则不符合人数-->
  17851. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17852. SELECT
  17853. count(
  17854. DISTINCT
  17855. CASE
  17856. WHEN a.type=5 THEN
  17857. a.behospital_code
  17858. ELSE
  17859. NULL
  17860. END
  17861. ) AS 'operationNote',
  17862. count(
  17863. DISTINCT
  17864. CASE
  17865. WHEN a.type = 4 THEN
  17866. a.behospital_code
  17867. ELSE
  17868. NULL
  17869. END
  17870. ) AS 'residentAdmitNote',
  17871. count(
  17872. DISTINCT
  17873. CASE
  17874. WHEN a.type = 6 THEN
  17875. a.behospital_code
  17876. ELSE
  17877. NULL
  17878. END
  17879. ) AS 'dischargeRecord',
  17880. count(
  17881. DISTINCT
  17882. CASE
  17883. WHEN a.type = 7 THEN
  17884. a.behospital_code
  17885. ELSE
  17886. NULL
  17887. END
  17888. ) AS 'medicalRecord',
  17889. count(
  17890. DISTINCT
  17891. CASE
  17892. WHEN a.type=8 THEN
  17893. a.behospital_code
  17894. ELSE
  17895. NULL
  17896. END
  17897. ) AS 'CT',
  17898. count(
  17899. DISTINCT
  17900. CASE
  17901. WHEN a.type = 9 THEN
  17902. a.behospital_code
  17903. ELSE
  17904. NULL
  17905. END
  17906. ) AS 'MR',
  17907. count(
  17908. DISTINCT
  17909. CASE
  17910. WHEN a.type = 10 THEN
  17911. a.behospital_code
  17912. ELSE
  17913. NULL
  17914. END
  17915. ) AS 'operationPathologyFee',
  17916. count(
  17917. DISTINCT
  17918. CASE
  17919. WHEN a.type = 15 THEN
  17920. a.behospital_code
  17921. ELSE
  17922. NULL
  17923. END
  17924. ) AS 'operationRecordNum',
  17925. count(
  17926. DISTINCT
  17927. CASE
  17928. WHEN a.type = 17 THEN
  17929. a.behospital_code
  17930. ELSE
  17931. NULL
  17932. END
  17933. ) AS 'bloodNum',
  17934. count(
  17935. DISTINCT
  17936. CASE
  17937. WHEN a.type = 18 THEN
  17938. a.behospital_code
  17939. ELSE
  17940. NULL
  17941. END
  17942. ) AS 'WardRoundNum',
  17943. count(
  17944. DISTINCT
  17945. CASE
  17946. WHEN a.type = 19 THEN
  17947. a.behospital_code
  17948. ELSE
  17949. NULL
  17950. END
  17951. ) AS 'rescueNum'
  17952. FROM
  17953. (
  17954. SELECT
  17955. a.behospital_code,
  17956. a.hospital_id,
  17957. q.type
  17958. FROM
  17959. (
  17960. SELECT
  17961. a.behospital_code,
  17962. a.cases_entry_id,
  17963. a.hospital_id
  17964. FROM
  17965. (
  17966. SELECT
  17967. a.behospital_code,
  17968. c.cases_entry_id,
  17969. a.hospital_id
  17970. FROM
  17971. (
  17972. SELECT
  17973. a.behospital_code,
  17974. a.hospital_id
  17975. FROM
  17976. med_behospital_info a,
  17977. med_qcresult_info c
  17978. WHERE
  17979. a.is_deleted = 'N'
  17980. AND c.is_deleted = 'N'
  17981. AND a.is_placefile = #{filterVO.isPlacefile}
  17982. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17983. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17984. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17985. </if>
  17986. AND a.behospital_code = c.behospital_code
  17987. AND a.hospital_id = #{filterVO.hospitalId}
  17988. AND a.hospital_id = c.hospital_id
  17989. ) a
  17990. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  17991. AND a.behospital_code = c.behospital_code
  17992. AND a.hospital_id = c.hospital_id
  17993. ) a
  17994. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  17995. AND d.is_deleted = 'N'
  17996. ) a
  17997. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  17998. AND a.hospital_id = q.hospital_id
  17999. ) a
  18000. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  18001. AND r.relevance_type = a.type
  18002. AND r.is_deleted = 'N'
  18003. AND a.hospital_id = r.hospital_id
  18004. </select>
  18005. <!-- 跟病案首页关联的出院病历-->
  18006. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18007. SELECT
  18008. d.behospital_code,
  18009. d.behospital_date,
  18010. d.leave_hospital_date,
  18011. b.behospital_code AS b_code,
  18012. b.operation_fee,
  18013. b.antibiosis_fee,
  18014. b.pathology_fee
  18015. FROM
  18016. (
  18017. SELECT
  18018. a.behospital_code,
  18019. a.hospital_id,
  18020. a.behospital_date,
  18021. a.leave_hospital_date
  18022. FROM
  18023. med_behospital_info a,
  18024. med_qcresult_info c
  18025. WHERE
  18026. a.behospital_code = c.behospital_code
  18027. AND a.hospital_id = #{filterVO.hospitalId}
  18028. AND a.is_placefile = #{filterVO.isPlacefile}
  18029. AND a.hospital_id = c.hospital_id
  18030. AND a.is_deleted = 'N'
  18031. AND c.is_deleted = 'N'
  18032. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18033. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  18034. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  18035. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18036. </if>
  18037. ) d
  18038. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18039. AND d.hospital_id = b.hospital_id
  18040. AND b.is_deleted = 'N'
  18041. where ISNULL(b.behospital_code)
  18042. </select>
  18043. <!-- 首页恶性肿瘤-->
  18044. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18045. SELECT
  18046. d.behospital_code
  18047. FROM
  18048. (
  18049. SELECT
  18050. a.behospital_code,
  18051. a.hospital_id,
  18052. a.behospital_date,
  18053. a.leave_hospital_date
  18054. FROM
  18055. med_behospital_info a,
  18056. med_qcresult_info c
  18057. WHERE
  18058. a.behospital_code = c.behospital_code
  18059. AND a.hospital_id = #{filterVO.hospitalId}
  18060. AND a.is_placefile = #{filterVO.isPlacefile}
  18061. AND a.hospital_id = c.hospital_id
  18062. AND a.is_deleted = 'N'
  18063. AND c.is_deleted = 'N'
  18064. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18065. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  18066. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  18067. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18068. </if>
  18069. ) d
  18070. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18071. AND d.hospital_id = b.hospital_id
  18072. AND b.is_deleted = 'N'
  18073. AND (
  18074. (
  18075. b.outpatient_emr_diagnose LIKE '%恶性肿瘤%'
  18076. AND b.outpatient_emr_diagnose_code LIKE 'C%'
  18077. )
  18078. OR (
  18079. b.outpatient_emr_diagnose LIKE 'C%'
  18080. AND b.outpatient_emr_diagnose_code LIKE '%恶性肿瘤%'
  18081. )
  18082. )
  18083. </select>
  18084. <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
  18085. <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
  18086. SELECT
  18087. mbi.behospital_code behospitalCode,
  18088. mhp.age,
  18089. TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
  18090. TIMESTAMPDIFF(day,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageDay
  18091. FROM
  18092. med_behospital_info mbi
  18093. LEFT JOIN med_home_page mhp
  18094. ON mbi.behospital_code=mhp.behospital_code
  18095. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  18096. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
  18097. <if test="behospitalCodes !=null and behospitalCodes.size > 0">
  18098. and mbi.behospital_code in
  18099. <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
  18100. #{item}
  18101. </foreach>
  18102. </if>
  18103. </select>
  18104. </mapper>