BehospitalInfoMapper.xml 869 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434
  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="in_state" property="inState"/>
  35. <result column="is_deleted" property="isDeleted"/>
  36. <result column="is_daytime" property="isDaytime"/>
  37. <result column="gmt_create" property="gmtCreate"/>
  38. <result column="gmt_modified" property="gmtModified"/>
  39. <result column="creator" property="creator"/>
  40. <result column="modifier" property="modifier"/>
  41. <result column="linkman" property="linkman"/>
  42. </resultMap>
  43. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  44. SELECT * FROM (
  45. select t.*,
  46. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  47. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  48. g.check_type AS ch_type,
  49. h.check_type AS mr_type,
  50. g.check_name AS ch_name,
  51. h.check_name AS mr_name,
  52. g.check_time AS ch_time,
  53. h.check_time AS mr_time
  54. from (
  55. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  56. 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
  57. LEFT JOIN med_qcresult_info b
  58. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  59. left join med_home_page c
  60. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  61. LEFT JOIN med_qcresult_cases e
  62. on a.behospital_code = e.behospital_code
  63. AND e.is_deleted = 'N'
  64. and e.cases_id = 243
  65. ) t
  66. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  67. ON t.behospital_code = g.behospital_code
  68. AND t.hospital_id = g.hospital_id
  69. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  70. ON t.behospital_code = h.behospital_code
  71. AND t.hospital_id = h.hospital_id
  72. where t.is_deleted = 'N'
  73. <if test="isDaytime != null and isDaytime != ''">
  74. AND t.is_daytime = #{isDaytime}
  75. </if>
  76. <if test="diagnose != null and diagnose != ''">
  77. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  78. </if>
  79. <if test="deptName != null and deptName != ''">
  80. and t.beh_dept_name= #{deptName}
  81. </if>
  82. <if test="doctorName != null and doctorName != ''">
  83. and CONCAT(
  84. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  85. like CONCAT('%',#{doctorName},'%')
  86. </if>
  87. <if test="name != null and name != ''">
  88. and t.name like CONCAT('%',#{name},'%')
  89. </if>
  90. <if test="doctorCode != null and doctorCode != ''">
  91. and (t.doctor_id = #{doctorCode}
  92. or t.beh_doctor_id = #{doctorCode}
  93. or t.director_doctor_id = #{doctorCode})
  94. </if>
  95. <if test="hospitalId != null">
  96. and t.hospital_id = #{hospitalId}
  97. </if>
  98. <if test="behospitalCode != null and behospitalCode != ''">
  99. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  100. </if>
  101. <if test="fileCode != null and fileCode != ''">
  102. and t.file_code like CONCAT('%',#{fileCode},'%')
  103. </if>
  104. <if test="behosDateStart != null">
  105. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  106. </if>
  107. <if test="behosDateEnd != null">
  108. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  109. </if>
  110. <if test="leaveHosDateStart != null">
  111. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  112. </if>
  113. <if test="leaveHosDateEnd != null">
  114. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  115. </if>
  116. <if test="level != null and level != ''">
  117. and t.level = #{level}
  118. </if>
  119. <if test="isPlacefile != null and isPlacefile != ''">
  120. and t.is_placefile = #{isPlacefile}
  121. </if>
  122. and t.qc_type_id != 0) p
  123. where p.is_deleted="N"
  124. <if test="checkStatus != null ">
  125. and p.check_status = #{checkStatus}
  126. </if>
  127. <if test="mrStatus != null ">
  128. AND p.mr_status = #{mrStatus}
  129. </if>
  130. <if test="chName != null and chName !=''">
  131. AND p.ch_name like CONCAT('%',#{chName},'%')
  132. </if>
  133. <if test="mrName != null and mrName !=''">
  134. AND p.mr_name like CONCAT('%',#{mrName},'%')
  135. </if>
  136. <if test="chTimeStart != null">
  137. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  138. </if>
  139. <if test="chTimeEnd != null">
  140. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  141. </if>
  142. <if test="mrTimeStart != null">
  143. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  144. </if>
  145. <if test="mrTimeEnd != null">
  146. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  147. </if>
  148. </select>
  149. <select id="getQualityCaseSorce" resultType="com.diagbot.dto.CaseScoreDTO">
  150. 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
  151. FROM med_qcresult_detail c,med_behospital_info e
  152. where c.is_deleted = 'N'AND e.is_deleted = 'N'
  153. AND c.behospital_code = e.behospital_code
  154. AND c.hospital_id = e.hospital_id
  155. and c.hospital_id = #{hospitalId}
  156. <if test="deptName != null and deptName != ''">
  157. and e.beh_dept_name= #{deptName}
  158. </if>
  159. <if test="behospitalCode != null and behospitalCode != ''">
  160. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  161. </if>
  162. <if test="isPlacefile != null and isPlacefile != ''">
  163. and e.is_placefile = #{isPlacefile}
  164. </if>
  165. <if test="behosDateStart != null">
  166. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  167. </if>
  168. <if test="behosDateEnd != null">
  169. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  170. </if>
  171. <if test="leaveHosDateStart != null">
  172. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  173. </if>
  174. <if test="leaveHosDateEnd != null">
  175. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  176. </if>
  177. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  178. order by c.behospital_code
  179. </select>
  180. <select id="getQualityCaseSorceByDept" resultType="com.diagbot.dto.CaseScoreDTO">
  181. 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
  182. FROM med_qcresult_detail c,sys_user_dept d,med_behospital_info e
  183. where c.is_deleted = 'N' AND d.is_deleted = 'N' AND e.is_deleted = 'N'
  184. AND c.behospital_code = e.behospital_code
  185. ON d.hospital_id = e.hospital_id
  186. AND e.beh_dept_id = d.dept_id
  187. AND c.hospital_id = e.hospital_id
  188. and c.hospital_id = #{hospitalId}
  189. <if test="deptName != null and deptName != ''">
  190. and e.beh_dept_name= #{deptName}
  191. </if>
  192. <if test="userId != null and userId != ''">
  193. and d.user_id = #{userId}
  194. </if>
  195. <if test="behospitalCode != null and behospitalCode != ''">
  196. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  197. </if>
  198. <if test="isPlacefile != null and isPlacefile != ''">
  199. and e.is_placefile = #{isPlacefile}
  200. </if>
  201. <if test="behosDateStart != null">
  202. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  203. </if>
  204. <if test="behosDateEnd != null">
  205. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  206. </if>
  207. <if test="leaveHosDateStart != null">
  208. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  209. </if>
  210. <if test="leaveHosDateEnd != null">
  211. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  212. </if>
  213. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  214. order by c.behospital_code
  215. </select>
  216. <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  217. SELECT * FROM (
  218. select
  219. distinct
  220. t.name AS NAME,
  221. t.behospital_code AS behospitalCode,
  222. t.doctor_name AS doctorName,
  223. t.beh_dept_name AS deptName,
  224. t.beh_dept_id AS deptId,
  225. t.leave_hospital_date AS leaveHospitalDate,
  226. t.level,
  227. t.age,
  228. t.score_res as totalScore,
  229. t.is_deleted,
  230. g.check_name AS chName,
  231. h.check_name AS mrName
  232. from (
  233. select a.*,
  234. ifnull(b.level,'未评分') as level,
  235. b.grade_type,
  236. IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,
  237. b.score_res
  238. from med_behospital_info a
  239. LEFT JOIN med_qcresult_info b
  240. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  241. left join med_home_page c
  242. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  243. ) t
  244. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  245. ON t.behospital_code = g.behospital_code
  246. AND t.hospital_id = g.hospital_id
  247. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  248. ON t.behospital_code = h.behospital_code
  249. AND t.hospital_id = h.hospital_id
  250. where t.is_deleted = 'N'
  251. <if test="diagnose != null and diagnose != ''">
  252. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  253. </if>
  254. <if test="deptName != null and deptName != ''">
  255. and t.beh_dept_name= #{deptName}
  256. </if>
  257. <if test="doctorName != null and doctorName != ''">
  258. and CONCAT(
  259. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  260. like CONCAT('%',#{doctorName},'%')
  261. </if>
  262. <if test="name != null and name != ''">
  263. and t.name like CONCAT('%',#{name},'%')
  264. </if>
  265. <if test="doctorCode != null and doctorCode != ''">
  266. and (t.doctor_id = #{doctorCode}
  267. or t.beh_doctor_id = #{doctorCode}
  268. or t.director_doctor_id = #{doctorCode})
  269. </if>
  270. <if test="fileCode != null and fileCode != ''">
  271. and t.file_code like CONCAT('%',#{fileCode},'%')
  272. </if>
  273. <if test="hospitalId != null">
  274. and t.hospital_id = #{hospitalId}
  275. </if>
  276. <if test="behospitalCode != null and behospitalCode != ''">
  277. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  278. </if>
  279. <if test="behosDateStart != null">
  280. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  281. </if>
  282. <if test="behosDateEnd != null">
  283. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  284. </if>
  285. <if test="leaveHosDateStart != null">
  286. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  287. </if>
  288. <if test="leaveHosDateEnd != null">
  289. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  290. </if>
  291. <if test="level != null and level != ''">
  292. and t.level = #{level}
  293. </if>
  294. <if test="isPlacefile != null and isPlacefile != ''">
  295. and t.is_placefile = #{isPlacefile}
  296. </if>
  297. and t.qc_type_id != 0) p
  298. where p.is_deleted="N"
  299. <if test="chName != null and chName !=''">
  300. AND p.chName like CONCAT('%',#{chName},'%')
  301. </if>
  302. <if test="mrName != null and mrName !=''">
  303. AND p.mrName like CONCAT('%',#{mrName},'%')
  304. </if>
  305. </select>
  306. <select id="qualityControlByDept" resultType="com.diagbot.dto.QualityControlDeptDTO">
  307. SELECT * FROM (
  308. select
  309. distinct
  310. t.name AS NAME,
  311. t.behospital_code AS behospitalCode,
  312. t.doctor_name AS doctorName,
  313. t.beh_dept_name AS deptName,
  314. t.beh_dept_id AS deptId,
  315. t.leave_hospital_date AS leaveHospitalDate,
  316. t.level,
  317. t.age,
  318. t.score_res as totalScore,
  319. t.is_deleted,
  320. g.check_name AS chName,
  321. h.check_name AS mrName
  322. from (
  323. 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
  324. grade_time from med_behospital_info a
  325. LEFT JOIN med_qcresult_info b
  326. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  327. left join med_home_page c
  328. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  329. LEFT JOIN sys_user_dept d
  330. ON a.hospital_id = d.hospital_id
  331. AND a.beh_dept_id = d.dept_id
  332. ) t
  333. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  334. ON t.behospital_code = g.behospital_code
  335. AND t.hospital_id = g.hospital_id
  336. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  337. ON t.behospital_code = h.behospital_code
  338. AND t.hospital_id = h.hospital_id
  339. where t.is_deleted = 'N'
  340. AND t.user_id = #{userId}
  341. <if test="diagnose != null and diagnose != ''">
  342. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  343. </if>
  344. <if test="deptName != null and deptName != ''">
  345. and t.beh_dept_name= #{deptName}
  346. </if>
  347. <if test="doctorName != null and doctorName != ''">
  348. and CONCAT(
  349. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  350. like CONCAT('%',#{doctorName},'%')
  351. </if>
  352. <if test="name != null and name != ''">
  353. and t.name like CONCAT('%',#{name},'%')
  354. </if>
  355. <if test="doctorCode != null and doctorCode != ''">
  356. and (t.doctor_id = #{doctorCode}
  357. or t.beh_doctor_id = #{doctorCode}
  358. or t.director_doctor_id = #{doctorCode})
  359. </if>
  360. <if test="hospitalId != null">
  361. and t.hospital_id = #{hospitalId}
  362. </if>
  363. <if test="behospitalCode != null and behospitalCode != ''">
  364. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  365. </if>
  366. <if test="fileCode != null and fileCode != ''">
  367. and t.file_code like CONCAT('%',#{fileCode},'%')
  368. </if>
  369. <if test="behosDateStart != null">
  370. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  371. </if>
  372. <if test="behosDateEnd != null">
  373. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  374. </if>
  375. <if test="leaveHosDateStart != null">
  376. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  377. </if>
  378. <if test="leaveHosDateEnd != null">
  379. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  380. </if>
  381. <if test="level != null and level != ''">
  382. and t.level = #{level}
  383. </if>
  384. <if test="isPlacefile != null and isPlacefile != ''">
  385. and t.is_placefile = #{isPlacefile}
  386. </if>
  387. and t.qc_type_id != 0) p
  388. where p.is_deleted="N"
  389. <if test="chName != null and chName !=''">
  390. AND p.chName like CONCAT('%',#{chName},'%')
  391. </if>
  392. <if test="mrName != null and mrName !=''">
  393. AND p.mrName like CONCAT('%',#{mrName},'%')
  394. </if>
  395. </select>
  396. <!-- <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  397. SELECT m.* FROM(
  398. SELECT
  399. a.name AS NAME,
  400. a.behospital_code AS behospitalCode,
  401. a.doctor_name AS doctorName,
  402. a.beh_dept_name AS deptName,
  403. a.beh_dept_id AS deptId,
  404. a.leave_hospital_date AS leaveHospitalDate,
  405. c.behospital_code,
  406. c.hospital_id,
  407. c.admissionNote,
  408. c.firstCourseNote,
  409. c.medHomePage,
  410. c.docAdviceNote,
  411. c.courseRecord,
  412. c.operationInfo,
  413. c.dischargeNote,
  414. c.admissionNoteScore,
  415. c.firstCourseNoteScore,
  416. c. medHomePageScore,
  417. c.docAdviceNoteScore,
  418. c.courseRecordScore,
  419. c.operationInfoScore,
  420. c.dischargeNoteScore,
  421. c.otherCase,
  422. (100.0-c.score_res) AS otherCaseScore,
  423. IFNULL(b.level,'未评分') AS `level`,
  424. g.check_name AS ch_name,
  425. h.check_name AS mr_name
  426. FROM
  427. med_behospital_info a LEFT JOIN med_qcresult_info b
  428. ON a.behospital_code = b.behospital_code AND b.is_deleted = 'N'
  429. LEFT JOIN (
  430. SELECT
  431. t.behospital_code,
  432. t.hospital_id,
  433. t.admissionNote,
  434. t.firstCourseNote,
  435. t.medHomePage,
  436. t.docAdviceNote,
  437. t.courseRecord,
  438. t.operationInfo,
  439. t.dischargeNote,
  440. t.otherCase,
  441. t.score_res,
  442. if(t.admissionNoteScoreOn >= t.admissionNoteTolScore, (t.admissionNoteTolScore + t.admissionNoteScoreTh),(t.admissionNoteScoreOn + t.admissionNoteScoreTh)) AS admissionNoteScore,
  443. if(t.firstCourseNoteScoreOn >= t.firstCourseNoteTolScore, (t.firstCourseNoteTolScore + t.firstCourseNoteScoreTh),(t.firstCourseNoteScoreOn + t.firstCourseNoteScoreTh)) AS firstCourseNoteScore,
  444. if(t.medHomePageScoreOn >= t.medHomePageTolScore, (t.medHomePageTolScore + t.medHomePageScoreTh),(t.medHomePageScoreOn + t.medHomePageScoreTh)) AS medHomePageScore,
  445. if(t.docAdviceNoteScoreOn >= t.docAdviceNoteTolScore, (t.docAdviceNoteTolScore + t.docAdviceNoteScoreTh),(t.docAdviceNoteScoreOn + t.docAdviceNoteScoreTh)) AS docAdviceNoteScore,
  446. if(t.courseRecordScoreOn >= t.courseRecordTolScore, (t.courseRecordTolScore + t.courseRecordScoreTh),(t.courseRecordScoreOn + t.courseRecordScoreTh)) AS courseRecordScore,
  447. if(t.operationInfoScoreOn >= t.operationInfoTolScore, (t.operationInfoTolScore + t.operationInfoScoreTh),(t.operationInfoScoreOn + t.operationInfoScoreTh)) AS operationInfoScore,
  448. if(t.dischargeNoteScoreOn >= t.dischargeNoteTolScore, (t.dischargeNoteTolScore + t.dischargeNoteScoreTh),(t.dischargeNoteScoreOn + t.dischargeNoteScoreTh)) AS dischargeNoteScore
  449. from(
  450. select
  451. t1.*,
  452. t2.admissionNoteTolScore,
  453. t2.firstCourseNoteTolScore,
  454. t2.medHomePageTolScore,
  455. t2.docAdviceNoteTolScore,
  456. t2.courseRecordTolScore,
  457. t2.operationInfoTolScore,
  458. t2.dischargeNoteTolScore,
  459. t2.score_res FROM (
  460. SELECT
  461. t1.behospital_code,
  462. t1.hospital_id,
  463. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  464. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  465. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  466. (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,
  467. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  468. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  469. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  470. (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,
  471. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  472. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  473. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  474. (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,
  475. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  476. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  477. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  478. (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,
  479. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  480. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  481. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  482. (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,
  483. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  484. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  485. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  486. (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,
  487. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  488. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  489. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  490. (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,
  491. 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
  492. FROM (
  493. SELECT
  494. c.behospital_code,
  495. c.hospital_id,
  496. a.mode_id,
  497. c.cases_score,
  498. c.score,
  499. c.msg,
  500. c.is_reject,
  501. c.cases_id
  502. FROM
  503. `qc_cases_entry` a,
  504. qc_mode b,
  505. med_qcresult_detail c,
  506. qc_cases_hospital d,
  507. med_behospital_info e
  508. 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'
  509. AND a.id = c.cases_entry_id
  510. AND a.mode_id = b.id
  511. AND c.cases_id = d.cases_id
  512. AND c.hospital_id = d.hospital_id
  513. AND c.behospital_code = e.behospital_code
  514. AND c.hospital_id = e.hospital_id
  515. <if test="hospitalId != null">
  516. and c.hospital_id = #{hospitalId}
  517. </if>
  518. <if test="deptName != null and deptName != ''">
  519. and e.beh_dept_name= #{deptName}
  520. </if>
  521. <if test="behospitalCode != null and behospitalCode != ''">
  522. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  523. </if>
  524. <if test="isPlacefile != null and isPlacefile != ''">
  525. and e.is_placefile = #{isPlacefile}
  526. </if>
  527. <if test="behosDateStart != null">
  528. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  529. </if>
  530. <if test="behosDateEnd != null">
  531. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  532. </if>
  533. <if test="leaveHosDateStart != null">
  534. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  535. </if>
  536. <if test="leaveHosDateEnd != null">
  537. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  538. </if>
  539. <if test="level != null and level != ''">
  540. and e.level = #{level}
  541. </if>
  542. <if test="level != null and level != ''">
  543. and e.level = #{level}
  544. </if>
  545. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  546. )t1 GROUP BY behospital_code)t1
  547. LEFT JOIN (
  548. SELECT m1.*, m2.score_res FROM(
  549. SELECT
  550. m1.hospital_id,
  551. m1.behospital_code,
  552. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  553. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  554. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  555. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  556. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  557. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  558. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  559. FROM (
  560. SELECT
  561. c.behospital_code,
  562. a.mode_id,
  563. c.cases_score,
  564. c.cases_id,
  565. c.hospital_id
  566. FROM
  567. `qc_cases_entry` a,
  568. qc_mode b,
  569. med_qcresult_detail c,
  570. qc_cases_hospital d,
  571. med_behospital_info e
  572. 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'
  573. AND a.id = c.cases_entry_id
  574. AND a.mode_id = b.id
  575. AND c.cases_id = d.cases_id
  576. AND c.hospital_id = d.hospital_id
  577. AND c.behospital_code = e.behospital_code
  578. AND c.hospital_id = e.hospital_id
  579. <if test="hospitalId != null">
  580. and c.hospital_id = #{hospitalId}
  581. </if>
  582. <if test="deptName != null and deptName != ''">
  583. and e.beh_dept_name= #{deptName}
  584. </if>
  585. <if test="behospitalCode != null and behospitalCode != ''">
  586. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  587. </if>
  588. <if test="isPlacefile != null and isPlacefile != ''">
  589. and e.is_placefile = #{isPlacefile}
  590. </if>
  591. <if test="behosDateStart != null">
  592. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  593. </if>
  594. <if test="behosDateEnd != null">
  595. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  596. </if>
  597. <if test="leaveHosDateStart != null">
  598. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  599. </if>
  600. <if test="leaveHosDateEnd != null">
  601. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  602. </if>
  603. <if test="level != null and level != ''">
  604. and e.level = #{level}
  605. </if>
  606. <if test="level != null and level != ''">
  607. and e.level = #{level}
  608. </if>
  609. GROUP BY mode_id
  610. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  611. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  612. ON m2.is_deleted = 'N'
  613. AND m1.hospital_id = m2.hospital_id
  614. AND m1.behospital_code = m2.behospital_code
  615. )t2
  616. ON t1.hospital_id = t2.hospital_id
  617. AND t1.behospital_code = t2.behospital_code)t)c
  618. ON a.behospital_code = c.behospital_code
  619. AND a.hospital_id = c.hospital_id
  620. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  621. ON a.behospital_code = g.behospital_code
  622. AND a.hospital_id = g.hospital_id
  623. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  624. ON a.behospital_code = h.behospital_code
  625. AND a.hospital_id = h.hospital_id
  626. where
  627. a.is_deleted = 'N'
  628. <if test="deptName != null and deptName != ''">
  629. and a.beh_dept_name= #{deptName}
  630. </if>
  631. <if test="doctorName != null and doctorName != ''">
  632. and CONCAT(
  633. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  634. like CONCAT('%',#{doctorName},'%')
  635. </if>
  636. <if test="name != null and name != ''">
  637. and a.name like CONCAT('%',#{name},'%')
  638. </if>
  639. <if test="doctorCode != null and doctorCode != ''">
  640. and (a.doctor_id = #{doctorCode}
  641. or a.beh_doctor_id = #{doctorCode}
  642. or a.director_doctor_id = #{doctorCode})
  643. </if>
  644. <if test="fileCode != null and fileCode != ''">
  645. and a.file_code like CONCAT('%',#{fileCode},'%')
  646. </if>
  647. <if test="hospitalId != null">
  648. and a.hospital_id = #{hospitalId}
  649. </if>
  650. <if test="behospitalCode != null and behospitalCode != ''">
  651. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  652. </if>
  653. <if test="behosDateStart != null">
  654. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  655. </if>
  656. <if test="behosDateEnd != null">
  657. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  658. </if>
  659. <if test="leaveHosDateStart != null">
  660. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  661. </if>
  662. <if test="leaveHosDateEnd != null">
  663. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  664. </if>
  665. <if test="level != null and level != ''">
  666. and a.level = #{level}
  667. </if>
  668. <if test="isPlacefile != null and isPlacefile != ''">
  669. and a.is_placefile = #{isPlacefile}
  670. </if>
  671. and a.qc_type_id != 0
  672. <if test="chName != null and chName !=''">
  673. AND g.ch_name like CONCAT('%',#{chName},'%')
  674. </if>
  675. <if test="mrName != null and mrName !=''">
  676. AND h.mr_name like CONCAT('%',#{mrName},'%')
  677. </if>)m
  678. </select>-->
  679. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  680. SELECT
  681. a.*, u.linkman,
  682. appeal.id appealInfoId,
  683. appeal.appeal_operation_type appealOperationType,
  684. appeal.example_status exampleStatus,
  685. appeal.reviewer,
  686. appeal.exampleDate
  687. FROM
  688. (
  689. SELECT DISTINCT
  690. b.`name` model_name,
  691. c.score,
  692. c.msg,
  693. c.cases_entry_id,
  694. c.is_reject,
  695. c.id id,
  696. c.info,
  697. a.cases_id cases_id,
  698. d.score cases_score,
  699. b.id model_id,
  700. a. NAME standard_msg,
  701. c.opt_type,
  702. c.grade_type,
  703. c.gmt_create,
  704. c.gmt_modified,
  705. c.modifier,
  706. c.is_deleted,
  707. c.remark,
  708. c.explain_info AS explainInfo,
  709. a.type,
  710. a.drgs,
  711. c.hospital_id,
  712. c.behospital_code
  713. FROM
  714. `qc_cases_entry` a,
  715. qc_mode b,
  716. med_qcresult_detail c,
  717. qc_cases_hospital d
  718. WHERE
  719. a.is_deleted = 'N'
  720. AND b.is_deleted = 'N'
  721. AND d.is_deleted = 'N'
  722. AND a.id = c.cases_entry_id
  723. AND a.mode_id = b.id
  724. AND c.cases_id = d.cases_id
  725. AND c.hospital_id = d.hospital_id
  726. AND c.hospital_id = #{hospitalId}
  727. <if test="qcresultInfoId != null">
  728. AND c.qcresult_info_id = #{qcresultInfoId}
  729. </if>
  730. AND c.behospital_code = #{behospitalCode}
  731. ORDER BY
  732. b.order_no,
  733. c.grade_type DESC,
  734. a.order_no
  735. ) a
  736. LEFT JOIN sys_user u ON u.id = a.modifier
  737. AND u.is_deleted = 'N'
  738. LEFT JOIN (
  739. SELECT
  740. appeal.id,
  741. appeal.cases_entry_id,
  742. appeal.behospital_code,
  743. appeal.hospital_id,
  744. appeal.appeal_operation_type,
  745. examine.example_status,
  746. u.linkman reviewer,
  747. examine.gmt_create exampleDate
  748. FROM
  749. med_appeal_info appeal
  750. JOIN med_appeal_examine_info examine ON examine.appeal_info_id = appeal.id
  751. LEFT JOIN sys_user u ON appeal.check_id = u.id
  752. AND u.is_deleted = 'N'
  753. WHERE
  754. appeal.is_deleted = 'N'
  755. ) appeal ON a.cases_entry_id = appeal.cases_entry_id
  756. AND a.hospital_id = appeal.hospital_id
  757. AND a.behospital_code = appeal.behospital_code
  758. </select>
  759. <select id="getForeignMsg" resultType="com.diagbot.dto.MsgDTO">
  760. SELECT
  761. a.*, u.linkman,
  762. appeal.id appealInfoId,
  763. appeal.appeal_operation_type appealOperationType,
  764. appeal.example_status exampleStatus
  765. FROM
  766. (
  767. SELECT DISTINCT
  768. b.`name` model_name,
  769. c.score,
  770. c.msg,
  771. c.cases_entry_id,
  772. c.is_reject,
  773. c.id id,
  774. c.info,
  775. a.cases_id cases_id,
  776. d.score cases_score,
  777. b.id model_id,
  778. a. NAME standard_msg,
  779. c.opt_type,
  780. c.grade_type,
  781. c.gmt_create,
  782. c.gmt_modified,
  783. c.modifier,
  784. c.is_deleted,
  785. c.remark,
  786. c.explain_info AS explainInfo,
  787. a.type,
  788. a.drgs,
  789. c.hospital_id,
  790. c.behospital_code
  791. FROM
  792. `qc_cases_entry` a,
  793. qc_mode b,
  794. med_qcresult_detail c,
  795. qc_cases_hospital d
  796. WHERE
  797. a.is_deleted = 'N'
  798. AND b.is_deleted = 'N'
  799. AND c.is_deleted = 'N'
  800. AND d.is_deleted = 'N'
  801. AND a.id = c.cases_entry_id
  802. AND a.mode_id = b.id
  803. AND c.cases_id = d.cases_id
  804. AND c.hospital_id = d.hospital_id
  805. AND c.hospital_id = #{hospitalId}
  806. <if test="qcresultInfoId != null">
  807. AND c.qcresult_info_id = #{qcresultInfoId}
  808. </if>
  809. AND c.behospital_code = #{behospitalCode}
  810. ORDER BY
  811. b.order_no,
  812. c.grade_type DESC,
  813. a.order_no
  814. ) a
  815. LEFT JOIN sys_user u ON u.id = a.modifier
  816. AND u.is_deleted = 'N'
  817. LEFT JOIN (
  818. SELECT
  819. appeal.id,
  820. appeal.cases_entry_id,
  821. appeal.behospital_code,
  822. appeal.hospital_id,
  823. appeal.appeal_operation_type,
  824. examine.example_status
  825. FROM
  826. med_appeal_info appeal
  827. JOIN med_appeal_examine_info examine ON examine.appeal_info_id = appeal.id
  828. WHERE
  829. appeal.is_deleted = 'N'
  830. ) appeal ON a.cases_entry_id = appeal.cases_entry_id
  831. AND a.hospital_id = appeal.hospital_id
  832. AND a.behospital_code = appeal.behospital_code
  833. </select>
  834. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  835. SELECT b.id model_id,b.`name` model_name,
  836. d.score,d.msg,d.cases_entry_id,d.is_reject,
  837. a.cases_id cases_id, a.name standard_msg,a.code
  838. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  839. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  840. and a.mode_id = b.id
  841. and a.id = d.cases_entry_id
  842. and d.hospital_id = #{hospitalId}
  843. and a.code in
  844. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  845. #{item}
  846. </foreach>
  847. <if test="modeId != null">
  848. and a.mode_id = #{modeId}
  849. </if>
  850. order by b.order_no, a.order_no;
  851. </select>
  852. <!--病案管理指标基础sql明细-->
  853. <select id="getBaseIndex" parameterType="com.diagbot.vo.MedIndexFilterVO" resultType="java.util.Map">
  854. select
  855. f1.firWorkNum,
  856. f2.secWorkNum,
  857. f3.thrWorkNum,
  858. f3.forWorkNum,
  859. f3.sixWorkNum
  860. from (
  861. SELECT count(DISTINCT a.behospital_code) as firWorkNum
  862. FROM
  863. med_behospital_info a
  864. WHERE
  865. a.is_deleted = 'N'
  866. AND a.is_placefile = 1
  867. <if test="hospitalId != null and hospitalId != ''">
  868. AND a.hospital_id = #{hospitalId}
  869. </if>
  870. <![CDATA[AND a.qc_type_id <>0 ]]>
  871. <if test="startDate != null and startDate != ''">
  872. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  873. </if>
  874. <if test="endDate != null and endDate != ''">
  875. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  876. </if>)f1,
  877. ( SELECT count(DISTINCT a.behospital_code) AS secWorkNum
  878. FROM
  879. med_outpatient_info a
  880. WHERE
  881. a.is_deleted = 'N'
  882. <if test="startDate != null and startDate != ''">
  883. <![CDATA[ AND a.visit_date >= #{lastStartDate}]]>
  884. </if>
  885. <if test="endDate != null and endDate != ''">
  886. <![CDATA[ AND a.visit_date <= #{lastEndDate}]]>
  887. </if>
  888. <if test="hospitalId != null and hospitalId != ''">
  889. AND a.hospital_id = #{hospitalId}
  890. </if>)f2,(
  891. select
  892. count(DISTINCT case when <![CDATA[m.behospital_date >= #{startDate}]]> and <![CDATA[m.behospital_date <= #{endDate}]]>
  893. and m.is_placefile = 0 then m.behospital_code else null end) as thrWorkNum,
  894. 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,
  895. 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
  896. from(
  897. SELECT DISTINCT a.*,b.level
  898. FROM
  899. med_behospital_info a,
  900. med_qcresult_info b
  901. WHERE
  902. a.is_deleted = 'N'
  903. AND b.is_deleted = 'N'
  904. AND a.hospital_id = b.hospital_id
  905. AND a.behospital_code = b.behospital_code
  906. <![CDATA[AND a.qc_type_id <>0 ]]>
  907. <if test="hospitalId != null and hospitalId != ''">
  908. AND a.hospital_id = #{hospitalId}
  909. </if>)m
  910. )f3
  911. </select>
  912. <!-- 病案管理规则质控缺陷病历总数查询-->
  913. <select id="getMedManageParams" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.MedManageParamsDTO">
  914. SELECT
  915. f1.behospitalCode,
  916. <if test="flagStr != null and flagStr == 1 ">
  917. f2.rep_name as repName,
  918. </if>
  919. <if test="flagStr != null and flagStr == 2">
  920. f3.da_item_name as daItemName,
  921. f3.da_status AS daStatus,
  922. f3.doctor_advice_type as doctorAdviceType,
  923. </if>
  924. <if test="flagStr != null and flagStr == 4 ">
  925. f5.content as content,
  926. f5.rec_title as recTitle,
  927. </if>
  928. f1.hospitalId
  929. from(
  930. SELECT DISTINCT
  931. a.hospital_id as hospitalId,
  932. a.behospital_code as behospitalCode
  933. FROM
  934. med_behospital_info a,
  935. med_qcresult_info b
  936. WHERE
  937. a.is_deleted = 'N'
  938. AND b.is_deleted = 'N'
  939. AND a.hospital_id = b.hospital_id
  940. AND a.behospital_code = b.behospital_code
  941. AND <![CDATA[a.leave_hospital_date >= #{startDate}]]>
  942. AND <![CDATA[a.leave_hospital_date <= #{endDate}]]>
  943. AND a.is_placefile = 1
  944. <![CDATA[AND a.qc_type_id <>0 ]]>
  945. <if test="hospitalId != null and hospitalId != ''">
  946. AND a.hospital_id = #{hospitalId}
  947. </if>)f1
  948. <if test="flagStr != null and flagStr == 1 ">
  949. join med_lis_info f2
  950. on f2.is_deleted = 'N'
  951. AND f1.hospitalId = f2.hospital_id
  952. AND f1.behospitalCode = f2.behospital_code
  953. </if>
  954. <if test="flagStr != null and flagStr == 2">
  955. join med_doctor_advice f3
  956. on f3.is_deleted = 'N'
  957. AND f1.hospitalId = f3.hospital_id
  958. AND f1.behospitalCode = f3.behospital_code
  959. </if>
  960. <if test="flagStr != null and flagStr == 3">
  961. join med_qcresult_detail f4
  962. on f4.is_deleted = 'N'
  963. AND f1.hospitalId = f4.hospital_id
  964. AND f1.behospitalCode = f4.behospital_code
  965. AND f4.is_reject = 1
  966. </if>
  967. <if test="flagStr != null and flagStr == 4">
  968. join str_informed_consent f5
  969. on f5.is_deleted = 'N'
  970. AND f1.hospitalId = f5.hospital_id
  971. AND f1.behospitalCode = f5.behospital_code
  972. </if>
  973. </select>
  974. <!-- 各科室缺陷占比-全院-首页 -->
  975. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  976. resultType="com.diagbot.dto.NumDTO">
  977. SELECT
  978. a.beh_dept_id as id,
  979. a.beh_dept_name as name,
  980. count(*) AS num
  981. FROM
  982. med_behospital_info a,
  983. med_qcresult_info c,
  984. med_qcresult_detail d
  985. WHERE
  986. a.behospital_code = c.behospital_code
  987. AND a.hospital_id = c.hospital_id
  988. AND a.behospital_code = d.behospital_code
  989. AND a.hospital_id = d.hospital_id
  990. AND a.is_deleted = 'N'
  991. AND c.is_deleted = 'N'
  992. AND d.is_deleted = 'N'
  993. <if test="isPlacefile != null and isPlacefile != ''">
  994. and a.is_placefile = #{isPlacefile}
  995. </if>
  996. <![CDATA[AND a.qc_type_id <>0 ]]>
  997. <if test="hospitalId != null and hospitalId != ''">
  998. AND a.hospital_id = #{hospitalId}
  999. </if>
  1000. <if test="isPlacefile != null and isPlacefile == 0">
  1001. <if test="startDate != null and startDate != ''">
  1002. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1003. </if>
  1004. <if test="endDate != null and endDate != ''">
  1005. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1006. </if>
  1007. </if>
  1008. <if test="isPlacefile != null and isPlacefile == 1">
  1009. <if test="startDate != null and startDate != ''">
  1010. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1011. </if>
  1012. <if test="endDate != null and endDate != ''">
  1013. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1014. </if>
  1015. </if>
  1016. GROUP BY
  1017. a.beh_dept_id,
  1018. a.beh_dept_name
  1019. ORDER BY
  1020. count(*) DESC
  1021. </select>
  1022. <!-- 质控结果缺陷总数查询-->
  1023. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1024. SELECT
  1025. count(*) AS totle
  1026. FROM
  1027. med_behospital_info a,
  1028. med_qcresult_info c,
  1029. med_qcresult_detail d
  1030. WHERE
  1031. a.behospital_code = c.behospital_code
  1032. AND a.hospital_id = c.hospital_id
  1033. AND a.behospital_code = d.behospital_code
  1034. AND a.hospital_id = d.hospital_id
  1035. AND a.is_deleted = 'N'
  1036. AND c.is_deleted = 'N'
  1037. AND d.is_deleted = 'N'
  1038. <if test="isPlacefile != null and isPlacefile != ''">
  1039. and a.is_placefile = #{isPlacefile}
  1040. </if>
  1041. <![CDATA[AND a.qc_type_id <>0 ]]>
  1042. <if test="hospitalId != null and hospitalId != ''">
  1043. AND a.hospital_id = #{hospitalId}
  1044. </if>
  1045. <if test="isPlacefile != null and isPlacefile == 0">
  1046. <if test="startDate != null and startDate != ''">
  1047. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1048. </if>
  1049. <if test="endDate != null and endDate != ''">
  1050. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1051. </if>
  1052. </if>
  1053. <if test="isPlacefile != null and isPlacefile == 1">
  1054. <if test="startDate != null and startDate != ''">
  1055. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1056. </if>
  1057. <if test="endDate != null and endDate != ''">
  1058. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1059. </if>
  1060. </if>
  1061. </select>
  1062. <!--获取病历-->
  1063. <select id="getNoGrade" resultMap="BaseResultMap">
  1064. select * from med_behospital_info a
  1065. where a.is_deleted = 'N'
  1066. and a.qc_type_id != 0
  1067. <if test="isPlacefile != null and isPlacefile != ''">
  1068. and a.is_placefile = #{isPlacefile}
  1069. </if>
  1070. <if test="filterFlag != null and filterFlag == 0">
  1071. and
  1072. not EXISTS (
  1073. SELECT
  1074. 1
  1075. FROM
  1076. med_qcresult_info b
  1077. WHERE
  1078. b.is_deleted = 'N'
  1079. AND a.hospital_id = b.hospital_id
  1080. AND a.behospital_code = b.behospital_code
  1081. )
  1082. </if>
  1083. <if test="leaveDate != null">
  1084. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  1085. </if>
  1086. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  1087. and a.hospital_id in
  1088. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  1089. #{item}
  1090. </foreach>
  1091. </if>
  1092. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  1093. and a.behospital_code in
  1094. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  1095. #{item}
  1096. </foreach>
  1097. </if>
  1098. <if test="individuation != null and individuation.contains(1)">
  1099. union
  1100. select * from med_behospital_info b
  1101. where b.is_deleted = 'N'
  1102. and b.qc_type_id != 0
  1103. <if test="isPlacefile != null and isPlacefile != ''">
  1104. and b.is_placefile = #{isPlacefile}
  1105. </if>
  1106. <if test="startLeaveDate != null">
  1107. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  1108. </if>
  1109. <if test="endLeaveDate != null">
  1110. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  1111. </if>
  1112. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  1113. and b.hospital_id in
  1114. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  1115. #{item}
  1116. </foreach>
  1117. </if>
  1118. </if>
  1119. </select>
  1120. <!--质控评分(科室)分页-->
  1121. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1122. SELECT * from (
  1123. SELECT
  1124. t.*,
  1125. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1126. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1127. g.check_type as ch_type,
  1128. h.check_type AS mr_type,
  1129. g.check_name as ch_name,
  1130. h.check_name as mr_name,
  1131. g.check_time as ch_time,
  1132. h.check_time AS mr_time
  1133. FROM
  1134. ( SELECT
  1135. a.*,
  1136. IFNULL(b.level, '未评分') AS `level`,
  1137. b.grade_type,
  1138. b.score_res,
  1139. e.score_res as score_bn,
  1140. b.gmt_create AS grade_time,
  1141. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1142. FROM
  1143. med_behospital_info a
  1144. JOIN sys_user_dept d
  1145. ON a.hospital_id = d.hospital_id
  1146. AND a.beh_dept_id = d.dept_id
  1147. LEFT JOIN med_qcresult_info b
  1148. ON a.behospital_code = b.behospital_code
  1149. AND b.is_deleted = 'N'
  1150. LEFT JOIN med_qcresult_cases e
  1151. on a.behospital_code = e.behospital_code
  1152. AND e.is_deleted = 'N'
  1153. and e.cases_id = 243
  1154. LEFT JOIN med_home_page c
  1155. ON a.behospital_code = c.behospital_code
  1156. AND c.is_deleted = 'N'
  1157. WHERE d.is_deleted = 'N'
  1158. AND d.user_id = #{userId}
  1159. <if test="pageType == 3">
  1160. AND b.level is not null
  1161. </if>
  1162. ) t
  1163. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1164. ON t.behospital_code = g.behospital_code
  1165. AND t.hospital_id = g.hospital_id
  1166. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1167. ON t.behospital_code = h.behospital_code
  1168. AND t.hospital_id = h.hospital_id
  1169. where t.is_deleted = 'N'
  1170. <if test="isDaytime != null and isDaytime != ''">
  1171. and t.is_daytime = #{isDaytime}
  1172. </if>
  1173. <if test="diagnose != null and diagnose != ''">
  1174. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1175. </if>
  1176. <if test="deptName != null and deptName != ''">
  1177. and t.beh_dept_name = #{deptName}
  1178. </if>
  1179. <if test="doctorName != null and doctorName != ''">
  1180. and CONCAT(
  1181. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  1182. like CONCAT('%',#{doctorName},'%')
  1183. </if>
  1184. <if test="doctorCode != null and doctorCode != ''">
  1185. and (t.doctor_id = #{doctorCode}
  1186. or t.beh_doctor_id = #{doctorCode}
  1187. or t.director_doctor_id = #{doctorCode})
  1188. </if>
  1189. <if test="name != null and name != ''">
  1190. and t.name like CONCAT('%',#{name},'%')
  1191. </if>
  1192. <if test="hospitalId != null">
  1193. and t.hospital_id = #{hospitalId}
  1194. </if>
  1195. <if test="behospitalCode != null and behospitalCode != ''">
  1196. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1197. </if>
  1198. <if test="fileCode != null and fileCode != ''">
  1199. and t.file_code like CONCAT('%',#{fileCode},'%')
  1200. </if>
  1201. <if test="behosDateStart != null">
  1202. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1203. </if>
  1204. <if test="behosDateEnd != null">
  1205. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1206. </if>
  1207. <if test="leaveHosDateStart != null">
  1208. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1209. </if>
  1210. <if test="leaveHosDateEnd != null">
  1211. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1212. </if>
  1213. <if test="level != null and level != ''">
  1214. and t.level = #{level}
  1215. </if>
  1216. <if test="isPlacefile != null and isPlacefile != ''">
  1217. and t.is_placefile = #{isPlacefile}
  1218. </if>
  1219. and t.qc_type_id != 0) p
  1220. where p.is_deleted="N"
  1221. <if test="checkStatus != null ">
  1222. and p.check_status = #{checkStatus}
  1223. </if>
  1224. <if test="mrStatus != null ">
  1225. AND p.mr_status = #{mrStatus}
  1226. </if>
  1227. <if test="chName != null and chName !=''">
  1228. AND p.ch_name like CONCAT('%',#{chName},'%')
  1229. </if>
  1230. <if test="mrName != null and mrName !=''">
  1231. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1232. </if>
  1233. <if test="chTimeStart != null">
  1234. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1235. </if>
  1236. <if test="chTimeEnd != null">
  1237. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1238. </if>
  1239. <if test="mrTimeStart != null">
  1240. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1241. </if>
  1242. <if test="mrTimeEnd != null">
  1243. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1244. </if>
  1245. </select>
  1246. <!--质控评分(个人)分页-->
  1247. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1248. Select * from (
  1249. select t.*,
  1250. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1251. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1252. g.check_type as ch_type,
  1253. h.check_type AS mr_type,
  1254. g.check_name as ch_name,
  1255. h.check_name as mr_name,
  1256. g.check_time as ch_time,
  1257. h.check_time AS mr_time
  1258. from (SELECT
  1259. a.*,
  1260. IFNULL(b.level, '未评分') AS `level`,
  1261. b.grade_type,
  1262. b.score_res,
  1263. e.score_res as score_bn,
  1264. b.gmt_create AS grade_time,
  1265. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1266. FROM
  1267. med_behospital_info a
  1268. JOIN
  1269. (SELECT
  1270. u.id,
  1271. u.linkman AS linkman,
  1272. uh.hospital_id
  1273. FROM
  1274. sys_user u
  1275. JOIN sys_user_hospital uh
  1276. ON u.id = uh.user_id
  1277. WHERE u.is_deleted = "N"
  1278. AND u.id = #{userId}
  1279. AND uh.hospital_id = #{hospitalId}) u1
  1280. ON a.hospital_id = u1.hospital_id
  1281. LEFT JOIN med_qcresult_info b
  1282. ON a.behospital_code = b.behospital_code
  1283. AND b.is_deleted = 'N'
  1284. LEFT JOIN med_qcresult_cases e
  1285. on a.behospital_code = e.behospital_code
  1286. AND e.is_deleted = 'N'
  1287. and e.cases_id = 243
  1288. LEFT JOIN med_home_page c
  1289. ON a.behospital_code = c.behospital_code
  1290. AND c.is_deleted = 'N'
  1291. WHERE
  1292. a.is_deleted = 'N'
  1293. and a.doctor_name = u1.linkman
  1294. or a.beh_doctor_name = u1.linkman
  1295. or a.director_doctor_name = u1.linkman
  1296. ) t
  1297. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1298. ON t.behospital_code = g.behospital_code
  1299. AND t.hospital_id = g.hospital_id
  1300. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1301. ON t.behospital_code = h.behospital_code
  1302. AND t.hospital_id = h.hospital_id
  1303. WHERE t.is_deleted = 'N'
  1304. <if test="isDaytime != null and isDaytime != ''">
  1305. and t.is_daytime = #{isDaytime}
  1306. </if>
  1307. <if test="diagnose != null and diagnose != ''">
  1308. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1309. </if>
  1310. <if test="deptName != null and deptName != ''">
  1311. and t.beh_dept_name = #{deptName}
  1312. </if>
  1313. <if test="name != null and name != ''">
  1314. and t.name like CONCAT('%',#{name},'%')
  1315. </if>
  1316. <if test="fileCode != null and fileCode != ''">
  1317. and t.file_code like CONCAT('%',#{fileCode},'%')
  1318. </if>
  1319. <if test="behospitalCode != null and behospitalCode != ''">
  1320. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1321. </if>
  1322. <if test="behosDateStart != null">
  1323. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1324. </if>
  1325. <if test="behosDateEnd != null">
  1326. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1327. </if>
  1328. <if test="leaveHosDateStart != null">
  1329. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1330. </if>
  1331. <if test="leaveHosDateEnd != null">
  1332. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1333. </if>
  1334. <if test="level != null and level != ''">
  1335. and t.level = #{level}
  1336. </if>
  1337. <if test="isPlacefile != null and isPlacefile != ''">
  1338. and t.is_placefile = #{isPlacefile}
  1339. </if>
  1340. and t.qc_type_id != 0) p
  1341. where p.is_deleted="N"
  1342. <if test="checkStatus != null ">
  1343. and p.check_status = #{checkStatus}
  1344. </if>
  1345. <if test="mrStatus != null ">
  1346. AND p.mr_status = #{mrStatus}
  1347. </if>
  1348. <if test="chName != null and chName !=''">
  1349. AND p.ch_name like CONCAT('%',#{chName},'%')
  1350. </if>
  1351. <if test="mrName != null and mrName !=''">
  1352. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1353. </if>
  1354. <if test="chTimeStart != null">
  1355. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1356. </if>
  1357. <if test="chTimeEnd != null">
  1358. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1359. </if>
  1360. <if test="mrTimeStart != null">
  1361. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1362. </if>
  1363. <if test="mrTimeEnd != null">
  1364. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1365. </if>
  1366. </select>
  1367. <!--质控评分(医疗组)分页-->
  1368. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1369. select * from (
  1370. select t.*,
  1371. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1372. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1373. g.check_type as ch_type,
  1374. h.check_type AS mr_type,
  1375. g.check_name as ch_name,
  1376. h.check_name as mr_name,
  1377. g.check_time as ch_time,
  1378. h.check_time AS mr_time
  1379. from (
  1380. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  1381. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  1382. LEFT JOIN med_qcresult_info b
  1383. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  1384. LEFT JOIN med_qcresult_cases e
  1385. on a.behospital_code = e.behospital_code
  1386. AND e.is_deleted = 'N'
  1387. and e.cases_id = 243
  1388. left join med_home_page c
  1389. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  1390. ) t
  1391. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1392. ON t.behospital_code = g.behospital_code
  1393. AND t.hospital_id = g.hospital_id
  1394. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1395. ON t.behospital_code = h.behospital_code
  1396. AND t.hospital_id = h.hospital_id
  1397. WHERE t.is_deleted = 'N'
  1398. and
  1399. t.doctor_id in (
  1400. SELECT doctor_id FROM `bas_doctor_info`
  1401. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  1402. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  1403. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  1404. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  1405. and c1.username = c3.doctor_id
  1406. and c2.hospital_id = #{hospitalId}
  1407. and c1.id = #{userId}
  1408. )
  1409. )
  1410. <if test="isDaytime != null and isDaytime != ''">
  1411. and t.is_daytime = #{isDaytime}
  1412. </if>
  1413. <if test="diagnose != null and diagnose != ''">
  1414. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1415. </if>
  1416. <if test="doctorName != null and doctorName != ''">
  1417. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  1418. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  1419. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  1420. </if>
  1421. <if test="name != null and name != ''">
  1422. and t.name like CONCAT('%',#{name},'%')
  1423. </if>
  1424. <if test="doctorCode != null and doctorCode != ''">
  1425. and (t.doctor_id = #{doctorCode}
  1426. or t.beh_doctor_id = #{doctorCode}
  1427. or t.director_doctor_id = #{doctorCode})
  1428. </if>
  1429. <if test="fileCode != null and fileCode != ''">
  1430. and t.file_code like CONCAT('%',#{fileCode},'%')
  1431. </if>
  1432. <if test="hospitalId != null">
  1433. and t.hospital_id = #{hospitalId}
  1434. </if>
  1435. <if test="behospitalCode != null and behospitalCode != ''">
  1436. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1437. </if>
  1438. <if test="behosDateStart != null">
  1439. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1440. </if>
  1441. <if test="behosDateEnd != null">
  1442. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1443. </if>
  1444. <if test="leaveHosDateStart != null">
  1445. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1446. </if>
  1447. <if test="leaveHosDateEnd != null">
  1448. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1449. </if>
  1450. <if test="level != null and level != ''">
  1451. and t.level = #{level}
  1452. </if>
  1453. <if test="isPlacefile != null and isPlacefile != ''">
  1454. and t.is_placefile = #{isPlacefile}
  1455. </if>
  1456. and t.qc_type_id != 0) p
  1457. where p.is_deleted="N"
  1458. <if test="checkStatus != null ">
  1459. and p.check_status = #{checkStatus}
  1460. </if>
  1461. <if test="mrStatus != null ">
  1462. AND p.mr_status = #{mrStatus}
  1463. </if>
  1464. <if test="chName != null and chName !=''">
  1465. AND p.ch_name like CONCAT('%',#{chName},'%')
  1466. </if>
  1467. <if test="mrName != null and mrName !=''">
  1468. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1469. </if>
  1470. <if test="chTimeStart != null">
  1471. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1472. </if>
  1473. <if test="chTimeEnd != null">
  1474. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1475. </if>
  1476. <if test="mrTimeStart != null">
  1477. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1478. </if>
  1479. <if test="mrTimeEnd != null">
  1480. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1481. </if>
  1482. </select>
  1483. <!-- 出院总人数统计-全院-首页 -->
  1484. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1485. SELECT
  1486. COUNT(*)
  1487. FROM
  1488. med_behospital_info a
  1489. WHERE
  1490. a.is_deleted = 'N'
  1491. AND a.qc_type_id != 0
  1492. <if test="isPlacefile != null and isPlacefile != ''">
  1493. and a.is_placefile = #{isPlacefile}
  1494. </if>
  1495. <if test="hospitalId != null and hospitalId != ''">
  1496. AND a.hospital_id = #{hospitalId}
  1497. </if>
  1498. <if test="isPlacefile != null and isPlacefile == 0">
  1499. <if test="startDate != null and startDate != ''">
  1500. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1501. </if>
  1502. <if test="endDate != null and endDate != ''">
  1503. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1504. </if>
  1505. </if>
  1506. <if test="isPlacefile != null and isPlacefile == 1">
  1507. <if test="startDate != null and startDate != ''">
  1508. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1509. </if>
  1510. <if test="endDate != null and endDate != ''">
  1511. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1512. </if>
  1513. </if>
  1514. </select>
  1515. <!-- 新生儿出院人数统计-全院-首页 -->
  1516. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1517. SELECT
  1518. COUNT(*)
  1519. FROM
  1520. med_behospital_info a,
  1521. med_home_page b
  1522. WHERE
  1523. a.is_deleted = 'N'
  1524. AND b.is_deleted = 'N'
  1525. AND a.hospital_id = b.hospital_id
  1526. AND a.behospital_code = b.behospital_code
  1527. AND (
  1528. ( IFNULL( b.newborn_behospital_weight, '' ) != '' AND b.newborn_behospital_weight != '0' AND b.newborn_behospital_weight != '-' AND b.newborn_behospital_weight != '—'))
  1529. <![CDATA[AND a.qc_type_id <>0 ]]>
  1530. <if test="hospitalId != null and hospitalId != ''">
  1531. AND a.hospital_id = #{hospitalId}
  1532. </if>
  1533. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1534. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1535. </select>
  1536. <!-- 死亡人数统计-全院-首页 -->
  1537. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1538. select COUNT(*) from(
  1539. SELECT distinct a.*
  1540. FROM
  1541. med_behospital_info a,
  1542. med_medical_record b,
  1543. med_medical_record_content c
  1544. WHERE
  1545. a.is_deleted = 'N'
  1546. AND b.is_deleted = 'N'
  1547. AND c.is_deleted = 'N'
  1548. AND a.hospital_id = b.hospital_id
  1549. AND a.hospital_id = c.hospital_id
  1550. AND a.behospital_code = b.behospital_code
  1551. AND b.rec_id = c.rec_id
  1552. and b.mode_id = '24'
  1553. <if test="isPlacefile != null and isPlacefile != ''">
  1554. and a.is_placefile = #{isPlacefile}
  1555. </if>
  1556. <![CDATA[AND a.qc_type_id <>0 ]]>
  1557. <if test="hospitalId != null and hospitalId != ''">
  1558. AND a.hospital_id = #{hospitalId}
  1559. </if>
  1560. <if test="isPlacefile != null and isPlacefile == 0">
  1561. <if test="startDate != null and startDate != ''">
  1562. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1563. </if>
  1564. <if test="endDate != null and endDate != ''">
  1565. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1566. </if>
  1567. </if>
  1568. <if test="isPlacefile != null and isPlacefile == 1">
  1569. <if test="startDate != null and startDate != ''">
  1570. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1571. </if>
  1572. <if test="endDate != null and endDate != ''">
  1573. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1574. </if>
  1575. </if>)m
  1576. </select>
  1577. <!-- 手术人数统计-全院-首页 -->
  1578. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1579. SELECT
  1580. COUNT( DISTINCT a.behospital_code )
  1581. FROM
  1582. med_behospital_info a,
  1583. med_medical_record c,
  1584. qc_mode d
  1585. WHERE
  1586. a.is_deleted = 'N'
  1587. AND c.is_deleted = 'N'
  1588. AND d.is_deleted = 'N'
  1589. AND a.hospital_id = c.hospital_id
  1590. AND a.behospital_code = c.behospital_code
  1591. AND c.mode_id = d.id
  1592. <if test="isPlacefile != null and isPlacefile != ''">
  1593. and a.is_placefile = #{isPlacefile}
  1594. </if>
  1595. AND d.`name` = '手术记录'
  1596. <![CDATA[AND a.qc_type_id <>0 ]]>
  1597. <if test="hospitalId != null and hospitalId != ''">
  1598. AND a.hospital_id = #{hospitalId}
  1599. </if>
  1600. <if test="isPlacefile != null and isPlacefile == 0">
  1601. <if test="startDate != null and startDate != ''">
  1602. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1603. </if>
  1604. <if test="endDate != null and endDate != ''">
  1605. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1606. </if>
  1607. </if>
  1608. <if test="isPlacefile != null and isPlacefile == 1">
  1609. <if test="startDate != null and startDate != ''">
  1610. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1611. </if>
  1612. <if test="endDate != null and endDate != ''">
  1613. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1614. </if>
  1615. </if>
  1616. </select>
  1617. <!-- 入院人数统计-首页 -->
  1618. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  1619. resultType="com.diagbot.dto.NumDTO">
  1620. SELECT
  1621. a.beh_dept_id AS id,
  1622. a.beh_dept_name AS NAME,
  1623. COUNT(*) AS num
  1624. FROM
  1625. med_behospital_info a
  1626. WHERE
  1627. a.is_deleted = 'N'
  1628. <if test="isPlacefile != null and isPlacefile != ''">
  1629. and a.is_placefile = #{isPlacefile}
  1630. </if>
  1631. <if test="hospitalId != null and hospitalId != ''">
  1632. AND a.hospital_id = #{hospitalId}
  1633. </if>
  1634. <if test="isPlacefile != null and isPlacefile == 0">
  1635. <if test="startDate != null and startDate != ''">
  1636. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1637. </if>
  1638. <if test="endDate != null and endDate != ''">
  1639. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1640. </if>
  1641. </if>
  1642. <if test="isPlacefile != null and isPlacefile == 1">
  1643. <if test="startDate != null and startDate != ''">
  1644. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1645. </if>
  1646. <if test="endDate != null and endDate != ''">
  1647. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1648. </if>
  1649. </if>
  1650. GROUP BY
  1651. a.beh_dept_id,
  1652. a.beh_dept_name
  1653. </select>
  1654. <!-- 出院总人数统计-科室-首页 -->
  1655. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1656. resultType="com.diagbot.dto.NumDTO">
  1657. SELECT
  1658. a.beh_dept_id AS id,
  1659. a.beh_dept_name AS NAME,
  1660. COUNT(*) AS num
  1661. FROM
  1662. med_behospital_info a,
  1663. sys_user_dept c
  1664. WHERE
  1665. a.is_deleted = 'N'
  1666. AND c.is_deleted = 'N'
  1667. AND a.hospital_id = c.hospital_id
  1668. AND a.beh_dept_id = c.dept_id
  1669. <if test="isPlacefile != null and isPlacefile != ''">
  1670. and a.is_placefile = #{isPlacefile}
  1671. </if>
  1672. <if test="userId!=null">
  1673. AND c.user_id = #{userId}
  1674. </if>
  1675. <if test="hospitalId != null and hospitalId != ''">
  1676. AND a.hospital_id = #{hospitalId}
  1677. </if>
  1678. <if test="isPlacefile != null and isPlacefile == 0">
  1679. <if test="startDate != null and startDate != ''">
  1680. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1681. </if>
  1682. <if test="endDate != null and endDate != ''">
  1683. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1684. </if>
  1685. </if>
  1686. <if test="isPlacefile != null and isPlacefile == 1">
  1687. <if test="startDate != null and startDate != ''">
  1688. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1689. </if>
  1690. <if test="endDate != null and endDate != ''">
  1691. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1692. </if>
  1693. </if>
  1694. GROUP BY
  1695. a.beh_dept_id,
  1696. a.beh_dept_name
  1697. </select>
  1698. <!-- 入院总人数统计-科室-首页 -->
  1699. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1700. resultType="com.diagbot.dto.AdmissionCountDTO">
  1701. SELECT
  1702. a.beh_dept_id as deptId,
  1703. a.beh_dept_name as deptName,
  1704. a.doctor_id as doctorId,
  1705. a.doctor_name as doctorName,
  1706. COUNT(*) AS num
  1707. FROM
  1708. med_behospital_info a,
  1709. sys_user_dept c
  1710. WHERE
  1711. a.is_deleted = 'N'
  1712. AND c.is_deleted = 'N'
  1713. AND a.hospital_id = c.hospital_id
  1714. AND a.beh_dept_id = c.dept_id
  1715. <if test="isPlacefile != null and isPlacefile != ''">
  1716. and a.is_placefile = #{isPlacefile}
  1717. </if>
  1718. <if test="userId!=null">
  1719. AND c.user_id = #{userId}
  1720. </if>
  1721. <if test="hospitalId != null and hospitalId != ''">
  1722. AND a.hospital_id = #{hospitalId}
  1723. </if>
  1724. <if test="isPlacefile != null and isPlacefile == 0">
  1725. <if test="startDate != null and startDate != ''">
  1726. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1727. </if>
  1728. <if test="endDate != null and endDate != ''">
  1729. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1730. </if>
  1731. </if>
  1732. <if test="isPlacefile != null and isPlacefile == 1">
  1733. <if test="startDate != null and startDate != ''">
  1734. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1735. </if>
  1736. <if test="endDate != null and endDate != ''">
  1737. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1738. </if>
  1739. </if>
  1740. GROUP BY
  1741. a.beh_dept_id,
  1742. a.beh_dept_name,
  1743. a.doctor_id,
  1744. a.doctor_name
  1745. </select>
  1746. <!-- 新生儿出院人数统计-科室-首页 -->
  1747. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1748. resultType="com.diagbot.dto.NumDTO">
  1749. SELECT
  1750. a.beh_dept_id AS id,
  1751. a.beh_dept_name AS NAME,
  1752. COUNT(*) AS num
  1753. FROM
  1754. med_behospital_info a,
  1755. med_home_page b,
  1756. sys_user_dept c
  1757. WHERE
  1758. a.is_deleted = 'N'
  1759. AND b.is_deleted = 'N'
  1760. AND c.is_deleted = 'N'
  1761. AND a.hospital_id = b.hospital_id
  1762. AND a.hospital_id = c.hospital_id
  1763. AND a.behospital_code = b.behospital_code
  1764. AND a.beh_dept_id = c.dept_id
  1765. AND (
  1766. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  1767. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1768. )
  1769. <if test="isPlacefile != null and isPlacefile != ''">
  1770. and a.is_placefile = #{isPlacefile}
  1771. </if>
  1772. <![CDATA[AND a.qc_type_id <>0 ]]>
  1773. <if test="userId!=null">
  1774. AND c.user_id = #{userId}
  1775. </if>
  1776. <if test="hospitalId != null and hospitalId != ''">
  1777. AND a.hospital_id = #{hospitalId}
  1778. </if>
  1779. <if test="isPlacefile != null and isPlacefile == 0">
  1780. <if test="startDate != null and startDate != ''">
  1781. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1782. </if>
  1783. <if test="endDate != null and endDate != ''">
  1784. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1785. </if>
  1786. </if>
  1787. <if test="isPlacefile != null and isPlacefile == 1">
  1788. <if test="startDate != null and startDate != ''">
  1789. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1790. </if>
  1791. <if test="endDate != null and endDate != ''">
  1792. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1793. </if>
  1794. </if>
  1795. GROUP BY
  1796. a.beh_dept_id,
  1797. a.beh_dept_name
  1798. </select>
  1799. <!-- 死亡人数统计-科室-首页 -->
  1800. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1801. resultType="com.diagbot.dto.NumDTO">
  1802. SELECT
  1803. a.beh_dept_id AS id,
  1804. a.beh_dept_name AS NAME,
  1805. COUNT(*) AS num
  1806. FROM
  1807. med_behospital_info a,
  1808. sys_user_dept c,
  1809. med_medical_record d,
  1810. med_medical_record_content e
  1811. WHERE
  1812. a.is_deleted = 'N'
  1813. AND c.is_deleted = 'N'
  1814. AND d.is_deleted = 'N'
  1815. AND e.is_deleted = 'N'
  1816. AND a.hospital_id = c.hospital_id
  1817. AND a.hospital_id = d.hospital_id
  1818. AND a.hospital_id = e.hospital_id
  1819. AND a.behospital_code = d.behospital_code
  1820. AND a.beh_dept_id = c.dept_id
  1821. AND d.rec_id = e.rec_id
  1822. AND d.mode_id = '24'
  1823. <if test="isPlacefile != null and isPlacefile != ''">
  1824. and a.is_placefile = #{isPlacefile}
  1825. </if>
  1826. <![CDATA[AND a.qc_type_id <>0 ]]>
  1827. <if test="userId!=null">
  1828. AND c.user_id = #{userId}
  1829. </if>
  1830. <if test="hospitalId != null and hospitalId != ''">
  1831. AND a.hospital_id = #{hospitalId}
  1832. </if>
  1833. <if test="isPlacefile != null and isPlacefile == 0">
  1834. <if test="startDate != null and startDate != ''">
  1835. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1836. </if>
  1837. <if test="endDate != null and endDate != ''">
  1838. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1839. </if>
  1840. </if>
  1841. <if test="isPlacefile != null and isPlacefile == 1">
  1842. <if test="startDate != null and startDate != ''">
  1843. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1844. </if>
  1845. <if test="endDate != null and endDate != ''">
  1846. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1847. </if>
  1848. </if>
  1849. GROUP BY
  1850. a.beh_dept_id,
  1851. a.beh_dept_name
  1852. </select>
  1853. <!-- 手术人数统计-科室-首页 -->
  1854. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1855. resultType="com.diagbot.dto.NumDTO">
  1856. SELECT
  1857. a.beh_dept_id AS id,
  1858. a.beh_dept_name AS NAME,
  1859. COUNT( DISTINCT a.behospital_code ) AS num
  1860. FROM
  1861. med_behospital_info a,
  1862. sys_user_dept c,
  1863. med_medical_record d,
  1864. qc_mode e
  1865. WHERE
  1866. a.is_deleted = 'N'
  1867. AND c.is_deleted = 'N'
  1868. AND d.is_deleted = 'N'
  1869. AND e.is_deleted = 'N'
  1870. AND a.hospital_id = c.hospital_id
  1871. AND a.hospital_id = d.hospital_id
  1872. AND a.behospital_code = d.behospital_code
  1873. AND a.beh_dept_id = c.dept_id
  1874. AND d.mode_id = e.id
  1875. AND e.`name` = '手术记录'
  1876. <if test="isPlacefile != null and isPlacefile != ''">
  1877. and a.is_placefile = #{isPlacefile}
  1878. </if>
  1879. <![CDATA[AND a.qc_type_id <>0 ]]>
  1880. <if test="userId!=null">
  1881. AND c.user_id = #{userId}
  1882. </if>
  1883. <if test="hospitalId != null and hospitalId != ''">
  1884. AND a.hospital_id = #{hospitalId}
  1885. </if>
  1886. <if test="isPlacefile != null and isPlacefile == 0">
  1887. <if test="startDate != null and startDate != ''">
  1888. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1889. </if>
  1890. <if test="endDate != null and endDate != ''">
  1891. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1892. </if>
  1893. </if>
  1894. <if test="isPlacefile != null and isPlacefile == 1">
  1895. <if test="startDate != null and startDate != ''">
  1896. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1897. </if>
  1898. <if test="endDate != null and endDate != ''">
  1899. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1900. </if>
  1901. </if>
  1902. GROUP BY
  1903. a.beh_dept_id,
  1904. a.beh_dept_name
  1905. </select>
  1906. <!-- 各科室缺陷占比排行(分页) -->
  1907. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1908. SELECT t.*
  1909. FROM
  1910. (SELECT
  1911. t1.beh_dept_name AS NAME,
  1912. t1.num AS num,
  1913. t2.totle AS totleNum,
  1914. round( t1.num / t2.totle, 4 ) AS percent,
  1915. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1916. FROM
  1917. (
  1918. SELECT
  1919. a.beh_dept_id,
  1920. a.beh_dept_name,
  1921. count(*) AS num
  1922. FROM
  1923. med_behospital_info a,
  1924. med_qcresult_info c,
  1925. med_qcresult_detail d
  1926. WHERE
  1927. a.behospital_code = c.behospital_code
  1928. AND a.hospital_id = c.hospital_id
  1929. AND a.behospital_code = d.behospital_code
  1930. AND a.hospital_id = d.hospital_id
  1931. AND a.is_deleted = 'N'
  1932. AND c.is_deleted = 'N'
  1933. AND d.is_deleted = 'N'
  1934. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1935. and a.is_placefile = #{filterPageVO.isPlacefile}
  1936. </if>
  1937. <![CDATA[AND a.qc_type_id <>0 ]]>
  1938. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1939. AND a.hospital_id = #{filterPageVO.hospitalId}
  1940. </if>
  1941. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1942. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1943. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1944. </if>
  1945. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1946. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1947. </if>
  1948. </if>
  1949. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1950. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1951. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1952. </if>
  1953. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1954. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1955. </if>
  1956. </if>
  1957. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1958. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1959. </if>
  1960. GROUP BY
  1961. a.beh_dept_id,
  1962. a.beh_dept_name
  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. WHERE
  1974. a.behospital_code = c.behospital_code
  1975. AND a.hospital_id = c.hospital_id
  1976. AND a.behospital_code = d.behospital_code
  1977. AND a.hospital_id = d.hospital_id
  1978. AND a.is_deleted = 'N'
  1979. AND c.is_deleted = 'N'
  1980. AND d.is_deleted = 'N'
  1981. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1982. and a.is_placefile = #{filterPageVO.isPlacefile}
  1983. </if>
  1984. <![CDATA[AND a.qc_type_id <>0 ]]>
  1985. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1986. AND a.hospital_id = #{filterPageVO.hospitalId}
  1987. </if>
  1988. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1989. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1990. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1991. </if>
  1992. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1993. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1994. </if>
  1995. </if>
  1996. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1997. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1998. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1999. </if>
  2000. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  2001. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  2002. </if>
  2003. </if>
  2004. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  2005. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  2006. </if>
  2007. ) t2
  2008. )t
  2009. </select>
  2010. <!-- 科室缺陷占比(主任医生) -->
  2011. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  2012. SELECT
  2013. t.*
  2014. FROM
  2015. (
  2016. SELECT
  2017. t1.NAME,
  2018. t1.num AS num,
  2019. t2.totle AS totleNum,
  2020. round( t1.num / t2.totle, 4 ) AS percent,
  2021. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  2022. FROM
  2023. (
  2024. SELECT
  2025. d.msg as name,
  2026. count(*) AS num
  2027. FROM
  2028. med_behospital_info a,
  2029. med_qcresult_info c,
  2030. med_qcresult_detail d,
  2031. sys_user_dept e
  2032. WHERE
  2033. a.behospital_code = c.behospital_code
  2034. AND a.hospital_id = c.hospital_id
  2035. AND a.behospital_code = d.behospital_code
  2036. AND a.hospital_id = d.hospital_id
  2037. AND a.is_deleted = 'N'
  2038. AND c.is_deleted = 'N'
  2039. AND d.is_deleted = 'N'
  2040. AND e.is_deleted = 'N'
  2041. AND a.beh_dept_id = e.dept_id
  2042. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  2043. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  2044. </if>
  2045. <![CDATA[AND a.qc_type_id <>0 ]]>
  2046. <if test="filterPageByDeptVO.userId!=null">
  2047. AND e.user_id = #{filterPageByDeptVO.userId}
  2048. </if>
  2049. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  2050. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  2051. </if>
  2052. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  2053. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2054. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  2055. </if>
  2056. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2057. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  2058. </if>
  2059. </if>
  2060. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  2061. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2062. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  2063. </if>
  2064. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2065. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  2066. </if>
  2067. </if>
  2068. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  2069. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  2070. </if>
  2071. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  2072. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  2073. </if>
  2074. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  2075. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  2076. </if>
  2077. GROUP BY
  2078. d.msg
  2079. ORDER BY
  2080. count(*) DESC
  2081. ) t1,
  2082. (
  2083. SELECT
  2084. count(*) AS totle
  2085. FROM
  2086. med_behospital_info a,
  2087. med_qcresult_info c,
  2088. med_qcresult_detail d,
  2089. sys_user_dept e
  2090. WHERE
  2091. a.behospital_code = c.behospital_code
  2092. AND a.hospital_id = c.hospital_id
  2093. AND a.behospital_code = d.behospital_code
  2094. AND a.hospital_id = d.hospital_id
  2095. AND a.is_deleted = 'N'
  2096. AND c.is_deleted = 'N'
  2097. AND d.is_deleted = 'N'
  2098. AND e.is_deleted = 'N'
  2099. AND a.beh_dept_id = e.dept_id
  2100. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  2101. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  2102. </if>
  2103. <![CDATA[AND a.qc_type_id <>0 ]]>
  2104. <if test="filterPageByDeptVO.userId!=null">
  2105. AND e.user_id = #{filterPageByDeptVO.userId}
  2106. </if>
  2107. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  2108. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  2109. </if>
  2110. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  2111. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2112. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  2113. </if>
  2114. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2115. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  2116. </if>
  2117. </if>
  2118. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  2119. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2120. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  2121. </if>
  2122. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2123. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  2124. </if>
  2125. </if>
  2126. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  2127. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  2128. </if>
  2129. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  2130. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  2131. </if>
  2132. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  2133. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  2134. </if>
  2135. ) t2
  2136. )t
  2137. </select>
  2138. <!-- 各科室缺陷占比(组合)-全院 -->
  2139. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2140. resultType="com.diagbot.dto.LevelStatisticsDTO">
  2141. SELECT
  2142. m1.deptId,
  2143. m1.deptName,
  2144. m1.entryNum,
  2145. m2.sameNum,
  2146. m1.mrNum,
  2147. m2.sameMrNum,
  2148. m1.totleValue,
  2149. m2.sameTotleValue,
  2150. m1.averageValue,
  2151. m2.sameAvgValue,
  2152. m1.firstLevelNum,
  2153. m2.sameFirstLevelNum,
  2154. m1.secondLevelNum,
  2155. m2.sameSecondLevelNum,
  2156. m1.thirdLevelNum,
  2157. m2.sameThirdLevelNum,
  2158. m1.firstLevelPercent,
  2159. m2.sameFirstLevelPercent,
  2160. m1.secondLevelPercent,
  2161. m2.sameSecondLevelPercent,
  2162. m1.thirdLevelPercent,
  2163. m2.sameThirdLevelPercent,
  2164. m1.firstLevelPercentStr,
  2165. m2.sameFirstLevelPercentStr,
  2166. m1.secondLevelPercentStr,
  2167. m2.sameSecondLevelPercentStr,
  2168. m1.thirdLevelPercentStr,
  2169. m2.sameThirdLevelPercentStr
  2170. FROM
  2171. (
  2172. SELECT
  2173. t1.deptId,
  2174. t1.deptName,
  2175. t2.entryNum,
  2176. t1.mrNum,
  2177. t1.totleValue,
  2178. t1.averageValue,
  2179. t1.firstLevelNum,
  2180. t1.secondLevelNum,
  2181. t1.thirdLevelNum,
  2182. t1.firstLevelPercent,
  2183. t1.secondLevelPercent,
  2184. t1.thirdLevelPercent,
  2185. t1.firstLevelPercentStr,
  2186. t1.secondLevelPercentStr,
  2187. t1.thirdLevelPercentStr
  2188. FROM
  2189. (
  2190. SELECT
  2191. a.beh_dept_id AS deptId,
  2192. a.beh_dept_name AS deptName,
  2193. count(*) AS mrNum,
  2194. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2195. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2196. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2197. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2198. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2199. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2200. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2201. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2202. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2203. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2204. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2205. FROM
  2206. med_behospital_info a,
  2207. med_qcresult_info c
  2208. WHERE
  2209. a.is_deleted = 'N'
  2210. AND c.is_deleted = 'N'
  2211. AND a.hospital_id = c.hospital_id
  2212. AND a.behospital_code = c.behospital_code
  2213. <if test="isPlacefile != null and isPlacefile != ''">
  2214. and a.is_placefile = #{isPlacefile}
  2215. </if>
  2216. AND a.qc_type_id != 0
  2217. <if test="hospitalId != null and hospitalId != ''">
  2218. AND a.hospital_id = #{hospitalId}
  2219. </if>
  2220. <if test="isPlacefile != null and isPlacefile == 0">
  2221. <if test="startDate != null and startDate != ''">
  2222. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2223. </if>
  2224. <if test="endDate != null and endDate != ''">
  2225. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2226. </if>
  2227. </if>
  2228. <if test="isPlacefile != null and isPlacefile == 1">
  2229. <if test="startDate != null and startDate != ''">
  2230. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2231. </if>
  2232. <if test="endDate != null and endDate != ''">
  2233. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2234. </if>
  2235. </if>
  2236. <if test="level != null and level != ''">
  2237. and c.level = #{level}
  2238. </if>
  2239. <if test="deptName != null and deptName != ''">
  2240. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2241. </if>
  2242. GROUP BY
  2243. a.beh_dept_id,
  2244. a.beh_dept_name
  2245. ) t1,
  2246. (
  2247. SELECT
  2248. a.beh_dept_id AS deptId,
  2249. a.beh_dept_name AS deptName,
  2250. count( * ) AS entryNum
  2251. FROM
  2252. med_behospital_info a,
  2253. med_qcresult_info c,
  2254. med_qcresult_detail d,
  2255. qc_cases_entry e
  2256. WHERE
  2257. a.is_deleted = 'N'
  2258. AND c.is_deleted = 'N'
  2259. AND d.is_deleted = 'N'
  2260. AND e.is_deleted = 'N'
  2261. AND a.hospital_id = c.hospital_id
  2262. AND a.hospital_id = d.hospital_id
  2263. AND a.behospital_code = c.behospital_code
  2264. AND a.behospital_code = d.behospital_code
  2265. AND d.cases_id = e.cases_id
  2266. AND d.cases_entry_id = e.id
  2267. <if test="isPlacefile != null and isPlacefile != ''">
  2268. and a.is_placefile = #{isPlacefile}
  2269. </if>
  2270. AND a.qc_type_id != 0
  2271. <if test="hospitalId != null and hospitalId != ''">
  2272. AND a.hospital_id = #{hospitalId}
  2273. </if>
  2274. <if test="isPlacefile != null and isPlacefile == 0">
  2275. <if test="startDate != null and startDate != ''">
  2276. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2277. </if>
  2278. <if test="endDate != null and endDate != ''">
  2279. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2280. </if>
  2281. </if>
  2282. <if test="isPlacefile != null and isPlacefile == 1">
  2283. <if test="startDate != null and startDate != ''">
  2284. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2285. </if>
  2286. <if test="endDate != null and endDate != ''">
  2287. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2288. </if>
  2289. </if>
  2290. <if test="level != null and level != ''">
  2291. and c.level = #{level}
  2292. </if>
  2293. <if test="deptName != null and deptName != ''">
  2294. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2295. </if>
  2296. GROUP BY
  2297. a.beh_dept_id,
  2298. a.beh_dept_name
  2299. ) t2
  2300. WHERE
  2301. t1.deptId = t2.deptId
  2302. AND t1.deptName = t2.deptName)m1 left join
  2303. ( SELECT
  2304. t1.deptId,
  2305. t1.deptName,
  2306. t2.entryNum as sameNum,
  2307. t1.mrNum as sameMrNum,
  2308. t1.totleValue as sameTotleValue,
  2309. t1.averageValue as sameAvgValue,
  2310. t1.firstLevelNum as sameFirstLevelNum,
  2311. t1.secondLevelNum as sameSecondLevelNum,
  2312. t1.thirdLevelNum as sameThirdLevelNum,
  2313. t1.firstLevelPercent as sameFirstLevelPercent,
  2314. t1.secondLevelPercent as sameSecondLevelPercent,
  2315. t1.thirdLevelPercent as sameThirdLevelPercent,
  2316. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2317. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2318. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2319. FROM
  2320. (
  2321. SELECT
  2322. a.beh_dept_id AS deptId,
  2323. a.beh_dept_name AS deptName,
  2324. count(*) AS mrNum,
  2325. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2326. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2327. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2328. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2329. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2330. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2331. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2332. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2333. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2334. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2335. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2336. FROM
  2337. med_behospital_info a,
  2338. med_qcresult_info c
  2339. WHERE
  2340. a.is_deleted = 'N'
  2341. AND c.is_deleted = 'N'
  2342. AND a.hospital_id = c.hospital_id
  2343. AND a.behospital_code = c.behospital_code
  2344. <if test="isPlacefile != null and isPlacefile != ''">
  2345. and a.is_placefile = #{isPlacefile}
  2346. </if>
  2347. AND a.qc_type_id != 0
  2348. <if test="hospitalId != null and hospitalId != ''">
  2349. AND a.hospital_id = #{hospitalId}
  2350. </if>
  2351. <if test="isPlacefile != null and isPlacefile == 0">
  2352. <if test="lastStartDate != null and lastStartDate != ''">
  2353. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2354. </if>
  2355. <if test="lastEndDate != null and lastEndDate != ''">
  2356. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2357. </if>
  2358. </if>
  2359. <if test="isPlacefile != null and isPlacefile == 1">
  2360. <if test="lastStartDate != null and lastStartDate != ''">
  2361. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2362. </if>
  2363. <if test="lastEndDate != null and lastEndDate != ''">
  2364. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2365. </if>
  2366. </if>
  2367. <if test="level != null and level != ''">
  2368. and c.level = #{level}
  2369. </if>
  2370. <if test="deptName != null and deptName != ''">
  2371. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2372. </if>
  2373. GROUP BY
  2374. a.beh_dept_id,
  2375. a.beh_dept_name
  2376. ) t1,
  2377. (
  2378. SELECT
  2379. a.beh_dept_id AS deptId,
  2380. a.beh_dept_name AS deptName,
  2381. count( * ) AS entryNum
  2382. FROM
  2383. med_behospital_info a,
  2384. med_qcresult_info c,
  2385. med_qcresult_detail d,
  2386. qc_cases_entry e
  2387. WHERE
  2388. a.is_deleted = 'N'
  2389. AND c.is_deleted = 'N'
  2390. AND d.is_deleted = 'N'
  2391. AND e.is_deleted = 'N'
  2392. AND a.hospital_id = c.hospital_id
  2393. AND a.hospital_id = d.hospital_id
  2394. AND a.behospital_code = c.behospital_code
  2395. AND a.behospital_code = d.behospital_code
  2396. AND d.cases_id = e.cases_id
  2397. AND d.cases_entry_id = e.id
  2398. <if test="isPlacefile != null and isPlacefile != ''">
  2399. and a.is_placefile = #{isPlacefile}
  2400. </if>
  2401. AND a.qc_type_id != 0
  2402. <if test="hospitalId != null and hospitalId != ''">
  2403. AND a.hospital_id = #{hospitalId}
  2404. </if>
  2405. <if test="isPlacefile != null and isPlacefile == 0">
  2406. <if test="lastStartDate != null and lastStartDate != ''">
  2407. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2408. </if>
  2409. <if test="lastEndDate != null and lastEndDate != ''">
  2410. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2411. </if>
  2412. </if>
  2413. <if test="isPlacefile != null and isPlacefile == 1">
  2414. <if test="lastStartDate != null and lastStartDate != ''">
  2415. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2416. </if>
  2417. <if test="lastEndDate != null and lastEndDate != ''">
  2418. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2419. </if>
  2420. </if>
  2421. <if test="level != null and level != ''">
  2422. and c.level = #{level}
  2423. </if>
  2424. <if test="deptName != null and deptName != ''">
  2425. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2426. </if>
  2427. GROUP BY
  2428. a.beh_dept_id,
  2429. a.beh_dept_name
  2430. ) t2
  2431. WHERE
  2432. t1.deptId = t2.deptId
  2433. AND t1.deptName = t2.deptName)m2
  2434. on
  2435. m1.deptId = m2.deptId
  2436. AND m1.deptName = m2.deptName
  2437. <if test="asc != null and asc !=''">
  2438. order by
  2439. <choose>
  2440. <when test='asc=="deptId"'>m1.deptId asc</when>
  2441. <when test='asc=="deptName"'>m1.deptName asc</when>
  2442. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2443. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2444. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2445. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2446. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2447. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2448. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2449. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2450. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2451. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2452. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2453. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2454. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2455. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2456. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2457. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2458. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2459. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2460. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2461. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2462. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2463. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2464. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2465. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2466. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2467. <otherwise>deptName asc</otherwise>
  2468. </choose>
  2469. </if>
  2470. <if test="desc != null and desc!=''">
  2471. order by
  2472. <choose>
  2473. <when test='desc=="deptId"'>m1.deptId desc</when>
  2474. <when test='desc=="deptName"'>m1.deptName desc</when>
  2475. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2476. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2477. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2478. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2479. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2480. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2481. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2482. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2483. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2484. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2485. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2486. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2487. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2488. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2489. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2490. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2491. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2492. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2493. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2494. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2495. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2496. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2497. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2498. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2499. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2500. <otherwise>deptName desc</otherwise>
  2501. </choose>
  2502. </if>
  2503. </select>
  2504. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  2505. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  2506. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2507. SELECT
  2508. t1.deptId,
  2509. t1.deptName,
  2510. t1.deptClassId,
  2511. t1.deptClass,
  2512. t2.entryNum,
  2513. t1.mrNum,
  2514. t1.totleValue,
  2515. t1.averageValue,
  2516. t1.firstLevelNum,
  2517. t1.secondLevelNum,
  2518. t1.thirdLevelNum,
  2519. t1.firstLevelPercent,
  2520. t1.secondLevelPercent,
  2521. t1.thirdLevelPercent,
  2522. t1.firstLevelPercentStr,
  2523. t1.secondLevelPercentStr,
  2524. t1.thirdLevelPercentStr
  2525. FROM
  2526. (
  2527. SELECT
  2528. a.beh_dept_id AS deptId,
  2529. a.beh_dept_name AS deptName,
  2530. e.dept_id AS deptClassId,
  2531. e.dept_name AS deptClass,
  2532. count( DISTINCT c.id ) AS mrNum,
  2533. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2534. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  2535. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  2536. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  2537. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  2538. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  2539. ) AS firstLevelPercent,
  2540. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2541. ) AS secondLevelPercent,
  2542. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2543. ) AS thirdLevelPercent,
  2544. concat(
  2545. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  2546. 100, 2 ),
  2547. '%'
  2548. ) AS firstLevelPercentStr,
  2549. concat(
  2550. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  2551. 100, 2 ),
  2552. '%'
  2553. ) AS secondLevelPercentStr,
  2554. concat(
  2555. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  2556. 100, 2 ),
  2557. '%'
  2558. ) AS thirdLevelPercentStr
  2559. FROM
  2560. med_behospital_info a,
  2561. med_qcresult_info c,
  2562. bas_dept_info d,
  2563. bas_dept_info e
  2564. WHERE
  2565. a.is_deleted = 'N'
  2566. AND c.is_deleted = 'N'
  2567. AND d.is_deleted = 'N'
  2568. AND e.is_deleted = 'N'
  2569. AND a.hospital_id = c.hospital_id
  2570. AND a.hospital_id = d.hospital_id
  2571. AND a.hospital_id = e.hospital_id
  2572. AND a.behospital_code = c.behospital_code
  2573. AND a.beh_dept_id = d.dept_id
  2574. AND d.parent_dept_id = e.dept_id
  2575. <if test="isPlacefile != null and isPlacefile != ''">
  2576. and a.is_placefile = #{isPlacefile}
  2577. </if>
  2578. <![CDATA[AND a.qc_type_id <>0 ]]>
  2579. <if test="hospitalId != null and hospitalId != ''">
  2580. AND a.hospital_id = #{hospitalId}
  2581. </if>
  2582. <if test="isPlacefile != null and isPlacefile == 0">
  2583. <if test="startDate != null and startDate != ''">
  2584. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2585. </if>
  2586. <if test="endDate != null and endDate != ''">
  2587. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2588. </if>
  2589. </if>
  2590. <if test="isPlacefile != null and isPlacefile == 1">
  2591. <if test="startDate != null and startDate != ''">
  2592. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2593. </if>
  2594. <if test="endDate != null and endDate != ''">
  2595. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2596. </if>
  2597. </if>
  2598. <if test="level != null and level != ''">
  2599. and c.level = #{level}
  2600. </if>
  2601. <if test="deptName != null and deptName != ''">
  2602. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2603. </if>
  2604. <if test="deptClass != null and deptClass != ''">
  2605. and e.dept_name = #{deptClass}
  2606. </if>
  2607. GROUP BY
  2608. a.beh_dept_id,
  2609. a.beh_dept_name,
  2610. e.dept_id,
  2611. e.dept_name
  2612. ) t1,
  2613. (
  2614. SELECT
  2615. a.beh_dept_id AS deptId,
  2616. a.beh_dept_name AS deptName,
  2617. g.dept_id AS deptClassId,
  2618. g.dept_name AS deptClass,
  2619. count( * ) AS entryNum
  2620. FROM
  2621. med_behospital_info a,
  2622. med_qcresult_info c,
  2623. med_qcresult_detail d,
  2624. qc_cases_entry e,
  2625. bas_dept_info f,
  2626. bas_dept_info g
  2627. WHERE
  2628. a.is_deleted = 'N'
  2629. AND c.is_deleted = 'N'
  2630. AND d.is_deleted = 'N'
  2631. AND e.is_deleted = 'N'
  2632. AND f.is_deleted = 'N'
  2633. AND g.is_deleted = 'N'
  2634. AND a.hospital_id = c.hospital_id
  2635. AND a.hospital_id = d.hospital_id
  2636. AND a.hospital_id = f.hospital_id
  2637. AND a.hospital_id = g.hospital_id
  2638. AND a.behospital_code = c.behospital_code
  2639. AND a.behospital_code = d.behospital_code
  2640. AND d.cases_id = e.cases_id
  2641. AND d.cases_entry_id = e.id
  2642. AND a.beh_dept_id = f.dept_id
  2643. AND f.parent_dept_id = g.dept_id
  2644. <if test="isPlacefile != null and isPlacefile != ''">
  2645. and a.is_placefile = #{isPlacefile}
  2646. </if>
  2647. <![CDATA[AND a.qc_type_id <>0 ]]>
  2648. <if test="hospitalId != null and hospitalId != ''">
  2649. AND a.hospital_id = #{hospitalId}
  2650. </if>
  2651. <if test="isPlacefile != null and isPlacefile == 0">
  2652. <if test="startDate != null and startDate != ''">
  2653. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2654. </if>
  2655. <if test="endDate != null and endDate != ''">
  2656. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2657. </if>
  2658. </if>
  2659. <if test="isPlacefile != null and isPlacefile == 1">
  2660. <if test="startDate != null and startDate != ''">
  2661. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2662. </if>
  2663. <if test="endDate != null and endDate != ''">
  2664. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2665. </if>
  2666. </if>
  2667. <if test="level != null and level != ''">
  2668. and c.level = #{level}
  2669. </if>
  2670. <if test="deptName != null and deptName != ''">
  2671. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2672. </if>
  2673. <if test="deptClass != null and deptClass != ''">
  2674. and g.dept_name = #{deptClass}
  2675. </if>
  2676. GROUP BY
  2677. a.beh_dept_id,
  2678. a.beh_dept_name,
  2679. g.dept_id,
  2680. g.dept_name
  2681. ) t2
  2682. WHERE
  2683. t1.deptId = t2.deptId
  2684. AND t1.deptName = t2.deptName
  2685. AND t1.deptClassId = t2.deptClassId
  2686. AND t1.deptClass = t2.deptClass
  2687. <if test="asc != null and asc !=''">
  2688. order by
  2689. <choose>
  2690. <when test='asc=="deptId"'>deptId asc</when>
  2691. <when test='asc=="deptName"'>deptName asc</when>
  2692. <when test='asc=="deptClassId"'>deptClassId asc</when>
  2693. <when test='asc=="deptClass"'>deptClass asc</when>
  2694. <when test='asc=="entryNum"'>entryNum asc</when>
  2695. <when test='asc=="mrNum"'>mrNum asc</when>
  2696. <when test='asc=="totleValue"'>totleValue asc</when>
  2697. <when test='asc=="averageValue"'>averageValue asc</when>
  2698. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2699. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2700. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2701. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2702. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2703. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2704. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2705. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2706. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2707. <otherwise>deptName asc</otherwise>
  2708. </choose>
  2709. </if>
  2710. <if test="desc != null and desc!=''">
  2711. order by
  2712. <choose>
  2713. <when test='desc=="deptId"'>deptId desc</when>
  2714. <when test='desc=="deptName"'>deptName desc</when>
  2715. <when test='desc=="deptClassId"'>deptClassId desc</when>
  2716. <when test='desc=="deptClass"'>deptClass desc</when>
  2717. <when test='desc=="entryNum"'>entryNum desc</when>
  2718. <when test='desc=="mrNum"'>mrNum desc</when>
  2719. <when test='desc=="totleValue"'>totleValue desc</when>
  2720. <when test='desc=="averageValue"'>averageValue desc</when>
  2721. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2722. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2723. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2724. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2725. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2726. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2727. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2728. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2729. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2730. <otherwise>deptName desc</otherwise>
  2731. </choose>
  2732. </if>
  2733. </select>
  2734. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  2735. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2736. select
  2737. m1.deptId,
  2738. m1.deptName,
  2739. m1.deptClassId,
  2740. m1.deptClass,
  2741. m1.entryNum,
  2742. m2.sameNum,
  2743. m1.mrNum,
  2744. m2.sameMrNum,
  2745. m1.totleValue,
  2746. m2.sameTotleValue,
  2747. m1.averageValue,
  2748. m2.sameAvgValue,
  2749. m1.firstLevelNum,
  2750. m2.sameFirstLevelNum,
  2751. m1.secondLevelNum,
  2752. m2.sameSecondLevelNum,
  2753. m1.thirdLevelNum,
  2754. m2.sameThirdLevelNum,
  2755. m1.firstLevelPercent,
  2756. m2.sameFirstLevelPercent,
  2757. m1.secondLevelPercent,
  2758. m2.sameSecondLevelPercent,
  2759. m1.thirdLevelPercent,
  2760. m2.sameThirdLevelPercent,
  2761. m1.firstLevelPercentStr,
  2762. m2.sameFirstLevelPercentStr,
  2763. m1.secondLevelPercentStr,
  2764. m2.sameSecondLevelPercentStr,
  2765. m1.thirdLevelPercentStr,
  2766. m2.sameThirdLevelPercentStr
  2767. from (
  2768. SELECT
  2769. t1.deptId,
  2770. t1.deptName,
  2771. t1.deptClassId,
  2772. t1.deptClass,
  2773. t2.entryNum,
  2774. t1.mrNum,
  2775. t1.totleValue,
  2776. t1.averageValue,
  2777. t1.firstLevelNum,
  2778. t1.secondLevelNum,
  2779. t1.thirdLevelNum,
  2780. t1.firstLevelPercent,
  2781. t1.secondLevelPercent,
  2782. t1.thirdLevelPercent,
  2783. t1.firstLevelPercentStr,
  2784. t1.secondLevelPercentStr,
  2785. t1.thirdLevelPercentStr
  2786. FROM
  2787. (
  2788. SELECT
  2789. tt1.deptId,
  2790. tt1.deptName,
  2791. e.dept_id AS deptClassId,
  2792. e.dept_name AS deptClass,
  2793. count(*) AS mrNum,
  2794. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2795. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2796. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2797. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2798. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2799. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2800. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2801. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2802. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2803. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2804. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2805. FROM
  2806. (
  2807. SELECT
  2808. a.beh_dept_id AS deptId,
  2809. a.beh_dept_name AS deptName,
  2810. d.parent_dept_id AS parentDeptId,
  2811. a.hospital_id AS hospitalId,
  2812. a.behospital_code AS behospitalCode,
  2813. c.score_res AS score,
  2814. c.LEVEL
  2815. FROM
  2816. med_behospital_info a,
  2817. med_qcresult_info c,
  2818. bas_dept_info d
  2819. WHERE
  2820. a.is_deleted = 'N'
  2821. AND c.is_deleted = 'N'
  2822. AND d.is_deleted = 'N'
  2823. AND a.hospital_id = c.hospital_id
  2824. AND a.hospital_id = d.hospital_id
  2825. AND a.behospital_code = c.behospital_code
  2826. AND a.beh_dept_id = d.dept_id
  2827. <if test="isPlacefile != null and isPlacefile != ''">
  2828. and a.is_placefile = #{isPlacefile}
  2829. </if>
  2830. AND a.qc_type_id != 0
  2831. <if test="hospitalId != null and hospitalId != ''">
  2832. AND a.hospital_id = #{hospitalId}
  2833. </if>
  2834. <if test="isPlacefile != null and isPlacefile == 0">
  2835. <if test="startDate != null and startDate != ''">
  2836. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2837. </if>
  2838. <if test="endDate != null and endDate != ''">
  2839. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2840. </if>
  2841. </if>
  2842. <if test="isPlacefile != null and isPlacefile == 1">
  2843. <if test="startDate != null and startDate != ''">
  2844. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2845. </if>
  2846. <if test="endDate != null and endDate != ''">
  2847. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2848. </if>
  2849. </if>
  2850. <if test="level != null and level != ''">
  2851. and c.level = #{level}
  2852. </if>
  2853. <if test="deptName != null and deptName != ''">
  2854. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2855. </if>
  2856. ) tt1
  2857. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2858. AND e.is_deleted = 'N'
  2859. AND tt1.hospitalId = e.hospital_id
  2860. <if test="deptClass != null and deptClass != ''">
  2861. WHERE e.dept_name = #{deptClass}
  2862. </if>
  2863. GROUP BY
  2864. tt1.deptId,
  2865. tt1.deptName,
  2866. e.dept_id,
  2867. e.dept_name
  2868. ) t1,
  2869. (
  2870. SELECT
  2871. tt2.deptId,
  2872. tt2.deptName,
  2873. g.dept_id AS deptClassId,
  2874. g.dept_name AS deptClass,
  2875. count( * ) AS entryNum
  2876. FROM
  2877. (
  2878. SELECT
  2879. a.beh_dept_id AS deptId,
  2880. a.beh_dept_name AS deptName,
  2881. f.parent_dept_id AS parentDeptId,
  2882. a.hospital_id AS hospitalId,
  2883. a.behospital_code AS behospitalCode
  2884. FROM
  2885. med_behospital_info a,
  2886. med_qcresult_info c,
  2887. med_qcresult_detail d,
  2888. qc_cases_entry e,
  2889. bas_dept_info f
  2890. WHERE
  2891. a.is_deleted = 'N'
  2892. AND c.is_deleted = 'N'
  2893. AND d.is_deleted = 'N'
  2894. AND e.is_deleted = 'N'
  2895. AND f.is_deleted = 'N'
  2896. AND a.hospital_id = c.hospital_id
  2897. AND a.hospital_id = d.hospital_id
  2898. AND a.hospital_id = f.hospital_id
  2899. AND a.behospital_code = c.behospital_code
  2900. AND a.behospital_code = d.behospital_code
  2901. AND d.cases_id = e.cases_id
  2902. AND d.cases_entry_id = e.id
  2903. AND a.beh_dept_id = f.dept_id
  2904. <if test="isPlacefile != null and isPlacefile != ''">
  2905. and a.is_placefile = #{isPlacefile}
  2906. </if>
  2907. AND a.qc_type_id != 0
  2908. <if test="hospitalId != null and hospitalId != ''">
  2909. AND a.hospital_id = #{hospitalId}
  2910. </if>
  2911. <if test="isPlacefile != null and isPlacefile == 0">
  2912. <if test="startDate != null and startDate != ''">
  2913. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2914. </if>
  2915. <if test="endDate != null and endDate != ''">
  2916. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2917. </if>
  2918. </if>
  2919. <if test="isPlacefile != null and isPlacefile == 1">
  2920. <if test="startDate != null and startDate != ''">
  2921. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2922. </if>
  2923. <if test="endDate != null and endDate != ''">
  2924. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2925. </if>
  2926. </if>
  2927. <if test="level != null and level != ''">
  2928. and c.level = #{level}
  2929. </if>
  2930. <if test="deptName != null and deptName != ''">
  2931. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2932. </if>
  2933. ) tt2
  2934. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2935. AND g.is_deleted = 'N'
  2936. AND tt2.hospitalId = g.hospital_id
  2937. <if test="deptClass != null and deptClass != ''">
  2938. WHERE g.dept_name = #{deptClass}
  2939. </if>
  2940. GROUP BY
  2941. tt2.deptId,
  2942. tt2.deptName,
  2943. g.dept_id,
  2944. g.dept_name
  2945. ) t2
  2946. WHERE
  2947. t1.deptId = t2.deptId
  2948. AND t1.deptName = t2.deptName)m1 left join
  2949. ( SELECT
  2950. t1.deptId,
  2951. t1.deptName,
  2952. t1.deptClassId,
  2953. t1.deptClass,
  2954. t2.entryNum as sameNum,
  2955. t1.mrNum as sameMrNum,
  2956. t1.totleValue as sameTotleValue,
  2957. t1.averageValue as sameAvgValue,
  2958. t1.firstLevelNum as sameFirstLevelNum,
  2959. t1.secondLevelNum as sameSecondLevelNum,
  2960. t1.thirdLevelNum as sameThirdLevelNum,
  2961. t1.firstLevelPercent as sameFirstLevelPercent,
  2962. t1.secondLevelPercent as sameSecondLevelPercent,
  2963. t1.thirdLevelPercent as sameThirdLevelPercent,
  2964. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2965. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2966. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2967. FROM
  2968. (
  2969. SELECT
  2970. tt1.deptId,
  2971. tt1.deptName,
  2972. e.dept_id AS deptClassId,
  2973. e.dept_name AS deptClass,
  2974. count(*) AS mrNum,
  2975. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2976. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2977. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2978. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2979. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2980. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2981. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2982. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2983. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2984. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2985. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2986. FROM
  2987. (
  2988. SELECT
  2989. a.beh_dept_id AS deptId,
  2990. a.beh_dept_name AS deptName,
  2991. d.parent_dept_id AS parentDeptId,
  2992. a.hospital_id AS hospitalId,
  2993. a.behospital_code AS behospitalCode,
  2994. c.score_res AS score,
  2995. c.LEVEL
  2996. FROM
  2997. med_behospital_info a,
  2998. med_qcresult_info c,
  2999. bas_dept_info d
  3000. WHERE
  3001. a.is_deleted = 'N'
  3002. AND c.is_deleted = 'N'
  3003. AND d.is_deleted = 'N'
  3004. AND a.hospital_id = c.hospital_id
  3005. AND a.hospital_id = d.hospital_id
  3006. AND a.behospital_code = c.behospital_code
  3007. AND a.beh_dept_id = d.dept_id
  3008. <if test="isPlacefile != null and isPlacefile != ''">
  3009. and a.is_placefile = #{isPlacefile}
  3010. </if>
  3011. AND a.qc_type_id != 0
  3012. <if test="hospitalId != null and hospitalId != ''">
  3013. AND a.hospital_id = #{hospitalId}
  3014. </if>
  3015. <if test="isPlacefile != null and isPlacefile == 0">
  3016. <if test="lastStartDate != null and lastStartDate != ''">
  3017. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3018. </if>
  3019. <if test="lastEndDate != null and lastEndDate != ''">
  3020. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3021. </if>
  3022. </if>
  3023. <if test="isPlacefile != null and isPlacefile == 1">
  3024. <if test="lastStartDate != null and lastStartDate != ''">
  3025. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3026. </if>
  3027. <if test="lastEndDate != null and lastEndDate != ''">
  3028. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3029. </if>
  3030. </if>
  3031. <if test="level != null and level != ''">
  3032. and c.level = #{level}
  3033. </if>
  3034. <if test="deptName != null and deptName != ''">
  3035. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3036. </if>
  3037. ) tt1
  3038. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  3039. AND e.is_deleted = 'N'
  3040. AND tt1.hospitalId = e.hospital_id
  3041. <if test="deptClass != null and deptClass != ''">
  3042. WHERE e.dept_name = #{deptClass}
  3043. </if>
  3044. GROUP BY
  3045. tt1.deptId,
  3046. tt1.deptName,
  3047. e.dept_id,
  3048. e.dept_name
  3049. ) t1,
  3050. (
  3051. SELECT
  3052. tt2.deptId,
  3053. tt2.deptName,
  3054. g.dept_id AS deptClassId,
  3055. g.dept_name AS deptClass,
  3056. count( * ) AS entryNum
  3057. FROM
  3058. (
  3059. SELECT
  3060. a.beh_dept_id AS deptId,
  3061. a.beh_dept_name AS deptName,
  3062. f.parent_dept_id AS parentDeptId,
  3063. a.hospital_id AS hospitalId,
  3064. a.behospital_code AS behospitalCode
  3065. FROM
  3066. med_behospital_info a,
  3067. med_qcresult_info c,
  3068. med_qcresult_detail d,
  3069. qc_cases_entry e,
  3070. bas_dept_info f
  3071. WHERE
  3072. a.is_deleted = 'N'
  3073. AND c.is_deleted = 'N'
  3074. AND d.is_deleted = 'N'
  3075. AND e.is_deleted = 'N'
  3076. AND f.is_deleted = 'N'
  3077. AND a.hospital_id = c.hospital_id
  3078. AND a.hospital_id = d.hospital_id
  3079. AND a.hospital_id = f.hospital_id
  3080. AND a.behospital_code = c.behospital_code
  3081. AND a.behospital_code = d.behospital_code
  3082. AND d.cases_id = e.cases_id
  3083. AND d.cases_entry_id = e.id
  3084. AND a.beh_dept_id = f.dept_id
  3085. <if test="isPlacefile != null and isPlacefile != ''">
  3086. and a.is_placefile = #{isPlacefile}
  3087. </if>
  3088. AND a.qc_type_id != 0
  3089. <if test="hospitalId != null and hospitalId != ''">
  3090. AND a.hospital_id = #{hospitalId}
  3091. </if>
  3092. <if test="isPlacefile != null and isPlacefile == 0">
  3093. <if test="lastStartDate != null and lastStartDate != ''">
  3094. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3095. </if>
  3096. <if test="lastEndDate != null and lastEndDate != ''">
  3097. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3098. </if>
  3099. </if>
  3100. <if test="isPlacefile != null and isPlacefile == 1">
  3101. <if test="lastStartDate != null and lastStartDate != ''">
  3102. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3103. </if>
  3104. <if test="lastEndDate != null and lastEndDate != ''">
  3105. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3106. </if>
  3107. </if>
  3108. <if test="level != null and level != ''">
  3109. and c.level = #{level}
  3110. </if>
  3111. <if test="deptName != null and deptName != ''">
  3112. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3113. </if>
  3114. ) tt2
  3115. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  3116. AND g.is_deleted = 'N'
  3117. AND tt2.hospitalId = g.hospital_id
  3118. <if test="deptClass != null and deptClass != ''">
  3119. WHERE g.dept_name = #{deptClass}
  3120. </if>
  3121. GROUP BY
  3122. tt2.deptId,
  3123. tt2.deptName,
  3124. g.dept_id,
  3125. g.dept_name
  3126. ) t2
  3127. WHERE
  3128. t1.deptId = t2.deptId
  3129. AND t1.deptName = t2.deptName)m2
  3130. on
  3131. m1.deptId = m2.deptId
  3132. and m1.deptName = m2.deptName
  3133. <if test="asc != null and asc !=''">
  3134. order by
  3135. <choose>
  3136. <when test='asc=="deptId"'>m1.deptId asc</when>
  3137. <when test='asc=="deptName"'>m1.deptName asc</when>
  3138. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  3139. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  3140. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3141. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3142. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3143. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3144. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3145. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3146. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3147. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3148. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3149. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3150. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3151. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3152. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3153. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3154. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3155. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3156. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3157. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3158. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3159. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3160. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3161. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3162. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3163. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3164. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3165. <otherwise>deptName asc</otherwise>
  3166. </choose>
  3167. </if>
  3168. <if test="desc != null and desc!=''">
  3169. order by
  3170. <choose>
  3171. <when test='desc=="deptId"'>m1.deptId desc</when>
  3172. <when test='desc=="deptName"'>m1.deptName desc</when>
  3173. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  3174. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  3175. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3176. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3177. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3178. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3179. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3180. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3181. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3182. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3183. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3184. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3185. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3186. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3187. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3188. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3189. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3190. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3191. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3192. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3193. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3194. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3195. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3196. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3197. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3198. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3199. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3200. <otherwise>deptName desc</otherwise>
  3201. </choose>
  3202. </if>
  3203. </select>
  3204. <!-- 病案首页合格率占比 -全院-->
  3205. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  3206. resultType="com.diagbot.dto.HomePageNumDTO">
  3207. SELECT
  3208. t1.deptId,
  3209. t1.deptName,
  3210. t2.entryNum,
  3211. t1.mrNum,
  3212. t1.totleValue,
  3213. t1.averageValue,
  3214. t1.firstLevelNum,
  3215. t1.secondLevelNum,
  3216. t1.firstLevelPercent,
  3217. t1.secondLevelPercent,
  3218. t1.firstLevelPercentStr,
  3219. t1.secondLevelPercentStr,
  3220. t3.emptyNum,
  3221. t3.errorNum,
  3222. t3.entryTotleNum,
  3223. t3.emptyPercent,
  3224. t3.errorPercent,
  3225. t3.emptyPercentStr,
  3226. t3.errorPercentStr
  3227. FROM
  3228. (
  3229. SELECT
  3230. a.beh_dept_id AS deptId,
  3231. a.beh_dept_name AS deptName,
  3232. count( * ) AS mrNum,
  3233. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3234. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3235. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3236. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3237. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3238. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3239. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3240. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3241. FROM
  3242. med_behospital_info a,
  3243. med_qcresult_cases c
  3244. WHERE
  3245. a.is_deleted = 'N'
  3246. AND c.is_deleted = 'N'
  3247. AND a.hospital_id = c.hospital_id
  3248. AND a.behospital_code = c.behospital_code
  3249. AND c.cases_id = 243
  3250. <if test="isPlacefile != null and isPlacefile != ''">
  3251. and a.is_placefile = #{isPlacefile}
  3252. </if>
  3253. AND a.qc_type_id != 0
  3254. <if test="hospitalId != null and hospitalId != ''">
  3255. AND a.hospital_id = #{hospitalId}
  3256. </if>
  3257. <if test="isPlacefile != null and isPlacefile == 0">
  3258. <if test="startDate != null and startDate != ''">
  3259. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3260. </if>
  3261. <if test="endDate != null and endDate != ''">
  3262. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3263. </if>
  3264. </if>
  3265. <if test="isPlacefile != null and isPlacefile == 1">
  3266. <if test="startDate != null and startDate != ''">
  3267. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3268. </if>
  3269. <if test="endDate != null and endDate != ''">
  3270. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3271. </if>
  3272. </if>
  3273. <if test="level != null and level != ''">
  3274. and c.level = #{level}
  3275. </if>
  3276. <if test="deptName != null and deptName != ''">
  3277. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3278. </if>
  3279. GROUP BY
  3280. a.beh_dept_id,
  3281. a.beh_dept_name
  3282. ) t1,
  3283. (
  3284. SELECT
  3285. a.beh_dept_id AS deptId,
  3286. a.beh_dept_name AS deptName,
  3287. count( * ) AS entryNum
  3288. FROM
  3289. med_behospital_info a,
  3290. med_qcresult_cases c,
  3291. med_qcresult_detail d,
  3292. qc_cases_entry e
  3293. WHERE
  3294. a.is_deleted = 'N'
  3295. AND c.is_deleted = 'N'
  3296. AND d.is_deleted = 'N'
  3297. AND e.is_deleted = 'N'
  3298. AND a.hospital_id = c.hospital_id
  3299. AND a.hospital_id = d.hospital_id
  3300. AND a.behospital_code = c.behospital_code
  3301. AND a.behospital_code = d.behospital_code
  3302. AND c.cases_id = d.cases_id
  3303. AND d.cases_id = e.cases_id
  3304. AND d.cases_entry_id = e.id
  3305. AND d.cases_id = 243
  3306. <if test="isPlacefile != null and isPlacefile != ''">
  3307. and a.is_placefile = #{isPlacefile}
  3308. </if>
  3309. AND a.qc_type_id != 0
  3310. <if test="hospitalId != null and hospitalId != ''">
  3311. AND a.hospital_id = #{hospitalId}
  3312. </if>
  3313. <if test="isPlacefile != null and isPlacefile == 0">
  3314. <if test="startDate != null and startDate != ''">
  3315. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3316. </if>
  3317. <if test="endDate != null and endDate != ''">
  3318. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3319. </if>
  3320. </if>
  3321. <if test="isPlacefile != null and isPlacefile == 1">
  3322. <if test="startDate != null and startDate != ''">
  3323. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3324. </if>
  3325. <if test="endDate != null and endDate != ''">
  3326. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3327. </if>
  3328. </if>
  3329. <if test="level != null and level != ''">
  3330. and c.level = #{level}
  3331. </if>
  3332. <if test="deptName != null and deptName != ''">
  3333. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3334. </if>
  3335. GROUP BY
  3336. a.beh_dept_id,
  3337. a.beh_dept_name
  3338. ) t2,(
  3339. SELECT
  3340. h1.deptId,
  3341. h1.deptName,
  3342. h1.emptyNum,
  3343. h1.errorNum,
  3344. h1.mrNum,
  3345. h2.entryNum,
  3346. h1.mrNum * h2.entryNum AS entryTotleNum,
  3347. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3348. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3349. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3350. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3351. FROM
  3352. (
  3353. SELECT
  3354. a.beh_dept_id AS deptId,
  3355. a.beh_dept_name AS deptName,
  3356. sum( d.rule_type = 1 ) AS emptyNum,
  3357. sum( d.rule_type = 2 ) AS errorNum,
  3358. count( DISTINCT a.behospital_code ) AS mrNum
  3359. FROM
  3360. med_behospital_info a,
  3361. med_qcresult_cases b,
  3362. med_qcresult_detail c,
  3363. qc_cases_entry d
  3364. WHERE
  3365. a.is_deleted = 'N'
  3366. AND b.is_deleted = 'N'
  3367. AND c.is_deleted = 'N'
  3368. AND d.is_deleted = 'N'
  3369. AND a.hospital_id = b.hospital_id
  3370. AND a.hospital_id = c.hospital_id
  3371. AND a.behospital_code = b.behospital_code
  3372. AND a.behospital_code = c.behospital_code
  3373. AND b.cases_id = c.cases_id
  3374. AND c.cases_id = d.cases_id
  3375. AND c.cases_entry_id = d.id
  3376. <if test="isPlacefile != null and isPlacefile != ''">
  3377. and a.is_placefile = #{isPlacefile}
  3378. </if>
  3379. AND d.cases_id = 243
  3380. AND a.qc_type_id != 0
  3381. <if test="hospitalId != null and hospitalId != ''">
  3382. AND a.hospital_id = #{hospitalId}
  3383. </if>
  3384. <if test="isPlacefile != null and isPlacefile == 0">
  3385. <if test="startDate != null and startDate != ''">
  3386. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3387. </if>
  3388. <if test="endDate != null and endDate != ''">
  3389. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3390. </if>
  3391. </if>
  3392. <if test="isPlacefile != null and isPlacefile == 1">
  3393. <if test="startDate != null and startDate != ''">
  3394. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3395. </if>
  3396. <if test="endDate != null and endDate != ''">
  3397. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3398. </if>
  3399. </if>
  3400. <if test="level != null and level != ''">
  3401. and b.level = #{level}
  3402. </if>
  3403. <if test="deptName != null and deptName != ''">
  3404. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3405. </if>
  3406. GROUP BY
  3407. a.beh_dept_id,
  3408. a.beh_dept_name
  3409. ) h1,(
  3410. SELECT
  3411. count(*) AS entryNum
  3412. FROM
  3413. qc_cases_entry
  3414. WHERE
  3415. is_deleted = 'N'
  3416. AND cases_id = 243
  3417. ) h2
  3418. ) t3
  3419. WHERE
  3420. t1.deptId = t2.deptId
  3421. AND t1.deptId = t3.deptId
  3422. AND t1.deptName = t2.deptName
  3423. AND t1.deptName = t3.deptName
  3424. <if test="asc != null and asc !=''">
  3425. order by
  3426. <choose>
  3427. <when test='asc=="deptId"'>deptId asc</when>
  3428. <when test='asc=="deptName"'>deptName asc</when>
  3429. <when test='asc=="entryNum"'>entryNum asc</when>
  3430. <when test='asc=="mrNum"'>mrNum asc</when>
  3431. <when test='asc=="totleValue"'>totleValue asc</when>
  3432. <when test='asc=="averageValue"'>averageValue asc</when>
  3433. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3434. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3435. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3436. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3437. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3438. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3439. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3440. <when test='asc=="errorNum"'>errorNum asc</when>
  3441. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3442. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3443. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3444. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3445. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3446. <otherwise>deptName asc</otherwise>
  3447. </choose>
  3448. </if>
  3449. <if test="desc != null and desc!=''">
  3450. order by
  3451. <choose>
  3452. <when test='desc=="deptId"'>deptId desc</when>
  3453. <when test='desc=="deptName"'>deptName desc</when>
  3454. <when test='desc=="entryNum"'>entryNum desc</when>
  3455. <when test='desc=="mrNum"'>mrNum desc</when>
  3456. <when test='desc=="totleValue"'>totleValue desc</when>
  3457. <when test='desc=="averageValue"'>averageValue desc</when>
  3458. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3459. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3460. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3461. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3462. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3463. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3464. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3465. <when test='desc=="errorNum"'>errorNum desc</when>
  3466. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3467. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3468. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3469. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3470. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3471. <otherwise>deptName desc</otherwise>
  3472. </choose>
  3473. </if>
  3474. </select>
  3475. <!-- 医师病案首页合格率占比 湘雅定制-->
  3476. <select id="homePageLevelStatisticsXY" resultType="com.diagbot.dto.HomePageNumXYDTO">
  3477. SELECT
  3478. tt1.*,
  3479. tt2.entryNum,
  3480. tt2.emptyNum,
  3481. tt2.errorNum,
  3482. tt2.entryTotleNum,
  3483. tt2.emptyPercent,
  3484. tt2.errorPercent,
  3485. tt2.emptyPercentStr,
  3486. tt2.errorPercentStr
  3487. FROM(
  3488. select
  3489. t1.deptId,
  3490. t1.deptName,
  3491. t1.doctorName,
  3492. t1.professor,
  3493. sum(t1.mrNum) as mrNum,
  3494. sum(t1.totleValue)as totleValue,
  3495. ROUND(CAST(sum(t1.totleValue)/sum(t1.mrNum) AS DECIMAL ( 18, 2 )), 2) AS averageValue,
  3496. sum(t1.firstLevelNum)as firstLevelNum,
  3497. sum(t1.secondLevelNum)as secondLevelNum,
  3498. ROUND(sum(t1.firstLevelNum)/sum(t1.mrNum),4) as firstLevelPercent,
  3499. ROUND(sum(t1.secondLevelNum)/sum(t1.mrNum),4) as secondLevelPercent,
  3500. concat( ROUND( sum(t1.firstLevelNum)/sum(t1.mrNum)* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3501. concat( ROUND( sum(t1.secondLevelNum)/sum(t1.mrNum)* 100, 2 ),'%' ) AS secondLevelPercentStr
  3502. from
  3503. (
  3504. SELECT
  3505. a.beh_dept_id AS deptId,
  3506. a.beh_dept_name AS deptName,
  3507. case
  3508. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  3509. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3510. b.director_doctor != '' and b.director_doctor is not null
  3511. then b.director_doctor
  3512. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3513. (b.director_doctor = '' or b.director_doctor is null) and
  3514. b.behospital_doctor != '' and b.behospital_doctor is not null
  3515. then b.behospital_doctor end as doctorName,
  3516. case
  3517. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  3518. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3519. b.director_doctor != '' and b.director_doctor is not null
  3520. then '主任医师'
  3521. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3522. (b.director_doctor = '' or b.director_doctor is null) and
  3523. b.behospital_doctor != '' and b.behospital_doctor is not null
  3524. then '住院医师' end as professor,
  3525. count( * ) AS mrNum,
  3526. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3527. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3528. count(case when c.`level` = '合格' then 1 end) AS firstLevelNum,
  3529. count(case when c.`level` = '不合格' then 1 end) AS secondLevelNum
  3530. FROM
  3531. med_behospital_info a,
  3532. med_home_page b,
  3533. med_qcresult_cases c
  3534. WHERE
  3535. a.is_deleted = 'N'
  3536. AND c.is_deleted = 'N'
  3537. AND b.is_deleted = 'N'
  3538. AND a.hospital_id = b.hospital_id
  3539. AND a.hospital_id = c.hospital_id
  3540. AND a.behospital_code = b.behospital_code
  3541. AND a.behospital_code = c.behospital_code
  3542. AND c.cases_id = 243
  3543. <if test="isPlacefile != null and isPlacefile != ''">
  3544. and a.is_placefile = #{isPlacefile}
  3545. </if>
  3546. AND a.qc_type_id != 0
  3547. <if test="hospitalId != null and hospitalId != ''">
  3548. AND a.hospital_id = #{hospitalId}
  3549. </if>
  3550. <if test="isPlacefile != null and isPlacefile == 0">
  3551. <if test="startDate != null and startDate != ''">
  3552. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3553. </if>
  3554. <if test="endDate != null and endDate != ''">
  3555. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3556. </if>
  3557. </if>
  3558. <if test="isPlacefile != null and isPlacefile == 1">
  3559. <if test="startDate != null and startDate != ''">
  3560. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3561. </if>
  3562. <if test="endDate != null and endDate != ''">
  3563. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3564. </if>
  3565. </if>
  3566. <if test="deptName != null and deptName != ''">
  3567. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3568. </if>
  3569. <if test="deptId != null and deptId != ''">
  3570. and a.beh_dept_id = #{deptId}
  3571. </if>
  3572. GROUP BY
  3573. a.beh_dept_id,
  3574. a.beh_dept_name,
  3575. b.attending_doctor,
  3576. b.director_doctor,
  3577. b.behospital_doctor
  3578. ) t1
  3579. group by t1.deptId,t1.deptName,t1.doctorName,t1.professor
  3580. )tt1,
  3581. (
  3582. select
  3583. t2.deptId,
  3584. t2.deptName,
  3585. t2.doctorName,
  3586. t2.professor,
  3587. sum(t2.entryNum)as entryNum,
  3588. sum(t2.emptyNum)as emptyNum,
  3589. sum(t2.errorNum)as errorNum,
  3590. sum(t2.mrNum) * t2.entryNumSec AS entryTotleNum,
  3591. ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.emptyNum) ) / ( sum(t2.mrNum) * t2.entryNumSec ), 4 ) AS emptyPercent,
  3592. ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.errorNum) ) / ( sum(t2.mrNum) * t2.entryNumSec ), 4 ) AS errorPercent,
  3593. CONCAT( ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.emptyNum) ) / ( sum(t2.mrNum) * t2.entryNumSec )* 100, 2 ), '%' ) AS emptyPercentStr,
  3594. CONCAT( ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.errorNum) ) / ( sum(t2.mrNum) * t2.entryNumSec )* 100, 2 ), '%' ) AS errorPercentStr
  3595. from (
  3596. select m1.*,m2.entryNum as entryNumSec from (
  3597. SELECT
  3598. a.beh_dept_id AS deptId,
  3599. a.beh_dept_name AS deptName,
  3600. case
  3601. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  3602. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3603. b.director_doctor != '' and b.director_doctor is not null
  3604. then b.director_doctor
  3605. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3606. (b.director_doctor = '' or b.director_doctor is null) and
  3607. b.behospital_doctor != '' and b.behospital_doctor is not null
  3608. then b.behospital_doctor end as doctorName,
  3609. case
  3610. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  3611. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3612. b.director_doctor != '' and b.director_doctor is not null
  3613. then '主任医师'
  3614. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3615. (b.director_doctor = '' or b.director_doctor is null) and
  3616. b.behospital_doctor != '' and b.behospital_doctor is not null
  3617. then '住院医师' end as professor,
  3618. count( * ) AS entryNum,
  3619. count(case when e.rule_type = 1 then 1 end) AS emptyNum,
  3620. count(case when e.rule_type = 2 then 1 end) AS errorNum,
  3621. count( DISTINCT a.behospital_code ) AS mrNum
  3622. FROM
  3623. med_behospital_info a,
  3624. med_home_page b,
  3625. med_qcresult_cases c,
  3626. med_qcresult_detail d,
  3627. qc_cases_entry e
  3628. WHERE
  3629. a.is_deleted = 'N'
  3630. AND b.is_deleted = 'N'
  3631. AND c.is_deleted = 'N'
  3632. AND d.is_deleted = 'N'
  3633. AND e.is_deleted = 'N'
  3634. AND a.hospital_id = b.hospital_id
  3635. AND a.hospital_id = c.hospital_id
  3636. AND a.hospital_id = d.hospital_id
  3637. AND a.behospital_code = b.behospital_code
  3638. AND a.behospital_code = c.behospital_code
  3639. AND a.behospital_code = d.behospital_code
  3640. AND c.cases_id = d.cases_id
  3641. AND d.cases_id = e.cases_id
  3642. AND d.cases_entry_id = e.id
  3643. AND d.cases_id = 243
  3644. <if test="isPlacefile != null and isPlacefile != ''">
  3645. and a.is_placefile = #{isPlacefile}
  3646. </if>
  3647. AND a.qc_type_id != 0
  3648. <if test="hospitalId != null and hospitalId != ''">
  3649. AND a.hospital_id = #{hospitalId}
  3650. </if>
  3651. <if test="isPlacefile != null and isPlacefile == 0">
  3652. <if test="startDate != null and startDate != ''">
  3653. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3654. </if>
  3655. <if test="endDate != null and endDate != ''">
  3656. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3657. </if>
  3658. </if>
  3659. <if test="isPlacefile != null and isPlacefile == 1">
  3660. <if test="startDate != null and startDate != ''">
  3661. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3662. </if>
  3663. <if test="endDate != null and endDate != ''">
  3664. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3665. </if>
  3666. </if>
  3667. <if test="deptName != null and deptName != ''">
  3668. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3669. </if>
  3670. <if test="deptId != null and deptId != ''">
  3671. and a.beh_dept_id = #{deptId}
  3672. </if>
  3673. GROUP BY
  3674. a.beh_dept_id,
  3675. a.beh_dept_name,
  3676. b.attending_doctor,
  3677. b.director_doctor,
  3678. b.behospital_doctor
  3679. )m1,(
  3680. SELECT
  3681. count(*) AS entryNum
  3682. FROM
  3683. qc_cases_entry
  3684. WHERE
  3685. is_deleted = 'N'
  3686. AND cases_id = 243
  3687. )m2) t2
  3688. group by t2.deptId,t2.deptName,t2.doctorName,t2.professor
  3689. ) tt2
  3690. WHERE
  3691. tt1.deptId = tt2.deptId
  3692. AND tt1.deptName = tt2.deptName
  3693. AND tt1.doctorName= tt2.doctorName
  3694. AND tt1.professor = tt2.professor
  3695. AND tt1.professor != ''
  3696. and tt1.professor is not null
  3697. <if test="doctorName != null and doctorName != ''">
  3698. and tt1.doctorName like CONCAT('%',#{doctorName},'%')
  3699. </if>
  3700. <if test="professor != null and professor != ''">
  3701. and tt1.professor = #{professor}
  3702. </if>
  3703. </select>
  3704. <!-- 各科室缺陷占比-科室 -->
  3705. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3706. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3707. SELECT
  3708. m1.doctorId,
  3709. m1.doctorName,
  3710. m1.entryNum,
  3711. m2.sameNum,
  3712. m1.mrNum,
  3713. m2.sameMrNum,
  3714. m1.totleValue,
  3715. m2.sameTotleValue,
  3716. m1.averageValue,
  3717. m2.sameAvgValue,
  3718. m1.firstLevelNum,
  3719. m2.sameFirstLevelNum,
  3720. m1.secondLevelNum,
  3721. m2.sameSecondLevelNum,
  3722. m1.thirdLevelNum,
  3723. m2.sameThirdLevelNum,
  3724. m1.firstLevelPercent,
  3725. m2.sameFirstLevelPercent,
  3726. m1.secondLevelPercent,
  3727. m2.sameSecondLevelPercent,
  3728. m1.thirdLevelPercent,
  3729. m2.sameThirdLevelPercent,
  3730. m1.firstLevelPercentStr,
  3731. m2.sameFirstLevelPercentStr,
  3732. m1.secondLevelPercentStr,
  3733. m2.sameSecondLevelPercentStr,
  3734. m1.thirdLevelPercentStr,
  3735. m2.sameThirdLevelPercentStr
  3736. FROM
  3737. (
  3738. SELECT
  3739. t1.doctorId,
  3740. t1.doctorName,
  3741. t2.entryNum,
  3742. t1.mrNum,
  3743. t1.totleValue,
  3744. t1.averageValue,
  3745. t1.firstLevelNum,
  3746. t1.secondLevelNum,
  3747. t1.thirdLevelNum,
  3748. t1.firstLevelPercent,
  3749. t1.secondLevelPercent,
  3750. t1.thirdLevelPercent,
  3751. t1.firstLevelPercentStr,
  3752. t1.secondLevelPercentStr,
  3753. t1.thirdLevelPercentStr
  3754. FROM
  3755. (
  3756. SELECT
  3757. a.doctor_id AS doctorId,
  3758. a.doctor_name AS doctorName,
  3759. count(*) AS mrNum,
  3760. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3761. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3762. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3763. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3764. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3765. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3766. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3767. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3768. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3769. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3770. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3771. FROM
  3772. med_behospital_info a,
  3773. med_qcresult_info c,
  3774. sys_user_dept e
  3775. WHERE
  3776. a.is_deleted = 'N'
  3777. AND c.is_deleted = 'N'
  3778. AND e.is_deleted = 'N'
  3779. AND a.hospital_id = c.hospital_id
  3780. AND a.behospital_code = c.behospital_code
  3781. AND a.beh_dept_id = e.dept_id
  3782. <if test="isPlacefile != null and isPlacefile != ''">
  3783. and a.is_placefile = #{isPlacefile}
  3784. </if>
  3785. AND a.qc_type_id != 0
  3786. <if test="hospitalId != null and hospitalId != ''">
  3787. AND a.hospital_id = #{hospitalId}
  3788. </if>
  3789. <if test="isPlacefile != null and isPlacefile == 0">
  3790. <if test="startDate != null and startDate != ''">
  3791. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3792. </if>
  3793. <if test="endDate != null and endDate != ''">
  3794. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3795. </if>
  3796. </if>
  3797. <if test="isPlacefile != null and isPlacefile == 1">
  3798. <if test="startDate != null and startDate != ''">
  3799. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3800. </if>
  3801. <if test="endDate != null and endDate != ''">
  3802. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3803. </if>
  3804. </if>
  3805. <if test="level != null and level != ''">
  3806. and c.level = #{level}
  3807. </if>
  3808. <if test="doctorName != null and doctorName != ''">
  3809. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3810. </if>
  3811. <if test="userId!=null and userId !=''">
  3812. AND e.user_id = #{userId}
  3813. </if>
  3814. <if test="deptName != null and deptName != ''">
  3815. and a.beh_dept_name = #{deptName}
  3816. </if>
  3817. GROUP BY
  3818. a.doctor_id,
  3819. a.doctor_name
  3820. ) t1,
  3821. (
  3822. SELECT
  3823. a.doctor_id AS doctorId,
  3824. a.doctor_name AS doctorName,
  3825. count( * ) AS entryNum
  3826. FROM
  3827. med_behospital_info a,
  3828. med_qcresult_info c,
  3829. med_qcresult_detail d,
  3830. qc_cases_entry e,
  3831. sys_user_dept f
  3832. WHERE
  3833. a.is_deleted = 'N'
  3834. AND c.is_deleted = 'N'
  3835. AND d.is_deleted = 'N'
  3836. AND e.is_deleted = 'N'
  3837. AND f.is_deleted = 'N'
  3838. AND a.hospital_id = c.hospital_id
  3839. AND a.hospital_id = d.hospital_id
  3840. AND a.behospital_code = c.behospital_code
  3841. AND a.behospital_code = d.behospital_code
  3842. AND d.cases_id = e.cases_id
  3843. AND d.cases_entry_id = e.id
  3844. AND a.beh_dept_id = f.dept_id
  3845. <if test="isPlacefile != null and isPlacefile != ''">
  3846. and a.is_placefile = #{isPlacefile}
  3847. </if>
  3848. AND a.qc_type_id != 0
  3849. <if test="hospitalId != null and hospitalId != ''">
  3850. AND a.hospital_id = #{hospitalId}
  3851. </if>
  3852. <if test="isPlacefile != null and isPlacefile == 0">
  3853. <if test="startDate != null and startDate != ''">
  3854. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3855. </if>
  3856. <if test="endDate != null and endDate != ''">
  3857. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3858. </if>
  3859. </if>
  3860. <if test="isPlacefile != null and isPlacefile == 1">
  3861. <if test="startDate != null and startDate != ''">
  3862. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3863. </if>
  3864. <if test="endDate != null and endDate != ''">
  3865. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3866. </if>
  3867. </if>
  3868. <if test="level != null and level != ''">
  3869. and c.level = #{level}
  3870. </if>
  3871. <if test="doctorName != null and doctorName != ''">
  3872. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3873. </if>
  3874. <if test="userId!=null and userId !=''">
  3875. AND f.user_id = #{userId}
  3876. </if>
  3877. <if test="deptName != null and deptName != ''">
  3878. and a.beh_dept_name = #{deptName}
  3879. </if>
  3880. GROUP BY
  3881. a.doctor_id,
  3882. a.doctor_name
  3883. ) t2
  3884. WHERE
  3885. t1.doctorId = t2.doctorId
  3886. AND t1.doctorName = t2.doctorName
  3887. )m1 left join
  3888. ( SELECT
  3889. t1.doctorId,
  3890. t1.doctorName,
  3891. t2.entryNum as sameNum,
  3892. t1.mrNum as sameMrNum,
  3893. t1.totleValue as sameTotleValue,
  3894. t1.averageValue as sameAvgValue,
  3895. t1.firstLevelNum as sameFirstLevelNum,
  3896. t1.secondLevelNum as sameSecondLevelNum,
  3897. t1.thirdLevelNum as sameThirdLevelNum,
  3898. t1.firstLevelPercent as sameFirstLevelPercent,
  3899. t1.secondLevelPercent as sameSecondLevelPercent,
  3900. t1.thirdLevelPercent as sameThirdLevelPercent,
  3901. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3902. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3903. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3904. FROM
  3905. (
  3906. SELECT
  3907. a.doctor_id AS doctorId,
  3908. a.doctor_name AS doctorName,
  3909. count(*) AS mrNum,
  3910. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3911. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3912. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3913. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3914. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3915. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3916. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3917. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3918. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3919. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3920. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3921. FROM
  3922. med_behospital_info a,
  3923. med_qcresult_info c,
  3924. sys_user_dept e
  3925. WHERE
  3926. a.is_deleted = 'N'
  3927. AND c.is_deleted = 'N'
  3928. AND e.is_deleted = 'N'
  3929. AND a.hospital_id = c.hospital_id
  3930. AND a.behospital_code = c.behospital_code
  3931. AND a.beh_dept_id = e.dept_id
  3932. <if test="isPlacefile != null and isPlacefile != ''">
  3933. and a.is_placefile = #{isPlacefile}
  3934. </if>
  3935. AND a.qc_type_id != 0
  3936. <if test="hospitalId != null and hospitalId != ''">
  3937. AND a.hospital_id = #{hospitalId}
  3938. </if>
  3939. <if test="isPlacefile != null and isPlacefile == 0">
  3940. <if test="lastStartDate != null and lastStartDate != ''">
  3941. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3942. </if>
  3943. <if test="lastEndDate != null and lastEndDate != ''">
  3944. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3945. </if>
  3946. </if>
  3947. <if test="isPlacefile != null and isPlacefile == 1">
  3948. <if test="lastStartDate != null and lastStartDate != ''">
  3949. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3950. </if>
  3951. <if test="lastEndDate != null and lastEndDate != ''">
  3952. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3953. </if>
  3954. </if>
  3955. <if test="level != null and level != ''">
  3956. and c.level = #{level}
  3957. </if>
  3958. <if test="doctorName != null and doctorName != ''">
  3959. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3960. </if>
  3961. <if test="userId!=null and userId !=''">
  3962. AND e.user_id = #{userId}
  3963. </if>
  3964. <if test="deptName != null and deptName != ''">
  3965. and a.beh_dept_name = #{deptName}
  3966. </if>
  3967. GROUP BY
  3968. a.doctor_id,
  3969. a.doctor_name
  3970. ) t1,
  3971. (
  3972. SELECT
  3973. a.doctor_id AS doctorId,
  3974. a.doctor_name AS doctorName,
  3975. count( * ) AS entryNum
  3976. FROM
  3977. med_behospital_info a,
  3978. med_qcresult_info c,
  3979. med_qcresult_detail d,
  3980. qc_cases_entry e,
  3981. sys_user_dept f
  3982. WHERE
  3983. a.is_deleted = 'N'
  3984. AND c.is_deleted = 'N'
  3985. AND d.is_deleted = 'N'
  3986. AND e.is_deleted = 'N'
  3987. AND f.is_deleted = 'N'
  3988. AND a.hospital_id = c.hospital_id
  3989. AND a.hospital_id = d.hospital_id
  3990. AND a.behospital_code = c.behospital_code
  3991. AND a.behospital_code = d.behospital_code
  3992. AND d.cases_id = e.cases_id
  3993. AND d.cases_entry_id = e.id
  3994. AND a.beh_dept_id = f.dept_id
  3995. <if test="isPlacefile != null and isPlacefile != ''">
  3996. and a.is_placefile = #{isPlacefile}
  3997. </if>
  3998. AND a.qc_type_id != 0
  3999. <if test="hospitalId != null and hospitalId != ''">
  4000. AND a.hospital_id = #{hospitalId}
  4001. </if>
  4002. <if test="isPlacefile != null and isPlacefile == 0">
  4003. <if test="lastStartDate != null and lastStartDate != ''">
  4004. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  4005. </if>
  4006. <if test="lastEndDate != null and lastEndDate != ''">
  4007. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  4008. </if>
  4009. </if>
  4010. <if test="isPlacefile != null and isPlacefile == 1">
  4011. <if test="lastStartDate != null and lastStartDate != ''">
  4012. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  4013. </if>
  4014. <if test="lastEndDate != null and lastEndDate != ''">
  4015. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  4016. </if>
  4017. </if>
  4018. <if test="level != null and level != ''">
  4019. and c.level = #{level}
  4020. </if>
  4021. <if test="doctorName != null and doctorName != ''">
  4022. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  4023. </if>
  4024. <if test="userId!=null and userId !=''">
  4025. AND f.user_id = #{userId}
  4026. </if>
  4027. <if test="deptName != null and deptName != ''">
  4028. and a.beh_dept_name = #{deptName}
  4029. </if>
  4030. GROUP BY
  4031. a.doctor_id,
  4032. a.doctor_name
  4033. ) t2
  4034. WHERE
  4035. t1.doctorId = t2.doctorId
  4036. AND t1.doctorName = t2.doctorName
  4037. )m2
  4038. on
  4039. m1.doctorId = m2.doctorId
  4040. AND m1.doctorName = m2.doctorName
  4041. <if test="asc != null and asc !=''">
  4042. order by
  4043. <choose>
  4044. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  4045. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  4046. <when test='asc=="name"'>m1.doctorName asc</when>
  4047. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  4048. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  4049. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  4050. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  4051. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  4052. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  4053. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  4054. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  4055. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  4056. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  4057. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  4058. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  4059. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  4060. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  4061. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  4062. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  4063. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  4064. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  4065. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  4066. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  4067. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  4068. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  4069. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  4070. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  4071. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  4072. <otherwise>doctorName asc</otherwise>
  4073. </choose>
  4074. </if>
  4075. <if test="desc != null and desc!=''">
  4076. order by
  4077. <choose>
  4078. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  4079. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  4080. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  4081. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  4082. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  4083. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  4084. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  4085. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  4086. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  4087. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  4088. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  4089. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  4090. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  4091. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  4092. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  4093. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  4094. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  4095. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  4096. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  4097. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  4098. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  4099. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  4100. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  4101. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  4102. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  4103. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  4104. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  4105. <otherwise>doctorName desc</otherwise>
  4106. </choose>
  4107. </if>
  4108. </select>
  4109. <!-- 病案首页合格率占比-科室 -->
  4110. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  4111. resultType="com.diagbot.dto.HomePageByDeptDTO">
  4112. SELECT
  4113. t1.doctorId,
  4114. t1.doctorName,
  4115. t2.entryNum,
  4116. t1.mrNum,
  4117. t1.totleValue,
  4118. t1.averageValue,
  4119. t1.firstLevelNum,
  4120. t1.secondLevelNum,
  4121. t1.firstLevelPercent,
  4122. t1.secondLevelPercent,
  4123. t1.firstLevelPercentStr,
  4124. t1.secondLevelPercentStr,
  4125. t3.emptyNum,
  4126. t3.errorNum,
  4127. t3.entryTotleNum,
  4128. t3.emptyPercent,
  4129. t3.errorPercent,
  4130. t3.emptyPercentStr,
  4131. t3.errorPercentStr
  4132. FROM
  4133. (
  4134. SELECT
  4135. a.doctor_id AS doctorId,
  4136. a.doctor_name AS doctorName,
  4137. count( * ) AS mrNum,
  4138. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  4139. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  4140. sum( c.`level` = '合格' ) AS firstLevelNum,
  4141. sum( c.`level` = '不合格' ) AS secondLevelNum,
  4142. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  4143. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  4144. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  4145. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  4146. FROM
  4147. med_behospital_info a,
  4148. med_qcresult_cases c,
  4149. sys_user_dept f
  4150. WHERE
  4151. a.is_deleted = 'N'
  4152. AND c.is_deleted = 'N'
  4153. AND f.is_deleted = 'N'
  4154. AND a.hospital_id = c.hospital_id
  4155. AND a.behospital_code = c.behospital_code
  4156. AND a.beh_dept_id = f.dept_id
  4157. AND c.cases_id = 243
  4158. <if test="isPlacefile != null and isPlacefile != ''">
  4159. and a.is_placefile = #{isPlacefile}
  4160. </if>
  4161. <![CDATA[AND a.qc_type_id <>0 ]]>
  4162. <if test="hospitalId != null and hospitalId != ''">
  4163. AND a.hospital_id = #{hospitalId}
  4164. </if>
  4165. <if test="isPlacefile != null and isPlacefile == 0">
  4166. <if test="startDate != null and startDate != ''">
  4167. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4168. </if>
  4169. <if test="endDate != null and endDate != ''">
  4170. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4171. </if>
  4172. </if>
  4173. <if test="isPlacefile != null and isPlacefile == 1">
  4174. <if test="startDate != null and startDate != ''">
  4175. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4176. </if>
  4177. <if test="endDate != null and endDate != ''">
  4178. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4179. </if>
  4180. </if>
  4181. <if test="level != null and level != ''">
  4182. and c.level = #{level}
  4183. </if>
  4184. <if test="name != null and name != ''">
  4185. <if test="name == '未知'">
  4186. and (a.doctor_name is null or a.doctor_name='')
  4187. </if>
  4188. <if test="name != '未知'">
  4189. and a.doctor_name like CONCAT('%',#{name},'%')
  4190. </if>
  4191. </if>
  4192. <if test="userId!=null and userId !=''">
  4193. AND f.user_id = #{userId}
  4194. </if>
  4195. <if test="deptName!=null and deptName !=''">
  4196. AND a.beh_dept_name = #{deptName}
  4197. </if>
  4198. <if test="deptId!=null and deptId !=''">
  4199. AND a.beh_dept_id = #{deptId}
  4200. </if>
  4201. <if test="doctorId != null and doctorId != ''">
  4202. AND a.doctor_id = #{doctorId}
  4203. </if>
  4204. <if test="doctorName != null and doctorName != ''">
  4205. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4206. </if>
  4207. <if test="name != null and name != ''">
  4208. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4209. </if>
  4210. GROUP BY
  4211. a.doctor_id,
  4212. a.doctor_name
  4213. ) t1,
  4214. (
  4215. SELECT
  4216. a.doctor_id AS doctorId,
  4217. a.doctor_name AS doctorName,
  4218. count( * ) AS entryNum
  4219. FROM
  4220. med_behospital_info a,
  4221. med_qcresult_cases c,
  4222. med_qcresult_detail d,
  4223. qc_cases_entry e,
  4224. sys_user_dept f
  4225. WHERE
  4226. a.is_deleted = 'N'
  4227. AND c.is_deleted = 'N'
  4228. AND d.is_deleted = 'N'
  4229. AND e.is_deleted = 'N'
  4230. AND f.is_deleted = 'N'
  4231. AND a.hospital_id = c.hospital_id
  4232. AND a.hospital_id = d.hospital_id
  4233. AND a.behospital_code = c.behospital_code
  4234. AND a.behospital_code = d.behospital_code
  4235. AND a.beh_dept_id = f.dept_id
  4236. AND c.cases_id = d.cases_id
  4237. AND d.cases_id = e.cases_id
  4238. AND d.cases_entry_id = e.id
  4239. AND c.cases_id = 243
  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="isPlacefile != null and isPlacefile == 0">
  4248. <if test="startDate != null and startDate != ''">
  4249. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4250. </if>
  4251. <if test="endDate != null and endDate != ''">
  4252. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4253. </if>
  4254. </if>
  4255. <if test="isPlacefile != null and isPlacefile == 1">
  4256. <if test="startDate != null and startDate != ''">
  4257. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4258. </if>
  4259. <if test="endDate != null and endDate != ''">
  4260. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4261. </if>
  4262. </if>
  4263. <if test="level != null and level != ''">
  4264. and c.level = #{level}
  4265. </if>
  4266. <if test="name != null and name != ''">
  4267. <if test="name == '未知'">
  4268. and (a.doctor_name is null or a.doctor_name='')
  4269. </if>
  4270. <if test="name != '未知'">
  4271. and a.doctor_name like CONCAT('%',#{name},'%')
  4272. </if>
  4273. </if>
  4274. <if test="userId!=null and userId !=''">
  4275. AND f.user_id = #{userId}
  4276. </if>
  4277. <if test="deptName!=null and deptName !=''">
  4278. AND a.beh_dept_name = #{deptName}
  4279. </if>
  4280. <if test="deptId!=null and deptId !=''">
  4281. AND a.beh_dept_id = #{deptId}
  4282. </if>
  4283. <if test="doctorId != null and doctorId != ''">
  4284. AND a.doctor_id = #{doctorId}
  4285. </if>
  4286. <if test="doctorName != null and doctorName != ''">
  4287. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4288. </if>
  4289. <if test="name != null and name != ''">
  4290. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4291. </if>
  4292. GROUP BY
  4293. a.doctor_id,
  4294. a.doctor_name
  4295. ) t2,(
  4296. SELECT
  4297. h1.doctorId,
  4298. h1.doctorName,
  4299. h1.emptyNum,
  4300. h1.errorNum,
  4301. h1.mrNum,
  4302. h2.entryNum,
  4303. h1.mrNum * h2.entryNum AS entryTotleNum,
  4304. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  4305. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  4306. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  4307. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  4308. FROM
  4309. (
  4310. SELECT
  4311. a.doctor_id AS doctorId,
  4312. a.doctor_name AS doctorName,
  4313. sum( d.rule_type = 1 ) AS emptyNum,
  4314. sum( d.rule_type = 2 ) AS errorNum,
  4315. count( DISTINCT a.behospital_code ) AS mrNum
  4316. FROM
  4317. med_behospital_info a,
  4318. med_qcresult_cases b,
  4319. med_qcresult_detail c,
  4320. qc_cases_entry d,
  4321. sys_user_dept e
  4322. WHERE
  4323. a.is_deleted = 'N'
  4324. AND b.is_deleted = 'N'
  4325. AND c.is_deleted = 'N'
  4326. AND d.is_deleted = 'N'
  4327. AND e.is_deleted = 'N'
  4328. AND a.hospital_id = b.hospital_id
  4329. AND a.hospital_id = c.hospital_id
  4330. AND a.hospital_id = e.hospital_id
  4331. AND a.behospital_code = b.behospital_code
  4332. AND a.behospital_code = c.behospital_code
  4333. AND b.cases_id = c.cases_id
  4334. AND c.cases_id = d.cases_id
  4335. AND c.cases_entry_id = d.id
  4336. AND a.beh_dept_id = e.dept_id
  4337. <if test="isPlacefile != null and isPlacefile != ''">
  4338. and a.is_placefile = #{isPlacefile}
  4339. </if>
  4340. AND d.cases_id = 243
  4341. <![CDATA[AND a.qc_type_id <>0 ]]>
  4342. <if test="hospitalId != null and hospitalId != ''">
  4343. AND a.hospital_id = #{hospitalId}
  4344. </if>
  4345. <if test="isPlacefile != null and isPlacefile == 0">
  4346. <if test="startDate != null and startDate != ''">
  4347. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4348. </if>
  4349. <if test="endDate != null and endDate != ''">
  4350. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4351. </if>
  4352. </if>
  4353. <if test="isPlacefile != null and isPlacefile == 1">
  4354. <if test="startDate != null and startDate != ''">
  4355. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4356. </if>
  4357. <if test="endDate != null and endDate != ''">
  4358. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4359. </if>
  4360. </if>
  4361. <if test="level != null and level != ''">
  4362. and b.level = #{level}
  4363. </if>
  4364. <if test="name != null and name != ''">
  4365. <if test="name == '未知'">
  4366. and (a.doctor_name is null or a.doctor_name='')
  4367. </if>
  4368. <if test="name != '未知'">
  4369. and a.doctor_name like CONCAT('%',#{name},'%')
  4370. </if>
  4371. </if>
  4372. <if test="userId!=null and userId !=''">
  4373. AND e.user_id = #{userId}
  4374. </if>
  4375. <if test="deptName!=null and deptName !=''">
  4376. AND a.beh_dept_name = #{deptName}
  4377. </if>
  4378. <if test="deptId!=null and deptId !=''">
  4379. AND a.beh_dept_id = #{deptId}
  4380. </if>
  4381. <if test="doctorId != null and doctorId != ''">
  4382. AND a.doctor_id = #{doctorId}
  4383. </if>
  4384. <if test="doctorName != null and doctorName != ''">
  4385. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4386. </if>
  4387. <if test="name != null and name != ''">
  4388. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4389. </if>
  4390. GROUP BY
  4391. a.doctor_id,
  4392. a.doctor_name
  4393. ) h1,(
  4394. SELECT
  4395. count(*) AS entryNum
  4396. FROM
  4397. qc_cases_entry
  4398. WHERE
  4399. is_deleted = 'N'
  4400. AND cases_id = 243
  4401. ) h2
  4402. ) t3
  4403. WHERE
  4404. t1.doctorId = t2.doctorId
  4405. AND t1.doctorId = t3.doctorId
  4406. AND t1.doctorName = t2.doctorName
  4407. AND t1.doctorName = t3.doctorName
  4408. <if test="asc != null and asc !=''">
  4409. order by
  4410. <choose>
  4411. <when test='asc=="doctorId"'>doctorId asc</when>
  4412. <when test='asc=="doctorName"'>doctorName asc</when>
  4413. <when test='asc=="entryNum"'>entryNum asc</when>
  4414. <when test='asc=="mrNum"'>mrNum asc</when>
  4415. <when test='asc=="totleValue"'>totleValue asc</when>
  4416. <when test='asc=="averageValue"'>averageValue asc</when>
  4417. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4418. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4419. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4420. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4421. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4422. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4423. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4424. <when test='asc=="errorNum"'>errorNum asc</when>
  4425. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4426. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4427. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4428. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4429. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4430. <otherwise>doctorName asc</otherwise>
  4431. </choose>
  4432. </if>
  4433. <if test="desc != null and desc!=''">
  4434. order by
  4435. <choose>
  4436. <when test='desc=="doctorId"'>doctorId desc</when>
  4437. <when test='desc=="doctorName"'>doctorName desc</when>
  4438. <when test='desc=="entryNum"'>entryNum desc</when>
  4439. <when test='desc=="mrNum"'>mrNum desc</when>
  4440. <when test='desc=="totleValue"'>totleValue desc</when>
  4441. <when test='desc=="averageValue"'>averageValue desc</when>
  4442. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4443. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4444. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4445. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4446. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4447. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4448. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4449. <when test='desc=="errorNum"'>errorNum desc</when>
  4450. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4451. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4452. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4453. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4454. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4455. <otherwise>doctorName desc</otherwise>
  4456. </choose>
  4457. </if>
  4458. </select>
  4459. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4460. <result column="behDeptName" property="behDeptName"/>
  4461. <result column="doctorName" property="doctorName"/>
  4462. <result column="avgScore" property="avgScore"/>
  4463. <collection property="excelBehospitalDTOS"
  4464. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  4465. <result column="patName" property="patName"/>
  4466. <result column="behospitalCode" property="behospitalCode"/>
  4467. <result column="behospitalDate" property="behospitalDate"/>
  4468. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4469. <result column="score" property="score"/>
  4470. <result column="scoreBn" property="scoreBn"/>
  4471. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4472. <result column="caseName" property="caseName"/>
  4473. <collection property="exportExcelMsgDTOS"
  4474. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4475. <result column="msg" property="msg"/>
  4476. </collection>
  4477. </collection>
  4478. </collection>
  4479. </resultMap>
  4480. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  4481. <result column="behDeptName" property="behDeptName"/>
  4482. <result column="avgScore" property="avgScore"/>
  4483. <collection property="excelBehospitalDTOS"
  4484. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  4485. <result column="doctorName" property="doctorName"/>
  4486. <result column="patName" property="patName"/>
  4487. <result column="behospitalCode" property="behospitalCode"/>
  4488. <result column="behospitalDate" property="behospitalDate"/>
  4489. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4490. <result column="score" property="score"/>
  4491. <result column="scoreBn" property="scoreBn"/>
  4492. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4493. <result column="caseName" property="caseName"/>
  4494. <collection property="exportExcelMsgDTOS"
  4495. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4496. <result column="msg" property="msg"/>
  4497. </collection>
  4498. </collection>
  4499. </collection>
  4500. </resultMap>
  4501. <resultMap id="ExportDoctorAverage_7" type="com.diagbot.dto.ExportDoctorAverageLevel_7DTO">
  4502. <result column="behDeptName" property="behDeptName"/>
  4503. <result column="avgScore" property="avgScore"/>
  4504. <collection property="excelBehospitalDTOS"
  4505. ofType="com.diagbot.dto.ExportBehospital_7DTO">
  4506. <result column="doctorName" property="doctorName"/>
  4507. <result column="patName" property="patName"/>
  4508. <result column="behospitalCode" property="behospitalCode"/>
  4509. <result column="behospitalDate" property="behospitalDate"/>
  4510. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4511. <result column="score" property="score"/>
  4512. <result column="scoreBn" property="scoreBn"/>
  4513. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportCase_7DTO">
  4514. <result column="caseName" property="caseName"/>
  4515. <collection property="exportExcelMsgDTOS"
  4516. ofType="com.diagbot.dto.ExportMsg_7DTO">
  4517. <result column="msg" property="msg"/>
  4518. </collection>
  4519. </collection>
  4520. </collection>
  4521. </resultMap>
  4522. <select id="exportExcel" resultMap="ExportExcelMap">
  4523. SELECT DISTINCT
  4524. t1.beh_dept_name AS behDeptName,
  4525. t1.beh_doctor_name AS doctorName,
  4526. t1.`name` AS patName,
  4527. t1.behospital_code AS behospitalCode,
  4528. t1.behospital_date AS behospitalDate,
  4529. t1.leave_hospital_date AS leaveHospitalDate,
  4530. t2.score_res AS score,
  4531. "1" AS avgScore,
  4532. t4.`name` AS caseName,
  4533. t3.msg AS msg
  4534. FROM
  4535. med_behospital_info t1,
  4536. med_qcresult_info t2,
  4537. med_qcresult_detail t3,
  4538. qc_cases t4
  4539. WHERE
  4540. t1.is_deleted = 'N'
  4541. AND t2.is_deleted = 'N'
  4542. AND t3.is_deleted = 'N'
  4543. AND t4.is_deleted = 'N'
  4544. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4545. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4546. AND t1.hospital_id = t2.hospital_id
  4547. AND t1.behospital_code = t2.behospital_code
  4548. AND t1.hospital_id = t3.hospital_id
  4549. AND t1.behospital_code = t3.behospital_code
  4550. AND t3.cases_id = t4.id
  4551. ORDER BY
  4552. t1.beh_dept_id ASC,
  4553. t1.leave_hospital_date DESC,
  4554. t1.behospital_code ASC,
  4555. t4.`name` ASC
  4556. </select>
  4557. <!-- 质控评分导出到excel-->
  4558. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4559. SELECT * FROM (
  4560. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4561. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4562. g.check_type AS ch_type,
  4563. h.check_type AS mr_type,
  4564. g.check_name AS ch_name,
  4565. h.check_name AS mr_name,
  4566. g.check_time AS ch_time,
  4567. h.check_time AS mr_time
  4568. FROM (
  4569. SELECT
  4570. t1.behDeptId,
  4571. t1.behDeptName,
  4572. t1.doctorName,
  4573. t1.patName,
  4574. t1.behospitalCode,
  4575. t1.hospitalId,
  4576. t1.behospitalDate,
  4577. t1.leaveHospitalDate,
  4578. t1.score,
  4579. <if test="radioCheck !=null and radioCheck == 1">
  4580. t1.msg,
  4581. t1.caseName,
  4582. </if>
  4583. t1.scoreBn,
  4584. t2.avgScore
  4585. FROM
  4586. (
  4587. SELECT
  4588. a.doctor_name AS doctorName,
  4589. a.`name` AS patName,
  4590. a.behospital_code AS behospitalCode,
  4591. a.behospital_date AS behospitalDate,
  4592. a.leave_hospital_date AS leaveHospitalDate,
  4593. b.score_res AS score,
  4594. e.score_res as scoreBn,
  4595. <if test="radioCheck !=null and radioCheck == 1">
  4596. c.msg AS msg,
  4597. d.NAME AS caseName,
  4598. </if>
  4599. a.beh_dept_id AS behDeptId,
  4600. a.beh_dept_name AS behDeptName,
  4601. a.hospital_id AS hospitalId
  4602. FROM
  4603. med_behospital_info a
  4604. RIGHT JOIN
  4605. med_qcresult_info b
  4606. ON a.hospital_id = b.hospital_id
  4607. AND a.is_deleted = 'N'
  4608. AND b.is_deleted = 'N'
  4609. AND a.behospital_code = b.behospital_code
  4610. <if test="radioCheck !=null and radioCheck == 1">
  4611. LEFT JOIN
  4612. med_qcresult_detail c
  4613. ON c.is_deleted = 'N'
  4614. AND b.behospital_code = c.behospital_code
  4615. AND b.hospital_id = c.hospital_id
  4616. LEFT JOIN
  4617. qc_cases d
  4618. on d.is_deleted = 'N'
  4619. AND c.cases_id = d.id
  4620. </if>
  4621. LEFT JOIN med_qcresult_cases e
  4622. on b.behospital_code = e.behospital_code
  4623. and b.hospital_id = e.hospital_id
  4624. AND e.is_deleted = 'N'
  4625. and e.cases_id = 243
  4626. WHERE
  4627. 1=1
  4628. <if test="isPlacefile != null and isPlacefile != ''">
  4629. and a.is_placefile = #{isPlacefile}
  4630. </if>
  4631. <![CDATA[AND a.qc_type_id <>0 ]]>
  4632. <if test="hospitalId != null and hospitalId != ''">
  4633. AND a.hospital_id = #{hospitalId}
  4634. </if>
  4635. <if test="diagnose != null and diagnose != ''">
  4636. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4637. </if>
  4638. <if test="behosDateStart != null">
  4639. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4640. </if>
  4641. <if test="behosDateEnd != null">
  4642. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4643. </if>
  4644. <if test="leaveHosDateStart != null ">
  4645. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4646. </if>
  4647. <if test="leaveHosDateEnd != null ">
  4648. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4649. </if>
  4650. <if test="behospitalCode != null and behospitalCode != ''">
  4651. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4652. </if>
  4653. <if test="level != null and level != ''">
  4654. AND b.level = #{level}
  4655. </if>
  4656. <if test="doctorName != null and doctorName != ''">
  4657. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4658. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4659. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4660. </if>
  4661. <if test="doctorCode != null and doctorCode != ''">
  4662. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4663. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4664. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4665. </if>
  4666. <if test="deptName != null and deptName != ''">
  4667. and a.beh_dept_name = #{deptName}
  4668. </if>
  4669. <if test="name != null and name != ''">
  4670. AND a.name like CONCAT('%',#{name},'%')
  4671. </if>
  4672. ) t1,
  4673. (
  4674. SELECT
  4675. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4676. a.beh_dept_id AS behDeptId,
  4677. a.beh_dept_name AS behDeptName
  4678. FROM
  4679. med_behospital_info a,
  4680. med_qcresult_info b
  4681. WHERE
  4682. a.is_deleted = 'N'
  4683. AND b.is_deleted = 'N'
  4684. AND a.hospital_id = b.hospital_id
  4685. AND a.behospital_code = b.behospital_code
  4686. <if test="isPlacefile != null and isPlacefile != ''">
  4687. and a.is_placefile = #{isPlacefile}
  4688. </if>
  4689. <![CDATA[AND a.qc_type_id <>0 ]]>
  4690. <if test="hospitalId != null and hospitalId != ''">
  4691. AND a.hospital_id = #{hospitalId}
  4692. </if>
  4693. <if test="diagnose != null and diagnose != ''">
  4694. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4695. </if>
  4696. <if test="behosDateStart != null">
  4697. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4698. </if>
  4699. <if test="behosDateEnd != null">
  4700. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4701. </if>
  4702. <if test="leaveHosDateStart != null ">
  4703. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4704. </if>
  4705. <if test="leaveHosDateEnd != null ">
  4706. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4707. </if>
  4708. <if test="behospitalCode != null and behospitalCode != ''">
  4709. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4710. </if>
  4711. <if test="level != null and level != ''">
  4712. AND b.level = #{level}
  4713. </if>
  4714. <if test="doctorName != null and doctorName != ''">
  4715. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4716. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4717. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4718. </if>
  4719. <if test="doctorCode != null and doctorCode != ''">
  4720. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4721. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4722. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4723. </if>
  4724. <if test="deptName != null and deptName != ''">
  4725. and a.beh_dept_name = #{deptName}
  4726. </if>
  4727. <if test="name != null and name != ''">
  4728. AND a.name like CONCAT('%',#{name},'%')
  4729. </if>
  4730. GROUP BY
  4731. a.beh_dept_id,
  4732. a.beh_dept_name
  4733. ) t2
  4734. WHERE
  4735. t1.behDeptId = t2.behDeptId
  4736. AND t1.behDeptName = t2.behDeptName
  4737. ORDER BY
  4738. t1.behDeptName,
  4739. t1.doctorName,
  4740. t1.patName,
  4741. <if test="radioCheck !=null and radioCheck == 1">
  4742. t1.caseName,
  4743. </if>
  4744. t1.behospitalCode
  4745. )tp
  4746. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4747. ON tp.behospitalCode = g.behospital_code
  4748. AND tp.hospitalId = g.hospital_id
  4749. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4750. ON tp.behospitalCode = h.behospital_code
  4751. AND tp.hospitalId = h.hospital_id
  4752. ) tu
  4753. WHERE tu.behospitalCode IS NOT NULL
  4754. <if test="checkStatus != null ">
  4755. and tu.check_status = #{checkStatus}
  4756. </if>
  4757. <if test="mrStatus != null ">
  4758. AND tu.mr_status = #{mrStatus}
  4759. </if>
  4760. <if test="chName != null and chName !=''">
  4761. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4762. </if>
  4763. <if test="mrName != null and mrName !=''">
  4764. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4765. </if>
  4766. <if test="chTimeStart != null">
  4767. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4768. </if>
  4769. <if test="chTimeEnd != null">
  4770. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4771. </if>
  4772. <if test="mrTimeStart != null">
  4773. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4774. </if>
  4775. <if test="mrTimeEnd != null">
  4776. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4777. </if>
  4778. </select>
  4779. <!-- 科室质控评分导出到excel-->
  4780. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4781. SELECT * FROM (
  4782. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4783. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4784. g.check_type AS ch_type,
  4785. h.check_type AS mr_type,
  4786. g.check_name AS ch_name,
  4787. h.check_name AS mr_name,
  4788. g.check_time AS ch_time,
  4789. h.check_time AS mr_time
  4790. FROM (
  4791. SELECT
  4792. t1.behDeptId,
  4793. t1.behDeptName,
  4794. t1.doctorName,
  4795. t1.patName,
  4796. t1.behospitalCode,
  4797. t1.hospitalId,
  4798. t1.behospitalDate,
  4799. t1.leaveHospitalDate,
  4800. t1.score,
  4801. t2.avgScore,
  4802. <if test="radioCheck !=null and radioCheck == 1">
  4803. t1.msg,
  4804. t1.caseName,
  4805. </if>
  4806. e.score_res as scoreBn
  4807. FROM
  4808. (
  4809. SELECT
  4810. a.doctor_name AS doctorName,
  4811. a.`name` AS patName,
  4812. a.behospital_code AS behospitalCode,
  4813. a.hospital_id AS hospital_id,
  4814. a.behospital_date AS behospitalDate,
  4815. a.leave_hospital_date AS leaveHospitalDate,
  4816. b.score_res AS score,
  4817. <if test="radioCheck !=null and radioCheck == 1">
  4818. c.msg AS msg,
  4819. d.NAME AS caseName,
  4820. </if>
  4821. a.beh_dept_id AS behDeptId,
  4822. a.beh_dept_name AS behDeptName,
  4823. a.hospital_id AS hospitalId
  4824. FROM
  4825. med_behospital_info a,
  4826. med_qcresult_info b,
  4827. med_qcresult_detail c,
  4828. qc_cases d,
  4829. sys_user_dept e
  4830. WHERE
  4831. a.is_deleted = 'N'
  4832. AND b.is_deleted = 'N'
  4833. AND c.is_deleted = 'N'
  4834. AND d.is_deleted = 'N'
  4835. AND e.is_deleted = 'N'
  4836. AND a.hospital_id = b.hospital_id
  4837. AND a.hospital_id = c.hospital_id
  4838. AND a.hospital_id = e.hospital_id
  4839. AND a.behospital_code = b.behospital_code
  4840. AND a.behospital_code = c.behospital_code
  4841. AND c.cases_id = d.id
  4842. AND a.beh_dept_id = e.dept_id
  4843. <if test="diagnose != null and diagnose != ''">
  4844. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4845. </if>
  4846. <if test="isPlacefile != null and isPlacefile != ''">
  4847. and a.is_placefile = #{isPlacefile}
  4848. </if>
  4849. <![CDATA[AND a.qc_type_id <>0 ]]>
  4850. <if test="hospitalId != null and hospitalId != ''">
  4851. AND a.hospital_id = #{hospitalId}
  4852. </if>
  4853. <if test="userId != null ">
  4854. AND e.user_id = #{userId}
  4855. </if>
  4856. <if test="behosDateStart != null">
  4857. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4858. </if>
  4859. <if test="behosDateEnd != null">
  4860. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4861. </if>
  4862. <if test="leaveHosDateStart != null ">
  4863. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4864. </if>
  4865. <if test="leaveHosDateEnd != null ">
  4866. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4867. </if>
  4868. <if test="behospitalCode != null and behospitalCode != ''">
  4869. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4870. </if>
  4871. <if test="level != null and level != ''">
  4872. AND b.level = #{level}
  4873. </if>
  4874. <if test="doctorName != null and doctorName != ''">
  4875. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4876. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4877. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4878. </if>
  4879. <if test="doctorCode != null and doctorCode != ''">
  4880. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4881. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4882. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4883. </if>
  4884. <if test="deptName != null and deptName != ''">
  4885. and a.beh_dept_name = #{deptName}
  4886. </if>
  4887. <if test="name != null and name != ''">
  4888. AND a.name like CONCAT('%',#{name},'%')
  4889. </if>
  4890. ) t1
  4891. LEFT JOIN med_qcresult_cases e
  4892. on t1.behospitalCode = e.behospital_code
  4893. and t1.hospital_id = e.hospital_id
  4894. AND e.is_deleted = 'N'
  4895. and e.cases_id = 243,
  4896. (
  4897. SELECT
  4898. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4899. a.beh_dept_id AS behDeptId,
  4900. a.beh_dept_name AS behDeptName
  4901. FROM
  4902. med_behospital_info a,
  4903. med_qcresult_info b,
  4904. sys_user_dept c
  4905. WHERE
  4906. a.is_deleted = 'N'
  4907. AND b.is_deleted = 'N'
  4908. AND c.is_deleted = 'N'
  4909. AND a.hospital_id = b.hospital_id
  4910. AND a.hospital_id = c.hospital_id
  4911. AND a.behospital_code = b.behospital_code
  4912. AND a.beh_dept_id = c.dept_id
  4913. <if test="diagnose != null and diagnose != ''">
  4914. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4915. </if>
  4916. <if test="isPlacefile != null and isPlacefile != ''">
  4917. and a.is_placefile = #{isPlacefile}
  4918. </if>
  4919. <![CDATA[AND a.qc_type_id <>0 ]]>
  4920. <if test="hospitalId != null and hospitalId != ''">
  4921. AND a.hospital_id = #{hospitalId}
  4922. </if>
  4923. <if test="userId != null ">
  4924. AND c.user_id = #{userId}
  4925. </if>
  4926. <if test="behosDateStart != null">
  4927. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4928. </if>
  4929. <if test="behosDateEnd != null">
  4930. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4931. </if>
  4932. <if test="leaveHosDateStart != null ">
  4933. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4934. </if>
  4935. <if test="leaveHosDateEnd != null ">
  4936. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4937. </if>
  4938. <if test="behospitalCode != null and behospitalCode != ''">
  4939. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4940. </if>
  4941. <if test="level != null and level != ''">
  4942. AND b.level = #{level}
  4943. </if>
  4944. <if test="doctorName != null and doctorName != ''">
  4945. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4946. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4947. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4948. </if>
  4949. <if test="doctorCode != null and doctorCode != ''">
  4950. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4951. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4952. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4953. </if>
  4954. <if test="deptName != null and deptName != ''">
  4955. and a.beh_dept_name = #{deptName}
  4956. </if>
  4957. <if test="name != null and name != ''">
  4958. AND a.name like CONCAT('%',#{name},'%')
  4959. </if>
  4960. GROUP BY
  4961. a.beh_dept_id,
  4962. a.beh_dept_name
  4963. ) t2
  4964. WHERE
  4965. t1.behDeptId = t2.behDeptId
  4966. AND t1.behDeptName = t2.behDeptName
  4967. ORDER BY
  4968. t1.behDeptName,
  4969. t1.doctorName,
  4970. t1.patName,
  4971. <if test="radioCheck !=null and radioCheck == 1">
  4972. t1.caseName,
  4973. </if>
  4974. t1.behospitalCode
  4975. )tp
  4976. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4977. ON tp.behospitalCode = g.behospital_code
  4978. AND tp.hospitalId = g.hospital_id
  4979. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4980. ON tp.behospitalCode = h.behospital_code
  4981. AND tp.hospitalId = h.hospital_id
  4982. ) tu
  4983. WHERE tu.behospitalCode IS NOT NULL
  4984. <if test="checkStatus != null ">
  4985. and tu.check_status = #{checkStatus}
  4986. </if>
  4987. <if test="mrStatus != null ">
  4988. AND tu.mr_status = #{mrStatus}
  4989. </if>
  4990. <if test="chName != null and chName !=''">
  4991. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4992. </if>
  4993. <if test="mrName != null and mrName !=''">
  4994. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4995. </if>
  4996. <if test="chTimeStart != null">
  4997. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4998. </if>
  4999. <if test="chTimeEnd != null">
  5000. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5001. </if>
  5002. <if test="mrTimeStart != null">
  5003. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5004. </if>
  5005. <if test="mrTimeEnd != null">
  5006. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5007. </if>
  5008. </select>
  5009. <!-- 个人质控评分导出到excel-->
  5010. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  5011. SELECT * FROM (
  5012. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  5013. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  5014. g.check_type AS ch_type,
  5015. h.check_type AS mr_type,
  5016. g.check_name AS ch_name,
  5017. h.check_name AS mr_name,
  5018. g.check_time AS ch_time,
  5019. h.check_time AS mr_time
  5020. FROM (
  5021. SELECT
  5022. t1.behDeptId,
  5023. t1.behDeptName,
  5024. t1.doctorName,
  5025. t1.patName,
  5026. t1.behospitalCode,
  5027. t1.hospitalId,
  5028. t1.behospitalDate,
  5029. t1.leaveHospitalDate,
  5030. t1.score,
  5031. t2.avgScore,
  5032. <if test="radioCheck !=null and radioCheck == 1">
  5033. t1.msg,
  5034. t1.caseName,
  5035. </if>
  5036. e.score_res as scoreBn
  5037. FROM
  5038. (
  5039. SELECT
  5040. a.doctor_name AS doctorName,
  5041. a.beh_doctor_name,
  5042. a.director_doctor_name,
  5043. a.`name` AS patName,
  5044. a.behospital_code AS behospitalCode,
  5045. a.behospital_date AS behospitalDate,
  5046. a.leave_hospital_date AS leaveHospitalDate,
  5047. b.score_res AS score,
  5048. <if test="radioCheck !=null and radioCheck == 1">
  5049. c.msg AS msg,
  5050. d.NAME AS caseName,
  5051. </if>
  5052. a.beh_dept_id AS behDeptId,
  5053. a.beh_dept_name AS behDeptName,
  5054. a.hospital_id AS hospitalId
  5055. FROM
  5056. med_behospital_info a,
  5057. med_qcresult_info b,
  5058. med_qcresult_detail c,
  5059. qc_cases d,
  5060. sys_user u,
  5061. sys_user_hospital uh
  5062. WHERE
  5063. a.is_deleted = 'N'
  5064. AND b.is_deleted = 'N'
  5065. AND c.is_deleted = 'N'
  5066. AND d.is_deleted = 'N'
  5067. AND u.is_deleted = 'N'
  5068. AND uh.is_deleted = 'N'
  5069. AND a.hospital_id = b.hospital_id
  5070. AND a.hospital_id = c.hospital_id
  5071. AND a.behospital_code = b.behospital_code
  5072. AND a.behospital_code = c.behospital_code
  5073. AND u.id = uh.user_id
  5074. AND a.hospital_id = uh.hospital_id
  5075. <if test="userId != null and userId != ''">
  5076. AND u.id = #{userId}
  5077. </if>
  5078. <if test="isPlacefile != null and isPlacefile != ''">
  5079. and a.is_placefile = #{isPlacefile}
  5080. </if>
  5081. <![CDATA[AND a.qc_type_id <>0 ]]>
  5082. <if test="hospitalId != null and hospitalId != ''">
  5083. AND a.hospital_id = #{hospitalId}
  5084. </if>
  5085. <if test="diagnose != null and diagnose != ''">
  5086. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5087. </if>
  5088. <if test="behosDateStart != null">
  5089. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5090. </if>
  5091. <if test="behosDateEnd != null">
  5092. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5093. </if>
  5094. <if test="leaveHosDateStart != null ">
  5095. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  5096. </if>
  5097. <if test="leaveHosDateEnd != null ">
  5098. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  5099. </if>
  5100. <if test="behospitalCode != null and behospitalCode != ''">
  5101. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5102. </if>
  5103. <if test="level != null and level != ''">
  5104. AND b.level = #{level}
  5105. </if>
  5106. <if test="doctorName != null and doctorName != ''">
  5107. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5108. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5109. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5110. </if>
  5111. <if test="doctorCode != null and doctorCode != ''">
  5112. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5113. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5114. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5115. </if>
  5116. <if test="deptId != null and deptId != ''">
  5117. AND a.beh_dept_id = #{deptId}
  5118. </if>
  5119. <if test="deptName != null and deptName != ''">
  5120. and a.beh_dept_name = #{deptName}
  5121. </if>
  5122. <if test="name != null and name != ''">
  5123. AND a.name like CONCAT('%',#{name},'%')
  5124. </if>
  5125. ) t1 LEFT JOIN med_qcresult_cases e
  5126. on t1.behospitalCode = e.behospital_code
  5127. and t1.hospitalId = e.hospital_id
  5128. AND e.is_deleted = 'N'
  5129. and e.cases_id = 243,
  5130. (
  5131. SELECT
  5132. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5133. a.beh_dept_id AS behDeptId,
  5134. a.beh_dept_name AS behDeptName
  5135. FROM
  5136. med_behospital_info a,
  5137. med_qcresult_info b,
  5138. sys_user u,
  5139. sys_user_hospital uh
  5140. WHERE
  5141. a.is_deleted = 'N'
  5142. AND b.is_deleted = 'N'
  5143. AND u.is_deleted = 'N'
  5144. AND uh.is_deleted = 'N'
  5145. AND a.hospital_id = b.hospital_id
  5146. AND a.behospital_code = b.behospital_code
  5147. AND u.id = uh.user_id
  5148. AND a.hospital_id = uh.hospital_id
  5149. and (a.doctor_name = u.linkman
  5150. or a.beh_doctor_name = u.linkman
  5151. or a.director_doctor_name = u.linkman)
  5152. <if test="userId != null and userId != ''">
  5153. AND u.id = #{userId}
  5154. </if>
  5155. <if test="diagnose != null and diagnose != ''">
  5156. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5157. </if>
  5158. <if test="isPlacefile != null and isPlacefile != ''">
  5159. and a.is_placefile = #{isPlacefile}
  5160. </if>
  5161. <![CDATA[AND a.qc_type_id <>0 ]]>
  5162. <if test="hospitalId != null and hospitalId != ''">
  5163. AND a.hospital_id = #{hospitalId}
  5164. </if>
  5165. <if test="behosDateStart != null">
  5166. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5167. </if>
  5168. <if test="behosDateEnd != null">
  5169. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5170. </if>
  5171. <if test="leaveHosDateStart != null ">
  5172. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  5173. </if>
  5174. <if test="leaveHosDateEnd != null ">
  5175. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  5176. </if>
  5177. <if test="behospitalCode != null and behospitalCode != ''">
  5178. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5179. </if>
  5180. <if test="level != null and level != ''">
  5181. AND b.level = #{level}
  5182. </if>
  5183. <if test="doctorName != null and doctorName != ''">
  5184. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5185. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5186. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5187. </if>
  5188. <if test="doctorCode != null and doctorCode != ''">
  5189. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5190. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5191. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5192. </if>
  5193. <if test="deptId != null and deptId != ''">
  5194. AND a.beh_dept_id = #{deptId}
  5195. </if>
  5196. <if test="deptName != null and deptName != ''">
  5197. and a.beh_dept_name = #{deptName}
  5198. </if>
  5199. <if test="name != null and name != ''">
  5200. AND a.name like CONCAT('%',#{name},'%')
  5201. </if>
  5202. ) t2
  5203. WHERE
  5204. t1.behDeptId = t2.behDeptId
  5205. AND t1.behDeptName = t2.behDeptName
  5206. ORDER BY
  5207. t1.behDeptName,
  5208. t1.doctorName,
  5209. t1.patName,
  5210. <if test="radioCheck !=null and radioCheck == 1">
  5211. t1.caseName,
  5212. </if>
  5213. t1.behospitalCode
  5214. )tp
  5215. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5216. ON tp.behospitalCode = g.behospital_code
  5217. AND tp.hospitalId = g.hospital_id
  5218. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5219. ON tp.behospitalCode = h.behospital_code
  5220. AND tp.hospitalId = h.hospital_id
  5221. ) tu
  5222. WHERE tu.behospitalCode IS NOT NULL
  5223. <if test="checkStatus != null ">
  5224. and tu.check_status = #{checkStatus}
  5225. </if>
  5226. <if test="mrStatus != null ">
  5227. AND tu.mr_status = #{mrStatus}
  5228. </if>
  5229. <if test="chName != null and chName !=''">
  5230. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5231. </if>
  5232. <if test="mrName != null and mrName !=''">
  5233. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5234. </if>
  5235. <if test="chTimeStart != null">
  5236. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5237. </if>
  5238. <if test="chTimeEnd != null">
  5239. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5240. </if>
  5241. <if test="mrTimeStart != null">
  5242. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5243. </if>
  5244. <if test="mrTimeEnd != null">
  5245. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5246. </if>
  5247. </select>
  5248. <!-- 医疗组质控评分导出到excel-->
  5249. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  5250. SELECT * FROM (
  5251. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  5252. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  5253. g.check_type AS ch_type,
  5254. h.check_type AS mr_type,
  5255. g.check_name AS ch_name,
  5256. h.check_name AS mr_name,
  5257. g.check_time AS ch_time,
  5258. h.check_time AS mr_time
  5259. FROM (
  5260. SELECT
  5261. t1.behDeptId,
  5262. t1.behDeptName,
  5263. t1.doctorName,
  5264. t1.patName,
  5265. t1.behospitalCode,
  5266. t1.hospitalId,
  5267. t1.behospitalDate,
  5268. t1.leaveHospitalDate,
  5269. t1.score,
  5270. t2.avgScore,
  5271. <if test="radioCheck !=null and radioCheck == 1">
  5272. t1.msg,
  5273. t1.caseName,
  5274. </if>
  5275. e.score_res as scoreBn
  5276. FROM
  5277. (
  5278. SELECT
  5279. a.doctor_name AS doctorName,
  5280. a.`name` AS patName,
  5281. a.behospital_code AS behospitalCode,
  5282. a.behospital_date AS behospitalDate,
  5283. a.leave_hospital_date AS leaveHospitalDate,
  5284. b.score_res AS score,
  5285. <if test="radioCheck !=null and radioCheck == 1">
  5286. c.msg AS msg,
  5287. d.NAME AS caseName,
  5288. </if>
  5289. a.beh_dept_id AS behDeptId,
  5290. a.beh_dept_name AS behDeptName,
  5291. a.hospital_id AS hospitalId
  5292. FROM
  5293. med_behospital_info a,
  5294. med_qcresult_info b,
  5295. med_qcresult_detail c,
  5296. qc_cases d
  5297. WHERE
  5298. a.is_deleted = 'N'
  5299. AND b.is_deleted = 'N'
  5300. AND c.is_deleted = 'N'
  5301. AND d.is_deleted = 'N'
  5302. AND a.hospital_id = b.hospital_id
  5303. AND a.hospital_id = c.hospital_id
  5304. AND a.behospital_code = b.behospital_code
  5305. AND a.behospital_code = c.behospital_code
  5306. AND c.cases_id = d.id
  5307. <if test="isPlacefile != null and isPlacefile != ''">
  5308. and a.is_placefile = #{isPlacefile}
  5309. </if>
  5310. AND a.doctor_id in
  5311. (SELECT doctor_id FROM `bas_doctor_info`
  5312. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5313. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5314. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5315. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5316. and c1.username = c3.doctor_id
  5317. and c2.hospital_id = #{hospitalId}
  5318. and c1.id = #{userId}
  5319. ))
  5320. <![CDATA[AND a.qc_type_id <>0 ]]>
  5321. <if test="hospitalId != null and hospitalId != ''">
  5322. AND a.hospital_id = #{hospitalId}
  5323. </if>
  5324. <if test="diagnose != null and diagnose != ''">
  5325. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5326. </if>
  5327. <if test="behosDateStart != null">
  5328. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5329. </if>
  5330. <if test="behosDateEnd != null">
  5331. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5332. </if>
  5333. <if test="leaveHosDateStart != null ">
  5334. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5335. </if>
  5336. <if test="leaveHosDateEnd != null ">
  5337. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5338. </if>
  5339. <if test="behospitalCode != null and behospitalCode != ''">
  5340. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5341. </if>
  5342. <if test="level != null and level != ''">
  5343. AND b.level = #{level}
  5344. </if>
  5345. <if test="doctorName != null and doctorName != ''">
  5346. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5347. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5348. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5349. </if>
  5350. <if test="doctorCode != null and doctorCode != ''">
  5351. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5352. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5353. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5354. </if>
  5355. <if test="deptId != null and deptId != ''">
  5356. AND a.beh_dept_id = #{deptId}
  5357. </if>
  5358. <if test="name != null and name != ''">
  5359. AND a.name like CONCAT('%',#{name},'%')
  5360. </if>
  5361. ) t1 LEFT JOIN med_qcresult_cases e
  5362. on t1.behospitalCode = e.behospital_code
  5363. and t1.hospitalId = e.hospital_id
  5364. AND e.is_deleted = 'N'
  5365. and e.cases_id = 243,
  5366. (
  5367. SELECT
  5368. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5369. a.beh_dept_id AS behDeptId,
  5370. a.beh_dept_name AS behDeptName
  5371. FROM
  5372. med_behospital_info a,
  5373. med_qcresult_info b
  5374. WHERE
  5375. a.is_deleted = 'N'
  5376. AND a.doctor_id in
  5377. (SELECT doctor_id FROM `bas_doctor_info`
  5378. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5379. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5380. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5381. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5382. and c1.username = c3.doctor_id
  5383. and c2.hospital_id = #{hospitalId}
  5384. and c1.id = #{userId}
  5385. ))
  5386. AND b.is_deleted = 'N'
  5387. AND a.hospital_id = b.hospital_id
  5388. AND a.behospital_code = b.behospital_code
  5389. <if test="diagnose != null and diagnose != ''">
  5390. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5391. </if>
  5392. <if test="isPlacefile != null and isPlacefile != ''">
  5393. and a.is_placefile = #{isPlacefile}
  5394. </if>
  5395. <![CDATA[AND a.qc_type_id <>0 ]]>
  5396. <if test="hospitalId != null and hospitalId != ''">
  5397. AND a.hospital_id = #{hospitalId}
  5398. </if>
  5399. <if test="behosDateStart != null">
  5400. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5401. </if>
  5402. <if test="behosDateEnd != null">
  5403. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5404. </if>
  5405. <if test="leaveHosDateStart != null ">
  5406. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5407. </if>
  5408. <if test="leaveHosDateEnd != null ">
  5409. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5410. </if>
  5411. <if test="behospitalCode != null and behospitalCode != ''">
  5412. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5413. </if>
  5414. <if test="level != null and level != ''">
  5415. AND b.level = #{level}
  5416. </if>
  5417. <if test="doctorName != null and doctorName != ''">
  5418. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5419. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5420. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5421. </if>
  5422. <if test="doctorCode != null and doctorCode != ''">
  5423. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5424. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5425. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5426. </if>
  5427. <if test="deptId != null and deptId != ''">
  5428. AND a.beh_dept_id = #{deptId}
  5429. </if>
  5430. <if test="name != null and name != ''">
  5431. AND a.name like CONCAT('%',#{name},'%')
  5432. </if>
  5433. GROUP BY
  5434. a.beh_dept_id,
  5435. a.beh_dept_name
  5436. ) t2
  5437. WHERE
  5438. t1.behDeptId = t2.behDeptId
  5439. AND t1.behDeptName = t2.behDeptName
  5440. ORDER BY
  5441. t1.behDeptName,
  5442. t1.doctorName,
  5443. t1.patName,
  5444. <if test="radioCheck !=null and radioCheck == 1">
  5445. t1.caseName,
  5446. </if>
  5447. t1.behospitalCode
  5448. )tp
  5449. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5450. ON tp.behospitalCode = g.behospital_code
  5451. AND tp.hospitalId = g.hospital_id
  5452. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5453. ON tp.behospitalCode = h.behospital_code
  5454. AND tp.hospitalId = h.hospital_id
  5455. ) tu
  5456. WHERE tu.behospitalCode IS NOT NULL
  5457. <if test="checkStatus != null ">
  5458. and tu.check_status = #{checkStatus}
  5459. </if>
  5460. <if test="mrStatus != null ">
  5461. AND tu.mr_status = #{mrStatus}
  5462. </if>
  5463. <if test="chName != null and chName !=''">
  5464. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5465. </if>
  5466. <if test="mrName != null and mrName !=''">
  5467. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5468. </if>
  5469. <if test="chTimeStart != null">
  5470. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5471. </if>
  5472. <if test="chTimeEnd != null">
  5473. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5474. </if>
  5475. <if test="mrTimeStart != null">
  5476. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5477. </if>
  5478. <if test="mrTimeEnd != null">
  5479. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5480. </if>
  5481. </select>
  5482. <!-- 条目缺陷质控评分页(内页)湘雅-->
  5483. <select id="qcResultShortXYPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5484. SELECT t.*
  5485. FROM
  5486. (SELECT DISTINCT
  5487. t1.hospital_id AS hospitalId,
  5488. t1.behospital_code AS behospitalCode,
  5489. t1.bed_code AS bedCode,
  5490. t1.LEVEL AS LEVEL,
  5491. t1.grade_type AS gradeType,
  5492. t1.score_res AS scoreRes,
  5493. t1.scoreBn,
  5494. t1.NAME AS NAME,
  5495. t1.sex AS sex,
  5496. t1.beh_dept_id AS behDeptId,
  5497. t1.beh_dept_name AS behDeptName,
  5498. t1.doctorId,
  5499. t1.doctor_name AS doctorName,
  5500. t1.birthday AS birthday,
  5501. t1.behospital_date AS behospitalDate,
  5502. t1.leave_hospital_date AS leaveHospitalDate,
  5503. t1.placefile_date AS placefileDate,
  5504. t1.gmt_create AS gradeTime,
  5505. t1.diagnose,
  5506. t1.ward_name AS wardName,
  5507. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5508. t1.file_code AS fileCode,
  5509. t1.checkStatus,
  5510. t1.mrStatus,
  5511. t1.chName,
  5512. t1.mrName,
  5513. t1.chTime,
  5514. t1.mrTime,
  5515. t1.is_daytime as isDaytime
  5516. FROM
  5517. (
  5518. SELECT DISTINCT
  5519. tt1.*
  5520. FROM
  5521. (SELECT
  5522. be.*,
  5523. ifnull(mci.status,0) AS checkStatus,
  5524. ifnull(hm_mci.status,0) AS mrStatus,
  5525. mci.check_name as chName,
  5526. e.score_res as scoreBn,
  5527. f.doctor_id as doctorId,
  5528. hm_mci.check_name as mrName,
  5529. mci.gmt_create as chTime,
  5530. hm_mci.gmt_create as mrTime
  5531. FROM
  5532. (
  5533. SELECT DISTINCT
  5534. a.hospital_id,
  5535. a.behospital_code,
  5536. a.bed_code,
  5537. a.file_code,
  5538. b.LEVEL,
  5539. b.grade_type,
  5540. b.score_res,
  5541. a.NAME,
  5542. a.sex,
  5543. a.beh_dept_id,
  5544. a.beh_dept_name,
  5545. a.birthday,
  5546. a.behospital_date,
  5547. a.leave_hospital_date,
  5548. case
  5549. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  5550. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5551. e.director_doctor != '' and e.director_doctor is not null
  5552. then e.director_doctor
  5553. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5554. (e.director_doctor = '' or e.director_doctor is null) and
  5555. e.behospital_doctor != '' and e.behospital_doctor is not null
  5556. then e.behospital_doctor end as doctor_name,
  5557. a.diagnose,
  5558. a.placefile_date,
  5559. a.ward_name,
  5560. b.gmt_create,
  5561. a.is_daytime
  5562. FROM
  5563. med_behospital_info a,
  5564. med_qcresult_info b,
  5565. med_qcresult_detail c,
  5566. qc_cases_entry d,
  5567. med_home_page e
  5568. WHERE
  5569. a.is_deleted = 'N'
  5570. AND b.is_deleted = 'N'
  5571. AND c.is_deleted = 'N'
  5572. AND d.is_deleted = 'N'
  5573. AND e.is_deleted = 'N'
  5574. AND a.hospital_id = b.hospital_id
  5575. AND a.hospital_id = c.hospital_id
  5576. AND a.hospital_id = e.hospital_id
  5577. AND a.behospital_code = b.behospital_code
  5578. AND a.behospital_code = c.behospital_code
  5579. AND a.behospital_code = e.behospital_code
  5580. AND c.cases_id = d.cases_id
  5581. AND c.cases_entry_id = d.id
  5582. AND a.qc_type_id != 0
  5583. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  5584. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  5585. </if>
  5586. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5587. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5588. </if>
  5589. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5590. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5591. </if>
  5592. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5593. <if test="qcResultShortPageVO.startDate != null ">
  5594. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5595. </if>
  5596. <if test="qcResultShortPageVO.endDate != null ">
  5597. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5598. </if>
  5599. </if>
  5600. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5601. <if test="qcResultShortPageVO.startDate != null ">
  5602. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5603. </if>
  5604. <if test="qcResultShortPageVO.endDate != null">
  5605. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5606. </if>
  5607. </if>
  5608. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5609. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5610. </if>
  5611. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5612. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5613. </if>
  5614. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  5615. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  5616. </if>
  5617. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5618. AND b.`level` = #{qcResultShortPageVO.level}
  5619. </if>
  5620. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5621. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5622. </if>
  5623. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  5624. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  5625. </if>
  5626. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5627. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5628. </if>
  5629. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5630. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5631. </if>
  5632. <if test="qcResultShortPageVO.casesEntryId != null ">
  5633. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5634. </if>
  5635. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5636. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5637. </if>
  5638. <if test="qcResultShortPageVO.casesId != null">
  5639. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5640. </if>
  5641. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5642. AND(case
  5643. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  5644. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5645. e.director_doctor != '' and e.director_doctor is not null
  5646. then e.director_doctor
  5647. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5648. (e.director_doctor = '' or e.director_doctor is null) and
  5649. e.behospital_doctor != '' and e.behospital_doctor is not null
  5650. then e.behospital_doctor end ) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5651. </if>
  5652. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  5653. AND(case
  5654. when e.attending_doctor != '' and e.attending_doctor is not null then '主治医师'
  5655. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5656. e.director_doctor != '' and e.director_doctor is not null
  5657. then '主任医师'
  5658. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5659. (e.director_doctor = '' or e.director_doctor is null) and
  5660. e.behospital_doctor != '' and e.behospital_doctor is not null
  5661. then '住院医师' end) = #{qcResultShortPageVO.professor}
  5662. </if>
  5663. <if test="qcResultShortPageVO.isReject != null">
  5664. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5665. </if>
  5666. <if test="qcResultShortPageVO.ruleType != null">
  5667. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5668. </if>
  5669. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5670. AND TIMESTAMPDIFF(
  5671. DAY,
  5672. DATE( a.behospital_date ),
  5673. DATE( a.leave_hospital_date ))> 30
  5674. </if>
  5675. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5676. AND TIMESTAMPDIFF(
  5677. DAY,
  5678. DATE( a.behospital_date ),
  5679. DATE( a.leave_hospital_date ))> 31
  5680. </if>
  5681. )be
  5682. left join med_check_info mci
  5683. on mci.is_deleted = 'N'
  5684. and mci.check_type in(0,2)
  5685. and be.hospital_id = mci.hospital_id
  5686. and be.behospital_code = mci.behospital_code
  5687. left join med_check_info hm_mci
  5688. on hm_mci.is_deleted = 'N'
  5689. and hm_mci.check_type = 1
  5690. and be.hospital_id = hm_mci.hospital_id
  5691. and be.behospital_code = hm_mci.behospital_code
  5692. LEFT JOIN med_qcresult_cases e
  5693. on be.behospital_code = e.behospital_code
  5694. and be.hospital_id = e.hospital_id
  5695. AND e.is_deleted = 'N'
  5696. and e.cases_id = 243
  5697. LEFT JOIN bas_doctor_info f
  5698. on be.hospital_id = f.hospital_id
  5699. and be.doctor_name = f.name
  5700. AND f.is_deleted = 'N'
  5701. )tt1
  5702. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5703. ,med_medical_record tt2
  5704. WHERE
  5705. tt2.is_deleted = 'N'
  5706. AND tt1.hospital_id = tt2.hospital_id
  5707. AND tt1.behospital_code = tt2.behospital_code
  5708. AND tt2.mode_id = 30
  5709. </if>
  5710. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5711. ,med_crisis_info tt2
  5712. WHERE
  5713. tt2.is_deleted = 'N'
  5714. AND tt1.hospital_id = tt2.hospital_id
  5715. AND tt1.behospital_code = tt2.behospital_code
  5716. </if>
  5717. ) t1
  5718. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5719. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5720. AND t1.behospital_code = t2.behospital_code
  5721. AND t2.is_deleted = 'N'
  5722. </if>
  5723. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5724. , med_home_page t2
  5725. , med_home_operation_info t3
  5726. WHERE t1.hospital_id = t2.hospital_id
  5727. AND t1.behospital_code = t2.behospital_code
  5728. AND t2.home_page_id = t3.home_page_id
  5729. AND t2.is_deleted = 'N'
  5730. AND t3.is_deleted = 'N'
  5731. </if>
  5732. ) t
  5733. where 1=1
  5734. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5735. AND t.doctorId = #{qcResultShortPageVO.doctorId}
  5736. </if>
  5737. <if test="qcResultShortPageVO.checkStatus != null">
  5738. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5739. </if>
  5740. <if test="qcResultShortPageVO.mrStatus != null">
  5741. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5742. </if>
  5743. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5744. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5745. </if>
  5746. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5747. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5748. </if>
  5749. <if test="qcResultShortPageVO.chTimeStart != null ">
  5750. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5751. </if>
  5752. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5753. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5754. </if>
  5755. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5756. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5757. </if>
  5758. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5759. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5760. </if>
  5761. </select>
  5762. <!-- 条目缺陷质控评分页(内页)-->
  5763. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5764. SELECT t.*
  5765. FROM
  5766. (SELECT DISTINCT
  5767. t1.hospital_id AS hospitalId,
  5768. t1.behospital_code AS behospitalCode,
  5769. t1.bed_code AS bedCode,
  5770. t1.LEVEL AS LEVEL,
  5771. t1.grade_type AS gradeType,
  5772. t1.score_res AS scoreRes,
  5773. t1.scoreBn,
  5774. t1.NAME AS NAME,
  5775. t1.sex AS sex,
  5776. t1.beh_dept_id AS behDeptId,
  5777. t1.beh_dept_name AS behDeptName,
  5778. t1.doctor_id AS doctorId,
  5779. t1.doctor_name AS doctorName,
  5780. t1.beh_doctor_id AS behDoctorId,
  5781. t1.beh_doctor_name AS behDoctorName,
  5782. t1.director_doctor_id AS directorDoctorId,
  5783. t1.director_doctor_name AS directorDoctorName,
  5784. t1.birthday AS birthday,
  5785. t1.behospital_date AS behospitalDate,
  5786. t1.leave_hospital_date AS leaveHospitalDate,
  5787. t1.placefile_date AS placefileDate,
  5788. t1.gmt_create AS gradeTime,
  5789. t1.diagnose,
  5790. t1.ward_name AS wardName,
  5791. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5792. t1.file_code AS fileCode,
  5793. t1.checkStatus,
  5794. t1.mrStatus,
  5795. t1.chName,
  5796. t1.mrName,
  5797. t1.chTime,
  5798. t1.mrTime,
  5799. t1.is_daytime as isDaytime
  5800. FROM
  5801. (
  5802. SELECT DISTINCT
  5803. tt1.*
  5804. FROM
  5805. (SELECT
  5806. be.*,
  5807. ifnull(mci.status,0) AS checkStatus,
  5808. ifnull(hm_mci.status,0) AS mrStatus,
  5809. mci.check_name as chName,
  5810. e.score_res as scoreBn,
  5811. hm_mci.check_name as mrName,
  5812. mci.gmt_create as chTime,
  5813. hm_mci.gmt_create as mrTime
  5814. FROM
  5815. (
  5816. SELECT DISTINCT
  5817. a.hospital_id,
  5818. a.behospital_code,
  5819. a.bed_code,
  5820. a.file_code,
  5821. b.LEVEL,
  5822. b.grade_type,
  5823. b.score_res,
  5824. a.NAME,
  5825. a.sex,
  5826. a.beh_dept_id,
  5827. a.beh_dept_name,
  5828. a.birthday,
  5829. a.behospital_date,
  5830. a.leave_hospital_date,
  5831. a.doctor_id,
  5832. a.doctor_name,
  5833. a.beh_doctor_id,
  5834. a.beh_doctor_name,
  5835. a.director_doctor_id,
  5836. a.director_doctor_name,
  5837. a.diagnose,
  5838. a.placefile_date,
  5839. a.ward_name,
  5840. a.is_daytime,
  5841. b.gmt_create
  5842. FROM
  5843. med_behospital_info a,
  5844. med_qcresult_info b,
  5845. med_qcresult_detail c,
  5846. qc_cases_entry d
  5847. WHERE
  5848. a.is_deleted = 'N'
  5849. AND b.is_deleted = 'N'
  5850. AND c.is_deleted = 'N'
  5851. AND d.is_deleted = 'N'
  5852. AND a.hospital_id = b.hospital_id
  5853. AND a.hospital_id = c.hospital_id
  5854. AND a.behospital_code = b.behospital_code
  5855. AND a.behospital_code = c.behospital_code
  5856. AND c.cases_id = d.cases_id
  5857. AND c.cases_entry_id = d.id
  5858. AND a.qc_type_id != 0
  5859. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  5860. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  5861. </if>
  5862. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5863. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5864. </if>
  5865. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5866. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5867. </if>
  5868. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5869. <if test="qcResultShortPageVO.startDate != null ">
  5870. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5871. </if>
  5872. <if test="qcResultShortPageVO.endDate != null ">
  5873. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5874. </if>
  5875. </if>
  5876. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5877. <if test="qcResultShortPageVO.startDate != null ">
  5878. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5879. </if>
  5880. <if test="qcResultShortPageVO.endDate != null">
  5881. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5882. </if>
  5883. </if>
  5884. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5885. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5886. </if>
  5887. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5888. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5889. </if>
  5890. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5891. AND b.`level` = #{qcResultShortPageVO.level}
  5892. </if>
  5893. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5894. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5895. </if>
  5896. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  5897. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  5898. </if>
  5899. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5900. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5901. </if>
  5902. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5903. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5904. </if>
  5905. <if test="qcResultShortPageVO.casesEntryId != null ">
  5906. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5907. </if>
  5908. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5909. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5910. </if>
  5911. <if test="qcResultShortPageVO.casesId != null">
  5912. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5913. </if>
  5914. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5915. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5916. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5917. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5918. </if>
  5919. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5920. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5921. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5922. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5923. </if>
  5924. <if test="qcResultShortPageVO.isReject != null">
  5925. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5926. </if>
  5927. <if test="qcResultShortPageVO.ruleType != null">
  5928. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5929. </if>
  5930. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5931. AND TIMESTAMPDIFF(
  5932. DAY,
  5933. DATE( a.behospital_date ),
  5934. DATE( a.leave_hospital_date ))> 30
  5935. </if>
  5936. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5937. AND TIMESTAMPDIFF(
  5938. DAY,
  5939. DATE( a.behospital_date ),
  5940. DATE( a.leave_hospital_date ))> 31
  5941. </if>
  5942. )be
  5943. left join med_check_info mci
  5944. on mci.is_deleted = 'N'
  5945. and mci.check_type in(0,2)
  5946. and be.hospital_id = mci.hospital_id
  5947. and be.behospital_code = mci.behospital_code
  5948. left join med_check_info hm_mci
  5949. on hm_mci.is_deleted = 'N'
  5950. and hm_mci.check_type = 1
  5951. and be.hospital_id = hm_mci.hospital_id
  5952. and be.behospital_code = hm_mci.behospital_code
  5953. LEFT JOIN med_qcresult_cases e
  5954. on be.behospital_code = e.behospital_code
  5955. and be.hospital_id = e.hospital_id
  5956. AND e.is_deleted = 'N'
  5957. and e.cases_id = 243
  5958. )tt1
  5959. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5960. ,med_medical_record tt2
  5961. WHERE
  5962. tt2.is_deleted = 'N'
  5963. AND tt1.hospital_id = tt2.hospital_id
  5964. AND tt1.behospital_code = tt2.behospital_code
  5965. AND tt2.mode_id = 30
  5966. </if>
  5967. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5968. ,med_crisis_info tt2
  5969. WHERE
  5970. tt2.is_deleted = 'N'
  5971. AND tt1.hospital_id = tt2.hospital_id
  5972. AND tt1.behospital_code = tt2.behospital_code
  5973. </if>
  5974. ) t1
  5975. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5976. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5977. AND t1.behospital_code = t2.behospital_code
  5978. AND t2.is_deleted = 'N'
  5979. </if>
  5980. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5981. , med_home_page t2
  5982. , med_home_operation_info t3
  5983. WHERE t1.hospital_id = t2.hospital_id
  5984. AND t1.behospital_code = t2.behospital_code
  5985. AND t2.home_page_id = t3.home_page_id
  5986. AND t2.is_deleted = 'N'
  5987. AND t3.is_deleted = 'N'
  5988. </if>
  5989. ) t
  5990. where 1=1
  5991. <if test="qcResultShortPageVO.checkStatus != null">
  5992. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5993. </if>
  5994. <if test="qcResultShortPageVO.mrStatus != null">
  5995. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5996. </if>
  5997. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5998. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5999. </if>
  6000. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6001. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6002. </if>
  6003. <if test="qcResultShortPageVO.chTimeStart != null ">
  6004. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6005. </if>
  6006. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6007. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6008. </if>
  6009. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6010. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6011. </if>
  6012. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6013. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6014. </if>
  6015. </select>
  6016. <!-- 条目缺陷质控评分页-科室(内页)-->
  6017. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  6018. SELECT t.*
  6019. FROM
  6020. (SELECT DISTINCT
  6021. t1.hospital_id AS hospitalId,
  6022. t1.behospital_code AS behospitalCode,
  6023. t1.bed_code AS bedCode,
  6024. t1.LEVEL AS LEVEL,
  6025. t1.grade_type AS gradeType,
  6026. t1.score_res AS scoreRes,
  6027. t1.scoreBn,
  6028. t1.NAME AS NAME,
  6029. t1.sex AS sex,
  6030. t1.beh_dept_id AS behDeptId,
  6031. t1.beh_dept_name AS behDeptName,
  6032. t1.doctor_id AS doctorId,
  6033. t1.doctor_name AS doctorName,
  6034. t1.beh_doctor_id AS behDoctorId,
  6035. t1.beh_doctor_name AS behDoctorName,
  6036. t1.director_doctor_id AS directorDoctorId,
  6037. t1.director_doctor_name AS directorDoctorName,
  6038. t1.birthday AS birthday,
  6039. t1.behospital_date AS behospitalDate,
  6040. t1.leave_hospital_date AS leaveHospitalDate,
  6041. t1.placefile_date AS placefileDate,
  6042. t1.gmt_create AS gradeTime,
  6043. t1.diagnose,
  6044. t1.ward_name AS wardName,
  6045. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  6046. t1.file_code AS fileCode,
  6047. t1.checkStatus,
  6048. t1.mrStatus,
  6049. t1.chName,
  6050. t1.mrName,
  6051. t1.chTime,
  6052. t1.mrTime,
  6053. t1.is_daytime as isDaytime
  6054. FROM
  6055. (
  6056. SELECT DISTINCT
  6057. tt1.*
  6058. FROM
  6059. (SELECT
  6060. be.*,
  6061. ifnull(mci.status,0) AS checkStatus,
  6062. ifnull(hm_mci.status,0) AS mrStatus,
  6063. mci.check_name as chName,
  6064. e.score_res as scoreBn,
  6065. hm_mci.check_name as mrName,
  6066. mci.gmt_create as chTime,
  6067. hm_mci.gmt_create as mrTime
  6068. FROM
  6069. (
  6070. SELECT DISTINCT
  6071. a.hospital_id,
  6072. a.behospital_code,
  6073. a.bed_code,
  6074. a.file_code,
  6075. b.LEVEL,
  6076. b.grade_type,
  6077. b.score_res,
  6078. a.NAME,
  6079. a.sex,
  6080. a.beh_dept_id,
  6081. a.beh_dept_name,
  6082. a.birthday,
  6083. a.behospital_date,
  6084. a.leave_hospital_date,
  6085. a.doctor_id,
  6086. a.doctor_name,
  6087. a.beh_doctor_id,
  6088. a.beh_doctor_name,
  6089. a.director_doctor_id,
  6090. a.director_doctor_name,
  6091. a.diagnose,
  6092. a.placefile_date,
  6093. a.is_daytime,
  6094. a.ward_name,
  6095. b.gmt_create
  6096. FROM
  6097. med_behospital_info a,
  6098. med_qcresult_info b,
  6099. med_qcresult_detail c,
  6100. qc_cases_entry d,
  6101. sys_user_dept e
  6102. WHERE
  6103. a.is_deleted = 'N'
  6104. AND b.is_deleted = 'N'
  6105. AND c.is_deleted = 'N'
  6106. AND d.is_deleted = 'N'
  6107. AND e.is_deleted = 'N'
  6108. AND a.hospital_id = b.hospital_id
  6109. AND a.hospital_id = c.hospital_id
  6110. AND a.hospital_id = e.hospital_id
  6111. AND a.behospital_code = b.behospital_code
  6112. AND a.behospital_code = c.behospital_code
  6113. AND a.beh_dept_id = e.dept_id
  6114. AND c.cases_id = d.cases_id
  6115. AND c.cases_entry_id = d.id
  6116. AND a.qc_type_id != 0
  6117. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  6118. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  6119. </if>
  6120. <if test="qcResultShortPageVO.userId!=null">
  6121. AND e.user_id = #{qcResultShortPageVO.userId}
  6122. </if>
  6123. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6124. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6125. </if>
  6126. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6127. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6128. </if>
  6129. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  6130. <if test="qcResultShortPageVO.startDate != null ">
  6131. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  6132. </if>
  6133. <if test="qcResultShortPageVO.endDate != null ">
  6134. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  6135. </if>
  6136. </if>
  6137. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  6138. <if test="qcResultShortPageVO.startDate != null ">
  6139. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6140. </if>
  6141. <if test="qcResultShortPageVO.endDate != null">
  6142. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6143. </if>
  6144. </if>
  6145. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  6146. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  6147. </if>
  6148. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  6149. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  6150. </if>
  6151. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  6152. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  6153. </if>
  6154. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6155. AND b.`level` = #{qcResultShortPageVO.level}
  6156. </if>
  6157. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6158. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6159. </if>
  6160. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  6161. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  6162. </if>
  6163. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6164. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6165. </if>
  6166. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  6167. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  6168. </if>
  6169. <if test="qcResultShortPageVO.casesEntryId != null ">
  6170. AND d.id = #{qcResultShortPageVO.casesEntryId}
  6171. </if>
  6172. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  6173. AND d.cases_name = #{qcResultShortPageVO.casesName}
  6174. </if>
  6175. <if test="qcResultShortPageVO.casesId != null">
  6176. AND d.cases_id = #{qcResultShortPageVO.casesId}
  6177. </if>
  6178. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6179. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  6180. </if>
  6181. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6182. AND a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6183. </if>
  6184. <if test="qcResultShortPageVO.isReject != null">
  6185. AND c.is_reject = #{qcResultShortPageVO.isReject}
  6186. </if>
  6187. <if test="qcResultShortPageVO.ruleType != null">
  6188. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  6189. </if>
  6190. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  6191. AND TIMESTAMPDIFF(
  6192. DAY,
  6193. DATE( a.behospital_date ),
  6194. DATE( a.leave_hospital_date ))> 30
  6195. </if>
  6196. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  6197. AND TIMESTAMPDIFF(
  6198. DAY,
  6199. DATE( a.behospital_date ),
  6200. DATE( a.leave_hospital_date ))> 31
  6201. </if>
  6202. )be
  6203. left join med_check_info mci
  6204. on mci.is_deleted = 'N'
  6205. and mci.check_type in(0,2)
  6206. and be.hospital_id = mci.hospital_id
  6207. and be.behospital_code = mci.behospital_code
  6208. left join med_check_info hm_mci
  6209. on hm_mci.is_deleted = 'N'
  6210. and hm_mci.check_type = 1
  6211. and be.hospital_id = hm_mci.hospital_id
  6212. and be.behospital_code = hm_mci.behospital_code
  6213. LEFT JOIN med_qcresult_cases e
  6214. on be.behospital_code = e.behospital_code
  6215. and be.hospital_id = e.hospital_id
  6216. AND e.is_deleted = 'N'
  6217. and e.cases_id = 243
  6218. )tt1
  6219. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  6220. ,med_medical_record tt2
  6221. WHERE
  6222. tt2.is_deleted = 'N'
  6223. AND tt1.hospital_id = tt2.hospital_id
  6224. AND tt1.behospital_code = tt2.behospital_code
  6225. AND tt2.mode_id = 30
  6226. </if>
  6227. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  6228. ,med_crisis_info tt2
  6229. WHERE
  6230. tt2.is_deleted = 'N'
  6231. AND tt1.hospital_id = tt2.hospital_id
  6232. AND tt1.behospital_code = tt2.behospital_code
  6233. </if>
  6234. ) t1
  6235. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  6236. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  6237. AND t1.behospital_code = t2.behospital_code
  6238. AND t2.is_deleted = 'N'
  6239. </if>
  6240. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  6241. , med_home_page t2
  6242. , med_home_operation_info t3
  6243. WHERE t1.hospital_id = t2.hospital_id
  6244. AND t1.behospital_code = t2.behospital_code
  6245. AND t2.home_page_id = t3.home_page_id
  6246. AND t2.is_deleted = 'N'
  6247. AND t3.is_deleted = 'N'
  6248. </if>
  6249. ) t
  6250. where 1=1
  6251. <if test="qcResultShortPageVO.checkStatus != null">
  6252. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6253. </if>
  6254. <if test="qcResultShortPageVO.mrStatus != null">
  6255. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6256. </if>
  6257. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6258. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6259. </if>
  6260. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6261. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6262. </if>
  6263. <if test="qcResultShortPageVO.chTimeStart != null ">
  6264. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6265. </if>
  6266. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6267. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6268. </if>
  6269. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6270. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6271. </if>
  6272. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6273. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6274. </if>
  6275. </select>
  6276. <update id="updateBatchByKey">
  6277. <foreach collection="list" item="item" separator=";">
  6278. update med_behospital_info
  6279. <set>
  6280. name = #{item.name},
  6281. sex = #{item.sex},
  6282. birthday = #{item.birthday},
  6283. file_code = #{item.fileCode},
  6284. ward_code = #{item.wardCode},
  6285. ward_name = #{item.wardName},
  6286. beh_dept_id = #{item.behDeptId},
  6287. beh_dept_name = #{item.behDeptName},
  6288. bed_code = #{item.bedCode},
  6289. bed_name = #{item.bedName},
  6290. insurance_name = #{item.insuranceName},
  6291. job_type = #{item.jobType},
  6292. behospital_date = #{item.behospitalDate},
  6293. leave_hospital_date = #{item.leaveHospitalDate},
  6294. diagnose_icd = #{item.diagnoseIcd},
  6295. diagnose = #{item.diagnose},
  6296. beh_doctor_id = #{item.behDoctorId},
  6297. beh_doctor_name = #{item.behDoctorName},
  6298. doctor_id = #{item.doctorId},
  6299. doctor_name = #{item.doctorName},
  6300. director_doctor_id = #{item.directorDoctorId},
  6301. director_doctor_name = #{item.directorDoctorName},
  6302. placefile_date = #{item.placefileDate},
  6303. is_placefile = #{item.isPlacefile},
  6304. <if test="item.gmtModified != null">
  6305. gmt_modified = #{item.gmtModified},
  6306. </if>
  6307. <if test="item.modifier != null">
  6308. modifier = #{item.modifier},
  6309. </if>
  6310. <if test="item.isDeleted != null">
  6311. is_deleted = #{item.isDeleted},
  6312. </if>
  6313. </set>
  6314. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  6315. </foreach>
  6316. </update>
  6317. <!-- 关键条目缺陷统计报表-->
  6318. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  6319. SELECT
  6320. deptId,
  6321. deptName,
  6322. consultationMRNum,
  6323. consultationNum,
  6324. 2511 AS consultationEntryId,
  6325. '普通会诊未在24小时内完成' AS consultationEntryName,
  6326. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6327. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6328. operationMRNum,
  6329. 2594 AS operationNameEntryId,
  6330. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6331. operationNameNum,
  6332. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6333. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6334. 2973 AS operationTimeEntryId,
  6335. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6336. operationTimeNum,
  6337. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6338. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6339. 2930 AS operation15MinuteEntryId,
  6340. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6341. operation15MinuteNum,
  6342. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6343. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6344. 2419 AS crisisEntryId,
  6345. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6346. crisisMRNum,
  6347. crisisNum,
  6348. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6349. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6350. 2495 AS stageSummaryEntryId,
  6351. '无阶段小结' AS stageSummaryEntryName,
  6352. stageSummaryMRNum,
  6353. stageSummaryNum,
  6354. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6355. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6356. beHosGT31DaysMRNum
  6357. FROM
  6358. (
  6359. SELECT
  6360. tt.deptId,
  6361. tt.deptName,
  6362. sum( tt.consultationNum ) AS consultationNum,
  6363. sum( tt.consultationMRNum ) AS consultationMRNum,
  6364. sum( tt.operationNameNum ) AS operationNameNum,
  6365. sum( tt.operationTimeNum ) AS operationTimeNum,
  6366. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6367. sum( tt.operationMRNum ) AS operationMRNum,
  6368. sum( tt.crisisNum ) AS crisisNum,
  6369. sum( tt.crisisMRNum ) AS crisisMRNum,
  6370. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6371. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6372. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6373. FROM
  6374. (
  6375. (
  6376. SELECT
  6377. c.beh_dept_id AS deptId,
  6378. c.beh_dept_name AS deptName,
  6379. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6380. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6381. 0 AS operationNameNum,
  6382. 0 AS operationTimeNum,
  6383. 0 AS operation15MinuteNum,
  6384. 0 AS operationMRNum,
  6385. 0 AS crisisNum,
  6386. 0 AS crisisMRNum,
  6387. 0 AS stageSummaryNum,
  6388. 0 AS stageSummaryMRNum,
  6389. 0 AS beHosGT31DaysMRNum
  6390. FROM
  6391. (
  6392. SELECT DISTINCT
  6393. a.hospital_id,
  6394. a.behospital_code,
  6395. a.beh_dept_name,
  6396. a.beh_dept_id
  6397. FROM
  6398. med_behospital_info a,
  6399. med_medical_record b
  6400. WHERE
  6401. a.is_deleted = 'N'
  6402. AND b.is_deleted = 'N'
  6403. AND a.hospital_id = b.hospital_id
  6404. AND a.behospital_code = b.behospital_code
  6405. AND b.mode_id = 30
  6406. <if test="isPlacefile != null and isPlacefile != ''">
  6407. and a.is_placefile = #{isPlacefile}
  6408. </if>
  6409. AND a.qc_type_id != 0
  6410. <if test="hospitalId != null and hospitalId != ''">
  6411. AND a.hospital_id = #{hospitalId}
  6412. </if>
  6413. <if test="isPlacefile != null and isPlacefile == 0">
  6414. <if test="startDate != null ">
  6415. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6416. </if>
  6417. <if test="endDate != null ">
  6418. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6419. </if>
  6420. </if>
  6421. <if test="isPlacefile != null and isPlacefile == 1">
  6422. <if test="startDate != null ">
  6423. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6424. </if>
  6425. <if test="endDate != null ">
  6426. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6427. </if>
  6428. </if>
  6429. <if test="deptName != null and deptName != ''">
  6430. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6431. </if>
  6432. ) c
  6433. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6434. AND c.hospital_id = d.hospital_id
  6435. AND c.behospital_code = d.behospital_code
  6436. GROUP BY
  6437. c.beh_dept_id,
  6438. c.beh_dept_name
  6439. ) UNION
  6440. (
  6441. SELECT
  6442. d.beh_dept_id AS deptId,
  6443. d.beh_dept_name AS deptName,
  6444. 0 AS consultationNum,
  6445. 0 AS consultationMRNum,
  6446. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6447. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6448. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6449. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6450. 0 AS crisisNum,
  6451. 0 AS crisisMRNum,
  6452. 0 AS stageSummaryNum,
  6453. 0 AS stageSummaryMRNum,
  6454. 0 AS beHosGT31DaysMRNum
  6455. FROM
  6456. (
  6457. SELECT DISTINCT
  6458. a.hospital_id,
  6459. a.behospital_code,
  6460. a.beh_dept_name,
  6461. a.beh_dept_id
  6462. FROM
  6463. med_behospital_info a,
  6464. med_home_page b,
  6465. med_home_operation_info c
  6466. WHERE
  6467. a.is_deleted = 'N'
  6468. AND b.is_deleted = 'N'
  6469. AND c.is_deleted = 'N'
  6470. AND a.hospital_id = b.hospital_id
  6471. AND a.hospital_id = c.hospital_id
  6472. AND a.behospital_code = b.behospital_code
  6473. AND b.home_page_id = c.home_page_id
  6474. <if test="isPlacefile != null and isPlacefile != ''">
  6475. and a.is_placefile = #{isPlacefile}
  6476. </if>
  6477. AND a.qc_type_id != 0
  6478. <if test="hospitalId != null and hospitalId != ''">
  6479. AND a.hospital_id = #{hospitalId}
  6480. </if>
  6481. <if test="isPlacefile != null and isPlacefile == 0">
  6482. <if test="startDate != null ">
  6483. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6484. </if>
  6485. <if test="endDate != null ">
  6486. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6487. </if>
  6488. </if>
  6489. <if test="isPlacefile != null and isPlacefile == 1">
  6490. <if test="startDate != null ">
  6491. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6492. </if>
  6493. <if test="endDate != null ">
  6494. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6495. </if>
  6496. </if>
  6497. <if test="deptName != null and deptName != ''">
  6498. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6499. </if>
  6500. ) d
  6501. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6502. AND d.hospital_id = e.hospital_id
  6503. AND d.behospital_code = e.behospital_code
  6504. GROUP BY
  6505. d.beh_dept_id,
  6506. d.beh_dept_name
  6507. ) UNION
  6508. (
  6509. SELECT
  6510. c.beh_dept_id AS deptId,
  6511. c.beh_dept_name AS deptName,
  6512. 0 AS consultationNum,
  6513. 0 AS consultationMRNum,
  6514. 0 AS operationNameNum,
  6515. 0 AS operationTimeNum,
  6516. 0 AS operation15MinuteNum,
  6517. 0 AS operationMRNum,
  6518. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6519. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6520. 0 AS stageSummaryNum,
  6521. 0 AS stageSummaryMRNum,
  6522. 0 AS beHosGT31DaysMRNum
  6523. FROM
  6524. (
  6525. SELECT DISTINCT
  6526. a.hospital_id,
  6527. a.behospital_code,
  6528. a.beh_dept_name,
  6529. a.beh_dept_id
  6530. FROM
  6531. med_behospital_info a,
  6532. med_crisis_info b
  6533. WHERE
  6534. a.is_deleted = 'N'
  6535. AND b.is_deleted = 'N'
  6536. AND a.hospital_id = b.hospital_id
  6537. AND a.behospital_code = b.behospital_code
  6538. <if test="isPlacefile != null and isPlacefile != ''">
  6539. and a.is_placefile = #{isPlacefile}
  6540. </if>
  6541. AND a.qc_type_id != 0
  6542. <if test="hospitalId != null and hospitalId != ''">
  6543. AND a.hospital_id = #{hospitalId}
  6544. </if>
  6545. <if test="isPlacefile != null and isPlacefile == 0">
  6546. <if test="startDate != null ">
  6547. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6548. </if>
  6549. <if test="endDate != null ">
  6550. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6551. </if>
  6552. </if>
  6553. <if test="isPlacefile != null and isPlacefile == 1">
  6554. <if test="startDate != null ">
  6555. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6556. </if>
  6557. <if test="endDate != null ">
  6558. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6559. </if>
  6560. </if>
  6561. <if test="deptName != null and deptName != ''">
  6562. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6563. </if>
  6564. ) c
  6565. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6566. AND c.hospital_id = d.hospital_id
  6567. AND c.behospital_code = d.behospital_code
  6568. GROUP BY
  6569. c.beh_dept_id,
  6570. c.beh_dept_name
  6571. ) UNION
  6572. (
  6573. SELECT
  6574. b.beh_dept_id AS deptId,
  6575. b.beh_dept_name AS deptName,
  6576. 0 AS consultationNum,
  6577. 0 AS consultationMRNum,
  6578. 0 AS operationNameNum,
  6579. 0 AS operationTimeNum,
  6580. 0 AS operation15MinuteNum,
  6581. 0 AS operationMRNum,
  6582. 0 AS crisisNum,
  6583. 0 AS crisisMRNum,
  6584. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6585. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6586. 0 AS beHosGT31DaysMRNum
  6587. FROM
  6588. (
  6589. SELECT DISTINCT
  6590. a.hospital_id,
  6591. a.behospital_code,
  6592. a.beh_dept_name,
  6593. a.beh_dept_id
  6594. FROM
  6595. med_behospital_info a
  6596. WHERE
  6597. a.is_deleted = 'N'
  6598. AND TIMESTAMPDIFF(
  6599. DAY,
  6600. DATE( behospital_date ),
  6601. DATE( leave_hospital_date ))> 30
  6602. <if test="isPlacefile != null and isPlacefile != ''">
  6603. and a.is_placefile = #{isPlacefile}
  6604. </if>
  6605. AND a.qc_type_id != 0
  6606. <if test="hospitalId != null and hospitalId != ''">
  6607. AND a.hospital_id = #{hospitalId}
  6608. </if>
  6609. <if test="isPlacefile != null and isPlacefile == 0">
  6610. <if test="startDate != null ">
  6611. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6612. </if>
  6613. <if test="endDate != null ">
  6614. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6615. </if>
  6616. </if>
  6617. <if test="isPlacefile != null and isPlacefile == 1">
  6618. <if test="startDate != null ">
  6619. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6620. </if>
  6621. <if test="endDate != null ">
  6622. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6623. </if>
  6624. </if>
  6625. <if test="deptName != null and deptName != ''">
  6626. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6627. </if>
  6628. ) b
  6629. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6630. AND b.hospital_id = c.hospital_id
  6631. AND b.behospital_code = c.behospital_code
  6632. GROUP BY
  6633. b.beh_dept_id,
  6634. b.beh_dept_name
  6635. ) UNION
  6636. (
  6637. SELECT
  6638. b.beh_dept_id AS deptId,
  6639. b.beh_dept_name AS deptName,
  6640. 0 AS consultationNum,
  6641. 0 AS consultationMRNum,
  6642. 0 AS operationNameNum,
  6643. 0 AS operationTimeNum,
  6644. 0 AS operation15MinuteNum,
  6645. 0 AS operationMRNum,
  6646. 0 AS crisisNum,
  6647. 0 AS crisisMRNum,
  6648. 0 AS stageSummaryNum,
  6649. 0 AS stageSummaryMRNum,
  6650. count(*) AS beHosGT31DaysMRNum
  6651. FROM
  6652. (
  6653. SELECT DISTINCT
  6654. a.hospital_id,
  6655. a.behospital_code,
  6656. a.beh_dept_name,
  6657. a.beh_dept_id
  6658. FROM
  6659. med_behospital_info a,
  6660. med_qcresult_info b,
  6661. med_qcresult_detail c,
  6662. qc_cases_entry d
  6663. WHERE
  6664. a.is_deleted = 'N'
  6665. AND b.is_deleted = 'N'
  6666. AND c.is_deleted = 'N'
  6667. AND d.is_deleted = 'N'
  6668. AND a.hospital_id = b.hospital_id
  6669. AND a.hospital_id = c.hospital_id
  6670. AND a.behospital_code = b.behospital_code
  6671. AND a.behospital_code = c.behospital_code
  6672. AND c.cases_id = d.cases_id
  6673. AND c.cases_entry_id = d.id
  6674. AND TIMESTAMPDIFF(
  6675. DAY,
  6676. DATE( behospital_date ),
  6677. DATE( leave_hospital_date ))> 31
  6678. <if test="isPlacefile != null and isPlacefile != ''">
  6679. and a.is_placefile = #{isPlacefile}
  6680. </if>
  6681. AND a.qc_type_id != 0
  6682. <if test="hospitalId != null and hospitalId != ''">
  6683. AND a.hospital_id = #{hospitalId}
  6684. </if>
  6685. <if test="isPlacefile != null and isPlacefile == 0">
  6686. <if test="startDate != null ">
  6687. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6688. </if>
  6689. <if test="endDate != null ">
  6690. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6691. </if>
  6692. </if>
  6693. <if test="isPlacefile != null and isPlacefile == 1">
  6694. <if test="startDate != null ">
  6695. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6696. </if>
  6697. <if test="endDate != null ">
  6698. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6699. </if>
  6700. </if>
  6701. <if test="deptName != null and deptName != ''">
  6702. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6703. </if>
  6704. ) b
  6705. GROUP BY
  6706. b.beh_dept_id,
  6707. b.beh_dept_name
  6708. )
  6709. ) tt
  6710. GROUP BY
  6711. tt.deptId,
  6712. tt.deptName
  6713. ) t
  6714. <if test="asc != null and asc !=''">
  6715. order by
  6716. <choose>
  6717. <when test='asc=="deptId"'>deptId asc</when>
  6718. <when test='asc=="deptName"'>deptName asc</when>
  6719. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6720. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6721. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6722. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6723. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6724. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6725. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6726. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6727. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6728. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6729. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6730. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6731. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6732. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6733. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6734. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6735. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6736. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6737. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6738. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6739. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6740. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6741. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6742. <otherwise>deptName asc</otherwise>
  6743. </choose>
  6744. </if>
  6745. <if test="desc != null and desc!=''">
  6746. order by
  6747. <choose>
  6748. <when test='desc=="deptId"'>deptId desc</when>
  6749. <when test='desc=="deptName"'>deptName desc</when>
  6750. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6751. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6752. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6753. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6754. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6755. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6756. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6757. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6758. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6759. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6760. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6761. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6762. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6763. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6764. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6765. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6766. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6767. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6768. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6769. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6770. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6771. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6772. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6773. <otherwise>deptName desc</otherwise>
  6774. </choose>
  6775. </if>
  6776. </select>
  6777. <!-- 关键条目缺陷统计报表-科室-->
  6778. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6779. SELECT
  6780. deptId,
  6781. deptName,
  6782. doctorName,
  6783. consultationMRNum,
  6784. consultationNum,
  6785. 2511 AS consultationEntryId,
  6786. '普通会诊未在24小时内完成' AS consultationEntryName,
  6787. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6788. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6789. operationMRNum,
  6790. 2594 AS operationNameEntryId,
  6791. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6792. operationNameNum,
  6793. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6794. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6795. 2973 AS operationTimeEntryId,
  6796. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6797. operationTimeNum,
  6798. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6799. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6800. 2930 AS operation15MinuteEntryId,
  6801. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6802. operation15MinuteNum,
  6803. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6804. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6805. 2419 AS crisisEntryId,
  6806. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6807. crisisMRNum,
  6808. crisisNum,
  6809. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6810. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6811. 2495 AS stageSummaryEntryId,
  6812. '无阶段小结' AS stageSummaryEntryName,
  6813. stageSummaryMRNum,
  6814. stageSummaryNum,
  6815. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6816. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6817. beHosGT31DaysMRNum
  6818. FROM
  6819. (
  6820. SELECT
  6821. tt.deptId,
  6822. tt.deptName,
  6823. tt.doctorId,
  6824. tt.doctorName,
  6825. sum( tt.consultationNum ) AS consultationNum,
  6826. sum( tt.consultationMRNum ) AS consultationMRNum,
  6827. sum( tt.operationNameNum ) AS operationNameNum,
  6828. sum( tt.operationTimeNum ) AS operationTimeNum,
  6829. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6830. sum( tt.operationMRNum ) AS operationMRNum,
  6831. sum( tt.crisisNum ) AS crisisNum,
  6832. sum( tt.crisisMRNum ) AS crisisMRNum,
  6833. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6834. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6835. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6836. FROM
  6837. (
  6838. (
  6839. SELECT
  6840. c.beh_dept_id AS deptId,
  6841. c.beh_dept_name AS deptName,
  6842. c.doctorId,
  6843. c.doctorName,
  6844. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6845. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6846. 0 AS operationNameNum,
  6847. 0 AS operationTimeNum,
  6848. 0 AS operation15MinuteNum,
  6849. 0 AS operationMRNum,
  6850. 0 AS crisisNum,
  6851. 0 AS crisisMRNum,
  6852. 0 AS stageSummaryNum,
  6853. 0 AS stageSummaryMRNum,
  6854. 0 AS beHosGT31DaysMRNum
  6855. FROM
  6856. (
  6857. SELECT DISTINCT
  6858. a.hospital_id,
  6859. a.behospital_code,
  6860. a.beh_dept_name,
  6861. a.beh_dept_id,
  6862. a.doctor_id as doctorId,
  6863. a.doctor_name as doctorName
  6864. FROM
  6865. med_behospital_info a,
  6866. med_medical_record b,
  6867. sys_user_dept c
  6868. WHERE
  6869. a.is_deleted = 'N'
  6870. AND b.is_deleted = 'N'
  6871. AND c.is_deleted = 'N'
  6872. AND a.hospital_id = b.hospital_id
  6873. AND a.hospital_id = c.hospital_id
  6874. AND a.behospital_code = b.behospital_code
  6875. AND a.beh_dept_id = c.dept_id
  6876. AND b.mode_id = 30
  6877. <if test="userId!=null">
  6878. AND c.user_id = #{userId}
  6879. </if>
  6880. <if test="isPlacefile != null and isPlacefile != ''">
  6881. and a.is_placefile = #{isPlacefile}
  6882. </if>
  6883. AND a.qc_type_id != 0
  6884. <if test="hospitalId != null and hospitalId != ''">
  6885. AND a.hospital_id = #{hospitalId}
  6886. </if>
  6887. <if test="isPlacefile != null and isPlacefile == 0">
  6888. <if test="startDate != null ">
  6889. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6890. </if>
  6891. <if test="endDate != null ">
  6892. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6893. </if>
  6894. </if>
  6895. <if test="isPlacefile != null and isPlacefile == 1">
  6896. <if test="startDate != null ">
  6897. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6898. </if>
  6899. <if test="endDate != null ">
  6900. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6901. </if>
  6902. </if>
  6903. <if test="doctorName != null and doctorName != ''">
  6904. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6905. </if>
  6906. <if test="deptName != null and deptName != ''">
  6907. AND a.beh_dept_name = #{deptName}
  6908. </if>
  6909. ) c
  6910. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6911. AND c.hospital_id = d.hospital_id
  6912. AND c.behospital_code = d.behospital_code
  6913. GROUP BY
  6914. c.doctorId,
  6915. c.doctorName
  6916. ) UNION
  6917. (
  6918. SELECT
  6919. d.beh_dept_id AS deptId,
  6920. d.beh_dept_name AS deptName,
  6921. d.doctor_id as doctorId,
  6922. d.doctor_name as doctorName,
  6923. 0 AS consultationNum,
  6924. 0 AS consultationMRNum,
  6925. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6926. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6927. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6928. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6929. 0 AS crisisNum,
  6930. 0 AS crisisMRNum,
  6931. 0 AS stageSummaryNum,
  6932. 0 AS stageSummaryMRNum,
  6933. 0 AS beHosGT31DaysMRNum
  6934. FROM
  6935. (
  6936. SELECT DISTINCT
  6937. a.hospital_id,
  6938. a.behospital_code,
  6939. a.beh_dept_name,
  6940. a.beh_dept_id,
  6941. a.doctor_id,
  6942. a.doctor_name
  6943. FROM
  6944. med_behospital_info a,
  6945. med_home_page b,
  6946. med_home_operation_info c,
  6947. sys_user_dept d
  6948. WHERE
  6949. a.is_deleted = 'N'
  6950. AND b.is_deleted = 'N'
  6951. AND c.is_deleted = 'N'
  6952. AND d.is_deleted = 'N'
  6953. AND a.hospital_id = b.hospital_id
  6954. AND a.hospital_id = c.hospital_id
  6955. AND a.hospital_id = d.hospital_id
  6956. AND a.behospital_code = b.behospital_code
  6957. AND b.home_page_id = c.home_page_id
  6958. AND a.beh_dept_id = d.dept_id
  6959. <if test="userId!=null">
  6960. AND d.user_id = #{userId}
  6961. </if>
  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 ">
  6971. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6972. </if>
  6973. <if test="endDate != null ">
  6974. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6975. </if>
  6976. </if>
  6977. <if test="isPlacefile != null and isPlacefile == 1">
  6978. <if test="startDate != null ">
  6979. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6980. </if>
  6981. <if test="endDate != null ">
  6982. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6983. </if>
  6984. </if>
  6985. <if test="doctorName != null and doctorName != ''">
  6986. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6987. </if>
  6988. <if test="deptName != null and deptName != ''">
  6989. AND a.beh_dept_name = #{deptName}
  6990. </if>
  6991. ) d
  6992. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6993. AND d.hospital_id = e.hospital_id
  6994. AND d.behospital_code = e.behospital_code
  6995. GROUP BY
  6996. d.doctor_id,
  6997. d.doctor_name
  6998. ) UNION
  6999. (
  7000. SELECT
  7001. c.beh_dept_id AS deptId,
  7002. c.beh_dept_name AS deptName,
  7003. c.doctor_id as doctorId,
  7004. c.doctor_name as doctorName,
  7005. 0 AS consultationNum,
  7006. 0 AS consultationMRNum,
  7007. 0 AS operationNameNum,
  7008. 0 AS operationTimeNum,
  7009. 0 AS operation15MinuteNum,
  7010. 0 AS operationMRNum,
  7011. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  7012. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  7013. 0 AS stageSummaryNum,
  7014. 0 AS stageSummaryMRNum,
  7015. 0 AS beHosGT31DaysMRNum
  7016. FROM
  7017. (
  7018. SELECT DISTINCT
  7019. a.hospital_id,
  7020. a.behospital_code,
  7021. a.beh_dept_name,
  7022. a.beh_dept_id,
  7023. a.doctor_id,
  7024. a.doctor_name
  7025. FROM
  7026. med_behospital_info a,
  7027. med_crisis_info b,
  7028. sys_user_dept c
  7029. WHERE
  7030. a.is_deleted = 'N'
  7031. AND b.is_deleted = 'N'
  7032. AND c.is_deleted = 'N'
  7033. AND a.hospital_id = b.hospital_id
  7034. AND a.hospital_id = c.hospital_id
  7035. AND a.behospital_code = b.behospital_code
  7036. AND a.beh_dept_id = c.dept_id
  7037. <if test="userId!=null">
  7038. AND c.user_id = #{userId}
  7039. </if>
  7040. <if test="isPlacefile != null and isPlacefile != ''">
  7041. and a.is_placefile = #{isPlacefile}
  7042. </if>
  7043. AND a.qc_type_id != 0
  7044. <if test="hospitalId != null and hospitalId != ''">
  7045. AND a.hospital_id = #{hospitalId}
  7046. </if>
  7047. <if test="isPlacefile != null and isPlacefile == 0">
  7048. <if test="startDate != null ">
  7049. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7050. </if>
  7051. <if test="endDate != null ">
  7052. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7053. </if>
  7054. </if>
  7055. <if test="isPlacefile != null and isPlacefile == 1">
  7056. <if test="startDate != null ">
  7057. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7058. </if>
  7059. <if test="endDate != null ">
  7060. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7061. </if>
  7062. </if>
  7063. <if test="doctorName != null and doctorName != ''">
  7064. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  7065. </if>
  7066. <if test="deptName != null and deptName != ''">
  7067. AND a.beh_dept_name = #{deptName}
  7068. </if>
  7069. ) c
  7070. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  7071. AND c.hospital_id = d.hospital_id
  7072. AND c.behospital_code = d.behospital_code
  7073. GROUP BY
  7074. c.doctor_id,
  7075. c.doctor_name
  7076. ) UNION
  7077. (
  7078. SELECT
  7079. b.beh_dept_id AS deptId,
  7080. b.beh_dept_name AS deptName,
  7081. b.doctor_id as doctorId,
  7082. b.doctor_name as doctorName,
  7083. 0 AS consultationNum,
  7084. 0 AS consultationMRNum,
  7085. 0 AS operationNameNum,
  7086. 0 AS operationTimeNum,
  7087. 0 AS operation15MinuteNum,
  7088. 0 AS operationMRNum,
  7089. 0 AS crisisNum,
  7090. 0 AS crisisMRNum,
  7091. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  7092. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  7093. 0 AS beHosGT31DaysMRNum
  7094. FROM
  7095. (
  7096. SELECT DISTINCT
  7097. a.hospital_id,
  7098. a.behospital_code,
  7099. a.beh_dept_name,
  7100. a.beh_dept_id,
  7101. a.doctor_id,
  7102. a.doctor_name
  7103. FROM
  7104. med_behospital_info a,
  7105. sys_user_dept b
  7106. WHERE
  7107. a.is_deleted = 'N'
  7108. AND b.is_deleted = 'N'
  7109. AND a.hospital_id = b.hospital_id
  7110. AND a.beh_dept_id = b.dept_id
  7111. AND TIMESTAMPDIFF(
  7112. DAY,
  7113. DATE( behospital_date ),
  7114. DATE( leave_hospital_date ))> 30
  7115. <if test="userId!=null">
  7116. AND b.user_id = #{userId}
  7117. </if>
  7118. <if test="isPlacefile != null and isPlacefile != ''">
  7119. and a.is_placefile = #{isPlacefile}
  7120. </if>
  7121. AND a.qc_type_id != 0
  7122. <if test="hospitalId != null and hospitalId != ''">
  7123. AND a.hospital_id = #{hospitalId}
  7124. </if>
  7125. <if test="isPlacefile != null and isPlacefile == 0">
  7126. <if test="startDate != null ">
  7127. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7128. </if>
  7129. <if test="endDate != null ">
  7130. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7131. </if>
  7132. </if>
  7133. <if test="isPlacefile != null and isPlacefile == 1">
  7134. <if test="startDate != null ">
  7135. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7136. </if>
  7137. <if test="endDate != null ">
  7138. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7139. </if>
  7140. </if>
  7141. <if test="doctorName != null and doctorName != ''">
  7142. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  7143. </if>
  7144. <if test="deptName != null and deptName != ''">
  7145. AND a.beh_dept_name = #{deptName}
  7146. </if>
  7147. ) b
  7148. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  7149. AND b.hospital_id = c.hospital_id
  7150. AND b.behospital_code = c.behospital_code
  7151. GROUP BY
  7152. b.doctor_id,
  7153. b.doctor_name
  7154. ) UNION
  7155. (
  7156. SELECT
  7157. b.beh_dept_id AS deptId,
  7158. b.beh_dept_name AS deptName,
  7159. b.doctor_id as doctorId,
  7160. b.doctor_name as doctorName,
  7161. 0 AS consultationNum,
  7162. 0 AS consultationMRNum,
  7163. 0 AS operationNameNum,
  7164. 0 AS operationTimeNum,
  7165. 0 AS operation15MinuteNum,
  7166. 0 AS operationMRNum,
  7167. 0 AS crisisNum,
  7168. 0 AS crisisMRNum,
  7169. 0 AS stageSummaryNum,
  7170. 0 AS stageSummaryMRNum,
  7171. count(*) AS beHosGT31DaysMRNum
  7172. FROM
  7173. (
  7174. SELECT DISTINCT
  7175. a.hospital_id,
  7176. a.behospital_code,
  7177. a.beh_dept_name,
  7178. a.beh_dept_id,
  7179. a.doctor_id,
  7180. a.doctor_name
  7181. FROM
  7182. med_behospital_info a,
  7183. med_qcresult_info b,
  7184. med_qcresult_detail c,
  7185. qc_cases_entry d,
  7186. sys_user_dept e
  7187. WHERE
  7188. a.is_deleted = 'N'
  7189. AND b.is_deleted = 'N'
  7190. AND c.is_deleted = 'N'
  7191. AND d.is_deleted = 'N'
  7192. AND e.is_deleted = 'N'
  7193. AND a.hospital_id = b.hospital_id
  7194. AND a.hospital_id = c.hospital_id
  7195. AND a.hospital_id = e.hospital_id
  7196. AND a.behospital_code = b.behospital_code
  7197. AND a.behospital_code = c.behospital_code
  7198. AND c.cases_id = d.cases_id
  7199. AND c.cases_entry_id = d.id
  7200. AND a.beh_dept_id = e.dept_id
  7201. AND TIMESTAMPDIFF(
  7202. DAY,
  7203. DATE( behospital_date ),
  7204. DATE( leave_hospital_date ))> 31
  7205. <if test="userId!=null">
  7206. AND e.user_id = #{userId}
  7207. </if>
  7208. <if test="isPlacefile != null and isPlacefile != ''">
  7209. and a.is_placefile = #{isPlacefile}
  7210. </if>
  7211. AND a.qc_type_id != 0
  7212. <if test="hospitalId != null and hospitalId != ''">
  7213. AND a.hospital_id = #{hospitalId}
  7214. </if>
  7215. <if test="isPlacefile != null and isPlacefile == 0">
  7216. <if test="startDate != null ">
  7217. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7218. </if>
  7219. <if test="endDate != null ">
  7220. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7221. </if>
  7222. </if>
  7223. <if test="isPlacefile != null and isPlacefile == 1">
  7224. <if test="startDate != null ">
  7225. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7226. </if>
  7227. <if test="endDate != null ">
  7228. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7229. </if>
  7230. </if>
  7231. <if test="doctorName != null and doctorName != ''">
  7232. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  7233. </if>
  7234. <if test="deptName != null and deptName != ''">
  7235. AND a.beh_dept_name = #{deptName}
  7236. </if>
  7237. ) b
  7238. GROUP BY
  7239. b.doctor_id,
  7240. b.doctor_name
  7241. )
  7242. ) tt
  7243. GROUP BY
  7244. tt.doctorName
  7245. ) t
  7246. <if test="asc != null and asc !=''">
  7247. order by
  7248. <choose>
  7249. <when test='asc=="deptId"'>deptId asc</when>
  7250. <when test='asc=="deptName"'>deptName asc</when>
  7251. <when test='asc=="doctorName"'>doctorName asc</when>
  7252. <when test='asc=="consultationNum"'>consultationNum asc</when>
  7253. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  7254. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  7255. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  7256. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  7257. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  7258. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  7259. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  7260. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  7261. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  7262. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  7263. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  7264. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  7265. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  7266. <when test='asc=="crisisNum"'>crisisNum asc</when>
  7267. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  7268. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  7269. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  7270. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  7271. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  7272. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  7273. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  7274. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  7275. <otherwise>doctorName asc</otherwise>
  7276. </choose>
  7277. </if>
  7278. <if test="desc != null and desc!=''">
  7279. order by
  7280. <choose>
  7281. <when test='desc=="deptId"'>deptId desc</when>
  7282. <when test='desc=="doctorName"'>doctorName desc</when>
  7283. <when test='desc=="deptName"'>deptName desc</when>
  7284. <when test='desc=="consultationNum"'>consultationNum desc</when>
  7285. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  7286. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  7287. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  7288. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  7289. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  7290. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  7291. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  7292. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  7293. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  7294. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  7295. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  7296. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  7297. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  7298. <when test='desc=="crisisNum"'>crisisNum desc</when>
  7299. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  7300. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  7301. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  7302. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  7303. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  7304. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  7305. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  7306. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  7307. <otherwise>doctorName desc</otherwise>
  7308. </choose>
  7309. </if>
  7310. </select>
  7311. <!-- 非医嘱离院病人记录-->
  7312. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  7313. SELECT
  7314. count(*)
  7315. FROM
  7316. med_behospital_info a,
  7317. med_home_page b
  7318. WHERE
  7319. a.is_deleted = 'N'
  7320. AND b.is_deleted = 'N'
  7321. AND a.hospital_id = b.hospital_id
  7322. AND a.behospital_code = b.behospital_code
  7323. AND b.leave_hospital_type = '非医嘱离院'
  7324. <if test="isPlacefile != null and isPlacefile != ''">
  7325. and a.is_placefile = #{isPlacefile}
  7326. </if>
  7327. AND a.qc_type_id != 0
  7328. <if test="hospitalId != null and hospitalId != ''">
  7329. AND a.hospital_id = #{hospitalId}
  7330. </if>
  7331. <if test="isPlacefile != null and isPlacefile == 0">
  7332. <if test="startDate != null and startDate != ''">
  7333. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7334. </if>
  7335. <if test="endDate != null and endDate != ''">
  7336. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7337. </if>
  7338. </if>
  7339. <if test="isPlacefile != null and isPlacefile == 1">
  7340. <if test="startDate != null and startDate != ''">
  7341. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7342. </if>
  7343. <if test="endDate != null and endDate != ''">
  7344. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7345. </if>
  7346. </if>
  7347. </select>
  7348. <!-- 31天内再入院记录-->
  7349. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  7350. SELECT
  7351. count(*)
  7352. FROM
  7353. (
  7354. SELECT
  7355. r1.file_code,
  7356. r1.diagnose,
  7357. r1.behospital_code AS behospitalCode,
  7358. r1.behospital_date AS behospitalDate,
  7359. r1.leave_hospital_date AS leaveHospitalDate,
  7360. r2.behospital_code AS lastBehospitalCode,
  7361. r2.behospital_date AS lastBehospitalDate,
  7362. r2.leave_hospital_date AS lastLeaveHospitalDate,
  7363. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  7364. FROM
  7365. (
  7366. SELECT
  7367. ( @rownum := @rownum + 1 ) AS rownum,
  7368. t1.file_code,
  7369. t1.diagnose,
  7370. t1.behospital_code,
  7371. t1.behospital_date,
  7372. t1.leave_hospital_date
  7373. FROM
  7374. (
  7375. SELECT
  7376. tt1.file_code,
  7377. tt1.diagnose,
  7378. tt2.behospital_code,
  7379. tt2.behospital_date,
  7380. tt2.leave_hospital_date
  7381. FROM
  7382. (
  7383. SELECT
  7384. a.file_code,
  7385. a.diagnose
  7386. FROM
  7387. med_behospital_info a
  7388. WHERE
  7389. a.is_deleted = 'N'
  7390. <if test="isPlacefile != null and isPlacefile != ''">
  7391. and a.is_placefile = #{isPlacefile}
  7392. </if>
  7393. AND a.qc_type_id != 0
  7394. AND IFNULL( a.diagnose, '' )!= ''
  7395. AND IFNULL( a.file_code, '' )!= ''
  7396. <if test="hospitalId != null and hospitalId != ''">
  7397. AND a.hospital_id = #{hospitalId}
  7398. </if>
  7399. <if test="isPlacefile != null and isPlacefile == 0">
  7400. <if test="startDate != null and startDate != ''">
  7401. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7402. </if>
  7403. <if test="endDate != null and endDate != ''">
  7404. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7405. </if>
  7406. </if>
  7407. <if test="isPlacefile != null and isPlacefile == 1">
  7408. <if test="startDate != null and startDate != ''">
  7409. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7410. </if>
  7411. <if test="endDate != null and endDate != ''">
  7412. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7413. </if>
  7414. </if>
  7415. GROUP BY
  7416. a.file_code,
  7417. a.diagnose
  7418. HAVING
  7419. count(*)> 1
  7420. ) tt1,
  7421. med_behospital_info tt2
  7422. WHERE
  7423. tt2.is_deleted = 'N'
  7424. <if test="isPlacefile != null and isPlacefile != ''">
  7425. and tt2.is_placefile = #{isPlacefile}
  7426. </if>
  7427. AND tt2.qc_type_id != 0
  7428. AND tt1.file_code = tt2.file_code
  7429. AND tt1.diagnose = tt2.diagnose
  7430. <if test="hospitalId != null and hospitalId != ''">
  7431. AND tt2.hospital_id = #{hospitalId}
  7432. </if>
  7433. <if test="isPlacefile != null and isPlacefile == 0">
  7434. <if test="startDate != null and startDate != ''">
  7435. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7436. </if>
  7437. <if test="endDate != null and endDate != ''">
  7438. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7439. </if>
  7440. </if>
  7441. <if test="isPlacefile != null and isPlacefile == 1">
  7442. <if test="startDate != null and startDate != ''">
  7443. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7444. </if>
  7445. <if test="endDate != null and endDate != ''">
  7446. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7447. </if>
  7448. </if>
  7449. ORDER BY
  7450. tt1.file_code,
  7451. tt1.diagnose,
  7452. tt2.behospital_date DESC
  7453. ) t1,
  7454. ( SELECT @rownum := 0 ) r
  7455. ) r1
  7456. LEFT JOIN (
  7457. SELECT
  7458. ( @INDEX := @INDEX + 1 ) AS rownum,
  7459. t2.file_code,
  7460. t2.diagnose,
  7461. t2.behospital_code,
  7462. t2.behospital_date,
  7463. t2.leave_hospital_date
  7464. FROM
  7465. (
  7466. SELECT
  7467. tt1.file_code,
  7468. tt1.diagnose,
  7469. tt2.behospital_code,
  7470. tt2.behospital_date,
  7471. tt2.leave_hospital_date
  7472. FROM
  7473. (
  7474. SELECT
  7475. a.file_code,
  7476. a.diagnose
  7477. FROM
  7478. med_behospital_info a
  7479. WHERE
  7480. a.is_deleted = 'N'
  7481. <if test="isPlacefile != null and isPlacefile != ''">
  7482. and a.is_placefile = #{isPlacefile}
  7483. </if>
  7484. AND a.qc_type_id != 0
  7485. AND IFNULL( a.diagnose, '' )!= ''
  7486. AND IFNULL( a.file_code, '' )!= ''
  7487. <if test="hospitalId != null and hospitalId != ''">
  7488. AND a.hospital_id = #{hospitalId}
  7489. </if>
  7490. <if test="isPlacefile != null and isPlacefile == 0">
  7491. <if test="startDate != null and startDate != ''">
  7492. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7493. </if>
  7494. <if test="endDate != null and endDate != ''">
  7495. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7496. </if>
  7497. </if>
  7498. <if test="isPlacefile != null and isPlacefile == 1">
  7499. <if test="startDate != null and startDate != ''">
  7500. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7501. </if>
  7502. <if test="endDate != null and endDate != ''">
  7503. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7504. </if>
  7505. </if>
  7506. GROUP BY
  7507. a.file_code,
  7508. a.diagnose
  7509. HAVING
  7510. count(*)> 1
  7511. ) tt1,
  7512. med_behospital_info tt2
  7513. WHERE
  7514. tt2.is_deleted = 'N'
  7515. <if test="isPlacefile != null and isPlacefile != ''">
  7516. and tt2.is_placefile = #{isPlacefile}
  7517. </if>
  7518. AND tt2.qc_type_id != 0
  7519. AND tt1.file_code = tt2.file_code
  7520. AND tt1.diagnose = tt2.diagnose
  7521. <if test="hospitalId != null and hospitalId != ''">
  7522. AND tt2.hospital_id = #{hospitalId}
  7523. </if>
  7524. <if test="isPlacefile != null and isPlacefile == 0">
  7525. <if test="startDate != null and startDate != ''">
  7526. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7527. </if>
  7528. <if test="endDate != null and endDate != ''">
  7529. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7530. </if>
  7531. </if>
  7532. <if test="isPlacefile != null and isPlacefile == 1">
  7533. <if test="startDate != null and startDate != ''">
  7534. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7535. </if>
  7536. <if test="endDate != null and endDate != ''">
  7537. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7538. </if>
  7539. </if>
  7540. ORDER BY
  7541. tt1.file_code,
  7542. tt1.diagnose,
  7543. tt2.behospital_date DESC
  7544. ) t2,(
  7545. SELECT
  7546. @INDEX := 0
  7547. ) r
  7548. ) r2 ON r1.file_code = r2.file_code
  7549. AND r1.rownum = r2.rownum - 1
  7550. ) t
  7551. WHERE
  7552. t.diffDays IS NOT NULL
  7553. AND t.diffDays BETWEEN 0
  7554. AND 31
  7555. </select>
  7556. <!-- 病案首页质控病历数统计-全院(首页)-->
  7557. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  7558. SELECT
  7559. count( * ) AS mrNum,
  7560. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  7561. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  7562. SUM( c.`level` = '合格' ) AS firstLevelNum,
  7563. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  7564. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  7565. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  7566. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  7567. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  7568. FROM
  7569. med_behospital_info a,
  7570. med_qcresult_cases c
  7571. WHERE
  7572. a.is_deleted = 'N'
  7573. AND c.is_deleted = 'N'
  7574. AND a.hospital_id = c.hospital_id
  7575. AND a.behospital_code = c.behospital_code
  7576. AND c.cases_id = 243
  7577. <if test="isPlacefile != null and isPlacefile != ''">
  7578. and a.is_placefile = #{isPlacefile}
  7579. </if>
  7580. AND a.qc_type_id != 0
  7581. <if test="hospitalId != null and hospitalId != ''">
  7582. AND a.hospital_id = #{hospitalId}
  7583. </if>
  7584. <if test="isPlacefile != null and isPlacefile == 0">
  7585. <if test="startDate != null and startDate != ''">
  7586. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7587. </if>
  7588. <if test="endDate != null and endDate != ''">
  7589. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7590. </if>
  7591. </if>
  7592. <if test="isPlacefile != null and isPlacefile == 1">
  7593. <if test="startDate != null and startDate != ''">
  7594. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7595. </if>
  7596. <if test="endDate != null and endDate != ''">
  7597. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7598. </if>
  7599. </if>
  7600. </select>
  7601. <!-- 病案首页完整率统计-全院(首页)-->
  7602. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  7603. SELECT
  7604. h1.emptyNum,
  7605. h1.mrNum,
  7606. h2.entryNum,
  7607. h1.mrNum * h2.entryNum AS entryTotleNum,
  7608. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  7609. CONCAT(
  7610. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  7611. '%'
  7612. ) AS emptyPercentStr
  7613. FROM
  7614. (
  7615. SELECT
  7616. sum( d.rule_type = 1 ) AS emptyNum,
  7617. count( DISTINCT a.behospital_code ) AS mrNum
  7618. FROM
  7619. med_behospital_info a,
  7620. med_qcresult_cases b,
  7621. med_qcresult_detail c,
  7622. qc_cases_entry d
  7623. WHERE
  7624. a.is_deleted = 'N'
  7625. AND b.is_deleted = 'N'
  7626. AND c.is_deleted = 'N'
  7627. AND d.is_deleted = 'N'
  7628. AND a.hospital_id = b.hospital_id
  7629. AND a.hospital_id = c.hospital_id
  7630. AND a.behospital_code = b.behospital_code
  7631. AND a.behospital_code = c.behospital_code
  7632. AND b.cases_id = c.cases_id
  7633. AND c.cases_id = d.cases_id
  7634. AND c.cases_entry_id = d.id
  7635. <if test="isPlacefile != null and isPlacefile != ''">
  7636. and a.is_placefile = #{isPlacefile}
  7637. </if>
  7638. AND d.cases_id = 243
  7639. AND a.qc_type_id != 0
  7640. <if test="hospitalId != null and hospitalId != ''">
  7641. AND a.hospital_id = #{hospitalId}
  7642. </if>
  7643. <if test="isPlacefile != null and isPlacefile == 0">
  7644. <if test="startDate != null and startDate != ''">
  7645. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7646. </if>
  7647. <if test="endDate != null and endDate != ''">
  7648. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7649. </if>
  7650. </if>
  7651. <if test="isPlacefile != null and isPlacefile == 1">
  7652. <if test="startDate != null and startDate != ''">
  7653. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7654. </if>
  7655. <if test="endDate != null and endDate != ''">
  7656. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7657. </if>
  7658. </if>
  7659. ) h1,(
  7660. SELECT
  7661. count(*) AS entryNum
  7662. FROM
  7663. qc_cases_entry
  7664. WHERE
  7665. is_deleted = 'N'
  7666. AND cases_id = 243
  7667. ) h2
  7668. </select>
  7669. <!-- 离院病人评分详情页-->
  7670. <select id="getAge" resultType="java.util.Map">
  7671. SELECT
  7672. a.behospital_code as behospitalCode,
  7673. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  7674. FROM
  7675. med_home_page a
  7676. WHERE
  7677. a.is_deleted = 'N'
  7678. AND a.hospital_id = #{hospitalId}
  7679. AND a.behospital_code IN
  7680. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  7681. '${item}'
  7682. </foreach>
  7683. </select>
  7684. <!-- 离院病人评分详情页-->
  7685. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7686. SELECT
  7687. t.*
  7688. FROM
  7689. (SELECT DISTINCT
  7690. t1.hospital_id AS hospitalId,
  7691. t1.behospital_code AS behospitalCode,
  7692. t1.bed_code AS bedCode,
  7693. t1.LEVEL AS LEVEL,
  7694. t1.grade_type AS gradeType,
  7695. t1.score_res AS scoreRes,
  7696. t1.scoreBn,
  7697. t1.NAME AS NAME,
  7698. t1.sex AS sex,
  7699. t1.beh_dept_id AS behDeptId,
  7700. t1.beh_dept_name AS behDeptName,
  7701. t1.doctor_id AS doctorId,
  7702. t1.doctor_name AS doctorName,
  7703. t1.beh_doctor_id AS behDoctorId,
  7704. t1.beh_doctor_name AS behDoctorName,
  7705. t1.director_doctor_id AS directorDoctorId,
  7706. t1.director_doctor_name AS directorDoctorName,
  7707. t1.birthday AS birthday,
  7708. t1.behospital_date AS behospitalDate,
  7709. t1.leave_hospital_date AS leaveHospitalDate,
  7710. t1.placefile_date AS placefileDate,
  7711. t1.gmt_create AS gradeTime,
  7712. t1.diagnose,
  7713. t1.ward_name AS wardName,
  7714. t1.checkStatus,
  7715. t1.mrStatus,
  7716. t1.chName,
  7717. t1.mrName,
  7718. t1.chTime,
  7719. t1.mrTime,
  7720. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7721. t1.file_code AS fileCode,
  7722. t1.is_daytime as isDaytime
  7723. FROM
  7724. (
  7725. SELECT be.*,
  7726. ifnull(mci.status,0) AS checkStatus,
  7727. ifnull(hm_mci.status,0) AS mrStatus,
  7728. mci.check_name as chName,
  7729. e.score_res as scoreBn,
  7730. hm_mci.check_name as mrName,
  7731. mci.gmt_create as chTime,
  7732. hm_mci.gmt_create as mrTime
  7733. FROM
  7734. (
  7735. SELECT DISTINCT
  7736. tt1.*
  7737. FROM
  7738. (
  7739. SELECT
  7740. b.*,
  7741. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7742. c.grade_type,
  7743. c.score_res,
  7744. c.gmt_create
  7745. FROM
  7746. (
  7747. SELECT DISTINCT
  7748. a.hospital_id,
  7749. a.behospital_code,
  7750. a.bed_code,
  7751. a.NAME,
  7752. a.sex,
  7753. a.beh_dept_id,
  7754. a.beh_dept_name,
  7755. a.birthday,
  7756. a.behospital_date,
  7757. a.leave_hospital_date,
  7758. a.doctor_id,
  7759. a.doctor_name,
  7760. a.beh_doctor_id,
  7761. a.beh_doctor_name,
  7762. a.director_doctor_id,
  7763. a.director_doctor_name,
  7764. a.diagnose,
  7765. a.placefile_date,
  7766. a.ward_name,
  7767. a.file_code,
  7768. a.is_daytime
  7769. FROM
  7770. med_behospital_info a
  7771. WHERE
  7772. a.is_deleted = 'N'
  7773. AND a.qc_type_id != 0
  7774. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  7775. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  7776. </if>
  7777. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != '' and qcResultShortPageVO.leaveHosType !=2">
  7778. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7779. </if>
  7780. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7781. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7782. </if>
  7783. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0 and qcResultShortPageVO.leaveHosType !=2">
  7784. <if test="qcResultShortPageVO.startDate != null ">
  7785. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7786. </if>
  7787. <if test="qcResultShortPageVO.endDate != null ">
  7788. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7789. </if>
  7790. </if>
  7791. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1 and qcResultShortPageVO.leaveHosType !=2">
  7792. <if test="qcResultShortPageVO.startDate != null ">
  7793. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7794. </if>
  7795. <if test="qcResultShortPageVO.endDate != null">
  7796. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7797. </if>
  7798. </if>
  7799. <if test="qcResultShortPageVO.leaveHosType ==2">
  7800. <if test="qcResultShortPageVO.startDate != null ">
  7801. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7802. </if>
  7803. <if test="qcResultShortPageVO.endDate != null">
  7804. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7805. </if>
  7806. </if>
  7807. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7808. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7809. </if>
  7810. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7811. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7812. </if>
  7813. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7814. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7815. </if>
  7816. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  7817. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  7818. </if>
  7819. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7820. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7821. </if>
  7822. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7823. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7824. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7825. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7826. </if>
  7827. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7828. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7829. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7830. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7831. </if>
  7832. ) b
  7833. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7834. AND b.hospital_id = c.hospital_id
  7835. AND b.behospital_code = c.behospital_code
  7836. ) tt1
  7837. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7838. ,med_medical_record tt2,
  7839. qc_mode tt3
  7840. WHERE
  7841. tt2.is_deleted = 'N'
  7842. AND tt3.is_deleted = 'N'
  7843. AND tt1.hospital_id = tt2.hospital_id
  7844. AND tt1.behospital_code = tt2.behospital_code
  7845. AND tt2.mode_id = tt3.id
  7846. AND tt3.`name` = '手术记录'
  7847. </if>
  7848. ) be
  7849. left join med_check_info mci
  7850. on mci.is_deleted = 'N'
  7851. and mci.check_type in(0,2)
  7852. and be.hospital_id = mci.hospital_id
  7853. and be.behospital_code = mci.behospital_code
  7854. left join med_check_info hm_mci
  7855. on hm_mci.is_deleted = 'N'
  7856. and hm_mci.check_type = 1
  7857. and be.hospital_id = hm_mci.hospital_id
  7858. and be.behospital_code = hm_mci.behospital_code
  7859. LEFT JOIN med_qcresult_cases e
  7860. on be.behospital_code = e.behospital_code
  7861. and be.hospital_id = e.hospital_id
  7862. AND e.is_deleted = 'N'
  7863. and e.cases_id = 243
  7864. )t1
  7865. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7866. ,med_home_page t2
  7867. WHERE
  7868. t2.is_deleted = 'N'
  7869. AND t1.hospital_id = t2.hospital_id
  7870. AND t1.behospital_code = t2.behospital_code
  7871. AND ( IFNULL( t2.newborn_behospital_weight, '' ) != '' AND t2.newborn_behospital_weight != '0' AND t2.newborn_behospital_weight != '-' AND t2.newborn_behospital_weight != '—')
  7872. </if>
  7873. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7874. , med_medical_record b,
  7875. med_medical_record_content c,
  7876. med_home_page t2
  7877. WHERE
  7878. b.is_deleted = 'N'
  7879. and c.is_deleted = 'N'
  7880. and t2.is_deleted = 'N'
  7881. and t1.hospital_id = b.hospital_id
  7882. and t1.hospital_id = c.hospital_id
  7883. and t1.hospital_id = t2.hospital_id
  7884. AND t1.behospital_code = b.behospital_code
  7885. AND t1.behospital_code = t2.behospital_code
  7886. AND b.rec_id = c.rec_id
  7887. and b.mode_id = '24'
  7888. </if>
  7889. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7890. ,med_home_page t2
  7891. WHERE
  7892. t2.is_deleted = 'N'
  7893. AND t1.hospital_id = t2.hospital_id
  7894. AND t1.behospital_code = t2.behospital_code
  7895. AND t2.leave_hospital_type = '非医嘱离院'
  7896. </if>
  7897. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7898. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7899. AND t1.hospital_id = t2.hospital_id
  7900. AND t1.behospital_code = t2.behospital_code
  7901. </if>
  7902. )t
  7903. where 1=1
  7904. <if test="qcResultShortPageVO.checkStatus != null">
  7905. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7906. </if>
  7907. <if test="qcResultShortPageVO.mrStatus != null">
  7908. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7909. </if>
  7910. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7911. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7912. </if>
  7913. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7914. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7915. </if>
  7916. <if test="qcResultShortPageVO.chTimeStart != null ">
  7917. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7918. </if>
  7919. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7920. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7921. </if>
  7922. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7923. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7924. </if>
  7925. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7926. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7927. </if>
  7928. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7929. AND t.`level` = #{qcResultShortPageVO.level}
  7930. </if>
  7931. </select>
  7932. <!-- 离院病人评分详情页-科室-->
  7933. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  7934. SELECT
  7935. t.*
  7936. FROM
  7937. (SELECT DISTINCT
  7938. t1.hospital_id AS hospitalId,
  7939. t1.behospital_code AS behospitalCode,
  7940. t1.bed_code AS bedCode,
  7941. t1.LEVEL AS LEVEL,
  7942. t1.grade_type AS gradeType,
  7943. t1.score_res AS scoreRes,
  7944. t1.scoreBn,
  7945. t1.NAME AS NAME,
  7946. t1.sex AS sex,
  7947. t1.beh_dept_id AS behDeptId,
  7948. t1.beh_dept_name AS behDeptName,
  7949. t1.doctor_id AS doctorId,
  7950. t1.doctor_name AS doctorName,
  7951. t1.beh_doctor_id AS behDoctorId,
  7952. t1.beh_doctor_name AS behDoctorName,
  7953. t1.director_doctor_id AS directorDoctorId,
  7954. t1.director_doctor_name AS directorDoctorName,
  7955. t1.birthday AS birthday,
  7956. t1.behospital_date AS behospitalDate,
  7957. t1.leave_hospital_date AS leaveHospitalDate,
  7958. t1.placefile_date AS placefileDate,
  7959. t1.gmt_create AS gradeTime,
  7960. t1.diagnose,
  7961. t1.ward_name AS wardName,
  7962. t1.checkStatus,
  7963. t1.mrStatus,
  7964. t1.chName,
  7965. t1.mrName,
  7966. t1.chTime,
  7967. t1.mrTime,
  7968. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7969. t1.file_code AS fileCode
  7970. FROM
  7971. (
  7972. SELECT be.*,
  7973. ifnull(mci.status,0) AS checkStatus,
  7974. ifnull(hm_mci.status,0) AS mrStatus,
  7975. mci.check_name as chName,
  7976. e.score_res as scoreBn,
  7977. hm_mci.check_name as mrName,
  7978. mci.gmt_create as chTime,
  7979. hm_mci.gmt_create as mrTime
  7980. FROM
  7981. (
  7982. SELECT DISTINCT
  7983. tt1.*
  7984. FROM
  7985. (
  7986. SELECT
  7987. b.*,
  7988. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7989. c.grade_type,
  7990. c.score_res,
  7991. c.gmt_create
  7992. FROM
  7993. (
  7994. SELECT DISTINCT
  7995. a.hospital_id,
  7996. a.behospital_code,
  7997. a.bed_code,
  7998. a.NAME,
  7999. a.sex,
  8000. a.beh_dept_id,
  8001. a.beh_dept_name,
  8002. a.birthday,
  8003. a.behospital_date,
  8004. a.leave_hospital_date,
  8005. a.doctor_id,
  8006. a.doctor_name,
  8007. a.beh_doctor_id,
  8008. a.beh_doctor_name,
  8009. a.director_doctor_id,
  8010. a.director_doctor_name,
  8011. a.diagnose,
  8012. a.placefile_date,
  8013. a.ward_name,
  8014. a.file_code
  8015. FROM
  8016. med_behospital_info a,
  8017. sys_user_dept b
  8018. WHERE
  8019. a.is_deleted = 'N'
  8020. AND b.is_deleted = 'N'
  8021. AND a.hospital_id = b.hospital_id
  8022. AND a.beh_dept_id = b.dept_id
  8023. AND a.qc_type_id != 0
  8024. <if test="qcResultShortPageVO.userId!=null">
  8025. AND b.user_id = #{qcResultShortPageVO.userId}
  8026. </if>
  8027. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != '' and qcResultShortPageVO.leaveHosType !=2">
  8028. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8029. </if>
  8030. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8031. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8032. </if>
  8033. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0 and qcResultShortPageVO.leaveHosType !=2">
  8034. <if test="qcResultShortPageVO.startDate != null ">
  8035. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8036. </if>
  8037. <if test="qcResultShortPageVO.endDate != null ">
  8038. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8039. </if>
  8040. </if>
  8041. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1 and qcResultShortPageVO.leaveHosType !=2">
  8042. <if test="qcResultShortPageVO.startDate != null ">
  8043. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8044. </if>
  8045. <if test="qcResultShortPageVO.endDate != null">
  8046. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8047. </if>
  8048. </if>
  8049. <if test="qcResultShortPageVO.leaveHosType ==2">
  8050. <if test="qcResultShortPageVO.startDate != null ">
  8051. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8052. </if>
  8053. <if test="qcResultShortPageVO.endDate != null">
  8054. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8055. </if>
  8056. </if>
  8057. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8058. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8059. </if>
  8060. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8061. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8062. </if>
  8063. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8064. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8065. </if>
  8066. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  8067. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  8068. </if>
  8069. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8070. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8071. </if>
  8072. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8073. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8074. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8075. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8076. </if>
  8077. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8078. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8079. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8080. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8081. </if>
  8082. ) b
  8083. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8084. AND b.hospital_id = c.hospital_id
  8085. AND b.behospital_code = c.behospital_code
  8086. ) tt1
  8087. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8088. ,med_medical_record tt2,
  8089. qc_mode tt3
  8090. WHERE
  8091. tt2.is_deleted = 'N'
  8092. AND tt3.is_deleted = 'N'
  8093. AND tt1.hospital_id = tt2.hospital_id
  8094. AND tt1.behospital_code = tt2.behospital_code
  8095. AND tt2.mode_id = tt3.id
  8096. AND tt3.`name` = '手术记录'
  8097. </if>
  8098. ) be
  8099. left join med_check_info mci
  8100. on mci.is_deleted = 'N'
  8101. and mci.check_type in(0,2)
  8102. and be.hospital_id = mci.hospital_id
  8103. and be.behospital_code = mci.behospital_code
  8104. left join med_check_info hm_mci
  8105. on hm_mci.is_deleted = 'N'
  8106. and hm_mci.check_type = 1
  8107. and be.hospital_id = hm_mci.hospital_id
  8108. and be.behospital_code = hm_mci.behospital_code
  8109. LEFT JOIN med_qcresult_cases e
  8110. on be.behospital_code = e.behospital_code
  8111. and be.hospital_id = e.hospital_id
  8112. AND e.is_deleted = 'N'
  8113. and e.cases_id = 243
  8114. )t1
  8115. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8116. ,med_home_page t2
  8117. WHERE
  8118. t2.is_deleted = 'N'
  8119. AND t1.hospital_id = t2.hospital_id
  8120. AND t1.behospital_code = t2.behospital_code
  8121. AND ( IFNULL( t2.newborn_behospital_weight, '' ) != '' AND t2.newborn_behospital_weight != '0' AND t2.newborn_behospital_weight != '-' AND t2.newborn_behospital_weight != '—')
  8122. </if>
  8123. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8124. , med_medical_record b,
  8125. med_medical_record_content c,
  8126. med_home_page t2
  8127. WHERE
  8128. b.is_deleted = 'N'
  8129. and c.is_deleted = 'N'
  8130. and t2.is_deleted = 'N'
  8131. and t1.hospital_id = b.hospital_id
  8132. and t1.hospital_id = c.hospital_id
  8133. and t1.hospital_id = t2.hospital_id
  8134. AND t1.behospital_code = b.behospital_code
  8135. AND t1.behospital_code = t2.behospital_code
  8136. AND b.rec_id = c.rec_id
  8137. and b.mode_id = '24'
  8138. </if>
  8139. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8140. ,med_home_page t2
  8141. WHERE
  8142. t2.is_deleted = 'N'
  8143. AND t1.hospital_id = t2.hospital_id
  8144. AND t1.behospital_code = t2.behospital_code
  8145. AND t2.leave_hospital_type = '非医嘱离院'
  8146. </if>
  8147. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8148. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8149. AND t1.hospital_id = t2.hospital_id
  8150. AND t1.behospital_code = t2.behospital_code
  8151. </if>
  8152. )t
  8153. where 1=1
  8154. <if test="qcResultShortPageVO.checkStatus != null">
  8155. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8156. </if>
  8157. <if test="qcResultShortPageVO.mrStatus != null">
  8158. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8159. </if>
  8160. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8161. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8162. </if>
  8163. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8164. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8165. </if>
  8166. <if test="qcResultShortPageVO.chTimeStart != null ">
  8167. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8168. </if>
  8169. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8170. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8171. </if>
  8172. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8173. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8174. </if>
  8175. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8176. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8177. </if>
  8178. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8179. AND t.`level` = #{qcResultShortPageVO.level}
  8180. </if>
  8181. </select>
  8182. <!-- 病案首页改善率统计(首页)-->
  8183. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  8184. SELECT
  8185. t2.homePageMRNum,
  8186. t1.improveNum,
  8187. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  8188. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8189. t1.improveToPassNum,
  8190. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  8191. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8192. t1.improveToFullNum,
  8193. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  8194. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8195. FROM
  8196. (
  8197. SELECT
  8198. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8199. sum( d.score_res = 20 ) AS improveToFullNum,
  8200. count(*) AS improveNum
  8201. FROM
  8202. med_behospital_info a,
  8203. med_home_page b,
  8204. med_qcresult_info c,
  8205. med_qcresult_cases d,
  8206. (
  8207. SELECT
  8208. m4.*
  8209. FROM
  8210. med_behospital_info m1,
  8211. med_home_page m2,
  8212. med_qcresult_info m3,
  8213. med_qcresult_cases m4
  8214. WHERE
  8215. m1.is_deleted = 'N'
  8216. AND m2.is_deleted = 'N'
  8217. AND m3.is_deleted = 'Y'
  8218. AND m4.is_deleted = 'Y'
  8219. AND m1.hospital_id = m2.hospital_id
  8220. AND m1.hospital_id = m3.hospital_id
  8221. AND m1.hospital_id = m4.hospital_id
  8222. AND m1.behospital_code = m2.behospital_code
  8223. AND m1.behospital_code = m3.behospital_code
  8224. AND m1.behospital_code = m4.behospital_code
  8225. AND m3.gmt_create = m4.gmt_create
  8226. AND m3.have_home_page = 1
  8227. AND m4.cases_id = 243
  8228. <if test="isPlacefile != null and isPlacefile != ''">
  8229. and m1.is_placefile = #{isPlacefile}
  8230. </if>
  8231. AND m1.qc_type_id != 0
  8232. <if test="hospitalId != null and hospitalId != ''">
  8233. AND m1.hospital_id = #{hospitalId}
  8234. </if>
  8235. <if test="isPlacefile != null and isPlacefile == 0">
  8236. <if test="startDate != null and startDate != ''">
  8237. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8238. </if>
  8239. <if test="endDate != null and endDate != ''">
  8240. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8241. </if>
  8242. </if>
  8243. <if test="isPlacefile != null and isPlacefile == 1">
  8244. <if test="startDate != null and startDate != ''">
  8245. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8246. </if>
  8247. <if test="endDate != null and endDate != ''">
  8248. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8249. </if>
  8250. </if>
  8251. GROUP BY
  8252. m1.behospital_code
  8253. ORDER BY
  8254. m1.behospital_code,
  8255. m4.gmt_create
  8256. ) e
  8257. WHERE
  8258. a.is_deleted = 'N'
  8259. AND b.is_deleted = 'N'
  8260. AND c.is_deleted = 'N'
  8261. AND d.is_deleted = 'N'
  8262. AND a.hospital_id = b.hospital_id
  8263. AND a.hospital_id = c.hospital_id
  8264. AND a.hospital_id = d.hospital_id
  8265. AND a.hospital_id = e.hospital_id
  8266. AND a.behospital_code = b.behospital_code
  8267. AND a.behospital_code = c.behospital_code
  8268. AND a.behospital_code = d.behospital_code
  8269. AND a.behospital_code = e.behospital_code
  8270. AND d.cases_id = 243
  8271. AND d.score_res > e.score_res
  8272. <if test="isPlacefile != null and isPlacefile != ''">
  8273. and a.is_placefile = #{isPlacefile}
  8274. </if>
  8275. AND a.qc_type_id != 0
  8276. <if test="hospitalId != null and hospitalId != ''">
  8277. AND a.hospital_id = #{hospitalId}
  8278. </if>
  8279. <if test="isPlacefile != null and isPlacefile == 0">
  8280. <if test="startDate != null and startDate != ''">
  8281. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8282. </if>
  8283. <if test="endDate != null and endDate != ''">
  8284. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8285. </if>
  8286. </if>
  8287. <if test="isPlacefile != null and isPlacefile == 1">
  8288. <if test="startDate != null and startDate != ''">
  8289. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8290. </if>
  8291. <if test="endDate != null and endDate != ''">
  8292. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8293. </if>
  8294. </if>
  8295. ) t1,
  8296. (
  8297. SELECT
  8298. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8299. FROM
  8300. med_behospital_info a,
  8301. med_home_page b,
  8302. med_qcresult_info c
  8303. WHERE
  8304. a.is_deleted = 'N'
  8305. AND b.is_deleted = 'N'
  8306. AND a.hospital_id = b.hospital_id
  8307. AND a.hospital_id = c.hospital_id
  8308. AND a.behospital_code = b.behospital_code
  8309. AND a.behospital_code = c.behospital_code
  8310. AND a.qc_type_id != 0
  8311. <if test="isPlacefile != null and isPlacefile != ''">
  8312. and a.is_placefile = #{isPlacefile}
  8313. </if>
  8314. <if test="hospitalId != null and hospitalId != ''">
  8315. AND a.hospital_id = #{hospitalId}
  8316. </if>
  8317. <if test="isPlacefile != null and isPlacefile == 0">
  8318. <if test="startDate != null and startDate != ''">
  8319. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8320. </if>
  8321. <if test="endDate != null and endDate != ''">
  8322. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8323. </if>
  8324. </if>
  8325. <if test="isPlacefile != null and isPlacefile == 1">
  8326. <if test="startDate != null and startDate != ''">
  8327. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8328. </if>
  8329. <if test="endDate != null and endDate != ''">
  8330. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8331. </if>
  8332. </if>
  8333. ) t2
  8334. </select>
  8335. <!-- 质控核查统计(内页)-->
  8336. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  8337. SELECT
  8338. t.*
  8339. FROM
  8340. (SELECT
  8341. mr.beh_dept_id AS deptId,
  8342. mr.beh_dept_name AS deptName,
  8343. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8344. ck.checkedNum AS checkedNum,
  8345. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8346. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8347. hmmr_t.homePageMRNum,
  8348. improve_t.improveNum,
  8349. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8350. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8351. improve_t.improveToPassNum,
  8352. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8353. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8354. improve_t.improveToFullNum,
  8355. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8356. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8357. FROM
  8358. (
  8359. SELECT
  8360. a.beh_dept_id,
  8361. a.beh_dept_name,
  8362. count(*) AS mrNum
  8363. FROM
  8364. med_behospital_info a,
  8365. med_qcresult_info b
  8366. WHERE
  8367. a.is_deleted = 'N'
  8368. AND b.is_deleted = 'N'
  8369. AND a.hospital_id = b.hospital_id
  8370. AND a.behospital_code = b.behospital_code
  8371. AND a.qc_type_id != 0
  8372. <if test="isPlacefile != null and isPlacefile != ''">
  8373. and a.is_placefile = #{isPlacefile}
  8374. </if>
  8375. <if test="hospitalId != null and hospitalId != ''">
  8376. AND a.hospital_id = #{hospitalId}
  8377. </if>
  8378. <if test="isPlacefile != null and isPlacefile == 0">
  8379. <if test="startDate != null and startDate != ''">
  8380. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8381. </if>
  8382. <if test="endDate != null and endDate != ''">
  8383. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8384. </if>
  8385. </if>
  8386. <if test="isPlacefile != null and isPlacefile == 1">
  8387. <if test="startDate != null and startDate != ''">
  8388. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8389. </if>
  8390. <if test="endDate != null and endDate != ''">
  8391. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8392. </if>
  8393. </if>
  8394. <if test="deptName != null and deptName != ''">
  8395. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8396. </if>
  8397. GROUP BY
  8398. a.beh_dept_id,
  8399. a.beh_dept_name
  8400. ) mr
  8401. LEFT JOIN (
  8402. SELECT
  8403. a.beh_dept_id,
  8404. a.beh_dept_name,
  8405. count(*) AS checkedNum
  8406. FROM
  8407. med_behospital_info a,
  8408. med_qcresult_info b,
  8409. med_check_info c
  8410. WHERE
  8411. a.is_deleted = 'N'
  8412. AND b.is_deleted = 'N'
  8413. AND c.is_deleted = 'N'
  8414. AND a.hospital_id = b.hospital_id
  8415. AND a.hospital_id = c.hospital_id
  8416. AND a.behospital_code = b.behospital_code
  8417. AND a.behospital_code = c.behospital_code
  8418. AND a.qc_type_id != 0
  8419. AND ifnull(c.`status`,0) = 1
  8420. AND c.check_type in (0,2)
  8421. <if test="isPlacefile != null and isPlacefile != ''">
  8422. and a.is_placefile = #{isPlacefile}
  8423. </if>
  8424. <if test="hospitalId != null and hospitalId != ''">
  8425. AND a.hospital_id = #{hospitalId}
  8426. </if>
  8427. <if test="isPlacefile != null and isPlacefile == 0">
  8428. <if test="startDate != null and startDate != ''">
  8429. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8430. </if>
  8431. <if test="endDate != null and endDate != ''">
  8432. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8433. </if>
  8434. </if>
  8435. <if test="isPlacefile != null and isPlacefile == 1">
  8436. <if test="startDate != null and startDate != ''">
  8437. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8438. </if>
  8439. <if test="endDate != null and endDate != ''">
  8440. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8441. </if>
  8442. </if>
  8443. <if test="deptName != null and deptName != ''">
  8444. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8445. </if>
  8446. GROUP BY
  8447. a.beh_dept_id,
  8448. a.beh_dept_name
  8449. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  8450. AND mr.beh_dept_name = ck.beh_dept_name
  8451. LEFT JOIN (
  8452. SELECT
  8453. a.beh_dept_id,
  8454. a.beh_dept_name,
  8455. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8456. FROM
  8457. med_behospital_info a,
  8458. med_home_page b,
  8459. med_qcresult_info c
  8460. WHERE
  8461. a.is_deleted = 'N'
  8462. AND b.is_deleted = 'N'
  8463. AND a.hospital_id = b.hospital_id
  8464. AND a.hospital_id = c.hospital_id
  8465. AND a.behospital_code = b.behospital_code
  8466. AND a.behospital_code = c.behospital_code
  8467. AND a.qc_type_id != 0
  8468. <if test="isPlacefile != null and isPlacefile != ''">
  8469. and a.is_placefile = #{isPlacefile}
  8470. </if>
  8471. <if test="hospitalId != null and hospitalId != ''">
  8472. AND a.hospital_id = #{hospitalId}
  8473. </if>
  8474. <if test="isPlacefile != null and isPlacefile == 0">
  8475. <if test="startDate != null and startDate != ''">
  8476. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8477. </if>
  8478. <if test="endDate != null and endDate != ''">
  8479. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8480. </if>
  8481. </if>
  8482. <if test="isPlacefile != null and isPlacefile == 1">
  8483. <if test="startDate != null and startDate != ''">
  8484. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8485. </if>
  8486. <if test="endDate != null and endDate != ''">
  8487. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8488. </if>
  8489. </if>
  8490. <if test="deptName != null and deptName != ''">
  8491. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8492. </if>
  8493. GROUP BY
  8494. a.beh_dept_id,
  8495. a.beh_dept_name
  8496. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  8497. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  8498. LEFT JOIN (
  8499. SELECT
  8500. a.beh_dept_id,
  8501. a.beh_dept_name,
  8502. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8503. sum( d.score_res = 20 ) AS improveToFullNum,
  8504. count(*) AS improveNum
  8505. FROM
  8506. med_behospital_info a,
  8507. med_home_page b,
  8508. med_qcresult_info c,
  8509. med_qcresult_cases d,
  8510. (
  8511. SELECT
  8512. m4.*
  8513. FROM
  8514. med_behospital_info m1,
  8515. med_home_page m2,
  8516. med_qcresult_info m3,
  8517. med_qcresult_cases m4
  8518. WHERE
  8519. m1.is_deleted = 'N'
  8520. AND m2.is_deleted = 'N'
  8521. AND m3.is_deleted = 'Y'
  8522. AND m4.is_deleted = 'Y'
  8523. AND m1.hospital_id = m2.hospital_id
  8524. AND m1.hospital_id = m3.hospital_id
  8525. AND m1.hospital_id = m4.hospital_id
  8526. AND m1.behospital_code = m2.behospital_code
  8527. AND m1.behospital_code = m3.behospital_code
  8528. AND m1.behospital_code = m4.behospital_code
  8529. AND m3.gmt_create = m4.gmt_create
  8530. AND m3.have_home_page = 1
  8531. AND m4.cases_id = 243
  8532. <if test="isPlacefile != null and isPlacefile != ''">
  8533. and m1.is_placefile = #{isPlacefile}
  8534. </if>
  8535. AND m1.qc_type_id != 0
  8536. <if test="hospitalId != null and hospitalId != ''">
  8537. AND m1.hospital_id = #{hospitalId}
  8538. </if>
  8539. <if test="isPlacefile != null and isPlacefile == 0">
  8540. <if test="startDate != null and startDate != ''">
  8541. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8542. </if>
  8543. <if test="endDate != null and endDate != ''">
  8544. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8545. </if>
  8546. </if>
  8547. <if test="isPlacefile != null and isPlacefile == 1">
  8548. <if test="startDate != null and startDate != ''">
  8549. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8550. </if>
  8551. <if test="endDate != null and endDate != ''">
  8552. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8553. </if>
  8554. </if>
  8555. <if test="deptName != null and deptName != ''">
  8556. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8557. </if>
  8558. GROUP BY
  8559. m1.behospital_code
  8560. ORDER BY
  8561. m1.behospital_code,
  8562. m4.gmt_create
  8563. ) e
  8564. WHERE
  8565. a.is_deleted = 'N'
  8566. AND b.is_deleted = 'N'
  8567. AND c.is_deleted = 'N'
  8568. AND d.is_deleted = 'N'
  8569. AND a.hospital_id = b.hospital_id
  8570. AND a.hospital_id = c.hospital_id
  8571. AND a.hospital_id = d.hospital_id
  8572. AND a.hospital_id = e.hospital_id
  8573. AND a.behospital_code = b.behospital_code
  8574. AND a.behospital_code = c.behospital_code
  8575. AND a.behospital_code = d.behospital_code
  8576. AND a.behospital_code = e.behospital_code
  8577. AND d.cases_id = 243
  8578. AND d.score_res > e.score_res
  8579. <if test="hospitalId != null and hospitalId != ''">
  8580. AND a.hospital_id = #{hospitalId}
  8581. </if>
  8582. <if test="isPlacefile != null and isPlacefile == 0">
  8583. <if test="startDate != null and startDate != ''">
  8584. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8585. </if>
  8586. <if test="endDate != null and endDate != ''">
  8587. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8588. </if>
  8589. </if>
  8590. <if test="isPlacefile != null and isPlacefile == 1">
  8591. <if test="startDate != null and startDate != ''">
  8592. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8593. </if>
  8594. <if test="endDate != null and endDate != ''">
  8595. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8596. </if>
  8597. </if>
  8598. <if test="deptName != null and deptName != ''">
  8599. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8600. </if>
  8601. GROUP BY
  8602. a.beh_dept_id,
  8603. a.beh_dept_name
  8604. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  8605. AND mr.beh_dept_name = improve_t.beh_dept_name
  8606. ) t
  8607. <if test="asc != null and asc !=''">
  8608. order by
  8609. <choose>
  8610. <when test='asc=="deptId"'>deptId asc</when>
  8611. <when test='asc=="deptName"'>deptName asc</when>
  8612. <when test='asc=="mrNum"'>mrNum asc</when>
  8613. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8614. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8615. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8616. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8617. <when test='asc=="improveNum"'>improveNum asc</when>
  8618. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8619. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8620. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8621. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8622. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8623. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8624. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8625. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8626. <otherwise>deptName asc</otherwise>
  8627. </choose>
  8628. </if>
  8629. <if test="desc != null and desc!=''">
  8630. order by
  8631. <choose>
  8632. <when test='desc=="deptId"'>deptId desc</when>
  8633. <when test='desc=="deptName"'>deptName desc</when>
  8634. <when test='desc=="mrNum"'>mrNum desc</when>
  8635. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8636. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8637. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8638. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8639. <when test='desc=="improveNum"'>improveNum desc</when>
  8640. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8641. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8642. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8643. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8644. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8645. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8646. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8647. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8648. <otherwise>deptName desc</otherwise>
  8649. </choose>
  8650. </if>
  8651. </select>
  8652. <!-- 质控核查统计-科室(内页)-->
  8653. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  8654. SELECT
  8655. t.*
  8656. FROM
  8657. (SELECT
  8658. mr.beh_dept_id AS deptId,
  8659. mr.beh_dept_name AS deptName,
  8660. mr.doctorId,
  8661. mr.doctorName,
  8662. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8663. ck.checkedNum AS checkedNum,
  8664. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8665. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8666. hmmr_t.homePageMRNum,
  8667. improve_t.improveNum,
  8668. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8669. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8670. improve_t.improveToPassNum,
  8671. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8672. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8673. improve_t.improveToFullNum,
  8674. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8675. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8676. FROM
  8677. (
  8678. SELECT
  8679. a.beh_dept_id,
  8680. a.beh_dept_name,
  8681. a.doctor_id as doctorId,
  8682. a.doctor_name as doctorName,
  8683. count(*) AS mrNum
  8684. FROM
  8685. med_behospital_info a,
  8686. med_qcresult_info b,
  8687. sys_user_dept c
  8688. WHERE
  8689. a.is_deleted = 'N'
  8690. AND b.is_deleted = 'N'
  8691. AND c.is_deleted = 'N'
  8692. AND a.hospital_id = b.hospital_id
  8693. AND a.hospital_id = c.hospital_id
  8694. AND a.beh_dept_id = c.dept_id
  8695. AND a.behospital_code = b.behospital_code
  8696. AND a.qc_type_id != 0
  8697. <if test="userId!=null">
  8698. AND c.user_id = #{userId}
  8699. </if>
  8700. <if test="isPlacefile != null and isPlacefile != ''">
  8701. and a.is_placefile = #{isPlacefile}
  8702. </if>
  8703. <if test="hospitalId != null and hospitalId != ''">
  8704. AND a.hospital_id = #{hospitalId}
  8705. </if>
  8706. <if test="isPlacefile != null and isPlacefile == 0">
  8707. <if test="startDate != null and startDate != ''">
  8708. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8709. </if>
  8710. <if test="endDate != null and endDate != ''">
  8711. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8712. </if>
  8713. </if>
  8714. <if test="isPlacefile != null and isPlacefile == 1">
  8715. <if test="startDate != null and startDate != ''">
  8716. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8717. </if>
  8718. <if test="endDate != null and endDate != ''">
  8719. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8720. </if>
  8721. </if>
  8722. <if test="deptName != null and deptName != ''">
  8723. and a.beh_dept_name = #{deptName}
  8724. </if>
  8725. <if test="doctorName != null and doctorName != ''">
  8726. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8727. </if>
  8728. GROUP BY
  8729. a.doctor_id,
  8730. a.doctor_name
  8731. ) mr
  8732. LEFT JOIN (
  8733. SELECT
  8734. a.beh_dept_id,
  8735. a.beh_dept_name,
  8736. a.doctor_id as doctorId,
  8737. a.doctor_name as doctorName,
  8738. count(*) AS checkedNum
  8739. FROM
  8740. med_behospital_info a,
  8741. med_qcresult_info b,
  8742. med_check_info c,
  8743. sys_user_dept d
  8744. WHERE
  8745. a.is_deleted = 'N'
  8746. AND b.is_deleted = 'N'
  8747. AND c.is_deleted = 'N'
  8748. AND d.is_deleted = 'N'
  8749. AND a.hospital_id = b.hospital_id
  8750. AND a.hospital_id = c.hospital_id
  8751. AND a.hospital_id = d.hospital_id
  8752. AND a.behospital_code = b.behospital_code
  8753. AND a.behospital_code = c.behospital_code
  8754. AND a.beh_dept_id = d.dept_id
  8755. AND a.qc_type_id != 0
  8756. AND ifnull(c.`status`,0) = 1
  8757. AND c.check_type = 0
  8758. <if test="userId!=null">
  8759. AND d.user_id = #{userId}
  8760. </if>
  8761. <if test="isPlacefile != null and isPlacefile != ''">
  8762. and a.is_placefile = #{isPlacefile}
  8763. </if>
  8764. <if test="hospitalId != null and hospitalId != ''">
  8765. AND a.hospital_id = #{hospitalId}
  8766. </if>
  8767. <if test="isPlacefile != null and isPlacefile == 0">
  8768. <if test="startDate != null and startDate != ''">
  8769. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8770. </if>
  8771. <if test="endDate != null and endDate != ''">
  8772. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8773. </if>
  8774. </if>
  8775. <if test="isPlacefile != null and isPlacefile == 1">
  8776. <if test="startDate != null and startDate != ''">
  8777. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8778. </if>
  8779. <if test="endDate != null and endDate != ''">
  8780. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8781. </if>
  8782. </if>
  8783. <if test="deptName != null and deptName != ''">
  8784. and a.beh_dept_name = #{deptName}
  8785. </if>
  8786. <if test="doctorName != null and doctorName != ''">
  8787. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8788. </if>
  8789. GROUP BY
  8790. a.doctor_id,
  8791. a.doctor_name
  8792. ) ck ON mr.doctorId = ck.doctorId
  8793. AND mr.doctorName = ck.doctorName
  8794. LEFT JOIN (
  8795. SELECT
  8796. a.beh_dept_id,
  8797. a.beh_dept_name,
  8798. a.doctor_id as doctorId,
  8799. a.doctor_name as doctorName,
  8800. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8801. FROM
  8802. med_behospital_info a,
  8803. med_home_page b,
  8804. med_qcresult_info c,
  8805. sys_user_dept d
  8806. WHERE
  8807. a.is_deleted = 'N'
  8808. AND b.is_deleted = 'N'
  8809. AND c.is_deleted = 'N'
  8810. AND d.is_deleted = 'N'
  8811. AND a.hospital_id = b.hospital_id
  8812. AND a.hospital_id = c.hospital_id
  8813. AND a.hospital_id = d.hospital_id
  8814. AND a.behospital_code = b.behospital_code
  8815. AND a.behospital_code = c.behospital_code
  8816. AND a.beh_dept_id = d.dept_id
  8817. AND a.qc_type_id != 0
  8818. <if test="userId!=null">
  8819. AND d.user_id = #{userId}
  8820. </if>
  8821. <if test="isPlacefile != null and isPlacefile != ''">
  8822. and a.is_placefile = #{isPlacefile}
  8823. </if>
  8824. <if test="hospitalId != null and hospitalId != ''">
  8825. AND a.hospital_id = #{hospitalId}
  8826. </if>
  8827. <if test="isPlacefile != null and isPlacefile == 0">
  8828. <if test="startDate != null and startDate != ''">
  8829. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8830. </if>
  8831. <if test="endDate != null and endDate != ''">
  8832. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8833. </if>
  8834. </if>
  8835. <if test="isPlacefile != null and isPlacefile == 1">
  8836. <if test="startDate != null and startDate != ''">
  8837. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8838. </if>
  8839. <if test="endDate != null and endDate != ''">
  8840. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8841. </if>
  8842. </if>
  8843. <if test="deptName != null and deptName != ''">
  8844. and a.beh_dept_name = #{deptName}
  8845. </if>
  8846. <if test="doctorName != null and doctorName != ''">
  8847. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8848. </if>
  8849. GROUP BY
  8850. a.doctor_id,
  8851. a.doctor_name
  8852. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8853. AND mr.doctorName = hmmr_t.doctorName
  8854. LEFT JOIN (
  8855. SELECT
  8856. a.beh_dept_id,
  8857. a.beh_dept_name,
  8858. a.doctor_id as doctorId,
  8859. a.doctor_name as doctorName,
  8860. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8861. sum( d.score_res = 20 ) AS improveToFullNum,
  8862. count(*) AS improveNum
  8863. FROM
  8864. med_behospital_info a,
  8865. med_home_page b,
  8866. med_qcresult_info c,
  8867. med_qcresult_cases d,
  8868. sys_user_dept f,
  8869. (
  8870. SELECT
  8871. m4.*
  8872. FROM
  8873. med_behospital_info m1,
  8874. med_home_page m2,
  8875. med_qcresult_info m3,
  8876. med_qcresult_cases m4
  8877. WHERE
  8878. m1.is_deleted = 'N'
  8879. AND m2.is_deleted = 'N'
  8880. AND m3.is_deleted = 'Y'
  8881. AND m4.is_deleted = 'Y'
  8882. AND m1.hospital_id = m2.hospital_id
  8883. AND m1.hospital_id = m3.hospital_id
  8884. AND m1.hospital_id = m4.hospital_id
  8885. AND m1.behospital_code = m2.behospital_code
  8886. AND m1.behospital_code = m3.behospital_code
  8887. AND m1.behospital_code = m4.behospital_code
  8888. AND m3.gmt_create = m4.gmt_create
  8889. AND m3.have_home_page = 1
  8890. AND m4.cases_id = 243
  8891. <if test="isPlacefile != null and isPlacefile != ''">
  8892. and m1.is_placefile = #{isPlacefile}
  8893. </if>
  8894. AND m1.qc_type_id != 0
  8895. <if test="hospitalId != null and hospitalId != ''">
  8896. AND m1.hospital_id = #{hospitalId}
  8897. </if>
  8898. <if test="isPlacefile != null and isPlacefile == 0">
  8899. <if test="startDate != null and startDate != ''">
  8900. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8901. </if>
  8902. <if test="endDate != null and endDate != ''">
  8903. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8904. </if>
  8905. </if>
  8906. <if test="isPlacefile != null and isPlacefile == 1">
  8907. <if test="startDate != null and startDate != ''">
  8908. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8909. </if>
  8910. <if test="endDate != null and endDate != ''">
  8911. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8912. </if>
  8913. </if>
  8914. <if test="deptName != null and deptName != ''">
  8915. and m1.beh_dept_name = #{deptName}
  8916. </if>
  8917. GROUP BY
  8918. m1.behospital_code
  8919. ORDER BY
  8920. m1.behospital_code,
  8921. m4.gmt_create
  8922. ) e
  8923. WHERE
  8924. a.is_deleted = 'N'
  8925. AND b.is_deleted = 'N'
  8926. AND c.is_deleted = 'N'
  8927. AND d.is_deleted = 'N'
  8928. AND f.is_deleted = 'N'
  8929. AND a.hospital_id = b.hospital_id
  8930. AND a.hospital_id = c.hospital_id
  8931. AND a.hospital_id = d.hospital_id
  8932. AND a.hospital_id = e.hospital_id
  8933. AND a.hospital_id = f.hospital_id
  8934. AND a.behospital_code = b.behospital_code
  8935. AND a.behospital_code = c.behospital_code
  8936. AND a.behospital_code = d.behospital_code
  8937. AND a.behospital_code = e.behospital_code
  8938. AND a.beh_dept_id = f.dept_id
  8939. <if test="userId!=null">
  8940. AND f.user_id = #{userId}
  8941. </if>
  8942. AND d.cases_id = 243
  8943. AND d.score_res > e.score_res
  8944. <if test="hospitalId != null and hospitalId != ''">
  8945. AND a.hospital_id = #{hospitalId}
  8946. </if>
  8947. <if test="isPlacefile != null and isPlacefile == 0">
  8948. <if test="startDate != null and startDate != ''">
  8949. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8950. </if>
  8951. <if test="endDate != null and endDate != ''">
  8952. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8953. </if>
  8954. </if>
  8955. <if test="isPlacefile != null and isPlacefile == 1">
  8956. <if test="startDate != null and startDate != ''">
  8957. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8958. </if>
  8959. <if test="endDate != null and endDate != ''">
  8960. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8961. </if>
  8962. </if>
  8963. <if test="doctorName != null and doctorName != ''">
  8964. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8965. </if>
  8966. <if test="deptName != null and deptName != ''">
  8967. and a.beh_dept_name = #{deptName}
  8968. </if>
  8969. GROUP BY
  8970. a.doctor_id,
  8971. a.doctor_name
  8972. ) improve_t ON mr.doctorId = improve_t.doctorId
  8973. AND mr.doctorName = improve_t.doctorName
  8974. ) t
  8975. <if test="asc != null and asc !=''">
  8976. order by
  8977. <choose>
  8978. <when test='asc=="deptId"'>deptId asc</when>
  8979. <when test='asc=="deptName"'>deptName asc</when>
  8980. <when test='asc=="doctorName"'>doctorName asc</when>
  8981. <when test='asc=="mrNum"'>mrNum asc</when>
  8982. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8983. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8984. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8985. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8986. <when test='asc=="improveNum"'>improveNum asc</when>
  8987. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8988. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8989. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8990. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8991. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8992. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8993. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8994. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8995. <otherwise>doctorName asc</otherwise>
  8996. </choose>
  8997. </if>
  8998. <if test="desc != null and desc!=''">
  8999. order by
  9000. <choose>
  9001. <when test='desc=="deptId"'>deptId desc</when>
  9002. <when test='desc=="deptName"'>deptName desc</when>
  9003. <when test='desc=="doctorName"'>doctorName desc</when>
  9004. <when test='desc=="mrNum"'>mrNum desc</when>
  9005. <when test='desc=="checkedNum"'>checkedNum desc</when>
  9006. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  9007. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  9008. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  9009. <when test='desc=="improveNum"'>improveNum desc</when>
  9010. <when test='desc=="improvePercent"'>improvePercent desc</when>
  9011. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  9012. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  9013. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  9014. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  9015. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  9016. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  9017. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  9018. <otherwise>deptName desc</otherwise>
  9019. </choose>
  9020. </if>
  9021. </select>
  9022. <!-- 离院病人评分详情页导出-->
  9023. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  9024. SELECT
  9025. f1.behDeptId,
  9026. f1.behDeptName,
  9027. f1.doctorName,
  9028. f1.patName,
  9029. f1.behospitalCode,
  9030. f1.hospitalId,
  9031. f1.behospitalDate,
  9032. f1.leaveHospitalDate,
  9033. f1.score,
  9034. f2.avgScore,
  9035. f1.scoreBn,
  9036. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9037. f1.msg,
  9038. f1.caseName,
  9039. </if>
  9040. f1.checkStatus,
  9041. f1.mrStatus,
  9042. f1.chName,
  9043. f1.mrName,
  9044. f1.chTime,
  9045. f1.mrTime
  9046. FROM
  9047. (SELECT
  9048. t.doctorName,
  9049. t.`name` AS patName,
  9050. t.behospitalCode AS behospitalCode,
  9051. t.behospitalDate AS behospitalDate,
  9052. t.leaveHospitalDate AS leaveHospitalDate,
  9053. qi.score_res AS score,
  9054. t.scoreBn,
  9055. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9056. qd.msg AS msg,
  9057. qc.NAME AS caseName,
  9058. </if>
  9059. t.behDeptId,
  9060. t.behDeptName,
  9061. t.hospitalId,
  9062. t.checkStatus,
  9063. t.mrStatus,
  9064. t.chName,
  9065. t.mrName,
  9066. t.chTime,
  9067. t.mrTime
  9068. FROM
  9069. (SELECT DISTINCT
  9070. t1.hospital_id AS hospitalId,
  9071. t1.behospital_code AS behospitalCode,
  9072. t1.bed_code AS bedCode,
  9073. t1.LEVEL AS LEVEL,
  9074. t1.grade_type AS gradeType,
  9075. t1.score_res AS scoreRes,
  9076. t1.scoreBn,
  9077. t1.NAME AS NAME,
  9078. t1.sex AS sex,
  9079. t1.beh_dept_id AS behDeptId,
  9080. t1.beh_dept_name AS behDeptName,
  9081. t1.doctor_id AS doctorId,
  9082. t1.doctor_name AS doctorName,
  9083. t1.beh_doctor_id AS behDoctorId,
  9084. t1.beh_doctor_name AS behDoctorName,
  9085. t1.director_doctor_id AS directorDoctorId,
  9086. t1.director_doctor_name AS directorDoctorName,
  9087. t1.birthday AS birthday,
  9088. t1.behospital_date AS behospitalDate,
  9089. t1.leave_hospital_date AS leaveHospitalDate,
  9090. t1.placefile_date AS placefileDate,
  9091. t1.gmt_create AS gradeTime,
  9092. t1.diagnose,
  9093. t1.ward_name AS wardName,
  9094. t1.checkStatus,
  9095. t1.mrStatus,
  9096. t1.chName,
  9097. t1.mrName,
  9098. t1.chTime,
  9099. t1.mrTime,
  9100. t2.age,
  9101. t1.file_code AS fileCode
  9102. FROM
  9103. (
  9104. SELECT be.*,
  9105. ifnull(mci.status,0) AS checkStatus,
  9106. ifnull(hm_mci.status,0) AS mrStatus,
  9107. mci.check_name as chName,
  9108. e.score_res as scoreBn,
  9109. hm_mci.check_name as mrName,
  9110. mci.gmt_create as chTime,
  9111. hm_mci.gmt_create as mrTime
  9112. FROM
  9113. (
  9114. SELECT DISTINCT
  9115. tt1.*
  9116. FROM
  9117. (
  9118. SELECT
  9119. b.*,
  9120. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9121. c.grade_type,
  9122. c.score_res,
  9123. c.gmt_create
  9124. FROM
  9125. (
  9126. SELECT DISTINCT
  9127. a.hospital_id,
  9128. a.behospital_code,
  9129. a.bed_code,
  9130. a.NAME,
  9131. a.sex,
  9132. a.beh_dept_id,
  9133. a.beh_dept_name,
  9134. a.birthday,
  9135. a.behospital_date,
  9136. a.leave_hospital_date,
  9137. a.doctor_id,
  9138. a.doctor_name,
  9139. a.beh_doctor_id,
  9140. a.beh_doctor_name,
  9141. a.director_doctor_id,
  9142. a.director_doctor_name,
  9143. a.diagnose,
  9144. a.placefile_date,
  9145. a.ward_name,
  9146. a.file_code
  9147. FROM
  9148. med_behospital_info a
  9149. WHERE
  9150. a.is_deleted = 'N'
  9151. AND a.qc_type_id != 0
  9152. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9153. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9154. </if>
  9155. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9156. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9157. </if>
  9158. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9159. <if test="qcResultShortPageVO.startDate != null ">
  9160. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9161. </if>
  9162. <if test="qcResultShortPageVO.endDate != null ">
  9163. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9164. </if>
  9165. </if>
  9166. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9167. <if test="qcResultShortPageVO.startDate != null ">
  9168. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9169. </if>
  9170. <if test="qcResultShortPageVO.endDate != null">
  9171. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9172. </if>
  9173. </if>
  9174. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9175. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9176. </if>
  9177. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9178. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9179. </if>
  9180. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9181. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9182. </if>
  9183. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9184. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9185. </if>
  9186. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9187. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9188. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9189. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9190. </if>
  9191. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9192. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9193. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9194. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9195. </if>
  9196. ) b
  9197. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9198. AND b.hospital_id = c.hospital_id
  9199. AND b.behospital_code = c.behospital_code
  9200. ) tt1
  9201. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9202. ,med_medical_record tt2,
  9203. qc_mode tt3
  9204. WHERE
  9205. tt2.is_deleted = 'N'
  9206. AND tt3.is_deleted = 'N'
  9207. AND tt1.hospital_id = tt2.hospital_id
  9208. AND tt1.behospital_code = tt2.behospital_code
  9209. AND tt2.mode_id = tt3.id
  9210. AND tt3.`name` = '手术记录'
  9211. </if>
  9212. ) be
  9213. left join med_check_info mci
  9214. on mci.is_deleted = 'N'
  9215. and mci.check_type in(0,2)
  9216. and be.hospital_id = mci.hospital_id
  9217. and be.behospital_code = mci.behospital_code
  9218. left join med_check_info hm_mci
  9219. on hm_mci.is_deleted = 'N'
  9220. and hm_mci.check_type = 1
  9221. and be.hospital_id = hm_mci.hospital_id
  9222. and be.behospital_code = hm_mci.behospital_code
  9223. LEFT JOIN med_qcresult_cases e
  9224. on be.behospital_code = e.behospital_code
  9225. and be.hospital_id = e.hospital_id
  9226. AND e.is_deleted = 'N'
  9227. and e.cases_id = 243
  9228. )t1
  9229. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9230. ,med_home_page t2
  9231. WHERE
  9232. t2.is_deleted = 'N'
  9233. AND t1.hospital_id = t2.hospital_id
  9234. AND t1.behospital_code = t2.behospital_code
  9235. AND (
  9236. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9237. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9238. )
  9239. </if>
  9240. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9241. ,med_home_page t2
  9242. WHERE
  9243. t2.is_deleted = 'N'
  9244. AND t1.hospital_id = t2.hospital_id
  9245. AND t1.behospital_code = t2.behospital_code
  9246. AND t2.return_to_type = '死亡'
  9247. </if>
  9248. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9249. ,med_home_page t2
  9250. WHERE
  9251. t2.is_deleted = 'N'
  9252. AND t1.hospital_id = t2.hospital_id
  9253. AND t1.behospital_code = t2.behospital_code
  9254. AND t2.leave_hospital_type = '非医嘱离院'
  9255. </if>
  9256. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9257. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9258. AND t1.hospital_id = t2.hospital_id
  9259. AND t1.behospital_code = t2.behospital_code
  9260. </if>
  9261. )t
  9262. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9263. AND t.hospitalId = qi.hospital_id
  9264. AND t.behospitalCode = qi.behospital_code
  9265. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9266. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9267. AND t.hospitalId = qd.hospital_id
  9268. AND t.behospitalCode = qd.behospital_code
  9269. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9270. AND qd.cases_id = qc.id
  9271. </if>
  9272. where 1=1
  9273. <if test="qcResultShortPageVO.checkStatus != null">
  9274. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9275. </if>
  9276. <if test="qcResultShortPageVO.mrStatus != null">
  9277. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9278. </if>
  9279. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9280. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9281. </if>
  9282. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9283. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9284. </if>
  9285. <if test="qcResultShortPageVO.chTimeStart != null ">
  9286. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9287. </if>
  9288. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9289. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9290. </if>
  9291. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9292. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9293. </if>
  9294. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9295. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9296. </if>
  9297. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9298. AND t.`level` = #{qcResultShortPageVO.level}
  9299. </if>)f1,(SELECT
  9300. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9301. t.behDeptId,
  9302. t.behDeptName
  9303. FROM
  9304. (SELECT DISTINCT
  9305. t1.hospital_id AS hospitalId,
  9306. t1.behospital_code AS behospitalCode,
  9307. t1.bed_code AS bedCode,
  9308. t1.LEVEL AS LEVEL,
  9309. t1.grade_type AS gradeType,
  9310. t1.score_res AS scoreRes,
  9311. t1.NAME AS NAME,
  9312. t1.sex AS sex,
  9313. t1.beh_dept_id AS behDeptId,
  9314. t1.beh_dept_name AS behDeptName,
  9315. t1.doctor_id AS doctorId,
  9316. t1.doctor_name AS doctorName,
  9317. t1.beh_doctor_id AS behDoctorId,
  9318. t1.beh_doctor_name AS behDoctorName,
  9319. t1.director_doctor_id AS directorDoctorId,
  9320. t1.director_doctor_name AS directorDoctorName,
  9321. t1.birthday AS birthday,
  9322. t1.behospital_date AS behospitalDate,
  9323. t1.leave_hospital_date AS leaveHospitalDate,
  9324. t1.placefile_date AS placefileDate,
  9325. t1.gmt_create AS gradeTime,
  9326. t1.diagnose,
  9327. t1.ward_name AS wardName,
  9328. t1.checkStatus,
  9329. t1.mrStatus,
  9330. t1.chName,
  9331. t1.mrName,
  9332. t1.chTime,
  9333. t1.mrTime,
  9334. t2.age,
  9335. t1.file_code AS fileCode
  9336. FROM
  9337. (
  9338. SELECT be.*,
  9339. ifnull(mci.status,0) AS checkStatus,
  9340. ifnull(hm_mci.status,0) AS mrStatus,
  9341. mci.check_name as chName,
  9342. hm_mci.check_name as mrName,
  9343. mci.gmt_create as chTime,
  9344. hm_mci.gmt_create as mrTime
  9345. FROM
  9346. (
  9347. SELECT DISTINCT
  9348. tt1.*
  9349. FROM
  9350. (
  9351. SELECT
  9352. b.*,
  9353. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9354. c.grade_type,
  9355. c.score_res,
  9356. c.gmt_create
  9357. FROM
  9358. (
  9359. SELECT DISTINCT
  9360. a.hospital_id,
  9361. a.behospital_code,
  9362. a.bed_code,
  9363. a.NAME,
  9364. a.sex,
  9365. a.beh_dept_id,
  9366. a.beh_dept_name,
  9367. a.birthday,
  9368. a.behospital_date,
  9369. a.leave_hospital_date,
  9370. a.doctor_id,
  9371. a.doctor_name,
  9372. a.beh_doctor_id,
  9373. a.beh_doctor_name,
  9374. a.director_doctor_id,
  9375. a.director_doctor_name,
  9376. a.diagnose,
  9377. a.placefile_date,
  9378. a.ward_name,
  9379. a.file_code
  9380. FROM
  9381. med_behospital_info a
  9382. WHERE
  9383. a.is_deleted = 'N'
  9384. AND a.qc_type_id != 0
  9385. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9386. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9387. </if>
  9388. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9389. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9390. </if>
  9391. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9392. <if test="qcResultShortPageVO.startDate != null ">
  9393. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9394. </if>
  9395. <if test="qcResultShortPageVO.endDate != null ">
  9396. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9397. </if>
  9398. </if>
  9399. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9400. <if test="qcResultShortPageVO.startDate != null ">
  9401. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9402. </if>
  9403. <if test="qcResultShortPageVO.endDate != null">
  9404. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9405. </if>
  9406. </if>
  9407. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9408. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9409. </if>
  9410. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9411. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9412. </if>
  9413. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9414. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9415. </if>
  9416. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9417. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9418. </if>
  9419. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9420. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9421. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9422. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9423. </if>
  9424. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9425. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9426. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9427. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9428. </if>
  9429. ) b
  9430. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9431. AND b.hospital_id = c.hospital_id
  9432. AND b.behospital_code = c.behospital_code
  9433. ) tt1
  9434. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9435. ,med_medical_record tt2,
  9436. qc_mode tt3
  9437. WHERE
  9438. tt2.is_deleted = 'N'
  9439. AND tt3.is_deleted = 'N'
  9440. AND tt1.hospital_id = tt2.hospital_id
  9441. AND tt1.behospital_code = tt2.behospital_code
  9442. AND tt2.mode_id = tt3.id
  9443. AND tt3.`name` = '手术记录'
  9444. </if>
  9445. ) be
  9446. left join med_check_info mci
  9447. on mci.is_deleted = 'N'
  9448. and mci.check_type in(0,2)
  9449. and be.hospital_id = mci.hospital_id
  9450. and be.behospital_code = mci.behospital_code
  9451. left join med_check_info hm_mci
  9452. on hm_mci.is_deleted = 'N'
  9453. and hm_mci.check_type = 1
  9454. and be.hospital_id = hm_mci.hospital_id
  9455. and be.behospital_code = hm_mci.behospital_code
  9456. )t1
  9457. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9458. ,med_home_page t2
  9459. WHERE
  9460. t2.is_deleted = 'N'
  9461. AND t1.hospital_id = t2.hospital_id
  9462. AND t1.behospital_code = t2.behospital_code
  9463. AND (
  9464. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  9465. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9466. )
  9467. </if>
  9468. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9469. ,med_home_page t2
  9470. WHERE
  9471. t2.is_deleted = 'N'
  9472. AND t1.hospital_id = t2.hospital_id
  9473. AND t1.behospital_code = t2.behospital_code
  9474. AND t2.return_to_type = '死亡'
  9475. </if>
  9476. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9477. ,med_home_page t2
  9478. WHERE
  9479. t2.is_deleted = 'N'
  9480. AND t1.hospital_id = t2.hospital_id
  9481. AND t1.behospital_code = t2.behospital_code
  9482. AND t2.leave_hospital_type = '非医嘱离院'
  9483. </if>
  9484. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9485. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9486. AND t1.hospital_id = t2.hospital_id
  9487. AND t1.behospital_code = t2.behospital_code
  9488. </if>
  9489. )t
  9490. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9491. AND t.hospitalId = qi.hospital_id
  9492. AND t.behospitalCode = qi.behospital_code
  9493. where 1=1
  9494. <if test="qcResultShortPageVO.checkStatus != null">
  9495. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9496. </if>
  9497. <if test="qcResultShortPageVO.mrStatus != null">
  9498. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9499. </if>
  9500. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9501. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9502. </if>
  9503. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9504. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9505. </if>
  9506. <if test="qcResultShortPageVO.chTimeStart != null ">
  9507. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9508. </if>
  9509. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9510. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9511. </if>
  9512. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9513. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9514. </if>
  9515. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9516. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9517. </if>
  9518. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9519. AND t.`level` = #{qcResultShortPageVO.level}
  9520. </if>
  9521. GROUP BY
  9522. t.behDeptId,
  9523. t.behDeptName
  9524. )f2
  9525. WHERE
  9526. f1.behDeptId = f2.behDeptId
  9527. AND f1.behDeptName = f2.behDeptName
  9528. </select>
  9529. <!-- 离院病人评分详情页导出-科室-->
  9530. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  9531. SELECT
  9532. f1.behDeptId,
  9533. f1.behDeptName,
  9534. f1.doctorName,
  9535. f1.patName,
  9536. f1.behospitalCode,
  9537. f1.hospitalId,
  9538. f1.behospitalDate,
  9539. f1.leaveHospitalDate,
  9540. f1.score,
  9541. f2.avgScore,
  9542. f1.scoreBn,
  9543. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9544. f1.msg,
  9545. f1.caseName,
  9546. </if>
  9547. f1.checkStatus,
  9548. f1.mrStatus,
  9549. f1.chName,
  9550. f1.mrName,
  9551. f1.chTime,
  9552. f1.mrTime
  9553. FROM
  9554. (SELECT
  9555. t.doctorName,
  9556. t.doctorId,
  9557. t.`name` AS patName,
  9558. t.behospitalCode AS behospitalCode,
  9559. t.behospitalDate AS behospitalDate,
  9560. t.leaveHospitalDate AS leaveHospitalDate,
  9561. qi.score_res AS score,
  9562. t.scoreBn,
  9563. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9564. qd.msg AS msg,
  9565. qc.NAME AS caseName,
  9566. </if>
  9567. t.behDeptId,
  9568. t.behDeptName,
  9569. t.hospitalId,
  9570. t.checkStatus,
  9571. t.mrStatus,
  9572. t.chName,
  9573. t.mrName,
  9574. t.chTime,
  9575. t.mrTime
  9576. FROM
  9577. (SELECT DISTINCT
  9578. t1.hospital_id AS hospitalId,
  9579. t1.behospital_code AS behospitalCode,
  9580. t1.bed_code AS bedCode,
  9581. t1.LEVEL AS LEVEL,
  9582. t1.grade_type AS gradeType,
  9583. t1.score_res AS scoreRes,
  9584. t1.scoreBn,
  9585. t1.NAME AS NAME,
  9586. t1.sex AS sex,
  9587. t1.beh_dept_id AS behDeptId,
  9588. t1.beh_dept_name AS behDeptName,
  9589. t1.doctor_id AS doctorId,
  9590. t1.doctor_name AS doctorName,
  9591. t1.beh_doctor_id AS behDoctorId,
  9592. t1.beh_doctor_name AS behDoctorName,
  9593. t1.director_doctor_id AS directorDoctorId,
  9594. t1.director_doctor_name AS directorDoctorName,
  9595. t1.birthday AS birthday,
  9596. t1.behospital_date AS behospitalDate,
  9597. t1.leave_hospital_date AS leaveHospitalDate,
  9598. t1.placefile_date AS placefileDate,
  9599. t1.gmt_create AS gradeTime,
  9600. t1.diagnose,
  9601. t1.ward_name AS wardName,
  9602. t1.checkStatus,
  9603. t1.mrStatus,
  9604. t1.chName,
  9605. t1.mrName,
  9606. t1.chTime,
  9607. t1.mrTime,
  9608. t2.age,
  9609. t1.file_code AS fileCode
  9610. FROM
  9611. (
  9612. SELECT be.*,
  9613. ifnull(mci.status,0) AS checkStatus,
  9614. ifnull(hm_mci.status,0) AS mrStatus,
  9615. mci.check_name as chName,
  9616. e.score_res as scoreBn,
  9617. hm_mci.check_name as mrName,
  9618. mci.gmt_create as chTime,
  9619. hm_mci.gmt_create as mrTime
  9620. FROM
  9621. (
  9622. SELECT DISTINCT
  9623. tt1.*
  9624. FROM
  9625. (
  9626. SELECT
  9627. b.*,
  9628. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9629. c.grade_type,
  9630. c.score_res,
  9631. c.gmt_create
  9632. FROM
  9633. (
  9634. SELECT DISTINCT
  9635. a.hospital_id,
  9636. a.behospital_code,
  9637. a.bed_code,
  9638. a.NAME,
  9639. a.sex,
  9640. a.beh_dept_id,
  9641. a.beh_dept_name,
  9642. a.birthday,
  9643. a.behospital_date,
  9644. a.leave_hospital_date,
  9645. a.doctor_id,
  9646. a.doctor_name,
  9647. a.beh_doctor_id,
  9648. a.beh_doctor_name,
  9649. a.director_doctor_id,
  9650. a.director_doctor_name,
  9651. a.diagnose,
  9652. a.placefile_date,
  9653. a.ward_name,
  9654. a.file_code
  9655. FROM
  9656. med_behospital_info a,
  9657. sys_user_dept b
  9658. WHERE
  9659. a.is_deleted = 'N'
  9660. AND b.is_deleted = 'N'
  9661. AND a.hospital_id = b.hospital_id
  9662. AND a.beh_dept_id = b.dept_id
  9663. AND a.qc_type_id != 0
  9664. <if test="qcResultShortPageVO.userId!=null">
  9665. AND b.user_id = #{qcResultShortPageVO.userId}
  9666. </if>
  9667. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9668. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9669. </if>
  9670. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9671. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9672. </if>
  9673. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9674. <if test="qcResultShortPageVO.startDate != null ">
  9675. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9676. </if>
  9677. <if test="qcResultShortPageVO.endDate != null ">
  9678. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9679. </if>
  9680. </if>
  9681. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9682. <if test="qcResultShortPageVO.startDate != null ">
  9683. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9684. </if>
  9685. <if test="qcResultShortPageVO.endDate != null">
  9686. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9687. </if>
  9688. </if>
  9689. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9690. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9691. </if>
  9692. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9693. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9694. </if>
  9695. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9696. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9697. </if>
  9698. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9699. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9700. </if>
  9701. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9702. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9703. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9704. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9705. </if>
  9706. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9707. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9708. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9709. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9710. </if>
  9711. ) b
  9712. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9713. AND b.hospital_id = c.hospital_id
  9714. AND b.behospital_code = c.behospital_code
  9715. ) tt1
  9716. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9717. ,med_medical_record tt2,
  9718. qc_mode tt3
  9719. WHERE
  9720. tt2.is_deleted = 'N'
  9721. AND tt3.is_deleted = 'N'
  9722. AND tt1.hospital_id = tt2.hospital_id
  9723. AND tt1.behospital_code = tt2.behospital_code
  9724. AND tt2.mode_id = tt3.id
  9725. AND tt3.`name` = '手术记录'
  9726. </if>
  9727. ) be
  9728. left join med_check_info mci
  9729. on mci.is_deleted = 'N'
  9730. and mci.check_type in(0,2)
  9731. and be.hospital_id = mci.hospital_id
  9732. and be.behospital_code = mci.behospital_code
  9733. left join med_check_info hm_mci
  9734. on hm_mci.is_deleted = 'N'
  9735. and hm_mci.check_type = 1
  9736. and be.hospital_id = hm_mci.hospital_id
  9737. and be.behospital_code = hm_mci.behospital_code
  9738. LEFT JOIN med_qcresult_cases e
  9739. on be.behospital_code = e.behospital_code
  9740. and be.hospital_id = e.hospital_id
  9741. AND e.is_deleted = 'N'
  9742. and e.cases_id = 243
  9743. )t1
  9744. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9745. ,med_home_page t2
  9746. WHERE
  9747. t2.is_deleted = 'N'
  9748. AND t1.hospital_id = t2.hospital_id
  9749. AND t1.behospital_code = t2.behospital_code
  9750. AND (
  9751. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9752. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9753. )
  9754. </if>
  9755. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9756. ,med_home_page t2
  9757. WHERE
  9758. t2.is_deleted = 'N'
  9759. AND t1.hospital_id = t2.hospital_id
  9760. AND t1.behospital_code = t2.behospital_code
  9761. AND t2.return_to_type = '死亡'
  9762. </if>
  9763. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9764. ,med_home_page t2
  9765. WHERE
  9766. t2.is_deleted = 'N'
  9767. AND t1.hospital_id = t2.hospital_id
  9768. AND t1.behospital_code = t2.behospital_code
  9769. AND t2.leave_hospital_type = '非医嘱离院'
  9770. </if>
  9771. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9772. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9773. AND t1.hospital_id = t2.hospital_id
  9774. AND t1.behospital_code = t2.behospital_code
  9775. </if>
  9776. )t
  9777. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9778. AND t.hospitalId = qi.hospital_id
  9779. AND t.behospitalCode = qi.behospital_code
  9780. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9781. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9782. AND t.hospitalId = qd.hospital_id
  9783. AND t.behospitalCode = qd.behospital_code
  9784. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9785. AND qd.cases_id = qc.id
  9786. </if>
  9787. where 1=1
  9788. <if test="qcResultShortPageVO.checkStatus != null">
  9789. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9790. </if>
  9791. <if test="qcResultShortPageVO.mrStatus != null">
  9792. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9793. </if>
  9794. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9795. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9796. </if>
  9797. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9798. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9799. </if>
  9800. <if test="qcResultShortPageVO.chTimeStart != null ">
  9801. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9802. </if>
  9803. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9804. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9805. </if>
  9806. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9807. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9808. </if>
  9809. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9810. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9811. </if>
  9812. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9813. AND t.`level` = #{qcResultShortPageVO.level}
  9814. </if>)f1,(SELECT
  9815. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9816. t.behDeptId,
  9817. t.behDeptName,
  9818. t.doctorId,
  9819. t.doctorName
  9820. FROM
  9821. (SELECT DISTINCT
  9822. t1.hospital_id AS hospitalId,
  9823. t1.behospital_code AS behospitalCode,
  9824. t1.bed_code AS bedCode,
  9825. t1.LEVEL AS LEVEL,
  9826. t1.grade_type AS gradeType,
  9827. t1.score_res AS scoreRes,
  9828. t1.NAME AS NAME,
  9829. t1.sex AS sex,
  9830. t1.beh_dept_id AS behDeptId,
  9831. t1.beh_dept_name AS behDeptName,
  9832. t1.doctor_id AS doctorId,
  9833. t1.doctor_name AS doctorName,
  9834. t1.beh_doctor_id AS behDoctorId,
  9835. t1.beh_doctor_name AS behDoctorName,
  9836. t1.director_doctor_id AS directorDoctorId,
  9837. t1.director_doctor_name AS directorDoctorName,
  9838. t1.birthday AS birthday,
  9839. t1.behospital_date AS behospitalDate,
  9840. t1.leave_hospital_date AS leaveHospitalDate,
  9841. t1.placefile_date AS placefileDate,
  9842. t1.gmt_create AS gradeTime,
  9843. t1.diagnose,
  9844. t1.ward_name AS wardName,
  9845. t1.checkStatus,
  9846. t1.mrStatus,
  9847. t1.chName,
  9848. t1.mrName,
  9849. t1.chTime,
  9850. t1.mrTime,
  9851. t2.age,
  9852. t1.file_code AS fileCode
  9853. FROM
  9854. (
  9855. SELECT be.*,
  9856. ifnull(mci.status,0) AS checkStatus,
  9857. ifnull(hm_mci.status,0) AS mrStatus,
  9858. mci.check_name as chName,
  9859. hm_mci.check_name as mrName,
  9860. mci.gmt_create as chTime,
  9861. hm_mci.gmt_create as mrTime
  9862. FROM
  9863. (
  9864. SELECT DISTINCT
  9865. tt1.*
  9866. FROM
  9867. (
  9868. SELECT
  9869. b.*,
  9870. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9871. c.grade_type,
  9872. c.score_res,
  9873. c.gmt_create
  9874. FROM
  9875. (
  9876. SELECT DISTINCT
  9877. a.hospital_id,
  9878. a.behospital_code,
  9879. a.bed_code,
  9880. a.NAME,
  9881. a.sex,
  9882. a.beh_dept_id,
  9883. a.beh_dept_name,
  9884. a.birthday,
  9885. a.behospital_date,
  9886. a.leave_hospital_date,
  9887. a.doctor_id,
  9888. a.doctor_name,
  9889. a.beh_doctor_id,
  9890. a.beh_doctor_name,
  9891. a.director_doctor_id,
  9892. a.director_doctor_name,
  9893. a.diagnose,
  9894. a.placefile_date,
  9895. a.ward_name,
  9896. a.file_code
  9897. FROM
  9898. med_behospital_info a,
  9899. sys_user_dept b
  9900. WHERE
  9901. a.is_deleted = 'N'
  9902. AND b.is_deleted = 'N'
  9903. AND a.hospital_id = b.hospital_id
  9904. AND a.beh_dept_id = b.dept_id
  9905. AND a.qc_type_id != 0
  9906. <if test="qcResultShortPageVO.userId!=null">
  9907. AND b.user_id = #{qcResultShortPageVO.userId}
  9908. </if>
  9909. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9910. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9911. </if>
  9912. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9913. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9914. </if>
  9915. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9916. <if test="qcResultShortPageVO.startDate != null ">
  9917. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9918. </if>
  9919. <if test="qcResultShortPageVO.endDate != null ">
  9920. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9921. </if>
  9922. </if>
  9923. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9924. <if test="qcResultShortPageVO.startDate != null ">
  9925. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9926. </if>
  9927. <if test="qcResultShortPageVO.endDate != null">
  9928. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9929. </if>
  9930. </if>
  9931. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9932. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9933. </if>
  9934. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9935. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9936. </if>
  9937. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9938. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9939. </if>
  9940. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9941. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9942. </if>
  9943. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9944. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9945. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9946. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9947. </if>
  9948. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9949. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9950. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9951. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9952. </if>
  9953. ) b
  9954. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9955. AND b.hospital_id = c.hospital_id
  9956. AND b.behospital_code = c.behospital_code
  9957. ) tt1
  9958. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9959. ,med_medical_record tt2,
  9960. qc_mode tt3
  9961. WHERE
  9962. tt2.is_deleted = 'N'
  9963. AND tt3.is_deleted = 'N'
  9964. AND tt1.hospital_id = tt2.hospital_id
  9965. AND tt1.behospital_code = tt2.behospital_code
  9966. AND tt2.mode_id = tt3.id
  9967. AND tt3.`name` = '手术记录'
  9968. </if>
  9969. ) be
  9970. left join med_check_info mci
  9971. on mci.is_deleted = 'N'
  9972. and mci.check_type in(0,2)
  9973. and be.hospital_id = mci.hospital_id
  9974. and be.behospital_code = mci.behospital_code
  9975. left join med_check_info hm_mci
  9976. on hm_mci.is_deleted = 'N'
  9977. and hm_mci.check_type = 1
  9978. and be.hospital_id = hm_mci.hospital_id
  9979. and be.behospital_code = hm_mci.behospital_code
  9980. )t1
  9981. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9982. ,med_home_page t2
  9983. WHERE
  9984. t2.is_deleted = 'N'
  9985. AND t1.hospital_id = t2.hospital_id
  9986. AND t1.behospital_code = t2.behospital_code
  9987. AND (
  9988. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9989. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9990. )
  9991. </if>
  9992. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9993. ,med_home_page t2
  9994. WHERE
  9995. t2.is_deleted = 'N'
  9996. AND t1.hospital_id = t2.hospital_id
  9997. AND t1.behospital_code = t2.behospital_code
  9998. AND t2.return_to_type = '死亡'
  9999. </if>
  10000. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  10001. ,med_home_page t2
  10002. WHERE
  10003. t2.is_deleted = 'N'
  10004. AND t1.hospital_id = t2.hospital_id
  10005. AND t1.behospital_code = t2.behospital_code
  10006. AND t2.leave_hospital_type = '非医嘱离院'
  10007. </if>
  10008. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  10009. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  10010. AND t1.hospital_id = t2.hospital_id
  10011. AND t1.behospital_code = t2.behospital_code
  10012. </if>
  10013. )t
  10014. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10015. AND t.hospitalId = qi.hospital_id
  10016. AND t.behospitalCode = qi.behospital_code
  10017. where 1=1
  10018. <if test="qcResultShortPageVO.checkStatus != null">
  10019. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10020. </if>
  10021. <if test="qcResultShortPageVO.mrStatus != null">
  10022. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10023. </if>
  10024. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10025. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10026. </if>
  10027. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10028. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10029. </if>
  10030. <if test="qcResultShortPageVO.chTimeStart != null ">
  10031. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10032. </if>
  10033. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10034. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10035. </if>
  10036. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10037. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10038. </if>
  10039. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10040. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10041. </if>
  10042. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10043. AND t.`level` = #{qcResultShortPageVO.level}
  10044. </if>
  10045. GROUP BY
  10046. t.behDeptId,
  10047. t.behDeptName,
  10048. t.doctorId,
  10049. t.doctorName
  10050. )f2
  10051. WHERE
  10052. f1.doctorId = f2.doctorId
  10053. AND f1.doctorName = f2.doctorName
  10054. </select>
  10055. <!--缺陷详情质控评分页导出-科室-->
  10056. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  10057. SELECT * from(
  10058. SELECT
  10059. f1.*,
  10060. f2.avgScore
  10061. FROM
  10062. (SELECT
  10063. t.*,
  10064. qi.score_res AS score,
  10065. qd.msg AS msg,
  10066. qc.NAME AS caseName
  10067. FROM
  10068. (SELECT DISTINCT
  10069. t1.hospital_id AS hospitalId,
  10070. t1.behospital_code AS behospitalCode,
  10071. t1.bed_code AS bedCode,
  10072. t1.LEVEL AS LEVEL,
  10073. t1.grade_type AS gradeType,
  10074. t1.score_res AS scoreRes,
  10075. t1.scoreBn AS scoreBn,
  10076. t1.NAME AS patName,
  10077. t1.sex AS sex,
  10078. t1.beh_dept_id AS behDeptId,
  10079. t1.beh_dept_name AS behDeptName,
  10080. t1.doctor_id AS doctorId,
  10081. t1.doctor_name AS doctorName,
  10082. t1.beh_doctor_id AS behDoctorId,
  10083. t1.beh_doctor_name AS behDoctorName,
  10084. t1.director_doctor_id AS directorDoctorId,
  10085. t1.director_doctor_name AS directorDoctorName,
  10086. t1.birthday AS birthday,
  10087. t1.behospital_date AS behospitalDate,
  10088. t1.leave_hospital_date AS leaveHospitalDate,
  10089. t1.placefile_date AS placefileDate,
  10090. t1.gmt_create AS gradeTime,
  10091. t1.diagnose AS diagnose,
  10092. t1.ward_name AS wardName,
  10093. t1.file_code AS fileCode,
  10094. t1.checkStatus AS checkStatus,
  10095. t1.mrStatus AS mrStatus,
  10096. t1.chName AS chName,
  10097. t1.mrName AS mrName,
  10098. t1.chTime AS chTime,
  10099. t1.mrTime AS mrTime
  10100. FROM
  10101. (
  10102. SELECT DISTINCT
  10103. tt1.*
  10104. FROM
  10105. (SELECT
  10106. be.*,
  10107. ifnull(mci.status,0) AS checkStatus,
  10108. ifnull(hm_mci.status,0) AS mrStatus,
  10109. mci.check_name as chName,
  10110. hm_mci.check_name as mrName,
  10111. mci.gmt_create as chTime,
  10112. e.score_res as scoreBn,
  10113. hm_mci.gmt_create as mrTime
  10114. FROM
  10115. (
  10116. SELECT DISTINCT
  10117. a.hospital_id,
  10118. a.behospital_code,
  10119. a.bed_code,
  10120. a.file_code,
  10121. b.LEVEL,
  10122. b.grade_type,
  10123. b.score_res,
  10124. a.NAME,
  10125. a.sex,
  10126. a.beh_dept_id,
  10127. a.beh_dept_name,
  10128. a.birthday,
  10129. a.behospital_date,
  10130. a.leave_hospital_date,
  10131. a.doctor_id,
  10132. a.doctor_name,
  10133. a.beh_doctor_id,
  10134. a.beh_doctor_name,
  10135. a.director_doctor_id,
  10136. a.director_doctor_name,
  10137. a.diagnose,
  10138. a.placefile_date,
  10139. a.ward_name,
  10140. b.gmt_create
  10141. FROM
  10142. med_behospital_info a,
  10143. med_qcresult_info b,
  10144. med_qcresult_detail c,
  10145. qc_cases_entry d,
  10146. sys_user_dept e
  10147. WHERE
  10148. a.is_deleted = 'N'
  10149. AND b.is_deleted = 'N'
  10150. AND c.is_deleted = 'N'
  10151. AND d.is_deleted = 'N'
  10152. AND e.is_deleted = 'N'
  10153. AND a.hospital_id = b.hospital_id
  10154. AND a.hospital_id = c.hospital_id
  10155. AND a.hospital_id = e.hospital_id
  10156. AND a.behospital_code = b.behospital_code
  10157. AND a.behospital_code = c.behospital_code
  10158. AND a.beh_dept_id = e.dept_id
  10159. AND c.cases_id = d.cases_id
  10160. AND c.cases_entry_id = d.id
  10161. AND a.qc_type_id != 0
  10162. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10163. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10164. </if>
  10165. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  10166. AND e.user_id = #{qcResultShortPageVO.userId}
  10167. </if>
  10168. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10169. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10170. </if>
  10171. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10172. <if test="qcResultShortPageVO.startDate != null ">
  10173. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10174. </if>
  10175. <if test="qcResultShortPageVO.endDate != null ">
  10176. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10177. </if>
  10178. </if>
  10179. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10180. <if test="qcResultShortPageVO.startDate != null ">
  10181. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10182. </if>
  10183. <if test="qcResultShortPageVO.endDate != null">
  10184. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10185. </if>
  10186. </if>
  10187. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10188. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10189. </if>
  10190. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10191. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10192. </if>
  10193. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10194. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10195. </if>
  10196. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10197. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10198. </if>
  10199. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10200. AND a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10201. </if>
  10202. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10203. AND b.`level` = #{qcResultShortPageVO.level}
  10204. </if>
  10205. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10206. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10207. </if>
  10208. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10209. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10210. </if>
  10211. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10212. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  10213. </if>
  10214. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  10215. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10216. </if>
  10217. <if test="qcResultShortPageVO.isReject != null">
  10218. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10219. </if>
  10220. <if test="qcResultShortPageVO.ruleType != null">
  10221. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10222. </if>
  10223. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10224. AND TIMESTAMPDIFF(
  10225. DAY,
  10226. DATE( a.behospital_date ),
  10227. DATE( a.leave_hospital_date ))> 30
  10228. </if>
  10229. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10230. AND TIMESTAMPDIFF(
  10231. DAY,
  10232. DATE( a.behospital_date ),
  10233. DATE( a.leave_hospital_date ))> 31
  10234. </if>
  10235. )be
  10236. left join med_check_info mci
  10237. on mci.is_deleted = 'N'
  10238. and mci.check_type in(0,2)
  10239. and be.hospital_id = mci.hospital_id
  10240. and be.behospital_code = mci.behospital_code
  10241. left join med_check_info hm_mci
  10242. on hm_mci.is_deleted = 'N'
  10243. and hm_mci.check_type = 1
  10244. and be.hospital_id = hm_mci.hospital_id
  10245. and be.behospital_code = hm_mci.behospital_code
  10246. LEFT JOIN med_qcresult_cases e
  10247. on be.behospital_code = e.behospital_code
  10248. and be.hospital_id = e.hospital_id
  10249. AND e.is_deleted = 'N'
  10250. and e.cases_id = 243
  10251. )tt1
  10252. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10253. ,med_medical_record tt2
  10254. WHERE
  10255. tt2.is_deleted = 'N'
  10256. AND tt1.hospital_id = tt2.hospital_id
  10257. AND tt1.behospital_code = tt2.behospital_code
  10258. AND tt2.mode_id = 30
  10259. </if>
  10260. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10261. ,med_crisis_info tt2
  10262. WHERE
  10263. tt2.is_deleted = 'N'
  10264. AND tt1.hospital_id = tt2.hospital_id
  10265. AND tt1.behospital_code = tt2.behospital_code
  10266. </if>
  10267. ) t1
  10268. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10269. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10270. AND t1.behospital_code = t2.behospital_code
  10271. AND t2.is_deleted = 'N'
  10272. </if>
  10273. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10274. , med_home_page t2
  10275. , med_home_operation_info t3
  10276. WHERE t1.hospital_id = t2.hospital_id
  10277. AND t1.behospital_code = t2.behospital_code
  10278. AND t2.home_page_id = t3.home_page_id
  10279. AND t2.is_deleted = 'N'
  10280. AND t3.is_deleted = 'N'
  10281. </if>
  10282. ) t
  10283. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10284. AND t.hospitalId = qi.hospital_id
  10285. AND t.behospitalCode = qi.behospital_code
  10286. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10287. AND t.hospitalId = qd.hospital_id
  10288. AND t.behospitalCode = qd.behospital_code
  10289. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10290. AND qd.cases_id = qc.id
  10291. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10292. AND qd.cases_id = qce.cases_id
  10293. AND qd.cases_entry_id = qce.id
  10294. where 1=1
  10295. <if test="qcResultShortPageVO.checkStatus != null">
  10296. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10297. </if>
  10298. <if test="qcResultShortPageVO.mrStatus != null">
  10299. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10300. </if>
  10301. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10302. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10303. </if>
  10304. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10305. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10306. </if>
  10307. <if test="qcResultShortPageVO.chTimeStart != null ">
  10308. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10309. </if>
  10310. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10311. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10312. </if>
  10313. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10314. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10315. </if>
  10316. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10317. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10318. </if>
  10319. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10320. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10321. </if>
  10322. <if test="qcResultShortPageVO.casesEntryId != null ">
  10323. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10324. </if>
  10325. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10326. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10327. </if>
  10328. <if test="qcResultShortPageVO.casesId != null">
  10329. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10330. </if>
  10331. )f1,
  10332. (SELECT
  10333. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10334. t.behDeptId,
  10335. t.behDeptName,
  10336. t.doctorId,
  10337. t.doctorName
  10338. FROM
  10339. (SELECT DISTINCT
  10340. t1.hospital_id AS hospitalId,
  10341. t1.behospital_code AS behospitalCode,
  10342. t1.bed_code AS bedCode,
  10343. t1.LEVEL AS LEVEL,
  10344. t1.grade_type AS gradeType,
  10345. t1.score_res AS scoreRes,
  10346. t1.NAME AS NAME,
  10347. t1.sex AS sex,
  10348. t1.beh_dept_id AS behDeptId,
  10349. t1.beh_dept_name AS behDeptName,
  10350. t1.doctor_id AS doctorId,
  10351. t1.doctor_name AS doctorName,
  10352. t1.beh_doctor_id AS behDoctorId,
  10353. t1.beh_doctor_name AS behDoctorName,
  10354. t1.director_doctor_id AS directorDoctorId,
  10355. t1.director_doctor_name AS directorDoctorName,
  10356. t1.birthday AS birthday,
  10357. t1.behospital_date AS behospitalDate,
  10358. t1.leave_hospital_date AS leaveHospitalDate,
  10359. t1.placefile_date AS placefileDate,
  10360. t1.gmt_create AS gradeTime,
  10361. t1.diagnose,
  10362. t1.ward_name AS wardName,
  10363. t2.age,
  10364. t1.file_code AS fileCode,
  10365. t1.checkStatus,
  10366. t1.mrStatus,
  10367. t1.chName,
  10368. t1.mrName,
  10369. t1.chTime,
  10370. t1.mrTime
  10371. FROM
  10372. (
  10373. SELECT DISTINCT
  10374. tt1.*
  10375. FROM
  10376. (SELECT
  10377. be.*,
  10378. ifnull(mci.status,0) AS checkStatus,
  10379. ifnull(hm_mci.status,0) AS mrStatus,
  10380. mci.check_name as chName,
  10381. hm_mci.check_name as mrName,
  10382. mci.gmt_create as chTime,
  10383. hm_mci.gmt_create as mrTime
  10384. FROM
  10385. (
  10386. SELECT DISTINCT
  10387. a.hospital_id,
  10388. a.behospital_code,
  10389. a.bed_code,
  10390. a.file_code,
  10391. b.LEVEL,
  10392. b.grade_type,
  10393. b.score_res,
  10394. a.NAME,
  10395. a.sex,
  10396. a.beh_dept_id,
  10397. a.beh_dept_name,
  10398. a.birthday,
  10399. a.behospital_date,
  10400. a.leave_hospital_date,
  10401. a.doctor_id,
  10402. a.doctor_name,
  10403. a.beh_doctor_id,
  10404. a.beh_doctor_name,
  10405. a.director_doctor_id,
  10406. a.director_doctor_name,
  10407. a.diagnose,
  10408. a.placefile_date,
  10409. a.ward_name,
  10410. b.gmt_create
  10411. FROM
  10412. med_behospital_info a,
  10413. med_qcresult_info b,
  10414. med_qcresult_detail c,
  10415. qc_cases_entry d,
  10416. sys_user_dept e
  10417. WHERE
  10418. a.is_deleted = 'N'
  10419. AND b.is_deleted = 'N'
  10420. AND c.is_deleted = 'N'
  10421. AND d.is_deleted = 'N'
  10422. AND e.is_deleted = 'N'
  10423. AND a.hospital_id = b.hospital_id
  10424. AND a.hospital_id = c.hospital_id
  10425. AND a.hospital_id = e.hospital_id
  10426. AND a.behospital_code = b.behospital_code
  10427. AND a.behospital_code = c.behospital_code
  10428. AND a.beh_dept_id = e.dept_id
  10429. AND c.cases_id = d.cases_id
  10430. AND c.cases_entry_id = d.id
  10431. AND a.qc_type_id != 0
  10432. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10433. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10434. </if>
  10435. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10436. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10437. </if>
  10438. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10439. <if test="qcResultShortPageVO.startDate != null ">
  10440. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10441. </if>
  10442. <if test="qcResultShortPageVO.endDate != null ">
  10443. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10444. </if>
  10445. </if>
  10446. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10447. <if test="qcResultShortPageVO.startDate != null ">
  10448. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10449. </if>
  10450. <if test="qcResultShortPageVO.endDate != null">
  10451. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10452. </if>
  10453. </if>
  10454. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10455. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10456. </if>
  10457. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10458. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10459. </if>
  10460. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10461. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10462. </if>
  10463. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10464. AND b.`level` = #{qcResultShortPageVO.level}
  10465. </if>
  10466. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10467. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10468. </if>
  10469. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10470. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10471. </if>
  10472. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10473. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10474. </if>
  10475. <if test="qcResultShortPageVO.casesEntryId != null ">
  10476. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10477. </if>
  10478. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10479. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10480. </if>
  10481. <if test="qcResultShortPageVO.casesId != null">
  10482. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10483. </if>
  10484. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10485. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10486. </if>
  10487. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10488. AND a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10489. </if>
  10490. <if test="qcResultShortPageVO.isReject != null">
  10491. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10492. </if>
  10493. <if test="qcResultShortPageVO.ruleType != null">
  10494. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10495. </if>
  10496. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10497. AND TIMESTAMPDIFF(
  10498. DAY,
  10499. DATE( a.behospital_date ),
  10500. DATE( a.leave_hospital_date ))> 30
  10501. </if>
  10502. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10503. AND TIMESTAMPDIFF(
  10504. DAY,
  10505. DATE( a.behospital_date ),
  10506. DATE( a.leave_hospital_date ))> 31
  10507. </if>
  10508. )be
  10509. left join med_check_info mci
  10510. on mci.is_deleted = 'N'
  10511. and mci.check_type in(0,2)
  10512. and be.hospital_id = mci.hospital_id
  10513. and be.behospital_code = mci.behospital_code
  10514. left join med_check_info hm_mci
  10515. on hm_mci.is_deleted = 'N'
  10516. and hm_mci.check_type = 1
  10517. and be.hospital_id = hm_mci.hospital_id
  10518. and be.behospital_code = hm_mci.behospital_code
  10519. )tt1
  10520. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10521. ,med_medical_record tt2
  10522. WHERE
  10523. tt2.is_deleted = 'N'
  10524. AND tt1.hospital_id = tt2.hospital_id
  10525. AND tt1.behospital_code = tt2.behospital_code
  10526. AND tt2.mode_id = 30
  10527. </if>
  10528. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10529. ,med_crisis_info tt2
  10530. WHERE
  10531. tt2.is_deleted = 'N'
  10532. AND tt1.hospital_id = tt2.hospital_id
  10533. AND tt1.behospital_code = tt2.behospital_code
  10534. </if>
  10535. ) t1
  10536. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10537. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10538. AND t1.behospital_code = t2.behospital_code
  10539. AND t2.is_deleted = 'N'
  10540. </if>
  10541. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10542. , med_home_page t2
  10543. , med_home_operation_info t3
  10544. WHERE t1.hospital_id = t2.hospital_id
  10545. AND t1.behospital_code = t2.behospital_code
  10546. AND t2.home_page_id = t3.home_page_id
  10547. AND t2.is_deleted = 'N'
  10548. AND t3.is_deleted = 'N'
  10549. </if>
  10550. ) t
  10551. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10552. AND t.hospitalId = qi.hospital_id
  10553. AND t.behospitalCode = qi.behospital_code
  10554. where 1=1
  10555. <if test="qcResultShortPageVO.checkStatus != null">
  10556. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10557. </if>
  10558. <if test="qcResultShortPageVO.mrStatus != null">
  10559. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10560. </if>
  10561. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10562. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10563. </if>
  10564. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10565. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10566. </if>
  10567. <if test="qcResultShortPageVO.chTimeStart != null ">
  10568. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10569. </if>
  10570. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10571. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10572. </if>
  10573. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10574. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10575. </if>
  10576. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10577. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10578. </if>
  10579. GROUP BY
  10580. t.behDeptId,
  10581. t.behDeptName,
  10582. t.doctorId,
  10583. t.doctorName
  10584. )f2
  10585. WHERE
  10586. f1.doctorId = f2.doctorId
  10587. AND f1.doctorName = f2.doctorName
  10588. )m
  10589. </select>
  10590. <!-- 条目缺陷评分详情页导出-->
  10591. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  10592. SELECT * from(
  10593. SELECT
  10594. f1.*,
  10595. f2.avgScore
  10596. FROM
  10597. (SELECT
  10598. t.*,
  10599. qi.score_res AS score,
  10600. qd.msg AS msg,
  10601. qc.NAME AS caseName
  10602. FROM
  10603. (SELECT DISTINCT
  10604. t1.hospital_id AS hospitalId,
  10605. t1.behospital_code AS behospitalCode,
  10606. t1.bed_code AS bedCode,
  10607. t1.LEVEL AS LEVEL,
  10608. t1.grade_type AS gradeType,
  10609. t1.score_res AS scoreRes,
  10610. t1.scoreBn AS scoreBn,
  10611. t1.NAME AS patName,
  10612. t1.sex AS sex,
  10613. t1.beh_dept_id AS behDeptId,
  10614. t1.beh_dept_name AS behDeptName,
  10615. t1.doctor_id AS doctorId,
  10616. t1.doctor_name AS doctorName,
  10617. t1.beh_doctor_id AS behDoctorId,
  10618. t1.beh_doctor_name AS behDoctorName,
  10619. t1.director_doctor_id AS directorDoctorId,
  10620. t1.director_doctor_name AS directorDoctorName,
  10621. t1.birthday AS birthday,
  10622. t1.behospital_date AS behospitalDate,
  10623. t1.leave_hospital_date AS leaveHospitalDate,
  10624. t1.placefile_date AS placefileDate,
  10625. t1.gmt_create AS gradeTime,
  10626. t1.diagnose AS diagnose,
  10627. t1.ward_name AS wardName,
  10628. t1.file_code AS fileCode,
  10629. t1.checkStatus AS checkStatus,
  10630. t1.mrStatus AS mrStatus,
  10631. t1.chName AS chName,
  10632. t1.mrName AS mrName,
  10633. t1.chTime AS chTime,
  10634. t1.mrTime AS mrTime
  10635. FROM
  10636. (
  10637. SELECT DISTINCT
  10638. tt1.*
  10639. FROM
  10640. (SELECT
  10641. be.*,
  10642. ifnull(mci.status,0) AS checkStatus,
  10643. ifnull(hm_mci.status,0) AS mrStatus,
  10644. mci.check_name as chName,
  10645. hm_mci.check_name as mrName,
  10646. mci.gmt_create as chTime,
  10647. e.score_res as scoreBn,
  10648. hm_mci.gmt_create as mrTime
  10649. FROM
  10650. (
  10651. SELECT DISTINCT
  10652. a.hospital_id,
  10653. a.behospital_code,
  10654. a.bed_code,
  10655. a.file_code,
  10656. b.LEVEL,
  10657. b.grade_type,
  10658. b.score_res,
  10659. a.NAME,
  10660. a.sex,
  10661. a.beh_dept_id,
  10662. a.beh_dept_name,
  10663. a.birthday,
  10664. a.behospital_date,
  10665. a.leave_hospital_date,
  10666. a.doctor_id,
  10667. a.doctor_name,
  10668. a.beh_doctor_id,
  10669. a.beh_doctor_name,
  10670. a.director_doctor_id,
  10671. a.director_doctor_name,
  10672. a.diagnose,
  10673. a.placefile_date,
  10674. a.ward_name,
  10675. b.gmt_create
  10676. FROM
  10677. med_behospital_info a,
  10678. med_qcresult_info b,
  10679. med_qcresult_detail c,
  10680. qc_cases_entry d
  10681. WHERE
  10682. a.is_deleted = 'N'
  10683. AND b.is_deleted = 'N'
  10684. AND c.is_deleted = 'N'
  10685. AND d.is_deleted = 'N'
  10686. AND a.hospital_id = b.hospital_id
  10687. AND a.hospital_id = c.hospital_id
  10688. AND a.behospital_code = b.behospital_code
  10689. AND a.behospital_code = c.behospital_code
  10690. AND c.cases_id = d.cases_id
  10691. AND c.cases_entry_id = d.id
  10692. AND a.qc_type_id != 0
  10693. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10694. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10695. </if>
  10696. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10697. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10698. </if>
  10699. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10700. <if test="qcResultShortPageVO.startDate != null ">
  10701. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10702. </if>
  10703. <if test="qcResultShortPageVO.endDate != null ">
  10704. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10705. </if>
  10706. </if>
  10707. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10708. <if test="qcResultShortPageVO.startDate != null ">
  10709. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10710. </if>
  10711. <if test="qcResultShortPageVO.endDate != null">
  10712. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10713. </if>
  10714. </if>
  10715. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10716. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10717. </if>
  10718. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10719. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10720. </if>
  10721. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10722. AND b.`level` = #{qcResultShortPageVO.level}
  10723. </if>
  10724. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10725. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10726. </if>
  10727. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10728. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10729. </if>
  10730. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10731. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10732. </if>
  10733. <if test="qcResultShortPageVO.casesEntryId != null ">
  10734. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10735. </if>
  10736. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10737. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10738. </if>
  10739. <if test="qcResultShortPageVO.casesId != null">
  10740. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10741. </if>
  10742. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10743. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10744. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10745. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10746. </if>
  10747. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10748. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10749. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10750. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10751. </if>
  10752. <if test="qcResultShortPageVO.isReject != null">
  10753. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10754. </if>
  10755. <if test="qcResultShortPageVO.ruleType != null">
  10756. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10757. </if>
  10758. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10759. AND TIMESTAMPDIFF(
  10760. DAY,
  10761. DATE( a.behospital_date ),
  10762. DATE( a.leave_hospital_date ))> 30
  10763. </if>
  10764. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10765. AND TIMESTAMPDIFF(
  10766. DAY,
  10767. DATE( a.behospital_date ),
  10768. DATE( a.leave_hospital_date ))> 31
  10769. </if>
  10770. )be
  10771. left join med_check_info mci
  10772. on mci.is_deleted = 'N'
  10773. and mci.check_type in(0,2)
  10774. and be.hospital_id = mci.hospital_id
  10775. and be.behospital_code = mci.behospital_code
  10776. left join med_check_info hm_mci
  10777. on hm_mci.is_deleted = 'N'
  10778. and hm_mci.check_type = 1
  10779. and be.hospital_id = hm_mci.hospital_id
  10780. and be.behospital_code = hm_mci.behospital_code
  10781. LEFT JOIN med_qcresult_cases e
  10782. on be.behospital_code = e.behospital_code
  10783. and be.hospital_id = e.hospital_id
  10784. AND e.is_deleted = 'N'
  10785. and e.cases_id = 243
  10786. )tt1
  10787. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10788. ,med_medical_record tt2
  10789. WHERE
  10790. tt2.is_deleted = 'N'
  10791. AND tt1.hospital_id = tt2.hospital_id
  10792. AND tt1.behospital_code = tt2.behospital_code
  10793. AND tt2.mode_id = 30
  10794. </if>
  10795. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10796. ,med_crisis_info tt2
  10797. WHERE
  10798. tt2.is_deleted = 'N'
  10799. AND tt1.hospital_id = tt2.hospital_id
  10800. AND tt1.behospital_code = tt2.behospital_code
  10801. </if>
  10802. ) t1
  10803. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10804. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10805. AND t1.behospital_code = t2.behospital_code
  10806. AND t2.is_deleted = 'N'
  10807. </if>
  10808. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10809. , med_home_page t2
  10810. , med_home_operation_info t3
  10811. WHERE t1.hospital_id = t2.hospital_id
  10812. AND t1.behospital_code = t2.behospital_code
  10813. AND t2.home_page_id = t3.home_page_id
  10814. AND t2.is_deleted = 'N'
  10815. AND t3.is_deleted = 'N'
  10816. </if>
  10817. ) t
  10818. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10819. AND t.hospitalId = qi.hospital_id
  10820. AND t.behospitalCode = qi.behospital_code
  10821. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10822. AND t.hospitalId = qd.hospital_id
  10823. AND t.behospitalCode = qd.behospital_code
  10824. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10825. AND qd.cases_id = qc.id
  10826. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10827. AND qd.cases_id = qce.cases_id
  10828. AND qd.cases_entry_id = qce.id
  10829. where 1=1
  10830. <if test="qcResultShortPageVO.checkStatus != null">
  10831. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10832. </if>
  10833. <if test="qcResultShortPageVO.mrStatus != null">
  10834. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10835. </if>
  10836. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10837. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10838. </if>
  10839. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10840. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10841. </if>
  10842. <if test="qcResultShortPageVO.chTimeStart != null ">
  10843. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10844. </if>
  10845. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10846. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10847. </if>
  10848. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10849. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10850. </if>
  10851. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10852. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10853. </if>
  10854. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10855. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10856. </if>
  10857. <if test="qcResultShortPageVO.casesEntryId != null ">
  10858. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10859. </if>
  10860. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10861. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10862. </if>
  10863. <if test="qcResultShortPageVO.casesId != null">
  10864. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10865. </if>
  10866. )f1,
  10867. (SELECT
  10868. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10869. t.behDeptId,
  10870. t.behDeptName
  10871. FROM
  10872. (SELECT DISTINCT
  10873. t1.hospital_id AS hospitalId,
  10874. t1.behospital_code AS behospitalCode,
  10875. t1.bed_code AS bedCode,
  10876. t1.LEVEL AS LEVEL,
  10877. t1.grade_type AS gradeType,
  10878. t1.score_res AS scoreRes,
  10879. t1.NAME AS NAME,
  10880. t1.sex AS sex,
  10881. t1.beh_dept_id AS behDeptId,
  10882. t1.beh_dept_name AS behDeptName,
  10883. t1.doctor_id AS doctorId,
  10884. t1.doctor_name AS doctorName,
  10885. t1.beh_doctor_id AS behDoctorId,
  10886. t1.beh_doctor_name AS behDoctorName,
  10887. t1.director_doctor_id AS directorDoctorId,
  10888. t1.director_doctor_name AS directorDoctorName,
  10889. t1.birthday AS birthday,
  10890. t1.behospital_date AS behospitalDate,
  10891. t1.leave_hospital_date AS leaveHospitalDate,
  10892. t1.placefile_date AS placefileDate,
  10893. t1.gmt_create AS gradeTime,
  10894. t1.diagnose,
  10895. t1.ward_name AS wardName,
  10896. t2.age,
  10897. t1.file_code AS fileCode,
  10898. t1.checkStatus,
  10899. t1.mrStatus,
  10900. t1.chName,
  10901. t1.mrName,
  10902. t1.chTime,
  10903. t1.mrTime
  10904. FROM
  10905. (
  10906. SELECT DISTINCT
  10907. tt1.*
  10908. FROM
  10909. (SELECT
  10910. be.*,
  10911. ifnull(mci.status,0) AS checkStatus,
  10912. ifnull(hm_mci.status,0) AS mrStatus,
  10913. mci.check_name as chName,
  10914. hm_mci.check_name as mrName,
  10915. mci.gmt_create as chTime,
  10916. hm_mci.gmt_create as mrTime
  10917. FROM
  10918. (
  10919. SELECT DISTINCT
  10920. a.hospital_id,
  10921. a.behospital_code,
  10922. a.bed_code,
  10923. a.file_code,
  10924. b.LEVEL,
  10925. b.grade_type,
  10926. b.score_res,
  10927. a.NAME,
  10928. a.sex,
  10929. a.beh_dept_id,
  10930. a.beh_dept_name,
  10931. a.birthday,
  10932. a.behospital_date,
  10933. a.leave_hospital_date,
  10934. a.doctor_id,
  10935. a.doctor_name,
  10936. a.beh_doctor_id,
  10937. a.beh_doctor_name,
  10938. a.director_doctor_id,
  10939. a.director_doctor_name,
  10940. a.diagnose,
  10941. a.placefile_date,
  10942. a.ward_name,
  10943. b.gmt_create
  10944. FROM
  10945. med_behospital_info a,
  10946. med_qcresult_info b,
  10947. med_qcresult_detail c,
  10948. qc_cases_entry d
  10949. WHERE
  10950. a.is_deleted = 'N'
  10951. AND b.is_deleted = 'N'
  10952. AND c.is_deleted = 'N'
  10953. AND d.is_deleted = 'N'
  10954. AND a.hospital_id = b.hospital_id
  10955. AND a.hospital_id = c.hospital_id
  10956. AND a.behospital_code = b.behospital_code
  10957. AND a.behospital_code = c.behospital_code
  10958. AND c.cases_id = d.cases_id
  10959. AND c.cases_entry_id = d.id
  10960. AND a.qc_type_id != 0
  10961. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10962. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10963. </if>
  10964. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10965. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10966. </if>
  10967. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10968. <if test="qcResultShortPageVO.startDate != null ">
  10969. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10970. </if>
  10971. <if test="qcResultShortPageVO.endDate != null ">
  10972. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10973. </if>
  10974. </if>
  10975. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10976. <if test="qcResultShortPageVO.startDate != null ">
  10977. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10978. </if>
  10979. <if test="qcResultShortPageVO.endDate != null">
  10980. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10981. </if>
  10982. </if>
  10983. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10984. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10985. </if>
  10986. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10987. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10988. </if>
  10989. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10990. AND b.`level` = #{qcResultShortPageVO.level}
  10991. </if>
  10992. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10993. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10994. </if>
  10995. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10996. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10997. </if>
  10998. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10999. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11000. </if>
  11001. <if test="qcResultShortPageVO.casesEntryId != null ">
  11002. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11003. </if>
  11004. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11005. AND d.cases_name = #{qcResultShortPageVO.casesName}
  11006. </if>
  11007. <if test="qcResultShortPageVO.casesId != null">
  11008. AND d.cases_id = #{qcResultShortPageVO.casesId}
  11009. </if>
  11010. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11011. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11012. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11013. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11014. </if>
  11015. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11016. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11017. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11018. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11019. </if>
  11020. <if test="qcResultShortPageVO.isReject != null">
  11021. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11022. </if>
  11023. <if test="qcResultShortPageVO.ruleType != null">
  11024. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11025. </if>
  11026. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  11027. AND TIMESTAMPDIFF(
  11028. DAY,
  11029. DATE( a.behospital_date ),
  11030. DATE( a.leave_hospital_date ))> 30
  11031. </if>
  11032. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  11033. AND TIMESTAMPDIFF(
  11034. DAY,
  11035. DATE( a.behospital_date ),
  11036. DATE( a.leave_hospital_date ))> 31
  11037. </if>
  11038. )be
  11039. left join med_check_info mci
  11040. on mci.is_deleted = 'N'
  11041. and mci.check_type in(0,2)
  11042. and be.hospital_id = mci.hospital_id
  11043. and be.behospital_code = mci.behospital_code
  11044. left join med_check_info hm_mci
  11045. on hm_mci.is_deleted = 'N'
  11046. and hm_mci.check_type = 1
  11047. and be.hospital_id = hm_mci.hospital_id
  11048. and be.behospital_code = hm_mci.behospital_code
  11049. )tt1
  11050. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  11051. ,med_medical_record tt2
  11052. WHERE
  11053. tt2.is_deleted = 'N'
  11054. AND tt1.hospital_id = tt2.hospital_id
  11055. AND tt1.behospital_code = tt2.behospital_code
  11056. AND tt2.mode_id = 30
  11057. </if>
  11058. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  11059. ,med_crisis_info tt2
  11060. WHERE
  11061. tt2.is_deleted = 'N'
  11062. AND tt1.hospital_id = tt2.hospital_id
  11063. AND tt1.behospital_code = tt2.behospital_code
  11064. </if>
  11065. ) t1
  11066. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  11067. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11068. AND t1.behospital_code = t2.behospital_code
  11069. AND t2.is_deleted = 'N'
  11070. </if>
  11071. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  11072. , med_home_page t2
  11073. , med_home_operation_info t3
  11074. WHERE t1.hospital_id = t2.hospital_id
  11075. AND t1.behospital_code = t2.behospital_code
  11076. AND t2.home_page_id = t3.home_page_id
  11077. AND t2.is_deleted = 'N'
  11078. AND t3.is_deleted = 'N'
  11079. </if>
  11080. ) t
  11081. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11082. AND t.hospitalId = qi.hospital_id
  11083. AND t.behospitalCode = qi.behospital_code
  11084. where 1=1
  11085. <if test="qcResultShortPageVO.checkStatus != null">
  11086. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11087. </if>
  11088. <if test="qcResultShortPageVO.mrStatus != null">
  11089. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11090. </if>
  11091. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11092. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11093. </if>
  11094. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11095. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11096. </if>
  11097. <if test="qcResultShortPageVO.chTimeStart != null ">
  11098. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11099. </if>
  11100. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11101. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11102. </if>
  11103. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11104. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11105. </if>
  11106. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11107. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11108. </if>
  11109. GROUP BY
  11110. t.behDeptId,
  11111. t.behDeptName
  11112. )f2
  11113. WHERE
  11114. f1.behDeptId = f2.behDeptId
  11115. AND f1.behDeptName = f2.behDeptName
  11116. )m
  11117. </select>
  11118. <!-- 条目缺陷评分详情页导出湘雅-->
  11119. <select id="qcResultShortXYPageExport" resultMap="ExportExcelMap">
  11120. SELECT * from(
  11121. SELECT
  11122. f1.*,
  11123. f2.avgScore
  11124. FROM
  11125. (SELECT
  11126. t.*,
  11127. qi.score_res AS score,
  11128. qd.msg AS msg,
  11129. qc.NAME AS caseName
  11130. FROM
  11131. (SELECT DISTINCT
  11132. t1.hospital_id AS hospitalId,
  11133. t1.behospital_code AS behospitalCode,
  11134. t1.bed_code AS bedCode,
  11135. t1.LEVEL AS LEVEL,
  11136. t1.grade_type AS gradeType,
  11137. t1.score_res AS scoreRes,
  11138. t1.scoreBn AS scoreBn,
  11139. t1.NAME AS patName,
  11140. t1.sex AS sex,
  11141. t1.beh_dept_id AS behDeptId,
  11142. t1.beh_dept_name AS behDeptName,
  11143. t1.doctor_name AS doctorName,
  11144. t1.doctorId,
  11145. t1.birthday AS birthday,
  11146. t1.behospital_date AS behospitalDate,
  11147. t1.leave_hospital_date AS leaveHospitalDate,
  11148. t1.placefile_date AS placefileDate,
  11149. t1.gmt_create AS gradeTime,
  11150. t1.diagnose AS diagnose,
  11151. t1.ward_name AS wardName,
  11152. t1.file_code AS fileCode,
  11153. t1.checkStatus AS checkStatus,
  11154. t1.mrStatus AS mrStatus,
  11155. t1.chName AS chName,
  11156. t1.mrName AS mrName,
  11157. t1.chTime AS chTime,
  11158. t1.mrTime AS mrTime
  11159. FROM
  11160. (
  11161. SELECT DISTINCT
  11162. tt1.*
  11163. FROM
  11164. (SELECT
  11165. be.*,
  11166. ifnull(mci.status,0) AS checkStatus,
  11167. ifnull(hm_mci.status,0) AS mrStatus,
  11168. mci.check_name as chName,
  11169. hm_mci.check_name as mrName,
  11170. mci.gmt_create as chTime,
  11171. e.score_res as scoreBn,
  11172. f.doctor_id as doctorId,
  11173. hm_mci.gmt_create as mrTime
  11174. FROM
  11175. (
  11176. SELECT DISTINCT
  11177. a.hospital_id,
  11178. a.behospital_code,
  11179. a.bed_code,
  11180. a.file_code,
  11181. b.LEVEL,
  11182. b.grade_type,
  11183. b.score_res,
  11184. a.NAME,
  11185. a.sex,
  11186. a.beh_dept_id,
  11187. a.beh_dept_name,
  11188. a.birthday,
  11189. a.behospital_date,
  11190. a.leave_hospital_date,
  11191. case
  11192. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11193. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11194. e.director_doctor != '' and e.director_doctor is not null
  11195. then e.director_doctor
  11196. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11197. (e.director_doctor = '' or e.director_doctor is null) and
  11198. e.behospital_doctor != '' and e.behospital_doctor is not null
  11199. then e.behospital_doctor end as doctor_name,
  11200. a.diagnose,
  11201. a.placefile_date,
  11202. a.ward_name,
  11203. b.gmt_create
  11204. FROM
  11205. med_behospital_info a,
  11206. med_qcresult_info b,
  11207. med_qcresult_detail c,
  11208. qc_cases_entry d,
  11209. med_home_page e
  11210. WHERE
  11211. a.is_deleted = 'N'
  11212. AND b.is_deleted = 'N'
  11213. AND c.is_deleted = 'N'
  11214. AND d.is_deleted = 'N'
  11215. AND e.is_deleted = 'N'
  11216. AND a.hospital_id = b.hospital_id
  11217. AND a.hospital_id = c.hospital_id
  11218. AND a.hospital_id = e.hospital_id
  11219. AND a.behospital_code = b.behospital_code
  11220. AND a.behospital_code = c.behospital_code
  11221. AND a.behospital_code = e.behospital_code
  11222. AND c.cases_id = d.cases_id
  11223. AND c.cases_entry_id = d.id
  11224. AND a.qc_type_id != 0
  11225. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11226. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11227. </if>
  11228. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11229. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11230. </if>
  11231. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11232. <if test="qcResultShortPageVO.startDate != null ">
  11233. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11234. </if>
  11235. <if test="qcResultShortPageVO.endDate != null ">
  11236. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11237. </if>
  11238. </if>
  11239. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11240. <if test="qcResultShortPageVO.startDate != null ">
  11241. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11242. </if>
  11243. <if test="qcResultShortPageVO.endDate != null">
  11244. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11245. </if>
  11246. </if>
  11247. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11248. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11249. </if>
  11250. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11251. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11252. </if>
  11253. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  11254. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  11255. </if>
  11256. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11257. AND b.`level` = #{qcResultShortPageVO.level}
  11258. </if>
  11259. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11260. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11261. </if>
  11262. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11263. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11264. </if>
  11265. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11266. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11267. </if>
  11268. <if test="qcResultShortPageVO.casesEntryId != null ">
  11269. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11270. </if>
  11271. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11272. AND d.cases_name = #{qcResultShortPageVO.casesName}
  11273. </if>
  11274. <if test="qcResultShortPageVO.casesId != null">
  11275. AND d.cases_id = #{qcResultShortPageVO.casesId}
  11276. </if>
  11277. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11278. AND(case
  11279. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11280. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11281. e.director_doctor != '' and e.director_doctor is not null
  11282. then e.director_doctor
  11283. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11284. (e.director_doctor = '' or e.director_doctor is null) and
  11285. e.behospital_doctor != '' and e.behospital_doctor is not null
  11286. then e.behospital_doctor end ) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11287. </if>
  11288. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  11289. AND(case
  11290. when e.attending_doctor != '' and e.attending_doctor is not null then '主治医师'
  11291. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11292. e.director_doctor != '' and e.director_doctor is not null
  11293. then '主任医师'
  11294. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11295. (e.director_doctor = '' or e.director_doctor is null) and
  11296. e.behospital_doctor != '' and e.behospital_doctor is not null
  11297. then '住院医师' end) = #{qcResultShortPageVO.professor}
  11298. </if>
  11299. <if test="qcResultShortPageVO.isReject != null">
  11300. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11301. </if>
  11302. <if test="qcResultShortPageVO.ruleType != null">
  11303. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11304. </if>
  11305. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  11306. AND TIMESTAMPDIFF(
  11307. DAY,
  11308. DATE( a.behospital_date ),
  11309. DATE( a.leave_hospital_date ))> 30
  11310. </if>
  11311. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  11312. AND TIMESTAMPDIFF(
  11313. DAY,
  11314. DATE( a.behospital_date ),
  11315. DATE( a.leave_hospital_date ))> 31
  11316. </if>
  11317. )be
  11318. left join med_check_info mci
  11319. on mci.is_deleted = 'N'
  11320. and mci.check_type in(0,2)
  11321. and be.hospital_id = mci.hospital_id
  11322. and be.behospital_code = mci.behospital_code
  11323. left join med_check_info hm_mci
  11324. on hm_mci.is_deleted = 'N'
  11325. and hm_mci.check_type = 1
  11326. and be.hospital_id = hm_mci.hospital_id
  11327. and be.behospital_code = hm_mci.behospital_code
  11328. LEFT JOIN med_qcresult_cases e
  11329. on be.behospital_code = e.behospital_code
  11330. and be.hospital_id = e.hospital_id
  11331. AND e.is_deleted = 'N'
  11332. and e.cases_id = 243
  11333. LEFT JOIN bas_doctor_info f
  11334. on be.hospital_id = f.hospital_id
  11335. and be.doctor_name = f.name
  11336. AND f.is_deleted = 'N'
  11337. )tt1
  11338. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  11339. ,med_medical_record tt2
  11340. WHERE
  11341. tt2.is_deleted = 'N'
  11342. AND tt1.hospital_id = tt2.hospital_id
  11343. AND tt1.behospital_code = tt2.behospital_code
  11344. AND tt2.mode_id = 30
  11345. </if>
  11346. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  11347. ,med_crisis_info tt2
  11348. WHERE
  11349. tt2.is_deleted = 'N'
  11350. AND tt1.hospital_id = tt2.hospital_id
  11351. AND tt1.behospital_code = tt2.behospital_code
  11352. </if>
  11353. ) t1
  11354. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  11355. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11356. AND t1.behospital_code = t2.behospital_code
  11357. AND t2.is_deleted = 'N'
  11358. </if>
  11359. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  11360. , med_home_page t2
  11361. , med_home_operation_info t3
  11362. WHERE t1.hospital_id = t2.hospital_id
  11363. AND t1.behospital_code = t2.behospital_code
  11364. AND t2.home_page_id = t3.home_page_id
  11365. AND t2.is_deleted = 'N'
  11366. AND t3.is_deleted = 'N'
  11367. </if>
  11368. ) t
  11369. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11370. AND t.hospitalId = qi.hospital_id
  11371. AND t.behospitalCode = qi.behospital_code
  11372. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  11373. AND t.hospitalId = qd.hospital_id
  11374. AND t.behospitalCode = qd.behospital_code
  11375. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  11376. AND qd.cases_id = qc.id
  11377. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  11378. AND qd.cases_id = qce.cases_id
  11379. AND qd.cases_entry_id = qce.id
  11380. where 1=1
  11381. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11382. AND t.doctorId = #{qcResultShortPageVO.doctorId}
  11383. </if>
  11384. <if test="qcResultShortPageVO.checkStatus != null">
  11385. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11386. </if>
  11387. <if test="qcResultShortPageVO.mrStatus != null">
  11388. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11389. </if>
  11390. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11391. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11392. </if>
  11393. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11394. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11395. </if>
  11396. <if test="qcResultShortPageVO.chTimeStart != null ">
  11397. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11398. </if>
  11399. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11400. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11401. </if>
  11402. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11403. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11404. </if>
  11405. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11406. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11407. </if>
  11408. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11409. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  11410. </if>
  11411. <if test="qcResultShortPageVO.casesEntryId != null ">
  11412. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  11413. </if>
  11414. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11415. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  11416. </if>
  11417. <if test="qcResultShortPageVO.casesId != null">
  11418. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  11419. </if>
  11420. )f1,
  11421. (SELECT
  11422. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  11423. t.behDeptId,
  11424. t.behDeptName
  11425. FROM
  11426. (SELECT DISTINCT
  11427. t1.hospital_id AS hospitalId,
  11428. t1.behospital_code AS behospitalCode,
  11429. t1.bed_code AS bedCode,
  11430. t1.LEVEL AS LEVEL,
  11431. t1.grade_type AS gradeType,
  11432. t1.score_res AS scoreRes,
  11433. t1.NAME AS NAME,
  11434. t1.sex AS sex,
  11435. t1.beh_dept_id AS behDeptId,
  11436. t1.beh_dept_name AS behDeptName,
  11437. t1.birthday AS birthday,
  11438. t1.behospital_date AS behospitalDate,
  11439. t1.leave_hospital_date AS leaveHospitalDate,
  11440. t1.placefile_date AS placefileDate,
  11441. t1.gmt_create AS gradeTime,
  11442. t1.diagnose,
  11443. t1.doctorId,
  11444. t1.ward_name AS wardName,
  11445. t2.age,
  11446. t1.file_code AS fileCode,
  11447. t1.checkStatus,
  11448. t1.mrStatus,
  11449. t1.chName,
  11450. t1.mrName,
  11451. t1.chTime,
  11452. t1.mrTime
  11453. FROM
  11454. (
  11455. SELECT DISTINCT
  11456. tt1.*
  11457. FROM
  11458. (SELECT
  11459. be.*,
  11460. ifnull(mci.status,0) AS checkStatus,
  11461. ifnull(hm_mci.status,0) AS mrStatus,
  11462. mci.check_name as chName,
  11463. hm_mci.check_name as mrName,
  11464. f.doctor_id as doctorId,
  11465. mci.gmt_create as chTime,
  11466. hm_mci.gmt_create as mrTime
  11467. FROM
  11468. (
  11469. SELECT DISTINCT
  11470. a.hospital_id,
  11471. a.behospital_code,
  11472. a.bed_code,
  11473. a.file_code,
  11474. b.LEVEL,
  11475. b.grade_type,
  11476. b.score_res,
  11477. a.NAME,
  11478. a.sex,
  11479. a.beh_dept_id,
  11480. a.beh_dept_name,
  11481. a.birthday,
  11482. a.behospital_date,
  11483. a.leave_hospital_date,
  11484. a.diagnose,
  11485. a.placefile_date,
  11486. a.ward_name,
  11487. case
  11488. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11489. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11490. e.director_doctor != '' and e.director_doctor is not null
  11491. then e.director_doctor
  11492. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11493. (e.director_doctor = '' or e.director_doctor is null) and
  11494. e.behospital_doctor != '' and e.behospital_doctor is not null
  11495. then e.behospital_doctor end as doctor_name,
  11496. b.gmt_create
  11497. FROM
  11498. med_behospital_info a,
  11499. med_qcresult_info b,
  11500. med_qcresult_detail c,
  11501. qc_cases_entry d,
  11502. med_home_page e
  11503. WHERE
  11504. a.is_deleted = 'N'
  11505. AND b.is_deleted = 'N'
  11506. AND c.is_deleted = 'N'
  11507. AND d.is_deleted = 'N'
  11508. AND e.is_deleted = 'N'
  11509. AND a.hospital_id = b.hospital_id
  11510. AND a.hospital_id = c.hospital_id
  11511. AND a.hospital_id = e.hospital_id
  11512. AND a.behospital_code = b.behospital_code
  11513. AND a.behospital_code = c.behospital_code
  11514. AND a.behospital_code = e.behospital_code
  11515. AND c.cases_id = d.cases_id
  11516. AND c.cases_entry_id = d.id
  11517. AND a.qc_type_id != 0
  11518. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11519. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11520. </if>
  11521. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11522. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11523. </if>
  11524. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11525. <if test="qcResultShortPageVO.startDate != null ">
  11526. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11527. </if>
  11528. <if test="qcResultShortPageVO.endDate != null ">
  11529. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11530. </if>
  11531. </if>
  11532. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11533. <if test="qcResultShortPageVO.startDate != null ">
  11534. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11535. </if>
  11536. <if test="qcResultShortPageVO.endDate != null">
  11537. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11538. </if>
  11539. </if>
  11540. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11541. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11542. </if>
  11543. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11544. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11545. </if>
  11546. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  11547. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  11548. </if>
  11549. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11550. AND b.`level` = #{qcResultShortPageVO.level}
  11551. </if>
  11552. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11553. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11554. </if>
  11555. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11556. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11557. </if>
  11558. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11559. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11560. </if>
  11561. <if test="qcResultShortPageVO.casesEntryId != null ">
  11562. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11563. </if>
  11564. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11565. AND d.cases_name = #{qcResultShortPageVO.casesName}
  11566. </if>
  11567. <if test="qcResultShortPageVO.casesId != null">
  11568. AND d.cases_id = #{qcResultShortPageVO.casesId}
  11569. </if>
  11570. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11571. AND(case
  11572. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11573. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11574. e.director_doctor != '' and e.director_doctor is not null
  11575. then e.director_doctor
  11576. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11577. (e.director_doctor = '' or e.director_doctor is null) and
  11578. e.behospital_doctor != '' and e.behospital_doctor is not null
  11579. then e.behospital_doctor end ) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11580. </if>
  11581. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  11582. AND(case
  11583. when e.attending_doctor != '' and e.attending_doctor is not null then '主治医师'
  11584. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11585. e.director_doctor != '' and e.director_doctor is not null
  11586. then '主任医师'
  11587. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11588. (e.director_doctor = '' or e.director_doctor is null) and
  11589. e.behospital_doctor != '' and e.behospital_doctor is not null
  11590. then '住院医师' end) = #{qcResultShortPageVO.professor}
  11591. </if>
  11592. <if test="qcResultShortPageVO.isReject != null">
  11593. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11594. </if>
  11595. <if test="qcResultShortPageVO.ruleType != null">
  11596. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11597. </if>
  11598. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  11599. AND TIMESTAMPDIFF(
  11600. DAY,
  11601. DATE( a.behospital_date ),
  11602. DATE( a.leave_hospital_date ))> 30
  11603. </if>
  11604. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  11605. AND TIMESTAMPDIFF(
  11606. DAY,
  11607. DATE( a.behospital_date ),
  11608. DATE( a.leave_hospital_date ))> 31
  11609. </if>
  11610. )be
  11611. left join med_check_info mci
  11612. on mci.is_deleted = 'N'
  11613. and mci.check_type in(0,2)
  11614. and be.hospital_id = mci.hospital_id
  11615. and be.behospital_code = mci.behospital_code
  11616. left join med_check_info hm_mci
  11617. on hm_mci.is_deleted = 'N'
  11618. and hm_mci.check_type = 1
  11619. and be.hospital_id = hm_mci.hospital_id
  11620. and be.behospital_code = hm_mci.behospital_code
  11621. LEFT JOIN bas_doctor_info f
  11622. on be.hospital_id = f.hospital_id
  11623. and be.doctor_name = f.name
  11624. AND f.is_deleted = 'N'
  11625. )tt1
  11626. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  11627. ,med_medical_record tt2
  11628. WHERE
  11629. tt2.is_deleted = 'N'
  11630. AND tt1.hospital_id = tt2.hospital_id
  11631. AND tt1.behospital_code = tt2.behospital_code
  11632. AND tt2.mode_id = 30
  11633. </if>
  11634. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  11635. ,med_crisis_info tt2
  11636. WHERE
  11637. tt2.is_deleted = 'N'
  11638. AND tt1.hospital_id = tt2.hospital_id
  11639. AND tt1.behospital_code = tt2.behospital_code
  11640. </if>
  11641. ) t1
  11642. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  11643. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11644. AND t1.behospital_code = t2.behospital_code
  11645. AND t2.is_deleted = 'N'
  11646. </if>
  11647. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  11648. , med_home_page t2
  11649. , med_home_operation_info t3
  11650. WHERE t1.hospital_id = t2.hospital_id
  11651. AND t1.behospital_code = t2.behospital_code
  11652. AND t2.home_page_id = t3.home_page_id
  11653. AND t2.is_deleted = 'N'
  11654. AND t3.is_deleted = 'N'
  11655. </if>
  11656. ) t
  11657. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11658. AND t.hospitalId = qi.hospital_id
  11659. AND t.behospitalCode = qi.behospital_code
  11660. where 1=1
  11661. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11662. AND t.doctorId = #{qcResultShortPageVO.doctorId}
  11663. </if>
  11664. <if test="qcResultShortPageVO.checkStatus != null">
  11665. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11666. </if>
  11667. <if test="qcResultShortPageVO.mrStatus != null">
  11668. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11669. </if>
  11670. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11671. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11672. </if>
  11673. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11674. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11675. </if>
  11676. <if test="qcResultShortPageVO.chTimeStart != null ">
  11677. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11678. </if>
  11679. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11680. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11681. </if>
  11682. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11683. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11684. </if>
  11685. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11686. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11687. </if>
  11688. GROUP BY
  11689. t.behDeptId,
  11690. t.behDeptName
  11691. )f2
  11692. WHERE
  11693. f1.behDeptId = f2.behDeptId
  11694. AND f1.behDeptName = f2.behDeptName
  11695. )m
  11696. </select>
  11697. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  11698. <result column="deptName" property="deptName"/>
  11699. <result column="deptId" property="deptId"/>
  11700. <result column="doctorGroup" property="doctorGroup"/>
  11701. <result column="doctorName" property="doctorName"/>
  11702. <result column="entry_2658_num" property="entry_2658_num"/>
  11703. <result column="entry_2686_num" property="entry_2686_num"/>
  11704. <result column="entry_2657_num" property="entry_2657_num"/>
  11705. <result column="entry_3010_num" property="entry_3010_num"/>
  11706. <result column="entry_2655_num" property="entry_2655_num"/>
  11707. <result column="entry_2654_num" property="entry_2654_num"/>
  11708. <result column="entry_2852_num" property="entry_2852_num"/>
  11709. <result column="entry_2287_num" property="entry_2287_num"/>
  11710. <result column="entry_3025_num" property="entry_3025_num"/>
  11711. <result column="entry_2170_num" property="entry_2170_num"/>
  11712. <result column="entry_2930_num" property="entry_2930_num"/>
  11713. <result column="entry_2900_num" property="entry_2900_num"/>
  11714. <result column="entry_2229_num" property="entry_2229_num"/>
  11715. <result column="entry_2217_num" property="entry_2217_num"/>
  11716. <result column="entry_2218_num" property="entry_2218_num"/>
  11717. <result column="entry_2220_num" property="entry_2220_num"/>
  11718. <result column="entry_2486_num" property="entry_2486_num"/>
  11719. <result column="entry_3063_num" property="entry_3063_num"/>
  11720. <result column="entry_3062_num" property="entry_3062_num"/>
  11721. <result column="entry_2495_num" property="entry_2495_num"/>
  11722. </resultMap>
  11723. <!-- 病历稽查表-->
  11724. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  11725. SELECT
  11726. a.beh_dept_id AS deptId,
  11727. a.beh_dept_name AS deptName,
  11728. a.doctor_name as doctorGroup,
  11729. a.doctor_name as doctorName,
  11730. sum(c.cases_entry_id = 2658) as entry_2658_num,
  11731. sum(c.cases_entry_id = 2686) as entry_2686_num,
  11732. sum(c.cases_entry_id = 2657) as entry_2657_num,
  11733. sum(c.cases_entry_id = 3010) as entry_3010_num,
  11734. sum(c.cases_entry_id = 2655) as entry_2655_num,
  11735. sum(c.cases_entry_id = 2654) as entry_2654_num,
  11736. sum(c.cases_entry_id = 2852) as entry_2852_num,
  11737. sum(c.cases_entry_id = 2287) as entry_2287_num,
  11738. sum(c.cases_entry_id = 3025) as entry_3025_num,
  11739. sum(c.cases_entry_id = 2170) as entry_2170_num,
  11740. sum(c.cases_entry_id = 2930) as entry_2930_num,
  11741. sum(c.cases_entry_id = 2900) as entry_2900_num,
  11742. sum(c.cases_entry_id = 2229) as entry_2229_num,
  11743. sum(c.cases_entry_id = 2217) as entry_2217_num,
  11744. sum(c.cases_entry_id = 2218) as entry_2218_num,
  11745. sum(c.cases_entry_id = 2220) as entry_2220_num,
  11746. sum(c.cases_entry_id = 2486) as entry_2486_num,
  11747. sum(c.cases_entry_id = 3063) as entry_3063_num,
  11748. sum(c.cases_entry_id = 3062) as entry_3062_num,
  11749. sum(c.cases_entry_id = 2495) as entry_2495_num
  11750. FROM
  11751. med_behospital_info a,
  11752. med_qcresult_info b,
  11753. med_qcresult_detail c,
  11754. qc_cases_entry d,
  11755. bas_doctor_info e
  11756. WHERE
  11757. a.is_deleted = 'N'
  11758. AND b.is_deleted = 'N'
  11759. AND c.is_deleted = 'N'
  11760. AND d.is_deleted = 'N'
  11761. AND e.is_deleted = 'N'
  11762. AND a.hospital_id = b.hospital_id
  11763. AND a.hospital_id = c.hospital_id
  11764. AND a.hospital_id = e.hospital_id
  11765. AND a.behospital_code = b.behospital_code
  11766. AND a.behospital_code = c.behospital_code
  11767. AND a.beh_dept_id = e.dept_id
  11768. AND c.cases_entry_id = d.id
  11769. and a.doctor_id=e.doctor_id
  11770. and e.group_id is not NULL
  11771. AND LENGTH(e.group_id)>0
  11772. AND a.qc_type_id != 0
  11773. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11774. and a.is_placefile = #{filterVO.isPlacefile}
  11775. </if>
  11776. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11777. AND a.hospital_id = #{filterVO.hospitalId}
  11778. </if>
  11779. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11780. <if test="filterVO.startDate != null ">
  11781. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11782. </if>
  11783. <if test="filterVO.endDate != null ">
  11784. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11785. </if>
  11786. </if>
  11787. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11788. <if test="filterVO.startDate != null ">
  11789. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11790. </if>
  11791. <if test="filterVO.endDate != null ">
  11792. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11793. </if>
  11794. </if>
  11795. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11796. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  11797. </if>
  11798. GROUP BY
  11799. a.beh_dept_id,
  11800. e.group_id,
  11801. a.doctor_id
  11802. </select>
  11803. <!-- 病历稽查表-科室-->
  11804. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  11805. SELECT
  11806. a.beh_dept_id AS deptId,
  11807. a.beh_dept_name AS deptName,
  11808. a.doctor_name as doctorName,
  11809. a.doctor_name as doctorGroup,
  11810. sum(c.cases_entry_id = 2658) as entry_2658_num,
  11811. sum(c.cases_entry_id = 2686) as entry_2686_num,
  11812. sum(c.cases_entry_id = 2657) as entry_2657_num,
  11813. sum(c.cases_entry_id = 3010) as entry_3010_num,
  11814. sum(c.cases_entry_id = 2655) as entry_2655_num,
  11815. sum(c.cases_entry_id = 2654) as entry_2654_num,
  11816. sum(c.cases_entry_id = 2852) as entry_2852_num,
  11817. sum(c.cases_entry_id = 2287) as entry_2287_num,
  11818. sum(c.cases_entry_id = 3025) as entry_3025_num,
  11819. sum(c.cases_entry_id = 2170) as entry_2170_num,
  11820. sum(c.cases_entry_id = 2930) as entry_2930_num,
  11821. sum(c.cases_entry_id = 2900) as entry_2900_num,
  11822. sum(c.cases_entry_id = 2229) as entry_2229_num,
  11823. sum(c.cases_entry_id = 2217) as entry_2217_num,
  11824. sum(c.cases_entry_id = 2218) as entry_2218_num,
  11825. sum(c.cases_entry_id = 2220) as entry_2220_num,
  11826. sum(c.cases_entry_id = 2486) as entry_2486_num,
  11827. sum(c.cases_entry_id = 3063) as entry_3063_num,
  11828. sum(c.cases_entry_id = 3062) as entry_3062_num,
  11829. sum(c.cases_entry_id = 2495) as entry_2495_num
  11830. FROM
  11831. med_behospital_info a,
  11832. med_qcresult_info b,
  11833. med_qcresult_detail c,
  11834. qc_cases_entry d,
  11835. bas_doctor_info e,
  11836. sys_user_dept f
  11837. WHERE
  11838. a.is_deleted = 'N'
  11839. AND b.is_deleted = 'N'
  11840. AND c.is_deleted = 'N'
  11841. AND d.is_deleted = 'N'
  11842. AND e.is_deleted = 'N'
  11843. AND f.is_deleted = 'N'
  11844. AND a.hospital_id = b.hospital_id
  11845. AND a.hospital_id = c.hospital_id
  11846. AND a.hospital_id = e.hospital_id
  11847. AND a.hospital_id = f.hospital_id
  11848. AND a.behospital_code = b.behospital_code
  11849. AND a.behospital_code = c.behospital_code
  11850. AND a.beh_dept_id = f.dept_id
  11851. AND c.cases_entry_id = d.id
  11852. and a.doctor_id=e.doctor_id
  11853. and e.group_id is not NULL
  11854. AND LENGTH(e.group_id)>0
  11855. AND a.qc_type_id != 0
  11856. <if test="filterVO.userId!=null">
  11857. AND f.user_id = #{filterVO.userId}
  11858. </if>
  11859. <if test="filterVO.name != null and filterVO.name != ''">
  11860. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11861. </if>
  11862. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11863. and a.is_placefile = #{filterVO.isPlacefile}
  11864. </if>
  11865. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11866. AND a.hospital_id = #{filterVO.hospitalId}
  11867. </if>
  11868. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11869. <if test="filterVO.startDate != null ">
  11870. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11871. </if>
  11872. <if test="filterVO.endDate != null ">
  11873. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11874. </if>
  11875. </if>
  11876. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11877. <if test="filterVO.startDate != null ">
  11878. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11879. </if>
  11880. <if test="filterVO.endDate != null ">
  11881. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11882. </if>
  11883. </if>
  11884. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11885. AND a.beh_dept_name = #{filterVO.deptName}
  11886. </if>
  11887. GROUP BY
  11888. a.beh_dept_id,
  11889. e.group_id,
  11890. a.doctor_name
  11891. </select>
  11892. <!-- 病历稽查表最新sql、id&&name-->
  11893. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  11894. SELECT
  11895. d.id,
  11896. d.name
  11897. from
  11898. qc_cases_entry d
  11899. where
  11900. 1=1
  11901. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  11902. and d.id in
  11903. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  11904. '${item}'
  11905. </foreach>
  11906. </if>
  11907. </select>
  11908. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  11909. <result column="deptName" property="deptName"/>
  11910. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  11911. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  11912. <result column="doctorName" property="doctorName"/>
  11913. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  11914. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  11915. <result column="RYJLW_24" property="ryjlw_24"/>
  11916. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  11917. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  11918. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  11919. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  11920. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  11921. <result column="QJJLW_6H" property="qjjlw_6h"/>
  11922. <result column="HZJLW_24H" property="hzjlw_24h"/>
  11923. <result column="SQTLXJW" property="sqtlxjw"/>
  11924. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  11925. <result column="XHSCW_30M" property="xhscw_30m"/>
  11926. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  11927. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  11928. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  11929. <result column="ZKJLW_24" property="zkjlw_24"/>
  11930. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  11931. <result column="SXHWJL" property="sxhwjl"/>
  11932. <result column="SXPJW_24" property="sxpjw_24"/>
  11933. <result column="WJZWJL" property="wjzwjl"/>
  11934. <result column="WYWWCXJ" property="wywwcxj"/>
  11935. </collection>
  11936. </collection>
  11937. </resultMap>
  11938. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  11939. <result column="deptName" property="deptName"/>
  11940. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  11941. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  11942. <result column="doctorGroup" property="doctorGroup"/>
  11943. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  11944. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  11945. <result column="doctorName" property="doctorName"/>
  11946. <result column="RYJLW_24" property="ryjlw_24"/>
  11947. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  11948. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  11949. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  11950. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  11951. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  11952. <result column="QJJLW_6H" property="qjjlw_6h"/>
  11953. <result column="HZJLW_24H" property="hzjlw_24h"/>
  11954. <result column="SQTLXJW" property="sqtlxjw"/>
  11955. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  11956. <result column="XHSCW_30M" property="xhscw_30m"/>
  11957. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  11958. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  11959. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  11960. <result column="ZKJLW_24" property="zkjlw_24"/>
  11961. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  11962. <result column="SXHWJL" property="sxhwjl"/>
  11963. <result column="SXPJW_24" property="sxpjw_24"/>
  11964. <result column="WJZWJL" property="wjzwjl"/>
  11965. <result column="WYWWCXJ" property="wywwcxj"/>
  11966. </collection>
  11967. </collection>
  11968. </resultMap>
  11969. <!-- 病历稽查表最新导出-->
  11970. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  11971. SELECT
  11972. a.beh_dept_id AS deptId,
  11973. a.beh_dept_name AS deptName,
  11974. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  11975. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  11976. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  11977. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  11978. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  11979. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  11980. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  11981. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  11982. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  11983. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  11984. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  11985. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  11986. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  11987. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  11988. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  11989. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  11990. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  11991. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  11992. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  11993. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  11994. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  11995. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  11996. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  11997. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  11998. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  11999. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  12000. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  12001. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  12002. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  12003. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  12004. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  12005. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  12006. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  12007. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  12008. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  12009. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  12010. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  12011. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  12012. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  12013. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  12014. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  12015. FROM
  12016. med_behospital_info a,
  12017. med_qcresult_info b,
  12018. med_qcresult_detail c,
  12019. qc_cases_entry d,
  12020. bas_doctor_info e
  12021. WHERE
  12022. a.is_deleted = 'N'
  12023. AND b.is_deleted = 'N'
  12024. AND c.is_deleted = 'N'
  12025. AND d.is_deleted = 'N'
  12026. AND e.is_deleted = 'N'
  12027. AND a.hospital_id = b.hospital_id
  12028. AND a.hospital_id = c.hospital_id
  12029. AND a.hospital_id = e.hospital_id
  12030. AND a.behospital_code = b.behospital_code
  12031. AND a.behospital_code = c.behospital_code
  12032. AND a.beh_dept_id = e.dept_id
  12033. AND c.cases_entry_id = d.id
  12034. and a.doctor_id=e.doctor_id
  12035. and e.group_id is not NULL
  12036. AND LENGTH(e.group_id)>0
  12037. AND a.qc_type_id != 0
  12038. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  12039. and a.is_placefile = #{filterVO.isPlacefile}
  12040. </if>
  12041. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  12042. AND a.hospital_id = #{filterVO.hospitalId}
  12043. </if>
  12044. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  12045. <if test="filterVO.startDate != null ">
  12046. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  12047. </if>
  12048. <if test="filterVO.endDate != null ">
  12049. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  12050. </if>
  12051. </if>
  12052. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  12053. <if test="filterVO.startDate != null ">
  12054. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  12055. </if>
  12056. <if test="filterVO.endDate != null ">
  12057. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  12058. </if>
  12059. </if>
  12060. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  12061. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  12062. </if>
  12063. GROUP BY
  12064. a.beh_dept_id,
  12065. e.group_id
  12066. </select>
  12067. <!-- 病历稽查表最新导出-->
  12068. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  12069. SELECT
  12070. a.beh_dept_id AS deptId,
  12071. a.beh_dept_name AS deptName,
  12072. a.doctor_name as doctorGroup,
  12073. a.doctor_name as doctorName,
  12074. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  12075. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  12076. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  12077. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  12078. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  12079. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  12080. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  12081. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  12082. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  12083. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  12084. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  12085. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  12086. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  12087. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  12088. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  12089. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  12090. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  12091. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  12092. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  12093. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  12094. FROM
  12095. med_behospital_info a,
  12096. med_qcresult_info b,
  12097. med_qcresult_detail c,
  12098. qc_cases_entry d,
  12099. bas_doctor_info e,
  12100. sys_user_dept f
  12101. WHERE
  12102. a.is_deleted = 'N'
  12103. AND b.is_deleted = 'N'
  12104. AND c.is_deleted = 'N'
  12105. AND d.is_deleted = 'N'
  12106. AND e.is_deleted = 'N'
  12107. AND f.is_deleted = 'N'
  12108. AND a.hospital_id = b.hospital_id
  12109. AND a.hospital_id = c.hospital_id
  12110. AND a.hospital_id = e.hospital_id
  12111. AND a.hospital_id = f.hospital_id
  12112. AND a.behospital_code = b.behospital_code
  12113. AND a.behospital_code = c.behospital_code
  12114. AND a.beh_dept_id = f.dept_id
  12115. AND c.cases_entry_id = d.id
  12116. and a.doctor_id=e.doctor_id
  12117. and e.group_id is not NULL
  12118. AND LENGTH(e.group_id)>0
  12119. AND a.qc_type_id != 0
  12120. <if test="filterVO.userId!=null">
  12121. AND f.user_id = #{filterVO.userId}
  12122. </if>
  12123. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  12124. and a.is_placefile = #{filterVO.isPlacefile}
  12125. </if>
  12126. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  12127. AND a.hospital_id = #{filterVO.hospitalId}
  12128. </if>
  12129. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  12130. <if test="filterVO.startDate != null ">
  12131. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  12132. </if>
  12133. <if test="filterVO.endDate != null ">
  12134. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  12135. </if>
  12136. </if>
  12137. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  12138. <if test="filterVO.startDate != null ">
  12139. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  12140. </if>
  12141. <if test="filterVO.endDate != null ">
  12142. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  12143. </if>
  12144. </if>
  12145. <if test="filterVO.name != null and filterVO.name != ''">
  12146. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  12147. </if>
  12148. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  12149. AND a.beh_dept_name = #{filterVO.deptName}
  12150. </if>
  12151. GROUP BY
  12152. a.beh_dept_id,
  12153. e.group_id,
  12154. a.doctor_name
  12155. </select>
  12156. <!-- 未整改病历统计-->
  12157. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  12158. SELECT
  12159. a.beh_dept_id AS deptId,
  12160. a.beh_dept_name AS deptName,
  12161. d.id AS casesEntryId,
  12162. d.NAME AS casesEntryName,
  12163. count(*) AS casesEntryNum
  12164. FROM
  12165. med_behospital_info a,
  12166. med_qcresult_info b,
  12167. med_qcresult_detail c,
  12168. qc_cases_entry d
  12169. WHERE
  12170. a.is_deleted = 'N'
  12171. AND b.is_deleted = 'N'
  12172. AND c.is_deleted = 'N'
  12173. AND d.is_deleted = 'N'
  12174. AND a.hospital_id = b.hospital_id
  12175. AND a.hospital_id = c.hospital_id
  12176. AND a.behospital_code = b.behospital_code
  12177. AND a.behospital_code = c.behospital_code
  12178. AND c.cases_entry_id = d.id
  12179. AND a.qc_type_id != 0
  12180. <if test="isPlacefile != null and isPlacefile != ''">
  12181. and a.is_placefile = #{isPlacefile}
  12182. </if>
  12183. <if test="hospitalId != null and hospitalId != ''">
  12184. AND a.hospital_id = #{hospitalId}
  12185. </if>
  12186. <if test="isPlacefile != null and isPlacefile == 0">
  12187. <if test="startDate != null ">
  12188. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12189. </if>
  12190. <if test="endDate != null ">
  12191. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12192. </if>
  12193. </if>
  12194. <if test="isPlacefile != null and isPlacefile == 1">
  12195. <if test="startDate != null ">
  12196. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12197. </if>
  12198. <if test="endDate != null ">
  12199. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12200. </if>
  12201. </if>
  12202. <if test="deptName != null and deptName != ''">
  12203. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  12204. </if>
  12205. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  12206. AND c.cases_entry_id IN
  12207. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  12208. #{item}
  12209. </foreach>
  12210. </if>
  12211. GROUP BY
  12212. a.beh_dept_id,
  12213. a.beh_dept_name,
  12214. c.cases_entry_id,
  12215. d.NAME
  12216. </select>
  12217. <!-- 未整改病历统计-科室-->
  12218. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  12219. SELECT
  12220. a.beh_dept_id AS deptId,
  12221. a.beh_dept_name AS deptName,
  12222. a.doctor_id as doctorId,
  12223. a.doctor_name as doctorName,
  12224. d.id AS casesEntryId,
  12225. d.NAME AS casesEntryName,
  12226. count(*) AS casesEntryNum
  12227. FROM
  12228. med_behospital_info a,
  12229. med_qcresult_info b,
  12230. med_qcresult_detail c,
  12231. qc_cases_entry d,
  12232. sys_user_dept f
  12233. WHERE
  12234. a.is_deleted = 'N'
  12235. AND b.is_deleted = 'N'
  12236. AND c.is_deleted = 'N'
  12237. AND d.is_deleted = 'N'
  12238. AND f.is_deleted = 'N'
  12239. AND a.hospital_id = b.hospital_id
  12240. AND a.hospital_id = c.hospital_id
  12241. AND a.hospital_id = f.hospital_id
  12242. AND a.behospital_code = b.behospital_code
  12243. AND a.behospital_code = c.behospital_code
  12244. AND a.beh_dept_id = f.dept_id
  12245. AND c.cases_entry_id = d.id
  12246. AND a.qc_type_id != 0
  12247. <if test="userId!=null">
  12248. AND f.user_id = #{userId}
  12249. </if>
  12250. <if test="isPlacefile != null and isPlacefile != ''">
  12251. and a.is_placefile = #{isPlacefile}
  12252. </if>
  12253. <if test="hospitalId != null and hospitalId != ''">
  12254. AND a.hospital_id = #{hospitalId}
  12255. </if>
  12256. <if test="isPlacefile != null and isPlacefile == 0">
  12257. <if test="startDate != null ">
  12258. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12259. </if>
  12260. <if test="endDate != null ">
  12261. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12262. </if>
  12263. </if>
  12264. <if test="isPlacefile != null and isPlacefile == 1">
  12265. <if test="startDate != null ">
  12266. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12267. </if>
  12268. <if test="endDate != null ">
  12269. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12270. </if>
  12271. </if>
  12272. <if test="deptName != null and deptName != ''">
  12273. AND a.beh_dept_name= #{deptName}
  12274. </if>
  12275. <if test="doctorName != null and doctorName != ''">
  12276. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  12277. </if>
  12278. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  12279. AND c.cases_entry_id IN
  12280. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  12281. #{item}
  12282. </foreach>
  12283. </if>
  12284. GROUP BY
  12285. a.doctor_id,
  12286. a.doctor_name,
  12287. c.cases_entry_id,
  12288. d.NAME
  12289. </select>
  12290. <!-- 不合格/合格数病历号(内页)科室-->
  12291. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  12292. SELECT t.*
  12293. FROM
  12294. (SELECT DISTINCT
  12295. t1.hospital_id AS hospitalId,
  12296. t1.behospital_code AS behospitalCode,
  12297. t1.bed_code AS bedCode,
  12298. t1.LEVEL AS LEVEL,
  12299. t1.grade_type AS gradeType,
  12300. t1.score_res AS scoreRes,
  12301. t1.scoreBn,
  12302. t1.NAME AS NAME,
  12303. t1.sex AS sex,
  12304. t1.beh_dept_id AS behDeptId,
  12305. t1.beh_dept_name AS behDeptName,
  12306. t1.doctor_id AS doctorId,
  12307. t1.doctor_name AS doctorName,
  12308. t1.beh_doctor_id AS behDoctorId,
  12309. t1.beh_doctor_name AS behDoctorName,
  12310. t1.director_doctor_id AS directorDoctorId,
  12311. t1.director_doctor_name AS directorDoctorName,
  12312. t1.birthday AS birthday,
  12313. t1.behospital_date AS behospitalDate,
  12314. t1.leave_hospital_date AS leaveHospitalDate,
  12315. t1.placefile_date AS placefileDate,
  12316. t1.gmt_create AS gradeTime,
  12317. t1.diagnose,
  12318. t1.ward_name AS wardName,
  12319. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12320. t1.file_code AS fileCode,
  12321. t1.checkStatus,
  12322. t1.mrStatus,
  12323. t1.chName,
  12324. t1.mrName,
  12325. t1.chTime,
  12326. t1.mrTime,
  12327. t1.is_daytime as isDaytime
  12328. FROM
  12329. (SELECT
  12330. be.*,
  12331. b.LEVEL,
  12332. b.grade_type,
  12333. b.score_res,
  12334. b.gmt_create,
  12335. ifnull(mci.status,0) AS checkStatus,
  12336. ifnull(hm_mci.status,0) AS mrStatus,
  12337. mci.check_name as chName,
  12338. hm_mci.check_name as mrName,
  12339. mci.gmt_create as chTime,
  12340. hm_mci.gmt_create as mrTime
  12341. FROM
  12342. (
  12343. SELECT DISTINCT
  12344. a.hospital_id,
  12345. a.behospital_code,
  12346. a.bed_code,
  12347. a.file_code,
  12348. e.score_res as scoreBn,
  12349. a.NAME,
  12350. a.sex,
  12351. a.beh_dept_id,
  12352. a.beh_dept_name,
  12353. a.birthday,
  12354. a.behospital_date,
  12355. a.leave_hospital_date,
  12356. a.doctor_id,
  12357. a.doctor_name,
  12358. a.beh_doctor_id,
  12359. a.beh_doctor_name,
  12360. a.director_doctor_id,
  12361. a.director_doctor_name,
  12362. a.diagnose,
  12363. a.placefile_date,
  12364. a.ward_name,
  12365. a.is_daytime
  12366. FROM
  12367. med_behospital_info a,
  12368. sys_user_dept c,
  12369. med_qcresult_cases e
  12370. WHERE
  12371. a.is_deleted = 'N'
  12372. AND c.is_deleted = 'N'
  12373. AND e.is_deleted = 'N'
  12374. AND a.hospital_id = c.hospital_id
  12375. AND a.hospital_id = e.hospital_id
  12376. AND a.beh_dept_id = c.dept_id
  12377. AND a.behospital_code = e.behospital_code
  12378. AND a.qc_type_id != 0
  12379. AND e.cases_id = 243
  12380. <if test="isDaytime != null and isDaytime != ''">
  12381. and a.is_daytime = #{isDaytime}
  12382. </if>
  12383. <if test="userId!=null">
  12384. AND c.user_id = #{userId}
  12385. </if>
  12386. <if test="deptName != null and deptName != ''">
  12387. and a.beh_dept_name = #{deptName}
  12388. </if>
  12389. <if test="deptClass != null and deptClass != ''">
  12390. and a.beh_dept_id = #{deptClass}
  12391. </if>
  12392. <if test="deptId != null and deptId != ''">
  12393. and a.beh_dept_id = #{deptId}
  12394. </if>
  12395. <if test="titleName != null and titleName != '' ">
  12396. <if test="titleName == '不合格数'">
  12397. AND e.`level`='不合格'
  12398. </if>
  12399. <if test="titleName == '合格数'">
  12400. AND e.`level`='合格'
  12401. </if>
  12402. </if>
  12403. <if test="isPlacefile != null and isPlacefile != ''">
  12404. and a.is_placefile = #{isPlacefile}
  12405. </if>
  12406. <if test="doctorName != null and doctorName != ''">
  12407. AND a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  12408. </if>
  12409. <if test="hospitalId != null and hospitalId != ''">
  12410. AND a.hospital_id = #{hospitalId}
  12411. </if>
  12412. <if test="isPlacefile != null and isPlacefile == 0">
  12413. <if test="startDate != null ">
  12414. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12415. </if>
  12416. <if test="endDate != null ">
  12417. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12418. </if>
  12419. </if>
  12420. <if test="isPlacefile != null and isPlacefile == 1">
  12421. <if test="startDate != null ">
  12422. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12423. </if>
  12424. <if test="endDate != null">
  12425. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12426. </if>
  12427. </if>
  12428. <if test="diagnose != null and diagnose != ''">
  12429. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  12430. </if>
  12431. <if test="behospitalCode != null and behospitalCode != ''">
  12432. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  12433. </if>
  12434. <if test="fileCode != null and fileCode != ''">
  12435. AND a.file_code LIKE CONCAT( '%', #{fileCode}, '%' )
  12436. </if>
  12437. <if test="fileCode != null and fileCode != ''">
  12438. AND a.file_code LIKE CONCAT( '%', #{fileCode}, '%' )
  12439. </if>
  12440. <if test="patName != null and patName != ''">
  12441. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  12442. </if>
  12443. <if test="doctorId != null and doctorId != ''">
  12444. AND a.doctor_id = #{doctorId}
  12445. </if>
  12446. )be
  12447. left join med_check_info mci
  12448. on mci.is_deleted = 'N'
  12449. and mci.check_type in(0,2)
  12450. and be.hospital_id = mci.hospital_id
  12451. and be.behospital_code = mci.behospital_code
  12452. left join med_check_info hm_mci
  12453. on hm_mci.is_deleted = 'N'
  12454. and hm_mci.check_type = 1
  12455. and be.hospital_id = hm_mci.hospital_id
  12456. and be.behospital_code = hm_mci.behospital_code
  12457. left join med_qcresult_info b
  12458. on b.is_deleted = 'N'
  12459. AND be.hospital_id = b.hospital_id
  12460. AND be.behospital_code = b.behospital_code
  12461. where
  12462. 1=1
  12463. <if test="level != null and level != ''">
  12464. AND b.`level` = #{level}
  12465. </if>
  12466. ) t1
  12467. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12468. AND t1.behospital_code = t2.behospital_code
  12469. AND t2.is_deleted = 'N'
  12470. ) t
  12471. where
  12472. 1=1
  12473. <if test="checkStatus != null">
  12474. AND t.checkStatus = #{checkStatus}
  12475. </if>
  12476. <if test="mrStatus != null">
  12477. AND t.mrStatus = #{mrStatus}
  12478. </if>
  12479. <if test="chName != null and chName!=''">
  12480. AND t.chName like concat('%', #{chName}, '%')
  12481. </if>
  12482. <if test="mrName != null and mrName!=''">
  12483. AND t.mrName like concat('%', #{mrName}, '%')
  12484. </if>
  12485. <if test="chTimeStart != null ">
  12486. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  12487. </if>
  12488. <if test="chTimeEnd != null ">
  12489. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  12490. </if>
  12491. <if test="mrTimeStart != null ">
  12492. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  12493. </if>
  12494. <if test="mrTimeEnd != null ">
  12495. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  12496. </if>
  12497. </select>
  12498. <!-- 不合格/合格数病历号(内页)全院-->
  12499. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12500. SELECT t.*
  12501. FROM
  12502. (SELECT DISTINCT
  12503. t1.hospital_id AS hospitalId,
  12504. t1.behospital_code AS behospitalCode,
  12505. t1.bed_code AS bedCode,
  12506. t1.LEVEL AS LEVEL,
  12507. t1.grade_type AS gradeType,
  12508. t1.score_res AS scoreRes,
  12509. t1.scoreBn,
  12510. t1.NAME AS NAME,
  12511. t1.sex AS sex,
  12512. t1.beh_dept_id AS behDeptId,
  12513. t1.beh_dept_name AS behDeptName,
  12514. t1.doctor_id AS doctorId,
  12515. t1.doctor_name AS doctorName,
  12516. t1.beh_doctor_id AS behDoctorId,
  12517. t1.beh_doctor_name AS behDoctorName,
  12518. t1.director_doctor_id AS directorDoctorId,
  12519. t1.director_doctor_name AS directorDoctorName,
  12520. t1.birthday AS birthday,
  12521. t1.behospital_date AS behospitalDate,
  12522. t1.leave_hospital_date AS leaveHospitalDate,
  12523. t1.placefile_date AS placefileDate,
  12524. t1.gmt_create AS gradeTime,
  12525. t1.diagnose,
  12526. t1.ward_name AS wardName,
  12527. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12528. t1.file_code AS fileCode,
  12529. t1.checkStatus,
  12530. t1.mrStatus,
  12531. t1.chName,
  12532. t1.mrName,
  12533. t1.chTime,
  12534. t1.mrTime,
  12535. t1.is_daytime as isDaytime
  12536. FROM
  12537. (SELECT
  12538. be.*,
  12539. b.LEVEL,
  12540. b.grade_type,
  12541. b.score_res,
  12542. b.gmt_create,
  12543. ifnull(mci.status,0) AS checkStatus,
  12544. ifnull(hm_mci.status,0) AS mrStatus,
  12545. mci.check_name as chName,
  12546. hm_mci.check_name as mrName,
  12547. mci.gmt_create as chTime,
  12548. hm_mci.gmt_create as mrTime
  12549. FROM
  12550. (
  12551. SELECT DISTINCT
  12552. a.hospital_id,
  12553. a.behospital_code,
  12554. a.bed_code,
  12555. a.file_code,
  12556. e.score_res as scoreBn,
  12557. a.NAME,
  12558. a.sex,
  12559. a.beh_dept_id,
  12560. a.beh_dept_name,
  12561. a.birthday,
  12562. a.behospital_date,
  12563. a.leave_hospital_date,
  12564. a.doctor_id,
  12565. a.doctor_name,
  12566. a.beh_doctor_id,
  12567. a.beh_doctor_name,
  12568. a.director_doctor_id,
  12569. a.director_doctor_name,
  12570. a.diagnose,
  12571. a.placefile_date,
  12572. a.ward_name,
  12573. a.is_daytime
  12574. FROM
  12575. med_behospital_info a,
  12576. med_qcresult_cases e
  12577. WHERE
  12578. a.is_deleted = 'N'
  12579. AND e.is_deleted = 'N'
  12580. AND a.hospital_id = e.hospital_id
  12581. AND a.behospital_code = e.behospital_code
  12582. AND a.qc_type_id != 0
  12583. AND e.cases_id = 243
  12584. <if test="qcResultPageVO.isDaytime != null and qcResultPageVO.isDaytime != ''">
  12585. and a.is_daytime = #{qcResultPageVO.isDaytime}
  12586. </if>
  12587. <if test="qcResultPageVO.titleName != null ">
  12588. <if test="qcResultPageVO.titleName == '不合格数'">
  12589. AND e.`level`='不合格'
  12590. </if>
  12591. <if test="qcResultPageVO.titleName == '合格数'">
  12592. AND e.`level`='合格'
  12593. </if>
  12594. </if>
  12595. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12596. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12597. </if>
  12598. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12599. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12600. </if>
  12601. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12602. <if test="qcResultPageVO.startDate != null ">
  12603. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12604. </if>
  12605. <if test="qcResultPageVO.endDate != null ">
  12606. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12607. </if>
  12608. </if>
  12609. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12610. <if test="qcResultPageVO.startDate != null ">
  12611. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12612. </if>
  12613. <if test="qcResultPageVO.endDate != null">
  12614. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12615. </if>
  12616. </if>
  12617. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12618. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12619. </if>
  12620. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12621. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  12622. </if>
  12623. <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
  12624. AND a.beh_dept_id = #{qcResultPageVO.deptId}
  12625. </if>
  12626. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12627. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12628. </if>
  12629. <if test="qcResultPageVO.fileCode != null and qcResultPageVO.fileCode != ''">
  12630. AND a.file_code LIKE CONCAT( '%', #{qcResultPageVO.fileCode}, '%' )
  12631. </if>
  12632. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12633. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12634. </if>
  12635. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12636. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12637. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12638. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  12639. </if>
  12640. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12641. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12642. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12643. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  12644. </if>
  12645. )be
  12646. left join med_check_info mci
  12647. on mci.is_deleted = 'N'
  12648. and mci.check_type in(0,2)
  12649. and be.hospital_id = mci.hospital_id
  12650. and be.behospital_code = mci.behospital_code
  12651. left join med_check_info hm_mci
  12652. on hm_mci.is_deleted = 'N'
  12653. and hm_mci.check_type = 1
  12654. and be.hospital_id = hm_mci.hospital_id
  12655. and be.behospital_code = hm_mci.behospital_code
  12656. left join med_qcresult_info b
  12657. on b.is_deleted = 'N'
  12658. AND be.hospital_id = b.hospital_id
  12659. AND be.behospital_code = b.behospital_code
  12660. where
  12661. 1=1
  12662. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  12663. AND b.`level` = #{qcResultPageVO.level}
  12664. </if>
  12665. ) t1
  12666. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12667. AND t1.behospital_code = t2.behospital_code
  12668. AND t2.is_deleted = 'N'
  12669. ) t
  12670. where
  12671. 1=1
  12672. <if test="qcResultPageVO.checkStatus != null">
  12673. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  12674. </if>
  12675. <if test="qcResultPageVO.mrStatus != null">
  12676. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  12677. </if>
  12678. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  12679. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  12680. </if>
  12681. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  12682. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  12683. </if>
  12684. <if test="qcResultPageVO.chTimeStart != null ">
  12685. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  12686. </if>
  12687. <if test="qcResultPageVO.chTimeEnd != null ">
  12688. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  12689. </if>
  12690. <if test="qcResultPageVO.mrTimeStart != null ">
  12691. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  12692. </if>
  12693. <if test="qcResultPageVO.mrTimeEnd != null ">
  12694. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  12695. </if>
  12696. </select>
  12697. <!-- 不合格/合格数病历号XY(内页)全院-->
  12698. <select id="badLevelXYPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12699. SELECT t.*
  12700. FROM
  12701. (SELECT DISTINCT
  12702. t1.hospital_id AS hospitalId,
  12703. t1.behospital_code AS behospitalCode,
  12704. t1.bed_code AS bedCode,
  12705. t1.LEVEL AS LEVEL,
  12706. t1.grade_type AS gradeType,
  12707. t1.score_res AS scoreRes,
  12708. t1.scoreBn,
  12709. t1.doctorName,
  12710. t1.doctorId,
  12711. t1.NAME AS NAME,
  12712. t1.sex AS sex,
  12713. t1.beh_dept_id AS behDeptId,
  12714. t1.beh_dept_name AS behDeptName,
  12715. t1.birthday AS birthday,
  12716. t1.behospital_date AS behospitalDate,
  12717. t1.leave_hospital_date AS leaveHospitalDate,
  12718. t1.placefile_date AS placefileDate,
  12719. t1.gmt_create AS gradeTime,
  12720. t1.diagnose,
  12721. t1.ward_name AS wardName,
  12722. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12723. t1.file_code AS fileCode,
  12724. t1.checkStatus,
  12725. t1.mrStatus,
  12726. t1.chName,
  12727. t1.mrName,
  12728. t1.chTime,
  12729. t1.mrTime
  12730. FROM
  12731. (SELECT
  12732. be.*,
  12733. b.LEVEL,
  12734. b.grade_type,
  12735. b.score_res,
  12736. b.gmt_create,
  12737. f.doctor_id as doctorId,
  12738. ifnull(mci.status,0) AS checkStatus,
  12739. ifnull(hm_mci.status,0) AS mrStatus,
  12740. mci.check_name as chName,
  12741. hm_mci.check_name as mrName,
  12742. mci.gmt_create as chTime,
  12743. hm_mci.gmt_create as mrTime
  12744. FROM
  12745. (
  12746. SELECT DISTINCT
  12747. a.hospital_id,
  12748. a.behospital_code,
  12749. a.bed_code,
  12750. a.file_code,
  12751. e.score_res as scoreBn,
  12752. a.NAME,
  12753. a.sex,
  12754. a.beh_dept_id,
  12755. a.beh_dept_name,
  12756. a.birthday,
  12757. a.behospital_date,
  12758. a.leave_hospital_date,
  12759. case
  12760. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  12761. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12762. b.director_doctor != '' and b.director_doctor is not null
  12763. then b.director_doctor
  12764. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12765. (b.director_doctor = '' or b.director_doctor is null) and
  12766. b.behospital_doctor != '' and b.behospital_doctor is not null
  12767. then b.behospital_doctor end as doctorName,
  12768. a.diagnose,
  12769. a.placefile_date,
  12770. a.ward_name
  12771. FROM
  12772. med_behospital_info a,
  12773. med_home_page b,
  12774. med_qcresult_cases e
  12775. WHERE
  12776. a.is_deleted = 'N'
  12777. AND b.is_deleted = 'N'
  12778. AND e.is_deleted = 'N'
  12779. AND a.hospital_id = b.hospital_id
  12780. AND a.hospital_id = e.hospital_id
  12781. AND a.behospital_code = b.behospital_code
  12782. AND a.behospital_code = e.behospital_code
  12783. AND a.qc_type_id != 0
  12784. AND e.cases_id = 243
  12785. <if test="qcResultPageVO.titleName != null ">
  12786. <if test="qcResultPageVO.titleName == '不合格数'">
  12787. AND e.`level`='不合格'
  12788. </if>
  12789. <if test="qcResultPageVO.titleName == '合格数'">
  12790. AND e.`level`='合格'
  12791. </if>
  12792. </if>
  12793. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12794. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12795. </if>
  12796. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12797. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12798. </if>
  12799. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12800. <if test="qcResultPageVO.startDate != null ">
  12801. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12802. </if>
  12803. <if test="qcResultPageVO.endDate != null ">
  12804. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12805. </if>
  12806. </if>
  12807. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12808. <if test="qcResultPageVO.startDate != null ">
  12809. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12810. </if>
  12811. <if test="qcResultPageVO.endDate != null">
  12812. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12813. </if>
  12814. </if>
  12815. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12816. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12817. </if>
  12818. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12819. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  12820. </if>
  12821. <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
  12822. AND a.beh_dept_id = #{qcResultPageVO.deptId}
  12823. </if>
  12824. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12825. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12826. </if>
  12827. <if test="qcResultPageVO.fileCode != null and qcResultPageVO.fileCode != ''">
  12828. AND a.file_code LIKE CONCAT( '%', #{qcResultPageVO.fileCode}, '%' )
  12829. </if>
  12830. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12831. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12832. </if>
  12833. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12834. AND (case
  12835. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  12836. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12837. b.director_doctor != '' and b.director_doctor is not null
  12838. then b.director_doctor
  12839. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12840. (b.director_doctor = '' or b.director_doctor is null) and
  12841. b.behospital_doctor != '' and b.behospital_doctor is not null
  12842. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12843. </if>
  12844. <if test="qcResultPageVO.professor != null and qcResultPageVO.professor != ''">
  12845. AND (case
  12846. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  12847. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12848. b.director_doctor != '' and b.director_doctor is not null
  12849. then '主任医师'
  12850. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12851. (b.director_doctor = '' or b.director_doctor is null) and
  12852. b.behospital_doctor != '' and b.behospital_doctor is not null
  12853. then '住院医师' end) = #{qcResultPageVO.professor}
  12854. </if>
  12855. )be
  12856. left join med_check_info mci
  12857. on mci.is_deleted = 'N'
  12858. and mci.check_type in(0,2)
  12859. and be.hospital_id = mci.hospital_id
  12860. and be.behospital_code = mci.behospital_code
  12861. left join med_check_info hm_mci
  12862. on hm_mci.is_deleted = 'N'
  12863. and hm_mci.check_type = 1
  12864. and be.hospital_id = hm_mci.hospital_id
  12865. and be.behospital_code = hm_mci.behospital_code
  12866. left join med_qcresult_info b
  12867. on b.is_deleted = 'N'
  12868. AND be.hospital_id = b.hospital_id
  12869. AND be.behospital_code = b.behospital_code
  12870. LEFT JOIN bas_doctor_info f
  12871. on be.hospital_id = f.hospital_id
  12872. and be.doctorName = f.name
  12873. AND f.is_deleted = 'N'
  12874. where
  12875. 1=1
  12876. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  12877. AND b.`level` = #{qcResultPageVO.level}
  12878. </if>
  12879. ) t1
  12880. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12881. AND t1.behospital_code = t2.behospital_code
  12882. AND t2.is_deleted = 'N'
  12883. ) t
  12884. where
  12885. 1=1
  12886. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12887. AND t.doctorId = #{qcResultPageVO.doctorId}
  12888. </if>
  12889. <if test="qcResultPageVO.checkStatus != null">
  12890. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  12891. </if>
  12892. <if test="qcResultPageVO.mrStatus != null">
  12893. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  12894. </if>
  12895. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  12896. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  12897. </if>
  12898. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  12899. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  12900. </if>
  12901. <if test="qcResultPageVO.chTimeStart != null ">
  12902. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  12903. </if>
  12904. <if test="qcResultPageVO.chTimeEnd != null ">
  12905. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  12906. </if>
  12907. <if test="qcResultPageVO.mrTimeStart != null ">
  12908. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  12909. </if>
  12910. <if test="qcResultPageVO.mrTimeEnd != null ">
  12911. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  12912. </if>
  12913. </select>
  12914. <!-- 未整改病历质控评分页(内页)-->
  12915. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12916. SELECT t.*
  12917. FROM
  12918. (SELECT DISTINCT
  12919. t1.hospital_id AS hospitalId,
  12920. t1.behospital_code AS behospitalCode,
  12921. t1.bed_code AS bedCode,
  12922. t1.LEVEL AS LEVEL,
  12923. t1.grade_type AS gradeType,
  12924. t1.score_res AS scoreRes,
  12925. t1.scoreBn,
  12926. t1.NAME AS NAME,
  12927. t1.sex AS sex,
  12928. t1.beh_dept_id AS behDeptId,
  12929. t1.beh_dept_name AS behDeptName,
  12930. t1.doctor_id AS doctorId,
  12931. t1.doctor_name AS doctorName,
  12932. t1.beh_doctor_id AS behDoctorId,
  12933. t1.beh_doctor_name AS behDoctorName,
  12934. t1.director_doctor_id AS directorDoctorId,
  12935. t1.director_doctor_name AS directorDoctorName,
  12936. t1.birthday AS birthday,
  12937. t1.behospital_date AS behospitalDate,
  12938. t1.leave_hospital_date AS leaveHospitalDate,
  12939. t1.placefile_date AS placefileDate,
  12940. t1.gmt_create AS gradeTime,
  12941. t1.diagnose,
  12942. t1.ward_name AS wardName,
  12943. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12944. t1.file_code AS fileCode,
  12945. t1.checkStatus,
  12946. t1.mrStatus,
  12947. t1.chName,
  12948. t1.mrName,
  12949. t1.chTime,
  12950. t1.mrTime,
  12951. t1.is_daytime as isDaytime
  12952. FROM
  12953. (SELECT
  12954. be.*,
  12955. ifnull(mci.status,0) AS checkStatus,
  12956. ifnull(hm_mci.status,0) AS mrStatus,
  12957. mci.check_name as chName,
  12958. e.score_res as scoreBn,
  12959. hm_mci.check_name as mrName,
  12960. mci.gmt_create as chTime,
  12961. hm_mci.gmt_create as mrTime
  12962. FROM
  12963. (
  12964. SELECT DISTINCT
  12965. a.hospital_id,
  12966. a.behospital_code,
  12967. a.bed_code,
  12968. a.file_code,
  12969. b.LEVEL,
  12970. b.grade_type,
  12971. b.score_res,
  12972. a.NAME,
  12973. a.sex,
  12974. a.beh_dept_id,
  12975. a.beh_dept_name,
  12976. a.birthday,
  12977. a.behospital_date,
  12978. a.leave_hospital_date,
  12979. a.doctor_id,
  12980. a.doctor_name,
  12981. a.beh_doctor_id,
  12982. a.beh_doctor_name,
  12983. a.director_doctor_id,
  12984. a.director_doctor_name,
  12985. a.diagnose,
  12986. a.placefile_date,
  12987. a.ward_name,
  12988. b.gmt_create,
  12989. a.is_daytime
  12990. FROM
  12991. med_behospital_info a,
  12992. med_qcresult_info b,
  12993. med_qcresult_detail c,
  12994. qc_cases_entry d
  12995. WHERE
  12996. a.is_deleted = 'N'
  12997. AND b.is_deleted = 'N'
  12998. AND c.is_deleted = 'N'
  12999. AND d.is_deleted = 'N'
  13000. AND a.hospital_id = b.hospital_id
  13001. AND a.hospital_id = c.hospital_id
  13002. AND a.behospital_code = b.behospital_code
  13003. AND a.behospital_code = c.behospital_code
  13004. AND c.cases_id = d.cases_id
  13005. AND c.cases_entry_id = d.id
  13006. AND a.qc_type_id != 0
  13007. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  13008. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  13009. </if>
  13010. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13011. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13012. </if>
  13013. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13014. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13015. </if>
  13016. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13017. <if test="qcResultShortPageVO.startDate != null ">
  13018. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13019. </if>
  13020. <if test="qcResultShortPageVO.endDate != null ">
  13021. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13022. </if>
  13023. </if>
  13024. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13025. <if test="qcResultShortPageVO.startDate != null ">
  13026. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13027. </if>
  13028. <if test="qcResultShortPageVO.endDate != null">
  13029. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13030. </if>
  13031. </if>
  13032. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13033. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13034. </if>
  13035. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13036. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13037. </if>
  13038. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13039. AND b.`level` = #{qcResultShortPageVO.level}
  13040. </if>
  13041. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13042. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13043. </if>
  13044. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  13045. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  13046. </if>
  13047. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13048. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13049. </if>
  13050. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13051. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13052. </if>
  13053. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13054. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13055. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13056. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13057. </if>
  13058. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13059. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13060. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13061. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13062. </if>
  13063. <if test="qcResultShortPageVO.casesEntryId != null ">
  13064. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13065. </if>
  13066. <if test="qcResultShortPageVO.isReject != null">
  13067. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13068. </if>
  13069. <if test="qcResultShortPageVO.ruleType != null">
  13070. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13071. </if>
  13072. )be
  13073. left join med_check_info mci
  13074. on mci.is_deleted = 'N'
  13075. and mci.check_type in(0,2)
  13076. and be.hospital_id = mci.hospital_id
  13077. and be.behospital_code = mci.behospital_code
  13078. left join med_check_info hm_mci
  13079. on hm_mci.is_deleted = 'N'
  13080. and hm_mci.check_type = 1
  13081. and be.hospital_id = hm_mci.hospital_id
  13082. and be.behospital_code = hm_mci.behospital_code
  13083. LEFT JOIN med_qcresult_cases e
  13084. on be.behospital_code = e.behospital_code
  13085. and be.hospital_id = e.hospital_id
  13086. AND e.is_deleted = 'N'
  13087. and e.cases_id = 243
  13088. ) t1
  13089. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13090. AND t1.behospital_code = t2.behospital_code
  13091. AND t2.is_deleted = 'N'
  13092. ) t
  13093. where 1=1
  13094. <if test="qcResultShortPageVO.checkStatus != null">
  13095. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13096. </if>
  13097. <if test="qcResultShortPageVO.mrStatus != null">
  13098. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13099. </if>
  13100. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13101. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13102. </if>
  13103. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13104. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13105. </if>
  13106. <if test="qcResultShortPageVO.chTimeStart != null ">
  13107. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13108. </if>
  13109. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13110. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13111. </if>
  13112. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13113. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13114. </if>
  13115. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13116. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13117. </if>
  13118. </select>
  13119. <!-- 未整改病历质控评分页-科室(内页)-->
  13120. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  13121. SELECT t.*
  13122. FROM
  13123. (SELECT DISTINCT
  13124. t1.hospital_id AS hospitalId,
  13125. t1.behospital_code AS behospitalCode,
  13126. t1.bed_code AS bedCode,
  13127. t1.LEVEL AS LEVEL,
  13128. t1.grade_type AS gradeType,
  13129. t1.score_res AS scoreRes,
  13130. t1.scoreBn,
  13131. t1.NAME AS NAME,
  13132. t1.sex AS sex,
  13133. t1.beh_dept_id AS behDeptId,
  13134. t1.beh_dept_name AS behDeptName,
  13135. t1.doctor_id AS doctorId,
  13136. t1.doctor_name AS doctorName,
  13137. t1.beh_doctor_id AS behDoctorId,
  13138. t1.beh_doctor_name AS behDoctorName,
  13139. t1.director_doctor_id AS directorDoctorId,
  13140. t1.director_doctor_name AS directorDoctorName,
  13141. t1.birthday AS birthday,
  13142. t1.behospital_date AS behospitalDate,
  13143. t1.leave_hospital_date AS leaveHospitalDate,
  13144. t1.placefile_date AS placefileDate,
  13145. t1.gmt_create AS gradeTime,
  13146. t1.diagnose,
  13147. t1.ward_name AS wardName,
  13148. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  13149. t1.file_code AS fileCode,
  13150. t1.checkStatus,
  13151. t1.mrStatus,
  13152. t1.chName,
  13153. t1.mrName,
  13154. t1.chTime,
  13155. t1.mrTime,
  13156. t1.is_daytime as isDaytime
  13157. FROM
  13158. (SELECT
  13159. be.*,
  13160. ifnull(mci.status,0) AS checkStatus,
  13161. ifnull(hm_mci.status,0) AS mrStatus,
  13162. mci.check_name as chName,
  13163. e.score_res as scoreBn,
  13164. hm_mci.check_name as mrName,
  13165. mci.gmt_create as chTime,
  13166. hm_mci.gmt_create as mrTime
  13167. FROM
  13168. (
  13169. SELECT DISTINCT
  13170. a.hospital_id,
  13171. a.behospital_code,
  13172. a.bed_code,
  13173. a.file_code,
  13174. b.LEVEL,
  13175. b.grade_type,
  13176. b.score_res,
  13177. a.NAME,
  13178. a.sex,
  13179. a.beh_dept_id,
  13180. a.beh_dept_name,
  13181. a.birthday,
  13182. a.behospital_date,
  13183. a.leave_hospital_date,
  13184. a.doctor_id,
  13185. a.doctor_name,
  13186. a.beh_doctor_id,
  13187. a.beh_doctor_name,
  13188. a.director_doctor_id,
  13189. a.director_doctor_name,
  13190. a.diagnose,
  13191. a.placefile_date,
  13192. a.ward_name,
  13193. b.gmt_create,
  13194. a.is_daytime
  13195. FROM
  13196. med_behospital_info a,
  13197. med_qcresult_info b,
  13198. med_qcresult_detail c,
  13199. qc_cases_entry d,
  13200. sys_user_dept f
  13201. WHERE
  13202. a.is_deleted = 'N'
  13203. AND b.is_deleted = 'N'
  13204. AND c.is_deleted = 'N'
  13205. AND d.is_deleted = 'N'
  13206. AND f.is_deleted = 'N'
  13207. AND a.hospital_id = b.hospital_id
  13208. AND a.hospital_id = c.hospital_id
  13209. AND a.hospital_id = f.hospital_id
  13210. AND a.behospital_code = b.behospital_code
  13211. AND a.behospital_code = c.behospital_code
  13212. AND c.cases_id = d.cases_id
  13213. AND a.beh_dept_id = f.dept_id
  13214. AND c.cases_entry_id = d.id
  13215. AND a.qc_type_id != 0
  13216. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  13217. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  13218. </if>
  13219. <if test="qcResultShortPageVO.userId!=null">
  13220. AND f.user_id = #{qcResultShortPageVO.userId}
  13221. </if>
  13222. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13223. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13224. </if>
  13225. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13226. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13227. </if>
  13228. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13229. <if test="qcResultShortPageVO.startDate != null ">
  13230. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13231. </if>
  13232. <if test="qcResultShortPageVO.endDate != null ">
  13233. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13234. </if>
  13235. </if>
  13236. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13237. <if test="qcResultShortPageVO.startDate != null ">
  13238. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13239. </if>
  13240. <if test="qcResultShortPageVO.endDate != null">
  13241. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13242. </if>
  13243. </if>
  13244. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13245. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13246. </if>
  13247. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13248. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13249. </if>
  13250. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13251. AND b.`level` = #{qcResultShortPageVO.level}
  13252. </if>
  13253. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13254. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13255. </if>
  13256. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  13257. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  13258. </if>
  13259. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13260. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13261. </if>
  13262. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13263. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13264. </if>
  13265. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13266. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13267. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13268. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13269. </if>
  13270. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13271. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13272. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13273. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13274. </if>
  13275. <if test="qcResultShortPageVO.casesEntryId != null ">
  13276. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13277. </if>
  13278. <if test="qcResultShortPageVO.isReject != null">
  13279. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13280. </if>
  13281. <if test="qcResultShortPageVO.ruleType != null">
  13282. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13283. </if>
  13284. )be
  13285. left join med_check_info mci
  13286. on mci.is_deleted = 'N'
  13287. and mci.check_type in(0,2)
  13288. and be.hospital_id = mci.hospital_id
  13289. and be.behospital_code = mci.behospital_code
  13290. left join med_check_info hm_mci
  13291. on hm_mci.is_deleted = 'N'
  13292. and hm_mci.check_type = 1
  13293. and be.hospital_id = hm_mci.hospital_id
  13294. and be.behospital_code = hm_mci.behospital_code
  13295. LEFT JOIN med_qcresult_cases e
  13296. on be.behospital_code = e.behospital_code
  13297. and be.hospital_id = e.hospital_id
  13298. AND e.is_deleted = 'N'
  13299. and e.cases_id = 243
  13300. ) t1
  13301. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13302. AND t1.behospital_code = t2.behospital_code
  13303. AND t2.is_deleted = 'N'
  13304. ) t
  13305. where 1=1
  13306. <if test="qcResultShortPageVO.checkStatus != null">
  13307. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13308. </if>
  13309. <if test="qcResultShortPageVO.mrStatus != null">
  13310. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13311. </if>
  13312. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13313. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13314. </if>
  13315. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13316. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13317. </if>
  13318. <if test="qcResultShortPageVO.chTimeStart != null ">
  13319. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13320. </if>
  13321. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13322. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13323. </if>
  13324. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13325. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13326. </if>
  13327. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13328. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13329. </if>
  13330. </select>
  13331. <!-- 病案首页不合格/合格数病历详情页导出-->
  13332. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  13333. SELECT
  13334. f1.behDeptId,
  13335. f1.behDeptName,
  13336. f1.doctorName,
  13337. f1.patName,
  13338. f1.behospitalCode,
  13339. f1.hospitalId,
  13340. f1.behospitalDate,
  13341. f1.leaveHospitalDate,
  13342. f1.score,
  13343. f1.scoreBn,
  13344. f2.avgScore,
  13345. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13346. f1.msg,
  13347. f1.caseName,
  13348. </if>
  13349. f1.checkStatus,
  13350. f1.mrStatus,
  13351. f1.chName,
  13352. f1.mrName,
  13353. f1.chTime,
  13354. f1.mrTime
  13355. FROM
  13356. (SELECT
  13357. t.doctorName,
  13358. t.`name` AS patName,
  13359. t.behospitalCode AS behospitalCode,
  13360. t.behospitalDate AS behospitalDate,
  13361. t.leaveHospitalDate AS leaveHospitalDate,
  13362. qi.score_res AS score,
  13363. t.scoreBn,
  13364. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13365. qd.msg AS msg,
  13366. qc.NAME AS caseName,
  13367. </if>
  13368. t.behDeptId,
  13369. t.behDeptName,
  13370. t.hospitalId,
  13371. t.checkStatus,
  13372. t.mrStatus,
  13373. t.chName,
  13374. t.mrName,
  13375. t.chTime,
  13376. t.mrTime
  13377. FROM
  13378. (SELECT DISTINCT
  13379. t1.hospital_id AS hospitalId,
  13380. t1.behospital_code AS behospitalCode,
  13381. t1.bed_code AS bedCode,
  13382. t1.LEVEL AS LEVEL,
  13383. t1.grade_type AS gradeType,
  13384. t1.score_res AS scoreRes,
  13385. t1.scoreBn,
  13386. t1.NAME AS NAME,
  13387. t1.sex AS sex,
  13388. t1.beh_dept_id AS behDeptId,
  13389. t1.beh_dept_name AS behDeptName,
  13390. t1.doctor_id AS doctorId,
  13391. t1.doctor_name AS doctorName,
  13392. t1.beh_doctor_id AS behDoctorId,
  13393. t1.beh_doctor_name AS behDoctorName,
  13394. t1.director_doctor_id AS directorDoctorId,
  13395. t1.director_doctor_name AS directorDoctorName,
  13396. t1.birthday AS birthday,
  13397. t1.behospital_date AS behospitalDate,
  13398. t1.leave_hospital_date AS leaveHospitalDate,
  13399. t1.placefile_date AS placefileDate,
  13400. t1.gmt_create AS gradeTime,
  13401. t1.diagnose,
  13402. t1.ward_name AS wardName,
  13403. t2.age,
  13404. t1.file_code AS fileCode,
  13405. t1.checkStatus,
  13406. t1.mrStatus,
  13407. t1.chName,
  13408. t1.mrName,
  13409. t1.chTime,
  13410. t1.mrTime
  13411. FROM
  13412. (SELECT
  13413. be.*,
  13414. b.LEVEL,
  13415. b.grade_type,
  13416. b.score_res,
  13417. b.gmt_create,
  13418. ifnull(mci.status,0) AS checkStatus,
  13419. ifnull(hm_mci.status,0) AS mrStatus,
  13420. mci.check_name as chName,
  13421. hm_mci.check_name as mrName,
  13422. mci.gmt_create as chTime,
  13423. hm_mci.gmt_create as mrTime
  13424. FROM
  13425. (
  13426. SELECT DISTINCT
  13427. a.hospital_id,
  13428. a.behospital_code,
  13429. a.bed_code,
  13430. a.file_code,
  13431. c.score_res as scoreBn,
  13432. c.cases_id,
  13433. a.NAME,
  13434. a.sex,
  13435. a.beh_dept_id,
  13436. a.beh_dept_name,
  13437. a.birthday,
  13438. a.behospital_date,
  13439. a.leave_hospital_date,
  13440. a.doctor_id,
  13441. a.doctor_name,
  13442. a.beh_doctor_id,
  13443. a.beh_doctor_name,
  13444. a.director_doctor_id,
  13445. a.director_doctor_name,
  13446. a.diagnose,
  13447. a.placefile_date,
  13448. a.ward_name
  13449. FROM
  13450. med_behospital_info a,
  13451. med_qcresult_cases c
  13452. WHERE
  13453. a.is_deleted = 'N'
  13454. AND c.is_deleted = 'N'
  13455. AND a.hospital_id = c.hospital_id
  13456. AND a.behospital_code = c.behospital_code
  13457. AND a.qc_type_id != 0
  13458. AND c.cases_id = 243
  13459. <if test="qcResultShortPageVO.titleName != null ">
  13460. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13461. AND c.`level`='不合格'
  13462. </if>
  13463. <if test="qcResultShortPageVO.titleName == '合格数'">
  13464. AND c.`level`='合格'
  13465. </if>
  13466. </if>
  13467. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13468. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13469. </if>
  13470. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13471. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13472. </if>
  13473. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13474. <if test="qcResultShortPageVO.startDate != null ">
  13475. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13476. </if>
  13477. <if test="qcResultShortPageVO.endDate != null ">
  13478. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13479. </if>
  13480. </if>
  13481. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13482. <if test="qcResultShortPageVO.startDate != null ">
  13483. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13484. </if>
  13485. <if test="qcResultShortPageVO.endDate != null">
  13486. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13487. </if>
  13488. </if>
  13489. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13490. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13491. </if>
  13492. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13493. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13494. </if>
  13495. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13496. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13497. </if>
  13498. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13499. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13500. </if>
  13501. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13502. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13503. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13504. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13505. </if>
  13506. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13507. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13508. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13509. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13510. </if>
  13511. )be
  13512. left join med_check_info mci
  13513. on mci.is_deleted = 'N'
  13514. and mci.check_type in(0,2)
  13515. and be.hospital_id = mci.hospital_id
  13516. and be.behospital_code = mci.behospital_code
  13517. left join med_check_info hm_mci
  13518. on hm_mci.is_deleted = 'N'
  13519. and hm_mci.check_type = 1
  13520. and be.hospital_id = hm_mci.hospital_id
  13521. and be.behospital_code = hm_mci.behospital_code
  13522. left join med_qcresult_info b
  13523. on b.is_deleted = 'N'
  13524. AND be.hospital_id = b.hospital_id
  13525. AND be.behospital_code = b.behospital_code
  13526. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13527. AND b.`level` = #{qcResultShortPageVO.level}
  13528. </if>
  13529. left join qc_cases_entry d
  13530. on d.is_deleted = 'N'
  13531. AND be.cases_id = d.cases_id
  13532. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13533. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13534. </if>
  13535. <if test="qcResultShortPageVO.casesEntryId != null ">
  13536. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13537. </if>
  13538. <if test="qcResultShortPageVO.ruleType != null">
  13539. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13540. </if>
  13541. ) t1
  13542. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13543. AND t1.behospital_code = t2.behospital_code
  13544. AND t2.is_deleted = 'N'
  13545. ) t
  13546. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13547. AND t.hospitalId = qi.hospital_id
  13548. AND t.behospitalCode = qi.behospital_code
  13549. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13550. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13551. AND t.hospitalId = qd.hospital_id
  13552. AND t.behospitalCode = qd.behospital_code
  13553. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13554. AND qd.cases_id = qc.id
  13555. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13556. AND qd.cases_id = qce.cases_id
  13557. AND qd.cases_entry_id = qce.id
  13558. </if>
  13559. where 1=1
  13560. <if test="qcResultShortPageVO.checkStatus != null">
  13561. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13562. </if>
  13563. <if test="qcResultShortPageVO.mrStatus != null">
  13564. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13565. </if>
  13566. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13567. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13568. </if>
  13569. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13570. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13571. </if>
  13572. <if test="qcResultShortPageVO.chTimeStart != null ">
  13573. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13574. </if>
  13575. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13576. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13577. </if>
  13578. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13579. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13580. </if>
  13581. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13582. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13583. </if>
  13584. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13585. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13586. </if>
  13587. <if test="qcResultShortPageVO.casesEntryId != null ">
  13588. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13589. </if>
  13590. )f1,
  13591. (SELECT
  13592. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13593. t.behDeptId,
  13594. t.behDeptName
  13595. FROM
  13596. (SELECT DISTINCT
  13597. t1.hospital_id AS hospitalId,
  13598. t1.behospital_code AS behospitalCode,
  13599. t1.bed_code AS bedCode,
  13600. t1.LEVEL AS LEVEL,
  13601. t1.grade_type AS gradeType,
  13602. t1.score_res AS scoreRes,
  13603. t1.NAME AS NAME,
  13604. t1.sex AS sex,
  13605. t1.beh_dept_id AS behDeptId,
  13606. t1.beh_dept_name AS behDeptName,
  13607. t1.doctor_id AS doctorId,
  13608. t1.doctor_name AS doctorName,
  13609. t1.beh_doctor_id AS behDoctorId,
  13610. t1.beh_doctor_name AS behDoctorName,
  13611. t1.director_doctor_id AS directorDoctorId,
  13612. t1.director_doctor_name AS directorDoctorName,
  13613. t1.birthday AS birthday,
  13614. t1.behospital_date AS behospitalDate,
  13615. t1.leave_hospital_date AS leaveHospitalDate,
  13616. t1.placefile_date AS placefileDate,
  13617. t1.gmt_create AS gradeTime,
  13618. t1.diagnose,
  13619. t1.ward_name AS wardName,
  13620. t2.age,
  13621. t1.file_code AS fileCode,
  13622. t1.checkStatus,
  13623. t1.mrStatus,
  13624. t1.chName,
  13625. t1.mrName,
  13626. t1.chTime,
  13627. t1.mrTime
  13628. FROM
  13629. (SELECT
  13630. be.*,
  13631. b.grade_type,
  13632. b.score_res,
  13633. b.gmt_create,
  13634. b.LEVEL,
  13635. ifnull(mci.status,0) AS checkStatus,
  13636. ifnull(hm_mci.status,0) AS mrStatus,
  13637. mci.check_name as chName,
  13638. hm_mci.check_name as mrName,
  13639. mci.gmt_create as chTime,
  13640. hm_mci.gmt_create as mrTime
  13641. FROM
  13642. (
  13643. SELECT DISTINCT
  13644. a.hospital_id,
  13645. a.behospital_code,
  13646. a.bed_code,
  13647. a.file_code,
  13648. a.NAME,
  13649. a.sex,
  13650. a.beh_dept_id,
  13651. a.beh_dept_name,
  13652. a.birthday,
  13653. a.behospital_date,
  13654. a.leave_hospital_date,
  13655. a.doctor_id,
  13656. a.doctor_name,
  13657. a.beh_doctor_id,
  13658. a.beh_doctor_name,
  13659. a.director_doctor_id,
  13660. a.director_doctor_name,
  13661. a.diagnose,
  13662. a.placefile_date,
  13663. a.ward_name
  13664. FROM
  13665. med_behospital_info a,
  13666. med_qcresult_cases c
  13667. WHERE
  13668. a.is_deleted = 'N'
  13669. AND c.is_deleted = 'N'
  13670. AND a.hospital_id = c.hospital_id
  13671. AND a.behospital_code = c.behospital_code
  13672. AND c.cases_id = 243
  13673. <if test="qcResultShortPageVO.titleName != null ">
  13674. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13675. AND c.`level`='不合格'
  13676. </if>
  13677. <if test="qcResultShortPageVO.titleName == '合格数'">
  13678. AND c.`level`='合格'
  13679. </if>
  13680. </if>
  13681. AND a.qc_type_id != 0
  13682. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13683. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13684. </if>
  13685. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13686. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13687. </if>
  13688. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13689. <if test="qcResultShortPageVO.startDate != null ">
  13690. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13691. </if>
  13692. <if test="qcResultShortPageVO.endDate != null ">
  13693. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13694. </if>
  13695. </if>
  13696. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13697. <if test="qcResultShortPageVO.startDate != null ">
  13698. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13699. </if>
  13700. <if test="qcResultShortPageVO.endDate != null">
  13701. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13702. </if>
  13703. </if>
  13704. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13705. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13706. </if>
  13707. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13708. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13709. </if>
  13710. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13711. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13712. </if>
  13713. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13714. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13715. </if>
  13716. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13717. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13718. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13719. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13720. </if>
  13721. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13722. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13723. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13724. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13725. </if>
  13726. )be
  13727. left join med_check_info mci
  13728. on mci.is_deleted = 'N'
  13729. and mci.check_type in(0,2)
  13730. and be.hospital_id = mci.hospital_id
  13731. and be.behospital_code = mci.behospital_code
  13732. left join med_check_info hm_mci
  13733. on hm_mci.is_deleted = 'N'
  13734. and hm_mci.check_type = 1
  13735. and be.hospital_id = hm_mci.hospital_id
  13736. and be.behospital_code = hm_mci.behospital_code
  13737. left join med_qcresult_info b
  13738. on b.is_deleted = 'N'
  13739. AND be.hospital_id = b.hospital_id
  13740. AND be.behospital_code = b.behospital_code
  13741. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13742. AND b.`level` = #{qcResultShortPageVO.level}
  13743. </if>
  13744. ) t1
  13745. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13746. AND t1.behospital_code = t2.behospital_code
  13747. AND t2.is_deleted = 'N'
  13748. ) t
  13749. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13750. AND t.hospitalId = qi.hospital_id
  13751. AND t.behospitalCode = qi.behospital_code
  13752. where 1=1
  13753. <if test="qcResultShortPageVO.checkStatus != null">
  13754. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13755. </if>
  13756. <if test="qcResultShortPageVO.mrStatus != null">
  13757. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13758. </if>
  13759. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13760. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13761. </if>
  13762. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13763. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13764. </if>
  13765. <if test="qcResultShortPageVO.chTimeStart != null ">
  13766. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13767. </if>
  13768. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13769. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13770. </if>
  13771. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13772. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13773. </if>
  13774. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13775. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13776. </if>
  13777. GROUP BY
  13778. t.behDeptId,
  13779. t.behDeptName
  13780. )f2
  13781. WHERE
  13782. f1.behDeptId = f2.behDeptId
  13783. AND f1.behDeptName = f2.behDeptName
  13784. </select>
  13785. <!-- 病案首页不合格/合格数病历详情页XY导出-->
  13786. <select id="badLevelPageXYExport" resultMap="ExportExcelMap">
  13787. SELECT
  13788. f1.behDeptId,
  13789. f1.behDeptName,
  13790. f1.doctorName,
  13791. f1.patName,
  13792. f1.behospitalCode,
  13793. f1.hospitalId,
  13794. f1.behospitalDate,
  13795. f1.leaveHospitalDate,
  13796. f1.score,
  13797. f1.scoreBn,
  13798. f2.avgScore,
  13799. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13800. f1.msg,
  13801. f1.caseName,
  13802. </if>
  13803. f1.checkStatus,
  13804. f1.mrStatus,
  13805. f1.chName,
  13806. f1.mrName,
  13807. f1.chTime,
  13808. f1.mrTime
  13809. FROM
  13810. (SELECT
  13811. t.doctorName,
  13812. t.`name` AS patName,
  13813. t.behospitalCode AS behospitalCode,
  13814. t.behospitalDate AS behospitalDate,
  13815. t.leaveHospitalDate AS leaveHospitalDate,
  13816. qi.score_res AS score,
  13817. t.scoreBn,
  13818. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13819. qd.msg AS msg,
  13820. qc.NAME AS caseName,
  13821. </if>
  13822. t.behDeptId,
  13823. t.behDeptName,
  13824. t.hospitalId,
  13825. t.doctorId,
  13826. t.checkStatus,
  13827. t.mrStatus,
  13828. t.chName,
  13829. t.mrName,
  13830. t.chTime,
  13831. t.mrTime
  13832. FROM
  13833. (SELECT DISTINCT
  13834. t1.hospital_id AS hospitalId,
  13835. t1.behospital_code AS behospitalCode,
  13836. t1.bed_code AS bedCode,
  13837. t1.level,
  13838. t1.grade_type AS gradeType,
  13839. t1.score_res AS scoreRes,
  13840. t1.scoreBn,
  13841. t1.NAME AS NAME,
  13842. t1.sex AS sex,
  13843. t1.beh_dept_id AS behDeptId,
  13844. t1.beh_dept_name AS behDeptName,
  13845. t1.doctor_name AS doctorName,
  13846. t1.birthday AS birthday,
  13847. t1.behospital_date AS behospitalDate,
  13848. t1.leave_hospital_date AS leaveHospitalDate,
  13849. t1.placefile_date AS placefileDate,
  13850. t1.gmt_create AS gradeTime,
  13851. t1.diagnose,
  13852. t1.doctorId,
  13853. t1.ward_name AS wardName,
  13854. t2.age,
  13855. t1.file_code AS fileCode,
  13856. t1.checkStatus,
  13857. t1.mrStatus,
  13858. t1.chName,
  13859. t1.mrName,
  13860. t1.chTime,
  13861. t1.mrTime
  13862. FROM
  13863. (SELECT
  13864. be.*,
  13865. b.level,
  13866. b.grade_type,
  13867. b.score_res,
  13868. b.gmt_create,
  13869. f.doctor_id as doctorId,
  13870. ifnull(mci.status,0) AS checkStatus,
  13871. ifnull(hm_mci.status,0) AS mrStatus,
  13872. mci.check_name as chName,
  13873. hm_mci.check_name as mrName,
  13874. mci.gmt_create as chTime,
  13875. hm_mci.gmt_create as mrTime
  13876. FROM
  13877. (
  13878. SELECT DISTINCT
  13879. a.hospital_id,
  13880. a.behospital_code,
  13881. a.bed_code,
  13882. a.file_code,
  13883. c.score_res as scoreBn,
  13884. c.cases_id,
  13885. a.NAME,
  13886. a.sex,
  13887. a.beh_dept_id,
  13888. a.beh_dept_name,
  13889. a.birthday,
  13890. a.behospital_date,
  13891. a.leave_hospital_date,
  13892. case
  13893. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  13894. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13895. b.director_doctor != '' and b.director_doctor is not null
  13896. then b.director_doctor
  13897. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13898. (b.director_doctor = '' or b.director_doctor is null) and
  13899. b.behospital_doctor != '' and b.behospital_doctor is not null
  13900. then b.behospital_doctor end as doctor_name,
  13901. a.diagnose,
  13902. a.placefile_date,
  13903. a.ward_name
  13904. FROM
  13905. med_behospital_info a,
  13906. med_home_page b,
  13907. med_qcresult_cases c
  13908. WHERE
  13909. a.is_deleted = 'N'
  13910. AND b.is_deleted = 'N'
  13911. AND c.is_deleted = 'N'
  13912. AND a.hospital_id = b.hospital_id
  13913. AND a.hospital_id = c.hospital_id
  13914. AND a.behospital_code = b.behospital_code
  13915. AND a.behospital_code = c.behospital_code
  13916. AND a.qc_type_id != 0
  13917. AND c.cases_id = 243
  13918. <if test="qcResultShortPageVO.titleName != null ">
  13919. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13920. AND c.`level`='不合格'
  13921. </if>
  13922. <if test="qcResultShortPageVO.titleName == '合格数'">
  13923. AND c.`level`='合格'
  13924. </if>
  13925. </if>
  13926. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13927. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13928. </if>
  13929. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13930. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13931. </if>
  13932. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13933. <if test="qcResultShortPageVO.startDate != null ">
  13934. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13935. </if>
  13936. <if test="qcResultShortPageVO.endDate != null ">
  13937. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13938. </if>
  13939. </if>
  13940. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13941. <if test="qcResultShortPageVO.startDate != null ">
  13942. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13943. </if>
  13944. <if test="qcResultShortPageVO.endDate != null">
  13945. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13946. </if>
  13947. </if>
  13948. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13949. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13950. </if>
  13951. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13952. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13953. </if>
  13954. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13955. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13956. </if>
  13957. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13958. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13959. </if>
  13960. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13961. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13962. </if>
  13963. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13964. AND (case
  13965. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  13966. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13967. b.director_doctor != '' and b.director_doctor is not null
  13968. then b.director_doctor
  13969. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13970. (b.director_doctor = '' or b.director_doctor is null) and
  13971. b.behospital_doctor != '' and b.behospital_doctor is not null
  13972. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13973. </if>
  13974. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  13975. AND (case
  13976. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  13977. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13978. b.director_doctor != '' and b.director_doctor is not null
  13979. then '主任医师'
  13980. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13981. (b.director_doctor = '' or b.director_doctor is null) and
  13982. b.behospital_doctor != '' and b.behospital_doctor is not null
  13983. then '住院医师' end) = #{qcResultShortPageVO.professor}
  13984. </if>
  13985. )be
  13986. left join med_check_info mci
  13987. on mci.is_deleted = 'N'
  13988. and mci.check_type in(0,2)
  13989. and be.hospital_id = mci.hospital_id
  13990. and be.behospital_code = mci.behospital_code
  13991. left join med_check_info hm_mci
  13992. on hm_mci.is_deleted = 'N'
  13993. and hm_mci.check_type = 1
  13994. and be.hospital_id = hm_mci.hospital_id
  13995. and be.behospital_code = hm_mci.behospital_code
  13996. left join med_qcresult_info b
  13997. on b.is_deleted = 'N'
  13998. AND be.hospital_id = b.hospital_id
  13999. AND be.behospital_code = b.behospital_code
  14000. left join qc_cases_entry d
  14001. on d.is_deleted = 'N'
  14002. AND be.cases_id = d.cases_id
  14003. LEFT JOIN bas_doctor_info f
  14004. on be.hospital_id = f.hospital_id
  14005. and be.doctor_name = f.name
  14006. AND f.is_deleted = 'N'
  14007. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14008. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14009. </if>
  14010. <if test="qcResultShortPageVO.casesEntryId != null ">
  14011. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14012. </if>
  14013. <if test="qcResultShortPageVO.ruleType != null">
  14014. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14015. </if>
  14016. ) t1
  14017. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14018. AND t1.behospital_code = t2.behospital_code
  14019. AND t2.is_deleted = 'N'
  14020. ) t
  14021. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14022. AND t.hospitalId = qi.hospital_id
  14023. AND t.behospitalCode = qi.behospital_code
  14024. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14025. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14026. AND t.hospitalId = qd.hospital_id
  14027. AND t.behospitalCode = qd.behospital_code
  14028. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14029. AND qd.cases_id = qc.id
  14030. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  14031. AND qd.cases_id = qce.cases_id
  14032. AND qd.cases_entry_id = qce.id
  14033. </if>
  14034. where 1=1
  14035. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14036. AND t.doctorId = #{qcResultShortPageVO.doctorId}
  14037. </if>
  14038. <if test="qcResultShortPageVO.checkStatus != null">
  14039. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14040. </if>
  14041. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14042. AND t.level = #{qcResultShortPageVO.level}
  14043. </if>
  14044. <if test="qcResultShortPageVO.mrStatus != null">
  14045. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14046. </if>
  14047. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14048. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14049. </if>
  14050. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14051. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14052. </if>
  14053. <if test="qcResultShortPageVO.chTimeStart != null ">
  14054. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14055. </if>
  14056. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14057. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14058. </if>
  14059. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14060. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14061. </if>
  14062. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14063. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14064. </if>
  14065. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14066. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  14067. </if>
  14068. <if test="qcResultShortPageVO.casesEntryId != null ">
  14069. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  14070. </if>
  14071. )f1,
  14072. (SELECT
  14073. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14074. t.behDeptId,
  14075. t.behDeptName
  14076. FROM
  14077. (SELECT DISTINCT
  14078. t1.beh_dept_id AS behDeptId,
  14079. t1.beh_dept_name AS behDeptName,
  14080. t1.hospital_id as hospitalId,
  14081. t1.behospital_code as behospitalCode,
  14082. t1.`level`,
  14083. t1.checkStatus,
  14084. t1.mrStatus,
  14085. t1.doctorId,
  14086. t1.chName,
  14087. t1.mrName,
  14088. t1.chTime,
  14089. t1.mrTime
  14090. FROM
  14091. (SELECT
  14092. be.*,
  14093. b.grade_type,
  14094. b.score_res,
  14095. b.`level`,
  14096. b.gmt_create,
  14097. f.doctor_id as doctorId,
  14098. ifnull(mci.status,0) AS checkStatus,
  14099. ifnull(hm_mci.status,0) AS mrStatus,
  14100. mci.check_name as chName,
  14101. hm_mci.check_name as mrName,
  14102. mci.gmt_create as chTime,
  14103. hm_mci.gmt_create as mrTime
  14104. FROM
  14105. (
  14106. SELECT DISTINCT
  14107. a.beh_dept_id,
  14108. a.beh_dept_name,
  14109. a.hospital_id,
  14110. case
  14111. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  14112. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14113. b.director_doctor != '' and b.director_doctor is not null
  14114. then b.director_doctor
  14115. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14116. (b.director_doctor = '' or b.director_doctor is null) and
  14117. b.behospital_doctor != '' and b.behospital_doctor is not null
  14118. then b.behospital_doctor end as doctor_name,
  14119. a.behospital_code
  14120. FROM
  14121. med_behospital_info a,
  14122. med_home_page b,
  14123. med_qcresult_cases c
  14124. WHERE
  14125. a.is_deleted = 'N'
  14126. AND b.is_deleted = 'N'
  14127. AND c.is_deleted = 'N'
  14128. AND a.hospital_id = b.hospital_id
  14129. AND a.hospital_id = c.hospital_id
  14130. AND a.behospital_code = b.behospital_code
  14131. AND a.behospital_code = c.behospital_code
  14132. AND c.cases_id = 243
  14133. <if test="qcResultShortPageVO.titleName != null ">
  14134. <if test="qcResultShortPageVO.titleName == '不合格数'">
  14135. AND c.`level`='不合格'
  14136. </if>
  14137. <if test="qcResultShortPageVO.titleName == '合格数'">
  14138. AND c.`level`='合格'
  14139. </if>
  14140. </if>
  14141. AND a.qc_type_id != 0
  14142. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14143. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14144. </if>
  14145. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14146. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14147. </if>
  14148. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14149. <if test="qcResultShortPageVO.startDate != null ">
  14150. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14151. </if>
  14152. <if test="qcResultShortPageVO.endDate != null ">
  14153. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14154. </if>
  14155. </if>
  14156. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14157. <if test="qcResultShortPageVO.startDate != null ">
  14158. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14159. </if>
  14160. <if test="qcResultShortPageVO.endDate != null">
  14161. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14162. </if>
  14163. </if>
  14164. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14165. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14166. </if>
  14167. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14168. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14169. </if>
  14170. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14171. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14172. </if>
  14173. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14174. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14175. </if>
  14176. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14177. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14178. </if>
  14179. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14180. AND (case
  14181. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  14182. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14183. b.director_doctor != '' and b.director_doctor is not null
  14184. then b.director_doctor
  14185. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14186. (b.director_doctor = '' or b.director_doctor is null) and
  14187. b.behospital_doctor != '' and b.behospital_doctor is not null
  14188. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14189. </if>
  14190. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  14191. AND (case
  14192. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  14193. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14194. b.director_doctor != '' and b.director_doctor is not null
  14195. then '主任医师'
  14196. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14197. (b.director_doctor = '' or b.director_doctor is null) and
  14198. b.behospital_doctor != '' and b.behospital_doctor is not null
  14199. then '住院医师' end) = #{qcResultShortPageVO.professor}
  14200. </if>
  14201. <if test="qcResultShortPageVO.casesEntryId != null ">
  14202. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14203. </if>
  14204. <if test="qcResultShortPageVO.ruleType != null">
  14205. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14206. </if>
  14207. )be
  14208. left join med_check_info mci
  14209. on mci.is_deleted = 'N'
  14210. and mci.check_type in(0,2)
  14211. and be.hospital_id = mci.hospital_id
  14212. and be.behospital_code = mci.behospital_code
  14213. left join med_check_info hm_mci
  14214. on hm_mci.is_deleted = 'N'
  14215. and hm_mci.check_type = 1
  14216. and be.hospital_id = hm_mci.hospital_id
  14217. and be.behospital_code = hm_mci.behospital_code
  14218. left join med_qcresult_info b
  14219. on b.is_deleted = 'N'
  14220. AND be.hospital_id = b.hospital_id
  14221. AND be.behospital_code = b.behospital_code
  14222. LEFT JOIN bas_doctor_info f
  14223. on be.hospital_id = f.hospital_id
  14224. and be.doctor_name = f.name
  14225. AND f.is_deleted = 'N'
  14226. ) t1
  14227. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14228. AND t1.behospital_code = t2.behospital_code
  14229. AND t2.is_deleted = 'N'
  14230. ) t
  14231. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14232. AND t.hospitalId = qi.hospital_id
  14233. AND t.behospitalCode = qi.behospital_code
  14234. where 1=1
  14235. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14236. AND t.doctorId = #{qcResultShortPageVO.doctorId}
  14237. </if>
  14238. <if test="qcResultShortPageVO.checkStatus != null">
  14239. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14240. </if>
  14241. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14242. AND t.level = #{qcResultShortPageVO.level}
  14243. </if>
  14244. <if test="qcResultShortPageVO.mrStatus != null">
  14245. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14246. </if>
  14247. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14248. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14249. </if>
  14250. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14251. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14252. </if>
  14253. <if test="qcResultShortPageVO.chTimeStart != null ">
  14254. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14255. </if>
  14256. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14257. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14258. </if>
  14259. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14260. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14261. </if>
  14262. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14263. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14264. </if>
  14265. GROUP BY
  14266. t.behDeptId,
  14267. t.behDeptName
  14268. )f2
  14269. WHERE
  14270. f1.behDeptId = f2.behDeptId
  14271. AND f1.behDeptName = f2.behDeptName
  14272. </select>
  14273. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  14274. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  14275. SELECT
  14276. f1.behDeptId,
  14277. f1.behDeptName,
  14278. f1.doctorName,
  14279. f1.patName,
  14280. f1.behospitalCode,
  14281. f1.hospitalId,
  14282. f1.behospitalDate,
  14283. f1.leaveHospitalDate,
  14284. f1.score,
  14285. f1.scoreBn,
  14286. f2.avgScore,
  14287. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14288. f1.msg,
  14289. f1.caseName,
  14290. </if>
  14291. f1.checkStatus,
  14292. f1.mrStatus,
  14293. f1.chName,
  14294. f1.mrName,
  14295. f1.chTime,
  14296. f1.mrTime
  14297. FROM
  14298. (SELECT
  14299. t.doctorName AS doctorName,
  14300. t.doctorId,
  14301. t.`name` AS patName,
  14302. t.behospitalCode AS behospitalCode,
  14303. t.behospitalDate AS behospitalDate,
  14304. t.leaveHospitalDate AS leaveHospitalDate,
  14305. qi.score_res AS score,
  14306. t.scoreBn,
  14307. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14308. qd.msg AS msg,
  14309. qc.NAME AS caseName,
  14310. </if>
  14311. t.behDeptId,
  14312. t.behDeptName,
  14313. t.hospitalId,
  14314. t.checkStatus,
  14315. t.mrStatus,
  14316. t.chName,
  14317. t.mrName,
  14318. t.chTime,
  14319. t.mrTime
  14320. FROM
  14321. (SELECT DISTINCT
  14322. t1.hospital_id AS hospitalId,
  14323. t1.behospital_code AS behospitalCode,
  14324. t1.bed_code AS bedCode,
  14325. t1.LEVEL AS LEVEL,
  14326. t1.grade_type AS gradeType,
  14327. t1.score_res AS scoreRes,
  14328. t1.scoreBn,
  14329. t1.NAME AS NAME,
  14330. t1.sex AS sex,
  14331. t1.beh_dept_id AS behDeptId,
  14332. t1.beh_dept_name AS behDeptName,
  14333. t1.doctor_id AS doctorId,
  14334. t1.doctor_name AS doctorName,
  14335. t1.beh_doctor_id AS behDoctorId,
  14336. t1.beh_doctor_name AS behDoctorName,
  14337. t1.director_doctor_id AS directorDoctorId,
  14338. t1.director_doctor_name AS directorDoctorName,
  14339. t1.birthday AS birthday,
  14340. t1.behospital_date AS behospitalDate,
  14341. t1.leave_hospital_date AS leaveHospitalDate,
  14342. t1.placefile_date AS placefileDate,
  14343. t1.gmt_create AS gradeTime,
  14344. t1.diagnose,
  14345. t1.ward_name AS wardName,
  14346. t2.age,
  14347. t1.file_code AS fileCode,
  14348. t1.checkStatus,
  14349. t1.mrStatus,
  14350. t1.chName,
  14351. t1.mrName,
  14352. t1.chTime,
  14353. t1.mrTime
  14354. FROM
  14355. (SELECT
  14356. be.*,
  14357. b.LEVEL,
  14358. b.grade_type,
  14359. b.score_res,
  14360. b.gmt_create,
  14361. ifnull(mci.status,0) AS checkStatus,
  14362. ifnull(hm_mci.status,0) AS mrStatus,
  14363. mci.check_name as chName,
  14364. hm_mci.check_name as mrName,
  14365. mci.gmt_create as chTime,
  14366. hm_mci.gmt_create as mrTime
  14367. FROM
  14368. (
  14369. SELECT DISTINCT
  14370. a.hospital_id,
  14371. a.behospital_code,
  14372. a.bed_code,
  14373. a.file_code,
  14374. c.score_res as scoreBn,
  14375. c.cases_id,
  14376. a.NAME,
  14377. a.sex,
  14378. a.beh_dept_id,
  14379. a.beh_dept_name,
  14380. a.birthday,
  14381. a.behospital_date,
  14382. a.leave_hospital_date,
  14383. a.doctor_id,
  14384. a.doctor_name,
  14385. a.beh_doctor_id,
  14386. a.beh_doctor_name,
  14387. a.director_doctor_id,
  14388. a.director_doctor_name,
  14389. a.diagnose,
  14390. a.placefile_date,
  14391. a.ward_name
  14392. FROM
  14393. med_behospital_info a,
  14394. sys_user_dept b,
  14395. med_qcresult_cases c
  14396. WHERE
  14397. a.is_deleted = 'N'
  14398. AND b.is_deleted = 'N'
  14399. AND c.is_deleted = 'N'
  14400. AND a.hospital_id = b.hospital_id
  14401. AND a.beh_dept_id = b.dept_id
  14402. AND a.hospital_id = c.hospital_id
  14403. AND a.behospital_code = c.behospital_code
  14404. AND a.qc_type_id != 0
  14405. AND c.cases_id = 243
  14406. <if test="qcResultShortPageVO.userId!=null">
  14407. AND b.user_id = #{qcResultShortPageVO.userId}
  14408. </if>
  14409. <if test="qcResultShortPageVO.titleName != null ">
  14410. <if test="qcResultShortPageVO.titleName == '不合格数'">
  14411. AND c.`level`='不合格'
  14412. </if>
  14413. <if test="qcResultShortPageVO.titleName == '合格数'">
  14414. AND c.`level`='合格'
  14415. </if>
  14416. </if>
  14417. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14418. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14419. </if>
  14420. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14421. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14422. </if>
  14423. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14424. <if test="qcResultShortPageVO.startDate != null ">
  14425. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14426. </if>
  14427. <if test="qcResultShortPageVO.endDate != null ">
  14428. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14429. </if>
  14430. </if>
  14431. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14432. <if test="qcResultShortPageVO.startDate != null ">
  14433. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14434. </if>
  14435. <if test="qcResultShortPageVO.endDate != null">
  14436. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14437. </if>
  14438. </if>
  14439. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14440. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14441. </if>
  14442. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14443. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  14444. </if>
  14445. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14446. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14447. </if>
  14448. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14449. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14450. </if>
  14451. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14452. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14453. </if>
  14454. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14455. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14456. </if>
  14457. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14458. AND a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14459. </if>
  14460. )be
  14461. left join med_check_info mci
  14462. on mci.is_deleted = 'N'
  14463. and mci.check_type in(0,2)
  14464. and be.hospital_id = mci.hospital_id
  14465. and be.behospital_code = mci.behospital_code
  14466. left join med_check_info hm_mci
  14467. on hm_mci.is_deleted = 'N'
  14468. and hm_mci.check_type = 1
  14469. and be.hospital_id = hm_mci.hospital_id
  14470. and be.behospital_code = hm_mci.behospital_code
  14471. left join med_qcresult_info b
  14472. on b.is_deleted = 'N'
  14473. AND be.hospital_id = b.hospital_id
  14474. AND be.behospital_code = b.behospital_code
  14475. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14476. AND b.`level` = #{qcResultShortPageVO.level}
  14477. </if>
  14478. left join qc_cases_entry d
  14479. on d.is_deleted = 'N'
  14480. AND be.cases_id = d.cases_id
  14481. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14482. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14483. </if>
  14484. <if test="qcResultShortPageVO.casesEntryId != null ">
  14485. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14486. </if>
  14487. <if test="qcResultShortPageVO.ruleType != null">
  14488. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14489. </if>
  14490. ) t1
  14491. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14492. AND t1.behospital_code = t2.behospital_code
  14493. AND t2.is_deleted = 'N'
  14494. ) t
  14495. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14496. AND t.hospitalId = qi.hospital_id
  14497. AND t.behospitalCode = qi.behospital_code
  14498. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14499. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14500. AND t.hospitalId = qd.hospital_id
  14501. AND t.behospitalCode = qd.behospital_code
  14502. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14503. AND qd.cases_id = qc.id
  14504. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  14505. AND qd.cases_id = qce.cases_id
  14506. AND qd.cases_entry_id = qce.id
  14507. </if>
  14508. where 1=1
  14509. <if test="qcResultShortPageVO.checkStatus != null">
  14510. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14511. </if>
  14512. <if test="qcResultShortPageVO.mrStatus != null">
  14513. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14514. </if>
  14515. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14516. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14517. </if>
  14518. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14519. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14520. </if>
  14521. <if test="qcResultShortPageVO.chTimeStart != null ">
  14522. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14523. </if>
  14524. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14525. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14526. </if>
  14527. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14528. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14529. </if>
  14530. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14531. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14532. </if>
  14533. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14534. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  14535. </if>
  14536. <if test="qcResultShortPageVO.casesEntryId != null ">
  14537. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  14538. </if>
  14539. )f1,
  14540. (SELECT
  14541. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14542. t.doctorId,
  14543. t.doctorName
  14544. FROM
  14545. (SELECT DISTINCT
  14546. t1.hospital_id AS hospitalId,
  14547. t1.behospital_code AS behospitalCode,
  14548. t1.bed_code AS bedCode,
  14549. t1.LEVEL AS LEVEL,
  14550. t1.grade_type AS gradeType,
  14551. t1.score_res AS scoreRes,
  14552. t1.NAME AS NAME,
  14553. t1.sex AS sex,
  14554. t1.beh_dept_id AS behDeptId,
  14555. t1.beh_dept_name AS behDeptName,
  14556. t1.doctor_id AS doctorId,
  14557. t1.doctor_name AS doctorName,
  14558. t1.beh_doctor_id AS behDoctorId,
  14559. t1.beh_doctor_name AS behDoctorName,
  14560. t1.director_doctor_id AS directorDoctorId,
  14561. t1.director_doctor_name AS directorDoctorName,
  14562. t1.birthday AS birthday,
  14563. t1.behospital_date AS behospitalDate,
  14564. t1.leave_hospital_date AS leaveHospitalDate,
  14565. t1.placefile_date AS placefileDate,
  14566. t1.gmt_create AS gradeTime,
  14567. t1.diagnose,
  14568. t1.ward_name AS wardName,
  14569. t2.age,
  14570. t1.file_code AS fileCode,
  14571. t1.checkStatus,
  14572. t1.mrStatus,
  14573. t1.chName,
  14574. t1.mrName,
  14575. t1.chTime,
  14576. t1.mrTime
  14577. FROM
  14578. (SELECT
  14579. be.*,
  14580. b.grade_type,
  14581. b.score_res,
  14582. b.gmt_create,
  14583. b.LEVEL,
  14584. ifnull(mci.status,0) AS checkStatus,
  14585. ifnull(hm_mci.status,0) AS mrStatus,
  14586. mci.check_name as chName,
  14587. hm_mci.check_name as mrName,
  14588. mci.gmt_create as chTime,
  14589. hm_mci.gmt_create as mrTime
  14590. FROM
  14591. (
  14592. SELECT DISTINCT
  14593. a.hospital_id,
  14594. a.behospital_code,
  14595. a.bed_code,
  14596. a.file_code,
  14597. a.NAME,
  14598. a.sex,
  14599. a.beh_dept_id,
  14600. a.beh_dept_name,
  14601. a.birthday,
  14602. a.behospital_date,
  14603. a.leave_hospital_date,
  14604. a.doctor_id,
  14605. a.doctor_name,
  14606. a.beh_doctor_id,
  14607. a.beh_doctor_name,
  14608. a.director_doctor_id,
  14609. a.director_doctor_name,
  14610. a.diagnose,
  14611. a.placefile_date,
  14612. a.ward_name
  14613. FROM
  14614. med_behospital_info a,
  14615. sys_user_dept b,
  14616. med_qcresult_cases c
  14617. WHERE
  14618. a.is_deleted = 'N'
  14619. AND b.is_deleted = 'N'
  14620. AND c.is_deleted = 'N'
  14621. AND a.hospital_id = b.hospital_id
  14622. AND a.hospital_id = c.hospital_id
  14623. AND a.behospital_code = c.behospital_code
  14624. AND a.beh_dept_id = b.dept_id
  14625. AND a.qc_type_id != 0
  14626. AND c.cases_id = 243
  14627. <if test="qcResultShortPageVO.titleName != null ">
  14628. <if test="qcResultShortPageVO.titleName == '不合格数'">
  14629. AND c.`level`='不合格'
  14630. </if>
  14631. <if test="qcResultShortPageVO.titleName == '合格数'">
  14632. AND c.`level`='合格'
  14633. </if>
  14634. </if>
  14635. <if test="qcResultShortPageVO.userId!=null">
  14636. AND b.user_id = #{qcResultShortPageVO.userId}
  14637. </if>
  14638. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14639. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14640. </if>
  14641. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14642. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14643. </if>
  14644. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14645. <if test="qcResultShortPageVO.startDate != null ">
  14646. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14647. </if>
  14648. <if test="qcResultShortPageVO.endDate != null ">
  14649. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14650. </if>
  14651. </if>
  14652. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14653. <if test="qcResultShortPageVO.startDate != null ">
  14654. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14655. </if>
  14656. <if test="qcResultShortPageVO.endDate != null">
  14657. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14658. </if>
  14659. </if>
  14660. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14661. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14662. </if>
  14663. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14664. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  14665. </if>
  14666. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14667. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14668. </if>
  14669. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14670. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14671. </if>
  14672. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14673. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14674. </if>
  14675. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14676. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14677. </if>
  14678. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14679. AND a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14680. </if>
  14681. )be
  14682. left join med_check_info mci
  14683. on mci.is_deleted = 'N'
  14684. and mci.check_type in(0,2)
  14685. and be.hospital_id = mci.hospital_id
  14686. and be.behospital_code = mci.behospital_code
  14687. left join med_check_info hm_mci
  14688. on hm_mci.is_deleted = 'N'
  14689. and hm_mci.check_type = 1
  14690. and be.hospital_id = hm_mci.hospital_id
  14691. and be.behospital_code = hm_mci.behospital_code
  14692. left join med_qcresult_info b
  14693. on b.is_deleted = 'N'
  14694. AND be.hospital_id = b.hospital_id
  14695. AND be.behospital_code = b.behospital_code
  14696. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14697. AND b.`level` = #{qcResultShortPageVO.level}
  14698. </if>
  14699. ) t1
  14700. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14701. AND t1.behospital_code = t2.behospital_code
  14702. AND t2.is_deleted = 'N'
  14703. ) t
  14704. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14705. AND t.hospitalId = qi.hospital_id
  14706. AND t.behospitalCode = qi.behospital_code
  14707. where 1=1
  14708. <if test="qcResultShortPageVO.checkStatus != null">
  14709. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14710. </if>
  14711. <if test="qcResultShortPageVO.mrStatus != null">
  14712. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14713. </if>
  14714. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14715. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14716. </if>
  14717. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14718. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14719. </if>
  14720. <if test="qcResultShortPageVO.chTimeStart != null ">
  14721. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14722. </if>
  14723. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14724. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14725. </if>
  14726. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14727. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14728. </if>
  14729. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14730. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14731. </if>
  14732. GROUP BY
  14733. t.behDeptId,
  14734. t.behDeptName,
  14735. t.doctorId,
  14736. t.doctorName
  14737. )f2
  14738. WHERE
  14739. f1.doctorId = f2.doctorId
  14740. AND f1.doctorName = f2.doctorName
  14741. </select>
  14742. <!-- 未整改病历缺陷评分详情页导出-->
  14743. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  14744. SELECT
  14745. f1.behDeptId,
  14746. f1.behDeptName,
  14747. f1.doctorName,
  14748. f1.patName,
  14749. f1.behospitalCode,
  14750. f1.hospitalId,
  14751. f1.behospitalDate,
  14752. f1.leaveHospitalDate,
  14753. f1.score,
  14754. f1.scoreBn,
  14755. f2.avgScore,
  14756. f1.msg,
  14757. f1.caseName,
  14758. f1.checkStatus,
  14759. f1.mrStatus,
  14760. f1.chName,
  14761. f1.mrName,
  14762. f1.chTime,
  14763. f1.mrTime
  14764. FROM
  14765. (SELECT
  14766. t.doctorName,
  14767. t.`name` AS patName,
  14768. t.behospitalCode AS behospitalCode,
  14769. t.behospitalDate AS behospitalDate,
  14770. t.leaveHospitalDate AS leaveHospitalDate,
  14771. qi.score_res AS score,
  14772. t.scoreBn,
  14773. qd.msg AS msg,
  14774. qc.NAME AS caseName,
  14775. t.behDeptId,
  14776. t.behDeptName,
  14777. t.hospitalId,
  14778. t.checkStatus,
  14779. t.mrStatus,
  14780. t.chName,
  14781. t.mrName,
  14782. t.chTime,
  14783. t.mrTime
  14784. FROM
  14785. (SELECT DISTINCT
  14786. t1.hospital_id AS hospitalId,
  14787. t1.behospital_code AS behospitalCode,
  14788. t1.bed_code AS bedCode,
  14789. t1.LEVEL AS LEVEL,
  14790. t1.grade_type AS gradeType,
  14791. t1.score_res AS scoreRes,
  14792. t1.scoreBn,
  14793. t1.NAME AS NAME,
  14794. t1.sex AS sex,
  14795. t1.beh_dept_id AS behDeptId,
  14796. t1.beh_dept_name AS behDeptName,
  14797. t1.doctor_id AS doctorId,
  14798. t1.doctor_name AS doctorName,
  14799. t1.beh_doctor_id AS behDoctorId,
  14800. t1.beh_doctor_name AS behDoctorName,
  14801. t1.director_doctor_id AS directorDoctorId,
  14802. t1.director_doctor_name AS directorDoctorName,
  14803. t1.birthday AS birthday,
  14804. t1.behospital_date AS behospitalDate,
  14805. t1.leave_hospital_date AS leaveHospitalDate,
  14806. t1.placefile_date AS placefileDate,
  14807. t1.gmt_create AS gradeTime,
  14808. t1.diagnose,
  14809. t1.ward_name AS wardName,
  14810. t2.age,
  14811. t1.file_code AS fileCode,
  14812. t1.checkStatus,
  14813. t1.mrStatus,
  14814. t1.chName,
  14815. t1.mrName,
  14816. t1.chTime,
  14817. t1.mrTime
  14818. FROM
  14819. (SELECT
  14820. be.*,
  14821. ifnull(mci.status,0) AS checkStatus,
  14822. ifnull(hm_mci.status,0) AS mrStatus,
  14823. mci.check_name as chName,
  14824. e.score_res as scoreBn,
  14825. hm_mci.check_name as mrName,
  14826. mci.gmt_create as chTime,
  14827. hm_mci.gmt_create as mrTime
  14828. FROM
  14829. (
  14830. SELECT DISTINCT
  14831. a.hospital_id,
  14832. a.behospital_code,
  14833. a.bed_code,
  14834. a.file_code,
  14835. b.LEVEL,
  14836. b.grade_type,
  14837. b.score_res,
  14838. a.NAME,
  14839. a.sex,
  14840. a.beh_dept_id,
  14841. a.beh_dept_name,
  14842. a.birthday,
  14843. a.behospital_date,
  14844. a.leave_hospital_date,
  14845. a.doctor_id,
  14846. a.doctor_name,
  14847. a.beh_doctor_id,
  14848. a.beh_doctor_name,
  14849. a.director_doctor_id,
  14850. a.director_doctor_name,
  14851. a.diagnose,
  14852. a.placefile_date,
  14853. a.ward_name,
  14854. b.gmt_create
  14855. FROM
  14856. med_behospital_info a,
  14857. med_qcresult_info b,
  14858. med_qcresult_detail c,
  14859. qc_cases_entry d
  14860. WHERE
  14861. a.is_deleted = 'N'
  14862. AND b.is_deleted = 'N'
  14863. AND c.is_deleted = 'N'
  14864. AND d.is_deleted = 'N'
  14865. AND a.hospital_id = b.hospital_id
  14866. AND a.hospital_id = c.hospital_id
  14867. AND a.behospital_code = b.behospital_code
  14868. AND a.behospital_code = c.behospital_code
  14869. AND c.cases_id = d.cases_id
  14870. AND c.cases_entry_id = d.id
  14871. AND a.qc_type_id != 0
  14872. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14873. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14874. </if>
  14875. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14876. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14877. </if>
  14878. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14879. <if test="qcResultShortPageVO.startDate != null ">
  14880. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14881. </if>
  14882. <if test="qcResultShortPageVO.endDate != null ">
  14883. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14884. </if>
  14885. </if>
  14886. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14887. <if test="qcResultShortPageVO.startDate != null ">
  14888. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14889. </if>
  14890. <if test="qcResultShortPageVO.endDate != null">
  14891. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14892. </if>
  14893. </if>
  14894. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14895. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14896. </if>
  14897. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14898. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14899. </if>
  14900. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14901. AND b.`level` = #{qcResultShortPageVO.level}
  14902. </if>
  14903. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14904. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14905. </if>
  14906. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14907. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14908. </if>
  14909. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14910. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14911. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14912. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14913. </if>
  14914. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14915. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14916. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14917. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14918. </if>
  14919. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14920. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14921. </if>
  14922. <if test="qcResultShortPageVO.casesEntryId != null ">
  14923. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14924. </if>
  14925. <if test="qcResultShortPageVO.isReject != null">
  14926. AND c.is_reject = #{qcResultShortPageVO.isReject}
  14927. </if>
  14928. <if test="qcResultShortPageVO.ruleType != null">
  14929. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14930. </if>
  14931. )be
  14932. left join med_check_info mci
  14933. on mci.is_deleted = 'N'
  14934. and mci.check_type in(0,2)
  14935. and be.hospital_id = mci.hospital_id
  14936. and be.behospital_code = mci.behospital_code
  14937. left join med_check_info hm_mci
  14938. on hm_mci.is_deleted = 'N'
  14939. and hm_mci.check_type = 1
  14940. and be.hospital_id = hm_mci.hospital_id
  14941. and be.behospital_code = hm_mci.behospital_code
  14942. LEFT JOIN med_qcresult_cases e
  14943. on be.behospital_code = e.behospital_code
  14944. and be.hospital_id = e.hospital_id
  14945. AND e.is_deleted = 'N'
  14946. and e.cases_id = 243
  14947. ) t1
  14948. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14949. AND t1.behospital_code = t2.behospital_code
  14950. AND t2.is_deleted = 'N'
  14951. ) t
  14952. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14953. AND t.hospitalId = qi.hospital_id
  14954. AND t.behospitalCode = qi.behospital_code
  14955. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14956. AND t.hospitalId = qd.hospital_id
  14957. AND t.behospitalCode = qd.behospital_code
  14958. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14959. AND qd.cases_id = qc.id
  14960. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  14961. AND qd.cases_id = qce.cases_id
  14962. AND qd.cases_entry_id = qce.id
  14963. where 1=1
  14964. <if test="qcResultShortPageVO.checkStatus != null">
  14965. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14966. </if>
  14967. <if test="qcResultShortPageVO.mrStatus != null">
  14968. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14969. </if>
  14970. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14971. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14972. </if>
  14973. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14974. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14975. </if>
  14976. <if test="qcResultShortPageVO.chTimeStart != null ">
  14977. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14978. </if>
  14979. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14980. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14981. </if>
  14982. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14983. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14984. </if>
  14985. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14986. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14987. </if>
  14988. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14989. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  14990. </if>
  14991. <if test="qcResultShortPageVO.casesEntryId != null ">
  14992. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  14993. </if>
  14994. )f1,
  14995. (SELECT
  14996. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14997. t.behDeptId,
  14998. t.behDeptName
  14999. FROM
  15000. (SELECT DISTINCT
  15001. t1.hospital_id AS hospitalId,
  15002. t1.behospital_code AS behospitalCode,
  15003. t1.bed_code AS bedCode,
  15004. t1.LEVEL AS LEVEL,
  15005. t1.grade_type AS gradeType,
  15006. t1.score_res AS scoreRes,
  15007. t1.NAME AS NAME,
  15008. t1.sex AS sex,
  15009. t1.beh_dept_id AS behDeptId,
  15010. t1.beh_dept_name AS behDeptName,
  15011. t1.doctor_id AS doctorId,
  15012. t1.doctor_name AS doctorName,
  15013. t1.beh_doctor_id AS behDoctorId,
  15014. t1.beh_doctor_name AS behDoctorName,
  15015. t1.director_doctor_id AS directorDoctorId,
  15016. t1.director_doctor_name AS directorDoctorName,
  15017. t1.birthday AS birthday,
  15018. t1.behospital_date AS behospitalDate,
  15019. t1.leave_hospital_date AS leaveHospitalDate,
  15020. t1.placefile_date AS placefileDate,
  15021. t1.gmt_create AS gradeTime,
  15022. t1.diagnose,
  15023. t1.ward_name AS wardName,
  15024. t2.age,
  15025. t1.file_code AS fileCode,
  15026. t1.checkStatus,
  15027. t1.mrStatus,
  15028. t1.chName,
  15029. t1.mrName,
  15030. t1.chTime,
  15031. t1.mrTime
  15032. FROM
  15033. (SELECT
  15034. be.*,
  15035. ifnull(mci.status,0) AS checkStatus,
  15036. ifnull(hm_mci.status,0) AS mrStatus,
  15037. mci.check_name as chName,
  15038. hm_mci.check_name as mrName,
  15039. mci.gmt_create as chTime,
  15040. hm_mci.gmt_create as mrTime
  15041. FROM
  15042. (
  15043. SELECT DISTINCT
  15044. a.hospital_id,
  15045. a.behospital_code,
  15046. a.bed_code,
  15047. a.file_code,
  15048. b.LEVEL,
  15049. b.grade_type,
  15050. b.score_res,
  15051. a.NAME,
  15052. a.sex,
  15053. a.beh_dept_id,
  15054. a.beh_dept_name,
  15055. a.birthday,
  15056. a.behospital_date,
  15057. a.leave_hospital_date,
  15058. a.doctor_id,
  15059. a.doctor_name,
  15060. a.beh_doctor_id,
  15061. a.beh_doctor_name,
  15062. a.director_doctor_id,
  15063. a.director_doctor_name,
  15064. a.diagnose,
  15065. a.placefile_date,
  15066. a.ward_name,
  15067. b.gmt_create
  15068. FROM
  15069. med_behospital_info a,
  15070. med_qcresult_info b,
  15071. med_qcresult_detail c,
  15072. qc_cases_entry d
  15073. WHERE
  15074. a.is_deleted = 'N'
  15075. AND b.is_deleted = 'N'
  15076. AND c.is_deleted = 'N'
  15077. AND d.is_deleted = 'N'
  15078. AND a.hospital_id = b.hospital_id
  15079. AND a.hospital_id = c.hospital_id
  15080. AND a.behospital_code = b.behospital_code
  15081. AND a.behospital_code = c.behospital_code
  15082. AND c.cases_id = d.cases_id
  15083. AND c.cases_entry_id = d.id
  15084. AND a.qc_type_id != 0
  15085. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15086. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15087. </if>
  15088. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15089. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15090. </if>
  15091. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15092. <if test="qcResultShortPageVO.startDate != null ">
  15093. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15094. </if>
  15095. <if test="qcResultShortPageVO.endDate != null ">
  15096. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15097. </if>
  15098. </if>
  15099. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15100. <if test="qcResultShortPageVO.startDate != null ">
  15101. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15102. </if>
  15103. <if test="qcResultShortPageVO.endDate != null">
  15104. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15105. </if>
  15106. </if>
  15107. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15108. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15109. </if>
  15110. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15111. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15112. </if>
  15113. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15114. AND b.`level` = #{qcResultShortPageVO.level}
  15115. </if>
  15116. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15117. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15118. </if>
  15119. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15120. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15121. </if>
  15122. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15123. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  15124. </if>
  15125. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15126. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15127. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15128. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15129. </if>
  15130. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15131. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15132. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15133. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15134. </if>
  15135. <if test="qcResultShortPageVO.casesEntryId != null ">
  15136. AND d.id = #{qcResultShortPageVO.casesEntryId}
  15137. </if>
  15138. <if test="qcResultShortPageVO.isReject != null">
  15139. AND c.is_reject = #{qcResultShortPageVO.isReject}
  15140. </if>
  15141. <if test="qcResultShortPageVO.ruleType != null">
  15142. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15143. </if>
  15144. )be
  15145. left join med_check_info mci
  15146. on mci.is_deleted = 'N'
  15147. and mci.check_type in(0,2)
  15148. and be.hospital_id = mci.hospital_id
  15149. and be.behospital_code = mci.behospital_code
  15150. left join med_check_info hm_mci
  15151. on hm_mci.is_deleted = 'N'
  15152. and hm_mci.check_type = 1
  15153. and be.hospital_id = hm_mci.hospital_id
  15154. and be.behospital_code = hm_mci.behospital_code
  15155. ) t1
  15156. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15157. AND t1.behospital_code = t2.behospital_code
  15158. AND t2.is_deleted = 'N'
  15159. ) t
  15160. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15161. AND t.hospitalId = qi.hospital_id
  15162. AND t.behospitalCode = qi.behospital_code
  15163. where 1=1
  15164. <if test="qcResultShortPageVO.checkStatus != null">
  15165. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15166. </if>
  15167. <if test="qcResultShortPageVO.mrStatus != null">
  15168. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15169. </if>
  15170. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15171. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15172. </if>
  15173. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15174. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15175. </if>
  15176. <if test="qcResultShortPageVO.chTimeStart != null ">
  15177. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15178. </if>
  15179. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15180. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15181. </if>
  15182. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15183. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15184. </if>
  15185. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15186. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15187. </if>
  15188. GROUP BY
  15189. t.behDeptId,
  15190. t.behDeptName
  15191. )f2
  15192. WHERE
  15193. f1.behDeptId = f2.behDeptId
  15194. AND f1.behDeptName = f2.behDeptName
  15195. </select>
  15196. <!-- 未整改病历缺陷评分详情页导出-科室-->
  15197. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  15198. SELECT
  15199. f1.behDeptId,
  15200. f1.behDeptName,
  15201. f1.doctorName,
  15202. f1.patName,
  15203. f1.behospitalCode,
  15204. f1.hospitalId,
  15205. f1.behospitalDate,
  15206. f1.leaveHospitalDate,
  15207. f1.score,
  15208. f1.scoreBn,
  15209. f2.avgScore,
  15210. f1.msg,
  15211. f1.caseName,
  15212. f1.checkStatus,
  15213. f1.mrStatus,
  15214. f1.chName,
  15215. f1.mrName,
  15216. f1.chTime,
  15217. f1.mrTime
  15218. FROM
  15219. (SELECT
  15220. t.doctorName,
  15221. t.doctorId,
  15222. t.`name` AS patName,
  15223. t.behospitalCode AS behospitalCode,
  15224. t.behospitalDate AS behospitalDate,
  15225. t.leaveHospitalDate AS leaveHospitalDate,
  15226. qi.score_res AS score,
  15227. t.scoreBn,
  15228. qd.msg AS msg,
  15229. qc.NAME AS caseName,
  15230. t.behDeptId,
  15231. t.behDeptName,
  15232. t.hospitalId,
  15233. t.checkStatus,
  15234. t.mrStatus,
  15235. t.chName,
  15236. t.mrName,
  15237. t.chTime,
  15238. t.mrTime
  15239. FROM
  15240. (SELECT DISTINCT
  15241. t1.hospital_id AS hospitalId,
  15242. t1.behospital_code AS behospitalCode,
  15243. t1.bed_code AS bedCode,
  15244. t1.LEVEL AS LEVEL,
  15245. t1.grade_type AS gradeType,
  15246. t1.score_res AS scoreRes,
  15247. t1.scoreBn,
  15248. t1.NAME AS NAME,
  15249. t1.sex AS sex,
  15250. t1.beh_dept_id AS behDeptId,
  15251. t1.beh_dept_name AS behDeptName,
  15252. t1.doctor_id AS doctorId,
  15253. t1.doctor_name AS doctorName,
  15254. t1.beh_doctor_id AS behDoctorId,
  15255. t1.beh_doctor_name AS behDoctorName,
  15256. t1.director_doctor_id AS directorDoctorId,
  15257. t1.director_doctor_name AS directorDoctorName,
  15258. t1.birthday AS birthday,
  15259. t1.behospital_date AS behospitalDate,
  15260. t1.leave_hospital_date AS leaveHospitalDate,
  15261. t1.placefile_date AS placefileDate,
  15262. t1.gmt_create AS gradeTime,
  15263. t1.diagnose,
  15264. t1.ward_name AS wardName,
  15265. t2.age,
  15266. t1.file_code AS fileCode,
  15267. t1.checkStatus,
  15268. t1.mrStatus,
  15269. t1.chName,
  15270. t1.mrName,
  15271. t1.chTime,
  15272. t1.mrTime
  15273. FROM
  15274. (SELECT
  15275. be.*,
  15276. ifnull(mci.status,0) AS checkStatus,
  15277. ifnull(hm_mci.status,0) AS mrStatus,
  15278. mci.check_name as chName,
  15279. e.score_res as scoreBn,
  15280. hm_mci.check_name as mrName,
  15281. mci.gmt_create as chTime,
  15282. hm_mci.gmt_create as mrTime
  15283. FROM
  15284. (
  15285. SELECT DISTINCT
  15286. a.hospital_id,
  15287. a.behospital_code,
  15288. a.bed_code,
  15289. a.file_code,
  15290. b.LEVEL,
  15291. b.grade_type,
  15292. b.score_res,
  15293. a.NAME,
  15294. a.sex,
  15295. a.beh_dept_id,
  15296. a.beh_dept_name,
  15297. a.birthday,
  15298. a.behospital_date,
  15299. a.leave_hospital_date,
  15300. a.doctor_id,
  15301. a.doctor_name,
  15302. a.beh_doctor_id,
  15303. a.beh_doctor_name,
  15304. a.director_doctor_id,
  15305. a.director_doctor_name,
  15306. a.diagnose,
  15307. a.placefile_date,
  15308. a.ward_name,
  15309. b.gmt_create
  15310. FROM
  15311. med_behospital_info a,
  15312. med_qcresult_info b,
  15313. med_qcresult_detail c,
  15314. qc_cases_entry d,
  15315. sys_user_dept f
  15316. WHERE
  15317. a.is_deleted = 'N'
  15318. AND b.is_deleted = 'N'
  15319. AND c.is_deleted = 'N'
  15320. AND d.is_deleted = 'N'
  15321. AND f.is_deleted = 'N'
  15322. AND a.hospital_id = b.hospital_id
  15323. AND a.hospital_id = c.hospital_id
  15324. AND a.hospital_id = f.hospital_id
  15325. AND a.behospital_code = b.behospital_code
  15326. AND a.behospital_code = c.behospital_code
  15327. AND c.cases_id = d.cases_id
  15328. AND c.cases_entry_id = d.id
  15329. AND a.beh_dept_id = f.dept_id
  15330. AND a.qc_type_id != 0
  15331. <if test="qcResultShortPageVO.userId!=null">
  15332. AND f.user_id = #{qcResultShortPageVO.userId}
  15333. </if>
  15334. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15335. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15336. </if>
  15337. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15338. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15339. </if>
  15340. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15341. <if test="qcResultShortPageVO.startDate != null ">
  15342. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15343. </if>
  15344. <if test="qcResultShortPageVO.endDate != null ">
  15345. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15346. </if>
  15347. </if>
  15348. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15349. <if test="qcResultShortPageVO.startDate != null ">
  15350. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15351. </if>
  15352. <if test="qcResultShortPageVO.endDate != null">
  15353. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15354. </if>
  15355. </if>
  15356. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15357. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15358. </if>
  15359. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15360. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15361. </if>
  15362. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15363. AND b.`level` = #{qcResultShortPageVO.level}
  15364. </if>
  15365. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15366. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15367. </if>
  15368. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15369. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15370. </if>
  15371. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15372. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15373. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15374. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15375. </if>
  15376. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15377. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15378. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15379. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15380. </if>
  15381. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15382. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  15383. </if>
  15384. <if test="qcResultShortPageVO.casesEntryId != null ">
  15385. AND d.id = #{qcResultShortPageVO.casesEntryId}
  15386. </if>
  15387. <if test="qcResultShortPageVO.isReject != null">
  15388. AND c.is_reject = #{qcResultShortPageVO.isReject}
  15389. </if>
  15390. <if test="qcResultShortPageVO.ruleType != null">
  15391. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15392. </if>
  15393. )be
  15394. left join med_check_info mci
  15395. on mci.is_deleted = 'N'
  15396. and mci.check_type in(0,2)
  15397. and be.hospital_id = mci.hospital_id
  15398. and be.behospital_code = mci.behospital_code
  15399. left join med_check_info hm_mci
  15400. on hm_mci.is_deleted = 'N'
  15401. and hm_mci.check_type = 1
  15402. and be.hospital_id = hm_mci.hospital_id
  15403. and be.behospital_code = hm_mci.behospital_code
  15404. LEFT JOIN med_qcresult_cases e
  15405. on be.behospital_code = e.behospital_code
  15406. and be.hospital_id = e.hospital_id
  15407. AND e.is_deleted = 'N'
  15408. and e.cases_id = 243
  15409. ) t1
  15410. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15411. AND t1.behospital_code = t2.behospital_code
  15412. AND t2.is_deleted = 'N'
  15413. ) t
  15414. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15415. AND t.hospitalId = qi.hospital_id
  15416. AND t.behospitalCode = qi.behospital_code
  15417. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15418. AND t.hospitalId = qd.hospital_id
  15419. AND t.behospitalCode = qd.behospital_code
  15420. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15421. AND qd.cases_id = qc.id
  15422. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  15423. AND qd.cases_id = qce.cases_id
  15424. AND qd.cases_entry_id = qce.id
  15425. where 1=1
  15426. <if test="qcResultShortPageVO.checkStatus != null">
  15427. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15428. </if>
  15429. <if test="qcResultShortPageVO.mrStatus != null">
  15430. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15431. </if>
  15432. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15433. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15434. </if>
  15435. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15436. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15437. </if>
  15438. <if test="qcResultShortPageVO.chTimeStart != null ">
  15439. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15440. </if>
  15441. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15442. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15443. </if>
  15444. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15445. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15446. </if>
  15447. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15448. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15449. </if>
  15450. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15451. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  15452. </if>
  15453. <if test="qcResultShortPageVO.casesEntryId != null ">
  15454. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  15455. </if>
  15456. )f1,
  15457. (SELECT
  15458. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15459. t.behDeptId,
  15460. t.behDeptName,
  15461. t.doctorId,
  15462. t.doctorName
  15463. FROM
  15464. (SELECT DISTINCT
  15465. t1.hospital_id AS hospitalId,
  15466. t1.behospital_code AS behospitalCode,
  15467. t1.bed_code AS bedCode,
  15468. t1.LEVEL AS LEVEL,
  15469. t1.grade_type AS gradeType,
  15470. t1.score_res AS scoreRes,
  15471. t1.NAME AS NAME,
  15472. t1.sex AS sex,
  15473. t1.beh_dept_id AS behDeptId,
  15474. t1.beh_dept_name AS behDeptName,
  15475. t1.doctor_id AS doctorId,
  15476. t1.doctor_name AS doctorName,
  15477. t1.beh_doctor_id AS behDoctorId,
  15478. t1.beh_doctor_name AS behDoctorName,
  15479. t1.director_doctor_id AS directorDoctorId,
  15480. t1.director_doctor_name AS directorDoctorName,
  15481. t1.birthday AS birthday,
  15482. t1.behospital_date AS behospitalDate,
  15483. t1.leave_hospital_date AS leaveHospitalDate,
  15484. t1.placefile_date AS placefileDate,
  15485. t1.gmt_create AS gradeTime,
  15486. t1.diagnose,
  15487. t1.ward_name AS wardName,
  15488. t2.age,
  15489. t1.file_code AS fileCode,
  15490. t1.checkStatus,
  15491. t1.mrStatus,
  15492. t1.chName,
  15493. t1.mrName,
  15494. t1.chTime,
  15495. t1.mrTime
  15496. FROM
  15497. (SELECT
  15498. be.*,
  15499. ifnull(mci.status,0) AS checkStatus,
  15500. ifnull(hm_mci.status,0) AS mrStatus,
  15501. mci.check_name as chName,
  15502. hm_mci.check_name as mrName,
  15503. mci.gmt_create as chTime,
  15504. hm_mci.gmt_create as mrTime
  15505. FROM
  15506. (
  15507. SELECT DISTINCT
  15508. a.hospital_id,
  15509. a.behospital_code,
  15510. a.bed_code,
  15511. a.file_code,
  15512. b.LEVEL,
  15513. b.grade_type,
  15514. b.score_res,
  15515. a.NAME,
  15516. a.sex,
  15517. a.beh_dept_id,
  15518. a.beh_dept_name,
  15519. a.birthday,
  15520. a.behospital_date,
  15521. a.leave_hospital_date,
  15522. a.doctor_id,
  15523. a.doctor_name,
  15524. a.beh_doctor_id,
  15525. a.beh_doctor_name,
  15526. a.director_doctor_id,
  15527. a.director_doctor_name,
  15528. a.diagnose,
  15529. a.placefile_date,
  15530. a.ward_name,
  15531. b.gmt_create
  15532. FROM
  15533. med_behospital_info a,
  15534. med_qcresult_info b,
  15535. med_qcresult_detail c,
  15536. qc_cases_entry d,
  15537. sys_user_dept f
  15538. WHERE
  15539. a.is_deleted = 'N'
  15540. AND b.is_deleted = 'N'
  15541. AND c.is_deleted = 'N'
  15542. AND d.is_deleted = 'N'
  15543. AND f.is_deleted = 'N'
  15544. AND a.hospital_id = b.hospital_id
  15545. AND a.hospital_id = c.hospital_id
  15546. AND a.hospital_id = f.hospital_id
  15547. AND a.behospital_code = b.behospital_code
  15548. AND a.behospital_code = c.behospital_code
  15549. AND c.cases_id = d.cases_id
  15550. AND c.cases_entry_id = d.id
  15551. AND a.beh_dept_id = f.dept_id
  15552. AND a.qc_type_id != 0
  15553. <if test="qcResultShortPageVO.userId!=null">
  15554. AND f.user_id = #{qcResultShortPageVO.userId}
  15555. </if>
  15556. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15557. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15558. </if>
  15559. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15560. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15561. </if>
  15562. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15563. <if test="qcResultShortPageVO.startDate != null ">
  15564. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15565. </if>
  15566. <if test="qcResultShortPageVO.endDate != null ">
  15567. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15568. </if>
  15569. </if>
  15570. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15571. <if test="qcResultShortPageVO.startDate != null ">
  15572. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15573. </if>
  15574. <if test="qcResultShortPageVO.endDate != null">
  15575. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15576. </if>
  15577. </if>
  15578. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15579. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15580. </if>
  15581. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15582. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15583. </if>
  15584. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15585. AND b.`level` = #{qcResultShortPageVO.level}
  15586. </if>
  15587. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15588. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15589. </if>
  15590. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15591. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15592. </if>
  15593. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15594. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  15595. </if>
  15596. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15597. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15598. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15599. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15600. </if>
  15601. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15602. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15603. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15604. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15605. </if>
  15606. <if test="qcResultShortPageVO.casesEntryId != null ">
  15607. AND d.id = #{qcResultShortPageVO.casesEntryId}
  15608. </if>
  15609. <if test="qcResultShortPageVO.isReject != null">
  15610. AND c.is_reject = #{qcResultShortPageVO.isReject}
  15611. </if>
  15612. <if test="qcResultShortPageVO.ruleType != null">
  15613. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15614. </if>
  15615. )be
  15616. left join med_check_info mci
  15617. on mci.is_deleted = 'N'
  15618. and mci.check_type in(0,2)
  15619. and be.hospital_id = mci.hospital_id
  15620. and be.behospital_code = mci.behospital_code
  15621. left join med_check_info hm_mci
  15622. on hm_mci.is_deleted = 'N'
  15623. and hm_mci.check_type = 1
  15624. and be.hospital_id = hm_mci.hospital_id
  15625. and be.behospital_code = hm_mci.behospital_code
  15626. ) t1
  15627. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15628. AND t1.behospital_code = t2.behospital_code
  15629. AND t2.is_deleted = 'N'
  15630. ) t
  15631. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15632. AND t.hospitalId = qi.hospital_id
  15633. AND t.behospitalCode = qi.behospital_code
  15634. where 1=1
  15635. <if test="qcResultShortPageVO.checkStatus != null">
  15636. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15637. </if>
  15638. <if test="qcResultShortPageVO.mrStatus != null">
  15639. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15640. </if>
  15641. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15642. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15643. </if>
  15644. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15645. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15646. </if>
  15647. <if test="qcResultShortPageVO.chTimeStart != null ">
  15648. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15649. </if>
  15650. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15651. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15652. </if>
  15653. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15654. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15655. </if>
  15656. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15657. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15658. </if>
  15659. GROUP BY
  15660. t.doctorId,
  15661. t.doctorName
  15662. )f2
  15663. WHERE
  15664. f1.doctorId = f2.doctorId
  15665. AND f1.doctorName = f2.doctorName
  15666. </select>
  15667. <!-- 31天再入院详情页-->
  15668. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  15669. SELECT
  15670. t.fileCode,
  15671. t.diagnose,
  15672. t.diagnoseName,
  15673. t.NAME,
  15674. t.sex,
  15675. t.hospitalId,
  15676. t.behDeptId,
  15677. t.behDeptName,
  15678. t.behospitalCode,
  15679. t.behospitalDate,
  15680. t.lastDiagnose,
  15681. t.lastDiagnoseName,
  15682. t.leaveHospitalDate,
  15683. t.lastBehDeptId,
  15684. t.lastBehDeptName,
  15685. t.lastBehospitalCode,
  15686. t.lastBehospitalDate,
  15687. t.lastLeaveHospitalDate,
  15688. t.diffDays,
  15689. mqi.score_res AS scoreRes,
  15690. mqi.LEVEL AS LEVEL,
  15691. mqi_last.score_res AS lastScoreRes,
  15692. mqi_last.LEVEL AS lastLevel,
  15693. mhp.total_fee AS totleFee,
  15694. mhp.behospital_day_num AS behospitalDayNum,
  15695. mhp.again_behospital_plan AS againBehospitalPlan,
  15696. IF(mhp.age is null, null,CONCAT( ifnull(mhp.age,'') ,ifnull(mhp.age_unit,'') ))as age,
  15697. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  15698. IF(mhp_last.age is null, null,CONCAT( ifnull(mhp_last.age,'') ,ifnull(mhp_last.age_unit,'') ))as lastAge,
  15699. mhp_last.total_fee AS lastTotleFee,
  15700. mhp_last.behospital_day_num AS lastBehospitalDayNum
  15701. FROM
  15702. (
  15703. SELECT
  15704. be.fileCode,
  15705. be.diagnose,
  15706. be.diagnoseName,
  15707. be.NAME,
  15708. be.sex,
  15709. be.hospitalId,
  15710. be.behDeptId,
  15711. be.behDeptName,
  15712. be.behospitalCode,
  15713. be.behospitalDate,
  15714. be.leaveHospitalDate,
  15715. be.lastDiagnose,
  15716. be.lastDiagnoseName,
  15717. be.lastBehDeptId,
  15718. be.lastBehDeptName,
  15719. be.lastBehospitalCode,
  15720. be.lastBehospitalDate,
  15721. be.lastLeaveHospitalDate,
  15722. be.diffDays
  15723. FROM
  15724. (
  15725. SELECT
  15726. r1.file_code AS fileCode,
  15727. r1.diagnose,
  15728. r1.diagnose_name AS diagnoseName,
  15729. r1.NAME,
  15730. r1.sex,
  15731. r1.hospital_id AS hospitalId,
  15732. r1.beh_dept_id AS behDeptId,
  15733. r1.beh_dept_name AS behDeptName,
  15734. r1.behospital_code AS behospitalCode,
  15735. r1.behospital_date AS behospitalDate,
  15736. r1.leave_hospital_date AS leaveHospitalDate,
  15737. r2.diagnose AS lastDiagnose,
  15738. r2.diagnose_name AS lastDiagnoseName,
  15739. r2.beh_dept_id AS lastBehDeptId,
  15740. r2.beh_dept_name AS lastBehDeptName,
  15741. r2.behospital_code AS lastBehospitalCode,
  15742. r2.behospital_date AS lastBehospitalDate,
  15743. r2.leave_hospital_date AS lastLeaveHospitalDate,
  15744. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  15745. FROM
  15746. (
  15747. SELECT
  15748. ( @rownum := @rownum + 1 ) AS rownum,
  15749. t1.file_code,
  15750. t1.behospital_code,
  15751. t1.diagnose,
  15752. t1.diagnose_name,
  15753. t1.NAME,
  15754. t1.sex,
  15755. t1.hospital_id,
  15756. t1.beh_dept_id,
  15757. t1.beh_dept_name,
  15758. t1.behospital_date,
  15759. t1.leave_hospital_date
  15760. FROM(
  15761. select
  15762. tt3.file_code,
  15763. tt3.behospital_code,
  15764. tt3.diagnose,
  15765. tt3.NAME,
  15766. tt3.sex,
  15767. tt3.hospital_id,
  15768. tt3.beh_dept_id,
  15769. tt3.beh_dept_name,
  15770. tt3.behospital_date,
  15771. tt3.leave_hospital_date,
  15772. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  15773. FROM(
  15774. SELECT
  15775. tt2.file_code,
  15776. tt2.diagnose,
  15777. tt2.NAME,
  15778. tt2.sex,
  15779. tt2.hospital_id,
  15780. tt2.beh_dept_id,
  15781. tt2.beh_dept_name,
  15782. tt2.behospital_code,
  15783. tt2.behospital_date,
  15784. tt2.leave_hospital_date
  15785. FROM
  15786. (
  15787. SELECT
  15788. a.file_code
  15789. FROM
  15790. med_behospital_info a
  15791. WHERE
  15792. a.is_deleted = 'N'
  15793. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15794. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  15795. </if>
  15796. AND a.qc_type_id != 0
  15797. AND IFNULL( a.diagnose, '' )!= ''
  15798. AND IFNULL( a.file_code, '' )!= ''
  15799. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15800. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  15801. </if>
  15802. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15803. <if test="reBeHosPageVO.startDate != null ">
  15804. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15805. </if>
  15806. <if test="reBeHosPageVO.endDate != null ">
  15807. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15808. </if>
  15809. </if>
  15810. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15811. <if test="reBeHosPageVO.startDate != null ">
  15812. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15813. </if>
  15814. <if test="reBeHosPageVO.endDate != null">
  15815. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15816. </if>
  15817. </if>
  15818. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15819. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15820. </if>
  15821. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15822. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  15823. </if>
  15824. GROUP BY
  15825. a.file_code
  15826. HAVING
  15827. count(*)> 1
  15828. ) tt1,
  15829. med_behospital_info tt2
  15830. WHERE
  15831. tt2.is_deleted = 'N'
  15832. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15833. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  15834. </if>
  15835. AND tt2.qc_type_id != 0
  15836. AND tt1.file_code = tt2.file_code
  15837. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15838. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  15839. </if>
  15840. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15841. <if test="reBeHosPageVO.startDate != null ">
  15842. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15843. </if>
  15844. <if test="reBeHosPageVO.endDate != null ">
  15845. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15846. </if>
  15847. </if>
  15848. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15849. <if test="reBeHosPageVO.startDate != null ">
  15850. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15851. </if>
  15852. <if test="reBeHosPageVO.endDate != null">
  15853. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15854. </if>
  15855. </if>
  15856. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15857. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15858. </if>
  15859. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15860. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  15861. </if>
  15862. ORDER BY
  15863. tt1.file_code,
  15864. tt2.behospital_date DESC)tt3
  15865. left join med_home_page tt4 on tt4.is_deleted = 'N'
  15866. AND tt3.hospital_id = tt4.hospital_id
  15867. AND tt3.behospital_code = tt4.behospital_code
  15868. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  15869. AND tt4.hospital_id = tt5.hospital_id
  15870. AND tt4.home_page_id = tt5.home_page_id
  15871. GROUP by tt3.behospital_code
  15872. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  15873. ) t1,
  15874. ( SELECT @rownum := 0 ) r
  15875. ) r1
  15876. LEFT JOIN (
  15877. SELECT
  15878. ( @INDEX := @INDEX + 1 ) AS rownum,
  15879. t1.file_code,
  15880. t1.behospital_code,
  15881. t1.diagnose,
  15882. t1.diagnose_name,
  15883. t1.NAME,
  15884. t1.sex,
  15885. t1.hospital_id,
  15886. t1.beh_dept_id,
  15887. t1.beh_dept_name,
  15888. t1.behospital_date,
  15889. t1.leave_hospital_date
  15890. FROM(
  15891. select
  15892. tt3.file_code,
  15893. tt3.behospital_code,
  15894. tt3.diagnose,
  15895. tt3.NAME,
  15896. tt3.sex,
  15897. tt3.hospital_id,
  15898. tt3.beh_dept_id,
  15899. tt3.beh_dept_name,
  15900. tt3.behospital_date,
  15901. tt3.leave_hospital_date,
  15902. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  15903. FROM(
  15904. SELECT
  15905. tt2.file_code,
  15906. tt2.diagnose,
  15907. tt2.NAME,
  15908. tt2.sex,
  15909. tt2.hospital_id,
  15910. tt2.beh_dept_id,
  15911. tt2.beh_dept_name,
  15912. tt2.behospital_code,
  15913. tt2.behospital_date,
  15914. tt2.leave_hospital_date
  15915. FROM
  15916. (
  15917. SELECT
  15918. a.file_code
  15919. FROM
  15920. med_behospital_info a
  15921. WHERE
  15922. a.is_deleted = 'N'
  15923. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15924. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  15925. </if>
  15926. AND a.qc_type_id != 0
  15927. AND IFNULL( a.diagnose, '' )!= ''
  15928. AND IFNULL( a.file_code, '' )!= ''
  15929. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15930. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  15931. </if>
  15932. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15933. <if test="reBeHosPageVO.startDate != null ">
  15934. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15935. </if>
  15936. <if test="reBeHosPageVO.endDate != null ">
  15937. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15938. </if>
  15939. </if>
  15940. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15941. <if test="reBeHosPageVO.startDate != null ">
  15942. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15943. </if>
  15944. <if test="reBeHosPageVO.endDate != null">
  15945. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15946. </if>
  15947. </if>
  15948. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15949. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15950. </if>
  15951. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15952. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  15953. </if>
  15954. GROUP BY
  15955. a.file_code
  15956. HAVING
  15957. count(*)> 1
  15958. ) tt1,
  15959. med_behospital_info tt2
  15960. WHERE
  15961. tt2.is_deleted = 'N'
  15962. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15963. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  15964. </if>
  15965. AND tt2.qc_type_id != 0
  15966. AND tt1.file_code = tt2.file_code
  15967. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15968. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  15969. </if>
  15970. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15971. <if test="reBeHosPageVO.startDate != null ">
  15972. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15973. </if>
  15974. <if test="reBeHosPageVO.endDate != null ">
  15975. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15976. </if>
  15977. </if>
  15978. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15979. <if test="reBeHosPageVO.startDate != null ">
  15980. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15981. </if>
  15982. <if test="reBeHosPageVO.endDate != null">
  15983. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15984. </if>
  15985. </if>
  15986. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15987. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15988. </if>
  15989. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15990. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  15991. </if>
  15992. ORDER BY
  15993. tt1.file_code,
  15994. tt2.behospital_date DESC)tt3
  15995. left join med_home_page tt4 on tt4.is_deleted = 'N'
  15996. AND tt3.hospital_id = tt4.hospital_id
  15997. AND tt3.behospital_code = tt4.behospital_code
  15998. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  15999. AND tt4.hospital_id = tt5.hospital_id
  16000. AND tt4.home_page_id = tt5.home_page_id
  16001. GROUP by tt3.behospital_code
  16002. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  16003. ) t1,
  16004. ( SELECT @INDEX := 0 ) r
  16005. ) r2 ON r1.file_code = r2.file_code
  16006. AND r1.rownum = r2.rownum - 1
  16007. ) be
  16008. WHERE
  16009. be.diffDays IS NOT NULL
  16010. AND be.diffDays BETWEEN 0
  16011. AND 31
  16012. ) t
  16013. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  16014. AND t.hospitalId = mqi.hospital_id
  16015. AND t.behospitalCode = mqi.behospital_code
  16016. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  16017. AND t.hospitalId = mqi_last.hospital_id
  16018. AND t.lastBehospitalCode = mqi_last.behospital_code
  16019. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  16020. AND t.hospitalId = mhp.hospital_id
  16021. AND t.behospitalCode = mhp.behospital_code
  16022. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  16023. AND t.hospitalId = mhp_last.hospital_id
  16024. AND t.lastBehospitalCode = mhp_last.behospital_code
  16025. </select>
  16026. <!-- 31天再入院详情页-科室-->
  16027. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  16028. SELECT
  16029. t.fileCode,
  16030. t.diagnose,
  16031. t.diagnoseName,
  16032. t.NAME,
  16033. t.sex,
  16034. t.hospitalId,
  16035. t.behDeptId,
  16036. t.behDeptName,
  16037. t.doctorId,
  16038. t.doctorName,
  16039. t.behospitalCode,
  16040. t.behospitalDate,
  16041. t.leaveHospitalDate,
  16042. t.lastDiagnose,
  16043. t.lastDiagnoseName,
  16044. t.lastBehDeptId,
  16045. t.lastBehDeptName,
  16046. t.lastDoctorName,
  16047. t.lastBehospitalCode,
  16048. t.lastBehospitalDate,
  16049. t.lastLeaveHospitalDate,
  16050. t.diffDays,
  16051. mqi.score_res AS scoreRes,
  16052. mqi.LEVEL AS LEVEL,
  16053. mqi_last.score_res AS lastScoreRes,
  16054. mqi_last.LEVEL AS lastLevel,
  16055. mhp.again_behospital_plan AS againBehospitalPlan,
  16056. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  16057. mhp.total_fee AS totleFee,
  16058. mhp.behospital_day_num AS behospitalDayNum,
  16059. mhp_last.total_fee AS lastTotleFee,
  16060. mhp_last.behospital_day_num AS lastBehospitalDayNum
  16061. FROM
  16062. (
  16063. SELECT
  16064. be.fileCode,
  16065. be.diagnose,
  16066. be.diagnoseName,
  16067. be.NAME,
  16068. be.sex,
  16069. be.hospitalId,
  16070. be.behDeptId,
  16071. be.behDeptName,
  16072. be.doctorId,
  16073. be.doctorName,
  16074. be.behospitalCode,
  16075. be.behospitalDate,
  16076. be.leaveHospitalDate,
  16077. be.lastDiagnose,
  16078. be.lastDiagnoseName,
  16079. be.lastBehDeptId,
  16080. be.lastBehDeptName,
  16081. be.lastDoctorId,
  16082. be.lastDoctorName,
  16083. be.lastBehospitalCode,
  16084. be.lastBehospitalDate,
  16085. be.lastLeaveHospitalDate,
  16086. be.diffDays
  16087. FROM
  16088. (
  16089. SELECT
  16090. r1.file_code AS fileCode,
  16091. r1.diagnose,
  16092. r1.diagnose_name AS diagnoseName,
  16093. r1.NAME,
  16094. r1.sex,
  16095. r1.hospital_id AS hospitalId,
  16096. r1.beh_dept_id AS behDeptId,
  16097. r1.beh_dept_name AS behDeptName,
  16098. r1.doctor_id as doctorId,
  16099. r1.doctor_name as doctorName,
  16100. r1.behospital_code AS behospitalCode,
  16101. r1.behospital_date AS behospitalDate,
  16102. r1.leave_hospital_date AS leaveHospitalDate,
  16103. r2.diagnose AS lastDiagnose,
  16104. r2.diagnose_name AS lastDiagnoseName,
  16105. r2.beh_dept_id AS lastBehDeptId,
  16106. r2.beh_dept_name AS lastBehDeptName,
  16107. r2.behospital_code AS lastBehospitalCode,
  16108. r2.behospital_date AS lastBehospitalDate,
  16109. r2.doctor_id as lastDoctorId,
  16110. r2.doctor_name as lastDoctorName,
  16111. r2.leave_hospital_date AS lastLeaveHospitalDate,
  16112. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  16113. FROM
  16114. (
  16115. SELECT
  16116. ( @rownum := @rownum + 1 ) AS rownum,
  16117. t1.file_code,
  16118. t1.NAME,
  16119. t1.sex,
  16120. t1.diagnose,
  16121. t1.diagnose_name,
  16122. t1.doctor_id,
  16123. t1.doctor_name,
  16124. t1.hospital_id,
  16125. t1.beh_dept_id,
  16126. t1.beh_dept_name,
  16127. t1.behospital_code,
  16128. t1.behospital_date,
  16129. t1.leave_hospital_date
  16130. FROM
  16131. (
  16132. select
  16133. tt3.file_code,
  16134. tt3.behospital_code,
  16135. tt3.diagnose,
  16136. tt3.NAME,
  16137. tt3.sex,
  16138. tt3.hospital_id,
  16139. tt3.beh_dept_id,
  16140. tt3.beh_dept_name,
  16141. tt3.doctor_id,
  16142. tt3.doctor_name,
  16143. tt3.behospital_date,
  16144. tt3.leave_hospital_date,
  16145. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  16146. FROM(
  16147. SELECT
  16148. tt1.file_code,
  16149. tt2.diagnose,
  16150. tt2.doctor_id,
  16151. tt2.doctor_name,
  16152. tt2.NAME,
  16153. tt2.sex,
  16154. tt2.hospital_id,
  16155. tt2.beh_dept_id,
  16156. tt2.beh_dept_name,
  16157. tt2.behospital_code,
  16158. tt2.behospital_date,
  16159. tt2.leave_hospital_date
  16160. FROM
  16161. (
  16162. SELECT
  16163. a.file_code
  16164. FROM
  16165. med_behospital_info a,
  16166. sys_user_dept c
  16167. WHERE
  16168. a.is_deleted = 'N'
  16169. AND c.is_deleted = 'N'
  16170. AND a.hospital_id = c.hospital_id
  16171. AND a.beh_dept_id = c.dept_id
  16172. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  16173. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  16174. </if>
  16175. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16176. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  16177. </if>
  16178. <if test="reBeHosPageVO.userId!=null">
  16179. AND c.user_id = #{reBeHosPageVO.userId}
  16180. </if>
  16181. AND a.qc_type_id != 0
  16182. AND IFNULL( a.diagnose, '' )!= ''
  16183. AND IFNULL( a.file_code, '' )!= ''
  16184. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16185. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  16186. </if>
  16187. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16188. <if test="reBeHosPageVO.startDate != null ">
  16189. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16190. </if>
  16191. <if test="reBeHosPageVO.endDate != null ">
  16192. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16193. </if>
  16194. </if>
  16195. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16196. <if test="reBeHosPageVO.startDate != null ">
  16197. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16198. </if>
  16199. <if test="reBeHosPageVO.endDate != null">
  16200. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16201. </if>
  16202. </if>
  16203. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16204. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16205. </if>
  16206. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16207. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  16208. </if>
  16209. GROUP BY
  16210. a.file_code
  16211. HAVING
  16212. count(*)> 1
  16213. ) tt1,
  16214. med_behospital_info tt2
  16215. WHERE
  16216. tt2.is_deleted = 'N'
  16217. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16218. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  16219. </if>
  16220. AND tt2.qc_type_id != 0
  16221. AND tt1.file_code = tt2.file_code
  16222. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16223. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  16224. </if>
  16225. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16226. <if test="reBeHosPageVO.startDate != null ">
  16227. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16228. </if>
  16229. <if test="reBeHosPageVO.endDate != null ">
  16230. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16231. </if>
  16232. </if>
  16233. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16234. <if test="reBeHosPageVO.startDate != null ">
  16235. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16236. </if>
  16237. <if test="reBeHosPageVO.endDate != null">
  16238. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16239. </if>
  16240. </if>
  16241. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16242. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16243. </if>
  16244. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16245. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  16246. </if>
  16247. ORDER BY
  16248. tt1.file_code,
  16249. tt2.behospital_date DESC)tt3
  16250. left join med_home_page tt4 on tt4.is_deleted = 'N'
  16251. AND tt3.hospital_id = tt4.hospital_id
  16252. AND tt3.behospital_code = tt4.behospital_code
  16253. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  16254. AND tt4.hospital_id = tt5.hospital_id
  16255. AND tt4.home_page_id = tt5.home_page_id
  16256. GROUP by tt3.behospital_code
  16257. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  16258. ) t1,
  16259. ( SELECT @rownum := 0 ) r
  16260. ) r1
  16261. LEFT JOIN (
  16262. SELECT
  16263. ( @INDEX := @INDEX + 1 ) AS rownum,
  16264. t1.file_code,
  16265. t1.NAME,
  16266. t1.sex,
  16267. t1.diagnose,
  16268. t1.diagnose_name,
  16269. t1.doctor_id,
  16270. t1.doctor_name,
  16271. t1.hospital_id,
  16272. t1.beh_dept_id,
  16273. t1.beh_dept_name,
  16274. t1.behospital_code,
  16275. t1.behospital_date,
  16276. t1.leave_hospital_date
  16277. FROM
  16278. (
  16279. select
  16280. tt3.file_code,
  16281. tt3.behospital_code,
  16282. tt3.diagnose,
  16283. tt3.NAME,
  16284. tt3.sex,
  16285. tt3.hospital_id,
  16286. tt3.beh_dept_id,
  16287. tt3.beh_dept_name,
  16288. tt3.doctor_id,
  16289. tt3.doctor_name,
  16290. tt3.behospital_date,
  16291. tt3.leave_hospital_date,
  16292. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  16293. FROM(
  16294. SELECT
  16295. tt1.file_code,
  16296. tt2.diagnose,
  16297. tt2.doctor_id,
  16298. tt2.doctor_name,
  16299. tt2.NAME,
  16300. tt2.sex,
  16301. tt2.hospital_id,
  16302. tt2.beh_dept_id,
  16303. tt2.beh_dept_name,
  16304. tt2.behospital_code,
  16305. tt2.behospital_date,
  16306. tt2.leave_hospital_date
  16307. FROM
  16308. (
  16309. SELECT
  16310. a.file_code
  16311. FROM
  16312. med_behospital_info a,
  16313. sys_user_dept c
  16314. WHERE
  16315. a.is_deleted = 'N'
  16316. AND c.is_deleted = 'N'
  16317. AND a.hospital_id = c.hospital_id
  16318. AND a.beh_dept_id = c.dept_id
  16319. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  16320. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  16321. </if>
  16322. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16323. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  16324. </if>
  16325. <if test="reBeHosPageVO.userId!=null">
  16326. AND c.user_id = #{reBeHosPageVO.userId}
  16327. </if>
  16328. AND a.qc_type_id != 0
  16329. AND IFNULL( a.diagnose, '' )!= ''
  16330. AND IFNULL( a.file_code, '' )!= ''
  16331. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16332. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  16333. </if>
  16334. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16335. <if test="reBeHosPageVO.startDate != null ">
  16336. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16337. </if>
  16338. <if test="reBeHosPageVO.endDate != null ">
  16339. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16340. </if>
  16341. </if>
  16342. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16343. <if test="reBeHosPageVO.startDate != null ">
  16344. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16345. </if>
  16346. <if test="reBeHosPageVO.endDate != null">
  16347. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16348. </if>
  16349. </if>
  16350. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16351. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16352. </if>
  16353. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16354. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  16355. </if>
  16356. GROUP BY
  16357. a.file_code
  16358. HAVING
  16359. count(*)> 1
  16360. ) tt1,
  16361. med_behospital_info tt2
  16362. WHERE
  16363. tt2.is_deleted = 'N'
  16364. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16365. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  16366. </if>
  16367. AND tt2.qc_type_id != 0
  16368. AND tt1.file_code = tt2.file_code
  16369. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16370. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  16371. </if>
  16372. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16373. <if test="reBeHosPageVO.startDate != null ">
  16374. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16375. </if>
  16376. <if test="reBeHosPageVO.endDate != null ">
  16377. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16378. </if>
  16379. </if>
  16380. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16381. <if test="reBeHosPageVO.startDate != null ">
  16382. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16383. </if>
  16384. <if test="reBeHosPageVO.endDate != null">
  16385. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16386. </if>
  16387. </if>
  16388. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16389. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16390. </if>
  16391. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16392. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  16393. </if>
  16394. ORDER BY
  16395. tt1.file_code,
  16396. tt2.behospital_date DESC)tt3
  16397. left join med_home_page tt4 on tt4.is_deleted = 'N'
  16398. AND tt3.hospital_id = tt4.hospital_id
  16399. AND tt3.behospital_code = tt4.behospital_code
  16400. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  16401. AND tt4.hospital_id = tt5.hospital_id
  16402. AND tt4.home_page_id = tt5.home_page_id
  16403. GROUP by tt3.behospital_code
  16404. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  16405. ) t1,
  16406. ( SELECT @INDEX := 0 ) r
  16407. ) r2 ON r1.file_code = r2.file_code
  16408. AND r1.rownum = r2.rownum - 1
  16409. ) be
  16410. WHERE
  16411. be.diffDays IS NOT NULL
  16412. AND be.diffDays BETWEEN 0
  16413. AND 31
  16414. ) t
  16415. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  16416. AND t.hospitalId = mqi.hospital_id
  16417. AND t.behospitalCode = mqi.behospital_code
  16418. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  16419. AND t.hospitalId = mqi_last.hospital_id
  16420. AND t.lastBehospitalCode = mqi_last.behospital_code
  16421. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  16422. AND t.hospitalId = mhp.hospital_id
  16423. AND t.behospitalCode = mhp.behospital_code
  16424. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  16425. AND t.hospitalId = mhp_last.hospital_id
  16426. AND t.lastBehospitalCode = mhp_last.behospital_code
  16427. </select>
  16428. <!-- 单条条目缺陷统计-->
  16429. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  16430. SELECT
  16431. a.beh_dept_id AS id,
  16432. a.beh_dept_name AS NAME,
  16433. count(*) AS num
  16434. FROM
  16435. med_behospital_info a,
  16436. med_qcresult_detail b
  16437. WHERE
  16438. a.is_deleted = 'N'
  16439. AND b.is_deleted = 'N'
  16440. AND a.hospital_id = b.hospital_id
  16441. AND a.behospital_code = b.behospital_code
  16442. AND a.qc_type_id != 0
  16443. and b.cases_entry_id=2658
  16444. <if test="isPlacefile != null and isPlacefile != ''">
  16445. and a.is_placefile = #{isPlacefile}
  16446. </if>
  16447. <if test="hospitalId != null and hospitalId != ''">
  16448. AND a.hospital_id = #{hospitalId}
  16449. </if>
  16450. <if test="isPlacefile != null and isPlacefile == 0">
  16451. <if test="startDate != null and startDate != ''">
  16452. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  16453. </if>
  16454. <if test="endDate != null and endDate != ''">
  16455. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  16456. </if>
  16457. </if>
  16458. <if test="isPlacefile != null and isPlacefile == 1">
  16459. <if test="startDate != null and startDate != ''">
  16460. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  16461. </if>
  16462. <if test="endDate != null and endDate != ''">
  16463. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  16464. </if>
  16465. </if>
  16466. GROUP BY
  16467. a.beh_dept_id,
  16468. a.beh_dept_name
  16469. </select>
  16470. <!-- 单条条目缺陷统计-->
  16471. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  16472. SELECT
  16473. a.beh_dept_id AS deptId,
  16474. a.beh_dept_name AS deptName,
  16475. a.doctor_id as doctorId,
  16476. a.doctor_name as doctorName,
  16477. count(*) AS num
  16478. FROM
  16479. med_behospital_info a,
  16480. med_qcresult_detail b,
  16481. sys_user_dept c
  16482. WHERE
  16483. a.is_deleted = 'N'
  16484. AND b.is_deleted = 'N'
  16485. AND c.is_deleted = 'N'
  16486. AND a.hospital_id = b.hospital_id
  16487. AND a.hospital_id = c.hospital_id
  16488. AND a.behospital_code = b.behospital_code
  16489. AND a.beh_dept_id = c.dept_id
  16490. AND a.qc_type_id != 0
  16491. and b.cases_entry_id=2658
  16492. <if test="isPlacefile != null and isPlacefile != ''">
  16493. and a.is_placefile = #{isPlacefile}
  16494. </if>
  16495. <if test="hospitalId != null and hospitalId != ''">
  16496. AND a.hospital_id = #{hospitalId}
  16497. </if>
  16498. <if test="userId!=null">
  16499. AND c.user_id = #{userId}
  16500. </if>
  16501. <if test="isPlacefile != null and isPlacefile == 0">
  16502. <if test="startDate != null and startDate != ''">
  16503. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  16504. </if>
  16505. <if test="endDate != null and endDate != ''">
  16506. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  16507. </if>
  16508. </if>
  16509. <if test="isPlacefile != null and isPlacefile == 1">
  16510. <if test="startDate != null and startDate != ''">
  16511. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  16512. </if>
  16513. <if test="endDate != null and endDate != ''">
  16514. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  16515. </if>
  16516. </if>
  16517. GROUP BY
  16518. a.beh_dept_id,
  16519. a.beh_dept_name,
  16520. a.doctor_id,
  16521. a.doctor_name
  16522. </select>
  16523. <!-- 病案首页改善率质控评分页(内页)-->
  16524. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  16525. SELECT
  16526. t.*
  16527. FROM
  16528. (
  16529. SELECT DISTINCT
  16530. t1.hospital_id AS hospitalId,
  16531. t1.behospital_code AS behospitalCode,
  16532. t1.bed_code AS bedCode,
  16533. t1.LEVEL AS LEVEL,
  16534. t1.grade_type AS gradeType,
  16535. t1.score_res AS scoreRes,
  16536. t1.scoreBn,
  16537. t1.NAME AS NAME,
  16538. t1.sex AS sex,
  16539. t1.beh_dept_id AS behDeptId,
  16540. t1.beh_dept_name AS behDeptName,
  16541. t1.doctor_id AS doctorId,
  16542. t1.doctor_name AS doctorName,
  16543. t1.beh_doctor_id AS behDoctorId,
  16544. t1.beh_doctor_name AS behDoctorName,
  16545. t1.director_doctor_id AS directorDoctorId,
  16546. t1.director_doctor_name AS directorDoctorName,
  16547. t1.birthday AS birthday,
  16548. t1.behospital_date AS behospitalDate,
  16549. t1.leave_hospital_date AS leaveHospitalDate,
  16550. t1.placefile_date AS placefileDate,
  16551. t1.gmt_create AS gradeTime,
  16552. t1.diagnose,
  16553. t1.ward_name AS wardName,
  16554. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  16555. t1.file_code AS fileCode,
  16556. t1.checkStatus,
  16557. t1.chName,
  16558. t1.chTime,
  16559. t1.is_daytime as isDaytime
  16560. FROM
  16561. (
  16562. SELECT
  16563. be.*,
  16564. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16565. mci.check_name AS chName,
  16566. mci.gmt_create AS chTime
  16567. FROM
  16568. (
  16569. SELECT DISTINCT
  16570. a.hospital_id,
  16571. a.behospital_code,
  16572. a.bed_code,
  16573. a.file_code,
  16574. c.LEVEL,
  16575. c.grade_type,
  16576. c.score_res,
  16577. a.NAME,
  16578. a.sex,
  16579. a.beh_dept_id,
  16580. a.beh_dept_name,
  16581. a.birthday,
  16582. a.behospital_date,
  16583. a.leave_hospital_date,
  16584. a.doctor_id,
  16585. a.doctor_name,
  16586. a.beh_doctor_id,
  16587. a.beh_doctor_name,
  16588. a.director_doctor_id,
  16589. a.director_doctor_name,
  16590. a.diagnose,
  16591. a.placefile_date,
  16592. a.ward_name,
  16593. c.gmt_create,
  16594. d.score_res as scoreBn,
  16595. a.is_daytime
  16596. FROM
  16597. med_behospital_info a,
  16598. med_home_page b,
  16599. med_qcresult_info c,
  16600. med_qcresult_cases d,
  16601. (
  16602. SELECT
  16603. m4.*
  16604. FROM
  16605. med_behospital_info m1,
  16606. med_home_page m2,
  16607. med_qcresult_info m3,
  16608. med_qcresult_cases m4
  16609. WHERE
  16610. m1.is_deleted = 'N'
  16611. AND m2.is_deleted = 'N'
  16612. AND m3.is_deleted = 'Y'
  16613. AND m4.is_deleted = 'Y'
  16614. AND m1.hospital_id = m2.hospital_id
  16615. AND m1.hospital_id = m3.hospital_id
  16616. AND m1.hospital_id = m4.hospital_id
  16617. AND m1.behospital_code = m2.behospital_code
  16618. AND m1.behospital_code = m3.behospital_code
  16619. AND m1.behospital_code = m4.behospital_code
  16620. AND m3.gmt_create = m4.gmt_create
  16621. AND m3.have_home_page = 1
  16622. AND m4.cases_id = 243
  16623. AND m1.qc_type_id != 0
  16624. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  16625. and m1.is_daytime = #{qcResultShortPageVO.isDaytime}
  16626. </if>
  16627. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16628. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16629. </if>
  16630. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16631. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16632. </if>
  16633. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16634. <if test="qcResultShortPageVO.startDate != null ">
  16635. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16636. </if>
  16637. <if test="qcResultShortPageVO.endDate != null ">
  16638. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16639. </if>
  16640. </if>
  16641. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16642. <if test="qcResultShortPageVO.startDate != null">
  16643. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16644. </if>
  16645. <if test="qcResultShortPageVO.endDate != null ">
  16646. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16647. </if>
  16648. </if>
  16649. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16650. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16651. </if>
  16652. GROUP BY
  16653. m1.behospital_code
  16654. ORDER BY
  16655. m1.behospital_code,
  16656. m4.gmt_create
  16657. ) e
  16658. WHERE
  16659. a.is_deleted = 'N'
  16660. AND b.is_deleted = 'N'
  16661. AND c.is_deleted = 'N'
  16662. AND d.is_deleted = 'N'
  16663. AND a.hospital_id = b.hospital_id
  16664. AND a.hospital_id = c.hospital_id
  16665. AND a.hospital_id = d.hospital_id
  16666. AND a.hospital_id = e.hospital_id
  16667. AND a.behospital_code = b.behospital_code
  16668. AND a.behospital_code = c.behospital_code
  16669. AND a.behospital_code = d.behospital_code
  16670. AND a.behospital_code = e.behospital_code
  16671. AND d.cases_id = 243
  16672. AND d.score_res > e.score_res
  16673. AND a.qc_type_id != 0
  16674. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  16675. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  16676. </if>
  16677. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16678. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16679. </if>
  16680. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16681. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16682. </if>
  16683. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16684. <if test="qcResultShortPageVO.startDate != null ">
  16685. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16686. </if>
  16687. <if test="qcResultShortPageVO.endDate != null ">
  16688. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16689. </if>
  16690. </if>
  16691. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16692. <if test="qcResultShortPageVO.startDate != null ">
  16693. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16694. </if>
  16695. <if test="qcResultShortPageVO.endDate != null">
  16696. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16697. </if>
  16698. </if>
  16699. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16700. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16701. </if>
  16702. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16703. AND c.`level` = #{qcResultShortPageVO.level}
  16704. </if>
  16705. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16706. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16707. </if>
  16708. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  16709. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  16710. </if>
  16711. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16712. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16713. </if>
  16714. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16715. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16716. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16717. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16718. </if>
  16719. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16720. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16721. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16722. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16723. </if>
  16724. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16725. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16726. </if>
  16727. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16728. AND d.score_res = 20
  16729. </if>
  16730. ) be
  16731. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16732. AND mci.check_type in(0,2)
  16733. AND be.hospital_id = mci.hospital_id
  16734. AND be.behospital_code = mci.behospital_code
  16735. ) t1
  16736. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16737. AND t1.behospital_code = t2.behospital_code
  16738. AND t2.is_deleted = 'N'
  16739. ) t
  16740. WHERE
  16741. 1 = 1
  16742. <if test="qcResultShortPageVO.checkStatus != null">
  16743. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16744. </if>
  16745. <if test="qcResultShortPageVO.mrStatus != null">
  16746. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16747. </if>
  16748. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16749. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16750. </if>
  16751. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16752. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16753. </if>
  16754. <if test="qcResultShortPageVO.chTimeStart != null ">
  16755. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16756. </if>
  16757. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16758. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16759. </if>
  16760. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16761. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16762. </if>
  16763. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16764. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16765. </if>
  16766. </select>
  16767. <!-- 病案首页改善率质控评分页(内页)-科室-->
  16768. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  16769. SELECT
  16770. t.*
  16771. FROM
  16772. (
  16773. SELECT DISTINCT
  16774. t1.hospital_id AS hospitalId,
  16775. t1.behospital_code AS behospitalCode,
  16776. t1.bed_code AS bedCode,
  16777. t1.LEVEL AS LEVEL,
  16778. t1.grade_type AS gradeType,
  16779. t1.score_res AS scoreRes,
  16780. t1.NAME AS NAME,
  16781. t1.scoreBn,
  16782. t1.sex AS sex,
  16783. t1.beh_dept_id AS behDeptId,
  16784. t1.beh_dept_name AS behDeptName,
  16785. t1.doctor_id AS doctorId,
  16786. t1.doctor_name AS doctorName,
  16787. t1.beh_doctor_id AS behDoctorId,
  16788. t1.beh_doctor_name AS behDoctorName,
  16789. t1.director_doctor_id AS directorDoctorId,
  16790. t1.director_doctor_name AS directorDoctorName,
  16791. t1.birthday AS birthday,
  16792. t1.behospital_date AS behospitalDate,
  16793. t1.leave_hospital_date AS leaveHospitalDate,
  16794. t1.placefile_date AS placefileDate,
  16795. t1.gmt_create AS gradeTime,
  16796. t1.diagnose,
  16797. t1.ward_name AS wardName,
  16798. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  16799. t1.file_code AS fileCode,
  16800. t1.checkStatus,
  16801. t1.mrStatus,
  16802. t1.chName,
  16803. t1.mrName,
  16804. t1.chTime,
  16805. t1.mrTime,
  16806. t1.is_daytime as isDaytime
  16807. FROM
  16808. (
  16809. SELECT
  16810. be.*,
  16811. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16812. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16813. mci.check_name AS chName,
  16814. hm_mci.check_name AS mrName,
  16815. e.score_res as scoreBn,
  16816. mci.gmt_create AS chTime,
  16817. hm_mci.gmt_create AS mrTime
  16818. FROM
  16819. (
  16820. SELECT DISTINCT
  16821. a.hospital_id,
  16822. a.behospital_code,
  16823. a.bed_code,
  16824. a.file_code,
  16825. c.LEVEL,
  16826. c.grade_type,
  16827. c.score_res,
  16828. a.NAME,
  16829. a.sex,
  16830. a.beh_dept_id,
  16831. a.beh_dept_name,
  16832. a.birthday,
  16833. a.behospital_date,
  16834. a.leave_hospital_date,
  16835. a.doctor_id,
  16836. a.doctor_name,
  16837. a.beh_doctor_id,
  16838. a.beh_doctor_name,
  16839. a.director_doctor_id,
  16840. a.director_doctor_name,
  16841. a.diagnose,
  16842. a.placefile_date,
  16843. a.ward_name,
  16844. a.is_daytime,
  16845. c.gmt_create
  16846. FROM
  16847. med_behospital_info a,
  16848. med_home_page b,
  16849. med_qcresult_info c,
  16850. med_qcresult_cases d,
  16851. sys_user_dept f,
  16852. (
  16853. SELECT
  16854. m4.*
  16855. FROM
  16856. med_behospital_info m1,
  16857. med_home_page m2,
  16858. med_qcresult_info m3,
  16859. med_qcresult_cases m4
  16860. WHERE
  16861. m1.is_deleted = 'N'
  16862. AND m2.is_deleted = 'N'
  16863. AND m3.is_deleted = 'Y'
  16864. AND m4.is_deleted = 'Y'
  16865. AND m1.hospital_id = m2.hospital_id
  16866. AND m1.hospital_id = m3.hospital_id
  16867. AND m1.hospital_id = m4.hospital_id
  16868. AND m1.behospital_code = m2.behospital_code
  16869. AND m1.behospital_code = m3.behospital_code
  16870. AND m1.behospital_code = m4.behospital_code
  16871. AND m3.gmt_create = m4.gmt_create
  16872. AND m3.have_home_page = 1
  16873. AND m4.cases_id = 243
  16874. AND m1.qc_type_id != 0
  16875. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  16876. and m1.is_daytime = #{qcResultShortPageVO.isDaytime}
  16877. </if>
  16878. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16879. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16880. </if>
  16881. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16882. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16883. </if>
  16884. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16885. <if test="qcResultShortPageVO.startDate != null ">
  16886. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16887. </if>
  16888. <if test="qcResultShortPageVO.endDate != null ">
  16889. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16890. </if>
  16891. </if>
  16892. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16893. <if test="qcResultShortPageVO.startDate != null">
  16894. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16895. </if>
  16896. <if test="qcResultShortPageVO.endDate != null ">
  16897. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16898. </if>
  16899. </if>
  16900. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16901. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  16902. </if>
  16903. GROUP BY
  16904. m1.behospital_code
  16905. ORDER BY
  16906. m1.behospital_code,
  16907. m4.gmt_create
  16908. ) e
  16909. WHERE
  16910. a.is_deleted = 'N'
  16911. AND b.is_deleted = 'N'
  16912. AND c.is_deleted = 'N'
  16913. AND d.is_deleted = 'N'
  16914. AND f.is_deleted = 'N'
  16915. AND a.hospital_id = b.hospital_id
  16916. AND a.hospital_id = c.hospital_id
  16917. AND a.hospital_id = d.hospital_id
  16918. AND a.hospital_id = f.hospital_id
  16919. AND a.hospital_id = e.hospital_id
  16920. AND a.behospital_code = b.behospital_code
  16921. AND a.behospital_code = c.behospital_code
  16922. AND a.behospital_code = d.behospital_code
  16923. AND a.beh_dept_id = f.dept_id
  16924. AND a.behospital_code = e.behospital_code
  16925. AND d.cases_id = 243
  16926. AND d.score_res > e.score_res
  16927. AND a.qc_type_id != 0
  16928. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  16929. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  16930. </if>
  16931. <if test="qcResultShortPageVO.userId!=null">
  16932. AND f.user_id = #{qcResultShortPageVO.userId}
  16933. </if>
  16934. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16935. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16936. </if>
  16937. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16938. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16939. </if>
  16940. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16941. <if test="qcResultShortPageVO.startDate != null ">
  16942. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16943. </if>
  16944. <if test="qcResultShortPageVO.endDate != null ">
  16945. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16946. </if>
  16947. </if>
  16948. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16949. <if test="qcResultShortPageVO.startDate != null ">
  16950. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16951. </if>
  16952. <if test="qcResultShortPageVO.endDate != null">
  16953. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16954. </if>
  16955. </if>
  16956. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16957. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16958. </if>
  16959. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16960. AND c.`level` = #{qcResultShortPageVO.level}
  16961. </if>
  16962. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16963. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16964. </if>
  16965. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  16966. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  16967. </if>
  16968. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16969. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16970. </if>
  16971. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16972. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16973. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16974. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16975. </if>
  16976. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16977. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16978. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16979. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16980. </if>
  16981. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16982. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16983. </if>
  16984. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16985. AND d.score_res = 20
  16986. </if>
  16987. ) be
  16988. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16989. AND mci.check_type in(0,2)
  16990. AND be.hospital_id = mci.hospital_id
  16991. AND be.behospital_code = mci.behospital_code
  16992. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16993. AND hm_mci.check_type = 1
  16994. AND be.hospital_id = hm_mci.hospital_id
  16995. AND be.behospital_code = hm_mci.behospital_code
  16996. LEFT JOIN med_qcresult_cases e
  16997. on be.behospital_code = e.behospital_code
  16998. and be.hospital_id = e.hospital_id
  16999. AND e.is_deleted = 'N'
  17000. and e.cases_id = 243
  17001. ) t1
  17002. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17003. AND t1.behospital_code = t2.behospital_code
  17004. AND t2.is_deleted = 'N'
  17005. ) t
  17006. WHERE
  17007. 1 = 1
  17008. <if test="qcResultShortPageVO.checkStatus != null">
  17009. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17010. </if>
  17011. <if test="qcResultShortPageVO.mrStatus != null">
  17012. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17013. </if>
  17014. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17015. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17016. </if>
  17017. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17018. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17019. </if>
  17020. <if test="qcResultShortPageVO.chTimeStart != null ">
  17021. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17022. </if>
  17023. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17024. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17025. </if>
  17026. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17027. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17028. </if>
  17029. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17030. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17031. </if>
  17032. </select>
  17033. <!-- 质控核查质控评分页(内页)-->
  17034. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  17035. SELECT
  17036. t.*
  17037. FROM
  17038. (
  17039. SELECT DISTINCT
  17040. t1.hospital_id AS hospitalId,
  17041. t1.behospital_code AS behospitalCode,
  17042. t1.bed_code AS bedCode,
  17043. t1.LEVEL AS LEVEL,
  17044. t1.grade_type AS gradeType,
  17045. t1.score_res AS scoreRes,
  17046. t1.scoreBn,
  17047. t1.NAME AS NAME,
  17048. t1.sex AS sex,
  17049. t1.beh_dept_id AS behDeptId,
  17050. t1.beh_dept_name AS behDeptName,
  17051. t1.doctor_id AS doctorId,
  17052. t1.doctor_name AS doctorName,
  17053. t1.beh_doctor_id AS behDoctorId,
  17054. t1.beh_doctor_name AS behDoctorName,
  17055. t1.director_doctor_id AS directorDoctorId,
  17056. t1.director_doctor_name AS directorDoctorName,
  17057. t1.birthday AS birthday,
  17058. t1.behospital_date AS behospitalDate,
  17059. t1.leave_hospital_date AS leaveHospitalDate,
  17060. t1.placefile_date AS placefileDate,
  17061. t1.gmt_create AS gradeTime,
  17062. t1.diagnose,
  17063. t1.ward_name AS wardName,
  17064. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  17065. t1.file_code AS fileCode,
  17066. t1.checkStatus,
  17067. t1.chName,
  17068. t1.chTime,
  17069. t1.is_daytime as isDaytime
  17070. FROM
  17071. (
  17072. SELECT
  17073. be.*,
  17074. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17075. mci.check_name AS chName,
  17076. e.score_res as scoreBn,
  17077. mci.gmt_create AS chTime
  17078. FROM
  17079. (
  17080. SELECT DISTINCT
  17081. a.hospital_id,
  17082. a.behospital_code,
  17083. a.bed_code,
  17084. a.file_code,
  17085. b.LEVEL,
  17086. b.grade_type,
  17087. b.score_res,
  17088. a.NAME,
  17089. a.sex,
  17090. a.beh_dept_id,
  17091. a.beh_dept_name,
  17092. a.birthday,
  17093. a.behospital_date,
  17094. a.leave_hospital_date,
  17095. a.doctor_id,
  17096. a.doctor_name,
  17097. a.beh_doctor_id,
  17098. a.beh_doctor_name,
  17099. a.director_doctor_id,
  17100. a.director_doctor_name,
  17101. a.diagnose,
  17102. a.placefile_date,
  17103. a.ward_name,
  17104. b.gmt_create,
  17105. a.is_daytime
  17106. FROM
  17107. med_behospital_info a,
  17108. med_qcresult_info b
  17109. WHERE
  17110. a.is_deleted = 'N'
  17111. AND b.is_deleted = 'N'
  17112. AND a.hospital_id = b.hospital_id
  17113. AND a.behospital_code = b.behospital_code
  17114. AND a.qc_type_id != 0
  17115. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  17116. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  17117. </if>
  17118. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17119. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17120. </if>
  17121. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17122. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17123. </if>
  17124. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17125. <if test="qcResultShortPageVO.startDate != null ">
  17126. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17127. </if>
  17128. <if test="qcResultShortPageVO.endDate != null ">
  17129. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17130. </if>
  17131. </if>
  17132. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17133. <if test="qcResultShortPageVO.startDate != null ">
  17134. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17135. </if>
  17136. <if test="qcResultShortPageVO.endDate != null">
  17137. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17138. </if>
  17139. </if>
  17140. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17141. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17142. </if>
  17143. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17144. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17145. </if>
  17146. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17147. AND b.`level` = #{qcResultShortPageVO.level}
  17148. </if>
  17149. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17150. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17151. </if>
  17152. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  17153. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  17154. </if>
  17155. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17156. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17157. </if>
  17158. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17159. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17160. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17161. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17162. </if>
  17163. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17164. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17165. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17166. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17167. </if>
  17168. ) be
  17169. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17170. AND mci.check_type in(0,2)
  17171. AND be.hospital_id = mci.hospital_id
  17172. AND be.behospital_code = mci.behospital_code
  17173. LEFT JOIN med_qcresult_cases e
  17174. on be.behospital_code = e.behospital_code
  17175. and be.hospital_id = e.hospital_id
  17176. AND e.is_deleted = 'N'
  17177. and e.cases_id = 243
  17178. ) t1
  17179. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17180. AND t1.behospital_code = t2.behospital_code
  17181. AND t2.is_deleted = 'N'
  17182. ) t
  17183. WHERE
  17184. 1 = 1
  17185. <if test="qcResultShortPageVO.checkStatus != null">
  17186. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17187. </if>
  17188. <if test="qcResultShortPageVO.mrStatus != null">
  17189. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17190. </if>
  17191. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17192. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17193. </if>
  17194. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17195. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17196. </if>
  17197. <if test="qcResultShortPageVO.chTimeStart != null ">
  17198. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17199. </if>
  17200. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17201. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17202. </if>
  17203. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17204. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17205. </if>
  17206. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17207. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17208. </if>
  17209. </select>
  17210. <!-- 质控核查质控评分页-科室(内页)-->
  17211. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  17212. SELECT
  17213. t.*
  17214. FROM
  17215. (
  17216. SELECT DISTINCT
  17217. t1.hospital_id AS hospitalId,
  17218. t1.behospital_code AS behospitalCode,
  17219. t1.bed_code AS bedCode,
  17220. t1.LEVEL AS LEVEL,
  17221. t1.grade_type AS gradeType,
  17222. t1.score_res AS scoreRes,
  17223. t1.scoreBn,
  17224. t1.NAME AS NAME,
  17225. t1.sex AS sex,
  17226. t1.beh_dept_id AS behDeptId,
  17227. t1.beh_dept_name AS behDeptName,
  17228. t1.doctor_id AS doctorId,
  17229. t1.doctor_name AS doctorName,
  17230. t1.beh_doctor_id AS behDoctorId,
  17231. t1.beh_doctor_name AS behDoctorName,
  17232. t1.director_doctor_id AS directorDoctorId,
  17233. t1.director_doctor_name AS directorDoctorName,
  17234. t1.birthday AS birthday,
  17235. t1.behospital_date AS behospitalDate,
  17236. t1.leave_hospital_date AS leaveHospitalDate,
  17237. t1.placefile_date AS placefileDate,
  17238. t1.gmt_create AS gradeTime,
  17239. t1.diagnose,
  17240. t1.ward_name AS wardName,
  17241. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  17242. t1.file_code AS fileCode,
  17243. t1.checkStatus,
  17244. t1.mrStatus,
  17245. t1.chName,
  17246. t1.mrName,
  17247. t1.chTime,
  17248. t1.mrTime,
  17249. t1.is_daytime as isDaytime
  17250. FROM
  17251. (
  17252. SELECT
  17253. be.*,
  17254. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17255. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17256. mci.check_name AS chName,
  17257. e.score_res as scoreBn,
  17258. hm_mci.check_name AS mrName,
  17259. mci.gmt_create AS chTime,
  17260. hm_mci.gmt_create AS mrTime
  17261. FROM
  17262. (
  17263. SELECT DISTINCT
  17264. a.hospital_id,
  17265. a.behospital_code,
  17266. a.bed_code,
  17267. a.file_code,
  17268. b.LEVEL,
  17269. b.grade_type,
  17270. b.score_res,
  17271. a.NAME,
  17272. a.sex,
  17273. a.beh_dept_id,
  17274. a.beh_dept_name,
  17275. a.birthday,
  17276. a.behospital_date,
  17277. a.leave_hospital_date,
  17278. a.doctor_id,
  17279. a.doctor_name,
  17280. a.beh_doctor_id,
  17281. a.beh_doctor_name,
  17282. a.director_doctor_id,
  17283. a.director_doctor_name,
  17284. a.diagnose,
  17285. a.placefile_date,
  17286. a.ward_name,
  17287. a.is_daytime,
  17288. b.gmt_create
  17289. FROM
  17290. med_behospital_info a,
  17291. med_qcresult_info b,
  17292. sys_user_dept c
  17293. WHERE
  17294. a.is_deleted = 'N'
  17295. AND b.is_deleted = 'N'
  17296. AND c.is_deleted = 'N'
  17297. AND a.hospital_id = b.hospital_id
  17298. AND a.hospital_id = c.hospital_id
  17299. AND a.beh_dept_id = c.dept_id
  17300. AND a.behospital_code = b.behospital_code
  17301. AND a.qc_type_id != 0
  17302. <if test="qcResultShortPageVO.isDaytime != null and qcResultShortPageVO.isDaytime != ''">
  17303. and a.is_daytime = #{qcResultShortPageVO.isDaytime}
  17304. </if>
  17305. <if test="qcResultShortPageVO.userId!=null">
  17306. AND c.user_id = #{qcResultShortPageVO.userId}
  17307. </if>
  17308. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17309. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17310. </if>
  17311. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17312. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17313. </if>
  17314. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17315. <if test="qcResultShortPageVO.startDate != null ">
  17316. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17317. </if>
  17318. <if test="qcResultShortPageVO.endDate != null ">
  17319. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17320. </if>
  17321. </if>
  17322. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17323. <if test="qcResultShortPageVO.startDate != null ">
  17324. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17325. </if>
  17326. <if test="qcResultShortPageVO.endDate != null">
  17327. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17328. </if>
  17329. </if>
  17330. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17331. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17332. </if>
  17333. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17334. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17335. </if>
  17336. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17337. AND b.`level` = #{qcResultShortPageVO.level}
  17338. </if>
  17339. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17340. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17341. </if>
  17342. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  17343. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  17344. </if>
  17345. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17346. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17347. </if>
  17348. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17349. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17350. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17351. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17352. </if>
  17353. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17354. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17355. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17356. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17357. </if>
  17358. ) be
  17359. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17360. AND mci.check_type in(0,2)
  17361. AND be.hospital_id = mci.hospital_id
  17362. AND be.behospital_code = mci.behospital_code
  17363. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17364. AND hm_mci.check_type = 1
  17365. AND be.hospital_id = hm_mci.hospital_id
  17366. AND be.behospital_code = hm_mci.behospital_code
  17367. LEFT JOIN med_qcresult_cases e
  17368. on be.behospital_code = e.behospital_code
  17369. and be.hospital_id = e.hospital_id
  17370. AND e.is_deleted = 'N'
  17371. and e.cases_id = 243
  17372. ) t1
  17373. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17374. AND t1.behospital_code = t2.behospital_code
  17375. AND t2.is_deleted = 'N'
  17376. ) t
  17377. WHERE
  17378. 1 = 1
  17379. <if test="qcResultShortPageVO.checkStatus != null">
  17380. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17381. </if>
  17382. <if test="qcResultShortPageVO.mrStatus != null">
  17383. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17384. </if>
  17385. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17386. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17387. </if>
  17388. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17389. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17390. </if>
  17391. <if test="qcResultShortPageVO.chTimeStart != null ">
  17392. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17393. </if>
  17394. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17395. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17396. </if>
  17397. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17398. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17399. </if>
  17400. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17401. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17402. </if>
  17403. </select>
  17404. <!-- 病案首页改善率质控评分页导出-->
  17405. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  17406. SELECT
  17407. f1.behDeptId,
  17408. f1.behDeptName,
  17409. f1.patName,
  17410. f1.behospitalCode,
  17411. f1.hospitalId,
  17412. f1.behospitalDate,
  17413. f1.leaveHospitalDate,
  17414. f1.score,
  17415. f1.scoreBn,
  17416. f2.avgScore,
  17417. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17418. f1.msg,
  17419. f1.caseName,
  17420. </if>
  17421. f1.checkStatus,
  17422. f1.chName,
  17423. f1.chTime
  17424. FROM
  17425. (SELECT
  17426. t.doctorName AS behDoctorName,
  17427. t.`name` AS patName,
  17428. t.behospitalCode AS behospitalCode,
  17429. t.behospitalDate AS behospitalDate,
  17430. t.leaveHospitalDate AS leaveHospitalDate,
  17431. qi.score_res AS score,
  17432. t.scoreBn,
  17433. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17434. qd.msg AS msg,
  17435. qc.NAME AS caseName,
  17436. </if>
  17437. t.behDeptId,
  17438. t.behDeptName,
  17439. t.hospitalId,
  17440. t.checkStatus,
  17441. t.chName,
  17442. t.chTime
  17443. FROM
  17444. (
  17445. SELECT DISTINCT
  17446. t1.hospital_id AS hospitalId,
  17447. t1.behospital_code AS behospitalCode,
  17448. t1.bed_code AS bedCode,
  17449. t1.LEVEL AS LEVEL,
  17450. t1.grade_type AS gradeType,
  17451. t1.score_res AS scoreRes,
  17452. t1.scoreBn,
  17453. t1.NAME AS NAME,
  17454. t1.sex AS sex,
  17455. t1.beh_dept_id AS behDeptId,
  17456. t1.beh_dept_name AS behDeptName,
  17457. t1.doctor_id AS doctorId,
  17458. t1.doctor_name AS doctorName,
  17459. t1.beh_doctor_id AS behDoctorId,
  17460. t1.beh_doctor_name AS behDoctorName,
  17461. t1.director_doctor_id AS directorDoctorId,
  17462. t1.director_doctor_name AS directorDoctorName,
  17463. t1.birthday AS birthday,
  17464. t1.behospital_date AS behospitalDate,
  17465. t1.leave_hospital_date AS leaveHospitalDate,
  17466. t1.placefile_date AS placefileDate,
  17467. t1.gmt_create AS gradeTime,
  17468. t1.diagnose,
  17469. t1.ward_name AS wardName,
  17470. t2.age,
  17471. t1.file_code AS fileCode,
  17472. t1.checkStatus,
  17473. t1.chName,
  17474. t1.chTime
  17475. FROM
  17476. (
  17477. SELECT
  17478. be.*,
  17479. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17480. mci.check_name AS chName,
  17481. mci.gmt_create AS chTime
  17482. FROM
  17483. (
  17484. SELECT DISTINCT
  17485. a.hospital_id,
  17486. a.behospital_code,
  17487. a.bed_code,
  17488. a.file_code,
  17489. c.LEVEL,
  17490. c.grade_type,
  17491. c.score_res,
  17492. a.NAME,
  17493. a.sex,
  17494. a.beh_dept_id,
  17495. a.beh_dept_name,
  17496. a.birthday,
  17497. a.behospital_date,
  17498. a.leave_hospital_date,
  17499. a.doctor_id,
  17500. a.doctor_name,
  17501. a.beh_doctor_id,
  17502. a.beh_doctor_name,
  17503. a.director_doctor_id,
  17504. a.director_doctor_name,
  17505. a.diagnose,
  17506. a.placefile_date,
  17507. a.ward_name,
  17508. c.gmt_create,
  17509. d.score_res as scoreBn
  17510. FROM
  17511. med_behospital_info a,
  17512. med_home_page b,
  17513. med_qcresult_info c,
  17514. med_qcresult_cases d,
  17515. (
  17516. SELECT
  17517. m4.*
  17518. FROM
  17519. med_behospital_info m1,
  17520. med_home_page m2,
  17521. med_qcresult_info m3,
  17522. med_qcresult_cases m4
  17523. WHERE
  17524. m1.is_deleted = 'N'
  17525. AND m2.is_deleted = 'N'
  17526. AND m3.is_deleted = 'Y'
  17527. AND m4.is_deleted = 'Y'
  17528. AND m1.hospital_id = m2.hospital_id
  17529. AND m1.hospital_id = m3.hospital_id
  17530. AND m1.hospital_id = m4.hospital_id
  17531. AND m1.behospital_code = m2.behospital_code
  17532. AND m1.behospital_code = m3.behospital_code
  17533. AND m1.behospital_code = m4.behospital_code
  17534. AND m3.gmt_create = m4.gmt_create
  17535. AND m3.have_home_page = 1
  17536. AND m4.cases_id = 243
  17537. AND m1.qc_type_id != 0
  17538. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17539. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17540. </if>
  17541. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17542. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  17543. </if>
  17544. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17545. <if test="qcResultShortPageVO.startDate != null ">
  17546. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17547. </if>
  17548. <if test="qcResultShortPageVO.endDate != null ">
  17549. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17550. </if>
  17551. </if>
  17552. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17553. <if test="qcResultShortPageVO.startDate != null">
  17554. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17555. </if>
  17556. <if test="qcResultShortPageVO.endDate != null ">
  17557. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17558. </if>
  17559. </if>
  17560. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17561. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  17562. </if>
  17563. GROUP BY
  17564. m1.behospital_code
  17565. ORDER BY
  17566. m1.behospital_code,
  17567. m4.gmt_create
  17568. ) e
  17569. WHERE
  17570. a.is_deleted = 'N'
  17571. AND b.is_deleted = 'N'
  17572. AND c.is_deleted = 'N'
  17573. AND d.is_deleted = 'N'
  17574. AND a.hospital_id = b.hospital_id
  17575. AND a.hospital_id = c.hospital_id
  17576. AND a.hospital_id = d.hospital_id
  17577. AND a.hospital_id = e.hospital_id
  17578. AND a.behospital_code = b.behospital_code
  17579. AND a.behospital_code = c.behospital_code
  17580. AND a.behospital_code = d.behospital_code
  17581. AND a.behospital_code = e.behospital_code
  17582. AND d.cases_id = 243
  17583. AND d.score_res > e.score_res
  17584. AND a.qc_type_id != 0
  17585. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17586. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17587. </if>
  17588. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17589. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17590. </if>
  17591. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17592. <if test="qcResultShortPageVO.startDate != null ">
  17593. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17594. </if>
  17595. <if test="qcResultShortPageVO.endDate != null ">
  17596. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17597. </if>
  17598. </if>
  17599. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17600. <if test="qcResultShortPageVO.startDate != null ">
  17601. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17602. </if>
  17603. <if test="qcResultShortPageVO.endDate != null">
  17604. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17605. </if>
  17606. </if>
  17607. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17608. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17609. </if>
  17610. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17611. AND c.`level` = #{qcResultShortPageVO.level}
  17612. </if>
  17613. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17614. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17615. </if>
  17616. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17617. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17618. </if>
  17619. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17620. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17621. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17622. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17623. </if>
  17624. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17625. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17626. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17627. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17628. </if>
  17629. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  17630. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  17631. </if>
  17632. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  17633. AND d.score_res = 20
  17634. </if>
  17635. ) be
  17636. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17637. AND mci.check_type in(0,2)
  17638. AND be.hospital_id = mci.hospital_id
  17639. AND be.behospital_code = mci.behospital_code
  17640. ) t1
  17641. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17642. AND t1.behospital_code = t2.behospital_code
  17643. AND t2.is_deleted = 'N'
  17644. ) t
  17645. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17646. AND t.hospitalId = qi.hospital_id
  17647. AND t.behospitalCode = qi.behospital_code
  17648. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17649. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17650. AND t.hospitalId = qd.hospital_id
  17651. AND t.behospitalCode = qd.behospital_code
  17652. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17653. AND qd.cases_id = qc.id
  17654. </if>
  17655. where 1=1
  17656. <if test="qcResultShortPageVO.checkStatus != null">
  17657. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17658. </if>
  17659. <if test="qcResultShortPageVO.mrStatus != null">
  17660. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17661. </if>
  17662. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17663. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17664. </if>
  17665. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17666. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17667. </if>
  17668. <if test="qcResultShortPageVO.chTimeStart != null ">
  17669. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17670. </if>
  17671. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17672. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17673. </if>
  17674. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17675. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17676. </if>
  17677. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17678. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17679. </if>
  17680. )f1,
  17681. (SELECT
  17682. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17683. t.behDeptId,
  17684. t.behDeptName
  17685. FROM
  17686. (
  17687. SELECT DISTINCT
  17688. t1.hospital_id AS hospitalId,
  17689. t1.behospital_code AS behospitalCode,
  17690. t1.bed_code AS bedCode,
  17691. t1.LEVEL AS LEVEL,
  17692. t1.grade_type AS gradeType,
  17693. t1.score_res AS scoreRes,
  17694. t1.NAME AS NAME,
  17695. t1.sex AS sex,
  17696. t1.beh_dept_id AS behDeptId,
  17697. t1.beh_dept_name AS behDeptName,
  17698. t1.doctor_id AS doctorId,
  17699. t1.doctor_name AS doctorName,
  17700. t1.beh_doctor_id AS behDoctorId,
  17701. t1.beh_doctor_name AS behDoctorName,
  17702. t1.director_doctor_id AS directorDoctorId,
  17703. t1.director_doctor_name AS directorDoctorName,
  17704. t1.birthday AS birthday,
  17705. t1.behospital_date AS behospitalDate,
  17706. t1.leave_hospital_date AS leaveHospitalDate,
  17707. t1.placefile_date AS placefileDate,
  17708. t1.gmt_create AS gradeTime,
  17709. t1.diagnose,
  17710. t1.ward_name AS wardName,
  17711. t2.age,
  17712. t1.file_code AS fileCode,
  17713. t1.checkStatus,
  17714. t1.chName,
  17715. t1.chTime
  17716. FROM
  17717. (
  17718. SELECT
  17719. be.*,
  17720. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17721. mci.check_name AS chName,
  17722. mci.gmt_create AS chTime
  17723. FROM
  17724. (
  17725. SELECT DISTINCT
  17726. a.hospital_id,
  17727. a.behospital_code,
  17728. a.bed_code,
  17729. a.file_code,
  17730. c.LEVEL,
  17731. c.grade_type,
  17732. c.score_res,
  17733. a.NAME,
  17734. a.sex,
  17735. a.beh_dept_id,
  17736. a.beh_dept_name,
  17737. a.birthday,
  17738. a.behospital_date,
  17739. a.leave_hospital_date,
  17740. a.doctor_id,
  17741. a.doctor_name,
  17742. a.beh_doctor_id,
  17743. a.beh_doctor_name,
  17744. a.director_doctor_id,
  17745. a.director_doctor_name,
  17746. a.diagnose,
  17747. a.placefile_date,
  17748. a.ward_name,
  17749. c.gmt_create
  17750. FROM
  17751. med_behospital_info a,
  17752. med_home_page b,
  17753. med_qcresult_info c,
  17754. med_qcresult_cases d,
  17755. (
  17756. SELECT
  17757. m4.*
  17758. FROM
  17759. med_behospital_info m1,
  17760. med_home_page m2,
  17761. med_qcresult_info m3,
  17762. med_qcresult_cases m4
  17763. WHERE
  17764. m1.is_deleted = 'N'
  17765. AND m2.is_deleted = 'N'
  17766. AND m3.is_deleted = 'Y'
  17767. AND m4.is_deleted = 'Y'
  17768. AND m1.hospital_id = m2.hospital_id
  17769. AND m1.hospital_id = m3.hospital_id
  17770. AND m1.hospital_id = m4.hospital_id
  17771. AND m1.behospital_code = m2.behospital_code
  17772. AND m1.behospital_code = m3.behospital_code
  17773. AND m1.behospital_code = m4.behospital_code
  17774. AND m3.gmt_create = m4.gmt_create
  17775. AND m3.have_home_page = 1
  17776. AND m4.cases_id = 243
  17777. AND m1.qc_type_id != 0
  17778. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17779. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17780. </if>
  17781. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17782. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  17783. </if>
  17784. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17785. <if test="qcResultShortPageVO.startDate != null ">
  17786. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17787. </if>
  17788. <if test="qcResultShortPageVO.endDate != null ">
  17789. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17790. </if>
  17791. </if>
  17792. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17793. <if test="qcResultShortPageVO.startDate != null">
  17794. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17795. </if>
  17796. <if test="qcResultShortPageVO.endDate != null ">
  17797. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17798. </if>
  17799. </if>
  17800. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17801. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  17802. </if>
  17803. GROUP BY
  17804. m1.behospital_code
  17805. ORDER BY
  17806. m1.behospital_code,
  17807. m4.gmt_create
  17808. ) e
  17809. WHERE
  17810. a.is_deleted = 'N'
  17811. AND b.is_deleted = 'N'
  17812. AND c.is_deleted = 'N'
  17813. AND d.is_deleted = 'N'
  17814. AND a.hospital_id = b.hospital_id
  17815. AND a.hospital_id = c.hospital_id
  17816. AND a.hospital_id = d.hospital_id
  17817. AND a.hospital_id = e.hospital_id
  17818. AND a.behospital_code = b.behospital_code
  17819. AND a.behospital_code = c.behospital_code
  17820. AND a.behospital_code = d.behospital_code
  17821. AND a.behospital_code = e.behospital_code
  17822. AND d.cases_id = 243
  17823. AND d.score_res > e.score_res
  17824. AND a.qc_type_id != 0
  17825. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17826. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17827. </if>
  17828. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17829. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17830. </if>
  17831. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17832. <if test="qcResultShortPageVO.startDate != null ">
  17833. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17834. </if>
  17835. <if test="qcResultShortPageVO.endDate != null ">
  17836. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17837. </if>
  17838. </if>
  17839. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17840. <if test="qcResultShortPageVO.startDate != null ">
  17841. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17842. </if>
  17843. <if test="qcResultShortPageVO.endDate != null">
  17844. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17845. </if>
  17846. </if>
  17847. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17848. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17849. </if>
  17850. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17851. AND c.`level` = #{qcResultShortPageVO.level}
  17852. </if>
  17853. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17854. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17855. </if>
  17856. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17857. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17858. </if>
  17859. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17860. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17861. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17862. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17863. </if>
  17864. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17865. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17866. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17867. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17868. </if>
  17869. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  17870. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  17871. </if>
  17872. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  17873. AND d.score_res = 20
  17874. </if>
  17875. ) be
  17876. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17877. AND mci.check_type in(0,2)
  17878. AND be.hospital_id = mci.hospital_id
  17879. AND be.behospital_code = mci.behospital_code
  17880. ) t1
  17881. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17882. AND t1.behospital_code = t2.behospital_code
  17883. AND t2.is_deleted = 'N'
  17884. ) t
  17885. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17886. AND t.hospitalId = qi.hospital_id
  17887. AND t.behospitalCode = qi.behospital_code
  17888. where 1=1
  17889. <if test="qcResultShortPageVO.checkStatus != null">
  17890. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17891. </if>
  17892. <if test="qcResultShortPageVO.mrStatus != null">
  17893. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17894. </if>
  17895. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17896. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17897. </if>
  17898. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17899. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17900. </if>
  17901. <if test="qcResultShortPageVO.chTimeStart != null ">
  17902. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17903. </if>
  17904. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17905. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17906. </if>
  17907. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17908. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17909. </if>
  17910. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17911. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17912. </if>
  17913. GROUP BY
  17914. t.behDeptId,
  17915. t.behDeptName
  17916. )f2
  17917. WHERE
  17918. f1.behDeptId = f2.behDeptId
  17919. AND f1.behDeptName = f2.behDeptName
  17920. </select>
  17921. <!-- 病案首页改善率质控评分页导出-->
  17922. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  17923. SELECT
  17924. f1.behDeptId,
  17925. f1.behDeptName,
  17926. f1.doctorId,
  17927. f1.doctorName,
  17928. f1.patName,
  17929. f1.behospitalCode,
  17930. f1.hospitalId,
  17931. f1.scoreBn,
  17932. f1.behospitalDate,
  17933. f1.leaveHospitalDate,
  17934. f1.score,
  17935. f2.avgScore,
  17936. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17937. f1.msg,
  17938. f1.caseName,
  17939. </if>
  17940. f1.checkStatus,
  17941. f1.mrStatus,
  17942. f1.chName,
  17943. f1.mrName,
  17944. f1.chTime,
  17945. f1.mrTime
  17946. FROM
  17947. (SELECT
  17948. t.doctorId,
  17949. t.doctorName,
  17950. t.`name` AS patName,
  17951. t.behospitalCode AS behospitalCode,
  17952. t.behospitalDate AS behospitalDate,
  17953. t.leaveHospitalDate AS leaveHospitalDate,
  17954. qi.score_res AS score,
  17955. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17956. qd.msg AS msg,
  17957. qc.NAME AS caseName,
  17958. </if>
  17959. t.behDeptId,
  17960. t.behDeptName,
  17961. t.hospitalId,
  17962. t.checkStatus,
  17963. t.mrStatus,
  17964. t.chName,
  17965. t.mrName,
  17966. t.chTime,
  17967. t.mrTime
  17968. FROM
  17969. (
  17970. SELECT DISTINCT
  17971. t1.hospital_id AS hospitalId,
  17972. t1.behospital_code AS behospitalCode,
  17973. t1.bed_code AS bedCode,
  17974. t1.LEVEL AS LEVEL,
  17975. t1.grade_type AS gradeType,
  17976. t1.score_res AS scoreRes,
  17977. t1.NAME AS NAME,
  17978. t1.sex AS sex,
  17979. t1.beh_dept_id AS behDeptId,
  17980. t1.beh_dept_name AS behDeptName,
  17981. t1.doctor_id AS doctorId,
  17982. t1.doctor_name AS doctorName,
  17983. t1.beh_doctor_id AS behDoctorId,
  17984. t1.beh_doctor_name AS behDoctorName,
  17985. t1.director_doctor_id AS directorDoctorId,
  17986. t1.director_doctor_name AS directorDoctorName,
  17987. t1.birthday AS birthday,
  17988. t1.behospital_date AS behospitalDate,
  17989. t1.leave_hospital_date AS leaveHospitalDate,
  17990. t1.placefile_date AS placefileDate,
  17991. t1.gmt_create AS gradeTime,
  17992. t1.diagnose,
  17993. t1.ward_name AS wardName,
  17994. t1.scoreBn,
  17995. t1.file_code AS fileCode,
  17996. t1.checkStatus,
  17997. t1.mrStatus,
  17998. t1.chName,
  17999. t1.mrName,
  18000. t1.chTime,
  18001. t1.mrTime
  18002. FROM
  18003. (
  18004. SELECT
  18005. be.*,
  18006. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18007. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18008. mci.check_name AS chName,
  18009. e.score_res as scoreBn,
  18010. hm_mci.check_name AS mrName,
  18011. mci.gmt_create AS chTime,
  18012. hm_mci.gmt_create AS mrTime
  18013. FROM
  18014. (
  18015. SELECT DISTINCT
  18016. a.hospital_id,
  18017. a.behospital_code,
  18018. a.bed_code,
  18019. a.file_code,
  18020. c.LEVEL,
  18021. c.grade_type,
  18022. c.score_res,
  18023. a.NAME,
  18024. a.sex,
  18025. a.beh_dept_id,
  18026. a.beh_dept_name,
  18027. a.birthday,
  18028. a.behospital_date,
  18029. a.leave_hospital_date,
  18030. a.doctor_id,
  18031. a.doctor_name,
  18032. a.beh_doctor_id,
  18033. a.beh_doctor_name,
  18034. a.director_doctor_id,
  18035. a.director_doctor_name,
  18036. a.diagnose,
  18037. a.placefile_date,
  18038. a.ward_name,
  18039. c.gmt_create
  18040. FROM
  18041. med_behospital_info a,
  18042. med_home_page b,
  18043. med_qcresult_info c,
  18044. med_qcresult_cases d,
  18045. sys_user_dept f,
  18046. (
  18047. SELECT
  18048. m4.*
  18049. FROM
  18050. med_behospital_info m1,
  18051. med_home_page m2,
  18052. med_qcresult_info m3,
  18053. med_qcresult_cases m4
  18054. WHERE
  18055. m1.is_deleted = 'N'
  18056. AND m2.is_deleted = 'N'
  18057. AND m3.is_deleted = 'Y'
  18058. AND m4.is_deleted = 'Y'
  18059. AND m1.hospital_id = m2.hospital_id
  18060. AND m1.hospital_id = m3.hospital_id
  18061. AND m1.hospital_id = m4.hospital_id
  18062. AND m1.behospital_code = m2.behospital_code
  18063. AND m1.behospital_code = m3.behospital_code
  18064. AND m1.behospital_code = m4.behospital_code
  18065. AND m3.gmt_create = m4.gmt_create
  18066. AND m3.have_home_page = 1
  18067. AND m4.cases_id = 243
  18068. AND m1.qc_type_id != 0
  18069. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18070. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18071. </if>
  18072. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18073. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  18074. </if>
  18075. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18076. <if test="qcResultShortPageVO.startDate != null ">
  18077. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18078. </if>
  18079. <if test="qcResultShortPageVO.endDate != null ">
  18080. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18081. </if>
  18082. </if>
  18083. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18084. <if test="qcResultShortPageVO.startDate != null">
  18085. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18086. </if>
  18087. <if test="qcResultShortPageVO.endDate != null ">
  18088. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18089. </if>
  18090. </if>
  18091. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18092. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  18093. </if>
  18094. GROUP BY
  18095. m1.behospital_code
  18096. ORDER BY
  18097. m1.behospital_code,
  18098. m4.gmt_create
  18099. ) e
  18100. WHERE
  18101. a.is_deleted = 'N'
  18102. AND b.is_deleted = 'N'
  18103. AND c.is_deleted = 'N'
  18104. AND d.is_deleted = 'N'
  18105. AND f.is_deleted = 'N'
  18106. AND a.hospital_id = b.hospital_id
  18107. AND a.hospital_id = c.hospital_id
  18108. AND a.hospital_id = d.hospital_id
  18109. AND a.hospital_id = e.hospital_id
  18110. AND a.hospital_id = f.hospital_id
  18111. AND a.behospital_code = b.behospital_code
  18112. AND a.behospital_code = c.behospital_code
  18113. AND a.behospital_code = d.behospital_code
  18114. AND a.behospital_code = e.behospital_code
  18115. AND a.beh_dept_id = f.dept_id
  18116. AND d.cases_id = 243
  18117. AND d.score_res > e.score_res
  18118. AND a.qc_type_id != 0
  18119. <if test="qcResultShortPageVO.userId!=null">
  18120. AND f.user_id = #{qcResultShortPageVO.userId}
  18121. </if>
  18122. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18123. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18124. </if>
  18125. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18126. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18127. </if>
  18128. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18129. <if test="qcResultShortPageVO.startDate != null ">
  18130. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18131. </if>
  18132. <if test="qcResultShortPageVO.endDate != null ">
  18133. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18134. </if>
  18135. </if>
  18136. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18137. <if test="qcResultShortPageVO.startDate != null ">
  18138. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18139. </if>
  18140. <if test="qcResultShortPageVO.endDate != null">
  18141. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18142. </if>
  18143. </if>
  18144. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18145. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18146. </if>
  18147. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18148. AND c.`level` = #{qcResultShortPageVO.level}
  18149. </if>
  18150. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18151. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18152. </if>
  18153. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18154. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18155. </if>
  18156. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18157. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18158. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18159. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18160. </if>
  18161. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18162. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18163. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18164. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18165. </if>
  18166. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  18167. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  18168. </if>
  18169. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  18170. AND d.score_res = 20
  18171. </if>
  18172. ) be
  18173. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18174. AND mci.check_type in(0,2)
  18175. AND be.hospital_id = mci.hospital_id
  18176. AND be.behospital_code = mci.behospital_code
  18177. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  18178. AND hm_mci.check_type = 1
  18179. AND be.hospital_id = hm_mci.hospital_id
  18180. AND be.behospital_code = hm_mci.behospital_code
  18181. LEFT JOIN med_qcresult_cases e
  18182. on be.behospital_code = e.behospital_code
  18183. and be.hospital_id = e.hospital_id
  18184. AND e.is_deleted = 'N'
  18185. and e.cases_id = 243
  18186. ) t1
  18187. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18188. AND t1.behospital_code = t2.behospital_code
  18189. AND t2.is_deleted = 'N'
  18190. ) t
  18191. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18192. AND t.hospitalId = qi.hospital_id
  18193. AND t.behospitalCode = qi.behospital_code
  18194. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18195. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  18196. AND t.hospitalId = qd.hospital_id
  18197. AND t.behospitalCode = qd.behospital_code
  18198. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  18199. AND qd.cases_id = qc.id
  18200. </if>
  18201. where 1=1
  18202. <if test="qcResultShortPageVO.checkStatus != null">
  18203. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18204. </if>
  18205. <if test="qcResultShortPageVO.mrStatus != null">
  18206. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18207. </if>
  18208. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18209. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18210. </if>
  18211. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18212. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18213. </if>
  18214. <if test="qcResultShortPageVO.chTimeStart != null ">
  18215. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18216. </if>
  18217. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18218. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18219. </if>
  18220. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18221. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18222. </if>
  18223. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18224. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18225. </if>
  18226. )f1,
  18227. (SELECT
  18228. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  18229. t.behDeptId,
  18230. t.behDeptName,
  18231. t.doctorId,
  18232. t.doctorName
  18233. FROM
  18234. (
  18235. SELECT DISTINCT
  18236. t1.hospital_id AS hospitalId,
  18237. t1.behospital_code AS behospitalCode,
  18238. t1.bed_code AS bedCode,
  18239. t1.LEVEL AS LEVEL,
  18240. t1.grade_type AS gradeType,
  18241. t1.score_res AS scoreRes,
  18242. t1.NAME AS NAME,
  18243. t1.sex AS sex,
  18244. t1.beh_dept_id AS behDeptId,
  18245. t1.beh_dept_name AS behDeptName,
  18246. t1.doctor_id AS doctorId,
  18247. t1.doctor_name AS doctorName,
  18248. t1.beh_doctor_id AS behDoctorId,
  18249. t1.beh_doctor_name AS behDoctorName,
  18250. t1.director_doctor_id AS directorDoctorId,
  18251. t1.director_doctor_name AS directorDoctorName,
  18252. t1.birthday AS birthday,
  18253. t1.behospital_date AS behospitalDate,
  18254. t1.leave_hospital_date AS leaveHospitalDate,
  18255. t1.placefile_date AS placefileDate,
  18256. t1.gmt_create AS gradeTime,
  18257. t1.diagnose,
  18258. t1.ward_name AS wardName,
  18259. t2.age,
  18260. t1.file_code AS fileCode,
  18261. t1.checkStatus,
  18262. t1.mrStatus,
  18263. t1.chName,
  18264. t1.mrName,
  18265. t1.chTime,
  18266. t1.mrTime
  18267. FROM
  18268. (
  18269. SELECT
  18270. be.*,
  18271. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18272. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18273. mci.check_name AS chName,
  18274. hm_mci.check_name AS mrName,
  18275. mci.gmt_create AS chTime,
  18276. hm_mci.gmt_create AS mrTime
  18277. FROM
  18278. (
  18279. SELECT DISTINCT
  18280. a.hospital_id,
  18281. a.behospital_code,
  18282. a.bed_code,
  18283. a.file_code,
  18284. c.LEVEL,
  18285. c.grade_type,
  18286. c.score_res,
  18287. a.NAME,
  18288. a.sex,
  18289. a.beh_dept_id,
  18290. a.beh_dept_name,
  18291. a.birthday,
  18292. a.behospital_date,
  18293. a.leave_hospital_date,
  18294. a.doctor_id,
  18295. a.doctor_name,
  18296. a.beh_doctor_id,
  18297. a.beh_doctor_name,
  18298. a.director_doctor_id,
  18299. a.director_doctor_name,
  18300. a.diagnose,
  18301. a.placefile_date,
  18302. a.ward_name,
  18303. c.gmt_create
  18304. FROM
  18305. med_behospital_info a,
  18306. med_home_page b,
  18307. med_qcresult_info c,
  18308. med_qcresult_cases d,
  18309. sys_user_dept f,
  18310. (
  18311. SELECT
  18312. m4.*
  18313. FROM
  18314. med_behospital_info m1,
  18315. med_home_page m2,
  18316. med_qcresult_info m3,
  18317. med_qcresult_cases m4
  18318. WHERE
  18319. m1.is_deleted = 'N'
  18320. AND m2.is_deleted = 'N'
  18321. AND m3.is_deleted = 'Y'
  18322. AND m4.is_deleted = 'Y'
  18323. AND m1.hospital_id = m2.hospital_id
  18324. AND m1.hospital_id = m3.hospital_id
  18325. AND m1.hospital_id = m4.hospital_id
  18326. AND m1.behospital_code = m2.behospital_code
  18327. AND m1.behospital_code = m3.behospital_code
  18328. AND m1.behospital_code = m4.behospital_code
  18329. AND m3.gmt_create = m4.gmt_create
  18330. AND m3.have_home_page = 1
  18331. AND m4.cases_id = 243
  18332. AND m1.qc_type_id != 0
  18333. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18334. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18335. </if>
  18336. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18337. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  18338. </if>
  18339. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18340. <if test="qcResultShortPageVO.startDate != null ">
  18341. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18342. </if>
  18343. <if test="qcResultShortPageVO.endDate != null ">
  18344. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18345. </if>
  18346. </if>
  18347. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18348. <if test="qcResultShortPageVO.startDate != null">
  18349. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18350. </if>
  18351. <if test="qcResultShortPageVO.endDate != null ">
  18352. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18353. </if>
  18354. </if>
  18355. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18356. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  18357. </if>
  18358. GROUP BY
  18359. m1.behospital_code
  18360. ORDER BY
  18361. m1.behospital_code,
  18362. m4.gmt_create
  18363. ) e
  18364. WHERE
  18365. a.is_deleted = 'N'
  18366. AND b.is_deleted = 'N'
  18367. AND c.is_deleted = 'N'
  18368. AND d.is_deleted = 'N'
  18369. AND f.is_deleted = 'N'
  18370. AND a.hospital_id = b.hospital_id
  18371. AND a.hospital_id = c.hospital_id
  18372. AND a.hospital_id = d.hospital_id
  18373. AND a.hospital_id = e.hospital_id
  18374. AND a.hospital_id = f.hospital_id
  18375. AND a.behospital_code = b.behospital_code
  18376. AND a.behospital_code = c.behospital_code
  18377. AND a.behospital_code = d.behospital_code
  18378. AND a.behospital_code = e.behospital_code
  18379. AND a.beh_dept_id = f.dept_id
  18380. AND d.cases_id = 243
  18381. AND d.score_res > e.score_res
  18382. AND a.qc_type_id != 0
  18383. <if test="qcResultShortPageVO.userId!=null">
  18384. AND f.user_id = #{qcResultShortPageVO.userId}
  18385. </if>
  18386. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18387. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18388. </if>
  18389. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18390. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18391. </if>
  18392. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18393. <if test="qcResultShortPageVO.startDate != null ">
  18394. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18395. </if>
  18396. <if test="qcResultShortPageVO.endDate != null ">
  18397. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18398. </if>
  18399. </if>
  18400. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18401. <if test="qcResultShortPageVO.startDate != null ">
  18402. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18403. </if>
  18404. <if test="qcResultShortPageVO.endDate != null">
  18405. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18406. </if>
  18407. </if>
  18408. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18409. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18410. </if>
  18411. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18412. AND c.`level` = #{qcResultShortPageVO.level}
  18413. </if>
  18414. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18415. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18416. </if>
  18417. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18418. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18419. </if>
  18420. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18421. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18422. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18423. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18424. </if>
  18425. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18426. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18427. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18428. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18429. </if>
  18430. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  18431. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  18432. </if>
  18433. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  18434. AND d.score_res = 20
  18435. </if>
  18436. ) be
  18437. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18438. AND mci.check_type in(0,2)
  18439. AND be.hospital_id = mci.hospital_id
  18440. AND be.behospital_code = mci.behospital_code
  18441. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  18442. AND hm_mci.check_type = 1
  18443. AND be.hospital_id = hm_mci.hospital_id
  18444. AND be.behospital_code = hm_mci.behospital_code
  18445. ) t1
  18446. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18447. AND t1.behospital_code = t2.behospital_code
  18448. AND t2.is_deleted = 'N'
  18449. ) t
  18450. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18451. AND t.hospitalId = qi.hospital_id
  18452. AND t.behospitalCode = qi.behospital_code
  18453. where 1=1
  18454. <if test="qcResultShortPageVO.checkStatus != null">
  18455. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18456. </if>
  18457. <if test="qcResultShortPageVO.mrStatus != null">
  18458. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18459. </if>
  18460. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18461. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18462. </if>
  18463. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18464. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18465. </if>
  18466. <if test="qcResultShortPageVO.chTimeStart != null ">
  18467. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18468. </if>
  18469. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18470. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18471. </if>
  18472. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18473. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18474. </if>
  18475. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18476. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18477. </if>
  18478. GROUP BY
  18479. t.doctorId,
  18480. t.doctorName
  18481. )f2
  18482. WHERE
  18483. f1.doctorId = f2.doctorId
  18484. AND f1.doctorName = f2.doctorName
  18485. </select>
  18486. <!-- 质控核查质控评分页导出-->
  18487. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  18488. SELECT
  18489. f1.behDeptId,
  18490. f1.behDeptName,
  18491. f1.doctorName,
  18492. f1.patName,
  18493. f1.behospitalCode,
  18494. f1.hospitalId,
  18495. f1.behospitalDate,
  18496. f1.leaveHospitalDate,
  18497. f1.score,
  18498. f1.scoreBn,
  18499. f2.avgScore,
  18500. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18501. f1.msg,
  18502. f1.caseName,
  18503. </if>
  18504. f1.checkStatus,
  18505. f1.chName,
  18506. f1.chTime
  18507. FROM
  18508. (SELECT
  18509. t.doctorName,
  18510. t.`name` AS patName,
  18511. t.behospitalCode AS behospitalCode,
  18512. t.behospitalDate AS behospitalDate,
  18513. t.leaveHospitalDate AS leaveHospitalDate,
  18514. qi.score_res AS score,
  18515. t.scoreBn,
  18516. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18517. qd.msg AS msg,
  18518. qc.NAME AS caseName,
  18519. </if>
  18520. t.behDeptId,
  18521. t.behDeptName,
  18522. t.hospitalId,
  18523. t.checkStatus,
  18524. t.chName,
  18525. t.chTime
  18526. FROM
  18527. (
  18528. SELECT DISTINCT
  18529. t1.hospital_id AS hospitalId,
  18530. t1.behospital_code AS behospitalCode,
  18531. t1.bed_code AS bedCode,
  18532. t1.LEVEL AS LEVEL,
  18533. t1.grade_type AS gradeType,
  18534. t1.score_res AS scoreRes,
  18535. t1.scoreBn,
  18536. t1.NAME AS NAME,
  18537. t1.sex AS sex,
  18538. t1.beh_dept_id AS behDeptId,
  18539. t1.beh_dept_name AS behDeptName,
  18540. t1.doctor_id AS doctorId,
  18541. t1.doctor_name AS doctorName,
  18542. t1.beh_doctor_id AS behDoctorId,
  18543. t1.beh_doctor_name AS behDoctorName,
  18544. t1.director_doctor_id AS directorDoctorId,
  18545. t1.director_doctor_name AS directorDoctorName,
  18546. t1.birthday AS birthday,
  18547. t1.behospital_date AS behospitalDate,
  18548. t1.leave_hospital_date AS leaveHospitalDate,
  18549. t1.placefile_date AS placefileDate,
  18550. t1.gmt_create AS gradeTime,
  18551. t1.diagnose,
  18552. t1.ward_name AS wardName,
  18553. t2.age,
  18554. t1.file_code AS fileCode,
  18555. t1.checkStatus,
  18556. t1.chName,
  18557. t1.chTime
  18558. FROM
  18559. (
  18560. SELECT
  18561. be.*,
  18562. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18563. mci.check_name AS chName,
  18564. e.score_res as scoreBn,
  18565. mci.gmt_create AS chTime
  18566. FROM
  18567. (
  18568. SELECT DISTINCT
  18569. a.hospital_id,
  18570. a.behospital_code,
  18571. a.bed_code,
  18572. a.file_code,
  18573. b.LEVEL,
  18574. b.grade_type,
  18575. b.score_res,
  18576. a.NAME,
  18577. a.sex,
  18578. a.beh_dept_id,
  18579. a.beh_dept_name,
  18580. a.birthday,
  18581. a.behospital_date,
  18582. a.leave_hospital_date,
  18583. a.doctor_id,
  18584. a.doctor_name,
  18585. a.beh_doctor_id,
  18586. a.beh_doctor_name,
  18587. a.director_doctor_id,
  18588. a.director_doctor_name,
  18589. a.diagnose,
  18590. a.placefile_date,
  18591. a.ward_name,
  18592. b.gmt_create
  18593. FROM
  18594. med_behospital_info a,
  18595. med_qcresult_info b
  18596. WHERE
  18597. a.is_deleted = 'N'
  18598. AND b.is_deleted = 'N'
  18599. AND a.hospital_id = b.hospital_id
  18600. AND a.behospital_code = b.behospital_code
  18601. AND a.qc_type_id != 0
  18602. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18603. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18604. </if>
  18605. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18606. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18607. </if>
  18608. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18609. <if test="qcResultShortPageVO.startDate != null ">
  18610. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18611. </if>
  18612. <if test="qcResultShortPageVO.endDate != null ">
  18613. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18614. </if>
  18615. </if>
  18616. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18617. <if test="qcResultShortPageVO.startDate != null ">
  18618. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18619. </if>
  18620. <if test="qcResultShortPageVO.endDate != null">
  18621. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18622. </if>
  18623. </if>
  18624. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  18625. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  18626. </if>
  18627. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18628. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18629. </if>
  18630. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18631. AND c.`level` = #{qcResultShortPageVO.level}
  18632. </if>
  18633. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18634. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18635. </if>
  18636. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18637. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18638. </if>
  18639. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18640. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18641. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18642. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18643. </if>
  18644. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18645. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18646. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18647. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18648. </if>
  18649. ) be
  18650. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18651. AND mci.check_type in(0,2)
  18652. AND be.hospital_id = mci.hospital_id
  18653. AND be.behospital_code = mci.behospital_code
  18654. LEFT JOIN med_qcresult_cases e
  18655. on be.behospital_code = e.behospital_code
  18656. and be.hospital_id = e.hospital_id
  18657. AND e.is_deleted = 'N'
  18658. and e.cases_id = 243
  18659. ) t1
  18660. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18661. AND t1.behospital_code = t2.behospital_code
  18662. AND t2.is_deleted = 'N'
  18663. ) t
  18664. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18665. AND t.hospitalId = qi.hospital_id
  18666. AND t.behospitalCode = qi.behospital_code
  18667. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18668. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  18669. AND t.hospitalId = qd.hospital_id
  18670. AND t.behospitalCode = qd.behospital_code
  18671. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  18672. AND qd.cases_id = qc.id
  18673. </if>
  18674. where 1=1
  18675. <if test="qcResultShortPageVO.checkStatus != null">
  18676. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18677. </if>
  18678. <if test="qcResultShortPageVO.mrStatus != null">
  18679. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18680. </if>
  18681. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18682. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18683. </if>
  18684. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18685. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18686. </if>
  18687. <if test="qcResultShortPageVO.chTimeStart != null ">
  18688. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18689. </if>
  18690. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18691. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18692. </if>
  18693. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18694. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18695. </if>
  18696. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18697. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18698. </if>
  18699. )f1,
  18700. (SELECT
  18701. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  18702. t.behDeptId,
  18703. t.behDeptName
  18704. FROM
  18705. (
  18706. SELECT DISTINCT
  18707. t1.hospital_id AS hospitalId,
  18708. t1.behospital_code AS behospitalCode,
  18709. t1.bed_code AS bedCode,
  18710. t1.LEVEL AS LEVEL,
  18711. t1.grade_type AS gradeType,
  18712. t1.score_res AS scoreRes,
  18713. t1.NAME AS NAME,
  18714. t1.sex AS sex,
  18715. t1.beh_dept_id AS behDeptId,
  18716. t1.beh_dept_name AS behDeptName,
  18717. t1.doctor_id AS doctorId,
  18718. t1.doctor_name AS doctorName,
  18719. t1.beh_doctor_id AS behDoctorId,
  18720. t1.beh_doctor_name AS behDoctorName,
  18721. t1.director_doctor_id AS directorDoctorId,
  18722. t1.director_doctor_name AS directorDoctorName,
  18723. t1.birthday AS birthday,
  18724. t1.behospital_date AS behospitalDate,
  18725. t1.leave_hospital_date AS leaveHospitalDate,
  18726. t1.placefile_date AS placefileDate,
  18727. t1.gmt_create AS gradeTime,
  18728. t1.diagnose,
  18729. t1.ward_name AS wardName,
  18730. t2.age,
  18731. t1.file_code AS fileCode,
  18732. t1.checkStatus,
  18733. t1.chName,
  18734. t1.chTime
  18735. FROM
  18736. (
  18737. SELECT
  18738. be.*,
  18739. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18740. mci.check_name AS chName,
  18741. mci.gmt_create AS chTime
  18742. FROM
  18743. (
  18744. SELECT DISTINCT
  18745. a.hospital_id,
  18746. a.behospital_code,
  18747. a.bed_code,
  18748. a.file_code,
  18749. b.LEVEL,
  18750. b.grade_type,
  18751. b.score_res,
  18752. a.NAME,
  18753. a.sex,
  18754. a.beh_dept_id,
  18755. a.beh_dept_name,
  18756. a.birthday,
  18757. a.behospital_date,
  18758. a.leave_hospital_date,
  18759. a.doctor_id,
  18760. a.doctor_name,
  18761. a.beh_doctor_id,
  18762. a.beh_doctor_name,
  18763. a.director_doctor_id,
  18764. a.director_doctor_name,
  18765. a.diagnose,
  18766. a.placefile_date,
  18767. a.ward_name,
  18768. b.gmt_create
  18769. FROM
  18770. med_behospital_info a,
  18771. med_qcresult_info b
  18772. WHERE
  18773. a.is_deleted = 'N'
  18774. AND b.is_deleted = 'N'
  18775. AND a.hospital_id = b.hospital_id
  18776. AND a.behospital_code = b.behospital_code
  18777. AND a.qc_type_id != 0
  18778. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18779. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18780. </if>
  18781. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18782. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18783. </if>
  18784. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18785. <if test="qcResultShortPageVO.startDate != null ">
  18786. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18787. </if>
  18788. <if test="qcResultShortPageVO.endDate != null ">
  18789. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18790. </if>
  18791. </if>
  18792. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18793. <if test="qcResultShortPageVO.startDate != null ">
  18794. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18795. </if>
  18796. <if test="qcResultShortPageVO.endDate != null">
  18797. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18798. </if>
  18799. </if>
  18800. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  18801. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  18802. </if>
  18803. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18804. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18805. </if>
  18806. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18807. AND c.`level` = #{qcResultShortPageVO.level}
  18808. </if>
  18809. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18810. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18811. </if>
  18812. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18813. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18814. </if>
  18815. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18816. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18817. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18818. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18819. </if>
  18820. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18821. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18822. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18823. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18824. </if>
  18825. ) be
  18826. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18827. AND mci.check_type in(0,2)
  18828. AND be.hospital_id = mci.hospital_id
  18829. AND be.behospital_code = mci.behospital_code
  18830. ) t1
  18831. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18832. AND t1.behospital_code = t2.behospital_code
  18833. AND t2.is_deleted = 'N'
  18834. ) t
  18835. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18836. AND t.hospitalId = qi.hospital_id
  18837. AND t.behospitalCode = qi.behospital_code
  18838. where 1=1
  18839. <if test="qcResultShortPageVO.checkStatus != null">
  18840. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18841. </if>
  18842. <if test="qcResultShortPageVO.mrStatus != null">
  18843. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18844. </if>
  18845. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18846. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18847. </if>
  18848. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18849. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18850. </if>
  18851. <if test="qcResultShortPageVO.chTimeStart != null ">
  18852. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18853. </if>
  18854. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18855. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18856. </if>
  18857. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18858. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18859. </if>
  18860. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18861. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18862. </if>
  18863. GROUP BY
  18864. t.behDeptId,
  18865. t.behDeptName
  18866. )f2
  18867. WHERE
  18868. f1.behDeptId = f2.behDeptId
  18869. AND f1.behDeptName = f2.behDeptName
  18870. </select>
  18871. <!-- 质控核查质控评分页导出 -科室-->
  18872. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  18873. SELECT
  18874. f1.behDeptId,
  18875. f1.behDeptName,
  18876. f1.doctorName,
  18877. f1.doctorId,
  18878. f1.patName,
  18879. f1.behospitalCode,
  18880. f1.hospitalId,
  18881. f1.behospitalDate,
  18882. f1.leaveHospitalDate,
  18883. f1.score,
  18884. f1.scoreBn,
  18885. f2.avgScore,
  18886. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18887. f1.msg,
  18888. f1.caseName,
  18889. </if>
  18890. f1.checkStatus,
  18891. f1.mrStatus,
  18892. f1.chName,
  18893. f1.mrName,
  18894. f1.chTime,
  18895. f1.mrTime
  18896. FROM
  18897. (SELECT
  18898. t.doctorName,
  18899. t.doctorId,
  18900. t.`name` AS patName,
  18901. t.behospitalCode AS behospitalCode,
  18902. t.behospitalDate AS behospitalDate,
  18903. t.leaveHospitalDate AS leaveHospitalDate,
  18904. qi.score_res AS score,
  18905. t.scoreBn,
  18906. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18907. qd.msg AS msg,
  18908. qc.NAME AS caseName,
  18909. </if>
  18910. t.behDeptId,
  18911. t.behDeptName,
  18912. t.hospitalId,
  18913. t.checkStatus,
  18914. t.mrStatus,
  18915. t.chName,
  18916. t.mrName,
  18917. t.chTime,
  18918. t.mrTime
  18919. FROM
  18920. (
  18921. SELECT DISTINCT
  18922. t1.hospital_id AS hospitalId,
  18923. t1.behospital_code AS behospitalCode,
  18924. t1.bed_code AS bedCode,
  18925. t1.LEVEL AS LEVEL,
  18926. t1.grade_type AS gradeType,
  18927. t1.score_res AS scoreRes,
  18928. t1.scoreBn,
  18929. t1.NAME AS NAME,
  18930. t1.sex AS sex,
  18931. t1.beh_dept_id AS behDeptId,
  18932. t1.beh_dept_name AS behDeptName,
  18933. t1.doctor_id AS doctorId,
  18934. t1.doctor_name AS doctorName,
  18935. t1.beh_doctor_id AS behDoctorId,
  18936. t1.beh_doctor_name AS behDoctorName,
  18937. t1.director_doctor_id AS directorDoctorId,
  18938. t1.director_doctor_name AS directorDoctorName,
  18939. t1.birthday AS birthday,
  18940. t1.behospital_date AS behospitalDate,
  18941. t1.leave_hospital_date AS leaveHospitalDate,
  18942. t1.placefile_date AS placefileDate,
  18943. t1.gmt_create AS gradeTime,
  18944. t1.diagnose,
  18945. t1.ward_name AS wardName,
  18946. t2.age,
  18947. t1.file_code AS fileCode,
  18948. t1.checkStatus,
  18949. t1.mrStatus,
  18950. t1.chName,
  18951. t1.mrName,
  18952. t1.chTime,
  18953. t1.mrTime
  18954. FROM
  18955. (
  18956. SELECT
  18957. be.*,
  18958. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18959. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18960. mci.check_name AS chName,
  18961. e.score_res as scoreBn,
  18962. hm_mci.check_name AS mrName,
  18963. mci.gmt_create AS chTime,
  18964. hm_mci.gmt_create AS mrTime
  18965. FROM
  18966. (
  18967. SELECT DISTINCT
  18968. a.hospital_id,
  18969. a.behospital_code,
  18970. a.bed_code,
  18971. a.file_code,
  18972. b.LEVEL,
  18973. b.grade_type,
  18974. b.score_res,
  18975. a.NAME,
  18976. a.sex,
  18977. a.beh_dept_id,
  18978. a.beh_dept_name,
  18979. a.birthday,
  18980. a.behospital_date,
  18981. a.leave_hospital_date,
  18982. a.doctor_id,
  18983. a.doctor_name,
  18984. a.beh_doctor_id,
  18985. a.beh_doctor_name,
  18986. a.director_doctor_id,
  18987. a.director_doctor_name,
  18988. a.diagnose,
  18989. a.placefile_date,
  18990. a.ward_name,
  18991. b.gmt_create
  18992. FROM
  18993. med_behospital_info a,
  18994. med_qcresult_info b,
  18995. sys_user_dept c
  18996. WHERE
  18997. a.is_deleted = 'N'
  18998. AND b.is_deleted = 'N'
  18999. AND c.is_deleted = 'N'
  19000. AND a.hospital_id = b.hospital_id
  19001. AND a.hospital_id = c.hospital_id
  19002. AND a.behospital_code = b.behospital_code
  19003. AND a.beh_dept_id = c.dept_id
  19004. AND a.qc_type_id != 0
  19005. <if test="qcResultShortPageVO.userId!=null">
  19006. AND c.user_id = #{qcResultShortPageVO.userId}
  19007. </if>
  19008. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  19009. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  19010. </if>
  19011. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  19012. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  19013. </if>
  19014. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  19015. <if test="qcResultShortPageVO.startDate != null ">
  19016. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  19017. </if>
  19018. <if test="qcResultShortPageVO.endDate != null ">
  19019. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  19020. </if>
  19021. </if>
  19022. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  19023. <if test="qcResultShortPageVO.startDate != null ">
  19024. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  19025. </if>
  19026. <if test="qcResultShortPageVO.endDate != null">
  19027. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  19028. </if>
  19029. </if>
  19030. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  19031. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  19032. </if>
  19033. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  19034. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  19035. </if>
  19036. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  19037. AND c.`level` = #{qcResultShortPageVO.level}
  19038. </if>
  19039. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  19040. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  19041. </if>
  19042. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  19043. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  19044. </if>
  19045. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  19046. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19047. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19048. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  19049. </if>
  19050. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  19051. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19052. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19053. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  19054. </if>
  19055. ) be
  19056. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  19057. AND mci.check_type in(0,2)
  19058. AND be.hospital_id = mci.hospital_id
  19059. AND be.behospital_code = mci.behospital_code
  19060. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  19061. AND hm_mci.check_type = 1
  19062. AND be.hospital_id = hm_mci.hospital_id
  19063. AND be.behospital_code = hm_mci.behospital_code
  19064. LEFT JOIN med_qcresult_cases e
  19065. on be.behospital_code = e.behospital_code
  19066. and be.hospital_id = e.hospital_id
  19067. AND e.is_deleted = 'N'
  19068. and e.cases_id = 243
  19069. ) t1
  19070. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  19071. AND t1.behospital_code = t2.behospital_code
  19072. AND t2.is_deleted = 'N'
  19073. ) t
  19074. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  19075. AND t.hospitalId = qi.hospital_id
  19076. AND t.behospitalCode = qi.behospital_code
  19077. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  19078. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  19079. AND t.hospitalId = qd.hospital_id
  19080. AND t.behospitalCode = qd.behospital_code
  19081. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  19082. AND qd.cases_id = qc.id
  19083. </if>
  19084. where 1=1
  19085. <if test="qcResultShortPageVO.checkStatus != null">
  19086. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  19087. </if>
  19088. <if test="qcResultShortPageVO.mrStatus != null">
  19089. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  19090. </if>
  19091. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  19092. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  19093. </if>
  19094. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  19095. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  19096. </if>
  19097. <if test="qcResultShortPageVO.chTimeStart != null ">
  19098. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  19099. </if>
  19100. <if test="qcResultShortPageVO.chTimeEnd != null ">
  19101. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  19102. </if>
  19103. <if test="qcResultShortPageVO.mrTimeStart != null ">
  19104. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  19105. </if>
  19106. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  19107. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  19108. </if>
  19109. )f1,
  19110. (SELECT
  19111. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  19112. t.behDeptId,
  19113. t.behDeptName,
  19114. t.doctorId,
  19115. t.doctorName
  19116. FROM
  19117. (
  19118. SELECT DISTINCT
  19119. t1.hospital_id AS hospitalId,
  19120. t1.behospital_code AS behospitalCode,
  19121. t1.bed_code AS bedCode,
  19122. t1.LEVEL AS LEVEL,
  19123. t1.grade_type AS gradeType,
  19124. t1.score_res AS scoreRes,
  19125. t1.NAME AS NAME,
  19126. t1.sex AS sex,
  19127. t1.beh_dept_id AS behDeptId,
  19128. t1.beh_dept_name AS behDeptName,
  19129. t1.doctor_id AS doctorId,
  19130. t1.doctor_name AS doctorName,
  19131. t1.beh_doctor_id AS behDoctorId,
  19132. t1.beh_doctor_name AS behDoctorName,
  19133. t1.director_doctor_id AS directorDoctorId,
  19134. t1.director_doctor_name AS directorDoctorName,
  19135. t1.birthday AS birthday,
  19136. t1.behospital_date AS behospitalDate,
  19137. t1.leave_hospital_date AS leaveHospitalDate,
  19138. t1.placefile_date AS placefileDate,
  19139. t1.gmt_create AS gradeTime,
  19140. t1.diagnose,
  19141. t1.ward_name AS wardName,
  19142. t2.age,
  19143. t1.file_code AS fileCode,
  19144. t1.checkStatus,
  19145. t1.mrStatus,
  19146. t1.chName,
  19147. t1.mrName,
  19148. t1.chTime,
  19149. t1.mrTime
  19150. FROM
  19151. (
  19152. SELECT
  19153. be.*,
  19154. ifnull( mci.STATUS, 0 ) AS checkStatus,
  19155. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  19156. mci.check_name AS chName,
  19157. hm_mci.check_name AS mrName,
  19158. mci.gmt_create AS chTime,
  19159. hm_mci.gmt_create AS mrTime
  19160. FROM
  19161. (
  19162. SELECT DISTINCT
  19163. a.hospital_id,
  19164. a.behospital_code,
  19165. a.bed_code,
  19166. a.file_code,
  19167. b.LEVEL,
  19168. b.grade_type,
  19169. b.score_res,
  19170. a.NAME,
  19171. a.sex,
  19172. a.beh_dept_id,
  19173. a.beh_dept_name,
  19174. a.birthday,
  19175. a.behospital_date,
  19176. a.leave_hospital_date,
  19177. a.doctor_id,
  19178. a.doctor_name,
  19179. a.beh_doctor_id,
  19180. a.beh_doctor_name,
  19181. a.director_doctor_id,
  19182. a.director_doctor_name,
  19183. a.diagnose,
  19184. a.placefile_date,
  19185. a.ward_name,
  19186. b.gmt_create
  19187. FROM
  19188. med_behospital_info a,
  19189. med_qcresult_info b,
  19190. sys_user_dept c
  19191. WHERE
  19192. a.is_deleted = 'N'
  19193. AND b.is_deleted = 'N'
  19194. AND c.is_deleted = 'N'
  19195. AND a.hospital_id = b.hospital_id
  19196. AND a.hospital_id = c.hospital_id
  19197. AND a.behospital_code = b.behospital_code
  19198. AND a.beh_dept_id = c.dept_id
  19199. AND a.qc_type_id != 0
  19200. <if test="qcResultShortPageVO.userId!=null">
  19201. AND c.user_id = #{qcResultShortPageVO.userId}
  19202. </if>
  19203. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  19204. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  19205. </if>
  19206. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  19207. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  19208. </if>
  19209. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  19210. <if test="qcResultShortPageVO.startDate != null ">
  19211. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  19212. </if>
  19213. <if test="qcResultShortPageVO.endDate != null ">
  19214. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  19215. </if>
  19216. </if>
  19217. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  19218. <if test="qcResultShortPageVO.startDate != null ">
  19219. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  19220. </if>
  19221. <if test="qcResultShortPageVO.endDate != null">
  19222. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  19223. </if>
  19224. </if>
  19225. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  19226. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  19227. </if>
  19228. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  19229. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  19230. </if>
  19231. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  19232. AND c.`level` = #{qcResultShortPageVO.level}
  19233. </if>
  19234. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  19235. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  19236. </if>
  19237. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  19238. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  19239. </if>
  19240. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  19241. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19242. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19243. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  19244. </if>
  19245. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  19246. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19247. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19248. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  19249. </if>
  19250. ) be
  19251. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  19252. AND mci.check_type in(0,2)
  19253. AND be.hospital_id = mci.hospital_id
  19254. AND be.behospital_code = mci.behospital_code
  19255. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  19256. AND hm_mci.check_type = 1
  19257. AND be.hospital_id = hm_mci.hospital_id
  19258. AND be.behospital_code = hm_mci.behospital_code
  19259. ) t1
  19260. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  19261. AND t1.behospital_code = t2.behospital_code
  19262. AND t2.is_deleted = 'N'
  19263. ) t
  19264. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  19265. AND t.hospitalId = qi.hospital_id
  19266. AND t.behospitalCode = qi.behospital_code
  19267. where 1=1
  19268. <if test="qcResultShortPageVO.checkStatus != null">
  19269. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  19270. </if>
  19271. <if test="qcResultShortPageVO.mrStatus != null">
  19272. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  19273. </if>
  19274. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  19275. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  19276. </if>
  19277. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  19278. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  19279. </if>
  19280. <if test="qcResultShortPageVO.chTimeStart != null ">
  19281. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  19282. </if>
  19283. <if test="qcResultShortPageVO.chTimeEnd != null ">
  19284. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  19285. </if>
  19286. <if test="qcResultShortPageVO.mrTimeStart != null ">
  19287. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  19288. </if>
  19289. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  19290. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  19291. </if>
  19292. GROUP BY
  19293. t.doctorId,
  19294. t.doctorName
  19295. )f2
  19296. WHERE
  19297. f1.doctorId = f2.doctorId
  19298. AND f1.doctorName = f2.doctorName
  19299. </select>
  19300. <!-- 入院,手术,出院病案情况-->
  19301. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19302. SELECT
  19303. count(
  19304. DISTINCT
  19305. CASE
  19306. WHEN q.type=5 THEN
  19307. a.behospital_code
  19308. ELSE
  19309. NULL
  19310. END
  19311. ) AS 'operationNote',
  19312. count(
  19313. DISTINCT
  19314. CASE
  19315. WHEN q.type = 4 THEN
  19316. a.behospital_code
  19317. ELSE
  19318. NULL
  19319. END
  19320. ) AS 'residentAdmitNote',
  19321. count(
  19322. DISTINCT
  19323. CASE
  19324. WHEN q.type = 6 THEN
  19325. a.behospital_code
  19326. ELSE
  19327. NULL
  19328. END
  19329. ) AS 'dischargeRecord',
  19330. count(
  19331. DISTINCT
  19332. CASE
  19333. WHEN q.type = 7 THEN
  19334. a.behospital_code
  19335. ELSE
  19336. NULL
  19337. END
  19338. ) AS 'medicalRecord'
  19339. FROM
  19340. (
  19341. SELECT
  19342. a.behospital_code,
  19343. a.cases_entry_id,
  19344. a.hospital_id
  19345. FROM
  19346. (
  19347. SELECT
  19348. a.behospital_code,
  19349. c.cases_entry_id,
  19350. a.hospital_id
  19351. FROM
  19352. (
  19353. SELECT
  19354. a.behospital_code,
  19355. a.hospital_id
  19356. FROM
  19357. med_behospital_info a,
  19358. med_qcresult_info c
  19359. WHERE
  19360. a.is_deleted = 'N'
  19361. AND c.is_deleted = 'N'
  19362. AND a.is_placefile = #{filterVO.isPlacefile}
  19363. <if test="filterVO.startDate != null and filterVO.endDate != null">
  19364. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  19365. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19366. </if>
  19367. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19368. AND a.behospital_code = c.behospital_code
  19369. AND a.hospital_id = #{filterVO.hospitalId}
  19370. AND a.hospital_id = c.hospital_id
  19371. ) a
  19372. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  19373. AND a.behospital_code = c.behospital_code
  19374. AND a.hospital_id = c.hospital_id
  19375. ) a
  19376. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  19377. AND d.is_deleted = 'N'
  19378. ) a
  19379. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  19380. AND a.hospital_id = q.hospital_id
  19381. </select>
  19382. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  19383. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19384. select
  19385. d.behospital_code behospitalCode,
  19386. b.operation_fee operationFee,
  19387. b.pathology_fee pathologyFee,
  19388. b.antibiosis_fee antibiosisFee
  19389. FROM
  19390. (
  19391. SELECT
  19392. a.behospital_code,
  19393. a.hospital_id,
  19394. a.behospital_date,
  19395. a.leave_hospital_date
  19396. FROM
  19397. med_behospital_info a,
  19398. med_qcresult_info c
  19399. WHERE
  19400. a.is_deleted = 'N'
  19401. AND c.is_deleted = 'N'
  19402. AND a.is_placefile = #{filterVO.isPlacefile}
  19403. <if test="filterVO.startDate != null and filterVO.endDate != null">
  19404. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  19405. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19406. </if>
  19407. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19408. AND a.hospital_id = c.hospital_id
  19409. AND a.hospital_id = #{filterVO.hospitalId}
  19410. and a.behospital_code = c.behospital_code
  19411. ) d
  19412. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  19413. AND d.hospital_id = b.hospital_id
  19414. AND b.is_deleted = 'N'
  19415. </select>
  19416. <!-- 关于触发规则不符合人数-->
  19417. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19418. SELECT
  19419. count(
  19420. DISTINCT
  19421. CASE
  19422. WHEN a.type=5 THEN
  19423. a.behospital_code
  19424. ELSE
  19425. NULL
  19426. END
  19427. ) AS 'operationNote',
  19428. count(
  19429. DISTINCT
  19430. CASE
  19431. WHEN a.type = 4 THEN
  19432. a.behospital_code
  19433. ELSE
  19434. NULL
  19435. END
  19436. ) AS 'residentAdmitNote',
  19437. count(
  19438. DISTINCT
  19439. CASE
  19440. WHEN a.type = 6 THEN
  19441. a.behospital_code
  19442. ELSE
  19443. NULL
  19444. END
  19445. ) AS 'dischargeRecord',
  19446. count(
  19447. DISTINCT
  19448. CASE
  19449. WHEN a.type = 7 THEN
  19450. a.behospital_code
  19451. ELSE
  19452. NULL
  19453. END
  19454. ) AS 'medicalRecord',
  19455. count(
  19456. DISTINCT
  19457. CASE
  19458. WHEN a.type=8 THEN
  19459. a.behospital_code
  19460. ELSE
  19461. NULL
  19462. END
  19463. ) AS 'CT',
  19464. count(
  19465. DISTINCT
  19466. CASE
  19467. WHEN a.type = 9 THEN
  19468. a.behospital_code
  19469. ELSE
  19470. NULL
  19471. END
  19472. ) AS 'MR',
  19473. count(
  19474. DISTINCT
  19475. CASE
  19476. WHEN a.type = 10 THEN
  19477. a.behospital_code
  19478. ELSE
  19479. NULL
  19480. END
  19481. ) AS 'operationPathologyFee',
  19482. count(
  19483. DISTINCT
  19484. CASE
  19485. WHEN a.type = 11 THEN
  19486. a.behospital_code
  19487. ELSE
  19488. NULL
  19489. END
  19490. ) AS 'bacterialCulture',
  19491. count(
  19492. DISTINCT
  19493. CASE
  19494. WHEN a.type = 12 THEN
  19495. a.behospital_code
  19496. ELSE
  19497. NULL
  19498. END
  19499. ) AS 'antibiosis',
  19500. count(
  19501. DISTINCT
  19502. CASE
  19503. WHEN a.type = 13 THEN
  19504. a.behospital_code
  19505. ELSE
  19506. NULL
  19507. END
  19508. ) AS 'chemotherapyMalignantTumors',
  19509. count(
  19510. DISTINCT
  19511. CASE
  19512. WHEN a.type = 15 THEN
  19513. a.behospital_code
  19514. ELSE
  19515. NULL
  19516. END
  19517. ) AS 'operationRecordNum',
  19518. count(
  19519. DISTINCT
  19520. CASE
  19521. WHEN a.type = 17 THEN
  19522. a.behospital_code
  19523. ELSE
  19524. NULL
  19525. END
  19526. ) AS 'bloodNum',
  19527. count(
  19528. DISTINCT
  19529. CASE
  19530. WHEN a.type = 18 THEN
  19531. a.behospital_code
  19532. ELSE
  19533. NULL
  19534. END
  19535. ) AS 'WardRoundNum',
  19536. count(
  19537. DISTINCT
  19538. CASE
  19539. WHEN a.type = 19 THEN
  19540. a.behospital_code
  19541. ELSE
  19542. NULL
  19543. END
  19544. ) AS 'rescueNum',
  19545. count(
  19546. DISTINCT
  19547. CASE
  19548. WHEN a.type = 22 THEN
  19549. a.behospital_code
  19550. ELSE
  19551. NULL
  19552. END
  19553. ) AS 'unreasonedCopyNum',
  19554. count(
  19555. DISTINCT
  19556. CASE
  19557. WHEN a.type = 14 THEN
  19558. a.behospital_code
  19559. ELSE
  19560. NULL
  19561. END
  19562. ) AS 'tumorRadiationNum',
  19563. count(
  19564. DISTINCT
  19565. CASE
  19566. WHEN a.type = 16 THEN
  19567. a.behospital_code
  19568. ELSE
  19569. NULL
  19570. END
  19571. ) AS 'implantsNum',
  19572. count(
  19573. DISTINCT
  19574. CASE
  19575. WHEN a.type = 23 THEN
  19576. a.behospital_code
  19577. ELSE
  19578. NULL
  19579. END
  19580. ) AS 'InformedNum'
  19581. FROM
  19582. (
  19583. SELECT
  19584. a.behospital_code,
  19585. a.hospital_id,
  19586. q.type
  19587. FROM
  19588. (
  19589. SELECT
  19590. a.behospital_code,
  19591. a.cases_entry_id,
  19592. a.hospital_id
  19593. FROM
  19594. (
  19595. SELECT
  19596. a.behospital_code,
  19597. c.cases_entry_id,
  19598. a.hospital_id
  19599. FROM
  19600. (
  19601. SELECT
  19602. a.behospital_code,
  19603. a.hospital_id
  19604. FROM
  19605. med_behospital_info a,
  19606. med_qcresult_info c
  19607. WHERE
  19608. a.is_deleted = 'N'
  19609. AND c.is_deleted = 'N'
  19610. AND a.is_placefile = #{filterVO.isPlacefile}
  19611. <if test="filterVO.startDate != null and filterVO.endDate != null">
  19612. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  19613. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19614. </if>
  19615. AND a.behospital_code = c.behospital_code
  19616. AND a.hospital_id = #{filterVO.hospitalId}
  19617. AND a.hospital_id = c.hospital_id
  19618. ) a
  19619. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  19620. AND a.behospital_code = c.behospital_code
  19621. AND a.hospital_id = c.hospital_id
  19622. ) a
  19623. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  19624. AND d.is_deleted = 'N'
  19625. ) a
  19626. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  19627. AND a.hospital_id = q.hospital_id
  19628. ) a
  19629. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  19630. AND r.relevance_type = a.type
  19631. AND r.is_deleted = 'N'
  19632. AND a.hospital_id = r.hospital_id
  19633. </select>
  19634. <!-- 跟病案首页关联的出院病历-->
  19635. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19636. SELECT
  19637. d.behospital_code,
  19638. d.behospital_date,
  19639. d.leave_hospital_date,
  19640. b.behospital_code AS b_code,
  19641. b.operation_fee,
  19642. b.antibiosis_fee,
  19643. b.pathology_fee
  19644. FROM
  19645. (
  19646. SELECT
  19647. a.behospital_code,
  19648. a.hospital_id,
  19649. a.behospital_date,
  19650. a.leave_hospital_date
  19651. FROM
  19652. med_behospital_info a,
  19653. med_qcresult_info c
  19654. WHERE
  19655. a.behospital_code = c.behospital_code
  19656. AND a.hospital_id = #{filterVO.hospitalId}
  19657. AND a.is_placefile = #{filterVO.isPlacefile}
  19658. AND a.hospital_id = c.hospital_id
  19659. AND a.is_deleted = 'N'
  19660. AND c.is_deleted = 'N'
  19661. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19662. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  19663. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  19664. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19665. </if>
  19666. ) d
  19667. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  19668. AND d.hospital_id = b.hospital_id
  19669. AND b.is_deleted = 'N'
  19670. where ISNULL(b.behospital_code)
  19671. </select>
  19672. <!-- 首页恶性肿瘤-->
  19673. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19674. select
  19675. a.behospital_code,
  19676. a.hospital_id,
  19677. d.diagnose_name,
  19678. d.diagnose_type,
  19679. d.icd_code
  19680. from(
  19681. SELECT
  19682. d.behospital_code,
  19683. d.hospital_id,
  19684. b.home_page_id
  19685. FROM
  19686. (
  19687. SELECT
  19688. a.behospital_code,
  19689. a.hospital_id,
  19690. a.behospital_date,
  19691. a.leave_hospital_date
  19692. FROM
  19693. med_behospital_info a,
  19694. med_qcresult_info c
  19695. WHERE
  19696. a.behospital_code = c.behospital_code
  19697. AND a.hospital_id = #{filterVO.hospitalId}
  19698. AND a.is_placefile = #{filterVO.isPlacefile}
  19699. AND a.hospital_id = c.hospital_id
  19700. AND a.is_deleted = 'N'
  19701. AND c.is_deleted = 'N'
  19702. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19703. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  19704. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  19705. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19706. </if>
  19707. ) d
  19708. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  19709. AND d.hospital_id = b.hospital_id
  19710. AND b.is_deleted = 'N'
  19711. )a join
  19712. med_home_diagnose_info d on a.hospital_id=d.hospital_id
  19713. where a.home_page_id =d.home_page_id
  19714. and d.is_deleted ='N'
  19715. and d.diagnose_name like '%恶性肿瘤%'
  19716. and d.icd_code like 'C%'
  19717. </select>
  19718. <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
  19719. <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
  19720. SELECT
  19721. mbi.behospital_code behospitalCode,
  19722. mhp.age,
  19723. TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
  19724. TIMESTAMPDIFF(day,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageDay
  19725. FROM
  19726. med_behospital_info mbi
  19727. LEFT JOIN med_home_page mhp
  19728. ON mbi.behospital_code=mhp.behospital_code
  19729. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  19730. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
  19731. <if test="behospitalCodes !=null and behospitalCodes.size > 0">
  19732. and mbi.behospital_code in
  19733. <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
  19734. #{item}
  19735. </foreach>
  19736. </if>
  19737. </select>
  19738. <select id="doctorAverageStatistics" resultType="com.diagbot.dto.DoctorAverageStatisticsDTO">
  19739. SELECT t1.*,t2.entryNum
  19740. FROM
  19741. (
  19742. SELECT
  19743. CASE WHEN (a.doctor_id is null OR a.doctor_id = '' OR a.doctor_id = '-') THEN '-' ELSE a.doctor_id END AS doctorId,
  19744. CASE WHEN (a.doctor_name is null OR a.doctor_name = '' OR a.doctor_name = '-') THEN '-' ELSE a.doctor_name END AS doctorName,
  19745. CASE WHEN (a.beh_dept_id is null OR a.beh_dept_id = '' OR a.beh_dept_id = '-') THEN '-' ELSE a.beh_dept_id END AS deptId,
  19746. CASE WHEN (a.beh_dept_name is null OR a.beh_dept_name = '' OR a.beh_dept_name = '-') THEN '-' ELSE a.beh_dept_name END AS deptName,
  19747. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  19748. SUM( c.`level` = '甲' ) AS firstLevelStrNum,
  19749. SUM( c.`level` = '乙' ) AS secondLevelStrNum,
  19750. SUM( c.`level` = '丙' ) AS thirdLevelStrNum
  19751. FROM
  19752. med_behospital_info a,
  19753. med_qcresult_info c
  19754. WHERE
  19755. a.is_deleted = 'N'
  19756. AND c.is_deleted = 'N'
  19757. AND a.hospital_id = c.hospital_id
  19758. AND a.behospital_code = c.behospital_code
  19759. <if test="doctorAverageStatisticsVO.isPlacefile != null and doctorAverageStatisticsVO.isPlacefile != ''">
  19760. and a.is_placefile = #{doctorAverageStatisticsVO.isPlacefile}
  19761. </if>
  19762. AND a.qc_type_id != 0
  19763. <if test="doctorAverageStatisticsVO.hospitalId != null and doctorAverageStatisticsVO.hospitalId != ''">
  19764. AND a.hospital_id = #{doctorAverageStatisticsVO.hospitalId}
  19765. </if>
  19766. <if test="doctorAverageStatisticsVO.deptId != null and doctorAverageStatisticsVO.deptId != '' and doctorAverageStatisticsVO.deptId != '-0'">
  19767. AND a.beh_dept_id = #{doctorAverageStatisticsVO.deptId}
  19768. </if>
  19769. <if test="doctorAverageStatisticsVO.deptId == '-0'">
  19770. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  19771. </if>
  19772. <if test="doctorAverageStatisticsVO.deptName != null and doctorAverageStatisticsVO.deptName != '' and doctorAverageStatisticsVO.deptName != '-0'">
  19773. AND a.beh_dept_name = #{doctorAverageStatisticsVO.deptName}
  19774. </if>
  19775. <if test="doctorAverageStatisticsVO.deptName == '-0'">
  19776. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  19777. </if>
  19778. <if test="doctorAverageStatisticsVO.doctorId != null and doctorAverageStatisticsVO.doctorId != '' and doctorAverageStatisticsVO.doctorId != '-0'">
  19779. AND a.doctor_id LIKE CONCAT('%',#{doctorAverageStatisticsVO.doctorId},'%')
  19780. </if>
  19781. <if test="doctorAverageStatisticsVO.doctorId == '-0'">
  19782. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  19783. </if>
  19784. <if test="doctorAverageStatisticsVO.doctorName != null and doctorAverageStatisticsVO.doctorName != '' and doctorAverageStatisticsVO.doctorName != '-0'">
  19785. AND a.doctor_name LIKE CONCAT('%',#{doctorAverageStatisticsVO.doctorName},'%')
  19786. </if>
  19787. <if test="doctorAverageStatisticsVO.doctorName == '-0'">
  19788. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  19789. </if>
  19790. <if test="doctorAverageStatisticsVO.isPlacefile != null and doctorAverageStatisticsVO.isPlacefile == 0">
  19791. <if test="doctorAverageStatisticsVO.startDate != null and doctorAverageStatisticsVO.startDate != ''">
  19792. <![CDATA[ AND a.behospital_date >= #{doctorAverageStatisticsVO.startDate}]]>
  19793. </if>
  19794. <if test="doctorAverageStatisticsVO.endDate != null and doctorAverageStatisticsVO.endDate != ''">
  19795. <![CDATA[ AND a.behospital_date <= #{doctorAverageStatisticsVO.endDate}]]>
  19796. </if>
  19797. </if>
  19798. <if test="doctorAverageStatisticsVO.isPlacefile != null and doctorAverageStatisticsVO.isPlacefile == 1">
  19799. <if test="doctorAverageStatisticsVO.startDate != null and doctorAverageStatisticsVO.startDate != ''">
  19800. <![CDATA[ AND a.leave_hospital_date >= #{doctorAverageStatisticsVO.startDate}]]>
  19801. </if>
  19802. <if test="doctorAverageStatisticsVO.endDate != null and doctorAverageStatisticsVO.endDate != ''">
  19803. <![CDATA[ AND a.leave_hospital_date <= #{doctorAverageStatisticsVO.endDate}]]>
  19804. </if>
  19805. </if>
  19806. GROUP BY
  19807. a.beh_dept_id,
  19808. a.beh_dept_name,
  19809. a.doctor_id,
  19810. a.doctor_name
  19811. )t1,
  19812. (
  19813. SELECT
  19814. CASE WHEN (a.doctor_id is null OR a.doctor_id = '' OR a.doctor_id = '-') THEN '-' ELSE a.doctor_id END AS doctorId,
  19815. CASE WHEN (a.doctor_name is null OR a.doctor_name = '' OR a.doctor_name = '-') THEN '-' ELSE a.doctor_name END AS doctorName,
  19816. CASE WHEN (a.beh_dept_id is null OR a.beh_dept_id = '' OR a.beh_dept_id = '-') THEN '-' ELSE a.beh_dept_id END AS deptId,
  19817. CASE WHEN (a.beh_dept_name is null OR a.beh_dept_name = '' OR a.beh_dept_name = '-') THEN '-' ELSE a.beh_dept_name END AS deptName,
  19818. count( 1 ) AS entryNum
  19819. FROM
  19820. med_behospital_info a,
  19821. med_qcresult_info c,
  19822. med_qcresult_detail d,
  19823. qc_cases_entry e
  19824. WHERE
  19825. a.is_deleted = 'N'
  19826. AND c.is_deleted = 'N'
  19827. AND d.is_deleted = 'N'
  19828. AND e.is_deleted = 'N'
  19829. AND a.hospital_id = c.hospital_id
  19830. AND a.hospital_id = d.hospital_id
  19831. AND a.behospital_code = c.behospital_code
  19832. AND a.behospital_code = d.behospital_code
  19833. AND d.cases_id = e.cases_id
  19834. AND d.cases_entry_id = e.id
  19835. <if test="doctorAverageStatisticsVO.isPlacefile != null and doctorAverageStatisticsVO.isPlacefile != ''">
  19836. and a.is_placefile = #{doctorAverageStatisticsVO.isPlacefile}
  19837. </if>
  19838. AND a.qc_type_id != 0
  19839. <if test="doctorAverageStatisticsVO.hospitalId != null and doctorAverageStatisticsVO.hospitalId != ''">
  19840. AND a.hospital_id = #{doctorAverageStatisticsVO.hospitalId}
  19841. </if>
  19842. <if test="doctorAverageStatisticsVO.deptId != null and doctorAverageStatisticsVO.deptId != '' and doctorAverageStatisticsVO.deptId != '-0'">
  19843. AND a.beh_dept_id = #{doctorAverageStatisticsVO.deptId}
  19844. </if>
  19845. <if test="doctorAverageStatisticsVO.deptId == '-0'">
  19846. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  19847. </if>
  19848. <if test="doctorAverageStatisticsVO.deptName != null and doctorAverageStatisticsVO.deptName != '' and doctorAverageStatisticsVO.deptName != '-0'">
  19849. AND a.beh_dept_name = #{doctorAverageStatisticsVO.deptName}
  19850. </if>
  19851. <if test="doctorAverageStatisticsVO.deptName == '-0'">
  19852. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  19853. </if>
  19854. <if test="doctorAverageStatisticsVO.doctorId != null and doctorAverageStatisticsVO.doctorId != '' and doctorAverageStatisticsVO.doctorId != '-0'">
  19855. AND a.doctor_id LIKE CONCAT('%',#{doctorAverageStatisticsVO.doctorId},'%')
  19856. </if>
  19857. <if test="doctorAverageStatisticsVO.doctorId == '-0'">
  19858. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  19859. </if>
  19860. <if test="doctorAverageStatisticsVO.doctorName != null and doctorAverageStatisticsVO.doctorName != '' and doctorAverageStatisticsVO.doctorName != '-0'">
  19861. AND a.doctor_name LIKE CONCAT('%',#{doctorAverageStatisticsVO.doctorName},'%')
  19862. </if>
  19863. <if test="doctorAverageStatisticsVO.doctorName == '-0'">
  19864. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  19865. </if>
  19866. <if test="doctorAverageStatisticsVO.isPlacefile != null and doctorAverageStatisticsVO.isPlacefile == 0">
  19867. <if test="doctorAverageStatisticsVO.startDate != null and doctorAverageStatisticsVO.startDate != ''">
  19868. <![CDATA[ AND a.behospital_date >= #{doctorAverageStatisticsVO.startDate}]]>
  19869. </if>
  19870. <if test="doctorAverageStatisticsVO.endDate != null and doctorAverageStatisticsVO.endDate != ''">
  19871. <![CDATA[ AND a.behospital_date <= #{doctorAverageStatisticsVO.endDate}]]>
  19872. </if>
  19873. </if>
  19874. <if test="doctorAverageStatisticsVO.isPlacefile != null and doctorAverageStatisticsVO.isPlacefile == 1">
  19875. <if test="doctorAverageStatisticsVO.startDate != null and doctorAverageStatisticsVO.startDate != ''">
  19876. <![CDATA[ AND a.leave_hospital_date >= #{doctorAverageStatisticsVO.startDate}]]>
  19877. </if>
  19878. <if test="doctorAverageStatisticsVO.endDate != null and doctorAverageStatisticsVO.endDate != ''">
  19879. <![CDATA[ AND a.leave_hospital_date <= #{doctorAverageStatisticsVO.endDate}]]>
  19880. </if>
  19881. </if>
  19882. GROUP BY
  19883. a.beh_dept_id,
  19884. a.beh_dept_name,
  19885. a.doctor_id,
  19886. a.doctor_name
  19887. )t2
  19888. WHERE t1.doctorId = t2.doctorId
  19889. AND t1.doctorName = t2.doctorName
  19890. AND t1.deptId = t2.deptId
  19891. AND t1.deptName = t2.deptName
  19892. <if test="doctorAverageStatisticsVO.asc !=null and doctorAverageStatisticsVO.asc.size > 0 and doctorAverageStatisticsVO.desc !=null and doctorAverageStatisticsVO.desc.size > 0">
  19893. order by
  19894. <foreach collection="doctorAverageStatisticsVO.asc" item="item" open=" " close=" " separator=",">
  19895. <choose>
  19896. <when test='item=="doctorName"'>t1.doctorName</when>
  19897. <when test='item=="deptId"'>t1.deptId</when>
  19898. <when test='item=="deptName"'>t1.deptName</when>
  19899. <when test='item=="averageValue"'>t1.averageValue</when>
  19900. <when test='item=="firstLevelStrNum"'>t1.firstLevelStrNum</when>
  19901. <when test='item=="secondLevelStrNum"'>t1.secondLevelStrNum</when>
  19902. <when test='item=="thirdLevelStrNum"'>t1.thirdLevelStrNum</when>
  19903. <when test='item=="entryNum"'>t2.entryNum</when>
  19904. <otherwise>t1.doctorId</otherwise>
  19905. </choose>
  19906. </foreach>
  19907. asc,
  19908. <foreach collection="doctorAverageStatisticsVO.desc" item="item" open=" " close=" " separator=",">
  19909. <choose>
  19910. <when test='item=="doctorName"'>t1.doctorName</when>
  19911. <when test='item=="deptId"'>t1.deptId</when>
  19912. <when test='item=="deptName"'>t1.deptName</when>
  19913. <when test='item=="averageValue"'>t1.averageValue</when>
  19914. <when test='item=="firstLevelStrNum"'>t1.firstLevelStrNum</when>
  19915. <when test='item=="secondLevelStrNum"'>t1.secondLevelStrNum</when>
  19916. <when test='item=="thirdLevelStrNum"'>t1.thirdLevelStrNum</when>
  19917. <when test='item=="entryNum"'>t2.entryNum</when>
  19918. <otherwise>t1.doctorId</otherwise>
  19919. </choose>
  19920. </foreach>
  19921. desc
  19922. </if>
  19923. <if test="doctorAverageStatisticsVO.asc !=null and doctorAverageStatisticsVO.asc.size > 0 and (doctorAverageStatisticsVO.desc ==null or doctorAverageStatisticsVO.desc.size == 0)">
  19924. order by
  19925. <foreach collection="doctorAverageStatisticsVO.asc" item="item" open=" " close=" " separator=",">
  19926. <choose>
  19927. <when test='item=="doctorName"'>t1.doctorName</when>
  19928. <when test='item=="deptId"'>t1.deptId</when>
  19929. <when test='item=="deptName"'>t1.deptName</when>
  19930. <when test='item=="averageValue"'>t1.averageValue</when>
  19931. <when test='item=="firstLevelStrNum"'>t1.firstLevelStrNum</when>
  19932. <when test='item=="secondLevelStrNum"'>t1.secondLevelStrNum</when>
  19933. <when test='item=="thirdLevelStrNum"'>t1.thirdLevelStrNum</when>
  19934. <when test='item=="entryNum"'>t2.entryNum</when>
  19935. <otherwise>t1.doctorId</otherwise>
  19936. </choose>
  19937. </foreach>
  19938. asc
  19939. </if>
  19940. <if test="(doctorAverageStatisticsVO.asc ==null or doctorAverageStatisticsVO.asc.size == 0) and doctorAverageStatisticsVO.desc !=null and doctorAverageStatisticsVO.desc.size > 0">
  19941. order by
  19942. <foreach collection="doctorAverageStatisticsVO.desc" item="item" open=" " close=" " separator=",">
  19943. <choose>
  19944. <when test='item=="doctorName"'>t1.doctorName</when>
  19945. <when test='item=="deptId"'>t1.deptId</when>
  19946. <when test='item=="deptName"'>t1.deptName</when>
  19947. <when test='item=="averageValue"'>t1.averageValue</when>
  19948. <when test='item=="firstLevelStrNum"'>t1.firstLevelStrNum</when>
  19949. <when test='item=="secondLevelStrNum"'>t1.secondLevelStrNum</when>
  19950. <when test='item=="thirdLevelStrNum"'>t1.thirdLevelStrNum</when>
  19951. <when test='item=="entryNum"'>t2.entryNum</when>
  19952. <otherwise>t1.doctorId</otherwise>
  19953. </choose>
  19954. </foreach>
  19955. desc
  19956. </if>
  19957. </select>
  19958. <!-- 医生质控平均分-患者列表(等级)-->
  19959. <select id="doctorAverageLevelPage" resultType="com.diagbot.dto.DoctorAverageLevelDTO">
  19960. SELECT * FROM (
  19961. select t.*,
  19962. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  19963. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  19964. g.check_type AS ch_type,
  19965. h.check_type AS mr_type,
  19966. g.check_name AS ch_name,
  19967. h.check_name AS mr_name,
  19968. g.check_time AS ch_time,
  19969. h.check_time AS mr_time
  19970. from (
  19971. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  19972. 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
  19973. LEFT JOIN med_qcresult_info b
  19974. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  19975. left join med_home_page c
  19976. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  19977. LEFT JOIN med_qcresult_cases e
  19978. on a.behospital_code = e.behospital_code
  19979. AND e.is_deleted = 'N'
  19980. and e.cases_id = 243
  19981. ) t
  19982. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  19983. ON t.behospital_code = g.behospital_code
  19984. AND t.hospital_id = g.hospital_id
  19985. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  19986. ON t.behospital_code = h.behospital_code
  19987. AND t.hospital_id = h.hospital_id
  19988. where t.is_deleted = 'N'
  19989. <if test="diagnose != null and diagnose != ''">
  19990. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  19991. </if>
  19992. <if test="deptId != null and deptId != '' and deptId != '-0'">
  19993. and t.beh_dept_id= #{deptId}
  19994. </if>
  19995. <if test="deptName == '-0'">
  19996. AND (t.beh_dept_id IS NULL OR t.beh_dept_id = '' OR t.beh_dept_id = '-')
  19997. </if>
  19998. <if test="deptName != null and deptName != '' and deptName != '-0'">
  19999. and t.beh_dept_name= #{deptName}
  20000. </if>
  20001. <if test="deptName == '-0'">
  20002. AND (t.beh_dept_name IS NULL OR t.beh_dept_name = '' OR t.beh_dept_name = '-')
  20003. </if>
  20004. <if test="doctorName != null and doctorName != '' and doctorName != '-0'">
  20005. and CONCAT(
  20006. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  20007. like CONCAT('%',#{doctorName},'%')
  20008. </if>
  20009. <if test="doctorName == '-0'">
  20010. AND (t.doctor_name IS NULL OR t.doctor_name = '' OR t.doctor_name = '-')
  20011. </if>
  20012. <if test="name != null and name != ''">
  20013. and t.name like CONCAT('%',#{name},'%')
  20014. </if>
  20015. <if test="doctorCode != null and doctorCode != '' and doctorCode != '-0'">
  20016. and (t.doctor_id = #{doctorCode}
  20017. or t.beh_doctor_id = #{doctorCode}
  20018. or t.director_doctor_id = #{doctorCode})
  20019. </if>
  20020. <if test="doctorCode == '-0'">
  20021. AND (t.doctor_id IS NULL OR t.doctor_id = '' OR t.doctor_id = '-')
  20022. </if>
  20023. <if test="fileCode != null and fileCode != ''">
  20024. and t.file_code like CONCAT('%',#{fileCode},'%')
  20025. </if>
  20026. <if test="hospitalId != null">
  20027. and t.hospital_id = #{hospitalId}
  20028. </if>
  20029. <if test="behospitalCode != null and behospitalCode != ''">
  20030. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  20031. </if>
  20032. <if test="behosDateStart != null">
  20033. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  20034. </if>
  20035. <if test="behosDateEnd != null">
  20036. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  20037. </if>
  20038. <if test="leaveHosDateStart != null">
  20039. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  20040. </if>
  20041. <if test="leaveHosDateEnd != null">
  20042. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  20043. </if>
  20044. <if test="level != null and level != ''">
  20045. and t.level = #{level}
  20046. </if>
  20047. <if test="isPlacefile != null and isPlacefile != ''">
  20048. and t.is_placefile = #{isPlacefile}
  20049. </if>
  20050. and t.qc_type_id != 0) p
  20051. where p.is_deleted="N"
  20052. <if test="checkStatus != null ">
  20053. and p.check_status = #{checkStatus}
  20054. </if>
  20055. <if test="mrStatus != null ">
  20056. AND p.mr_status = #{mrStatus}
  20057. </if>
  20058. <if test="chName != null and chName !=''">
  20059. AND p.ch_name like CONCAT('%',#{chName},'%')
  20060. </if>
  20061. <if test="mrName != null and mrName !=''">
  20062. AND p.mr_name like CONCAT('%',#{mrName},'%')
  20063. </if>
  20064. <if test="chTimeStart != null">
  20065. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  20066. </if>
  20067. <if test="chTimeEnd != null">
  20068. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  20069. </if>
  20070. <if test="mrTimeStart != null">
  20071. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  20072. </if>
  20073. <if test="mrTimeEnd != null">
  20074. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  20075. </if>
  20076. </select>
  20077. <!-- 医生质控平均分-患者列表(等级)-导出-->
  20078. <select id="doctorAverageLevelExport" resultMap="ExportDoctorAverage_7">
  20079. SELECT * FROM (
  20080. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  20081. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  20082. g.check_type AS ch_type,
  20083. h.check_type AS mr_type,
  20084. g.check_name AS ch_name,
  20085. h.check_name AS mr_name,
  20086. g.check_time AS ch_time,
  20087. h.check_time AS mr_time
  20088. FROM (
  20089. SELECT
  20090. t1.behDeptId,
  20091. t1.behDeptName,
  20092. t1.doctorName,
  20093. t1.patName,
  20094. t1.behospitalCode,
  20095. t1.hospitalId,
  20096. t1.behospitalDate,
  20097. t1.leaveHospitalDate,
  20098. t1.score,
  20099. <if test="radioCheck !=null and radioCheck == 1">
  20100. t1.msg,
  20101. t1.caseName,
  20102. </if>
  20103. t1.scoreBn,
  20104. t2.avgScore
  20105. FROM
  20106. (
  20107. SELECT
  20108. a.doctor_name AS doctorName,
  20109. a.`name` AS patName,
  20110. a.behospital_code AS behospitalCode,
  20111. a.behospital_date AS behospitalDate,
  20112. a.leave_hospital_date AS leaveHospitalDate,
  20113. b.score_res AS score,
  20114. e.score_res as scoreBn,
  20115. <if test="radioCheck !=null and radioCheck == 1">
  20116. c.msg AS msg,
  20117. d.NAME AS caseName,
  20118. </if>
  20119. a.beh_dept_id AS behDeptId,
  20120. a.beh_dept_name AS behDeptName,
  20121. a.hospital_id AS hospitalId
  20122. FROM
  20123. med_behospital_info a
  20124. RIGHT JOIN
  20125. med_qcresult_info b
  20126. ON a.hospital_id = b.hospital_id
  20127. AND a.is_deleted = 'N'
  20128. AND b.is_deleted = 'N'
  20129. AND a.behospital_code = b.behospital_code
  20130. <if test="radioCheck !=null and radioCheck == 1">
  20131. LEFT JOIN
  20132. med_qcresult_detail c
  20133. ON c.is_deleted = 'N'
  20134. AND b.behospital_code = c.behospital_code
  20135. AND b.hospital_id = c.hospital_id
  20136. LEFT JOIN
  20137. qc_cases d
  20138. on d.is_deleted = 'N'
  20139. AND c.cases_id = d.id
  20140. </if>
  20141. LEFT JOIN med_qcresult_cases e
  20142. on b.behospital_code = e.behospital_code
  20143. and b.hospital_id = e.hospital_id
  20144. AND e.is_deleted = 'N'
  20145. and e.cases_id = 243
  20146. WHERE
  20147. 1=1
  20148. <if test="isPlacefile != null and isPlacefile != ''">
  20149. and a.is_placefile = #{isPlacefile}
  20150. </if>
  20151. <![CDATA[AND a.qc_type_id <>0 ]]>
  20152. <if test="hospitalId != null and hospitalId != ''">
  20153. AND a.hospital_id = #{hospitalId}
  20154. </if>
  20155. <if test="diagnose != null and diagnose != ''">
  20156. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  20157. </if>
  20158. <if test="behosDateStart != null">
  20159. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  20160. </if>
  20161. <if test="behosDateEnd != null">
  20162. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  20163. </if>
  20164. <if test="leaveHosDateStart != null ">
  20165. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  20166. </if>
  20167. <if test="leaveHosDateEnd != null ">
  20168. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  20169. </if>
  20170. <if test="behospitalCode != null and behospitalCode != ''">
  20171. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  20172. </if>
  20173. <if test="level != null and level != ''">
  20174. AND b.level = #{level}
  20175. </if>
  20176. <if test="doctorName != null and doctorName != ''">
  20177. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  20178. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  20179. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  20180. </if>
  20181. <if test="doctorCode != null and doctorCode != ''">
  20182. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  20183. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  20184. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  20185. </if>
  20186. <if test="deptName != null and deptName != ''">
  20187. and a.beh_dept_name = #{deptName}
  20188. </if>
  20189. <if test="name != null and name != ''">
  20190. AND a.name like CONCAT('%',#{name},'%')
  20191. </if>
  20192. ) t1,
  20193. (
  20194. SELECT
  20195. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  20196. a.beh_dept_id AS behDeptId,
  20197. a.beh_dept_name AS behDeptName
  20198. FROM
  20199. med_behospital_info a,
  20200. med_qcresult_info b
  20201. WHERE
  20202. a.is_deleted = 'N'
  20203. AND b.is_deleted = 'N'
  20204. AND a.hospital_id = b.hospital_id
  20205. AND a.behospital_code = b.behospital_code
  20206. <if test="isPlacefile != null and isPlacefile != ''">
  20207. and a.is_placefile = #{isPlacefile}
  20208. </if>
  20209. <![CDATA[AND a.qc_type_id <>0 ]]>
  20210. <if test="hospitalId != null and hospitalId != ''">
  20211. AND a.hospital_id = #{hospitalId}
  20212. </if>
  20213. <if test="diagnose != null and diagnose != ''">
  20214. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  20215. </if>
  20216. <if test="behosDateStart != null">
  20217. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  20218. </if>
  20219. <if test="behosDateEnd != null">
  20220. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  20221. </if>
  20222. <if test="leaveHosDateStart != null ">
  20223. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  20224. </if>
  20225. <if test="leaveHosDateEnd != null ">
  20226. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  20227. </if>
  20228. <if test="behospitalCode != null and behospitalCode != ''">
  20229. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  20230. </if>
  20231. <if test="level != null and level != ''">
  20232. AND b.level = #{level}
  20233. </if>
  20234. <if test="doctorName != null and doctorName != ''">
  20235. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  20236. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  20237. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  20238. </if>
  20239. <if test="doctorCode != null and doctorCode != ''">
  20240. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  20241. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  20242. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  20243. </if>
  20244. <if test="deptName != null and deptName != ''">
  20245. and a.beh_dept_name = #{deptName}
  20246. </if>
  20247. <if test="name != null and name != ''">
  20248. AND a.name like CONCAT('%',#{name},'%')
  20249. </if>
  20250. GROUP BY
  20251. a.beh_dept_id,
  20252. a.beh_dept_name
  20253. ) t2
  20254. WHERE
  20255. t1.behDeptId = t2.behDeptId
  20256. AND t1.behDeptName = t2.behDeptName
  20257. ORDER BY
  20258. t1.behDeptName,
  20259. t1.doctorName,
  20260. t1.patName,
  20261. <if test="radioCheck !=null and radioCheck == 1">
  20262. t1.caseName,
  20263. </if>
  20264. t1.behospitalCode
  20265. )tp
  20266. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  20267. ON tp.behospitalCode = g.behospital_code
  20268. AND tp.hospitalId = g.hospital_id
  20269. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  20270. ON tp.behospitalCode = h.behospital_code
  20271. AND tp.hospitalId = h.hospital_id
  20272. ) tu
  20273. WHERE tu.behospitalCode IS NOT NULL
  20274. <if test="checkStatus != null ">
  20275. and tu.check_status = #{checkStatus}
  20276. </if>
  20277. <if test="mrStatus != null ">
  20278. AND tu.mr_status = #{mrStatus}
  20279. </if>
  20280. <if test="chName != null and chName !=''">
  20281. AND tu.ch_name like CONCAT('%',#{chName},'%')
  20282. </if>
  20283. <if test="mrName != null and mrName !=''">
  20284. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  20285. </if>
  20286. <if test="chTimeStart != null">
  20287. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  20288. </if>
  20289. <if test="chTimeEnd != null">
  20290. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  20291. </if>
  20292. <if test="mrTimeStart != null">
  20293. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  20294. </if>
  20295. <if test="mrTimeEnd != null">
  20296. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  20297. </if>
  20298. </select>
  20299. <!-- 缺陷详情-个人(分页) -->
  20300. <select id="getDoctorDetailPage" resultType="com.diagbot.dto.GetDoctorDetailPageDTO">
  20301. SELECT
  20302. t.*
  20303. FROM
  20304. (
  20305. SELECT
  20306. t1.deptId,
  20307. t1.deptName,
  20308. t1.id,
  20309. t1.NAME,
  20310. t1.casesId,
  20311. t1.casesName,
  20312. t1.num,
  20313. t2.totleNum,
  20314. t1.doctorId,
  20315. t1.ruleType,
  20316. t1.isReject,
  20317. t1.doctorName,
  20318. ROUND( t1.num / t2.totleNum, 4 ) AS percent,
  20319. CONCAT( ROUND( t1.num / t2.totleNum * 100, 2 ), '%' ) AS percentStr
  20320. FROM
  20321. (
  20322. SELECT
  20323. tt1.deptId ,
  20324. tt1.deptName ,
  20325. tt2.id AS id,
  20326. tt2.NAME AS NAME,
  20327. tt2.cases_id AS casesId,
  20328. tt2.cases_name AS casesName,
  20329. tt1.num,
  20330. tt1.doctorId ,
  20331. tt1.doctorName ,
  20332. tt2.rule_type AS ruleType,
  20333. tt1.is_reject AS isReject
  20334. FROM
  20335. (
  20336. SELECT
  20337. d.cases_id,
  20338. d.cases_entry_id,
  20339. CASE WHEN (a.doctor_id is null OR a.doctor_id = '' OR a.doctor_id = '-') THEN '-' ELSE a.doctor_id END AS doctorId,
  20340. CASE WHEN (a.doctor_name is null OR a.doctor_name = '' OR a.doctor_name = '-') THEN '-' ELSE a.doctor_name END AS doctorName,
  20341. CASE WHEN (a.beh_dept_id is null OR a.beh_dept_id = '' OR a.beh_dept_id = '-') THEN '-' ELSE a.beh_dept_id END AS deptId,
  20342. CASE WHEN (a.beh_dept_name is null OR a.beh_dept_name = '' OR a.beh_dept_name = '-') THEN '-' ELSE a.beh_dept_name END AS deptName,
  20343. d.is_reject,
  20344. count(*) AS num
  20345. FROM
  20346. med_behospital_info a,
  20347. med_qcresult_detail d
  20348. WHERE
  20349. a.is_deleted = 'N'
  20350. AND d.is_deleted = 'N'
  20351. AND a.hospital_id = d.hospital_id
  20352. AND a.behospital_code = d.behospital_code
  20353. <if test="getDoctorDetailPageVO.isPlacefile != null and getDoctorDetailPageVO.isPlacefile != ''">
  20354. and a.is_placefile = #{getDoctorDetailPageVO.isPlacefile}
  20355. </if>
  20356. AND a.qc_type_id != 0
  20357. <if test="getDoctorDetailPageVO.hospitalId != null and getDoctorDetailPageVO.hospitalId != ''">
  20358. AND a.hospital_id = #{getDoctorDetailPageVO.hospitalId}
  20359. </if>
  20360. <if test="getDoctorDetailPageVO.isPlacefile != null and getDoctorDetailPageVO.isPlacefile == 0">
  20361. <if test="getDoctorDetailPageVO.startDate != null and getDoctorDetailPageVO.startDate != ''">
  20362. <![CDATA[ AND a.behospital_date >= #{getDoctorDetailPageVO.startDate}]]>
  20363. </if>
  20364. <if test="getDoctorDetailPageVO.endDate != null and getDoctorDetailPageVO.endDate != ''">
  20365. <![CDATA[ AND a.behospital_date <= #{getDoctorDetailPageVO.endDate}]]>
  20366. </if>
  20367. </if>
  20368. <if test="getDoctorDetailPageVO.isPlacefile != null and getDoctorDetailPageVO.isPlacefile == 1">
  20369. <if test="getDoctorDetailPageVO.startDate != null and getDoctorDetailPageVO.startDate != ''">
  20370. <![CDATA[ AND a.leave_hospital_date >= #{getDoctorDetailPageVO.startDate}]]>
  20371. </if>
  20372. <if test="getDoctorDetailPageVO.endDate != null and getDoctorDetailPageVO.endDate != ''">
  20373. <![CDATA[ AND a.leave_hospital_date <= #{getDoctorDetailPageVO.endDate}]]>
  20374. </if>
  20375. </if>
  20376. <if test="getDoctorDetailPageVO.deptName != null and getDoctorDetailPageVO.deptName != '' and getDoctorDetailPageVO.deptName != '-0'">
  20377. AND a.beh_dept_name = #{getDoctorDetailPageVO.deptName}
  20378. </if>
  20379. <if test="getDoctorDetailPageVO.deptName == '-0'">
  20380. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  20381. </if>
  20382. <if test="getDoctorDetailPageVO.deptId != null and getDoctorDetailPageVO.deptId != '' and getDoctorDetailPageVO.deptId != '-0'">
  20383. AND a.beh_dept_id = #{getDoctorDetailPageVO.deptId}
  20384. </if>
  20385. <if test="getDoctorDetailPageVO.deptId == '-0'">
  20386. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  20387. </if>
  20388. <if test="getDoctorDetailPageVO.doctorId != null and getDoctorDetailPageVO.doctorId != '' and getDoctorDetailPageVO.doctorId != '-0'">
  20389. AND a.doctor_id = #{getDoctorDetailPageVO.doctorId}
  20390. </if>
  20391. <if test="getDoctorDetailPageVO.doctorId == '-0'">
  20392. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  20393. </if>
  20394. <if test="getDoctorDetailPageVO.doctorName != null and getDoctorDetailPageVO.doctorName != '' and getDoctorDetailPageVO.doctorName != '-0' ">
  20395. AND a.doctor_name = #{getDoctorDetailPageVO.doctorName}
  20396. </if>
  20397. <if test="getDoctorDetailPageVO.doctorName == '-0'">
  20398. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  20399. </if>
  20400. <if test="getDoctorDetailPageVO.casesId != null and getDoctorDetailPageVO.casesId != 0">
  20401. AND d.cases_id = #{getDoctorDetailPageVO.casesId}
  20402. </if>
  20403. <if test="getDoctorDetailPageVO.isReject != null">
  20404. AND d.is_reject = #{getDoctorDetailPageVO.isReject}
  20405. </if>
  20406. GROUP BY
  20407. a.beh_dept_id,
  20408. a.beh_dept_name,
  20409. a.doctor_id,
  20410. a.doctor_name,
  20411. d.cases_entry_id,
  20412. d.cases_id
  20413. ) tt1,
  20414. qc_cases_entry tt2
  20415. WHERE
  20416. tt2.is_deleted = 'N'
  20417. AND tt1.cases_id = tt2.cases_id
  20418. AND tt1.cases_entry_id = tt2.id
  20419. <if test="getDoctorDetailPageVO.casesName != null and getDoctorDetailPageVO.casesName != ''">
  20420. AND tt2.cases_name like CONCAT('%', #{getDoctorDetailPageVO.casesName},'%')
  20421. </if>
  20422. <if test="getDoctorDetailPageVO.name != null and getDoctorDetailPageVO.name != ''">
  20423. AND tt2.name like CONCAT('%', #{getDoctorDetailPageVO.name},'%')
  20424. </if>
  20425. <if test="getDoctorDetailPageVO.ruleType != null">
  20426. AND tt2.rule_type = #{getDoctorDetailPageVO.ruleType}
  20427. </if>
  20428. ) t1,(
  20429. SELECT
  20430. count(*) AS totleNum
  20431. FROM
  20432. med_behospital_info a,
  20433. med_qcresult_detail d,
  20434. qc_cases_entry e
  20435. WHERE
  20436. a.is_deleted = 'N'
  20437. AND d.is_deleted = 'N'
  20438. AND e.is_deleted = 'N'
  20439. AND a.hospital_id = d.hospital_id
  20440. AND a.behospital_code = d.behospital_code
  20441. <if test="getDoctorDetailPageVO.isPlacefile != null and getDoctorDetailPageVO.isPlacefile != ''">
  20442. and a.is_placefile = #{getDoctorDetailPageVO.isPlacefile}
  20443. </if>
  20444. AND e.cases_id = d.cases_id
  20445. AND e.id = d.cases_entry_id
  20446. AND a.qc_type_id != 0
  20447. <if test="getDoctorDetailPageVO.hospitalId != null and getDoctorDetailPageVO.hospitalId != ''">
  20448. AND a.hospital_id = #{getDoctorDetailPageVO.hospitalId}
  20449. </if>
  20450. <if test="getDoctorDetailPageVO.isPlacefile != null and getDoctorDetailPageVO.isPlacefile == 0">
  20451. <if test="getDoctorDetailPageVO.startDate != null and getDoctorDetailPageVO.startDate != ''">
  20452. <![CDATA[ AND a.behospital_date >= #{getDoctorDetailPageVO.startDate}]]>
  20453. </if>
  20454. <if test="getDoctorDetailPageVO.endDate != null and getDoctorDetailPageVO.endDate != ''">
  20455. <![CDATA[ AND a.behospital_date <= #{getDoctorDetailPageVO.endDate}]]>
  20456. </if>
  20457. </if>
  20458. <if test="getDoctorDetailPageVO.isPlacefile != null and getDoctorDetailPageVO.isPlacefile == 1">
  20459. <if test="getDoctorDetailPageVO.startDate != null and getDoctorDetailPageVO.startDate != ''">
  20460. <![CDATA[ AND a.leave_hospital_date >= #{getDoctorDetailPageVO.startDate}]]>
  20461. </if>
  20462. <if test="getDoctorDetailPageVO.endDate != null and getDoctorDetailPageVO.endDate != ''">
  20463. <![CDATA[ AND a.leave_hospital_date <= #{getDoctorDetailPageVO.endDate}]]>
  20464. </if>
  20465. </if>
  20466. <if test="getDoctorDetailPageVO.deptName != null and getDoctorDetailPageVO.deptName != '' and getDoctorDetailPageVO.deptName != '-0'">
  20467. AND a.beh_dept_name = #{getDoctorDetailPageVO.deptName}
  20468. </if>
  20469. <if test="getDoctorDetailPageVO.deptName == '-0'">
  20470. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  20471. </if>
  20472. <if test="getDoctorDetailPageVO.deptId != null and getDoctorDetailPageVO.deptId != '' and getDoctorDetailPageVO.deptId != '-0'">
  20473. AND a.beh_dept_id = #{getDoctorDetailPageVO.deptId}
  20474. </if>
  20475. <if test="getDoctorDetailPageVO.deptId == '-0'">
  20476. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  20477. </if>
  20478. <if test="getDoctorDetailPageVO.doctorId != null and getDoctorDetailPageVO.doctorId != '' and getDoctorDetailPageVO.doctorId != '-0'">
  20479. AND a.doctor_id = #{getDoctorDetailPageVO.doctorId}
  20480. </if>
  20481. <if test="getDoctorDetailPageVO.doctorId == '-0'">
  20482. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  20483. </if>
  20484. <if test="getDoctorDetailPageVO.doctorName != null and getDoctorDetailPageVO.doctorName != '' and getDoctorDetailPageVO.doctorName != '-0' ">
  20485. AND a.doctor_name = #{getDoctorDetailPageVO.doctorName}
  20486. </if>
  20487. <if test="getDoctorDetailPageVO.doctorName == '-0'">
  20488. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  20489. </if>
  20490. <if test="getDoctorDetailPageVO.isReject != null">
  20491. AND d.is_reject = #{getDoctorDetailPageVO.isReject}
  20492. </if>
  20493. <if test="getDoctorDetailPageVO.ruleType != null">
  20494. AND e.rule_type = #{getDoctorDetailPageVO.ruleType}
  20495. </if>
  20496. ) t2
  20497. )t
  20498. </select>
  20499. <!-- 获取缺陷数量对应的病历 -->
  20500. <select id="getDetailRecordListPage" resultType="com.diagbot.dto.GetDetailRecordListPageDTO">
  20501. SELECT t.*
  20502. FROM
  20503. (SELECT DISTINCT
  20504. t1.hospital_id AS hospitalId,
  20505. t1.behospital_code AS behospitalCode,
  20506. t1.bed_code AS bedCode,
  20507. t1.LEVEL AS LEVEL,
  20508. t1.grade_type AS gradeType,
  20509. t1.score_res AS scoreRes,
  20510. t1.scoreBn,
  20511. t1.NAME AS NAME,
  20512. t1.sex AS sex,
  20513. t1.beh_dept_id AS behDeptId,
  20514. t1.beh_dept_name AS behDeptName,
  20515. t1.doctor_id AS doctorId,
  20516. t1.doctor_name AS doctorName,
  20517. t1.beh_doctor_id AS behDoctorId,
  20518. t1.beh_doctor_name AS behDoctorName,
  20519. t1.director_doctor_id AS directorDoctorId,
  20520. t1.director_doctor_name AS directorDoctorName,
  20521. t1.birthday AS birthday,
  20522. t1.behospital_date AS behospitalDate,
  20523. t1.leave_hospital_date AS leaveHospitalDate,
  20524. t1.placefile_date AS placefileDate,
  20525. t1.gmt_create AS gradeTime,
  20526. t1.diagnose,
  20527. t1.ward_name AS wardName,
  20528. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  20529. t1.file_code AS fileCode,
  20530. t1.checkStatus,
  20531. t1.mrStatus,
  20532. t1.chName,
  20533. t1.mrName,
  20534. t1.chTime,
  20535. t1.mrTime
  20536. FROM
  20537. (
  20538. SELECT DISTINCT
  20539. tt1.*
  20540. FROM
  20541. (SELECT
  20542. be.*,
  20543. ifnull(mci.status,0) AS checkStatus,
  20544. ifnull(hm_mci.status,0) AS mrStatus,
  20545. mci.check_name as chName,
  20546. e.score_res as scoreBn,
  20547. hm_mci.check_name as mrName,
  20548. mci.gmt_create as chTime,
  20549. hm_mci.gmt_create as mrTime
  20550. FROM
  20551. (
  20552. SELECT DISTINCT
  20553. a.hospital_id,
  20554. a.behospital_code,
  20555. a.bed_code,
  20556. a.file_code,
  20557. b.LEVEL,
  20558. b.grade_type,
  20559. b.score_res,
  20560. a.NAME,
  20561. a.sex,
  20562. a.beh_dept_id,
  20563. a.beh_dept_name,
  20564. a.birthday,
  20565. a.behospital_date,
  20566. a.leave_hospital_date,
  20567. a.doctor_id,
  20568. a.doctor_name,
  20569. a.beh_doctor_id,
  20570. a.beh_doctor_name,
  20571. a.director_doctor_id,
  20572. a.director_doctor_name,
  20573. a.diagnose,
  20574. a.placefile_date,
  20575. a.ward_name,
  20576. b.gmt_create
  20577. FROM
  20578. med_behospital_info a,
  20579. med_qcresult_info b,
  20580. med_qcresult_detail c,
  20581. qc_cases_entry d
  20582. WHERE
  20583. a.is_deleted = 'N'
  20584. AND b.is_deleted = 'N'
  20585. AND c.is_deleted = 'N'
  20586. AND d.is_deleted = 'N'
  20587. AND a.hospital_id = b.hospital_id
  20588. AND a.hospital_id = c.hospital_id
  20589. AND a.behospital_code = b.behospital_code
  20590. AND a.behospital_code = c.behospital_code
  20591. AND c.cases_id = d.cases_id
  20592. AND c.cases_entry_id = d.id
  20593. AND a.qc_type_id != 0
  20594. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile != ''">
  20595. and a.is_placefile = #{getDetailRecordListPageVO.isPlacefile}
  20596. </if>
  20597. <if test="getDetailRecordListPageVO.hospitalId != null and getDetailRecordListPageVO.hospitalId != ''">
  20598. AND a.hospital_id = #{getDetailRecordListPageVO.hospitalId}
  20599. </if>
  20600. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 0">
  20601. <if test="getDetailRecordListPageVO.startDate != null ">
  20602. <![CDATA[ AND a.behospital_date >= #{getDetailRecordListPageVO.startDate}]]>
  20603. </if>
  20604. <if test="getDetailRecordListPageVO.endDate != null ">
  20605. <![CDATA[ AND a.behospital_date <= #{getDetailRecordListPageVO.endDate}]]>
  20606. </if>
  20607. </if>
  20608. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 1">
  20609. <if test="getDetailRecordListPageVO.startDate != null ">
  20610. <![CDATA[ AND a.leave_hospital_date >= #{getDetailRecordListPageVO.startDate}]]>
  20611. </if>
  20612. <if test="getDetailRecordListPageVO.endDate != null">
  20613. <![CDATA[ AND a.leave_hospital_date <= #{getDetailRecordListPageVO.endDate}]]>
  20614. </if>
  20615. </if>
  20616. <if test="getDetailRecordListPageVO.diagnose != null and getDetailRecordListPageVO.diagnose != ''">
  20617. AND a.diagnose LIKE CONCAT( '%', #{getDetailRecordListPageVO.diagnose}, '%' )
  20618. </if>
  20619. <if test="getDetailRecordListPageVO.deptName != null and getDetailRecordListPageVO.deptName != '' and getDetailRecordListPageVO.deptName != '-0'">
  20620. AND a.beh_dept_name = #{getDetailRecordListPageVO.deptName}
  20621. </if>
  20622. <if test="getDetailRecordListPageVO.deptName == '-0'">
  20623. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  20624. </if>
  20625. <if test="getDetailRecordListPageVO.deptId != null and getDetailRecordListPageVO.deptId != '' and getDetailRecordListPageVO.deptId != '-0'">
  20626. AND a.beh_dept_id = #{getDetailRecordListPageVO.deptId}
  20627. </if>
  20628. <if test="getDetailRecordListPageVO.deptId == '-0'">
  20629. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  20630. </if>
  20631. <if test="getDetailRecordListPageVO.doctorId != null and getDetailRecordListPageVO.doctorId != '' and getDetailRecordListPageVO.doctorId != '-0'">
  20632. AND a.doctor_id = #{getDetailRecordListPageVO.doctorId}
  20633. </if>
  20634. <if test="getDetailRecordListPageVO.doctorId == '-0'">
  20635. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  20636. </if>
  20637. <if test="getDetailRecordListPageVO.doctorName != null and getDetailRecordListPageVO.doctorName != '' and getDetailRecordListPageVO.doctorName != '-0' ">
  20638. AND a.doctor_name = #{getDetailRecordListPageVO.doctorName}
  20639. </if>
  20640. <if test="getDetailRecordListPageVO.doctorName == '-0'">
  20641. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  20642. </if>
  20643. <if test="getDetailRecordListPageVO.level != null and getDetailRecordListPageVO.level != ''">
  20644. AND b.`level` = #{getDetailRecordListPageVO.level}
  20645. </if>
  20646. <if test="getDetailRecordListPageVO.behospitalCode != null and getDetailRecordListPageVO.behospitalCode != ''">
  20647. AND a.behospital_code LIKE CONCAT( '%', #{getDetailRecordListPageVO.behospitalCode}, '%' )
  20648. </if>
  20649. <if test="getDetailRecordListPageVO.fileCode != null and getDetailRecordListPageVO.fileCode != ''">
  20650. AND a.file_code LIKE CONCAT( '%', #{getDetailRecordListPageVO.fileCode}, '%' )
  20651. </if>
  20652. <if test="getDetailRecordListPageVO.patName != null and getDetailRecordListPageVO.patName != ''">
  20653. AND a.NAME LIKE CONCAT( '%', #{getDetailRecordListPageVO.patName}, '%' )
  20654. </if>
  20655. <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
  20656. AND d.NAME = #{getDetailRecordListPageVO.casesEntryName}
  20657. </if>
  20658. <if test="getDetailRecordListPageVO.casesEntryId != null ">
  20659. AND d.id = #{getDetailRecordListPageVO.casesEntryId}
  20660. </if>
  20661. <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
  20662. AND d.cases_name = #{getDetailRecordListPageVO.casesName}
  20663. </if>
  20664. <if test="getDetailRecordListPageVO.casesId != null">
  20665. AND d.cases_id = #{getDetailRecordListPageVO.casesId}
  20666. </if>
  20667. <if test="getDetailRecordListPageVO.isReject != null">
  20668. AND c.is_reject = #{getDetailRecordListPageVO.isReject}
  20669. </if>
  20670. <if test="getDetailRecordListPageVO.ruleType != null">
  20671. AND d.rule_type = #{getDetailRecordListPageVO.ruleType}
  20672. </if>
  20673. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2495">
  20674. AND TIMESTAMPDIFF(
  20675. DAY,
  20676. DATE( a.behospital_date ),
  20677. DATE( a.leave_hospital_date ))> 30
  20678. </if>
  20679. <if test="getDetailRecordListPageVO.beHosGT31Days != null and getDetailRecordListPageVO.beHosGT31Days==1">
  20680. AND TIMESTAMPDIFF(
  20681. DAY,
  20682. DATE( a.behospital_date ),
  20683. DATE( a.leave_hospital_date ))> 31
  20684. </if>
  20685. )be
  20686. left join med_check_info mci
  20687. on mci.is_deleted = 'N'
  20688. and mci.check_type in(0,2)
  20689. and be.hospital_id = mci.hospital_id
  20690. and be.behospital_code = mci.behospital_code
  20691. left join med_check_info hm_mci
  20692. on hm_mci.is_deleted = 'N'
  20693. and hm_mci.check_type = 1
  20694. and be.hospital_id = hm_mci.hospital_id
  20695. and be.behospital_code = hm_mci.behospital_code
  20696. LEFT JOIN med_qcresult_cases e
  20697. on be.behospital_code = e.behospital_code
  20698. and be.hospital_id = e.hospital_id
  20699. AND e.is_deleted = 'N'
  20700. and e.cases_id = 243
  20701. )tt1
  20702. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2511">
  20703. ,med_medical_record tt2
  20704. WHERE
  20705. tt2.is_deleted = 'N'
  20706. AND tt1.hospital_id = tt2.hospital_id
  20707. AND tt1.behospital_code = tt2.behospital_code
  20708. AND tt2.mode_id = 30
  20709. </if>
  20710. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2419">
  20711. ,med_crisis_info tt2
  20712. WHERE
  20713. tt2.is_deleted = 'N'
  20714. AND tt1.hospital_id = tt2.hospital_id
  20715. AND tt1.behospital_code = tt2.behospital_code
  20716. </if>
  20717. ) t1
  20718. <if test="getDetailRecordListPageVO.casesEntryId == null or (getDetailRecordListPageVO.casesEntryId!=2594 and getDetailRecordListPageVO.casesEntryId!=2973 and getDetailRecordListPageVO.casesEntryId!=2930)">
  20719. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  20720. AND t1.behospital_code = t2.behospital_code
  20721. AND t2.is_deleted = 'N'
  20722. </if>
  20723. <if test="getDetailRecordListPageVO.casesEntryId != null and( getDetailRecordListPageVO.casesEntryId==2594 or getDetailRecordListPageVO.casesEntryId==2973 or getDetailRecordListPageVO.casesEntryId==2930)">
  20724. , med_home_page t2
  20725. , med_home_operation_info t3
  20726. WHERE t1.hospital_id = t2.hospital_id
  20727. AND t1.behospital_code = t2.behospital_code
  20728. AND t2.home_page_id = t3.home_page_id
  20729. AND t2.is_deleted = 'N'
  20730. AND t3.is_deleted = 'N'
  20731. </if>
  20732. ) t
  20733. where 1=1
  20734. <if test="getDetailRecordListPageVO.checkStatus != null">
  20735. AND t.checkStatus = #{getDetailRecordListPageVO.checkStatus}
  20736. </if>
  20737. <if test="getDetailRecordListPageVO.mrStatus != null">
  20738. AND t.mrStatus = #{getDetailRecordListPageVO.mrStatus}
  20739. </if>
  20740. <if test="getDetailRecordListPageVO.chName != null and getDetailRecordListPageVO.chName!=''">
  20741. AND t.chName like concat('%', #{getDetailRecordListPageVO.chName}, '%')
  20742. </if>
  20743. <if test="getDetailRecordListPageVO.mrName != null and getDetailRecordListPageVO.mrName!=''">
  20744. AND t.mrName like concat('%', #{getDetailRecordListPageVO.mrName}, '%')
  20745. </if>
  20746. <if test="getDetailRecordListPageVO.chTimeStart != null ">
  20747. <![CDATA[ AND t.chTime >= #{getDetailRecordListPageVO.chTimeStart}]]>
  20748. </if>
  20749. <if test="getDetailRecordListPageVO.chTimeEnd != null ">
  20750. <![CDATA[ AND t.chTime <= #{getDetailRecordListPageVO.chTimeEnd}]]>
  20751. </if>
  20752. <if test="getDetailRecordListPageVO.mrTimeStart != null ">
  20753. <![CDATA[ AND t.mrTime >= #{getDetailRecordListPageVO.mrTimeStart}]]>
  20754. </if>
  20755. <if test="getDetailRecordListPageVO.mrTimeEnd != null ">
  20756. <![CDATA[ AND t.mrTime <= #{getDetailRecordListPageVO.mrTimeEnd}]]>
  20757. </if>
  20758. </select>
  20759. <!-- 条目缺陷评分详情页导出-->
  20760. <select id="getDetailRecordListExport" resultMap="ExportExcelMap">
  20761. SELECT * from(
  20762. SELECT
  20763. f1.*,
  20764. f2.avgScore
  20765. FROM
  20766. (SELECT
  20767. t.*,
  20768. qi.score_res AS score,
  20769. qd.msg AS msg,
  20770. qc.NAME AS caseName
  20771. FROM
  20772. (SELECT DISTINCT
  20773. t1.hospital_id AS hospitalId,
  20774. t1.behospital_code AS behospitalCode,
  20775. t1.bed_code AS bedCode,
  20776. t1.LEVEL AS LEVEL,
  20777. t1.grade_type AS gradeType,
  20778. t1.score_res AS scoreRes,
  20779. t1.scoreBn AS scoreBn,
  20780. t1.NAME AS patName,
  20781. t1.sex AS sex,
  20782. t1.beh_dept_id AS behDeptId,
  20783. t1.beh_dept_name AS behDeptName,
  20784. t1.doctor_id AS doctorId,
  20785. t1.doctor_name AS doctorName,
  20786. t1.beh_doctor_id AS behDoctorId,
  20787. t1.beh_doctor_name AS behDoctorName,
  20788. t1.director_doctor_id AS directorDoctorId,
  20789. t1.director_doctor_name AS directorDoctorName,
  20790. t1.birthday AS birthday,
  20791. t1.behospital_date AS behospitalDate,
  20792. t1.leave_hospital_date AS leaveHospitalDate,
  20793. t1.placefile_date AS placefileDate,
  20794. t1.gmt_create AS gradeTime,
  20795. t1.diagnose AS diagnose,
  20796. t1.ward_name AS wardName,
  20797. t1.file_code AS fileCode,
  20798. t1.checkStatus AS checkStatus,
  20799. t1.mrStatus AS mrStatus,
  20800. t1.chName AS chName,
  20801. t1.mrName AS mrName,
  20802. t1.chTime AS chTime,
  20803. t1.mrTime AS mrTime
  20804. FROM
  20805. (
  20806. SELECT DISTINCT
  20807. tt1.*
  20808. FROM
  20809. (SELECT
  20810. be.*,
  20811. ifnull(mci.status,0) AS checkStatus,
  20812. ifnull(hm_mci.status,0) AS mrStatus,
  20813. mci.check_name as chName,
  20814. hm_mci.check_name as mrName,
  20815. mci.gmt_create as chTime,
  20816. e.score_res as scoreBn,
  20817. hm_mci.gmt_create as mrTime
  20818. FROM
  20819. (
  20820. SELECT DISTINCT
  20821. a.hospital_id,
  20822. a.behospital_code,
  20823. a.bed_code,
  20824. a.file_code,
  20825. b.LEVEL,
  20826. b.grade_type,
  20827. b.score_res,
  20828. a.NAME,
  20829. a.sex,
  20830. a.beh_dept_id,
  20831. a.beh_dept_name,
  20832. a.birthday,
  20833. a.behospital_date,
  20834. a.leave_hospital_date,
  20835. a.doctor_id,
  20836. a.doctor_name,
  20837. a.beh_doctor_id,
  20838. a.beh_doctor_name,
  20839. a.director_doctor_id,
  20840. a.director_doctor_name,
  20841. a.diagnose,
  20842. a.placefile_date,
  20843. a.ward_name,
  20844. b.gmt_create
  20845. FROM
  20846. med_behospital_info a,
  20847. med_qcresult_info b,
  20848. med_qcresult_detail c,
  20849. qc_cases_entry d
  20850. WHERE
  20851. a.is_deleted = 'N'
  20852. AND b.is_deleted = 'N'
  20853. AND c.is_deleted = 'N'
  20854. AND d.is_deleted = 'N'
  20855. AND a.hospital_id = b.hospital_id
  20856. AND a.hospital_id = c.hospital_id
  20857. AND a.behospital_code = b.behospital_code
  20858. AND a.behospital_code = c.behospital_code
  20859. AND c.cases_id = d.cases_id
  20860. AND c.cases_entry_id = d.id
  20861. AND a.qc_type_id != 0
  20862. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile != ''">
  20863. and a.is_placefile = #{getDetailRecordListPageVO.isPlacefile}
  20864. </if>
  20865. <if test="getDetailRecordListPageVO.hospitalId != null and getDetailRecordListPageVO.hospitalId != ''">
  20866. AND a.hospital_id = #{getDetailRecordListPageVO.hospitalId}
  20867. </if>
  20868. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 0">
  20869. <if test="getDetailRecordListPageVO.startDate != null ">
  20870. <![CDATA[ AND a.behospital_date >= #{getDetailRecordListPageVO.startDate}]]>
  20871. </if>
  20872. <if test="getDetailRecordListPageVO.endDate != null ">
  20873. <![CDATA[ AND a.behospital_date <= #{getDetailRecordListPageVO.endDate}]]>
  20874. </if>
  20875. </if>
  20876. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 1">
  20877. <if test="getDetailRecordListPageVO.startDate != null ">
  20878. <![CDATA[ AND a.leave_hospital_date >= #{getDetailRecordListPageVO.startDate}]]>
  20879. </if>
  20880. <if test="getDetailRecordListPageVO.endDate != null">
  20881. <![CDATA[ AND a.leave_hospital_date <= #{getDetailRecordListPageVO.endDate}]]>
  20882. </if>
  20883. </if>
  20884. <if test="getDetailRecordListPageVO.diagnose != null and getDetailRecordListPageVO.diagnose != ''">
  20885. AND a.diagnose LIKE CONCAT( '%', #{getDetailRecordListPageVO.diagnose}, '%' )
  20886. </if>
  20887. <if test="getDetailRecordListPageVO.level != null and getDetailRecordListPageVO.level != ''">
  20888. AND b.`level` = #{getDetailRecordListPageVO.level}
  20889. </if>
  20890. <if test="getDetailRecordListPageVO.behospitalCode != null and getDetailRecordListPageVO.behospitalCode != ''">
  20891. AND a.behospital_code LIKE CONCAT( '%', #{getDetailRecordListPageVO.behospitalCode}, '%' )
  20892. </if>
  20893. <if test="getDetailRecordListPageVO.patName != null and getDetailRecordListPageVO.patName != ''">
  20894. AND a.NAME LIKE CONCAT( '%', #{getDetailRecordListPageVO.patName}, '%' )
  20895. </if>
  20896. <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
  20897. AND d.NAME = #{getDetailRecordListPageVO.casesEntryName}
  20898. </if>
  20899. <if test="getDetailRecordListPageVO.casesEntryId != null ">
  20900. AND d.id = #{getDetailRecordListPageVO.casesEntryId}
  20901. </if>
  20902. <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
  20903. AND d.cases_name = #{getDetailRecordListPageVO.casesName}
  20904. </if>
  20905. <if test="getDetailRecordListPageVO.casesId != null">
  20906. AND d.cases_id = #{getDetailRecordListPageVO.casesId}
  20907. </if>
  20908. <if test="getDetailRecordListPageVO.deptName != null and getDetailRecordListPageVO.deptName != '' and getDetailRecordListPageVO.deptName != '-0'">
  20909. AND a.beh_dept_name = #{getDetailRecordListPageVO.deptName}
  20910. </if>
  20911. <if test="getDetailRecordListPageVO.deptName == '-0'">
  20912. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  20913. </if>
  20914. <if test="getDetailRecordListPageVO.deptId != null and getDetailRecordListPageVO.deptId != '' and getDetailRecordListPageVO.deptId != '-0'">
  20915. AND a.beh_dept_id = #{getDetailRecordListPageVO.deptId}
  20916. </if>
  20917. <if test="getDetailRecordListPageVO.deptId == '-0'">
  20918. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  20919. </if>
  20920. <if test="getDetailRecordListPageVO.doctorId != null and getDetailRecordListPageVO.doctorId != '' and getDetailRecordListPageVO.doctorId != '-0'">
  20921. AND a.doctor_id = #{getDetailRecordListPageVO.doctorId}
  20922. </if>
  20923. <if test="getDetailRecordListPageVO.doctorId == '-0'">
  20924. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  20925. </if>
  20926. <if test="getDetailRecordListPageVO.doctorName != null and getDetailRecordListPageVO.doctorName != '' and getDetailRecordListPageVO.doctorName != '-0' ">
  20927. AND a.doctor_name = #{getDetailRecordListPageVO.doctorName}
  20928. </if>
  20929. <if test="getDetailRecordListPageVO.doctorName == '-0'">
  20930. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  20931. </if>
  20932. <if test="getDetailRecordListPageVO.isReject != null">
  20933. AND c.is_reject = #{getDetailRecordListPageVO.isReject}
  20934. </if>
  20935. <if test="getDetailRecordListPageVO.ruleType != null">
  20936. AND d.rule_type = #{getDetailRecordListPageVO.ruleType}
  20937. </if>
  20938. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2495">
  20939. AND TIMESTAMPDIFF(
  20940. DAY,
  20941. DATE( a.behospital_date ),
  20942. DATE( a.leave_hospital_date ))> 30
  20943. </if>
  20944. <if test="getDetailRecordListPageVO.beHosGT31Days != null and getDetailRecordListPageVO.beHosGT31Days==1">
  20945. AND TIMESTAMPDIFF(
  20946. DAY,
  20947. DATE( a.behospital_date ),
  20948. DATE( a.leave_hospital_date ))> 31
  20949. </if>
  20950. )be
  20951. left join med_check_info mci
  20952. on mci.is_deleted = 'N'
  20953. and mci.check_type in(0,2)
  20954. and be.hospital_id = mci.hospital_id
  20955. and be.behospital_code = mci.behospital_code
  20956. left join med_check_info hm_mci
  20957. on hm_mci.is_deleted = 'N'
  20958. and hm_mci.check_type = 1
  20959. and be.hospital_id = hm_mci.hospital_id
  20960. and be.behospital_code = hm_mci.behospital_code
  20961. LEFT JOIN med_qcresult_cases e
  20962. on be.behospital_code = e.behospital_code
  20963. and be.hospital_id = e.hospital_id
  20964. AND e.is_deleted = 'N'
  20965. and e.cases_id = 243
  20966. )tt1
  20967. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2511">
  20968. ,med_medical_record tt2
  20969. WHERE
  20970. tt2.is_deleted = 'N'
  20971. AND tt1.hospital_id = tt2.hospital_id
  20972. AND tt1.behospital_code = tt2.behospital_code
  20973. AND tt2.mode_id = 30
  20974. </if>
  20975. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2419">
  20976. ,med_crisis_info tt2
  20977. WHERE
  20978. tt2.is_deleted = 'N'
  20979. AND tt1.hospital_id = tt2.hospital_id
  20980. AND tt1.behospital_code = tt2.behospital_code
  20981. </if>
  20982. ) t1
  20983. <if test="getDetailRecordListPageVO.casesEntryId == null or (getDetailRecordListPageVO.casesEntryId!=2594 and getDetailRecordListPageVO.casesEntryId!=2973 and getDetailRecordListPageVO.casesEntryId!=2930)">
  20984. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  20985. AND t1.behospital_code = t2.behospital_code
  20986. AND t2.is_deleted = 'N'
  20987. </if>
  20988. <if test="getDetailRecordListPageVO.casesEntryId != null and( getDetailRecordListPageVO.casesEntryId==2594 or getDetailRecordListPageVO.casesEntryId==2973 or getDetailRecordListPageVO.casesEntryId==2930)">
  20989. , med_home_page t2
  20990. , med_home_operation_info t3
  20991. WHERE t1.hospital_id = t2.hospital_id
  20992. AND t1.behospital_code = t2.behospital_code
  20993. AND t2.home_page_id = t3.home_page_id
  20994. AND t2.is_deleted = 'N'
  20995. AND t3.is_deleted = 'N'
  20996. </if>
  20997. ) t
  20998. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  20999. AND t.hospitalId = qi.hospital_id
  21000. AND t.behospitalCode = qi.behospital_code
  21001. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  21002. AND t.hospitalId = qd.hospital_id
  21003. AND t.behospitalCode = qd.behospital_code
  21004. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  21005. AND qd.cases_id = qc.id
  21006. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  21007. AND qd.cases_id = qce.cases_id
  21008. AND qd.cases_entry_id = qce.id
  21009. where 1=1
  21010. <if test="getDetailRecordListPageVO.checkStatus != null">
  21011. AND t.checkStatus = #{getDetailRecordListPageVO.checkStatus}
  21012. </if>
  21013. <if test="getDetailRecordListPageVO.mrStatus != null">
  21014. AND t.mrStatus = #{getDetailRecordListPageVO.mrStatus}
  21015. </if>
  21016. <if test="getDetailRecordListPageVO.chName != null and getDetailRecordListPageVO.chName!=''">
  21017. AND t.chName like concat('%', #{getDetailRecordListPageVO.chName}, '%')
  21018. </if>
  21019. <if test="getDetailRecordListPageVO.mrName != null and getDetailRecordListPageVO.mrName!=''">
  21020. AND t.mrName like concat('%', #{getDetailRecordListPageVO.mrName}, '%')
  21021. </if>
  21022. <if test="getDetailRecordListPageVO.chTimeStart != null ">
  21023. <![CDATA[ AND t.chTime >= #{getDetailRecordListPageVO.chTimeStart}]]>
  21024. </if>
  21025. <if test="getDetailRecordListPageVO.chTimeEnd != null ">
  21026. <![CDATA[ AND t.chTime <= #{getDetailRecordListPageVO.chTimeEnd}]]>
  21027. </if>
  21028. <if test="getDetailRecordListPageVO.mrTimeStart != null ">
  21029. <![CDATA[ AND t.mrTime >= #{getDetailRecordListPageVO.mrTimeStart}]]>
  21030. </if>
  21031. <if test="getDetailRecordListPageVO.mrTimeEnd != null ">
  21032. <![CDATA[ AND t.mrTime <= #{getDetailRecordListPageVO.mrTimeEnd}]]>
  21033. </if>
  21034. <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
  21035. AND qce.NAME = #{getDetailRecordListPageVO.casesEntryName}
  21036. </if>
  21037. <if test="getDetailRecordListPageVO.casesEntryId != null ">
  21038. AND qce.id = #{getDetailRecordListPageVO.casesEntryId}
  21039. </if>
  21040. <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
  21041. AND qce.cases_name = #{getDetailRecordListPageVO.casesName}
  21042. </if>
  21043. <if test="getDetailRecordListPageVO.casesId != null">
  21044. AND qce.cases_id = #{getDetailRecordListPageVO.casesId}
  21045. </if>
  21046. )f1,
  21047. (SELECT
  21048. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  21049. t.behDeptId,
  21050. t.behDeptName
  21051. FROM
  21052. (SELECT DISTINCT
  21053. t1.hospital_id AS hospitalId,
  21054. t1.behospital_code AS behospitalCode,
  21055. t1.bed_code AS bedCode,
  21056. t1.LEVEL AS LEVEL,
  21057. t1.grade_type AS gradeType,
  21058. t1.score_res AS scoreRes,
  21059. t1.NAME AS NAME,
  21060. t1.sex AS sex,
  21061. t1.beh_dept_id AS behDeptId,
  21062. t1.beh_dept_name AS behDeptName,
  21063. t1.doctor_id AS doctorId,
  21064. t1.doctor_name AS doctorName,
  21065. t1.beh_doctor_id AS behDoctorId,
  21066. t1.beh_doctor_name AS behDoctorName,
  21067. t1.director_doctor_id AS directorDoctorId,
  21068. t1.director_doctor_name AS directorDoctorName,
  21069. t1.birthday AS birthday,
  21070. t1.behospital_date AS behospitalDate,
  21071. t1.leave_hospital_date AS leaveHospitalDate,
  21072. t1.placefile_date AS placefileDate,
  21073. t1.gmt_create AS gradeTime,
  21074. t1.diagnose,
  21075. t1.ward_name AS wardName,
  21076. t2.age,
  21077. t1.file_code AS fileCode,
  21078. t1.checkStatus,
  21079. t1.mrStatus,
  21080. t1.chName,
  21081. t1.mrName,
  21082. t1.chTime,
  21083. t1.mrTime
  21084. FROM
  21085. (
  21086. SELECT DISTINCT
  21087. tt1.*
  21088. FROM
  21089. (SELECT
  21090. be.*,
  21091. ifnull(mci.status,0) AS checkStatus,
  21092. ifnull(hm_mci.status,0) AS mrStatus,
  21093. mci.check_name as chName,
  21094. hm_mci.check_name as mrName,
  21095. mci.gmt_create as chTime,
  21096. hm_mci.gmt_create as mrTime
  21097. FROM
  21098. (
  21099. SELECT DISTINCT
  21100. a.hospital_id,
  21101. a.behospital_code,
  21102. a.bed_code,
  21103. a.file_code,
  21104. b.LEVEL,
  21105. b.grade_type,
  21106. b.score_res,
  21107. a.NAME,
  21108. a.sex,
  21109. a.beh_dept_id,
  21110. a.beh_dept_name,
  21111. a.birthday,
  21112. a.behospital_date,
  21113. a.leave_hospital_date,
  21114. a.doctor_id,
  21115. a.doctor_name,
  21116. a.beh_doctor_id,
  21117. a.beh_doctor_name,
  21118. a.director_doctor_id,
  21119. a.director_doctor_name,
  21120. a.diagnose,
  21121. a.placefile_date,
  21122. a.ward_name,
  21123. b.gmt_create
  21124. FROM
  21125. med_behospital_info a,
  21126. med_qcresult_info b,
  21127. med_qcresult_detail c,
  21128. qc_cases_entry d
  21129. WHERE
  21130. a.is_deleted = 'N'
  21131. AND b.is_deleted = 'N'
  21132. AND c.is_deleted = 'N'
  21133. AND d.is_deleted = 'N'
  21134. AND a.hospital_id = b.hospital_id
  21135. AND a.hospital_id = c.hospital_id
  21136. AND a.behospital_code = b.behospital_code
  21137. AND a.behospital_code = c.behospital_code
  21138. AND c.cases_id = d.cases_id
  21139. AND c.cases_entry_id = d.id
  21140. AND a.qc_type_id != 0
  21141. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile != ''">
  21142. and a.is_placefile = #{getDetailRecordListPageVO.isPlacefile}
  21143. </if>
  21144. <if test="getDetailRecordListPageVO.hospitalId != null and getDetailRecordListPageVO.hospitalId != ''">
  21145. AND a.hospital_id = #{getDetailRecordListPageVO.hospitalId}
  21146. </if>
  21147. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 0">
  21148. <if test="getDetailRecordListPageVO.startDate != null ">
  21149. <![CDATA[ AND a.behospital_date >= #{getDetailRecordListPageVO.startDate}]]>
  21150. </if>
  21151. <if test="getDetailRecordListPageVO.endDate != null ">
  21152. <![CDATA[ AND a.behospital_date <= #{getDetailRecordListPageVO.endDate}]]>
  21153. </if>
  21154. </if>
  21155. <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 1">
  21156. <if test="getDetailRecordListPageVO.startDate != null ">
  21157. <![CDATA[ AND a.leave_hospital_date >= #{getDetailRecordListPageVO.startDate}]]>
  21158. </if>
  21159. <if test="getDetailRecordListPageVO.endDate != null">
  21160. <![CDATA[ AND a.leave_hospital_date <= #{getDetailRecordListPageVO.endDate}]]>
  21161. </if>
  21162. </if>
  21163. <if test="getDetailRecordListPageVO.diagnose != null and getDetailRecordListPageVO.diagnose != ''">
  21164. AND a.diagnose LIKE CONCAT( '%', #{getDetailRecordListPageVO.diagnose}, '%' )
  21165. </if>
  21166. <if test="getDetailRecordListPageVO.level != null and getDetailRecordListPageVO.level != ''">
  21167. AND b.`level` = #{getDetailRecordListPageVO.level}
  21168. </if>
  21169. <if test="getDetailRecordListPageVO.behospitalCode != null and getDetailRecordListPageVO.behospitalCode != ''">
  21170. AND a.behospital_code LIKE CONCAT( '%', #{getDetailRecordListPageVO.behospitalCode}, '%' )
  21171. </if>
  21172. <if test="getDetailRecordListPageVO.patName != null and getDetailRecordListPageVO.patName != ''">
  21173. AND a.NAME LIKE CONCAT( '%', #{getDetailRecordListPageVO.patName}, '%' )
  21174. </if>
  21175. <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
  21176. AND d.NAME = #{getDetailRecordListPageVO.casesEntryName}
  21177. </if>
  21178. <if test="getDetailRecordListPageVO.casesEntryId != null ">
  21179. AND d.id = #{getDetailRecordListPageVO.casesEntryId}
  21180. </if>
  21181. <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
  21182. AND d.cases_name = #{getDetailRecordListPageVO.casesName}
  21183. </if>
  21184. <if test="getDetailRecordListPageVO.casesId != null">
  21185. AND d.cases_id = #{getDetailRecordListPageVO.casesId}
  21186. </if>
  21187. <if test="getDetailRecordListPageVO.deptName != null and getDetailRecordListPageVO.deptName != '' and getDetailRecordListPageVO.deptName != '-0'">
  21188. AND a.beh_dept_name = #{getDetailRecordListPageVO.deptName}
  21189. </if>
  21190. <if test="getDetailRecordListPageVO.deptName == '-0'">
  21191. AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
  21192. </if>
  21193. <if test="getDetailRecordListPageVO.deptId != null and getDetailRecordListPageVO.deptId != '' and getDetailRecordListPageVO.deptId != '-0'">
  21194. AND a.beh_dept_id = #{getDetailRecordListPageVO.deptId}
  21195. </if>
  21196. <if test="getDetailRecordListPageVO.deptId == '-0'">
  21197. AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
  21198. </if>
  21199. <if test="getDetailRecordListPageVO.doctorId != null and getDetailRecordListPageVO.doctorId != '' and getDetailRecordListPageVO.doctorId != '-0'">
  21200. AND a.doctor_id = #{getDetailRecordListPageVO.doctorId}
  21201. </if>
  21202. <if test="getDetailRecordListPageVO.doctorId == '-0'">
  21203. AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
  21204. </if>
  21205. <if test="getDetailRecordListPageVO.doctorName != null and getDetailRecordListPageVO.doctorName != '' and getDetailRecordListPageVO.doctorName != '-0' ">
  21206. AND a.doctor_name = #{getDetailRecordListPageVO.doctorName}
  21207. </if>
  21208. <if test="getDetailRecordListPageVO.doctorName == '-0'">
  21209. AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
  21210. </if>
  21211. <if test="getDetailRecordListPageVO.isReject != null">
  21212. AND c.is_reject = #{getDetailRecordListPageVO.isReject}
  21213. </if>
  21214. <if test="getDetailRecordListPageVO.ruleType != null">
  21215. AND d.rule_type = #{getDetailRecordListPageVO.ruleType}
  21216. </if>
  21217. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2495">
  21218. AND TIMESTAMPDIFF(
  21219. DAY,
  21220. DATE( a.behospital_date ),
  21221. DATE( a.leave_hospital_date ))> 30
  21222. </if>
  21223. <if test="getDetailRecordListPageVO.beHosGT31Days != null and getDetailRecordListPageVO.beHosGT31Days==1">
  21224. AND TIMESTAMPDIFF(
  21225. DAY,
  21226. DATE( a.behospital_date ),
  21227. DATE( a.leave_hospital_date ))> 31
  21228. </if>
  21229. )be
  21230. left join med_check_info mci
  21231. on mci.is_deleted = 'N'
  21232. and mci.check_type in(0,2)
  21233. and be.hospital_id = mci.hospital_id
  21234. and be.behospital_code = mci.behospital_code
  21235. left join med_check_info hm_mci
  21236. on hm_mci.is_deleted = 'N'
  21237. and hm_mci.check_type = 1
  21238. and be.hospital_id = hm_mci.hospital_id
  21239. and be.behospital_code = hm_mci.behospital_code
  21240. )tt1
  21241. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2511">
  21242. ,med_medical_record tt2
  21243. WHERE
  21244. tt2.is_deleted = 'N'
  21245. AND tt1.hospital_id = tt2.hospital_id
  21246. AND tt1.behospital_code = tt2.behospital_code
  21247. AND tt2.mode_id = 30
  21248. </if>
  21249. <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2419">
  21250. ,med_crisis_info tt2
  21251. WHERE
  21252. tt2.is_deleted = 'N'
  21253. AND tt1.hospital_id = tt2.hospital_id
  21254. AND tt1.behospital_code = tt2.behospital_code
  21255. </if>
  21256. ) t1
  21257. <if test="getDetailRecordListPageVO.casesEntryId == null or (getDetailRecordListPageVO.casesEntryId!=2594 and getDetailRecordListPageVO.casesEntryId!=2973 and getDetailRecordListPageVO.casesEntryId!=2930)">
  21258. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  21259. AND t1.behospital_code = t2.behospital_code
  21260. AND t2.is_deleted = 'N'
  21261. </if>
  21262. <if test="getDetailRecordListPageVO.casesEntryId != null and( getDetailRecordListPageVO.casesEntryId==2594 or getDetailRecordListPageVO.casesEntryId==2973 or getDetailRecordListPageVO.casesEntryId==2930)">
  21263. , med_home_page t2
  21264. , med_home_operation_info t3
  21265. WHERE t1.hospital_id = t2.hospital_id
  21266. AND t1.behospital_code = t2.behospital_code
  21267. AND t2.home_page_id = t3.home_page_id
  21268. AND t2.is_deleted = 'N'
  21269. AND t3.is_deleted = 'N'
  21270. </if>
  21271. ) t
  21272. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  21273. AND t.hospitalId = qi.hospital_id
  21274. AND t.behospitalCode = qi.behospital_code
  21275. where 1=1
  21276. <if test="getDetailRecordListPageVO.checkStatus != null">
  21277. AND t.checkStatus = #{getDetailRecordListPageVO.checkStatus}
  21278. </if>
  21279. <if test="getDetailRecordListPageVO.mrStatus != null">
  21280. AND t.mrStatus = #{getDetailRecordListPageVO.mrStatus}
  21281. </if>
  21282. <if test="getDetailRecordListPageVO.chName != null and getDetailRecordListPageVO.chName!=''">
  21283. AND t.chName like concat('%', #{getDetailRecordListPageVO.chName}, '%')
  21284. </if>
  21285. <if test="getDetailRecordListPageVO.mrName != null and getDetailRecordListPageVO.mrName!=''">
  21286. AND t.mrName like concat('%', #{getDetailRecordListPageVO.mrName}, '%')
  21287. </if>
  21288. <if test="getDetailRecordListPageVO.chTimeStart != null ">
  21289. <![CDATA[ AND t.chTime >= #{getDetailRecordListPageVO.chTimeStart}]]>
  21290. </if>
  21291. <if test="getDetailRecordListPageVO.chTimeEnd != null ">
  21292. <![CDATA[ AND t.chTime <= #{getDetailRecordListPageVO.chTimeEnd}]]>
  21293. </if>
  21294. <if test="getDetailRecordListPageVO.mrTimeStart != null ">
  21295. <![CDATA[ AND t.mrTime >= #{getDetailRecordListPageVO.mrTimeStart}]]>
  21296. </if>
  21297. <if test="getDetailRecordListPageVO.mrTimeEnd != null ">
  21298. <![CDATA[ AND t.mrTime <= #{getDetailRecordListPageVO.mrTimeEnd}]]>
  21299. </if>
  21300. GROUP BY
  21301. t.behDeptId,
  21302. t.behDeptName
  21303. )f2
  21304. WHERE
  21305. f1.behDeptId = f2.behDeptId
  21306. AND f1.behDeptName = f2.behDeptName
  21307. )m
  21308. </select>
  21309. </mapper>