BehospitalInfoMapper.xml 800 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  7. <id column="behospital_code" property="behospitalCode"/>
  8. <result column="hospital_id" property="hospitalId"/>
  9. <result column="name" property="name"/>
  10. <result column="sex" property="sex"/>
  11. <result column="birthday" property="birthday"/>
  12. <result column="file_code" property="fileCode"/>
  13. <result column="qc_type_id" property="qcTypeId"/>
  14. <result column="ward_code" property="wardCode"/>
  15. <result column="ward_name" property="wardName"/>
  16. <result column="beh_dept_id" property="behDeptId"/>
  17. <result column="beh_dept_name" property="behDeptName"/>
  18. <result column="bed_code" property="bedCode"/>
  19. <result column="bed_name" property="bedName"/>
  20. <result column="insurance_name" property="insuranceName"/>
  21. <result column="job_type" property="jobType"/>
  22. <result column="behospital_date" property="behospitalDate"/>
  23. <result column="leave_hospital_date" property="leaveHospitalDate"/>
  24. <result column="diagnose_icd" property="diagnoseIcd"/>
  25. <result column="diagnose" property="diagnose"/>
  26. <result column="beh_doctor_id" property="behDoctorId"/>
  27. <result column="beh_doctor_name" property="behDoctorName"/>
  28. <result column="doctor_id" property="doctorId"/>
  29. <result column="doctor_name" property="doctorName"/>
  30. <result column="director_doctor_id" property="directorDoctorId"/>
  31. <result column="director_doctor_name" property="directorDoctorName"/>
  32. <result column="is_placefile" property="isPlacefile"/>
  33. <result column="placefile_date" property="placefileDate"/>
  34. <result column="is_deleted" property="isDeleted"/>
  35. <result column="gmt_create" property="gmtCreate"/>
  36. <result column="gmt_modified" property="gmtModified"/>
  37. <result column="creator" property="creator"/>
  38. <result column="modifier" property="modifier"/>
  39. <result column="linkman" property="linkman"/>
  40. </resultMap>
  41. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  42. SELECT * FROM (
  43. select t.*,
  44. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  45. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  46. g.check_type AS ch_type,
  47. h.check_type AS mr_type,
  48. g.check_name AS ch_name,
  49. h.check_name AS mr_name,
  50. g.check_time AS ch_time,
  51. h.check_time AS mr_time
  52. from (
  53. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  54. grade_time,IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,e.score_res as score_bn from med_behospital_info a
  55. LEFT JOIN med_qcresult_info b
  56. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  57. left join med_home_page c
  58. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  59. LEFT JOIN med_qcresult_cases e
  60. on a.behospital_code = e.behospital_code
  61. AND e.is_deleted = 'N'
  62. and e.cases_id = 243
  63. ) t
  64. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  65. ON t.behospital_code = g.behospital_code
  66. AND t.hospital_id = g.hospital_id
  67. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  68. ON t.behospital_code = h.behospital_code
  69. AND t.hospital_id = h.hospital_id
  70. where t.is_deleted = 'N'
  71. <if test="diagnose != null and diagnose != ''">
  72. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  73. </if>
  74. <if test="deptName != null and deptName != ''">
  75. and t.beh_dept_name= #{deptName}
  76. </if>
  77. <if test="doctorName != null and doctorName != ''">
  78. and CONCAT(
  79. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  80. like CONCAT('%',#{doctorName},'%')
  81. </if>
  82. <if test="name != null and name != ''">
  83. and t.name like CONCAT('%',#{name},'%')
  84. </if>
  85. <if test="doctorCode != null and doctorCode != ''">
  86. and (t.doctor_id = #{doctorCode}
  87. or t.beh_doctor_id = #{doctorCode}
  88. or t.director_doctor_id = #{doctorCode})
  89. </if>
  90. <if test="fileCode != null and fileCode != ''">
  91. and t.file_code like CONCAT('%',#{fileCode},'%')
  92. </if>
  93. <if test="hospitalId != null">
  94. and t.hospital_id = #{hospitalId}
  95. </if>
  96. <if test="behospitalCode != null and behospitalCode != ''">
  97. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  98. </if>
  99. <if test="behosDateStart != null">
  100. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  101. </if>
  102. <if test="behosDateEnd != null">
  103. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  104. </if>
  105. <if test="leaveHosDateStart != null">
  106. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  107. </if>
  108. <if test="leaveHosDateEnd != null">
  109. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  110. </if>
  111. <if test="level != null and level != ''">
  112. and t.level = #{level}
  113. </if>
  114. <if test="isPlacefile != null and isPlacefile != ''">
  115. and t.is_placefile = #{isPlacefile}
  116. </if>
  117. and t.qc_type_id != 0) p
  118. where p.is_deleted="N"
  119. <if test="checkStatus != null ">
  120. and p.check_status = #{checkStatus}
  121. </if>
  122. <if test="mrStatus != null ">
  123. AND p.mr_status = #{mrStatus}
  124. </if>
  125. <if test="chName != null and chName !=''">
  126. AND p.ch_name like CONCAT('%',#{chName},'%')
  127. </if>
  128. <if test="mrName != null and mrName !=''">
  129. AND p.mr_name like CONCAT('%',#{mrName},'%')
  130. </if>
  131. <if test="chTimeStart != null">
  132. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  133. </if>
  134. <if test="chTimeEnd != null">
  135. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  136. </if>
  137. <if test="mrTimeStart != null">
  138. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  139. </if>
  140. <if test="mrTimeEnd != null">
  141. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  142. </if>
  143. </select>
  144. <select id="getQualityCaseSorce" resultType="com.diagbot.dto.CaseScoreDTO">
  145. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  146. FROM med_qcresult_detail c,med_behospital_info e
  147. where c.is_deleted = 'N'AND e.is_deleted = 'N'
  148. AND c.behospital_code = e.behospital_code
  149. AND c.hospital_id = e.hospital_id
  150. and c.hospital_id = #{hospitalId}
  151. <if test="deptName != null and deptName != ''">
  152. and e.beh_dept_name= #{deptName}
  153. </if>
  154. <if test="behospitalCode != null and behospitalCode != ''">
  155. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  156. </if>
  157. <if test="isPlacefile != null and isPlacefile != ''">
  158. and e.is_placefile = #{isPlacefile}
  159. </if>
  160. <if test="behosDateStart != null">
  161. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  162. </if>
  163. <if test="behosDateEnd != null">
  164. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  165. </if>
  166. <if test="leaveHosDateStart != null">
  167. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  168. </if>
  169. <if test="leaveHosDateEnd != null">
  170. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  171. </if>
  172. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  173. order by c.behospital_code
  174. </select>
  175. <select id="getQualityCaseSorceByDept" resultType="com.diagbot.dto.CaseScoreDTO">
  176. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  177. FROM med_qcresult_detail c,sys_user_dept d,med_behospital_info e
  178. where c.is_deleted = 'N' AND d.is_deleted = 'N' AND e.is_deleted = 'N'
  179. AND c.behospital_code = e.behospital_code
  180. ON d.hospital_id = e.hospital_id
  181. AND e.beh_dept_id = d.dept_id
  182. AND c.hospital_id = e.hospital_id
  183. and c.hospital_id = #{hospitalId}
  184. <if test="deptName != null and deptName != ''">
  185. and e.beh_dept_name= #{deptName}
  186. </if>
  187. <if test="userId != null and userId != ''">
  188. and d.user_id = #{userId}
  189. </if>
  190. <if test="behospitalCode != null and behospitalCode != ''">
  191. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  192. </if>
  193. <if test="isPlacefile != null and isPlacefile != ''">
  194. and e.is_placefile = #{isPlacefile}
  195. </if>
  196. <if test="behosDateStart != null">
  197. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  198. </if>
  199. <if test="behosDateEnd != null">
  200. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  201. </if>
  202. <if test="leaveHosDateStart != null">
  203. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  204. </if>
  205. <if test="leaveHosDateEnd != null">
  206. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  207. </if>
  208. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  209. order by c.behospital_code
  210. </select>
  211. <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  212. SELECT * FROM (
  213. select
  214. distinct
  215. t.name AS NAME,
  216. t.behospital_code AS behospitalCode,
  217. t.doctor_name AS doctorName,
  218. t.beh_dept_name AS deptName,
  219. t.beh_dept_id AS deptId,
  220. t.leave_hospital_date AS leaveHospitalDate,
  221. t.level,
  222. t.age,
  223. t.score_res as totalScore,
  224. t.is_deleted,
  225. g.check_name AS chName,
  226. h.check_name AS mrName
  227. from (
  228. select a.*,
  229. ifnull(b.level,'未评分') as level,
  230. b.grade_type,
  231. IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,
  232. b.score_res
  233. from med_behospital_info a
  234. LEFT JOIN med_qcresult_info b
  235. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  236. left join med_home_page c
  237. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  238. ) t
  239. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  240. ON t.behospital_code = g.behospital_code
  241. AND t.hospital_id = g.hospital_id
  242. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  243. ON t.behospital_code = h.behospital_code
  244. AND t.hospital_id = h.hospital_id
  245. where t.is_deleted = 'N'
  246. <if test="diagnose != null and diagnose != ''">
  247. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  248. </if>
  249. <if test="deptName != null and deptName != ''">
  250. and t.beh_dept_name= #{deptName}
  251. </if>
  252. <if test="doctorName != null and doctorName != ''">
  253. and CONCAT(
  254. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  255. like CONCAT('%',#{doctorName},'%')
  256. </if>
  257. <if test="name != null and name != ''">
  258. and t.name like CONCAT('%',#{name},'%')
  259. </if>
  260. <if test="doctorCode != null and doctorCode != ''">
  261. and (t.doctor_id = #{doctorCode}
  262. or t.beh_doctor_id = #{doctorCode}
  263. or t.director_doctor_id = #{doctorCode})
  264. </if>
  265. <if test="fileCode != null and fileCode != ''">
  266. and t.file_code like CONCAT('%',#{fileCode},'%')
  267. </if>
  268. <if test="hospitalId != null">
  269. and t.hospital_id = #{hospitalId}
  270. </if>
  271. <if test="behospitalCode != null and behospitalCode != ''">
  272. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  273. </if>
  274. <if test="behosDateStart != null">
  275. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  276. </if>
  277. <if test="behosDateEnd != null">
  278. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  279. </if>
  280. <if test="leaveHosDateStart != null">
  281. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  282. </if>
  283. <if test="leaveHosDateEnd != null">
  284. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  285. </if>
  286. <if test="level != null and level != ''">
  287. and t.level = #{level}
  288. </if>
  289. <if test="isPlacefile != null and isPlacefile != ''">
  290. and t.is_placefile = #{isPlacefile}
  291. </if>
  292. and t.qc_type_id != 0) p
  293. where p.is_deleted="N"
  294. <if test="chName != null and chName !=''">
  295. AND p.chName like CONCAT('%',#{chName},'%')
  296. </if>
  297. <if test="mrName != null and mrName !=''">
  298. AND p.mrName like CONCAT('%',#{mrName},'%')
  299. </if>
  300. </select>
  301. <select id="qualityControlByDept" resultType="com.diagbot.dto.QualityControlDeptDTO">
  302. SELECT * FROM (
  303. select
  304. distinct
  305. t.name AS NAME,
  306. t.behospital_code AS behospitalCode,
  307. t.doctor_name AS doctorName,
  308. t.beh_dept_name AS deptName,
  309. t.beh_dept_id AS deptId,
  310. t.leave_hospital_date AS leaveHospitalDate,
  311. t.level,
  312. t.age,
  313. t.score_res as totalScore,
  314. t.is_deleted,
  315. g.check_name AS chName,
  316. h.check_name AS mrName
  317. from (
  318. select a.*, ifnull(b.level,'未评分') as level, IF(c.age is null, null,CONCAT( ifnull(c.age,''),ifnull(c.age_unit,'') ))as age, b.grade_type,d.user_id, b.score_res, b.gmt_create as
  319. grade_time from med_behospital_info a
  320. LEFT JOIN med_qcresult_info b
  321. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  322. left join med_home_page c
  323. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  324. LEFT JOIN sys_user_dept d
  325. ON a.hospital_id = d.hospital_id
  326. AND a.beh_dept_id = d.dept_id
  327. ) t
  328. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  329. ON t.behospital_code = g.behospital_code
  330. AND t.hospital_id = g.hospital_id
  331. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  332. ON t.behospital_code = h.behospital_code
  333. AND t.hospital_id = h.hospital_id
  334. where t.is_deleted = 'N'
  335. AND t.user_id = #{userId}
  336. <if test="diagnose != null and diagnose != ''">
  337. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  338. </if>
  339. <if test="deptName != null and deptName != ''">
  340. and t.beh_dept_name= #{deptName}
  341. </if>
  342. <if test="doctorName != null and doctorName != ''">
  343. and CONCAT(
  344. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  345. like CONCAT('%',#{doctorName},'%')
  346. </if>
  347. <if test="name != null and name != ''">
  348. and t.name like CONCAT('%',#{name},'%')
  349. </if>
  350. <if test="doctorCode != null and doctorCode != ''">
  351. and (t.doctor_id = #{doctorCode}
  352. or t.beh_doctor_id = #{doctorCode}
  353. or t.director_doctor_id = #{doctorCode})
  354. </if>
  355. <if test="fileCode != null and fileCode != ''">
  356. and t.file_code like CONCAT('%',#{fileCode},'%')
  357. </if>
  358. <if test="hospitalId != null">
  359. and t.hospital_id = #{hospitalId}
  360. </if>
  361. <if test="behospitalCode != null and behospitalCode != ''">
  362. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  363. </if>
  364. <if test="behosDateStart != null">
  365. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  366. </if>
  367. <if test="behosDateEnd != null">
  368. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  369. </if>
  370. <if test="leaveHosDateStart != null">
  371. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  372. </if>
  373. <if test="leaveHosDateEnd != null">
  374. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  375. </if>
  376. <if test="level != null and level != ''">
  377. and t.level = #{level}
  378. </if>
  379. <if test="isPlacefile != null and isPlacefile != ''">
  380. and t.is_placefile = #{isPlacefile}
  381. </if>
  382. and t.qc_type_id != 0) p
  383. where p.is_deleted="N"
  384. <if test="chName != null and chName !=''">
  385. AND p.chName like CONCAT('%',#{chName},'%')
  386. </if>
  387. <if test="mrName != null and mrName !=''">
  388. AND p.mrName like CONCAT('%',#{mrName},'%')
  389. </if>
  390. </select>
  391. <!-- <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  392. SELECT m.* FROM(
  393. SELECT
  394. a.name AS NAME,
  395. a.behospital_code AS behospitalCode,
  396. a.doctor_name AS doctorName,
  397. a.beh_dept_name AS deptName,
  398. a.beh_dept_id AS deptId,
  399. a.leave_hospital_date AS leaveHospitalDate,
  400. c.behospital_code,
  401. c.hospital_id,
  402. c.admissionNote,
  403. c.firstCourseNote,
  404. c.medHomePage,
  405. c.docAdviceNote,
  406. c.courseRecord,
  407. c.operationInfo,
  408. c.dischargeNote,
  409. c.admissionNoteScore,
  410. c.firstCourseNoteScore,
  411. c. medHomePageScore,
  412. c.docAdviceNoteScore,
  413. c.courseRecordScore,
  414. c.operationInfoScore,
  415. c.dischargeNoteScore,
  416. c.otherCase,
  417. (100.0-c.score_res) AS otherCaseScore,
  418. IFNULL(b.level,'未评分') AS `level`,
  419. g.check_name AS ch_name,
  420. h.check_name AS mr_name
  421. FROM
  422. med_behospital_info a LEFT JOIN med_qcresult_info b
  423. ON a.behospital_code = b.behospital_code AND b.is_deleted = 'N'
  424. LEFT JOIN (
  425. SELECT
  426. t.behospital_code,
  427. t.hospital_id,
  428. t.admissionNote,
  429. t.firstCourseNote,
  430. t.medHomePage,
  431. t.docAdviceNote,
  432. t.courseRecord,
  433. t.operationInfo,
  434. t.dischargeNote,
  435. t.otherCase,
  436. t.score_res,
  437. if(t.admissionNoteScoreOn >= t.admissionNoteTolScore, (t.admissionNoteTolScore + t.admissionNoteScoreTh),(t.admissionNoteScoreOn + t.admissionNoteScoreTh)) AS admissionNoteScore,
  438. if(t.firstCourseNoteScoreOn >= t.firstCourseNoteTolScore, (t.firstCourseNoteTolScore + t.firstCourseNoteScoreTh),(t.firstCourseNoteScoreOn + t.firstCourseNoteScoreTh)) AS firstCourseNoteScore,
  439. if(t.medHomePageScoreOn >= t.medHomePageTolScore, (t.medHomePageTolScore + t.medHomePageScoreTh),(t.medHomePageScoreOn + t.medHomePageScoreTh)) AS medHomePageScore,
  440. if(t.docAdviceNoteScoreOn >= t.docAdviceNoteTolScore, (t.docAdviceNoteTolScore + t.docAdviceNoteScoreTh),(t.docAdviceNoteScoreOn + t.docAdviceNoteScoreTh)) AS docAdviceNoteScore,
  441. if(t.courseRecordScoreOn >= t.courseRecordTolScore, (t.courseRecordTolScore + t.courseRecordScoreTh),(t.courseRecordScoreOn + t.courseRecordScoreTh)) AS courseRecordScore,
  442. if(t.operationInfoScoreOn >= t.operationInfoTolScore, (t.operationInfoTolScore + t.operationInfoScoreTh),(t.operationInfoScoreOn + t.operationInfoScoreTh)) AS operationInfoScore,
  443. if(t.dischargeNoteScoreOn >= t.dischargeNoteTolScore, (t.dischargeNoteTolScore + t.dischargeNoteScoreTh),(t.dischargeNoteScoreOn + t.dischargeNoteScoreTh)) AS dischargeNoteScore
  444. from(
  445. select
  446. t1.*,
  447. t2.admissionNoteTolScore,
  448. t2.firstCourseNoteTolScore,
  449. t2.medHomePageTolScore,
  450. t2.docAdviceNoteTolScore,
  451. t2.courseRecordTolScore,
  452. t2.operationInfoTolScore,
  453. t2.dischargeNoteTolScore,
  454. t2.score_res FROM (
  455. SELECT
  456. t1.behospital_code,
  457. t1.hospital_id,
  458. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  459. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  460. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  461. (SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS admissionNoteScoreTh,
  462. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  463. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  464. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  465. (SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) -SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS firstCourseNoteScoreTh,
  466. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  467. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  468. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  469. (SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS medHomePageScoreTh,
  470. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  471. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  472. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  473. (SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS docAdviceNoteScoreTh,
  474. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  475. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  476. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  477. (SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS courseRecordScoreTh,
  478. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  479. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  480. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  481. (SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS operationInfoScoreTh,
  482. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  483. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  484. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  485. (SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END)-GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' )) AS dischargeNoteScoreTh,
  486. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id != 1 AND t1.mode_id != 2 AND t1.mode_id != 6 AND t1.mode_id != 8 AND t1.mode_id != 156 AND t1.mode_id != 17 AND t1.mode_id != 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS otherCase
  487. FROM (
  488. SELECT
  489. c.behospital_code,
  490. c.hospital_id,
  491. a.mode_id,
  492. c.cases_score,
  493. c.score,
  494. c.msg,
  495. c.is_reject,
  496. c.cases_id
  497. FROM
  498. `qc_cases_entry` a,
  499. qc_mode b,
  500. med_qcresult_detail c,
  501. qc_cases_hospital d,
  502. med_behospital_info e
  503. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  504. AND a.id = c.cases_entry_id
  505. AND a.mode_id = b.id
  506. AND c.cases_id = d.cases_id
  507. AND c.hospital_id = d.hospital_id
  508. AND c.behospital_code = e.behospital_code
  509. AND c.hospital_id = e.hospital_id
  510. <if test="hospitalId != null">
  511. and c.hospital_id = #{hospitalId}
  512. </if>
  513. <if test="deptName != null and deptName != ''">
  514. and e.beh_dept_name= #{deptName}
  515. </if>
  516. <if test="behospitalCode != null and behospitalCode != ''">
  517. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  518. </if>
  519. <if test="isPlacefile != null and isPlacefile != ''">
  520. and e.is_placefile = #{isPlacefile}
  521. </if>
  522. <if test="behosDateStart != null">
  523. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  524. </if>
  525. <if test="behosDateEnd != null">
  526. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  527. </if>
  528. <if test="leaveHosDateStart != null">
  529. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  530. </if>
  531. <if test="leaveHosDateEnd != null">
  532. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  533. </if>
  534. <if test="level != null and level != ''">
  535. and e.level = #{level}
  536. </if>
  537. <if test="level != null and level != ''">
  538. and e.level = #{level}
  539. </if>
  540. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  541. )t1 GROUP BY behospital_code)t1
  542. LEFT JOIN (
  543. SELECT m1.*, m2.score_res FROM(
  544. SELECT
  545. m1.hospital_id,
  546. m1.behospital_code,
  547. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  548. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  549. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  550. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  551. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  552. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  553. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  554. FROM (
  555. SELECT
  556. c.behospital_code,
  557. a.mode_id,
  558. c.cases_score,
  559. c.cases_id,
  560. c.hospital_id
  561. FROM
  562. `qc_cases_entry` a,
  563. qc_mode b,
  564. med_qcresult_detail c,
  565. qc_cases_hospital d,
  566. med_behospital_info e
  567. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  568. AND a.id = c.cases_entry_id
  569. AND a.mode_id = b.id
  570. AND c.cases_id = d.cases_id
  571. AND c.hospital_id = d.hospital_id
  572. AND c.behospital_code = e.behospital_code
  573. AND c.hospital_id = e.hospital_id
  574. <if test="hospitalId != null">
  575. and c.hospital_id = #{hospitalId}
  576. </if>
  577. <if test="deptName != null and deptName != ''">
  578. and e.beh_dept_name= #{deptName}
  579. </if>
  580. <if test="behospitalCode != null and behospitalCode != ''">
  581. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  582. </if>
  583. <if test="isPlacefile != null and isPlacefile != ''">
  584. and e.is_placefile = #{isPlacefile}
  585. </if>
  586. <if test="behosDateStart != null">
  587. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  588. </if>
  589. <if test="behosDateEnd != null">
  590. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  591. </if>
  592. <if test="leaveHosDateStart != null">
  593. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  594. </if>
  595. <if test="leaveHosDateEnd != null">
  596. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  597. </if>
  598. <if test="level != null and level != ''">
  599. and e.level = #{level}
  600. </if>
  601. <if test="level != null and level != ''">
  602. and e.level = #{level}
  603. </if>
  604. GROUP BY mode_id
  605. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  606. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  607. ON m2.is_deleted = 'N'
  608. AND m1.hospital_id = m2.hospital_id
  609. AND m1.behospital_code = m2.behospital_code
  610. )t2
  611. ON t1.hospital_id = t2.hospital_id
  612. AND t1.behospital_code = t2.behospital_code)t)c
  613. ON a.behospital_code = c.behospital_code
  614. AND a.hospital_id = c.hospital_id
  615. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  616. ON a.behospital_code = g.behospital_code
  617. AND a.hospital_id = g.hospital_id
  618. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  619. ON a.behospital_code = h.behospital_code
  620. AND a.hospital_id = h.hospital_id
  621. where
  622. a.is_deleted = 'N'
  623. <if test="deptName != null and deptName != ''">
  624. and a.beh_dept_name= #{deptName}
  625. </if>
  626. <if test="doctorName != null and doctorName != ''">
  627. and CONCAT(
  628. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  629. like CONCAT('%',#{doctorName},'%')
  630. </if>
  631. <if test="name != null and name != ''">
  632. and a.name like CONCAT('%',#{name},'%')
  633. </if>
  634. <if test="doctorCode != null and doctorCode != ''">
  635. and (a.doctor_id = #{doctorCode}
  636. or a.beh_doctor_id = #{doctorCode}
  637. or a.director_doctor_id = #{doctorCode})
  638. </if>
  639. <if test="fileCode != null and fileCode != ''">
  640. and a.file_code like CONCAT('%',#{fileCode},'%')
  641. </if>
  642. <if test="hospitalId != null">
  643. and a.hospital_id = #{hospitalId}
  644. </if>
  645. <if test="behospitalCode != null and behospitalCode != ''">
  646. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  647. </if>
  648. <if test="behosDateStart != null">
  649. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  650. </if>
  651. <if test="behosDateEnd != null">
  652. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  653. </if>
  654. <if test="leaveHosDateStart != null">
  655. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  656. </if>
  657. <if test="leaveHosDateEnd != null">
  658. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  659. </if>
  660. <if test="level != null and level != ''">
  661. and a.level = #{level}
  662. </if>
  663. <if test="isPlacefile != null and isPlacefile != ''">
  664. and a.is_placefile = #{isPlacefile}
  665. </if>
  666. and a.qc_type_id != 0
  667. <if test="chName != null and chName !=''">
  668. AND g.ch_name like CONCAT('%',#{chName},'%')
  669. </if>
  670. <if test="mrName != null and mrName !=''">
  671. AND h.mr_name like CONCAT('%',#{mrName},'%')
  672. </if>)m
  673. </select>-->
  674. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  675. SELECT a.*, u.linkman
  676. FROM
  677. (
  678. SELECT DISTINCT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info, a.cases_id cases_id, d.score cases_score,
  679. b.id model_id, a.name standard_msg, c.opt_type, c.grade_type,
  680. c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,c.explain_info as explainInfo,
  681. a.type, a.drgs
  682. FROM
  683. `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  684. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  685. and a.id = c.cases_entry_id and a.mode_id = b.id
  686. AND c.cases_id = d.cases_id and c.hospital_id = d.hospital_id
  687. and c.hospital_id = #{hospitalId}
  688. and c.behospital_code = #{behospitalCode}
  689. order by b.order_no, c.grade_type desc, a.order_no) a
  690. LEFT JOIN sys_user u on u.id = a.modifier and u.is_deleted = 'N'
  691. </select>
  692. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  693. SELECT b.id model_id,b.`name` model_name,
  694. d.score,d.msg,d.cases_entry_id,d.is_reject,
  695. a.cases_id cases_id, a.name standard_msg,a.code
  696. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  697. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  698. and a.mode_id = b.id
  699. and a.id = d.cases_entry_id
  700. and d.is_used = 1
  701. and d.hospital_id = #{hospitalId}
  702. and a.code in
  703. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  704. #{item}
  705. </foreach>
  706. <if test="modeId != null">
  707. and a.mode_id = #{modeId}
  708. </if>
  709. order by b.order_no, a.order_no;
  710. </select>
  711. <!--病案管理指标基础sql明细-->
  712. <select id="getBaseIndex" parameterType="com.diagbot.vo.MedIndexFilterVO" resultType="java.util.Map">
  713. select
  714. f1.firWorkNum,
  715. f2.secWorkNum,
  716. f3.thrWorkNum,
  717. f3.forWorkNum,
  718. f3.sixWorkNum
  719. from (
  720. SELECT count(DISTINCT a.behospital_code) as firWorkNum
  721. FROM
  722. med_behospital_info a
  723. WHERE
  724. a.is_deleted = 'N'
  725. AND a.is_placefile = 1
  726. <if test="hospitalId != null and hospitalId != ''">
  727. AND a.hospital_id = #{hospitalId}
  728. </if>
  729. <![CDATA[AND a.qc_type_id <>0 ]]>
  730. <if test="startDate != null and startDate != ''">
  731. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  732. </if>
  733. <if test="endDate != null and endDate != ''">
  734. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  735. </if>)f1,
  736. ( SELECT count(DISTINCT a.behospital_code) AS secWorkNum
  737. FROM
  738. med_outpatient_info a
  739. WHERE
  740. a.is_deleted = 'N'
  741. <if test="startDate != null and startDate != ''">
  742. <![CDATA[ AND a.visit_date >= #{lastStartDate}]]>
  743. </if>
  744. <if test="endDate != null and endDate != ''">
  745. <![CDATA[ AND a.visit_date <= #{lastEndDate}]]>
  746. </if>
  747. <if test="hospitalId != null and hospitalId != ''">
  748. AND a.hospital_id = #{hospitalId}
  749. </if>)f2,(
  750. select
  751. count(DISTINCT case when <![CDATA[m.behospital_date >= #{startDate}]]> and <![CDATA[m.behospital_date <= #{endDate}]]>
  752. and m.is_placefile = 0 then m.behospital_code else null end) as thrWorkNum,
  753. 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,
  754. 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
  755. from(
  756. SELECT DISTINCT a.*,b.level
  757. FROM
  758. med_behospital_info a,
  759. med_qcresult_info b
  760. WHERE
  761. a.is_deleted = 'N'
  762. AND b.is_deleted = 'N'
  763. AND a.hospital_id = b.hospital_id
  764. AND a.behospital_code = b.behospital_code
  765. <![CDATA[AND a.qc_type_id <>0 ]]>
  766. <if test="hospitalId != null and hospitalId != ''">
  767. AND a.hospital_id = #{hospitalId}
  768. </if>)m
  769. )f3
  770. </select>
  771. <!-- 病案管理规则质控缺陷病历总数查询-->
  772. <select id="getMedManageParams" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.MedManageParamsDTO">
  773. SELECT
  774. f1.behospitalCode,
  775. <if test="flagStr != null and flagStr == 1 ">
  776. f2.rep_name as repName,
  777. </if>
  778. <if test="flagStr != null and flagStr == 2">
  779. f3.da_item_name as daItemName,
  780. f3.da_status AS daStatus,
  781. f3.doctor_advice_type as doctorAdviceType,
  782. </if>
  783. <if test="flagStr != null and flagStr == 4 ">
  784. f5.content as content,
  785. f5.rec_title as recTitle,
  786. </if>
  787. f1.hospitalId
  788. from(
  789. SELECT DISTINCT
  790. a.hospital_id as hospitalId,
  791. a.behospital_code as behospitalCode
  792. FROM
  793. med_behospital_info a,
  794. med_qcresult_info b
  795. WHERE
  796. a.is_deleted = 'N'
  797. AND b.is_deleted = 'N'
  798. AND a.hospital_id = b.hospital_id
  799. AND a.behospital_code = b.behospital_code
  800. AND <![CDATA[a.leave_hospital_date >= #{startDate}]]>
  801. AND <![CDATA[a.leave_hospital_date <= #{endDate}]]>
  802. AND a.is_placefile = 1
  803. <![CDATA[AND a.qc_type_id <>0 ]]>
  804. <if test="hospitalId != null and hospitalId != ''">
  805. AND a.hospital_id = #{hospitalId}
  806. </if>)f1
  807. <if test="flagStr != null and flagStr == 1 ">
  808. join med_lis_info f2
  809. on f2.is_deleted = 'N'
  810. AND f1.hospitalId = f2.hospital_id
  811. AND f1.behospitalCode = f2.behospital_code
  812. </if>
  813. <if test="flagStr != null and flagStr == 2">
  814. join med_doctor_advice f3
  815. on f3.is_deleted = 'N'
  816. AND f1.hospitalId = f3.hospital_id
  817. AND f1.behospitalCode = f3.behospital_code
  818. </if>
  819. <if test="flagStr != null and flagStr == 3">
  820. join med_qcresult_detail f4
  821. on f4.is_deleted = 'N'
  822. AND f1.hospitalId = f4.hospital_id
  823. AND f1.behospitalCode = f4.behospital_code
  824. AND f4.is_reject = 1
  825. </if>
  826. <if test="flagStr != null and flagStr == 4">
  827. join str_informed_consent f5
  828. on f5.is_deleted = 'N'
  829. AND f1.hospitalId = f5.hospital_id
  830. AND f1.behospitalCode = f5.behospital_code
  831. </if>
  832. </select>
  833. <!-- 各科室缺陷占比-全院-首页 -->
  834. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  835. resultType="com.diagbot.dto.NumDTO">
  836. SELECT
  837. a.beh_dept_id as id,
  838. a.beh_dept_name as name,
  839. count(*) AS num
  840. FROM
  841. med_behospital_info a,
  842. med_qcresult_info c,
  843. med_qcresult_detail d
  844. WHERE
  845. a.behospital_code = c.behospital_code
  846. AND a.hospital_id = c.hospital_id
  847. AND a.behospital_code = d.behospital_code
  848. AND a.hospital_id = d.hospital_id
  849. AND a.is_deleted = 'N'
  850. AND c.is_deleted = 'N'
  851. AND d.is_deleted = 'N'
  852. <if test="isPlacefile != null and isPlacefile != ''">
  853. and a.is_placefile = #{isPlacefile}
  854. </if>
  855. <![CDATA[AND a.qc_type_id <>0 ]]>
  856. <if test="hospitalId != null and hospitalId != ''">
  857. AND a.hospital_id = #{hospitalId}
  858. </if>
  859. <if test="isPlacefile != null and isPlacefile == 0">
  860. <if test="startDate != null and startDate != ''">
  861. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  862. </if>
  863. <if test="endDate != null and endDate != ''">
  864. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  865. </if>
  866. </if>
  867. <if test="isPlacefile != null and isPlacefile == 1">
  868. <if test="startDate != null and startDate != ''">
  869. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  870. </if>
  871. <if test="endDate != null and endDate != ''">
  872. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  873. </if>
  874. </if>
  875. GROUP BY
  876. a.beh_dept_id,
  877. a.beh_dept_name
  878. ORDER BY
  879. count(*) DESC
  880. </select>
  881. <!-- 质控结果缺陷总数查询-->
  882. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  883. SELECT
  884. count(*) AS totle
  885. FROM
  886. med_behospital_info a,
  887. med_qcresult_info c,
  888. med_qcresult_detail d
  889. WHERE
  890. a.behospital_code = c.behospital_code
  891. AND a.hospital_id = c.hospital_id
  892. AND a.behospital_code = d.behospital_code
  893. AND a.hospital_id = d.hospital_id
  894. AND a.is_deleted = 'N'
  895. AND c.is_deleted = 'N'
  896. AND d.is_deleted = 'N'
  897. <if test="isPlacefile != null and isPlacefile != ''">
  898. and a.is_placefile = #{isPlacefile}
  899. </if>
  900. <![CDATA[AND a.qc_type_id <>0 ]]>
  901. <if test="hospitalId != null and hospitalId != ''">
  902. AND a.hospital_id = #{hospitalId}
  903. </if>
  904. <if test="isPlacefile != null and isPlacefile == 0">
  905. <if test="startDate != null and startDate != ''">
  906. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  907. </if>
  908. <if test="endDate != null and endDate != ''">
  909. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  910. </if>
  911. </if>
  912. <if test="isPlacefile != null and isPlacefile == 1">
  913. <if test="startDate != null and startDate != ''">
  914. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  915. </if>
  916. <if test="endDate != null and endDate != ''">
  917. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  918. </if>
  919. </if>
  920. </select>
  921. <!--获取病历-->
  922. <select id="getNoGrade" resultMap="BaseResultMap">
  923. select * from med_behospital_info a
  924. where a.is_deleted = 'N'
  925. and a.qc_type_id != 0
  926. <if test="isPlacefile != null and isPlacefile != ''">
  927. and a.is_placefile = #{isPlacefile}
  928. </if>
  929. <if test="filterFlag != null and filterFlag == 0">
  930. and
  931. not EXISTS (
  932. SELECT
  933. 1
  934. FROM
  935. med_qcresult_info b
  936. WHERE
  937. b.is_deleted = 'N'
  938. AND a.hospital_id = b.hospital_id
  939. AND a.behospital_code = b.behospital_code
  940. )
  941. </if>
  942. <if test="leaveDate != null">
  943. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  944. </if>
  945. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  946. and a.hospital_id in
  947. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  948. #{item}
  949. </foreach>
  950. </if>
  951. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  952. and a.behospital_code in
  953. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  954. #{item}
  955. </foreach>
  956. </if>
  957. <if test="individuation != null and individuation.contains(1)">
  958. union
  959. select * from med_behospital_info b
  960. where b.is_deleted = 'N'
  961. and b.qc_type_id != 0
  962. <if test="isPlacefile != null and isPlacefile != ''">
  963. and b.is_placefile = #{isPlacefile}
  964. </if>
  965. <if test="startLeaveDate != null">
  966. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  967. </if>
  968. <if test="endLeaveDate != null">
  969. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  970. </if>
  971. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  972. and b.hospital_id in
  973. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  974. #{item}
  975. </foreach>
  976. </if>
  977. </if>
  978. </select>
  979. <!--质控评分(科室)分页-->
  980. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  981. SELECT * from (
  982. SELECT
  983. t.*,
  984. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  985. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  986. g.check_type as ch_type,
  987. h.check_type AS mr_type,
  988. g.check_name as ch_name,
  989. h.check_name as mr_name,
  990. g.check_time as ch_time,
  991. h.check_time AS mr_time
  992. FROM
  993. ( SELECT
  994. a.*,
  995. IFNULL(b.level, '未评分') AS `level`,
  996. b.grade_type,
  997. b.score_res,
  998. e.score_res as score_bn,
  999. b.gmt_create AS grade_time,
  1000. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1001. FROM
  1002. med_behospital_info a
  1003. JOIN sys_user_dept d
  1004. ON a.hospital_id = d.hospital_id
  1005. AND a.beh_dept_id = d.dept_id
  1006. LEFT JOIN med_qcresult_info b
  1007. ON a.behospital_code = b.behospital_code
  1008. AND b.is_deleted = 'N'
  1009. LEFT JOIN med_qcresult_cases e
  1010. on a.behospital_code = e.behospital_code
  1011. AND e.is_deleted = 'N'
  1012. and e.cases_id = 243
  1013. LEFT JOIN med_home_page c
  1014. ON a.behospital_code = c.behospital_code
  1015. AND c.is_deleted = 'N'
  1016. WHERE d.is_deleted = 'N'
  1017. AND d.user_id = #{userId}
  1018. ) t
  1019. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1020. ON t.behospital_code = g.behospital_code
  1021. AND t.hospital_id = g.hospital_id
  1022. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1023. ON t.behospital_code = h.behospital_code
  1024. AND t.hospital_id = h.hospital_id
  1025. where t.is_deleted = 'N'
  1026. <if test="diagnose != null and diagnose != ''">
  1027. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1028. </if>
  1029. <if test="deptName != null and deptName != ''">
  1030. and t.beh_dept_name = #{deptName}
  1031. </if>
  1032. <if test="doctorName != null and doctorName != ''">
  1033. and CONCAT(
  1034. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  1035. like CONCAT('%',#{doctorName},'%')
  1036. </if>
  1037. <if test="doctorCode != null and doctorCode != ''">
  1038. and (t.doctor_id = #{doctorCode}
  1039. or t.beh_doctor_id = #{doctorCode}
  1040. or t.director_doctor_id = #{doctorCode})
  1041. </if>
  1042. <if test="name != null and name != ''">
  1043. and t.name like CONCAT('%',#{name},'%')
  1044. </if>
  1045. <if test="fileCode != null and fileCode != ''">
  1046. and t.file_code like CONCAT('%',#{fileCode},'%')
  1047. </if>
  1048. <if test="hospitalId != null">
  1049. and t.hospital_id = #{hospitalId}
  1050. </if>
  1051. <if test="behospitalCode != null and behospitalCode != ''">
  1052. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1053. </if>
  1054. <if test="behosDateStart != null">
  1055. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1056. </if>
  1057. <if test="behosDateEnd != null">
  1058. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1059. </if>
  1060. <if test="leaveHosDateStart != null">
  1061. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1062. </if>
  1063. <if test="leaveHosDateEnd != null">
  1064. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1065. </if>
  1066. <if test="level != null and level != ''">
  1067. and t.level = #{level}
  1068. </if>
  1069. <if test="isPlacefile != null and isPlacefile != ''">
  1070. and t.is_placefile = #{isPlacefile}
  1071. </if>
  1072. and t.qc_type_id != 0) p
  1073. where p.is_deleted="N"
  1074. <if test="checkStatus != null ">
  1075. and p.check_status = #{checkStatus}
  1076. </if>
  1077. <if test="mrStatus != null ">
  1078. AND p.mr_status = #{mrStatus}
  1079. </if>
  1080. <if test="chName != null and chName !=''">
  1081. AND p.ch_name like CONCAT('%',#{chName},'%')
  1082. </if>
  1083. <if test="mrName != null and mrName !=''">
  1084. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1085. </if>
  1086. <if test="chTimeStart != null">
  1087. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1088. </if>
  1089. <if test="chTimeEnd != null">
  1090. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1091. </if>
  1092. <if test="mrTimeStart != null">
  1093. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1094. </if>
  1095. <if test="mrTimeEnd != null">
  1096. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1097. </if>
  1098. </select>
  1099. <!--质控评分(个人)分页-->
  1100. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1101. Select * from (
  1102. select t.*,
  1103. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1104. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1105. g.check_type as ch_type,
  1106. h.check_type AS mr_type,
  1107. g.check_name as ch_name,
  1108. h.check_name as mr_name,
  1109. g.check_time as ch_time,
  1110. h.check_time AS mr_time
  1111. from (SELECT
  1112. a.*,
  1113. IFNULL(b.level, '未评分') AS `level`,
  1114. b.grade_type,
  1115. b.score_res,
  1116. e.score_res as score_bn,
  1117. b.gmt_create AS grade_time,
  1118. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1119. FROM
  1120. med_behospital_info a
  1121. JOIN
  1122. (SELECT
  1123. u.id,
  1124. u.linkman AS linkman,
  1125. uh.hospital_id
  1126. FROM
  1127. sys_user u
  1128. JOIN sys_user_hospital uh
  1129. ON u.id = uh.user_id
  1130. WHERE u.is_deleted = "N"
  1131. AND u.id = #{userId}
  1132. AND uh.hospital_id = #{hospitalId}) u1
  1133. ON a.hospital_id = u1.hospital_id
  1134. LEFT JOIN med_qcresult_info b
  1135. ON a.behospital_code = b.behospital_code
  1136. AND b.is_deleted = 'N'
  1137. LEFT JOIN med_qcresult_cases e
  1138. on a.behospital_code = e.behospital_code
  1139. AND e.is_deleted = 'N'
  1140. and e.cases_id = 243
  1141. LEFT JOIN med_home_page c
  1142. ON a.behospital_code = c.behospital_code
  1143. AND c.is_deleted = 'N'
  1144. WHERE
  1145. a.is_deleted = 'N'
  1146. and a.doctor_name = u1.linkman
  1147. or a.beh_doctor_name = u1.linkman
  1148. or a.director_doctor_name = u1.linkman
  1149. ) t
  1150. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1151. ON t.behospital_code = g.behospital_code
  1152. AND t.hospital_id = g.hospital_id
  1153. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1154. ON t.behospital_code = h.behospital_code
  1155. AND t.hospital_id = h.hospital_id
  1156. WHERE t.is_deleted = 'N'
  1157. <if test="diagnose != null and diagnose != ''">
  1158. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1159. </if>
  1160. <if test="deptName != null and deptName != ''">
  1161. and t.beh_dept_name = #{deptName}
  1162. </if>
  1163. <if test="name != null and name != ''">
  1164. and t.name like CONCAT('%',#{name},'%')
  1165. </if>
  1166. <if test="fileCode != null and fileCode != ''">
  1167. and t.file_code like CONCAT('%',#{fileCode},'%')
  1168. </if>
  1169. <if test="behospitalCode != null and behospitalCode != ''">
  1170. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1171. </if>
  1172. <if test="behosDateStart != null">
  1173. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1174. </if>
  1175. <if test="behosDateEnd != null">
  1176. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1177. </if>
  1178. <if test="leaveHosDateStart != null">
  1179. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1180. </if>
  1181. <if test="leaveHosDateEnd != null">
  1182. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1183. </if>
  1184. <if test="level != null and level != ''">
  1185. and t.level = #{level}
  1186. </if>
  1187. <if test="isPlacefile != null and isPlacefile != ''">
  1188. and t.is_placefile = #{isPlacefile}
  1189. </if>
  1190. and t.qc_type_id != 0) p
  1191. where p.is_deleted="N"
  1192. <if test="checkStatus != null ">
  1193. and p.check_status = #{checkStatus}
  1194. </if>
  1195. <if test="mrStatus != null ">
  1196. AND p.mr_status = #{mrStatus}
  1197. </if>
  1198. <if test="chName != null and chName !=''">
  1199. AND p.ch_name like CONCAT('%',#{chName},'%')
  1200. </if>
  1201. <if test="mrName != null and mrName !=''">
  1202. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1203. </if>
  1204. <if test="chTimeStart != null">
  1205. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1206. </if>
  1207. <if test="chTimeEnd != null">
  1208. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1209. </if>
  1210. <if test="mrTimeStart != null">
  1211. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1212. </if>
  1213. <if test="mrTimeEnd != null">
  1214. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1215. </if>
  1216. </select>
  1217. <!--质控评分(医疗组)分页-->
  1218. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1219. select * from (
  1220. select t.*,
  1221. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1222. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1223. g.check_type as ch_type,
  1224. h.check_type AS mr_type,
  1225. g.check_name as ch_name,
  1226. h.check_name as mr_name,
  1227. g.check_time as ch_time,
  1228. h.check_time AS mr_time
  1229. from (
  1230. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  1231. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  1232. LEFT JOIN med_qcresult_info b
  1233. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  1234. LEFT JOIN med_qcresult_cases e
  1235. on a.behospital_code = e.behospital_code
  1236. AND e.is_deleted = 'N'
  1237. and e.cases_id = 243
  1238. left join med_home_page c
  1239. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  1240. ) t
  1241. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1242. ON t.behospital_code = g.behospital_code
  1243. AND t.hospital_id = g.hospital_id
  1244. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1245. ON t.behospital_code = h.behospital_code
  1246. AND t.hospital_id = h.hospital_id
  1247. WHERE t.is_deleted = 'N'
  1248. and
  1249. t.doctor_id in (
  1250. SELECT doctor_id FROM `bas_doctor_info`
  1251. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  1252. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  1253. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  1254. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  1255. and c1.username = c3.doctor_id
  1256. and c2.hospital_id = #{hospitalId}
  1257. and c1.id = #{userId}
  1258. )
  1259. )
  1260. <if test="diagnose != null and diagnose != ''">
  1261. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1262. </if>
  1263. <if test="doctorName != null and doctorName != ''">
  1264. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  1265. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  1266. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  1267. </if>
  1268. <if test="name != null and name != ''">
  1269. and t.name like CONCAT('%',#{name},'%')
  1270. </if>
  1271. <if test="doctorCode != null and doctorCode != ''">
  1272. and (t.doctor_id = #{doctorCode}
  1273. or t.beh_doctor_id = #{doctorCode}
  1274. or t.director_doctor_id = #{doctorCode})
  1275. </if>
  1276. <if test="fileCode != null and fileCode != ''">
  1277. and t.file_code like CONCAT('%',#{fileCode},'%')
  1278. </if>
  1279. <if test="hospitalId != null">
  1280. and t.hospital_id = #{hospitalId}
  1281. </if>
  1282. <if test="behospitalCode != null and behospitalCode != ''">
  1283. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1284. </if>
  1285. <if test="behosDateStart != null">
  1286. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1287. </if>
  1288. <if test="behosDateEnd != null">
  1289. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1290. </if>
  1291. <if test="leaveHosDateStart != null">
  1292. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1293. </if>
  1294. <if test="leaveHosDateEnd != null">
  1295. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1296. </if>
  1297. <if test="level != null and level != ''">
  1298. and t.level = #{level}
  1299. </if>
  1300. <if test="isPlacefile != null and isPlacefile != ''">
  1301. and t.is_placefile = #{isPlacefile}
  1302. </if>
  1303. and t.qc_type_id != 0) p
  1304. where p.is_deleted="N"
  1305. <if test="checkStatus != null ">
  1306. and p.check_status = #{checkStatus}
  1307. </if>
  1308. <if test="mrStatus != null ">
  1309. AND p.mr_status = #{mrStatus}
  1310. </if>
  1311. <if test="chName != null and chName !=''">
  1312. AND p.ch_name like CONCAT('%',#{chName},'%')
  1313. </if>
  1314. <if test="mrName != null and mrName !=''">
  1315. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1316. </if>
  1317. <if test="chTimeStart != null">
  1318. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1319. </if>
  1320. <if test="chTimeEnd != null">
  1321. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1322. </if>
  1323. <if test="mrTimeStart != null">
  1324. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1325. </if>
  1326. <if test="mrTimeEnd != null">
  1327. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1328. </if>
  1329. </select>
  1330. <!-- 出院总人数统计-全院-首页 -->
  1331. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1332. SELECT
  1333. COUNT(*)
  1334. FROM
  1335. med_behospital_info a
  1336. WHERE
  1337. a.is_deleted = 'N'
  1338. <if test="isPlacefile != null and isPlacefile != ''">
  1339. and a.is_placefile = #{isPlacefile}
  1340. </if>
  1341. <if test="hospitalId != null and hospitalId != ''">
  1342. AND a.hospital_id = #{hospitalId}
  1343. </if>
  1344. <if test="isPlacefile != null and isPlacefile == 0">
  1345. <if test="startDate != null and startDate != ''">
  1346. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1347. </if>
  1348. <if test="endDate != null and endDate != ''">
  1349. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1350. </if>
  1351. </if>
  1352. <if test="isPlacefile != null and isPlacefile == 1">
  1353. <if test="startDate != null and startDate != ''">
  1354. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1355. </if>
  1356. <if test="endDate != null and endDate != ''">
  1357. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1358. </if>
  1359. </if>
  1360. </select>
  1361. <!-- 新生儿出院人数统计-全院-首页 -->
  1362. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1363. SELECT
  1364. COUNT(*)
  1365. FROM
  1366. med_behospital_info a,
  1367. med_home_page b
  1368. WHERE
  1369. a.is_deleted = 'N'
  1370. AND b.is_deleted = 'N'
  1371. AND a.hospital_id = b.hospital_id
  1372. AND a.behospital_code = b.behospital_code
  1373. <if test="isPlacefile != null and isPlacefile != ''">
  1374. and a.is_placefile = #{isPlacefile}
  1375. </if>
  1376. AND (
  1377. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  1378. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1379. )
  1380. <![CDATA[AND a.qc_type_id <>0 ]]>
  1381. <if test="hospitalId != null and hospitalId != ''">
  1382. AND a.hospital_id = #{hospitalId}
  1383. </if>
  1384. <if test="isPlacefile != null and isPlacefile == 0">
  1385. <if test="startDate != null and startDate != ''">
  1386. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1387. </if>
  1388. <if test="endDate != null and endDate != ''">
  1389. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1390. </if>
  1391. </if>
  1392. <if test="isPlacefile != null and isPlacefile == 1">
  1393. <if test="startDate != null and startDate != ''">
  1394. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1395. </if>
  1396. <if test="endDate != null and endDate != ''">
  1397. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1398. </if>
  1399. </if>
  1400. </select>
  1401. <!-- 死亡人数统计-全院-首页 -->
  1402. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1403. select COUNT(*) from(
  1404. SELECT distinct a.*
  1405. FROM
  1406. med_behospital_info a,
  1407. med_medical_record b,
  1408. med_medical_record_content c
  1409. WHERE
  1410. a.is_deleted = 'N'
  1411. AND b.is_deleted = 'N'
  1412. AND c.is_deleted = 'N'
  1413. AND a.hospital_id = b.hospital_id
  1414. AND a.hospital_id = c.hospital_id
  1415. AND a.behospital_code = b.behospital_code
  1416. AND b.rec_id = c.rec_id
  1417. and b.mode_id = '24'
  1418. <if test="isPlacefile != null and isPlacefile != ''">
  1419. and a.is_placefile = #{isPlacefile}
  1420. </if>
  1421. <![CDATA[AND a.qc_type_id <>0 ]]>
  1422. <if test="hospitalId != null and hospitalId != ''">
  1423. AND a.hospital_id = #{hospitalId}
  1424. </if>
  1425. <if test="isPlacefile != null and isPlacefile == 0">
  1426. <if test="startDate != null and startDate != ''">
  1427. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1428. </if>
  1429. <if test="endDate != null and endDate != ''">
  1430. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1431. </if>
  1432. </if>
  1433. <if test="isPlacefile != null and isPlacefile == 1">
  1434. <if test="startDate != null and startDate != ''">
  1435. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1436. </if>
  1437. <if test="endDate != null and endDate != ''">
  1438. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1439. </if>
  1440. </if>)m
  1441. </select>
  1442. <!-- 手术人数统计-全院-首页 -->
  1443. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1444. SELECT
  1445. COUNT( DISTINCT a.behospital_code )
  1446. FROM
  1447. med_behospital_info a,
  1448. med_medical_record c,
  1449. qc_mode d
  1450. WHERE
  1451. a.is_deleted = 'N'
  1452. AND c.is_deleted = 'N'
  1453. AND d.is_deleted = 'N'
  1454. AND a.hospital_id = c.hospital_id
  1455. AND a.behospital_code = c.behospital_code
  1456. AND c.mode_id = d.id
  1457. <if test="isPlacefile != null and isPlacefile != ''">
  1458. and a.is_placefile = #{isPlacefile}
  1459. </if>
  1460. AND d.`name` = '手术记录'
  1461. <![CDATA[AND a.qc_type_id <>0 ]]>
  1462. <if test="hospitalId != null and hospitalId != ''">
  1463. AND a.hospital_id = #{hospitalId}
  1464. </if>
  1465. <if test="isPlacefile != null and isPlacefile == 0">
  1466. <if test="startDate != null and startDate != ''">
  1467. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1468. </if>
  1469. <if test="endDate != null and endDate != ''">
  1470. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1471. </if>
  1472. </if>
  1473. <if test="isPlacefile != null and isPlacefile == 1">
  1474. <if test="startDate != null and startDate != ''">
  1475. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1476. </if>
  1477. <if test="endDate != null and endDate != ''">
  1478. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1479. </if>
  1480. </if>
  1481. </select>
  1482. <!-- 入院人数统计-首页 -->
  1483. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  1484. resultType="com.diagbot.dto.NumDTO">
  1485. SELECT
  1486. a.beh_dept_id AS id,
  1487. a.beh_dept_name AS NAME,
  1488. COUNT(*) AS num
  1489. FROM
  1490. med_behospital_info a
  1491. WHERE
  1492. a.is_deleted = 'N'
  1493. <if test="isPlacefile != null and isPlacefile != ''">
  1494. and a.is_placefile = #{isPlacefile}
  1495. </if>
  1496. <if test="hospitalId != null and hospitalId != ''">
  1497. AND a.hospital_id = #{hospitalId}
  1498. </if>
  1499. <if test="isPlacefile != null and isPlacefile == 0">
  1500. <if test="startDate != null and startDate != ''">
  1501. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1502. </if>
  1503. <if test="endDate != null and endDate != ''">
  1504. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1505. </if>
  1506. </if>
  1507. <if test="isPlacefile != null and isPlacefile == 1">
  1508. <if test="startDate != null and startDate != ''">
  1509. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1510. </if>
  1511. <if test="endDate != null and endDate != ''">
  1512. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1513. </if>
  1514. </if>
  1515. GROUP BY
  1516. a.beh_dept_id,
  1517. a.beh_dept_name
  1518. </select>
  1519. <!-- 出院总人数统计-科室-首页 -->
  1520. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1521. resultType="com.diagbot.dto.NumDTO">
  1522. SELECT
  1523. a.beh_dept_id AS id,
  1524. a.beh_dept_name AS NAME,
  1525. COUNT(*) AS num
  1526. FROM
  1527. med_behospital_info a,
  1528. sys_user_dept c
  1529. WHERE
  1530. a.is_deleted = 'N'
  1531. AND c.is_deleted = 'N'
  1532. AND a.hospital_id = c.hospital_id
  1533. AND a.beh_dept_id = c.dept_id
  1534. <if test="isPlacefile != null and isPlacefile != ''">
  1535. and a.is_placefile = #{isPlacefile}
  1536. </if>
  1537. <if test="userId!=null">
  1538. AND c.user_id = #{userId}
  1539. </if>
  1540. <if test="hospitalId != null and hospitalId != ''">
  1541. AND a.hospital_id = #{hospitalId}
  1542. </if>
  1543. <if test="isPlacefile != null and isPlacefile == 0">
  1544. <if test="startDate != null and startDate != ''">
  1545. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1546. </if>
  1547. <if test="endDate != null and endDate != ''">
  1548. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1549. </if>
  1550. </if>
  1551. <if test="isPlacefile != null and isPlacefile == 1">
  1552. <if test="startDate != null and startDate != ''">
  1553. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1554. </if>
  1555. <if test="endDate != null and endDate != ''">
  1556. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1557. </if>
  1558. </if>
  1559. GROUP BY
  1560. a.beh_dept_id,
  1561. a.beh_dept_name
  1562. </select>
  1563. <!-- 入院总人数统计-科室-首页 -->
  1564. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1565. resultType="com.diagbot.dto.AdmissionCountDTO">
  1566. SELECT
  1567. a.beh_dept_id as deptId,
  1568. a.beh_dept_name as deptName,
  1569. a.doctor_id as doctorId,
  1570. a.doctor_name as doctorName,
  1571. COUNT(*) AS num
  1572. FROM
  1573. med_behospital_info a,
  1574. sys_user_dept c
  1575. WHERE
  1576. a.is_deleted = 'N'
  1577. AND c.is_deleted = 'N'
  1578. AND a.hospital_id = c.hospital_id
  1579. AND a.beh_dept_id = c.dept_id
  1580. <if test="isPlacefile != null and isPlacefile != ''">
  1581. and a.is_placefile = #{isPlacefile}
  1582. </if>
  1583. <if test="userId!=null">
  1584. AND c.user_id = #{userId}
  1585. </if>
  1586. <if test="hospitalId != null and hospitalId != ''">
  1587. AND a.hospital_id = #{hospitalId}
  1588. </if>
  1589. <if test="isPlacefile != null and isPlacefile == 0">
  1590. <if test="startDate != null and startDate != ''">
  1591. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1592. </if>
  1593. <if test="endDate != null and endDate != ''">
  1594. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1595. </if>
  1596. </if>
  1597. <if test="isPlacefile != null and isPlacefile == 1">
  1598. <if test="startDate != null and startDate != ''">
  1599. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1600. </if>
  1601. <if test="endDate != null and endDate != ''">
  1602. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1603. </if>
  1604. </if>
  1605. GROUP BY
  1606. a.beh_dept_id,
  1607. a.beh_dept_name,
  1608. a.doctor_id,
  1609. a.doctor_name
  1610. </select>
  1611. <!-- 新生儿出院人数统计-科室-首页 -->
  1612. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1613. resultType="com.diagbot.dto.NumDTO">
  1614. SELECT
  1615. a.beh_dept_id AS id,
  1616. a.beh_dept_name AS NAME,
  1617. COUNT(*) AS num
  1618. FROM
  1619. med_behospital_info a,
  1620. med_home_page b,
  1621. sys_user_dept c
  1622. WHERE
  1623. a.is_deleted = 'N'
  1624. AND b.is_deleted = 'N'
  1625. AND c.is_deleted = 'N'
  1626. AND a.hospital_id = b.hospital_id
  1627. AND a.hospital_id = c.hospital_id
  1628. AND a.behospital_code = b.behospital_code
  1629. AND a.beh_dept_id = c.dept_id
  1630. AND (
  1631. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  1632. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1633. )
  1634. <if test="isPlacefile != null and isPlacefile != ''">
  1635. and a.is_placefile = #{isPlacefile}
  1636. </if>
  1637. <![CDATA[AND a.qc_type_id <>0 ]]>
  1638. <if test="userId!=null">
  1639. AND c.user_id = #{userId}
  1640. </if>
  1641. <if test="hospitalId != null and hospitalId != ''">
  1642. AND a.hospital_id = #{hospitalId}
  1643. </if>
  1644. <if test="isPlacefile != null and isPlacefile == 0">
  1645. <if test="startDate != null and startDate != ''">
  1646. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1647. </if>
  1648. <if test="endDate != null and endDate != ''">
  1649. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1650. </if>
  1651. </if>
  1652. <if test="isPlacefile != null and isPlacefile == 1">
  1653. <if test="startDate != null and startDate != ''">
  1654. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1655. </if>
  1656. <if test="endDate != null and endDate != ''">
  1657. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1658. </if>
  1659. </if>
  1660. GROUP BY
  1661. a.beh_dept_id,
  1662. a.beh_dept_name
  1663. </select>
  1664. <!-- 死亡人数统计-科室-首页 -->
  1665. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1666. resultType="com.diagbot.dto.NumDTO">
  1667. SELECT
  1668. a.beh_dept_id AS id,
  1669. a.beh_dept_name AS NAME,
  1670. COUNT(*) AS num
  1671. FROM
  1672. med_behospital_info a,
  1673. sys_user_dept c,
  1674. med_medical_record d,
  1675. med_medical_record_content e
  1676. WHERE
  1677. a.is_deleted = 'N'
  1678. AND c.is_deleted = 'N'
  1679. AND d.is_deleted = 'N'
  1680. AND e.is_deleted = 'N'
  1681. AND a.hospital_id = c.hospital_id
  1682. AND a.hospital_id = d.hospital_id
  1683. AND a.hospital_id = e.hospital_id
  1684. AND a.behospital_code = d.behospital_code
  1685. AND a.beh_dept_id = c.dept_id
  1686. AND d.rec_id = e.rec_id
  1687. AND d.mode_id = '24'
  1688. <if test="isPlacefile != null and isPlacefile != ''">
  1689. and a.is_placefile = #{isPlacefile}
  1690. </if>
  1691. <![CDATA[AND a.qc_type_id <>0 ]]>
  1692. <if test="userId!=null">
  1693. AND c.user_id = #{userId}
  1694. </if>
  1695. <if test="hospitalId != null and hospitalId != ''">
  1696. AND a.hospital_id = #{hospitalId}
  1697. </if>
  1698. <if test="isPlacefile != null and isPlacefile == 0">
  1699. <if test="startDate != null and startDate != ''">
  1700. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1701. </if>
  1702. <if test="endDate != null and endDate != ''">
  1703. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1704. </if>
  1705. </if>
  1706. <if test="isPlacefile != null and isPlacefile == 1">
  1707. <if test="startDate != null and startDate != ''">
  1708. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1709. </if>
  1710. <if test="endDate != null and endDate != ''">
  1711. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1712. </if>
  1713. </if>
  1714. GROUP BY
  1715. a.beh_dept_id,
  1716. a.beh_dept_name
  1717. </select>
  1718. <!-- 手术人数统计-科室-首页 -->
  1719. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1720. resultType="com.diagbot.dto.NumDTO">
  1721. SELECT
  1722. a.beh_dept_id AS id,
  1723. a.beh_dept_name AS NAME,
  1724. COUNT( DISTINCT a.behospital_code ) AS num
  1725. FROM
  1726. med_behospital_info a,
  1727. sys_user_dept c,
  1728. med_medical_record d,
  1729. qc_mode e
  1730. WHERE
  1731. a.is_deleted = 'N'
  1732. AND c.is_deleted = 'N'
  1733. AND d.is_deleted = 'N'
  1734. AND e.is_deleted = 'N'
  1735. AND a.hospital_id = c.hospital_id
  1736. AND a.hospital_id = d.hospital_id
  1737. AND a.behospital_code = d.behospital_code
  1738. AND a.beh_dept_id = c.dept_id
  1739. AND d.mode_id = e.id
  1740. AND e.`name` = '手术记录'
  1741. <if test="isPlacefile != null and isPlacefile != ''">
  1742. and a.is_placefile = #{isPlacefile}
  1743. </if>
  1744. <![CDATA[AND a.qc_type_id <>0 ]]>
  1745. <if test="userId!=null">
  1746. AND c.user_id = #{userId}
  1747. </if>
  1748. <if test="hospitalId != null and hospitalId != ''">
  1749. AND a.hospital_id = #{hospitalId}
  1750. </if>
  1751. <if test="isPlacefile != null and isPlacefile == 0">
  1752. <if test="startDate != null and startDate != ''">
  1753. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1754. </if>
  1755. <if test="endDate != null and endDate != ''">
  1756. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1757. </if>
  1758. </if>
  1759. <if test="isPlacefile != null and isPlacefile == 1">
  1760. <if test="startDate != null and startDate != ''">
  1761. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1762. </if>
  1763. <if test="endDate != null and endDate != ''">
  1764. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1765. </if>
  1766. </if>
  1767. GROUP BY
  1768. a.beh_dept_id,
  1769. a.beh_dept_name
  1770. </select>
  1771. <!-- 各科室缺陷占比排行(分页) -->
  1772. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1773. SELECT t.*
  1774. FROM
  1775. (SELECT
  1776. t1.beh_dept_name AS NAME,
  1777. t1.num AS num,
  1778. t2.totle AS totleNum,
  1779. round( t1.num / t2.totle, 4 ) AS percent,
  1780. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1781. FROM
  1782. (
  1783. SELECT
  1784. a.beh_dept_id,
  1785. a.beh_dept_name,
  1786. count(*) AS num
  1787. FROM
  1788. med_behospital_info a,
  1789. med_qcresult_info c,
  1790. med_qcresult_detail d
  1791. WHERE
  1792. a.behospital_code = c.behospital_code
  1793. AND a.hospital_id = c.hospital_id
  1794. AND a.behospital_code = d.behospital_code
  1795. AND a.hospital_id = d.hospital_id
  1796. AND a.is_deleted = 'N'
  1797. AND c.is_deleted = 'N'
  1798. AND d.is_deleted = 'N'
  1799. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1800. and a.is_placefile = #{filterPageVO.isPlacefile}
  1801. </if>
  1802. <![CDATA[AND a.qc_type_id <>0 ]]>
  1803. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1804. AND a.hospital_id = #{filterPageVO.hospitalId}
  1805. </if>
  1806. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1807. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1808. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1809. </if>
  1810. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1811. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1812. </if>
  1813. </if>
  1814. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1815. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1816. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1817. </if>
  1818. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1819. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1820. </if>
  1821. </if>
  1822. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1823. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1824. </if>
  1825. GROUP BY
  1826. a.beh_dept_id,
  1827. a.beh_dept_name
  1828. ORDER BY
  1829. count(*) DESC
  1830. ) t1,
  1831. (
  1832. SELECT
  1833. count(*) AS totle
  1834. FROM
  1835. med_behospital_info a,
  1836. med_qcresult_info c,
  1837. med_qcresult_detail d
  1838. WHERE
  1839. a.behospital_code = c.behospital_code
  1840. AND a.hospital_id = c.hospital_id
  1841. AND a.behospital_code = d.behospital_code
  1842. AND a.hospital_id = d.hospital_id
  1843. AND a.is_deleted = 'N'
  1844. AND c.is_deleted = 'N'
  1845. AND d.is_deleted = 'N'
  1846. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1847. and a.is_placefile = #{filterPageVO.isPlacefile}
  1848. </if>
  1849. <![CDATA[AND a.qc_type_id <>0 ]]>
  1850. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1851. AND a.hospital_id = #{filterPageVO.hospitalId}
  1852. </if>
  1853. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1854. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1855. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1856. </if>
  1857. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1858. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1859. </if>
  1860. </if>
  1861. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1862. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1863. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1864. </if>
  1865. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1866. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1867. </if>
  1868. </if>
  1869. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1870. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1871. </if>
  1872. ) t2
  1873. )t
  1874. </select>
  1875. <!-- 科室缺陷占比(主任医生) -->
  1876. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  1877. SELECT
  1878. t.*
  1879. FROM
  1880. (
  1881. SELECT
  1882. t1.NAME,
  1883. t1.num AS num,
  1884. t2.totle AS totleNum,
  1885. round( t1.num / t2.totle, 4 ) AS percent,
  1886. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1887. FROM
  1888. (
  1889. SELECT
  1890. d.msg as name,
  1891. count(*) AS num
  1892. FROM
  1893. med_behospital_info a,
  1894. med_qcresult_info c,
  1895. med_qcresult_detail d,
  1896. sys_user_dept e
  1897. WHERE
  1898. a.behospital_code = c.behospital_code
  1899. AND a.hospital_id = c.hospital_id
  1900. AND a.behospital_code = d.behospital_code
  1901. AND a.hospital_id = d.hospital_id
  1902. AND a.is_deleted = 'N'
  1903. AND c.is_deleted = 'N'
  1904. AND d.is_deleted = 'N'
  1905. AND e.is_deleted = 'N'
  1906. AND a.beh_dept_id = e.dept_id
  1907. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1908. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1909. </if>
  1910. <![CDATA[AND a.qc_type_id <>0 ]]>
  1911. <if test="filterPageByDeptVO.userId!=null">
  1912. AND e.user_id = #{filterPageByDeptVO.userId}
  1913. </if>
  1914. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1915. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1916. </if>
  1917. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1918. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1919. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1920. </if>
  1921. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1922. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1923. </if>
  1924. </if>
  1925. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1926. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1927. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1928. </if>
  1929. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1930. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1931. </if>
  1932. </if>
  1933. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1934. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1935. </if>
  1936. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1937. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1938. </if>
  1939. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1940. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1941. </if>
  1942. GROUP BY
  1943. d.msg
  1944. ORDER BY
  1945. count(*) DESC
  1946. ) t1,
  1947. (
  1948. SELECT
  1949. count(*) AS totle
  1950. FROM
  1951. med_behospital_info a,
  1952. med_qcresult_info c,
  1953. med_qcresult_detail d,
  1954. sys_user_dept e
  1955. WHERE
  1956. a.behospital_code = c.behospital_code
  1957. AND a.hospital_id = c.hospital_id
  1958. AND a.behospital_code = d.behospital_code
  1959. AND a.hospital_id = d.hospital_id
  1960. AND a.is_deleted = 'N'
  1961. AND c.is_deleted = 'N'
  1962. AND d.is_deleted = 'N'
  1963. AND e.is_deleted = 'N'
  1964. AND a.beh_dept_id = e.dept_id
  1965. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1966. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1967. </if>
  1968. <![CDATA[AND a.qc_type_id <>0 ]]>
  1969. <if test="filterPageByDeptVO.userId!=null">
  1970. AND e.user_id = #{filterPageByDeptVO.userId}
  1971. </if>
  1972. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1973. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1974. </if>
  1975. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1976. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1977. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1978. </if>
  1979. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1980. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1981. </if>
  1982. </if>
  1983. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1984. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1985. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1986. </if>
  1987. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1988. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1989. </if>
  1990. </if>
  1991. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1992. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1993. </if>
  1994. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1995. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1996. </if>
  1997. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1998. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1999. </if>
  2000. ) t2
  2001. )t
  2002. </select>
  2003. <!-- 各科室缺陷占比(组合)-全院 -->
  2004. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2005. resultType="com.diagbot.dto.LevelStatisticsDTO">
  2006. SELECT
  2007. m1.deptId,
  2008. m1.deptName,
  2009. m1.entryNum,
  2010. m2.sameNum,
  2011. m1.mrNum,
  2012. m2.sameMrNum,
  2013. m1.totleValue,
  2014. m2.sameTotleValue,
  2015. m1.averageValue,
  2016. m2.sameAvgValue,
  2017. m1.firstLevelNum,
  2018. m2.sameFirstLevelNum,
  2019. m1.secondLevelNum,
  2020. m2.sameSecondLevelNum,
  2021. m1.thirdLevelNum,
  2022. m2.sameThirdLevelNum,
  2023. m1.firstLevelPercent,
  2024. m2.sameFirstLevelPercent,
  2025. m1.secondLevelPercent,
  2026. m2.sameSecondLevelPercent,
  2027. m1.thirdLevelPercent,
  2028. m2.sameThirdLevelPercent,
  2029. m1.firstLevelPercentStr,
  2030. m2.sameFirstLevelPercentStr,
  2031. m1.secondLevelPercentStr,
  2032. m2.sameSecondLevelPercentStr,
  2033. m1.thirdLevelPercentStr,
  2034. m2.sameThirdLevelPercentStr
  2035. FROM
  2036. (
  2037. SELECT
  2038. t1.deptId,
  2039. t1.deptName,
  2040. t2.entryNum,
  2041. t1.mrNum,
  2042. t1.totleValue,
  2043. t1.averageValue,
  2044. t1.firstLevelNum,
  2045. t1.secondLevelNum,
  2046. t1.thirdLevelNum,
  2047. t1.firstLevelPercent,
  2048. t1.secondLevelPercent,
  2049. t1.thirdLevelPercent,
  2050. t1.firstLevelPercentStr,
  2051. t1.secondLevelPercentStr,
  2052. t1.thirdLevelPercentStr
  2053. FROM
  2054. (
  2055. SELECT
  2056. a.beh_dept_id AS deptId,
  2057. a.beh_dept_name AS deptName,
  2058. count(*) AS mrNum,
  2059. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2060. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2061. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2062. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2063. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2064. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2065. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2066. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2067. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2068. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2069. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2070. FROM
  2071. med_behospital_info a,
  2072. med_qcresult_info c
  2073. WHERE
  2074. a.is_deleted = 'N'
  2075. AND c.is_deleted = 'N'
  2076. AND a.hospital_id = c.hospital_id
  2077. AND a.behospital_code = c.behospital_code
  2078. <if test="isPlacefile != null and isPlacefile != ''">
  2079. and a.is_placefile = #{isPlacefile}
  2080. </if>
  2081. AND a.qc_type_id != 0
  2082. <if test="hospitalId != null and hospitalId != ''">
  2083. AND a.hospital_id = #{hospitalId}
  2084. </if>
  2085. <if test="isPlacefile != null and isPlacefile == 0">
  2086. <if test="startDate != null and startDate != ''">
  2087. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2088. </if>
  2089. <if test="endDate != null and endDate != ''">
  2090. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2091. </if>
  2092. </if>
  2093. <if test="isPlacefile != null and isPlacefile == 1">
  2094. <if test="startDate != null and startDate != ''">
  2095. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2096. </if>
  2097. <if test="endDate != null and endDate != ''">
  2098. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2099. </if>
  2100. </if>
  2101. <if test="level != null and level != ''">
  2102. and c.level = #{level}
  2103. </if>
  2104. <if test="deptName != null and deptName != ''">
  2105. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2106. </if>
  2107. GROUP BY
  2108. a.beh_dept_id,
  2109. a.beh_dept_name
  2110. ) t1,
  2111. (
  2112. SELECT
  2113. a.beh_dept_id AS deptId,
  2114. a.beh_dept_name AS deptName,
  2115. count( * ) AS entryNum
  2116. FROM
  2117. med_behospital_info a,
  2118. med_qcresult_info c,
  2119. med_qcresult_detail d,
  2120. qc_cases_entry e
  2121. WHERE
  2122. a.is_deleted = 'N'
  2123. AND c.is_deleted = 'N'
  2124. AND d.is_deleted = 'N'
  2125. AND e.is_deleted = 'N'
  2126. AND a.hospital_id = c.hospital_id
  2127. AND a.hospital_id = d.hospital_id
  2128. AND a.behospital_code = c.behospital_code
  2129. AND a.behospital_code = d.behospital_code
  2130. AND d.cases_id = e.cases_id
  2131. AND d.cases_entry_id = e.id
  2132. <if test="isPlacefile != null and isPlacefile != ''">
  2133. and a.is_placefile = #{isPlacefile}
  2134. </if>
  2135. AND a.qc_type_id != 0
  2136. <if test="hospitalId != null and hospitalId != ''">
  2137. AND a.hospital_id = #{hospitalId}
  2138. </if>
  2139. <if test="isPlacefile != null and isPlacefile == 0">
  2140. <if test="startDate != null and startDate != ''">
  2141. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2142. </if>
  2143. <if test="endDate != null and endDate != ''">
  2144. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2145. </if>
  2146. </if>
  2147. <if test="isPlacefile != null and isPlacefile == 1">
  2148. <if test="startDate != null and startDate != ''">
  2149. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2150. </if>
  2151. <if test="endDate != null and endDate != ''">
  2152. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2153. </if>
  2154. </if>
  2155. <if test="level != null and level != ''">
  2156. and c.level = #{level}
  2157. </if>
  2158. <if test="deptName != null and deptName != ''">
  2159. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2160. </if>
  2161. GROUP BY
  2162. a.beh_dept_id,
  2163. a.beh_dept_name
  2164. ) t2
  2165. WHERE
  2166. t1.deptId = t2.deptId
  2167. AND t1.deptName = t2.deptName)m1 left join
  2168. ( SELECT
  2169. t1.deptId,
  2170. t1.deptName,
  2171. t2.entryNum as sameNum,
  2172. t1.mrNum as sameMrNum,
  2173. t1.totleValue as sameTotleValue,
  2174. t1.averageValue as sameAvgValue,
  2175. t1.firstLevelNum as sameFirstLevelNum,
  2176. t1.secondLevelNum as sameSecondLevelNum,
  2177. t1.thirdLevelNum as sameThirdLevelNum,
  2178. t1.firstLevelPercent as sameFirstLevelPercent,
  2179. t1.secondLevelPercent as sameSecondLevelPercent,
  2180. t1.thirdLevelPercent as sameThirdLevelPercent,
  2181. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2182. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2183. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2184. FROM
  2185. (
  2186. SELECT
  2187. a.beh_dept_id AS deptId,
  2188. a.beh_dept_name AS deptName,
  2189. count(*) AS mrNum,
  2190. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2191. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2192. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2193. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2194. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2195. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2196. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2197. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2198. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2199. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2200. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2201. FROM
  2202. med_behospital_info a,
  2203. med_qcresult_info c
  2204. WHERE
  2205. a.is_deleted = 'N'
  2206. AND c.is_deleted = 'N'
  2207. AND a.hospital_id = c.hospital_id
  2208. AND a.behospital_code = c.behospital_code
  2209. <if test="isPlacefile != null and isPlacefile != ''">
  2210. and a.is_placefile = #{isPlacefile}
  2211. </if>
  2212. AND a.qc_type_id != 0
  2213. <if test="hospitalId != null and hospitalId != ''">
  2214. AND a.hospital_id = #{hospitalId}
  2215. </if>
  2216. <if test="isPlacefile != null and isPlacefile == 0">
  2217. <if test="lastStartDate != null and lastStartDate != ''">
  2218. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2219. </if>
  2220. <if test="lastEndDate != null and lastEndDate != ''">
  2221. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2222. </if>
  2223. </if>
  2224. <if test="isPlacefile != null and isPlacefile == 1">
  2225. <if test="lastStartDate != null and lastStartDate != ''">
  2226. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2227. </if>
  2228. <if test="lastEndDate != null and lastEndDate != ''">
  2229. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2230. </if>
  2231. </if>
  2232. <if test="level != null and level != ''">
  2233. and c.level = #{level}
  2234. </if>
  2235. <if test="deptName != null and deptName != ''">
  2236. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2237. </if>
  2238. GROUP BY
  2239. a.beh_dept_id,
  2240. a.beh_dept_name
  2241. ) t1,
  2242. (
  2243. SELECT
  2244. a.beh_dept_id AS deptId,
  2245. a.beh_dept_name AS deptName,
  2246. count( * ) AS entryNum
  2247. FROM
  2248. med_behospital_info a,
  2249. med_qcresult_info c,
  2250. med_qcresult_detail d,
  2251. qc_cases_entry e
  2252. WHERE
  2253. a.is_deleted = 'N'
  2254. AND c.is_deleted = 'N'
  2255. AND d.is_deleted = 'N'
  2256. AND e.is_deleted = 'N'
  2257. AND a.hospital_id = c.hospital_id
  2258. AND a.hospital_id = d.hospital_id
  2259. AND a.behospital_code = c.behospital_code
  2260. AND a.behospital_code = d.behospital_code
  2261. AND d.cases_id = e.cases_id
  2262. AND d.cases_entry_id = e.id
  2263. <if test="isPlacefile != null and isPlacefile != ''">
  2264. and a.is_placefile = #{isPlacefile}
  2265. </if>
  2266. AND a.qc_type_id != 0
  2267. <if test="hospitalId != null and hospitalId != ''">
  2268. AND a.hospital_id = #{hospitalId}
  2269. </if>
  2270. <if test="isPlacefile != null and isPlacefile == 0">
  2271. <if test="lastStartDate != null and lastStartDate != ''">
  2272. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2273. </if>
  2274. <if test="lastEndDate != null and lastEndDate != ''">
  2275. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2276. </if>
  2277. </if>
  2278. <if test="isPlacefile != null and isPlacefile == 1">
  2279. <if test="lastStartDate != null and lastStartDate != ''">
  2280. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2281. </if>
  2282. <if test="lastEndDate != null and lastEndDate != ''">
  2283. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2284. </if>
  2285. </if>
  2286. <if test="level != null and level != ''">
  2287. and c.level = #{level}
  2288. </if>
  2289. <if test="deptName != null and deptName != ''">
  2290. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2291. </if>
  2292. GROUP BY
  2293. a.beh_dept_id,
  2294. a.beh_dept_name
  2295. ) t2
  2296. WHERE
  2297. t1.deptId = t2.deptId
  2298. AND t1.deptName = t2.deptName)m2
  2299. on
  2300. m1.deptId = m2.deptId
  2301. AND m1.deptName = m2.deptName
  2302. <if test="asc != null and asc !=''">
  2303. order by
  2304. <choose>
  2305. <when test='asc=="deptId"'>m1.deptId asc</when>
  2306. <when test='asc=="deptName"'>m1.deptName asc</when>
  2307. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2308. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2309. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2310. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2311. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2312. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2313. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2314. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2315. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2316. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2317. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2318. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2319. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2320. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2321. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2322. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2323. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2324. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2325. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2326. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2327. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2328. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2329. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2330. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2331. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2332. <otherwise>deptName asc</otherwise>
  2333. </choose>
  2334. </if>
  2335. <if test="desc != null and desc!=''">
  2336. order by
  2337. <choose>
  2338. <when test='desc=="deptId"'>m1.deptId desc</when>
  2339. <when test='desc=="deptName"'>m1.deptName desc</when>
  2340. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2341. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2342. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2343. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2344. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2345. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2346. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2347. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2348. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2349. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2350. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2351. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2352. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2353. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2354. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2355. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2356. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2357. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2358. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2359. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2360. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2361. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2362. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2363. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2364. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2365. <otherwise>deptName desc</otherwise>
  2366. </choose>
  2367. </if>
  2368. </select>
  2369. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  2370. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  2371. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2372. SELECT
  2373. t1.deptId,
  2374. t1.deptName,
  2375. t1.deptClassId,
  2376. t1.deptClass,
  2377. t2.entryNum,
  2378. t1.mrNum,
  2379. t1.totleValue,
  2380. t1.averageValue,
  2381. t1.firstLevelNum,
  2382. t1.secondLevelNum,
  2383. t1.thirdLevelNum,
  2384. t1.firstLevelPercent,
  2385. t1.secondLevelPercent,
  2386. t1.thirdLevelPercent,
  2387. t1.firstLevelPercentStr,
  2388. t1.secondLevelPercentStr,
  2389. t1.thirdLevelPercentStr
  2390. FROM
  2391. (
  2392. SELECT
  2393. a.beh_dept_id AS deptId,
  2394. a.beh_dept_name AS deptName,
  2395. e.dept_id AS deptClassId,
  2396. e.dept_name AS deptClass,
  2397. count( DISTINCT c.id ) AS mrNum,
  2398. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2399. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  2400. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  2401. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  2402. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  2403. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  2404. ) AS firstLevelPercent,
  2405. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2406. ) AS secondLevelPercent,
  2407. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2408. ) AS thirdLevelPercent,
  2409. concat(
  2410. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  2411. 100, 2 ),
  2412. '%'
  2413. ) AS firstLevelPercentStr,
  2414. concat(
  2415. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  2416. 100, 2 ),
  2417. '%'
  2418. ) AS secondLevelPercentStr,
  2419. concat(
  2420. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  2421. 100, 2 ),
  2422. '%'
  2423. ) AS thirdLevelPercentStr
  2424. FROM
  2425. med_behospital_info a,
  2426. med_qcresult_info c,
  2427. bas_dept_info d,
  2428. bas_dept_info e
  2429. WHERE
  2430. a.is_deleted = 'N'
  2431. AND c.is_deleted = 'N'
  2432. AND d.is_deleted = 'N'
  2433. AND e.is_deleted = 'N'
  2434. AND a.hospital_id = c.hospital_id
  2435. AND a.hospital_id = d.hospital_id
  2436. AND a.hospital_id = e.hospital_id
  2437. AND a.behospital_code = c.behospital_code
  2438. AND a.beh_dept_id = d.dept_id
  2439. AND d.parent_dept_id = e.dept_id
  2440. <if test="isPlacefile != null and isPlacefile != ''">
  2441. and a.is_placefile = #{isPlacefile}
  2442. </if>
  2443. <![CDATA[AND a.qc_type_id <>0 ]]>
  2444. <if test="hospitalId != null and hospitalId != ''">
  2445. AND a.hospital_id = #{hospitalId}
  2446. </if>
  2447. <if test="isPlacefile != null and isPlacefile == 0">
  2448. <if test="startDate != null and startDate != ''">
  2449. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2450. </if>
  2451. <if test="endDate != null and endDate != ''">
  2452. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2453. </if>
  2454. </if>
  2455. <if test="isPlacefile != null and isPlacefile == 1">
  2456. <if test="startDate != null and startDate != ''">
  2457. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2458. </if>
  2459. <if test="endDate != null and endDate != ''">
  2460. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2461. </if>
  2462. </if>
  2463. <if test="level != null and level != ''">
  2464. and c.level = #{level}
  2465. </if>
  2466. <if test="deptName != null and deptName != ''">
  2467. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2468. </if>
  2469. <if test="deptClass != null and deptClass != ''">
  2470. and e.dept_name = #{deptClass}
  2471. </if>
  2472. GROUP BY
  2473. a.beh_dept_id,
  2474. a.beh_dept_name,
  2475. e.dept_id,
  2476. e.dept_name
  2477. ) t1,
  2478. (
  2479. SELECT
  2480. a.beh_dept_id AS deptId,
  2481. a.beh_dept_name AS deptName,
  2482. g.dept_id AS deptClassId,
  2483. g.dept_name AS deptClass,
  2484. count( * ) AS entryNum
  2485. FROM
  2486. med_behospital_info a,
  2487. med_qcresult_info c,
  2488. med_qcresult_detail d,
  2489. qc_cases_entry e,
  2490. bas_dept_info f,
  2491. bas_dept_info g
  2492. WHERE
  2493. a.is_deleted = 'N'
  2494. AND c.is_deleted = 'N'
  2495. AND d.is_deleted = 'N'
  2496. AND e.is_deleted = 'N'
  2497. AND f.is_deleted = 'N'
  2498. AND g.is_deleted = 'N'
  2499. AND a.hospital_id = c.hospital_id
  2500. AND a.hospital_id = d.hospital_id
  2501. AND a.hospital_id = f.hospital_id
  2502. AND a.hospital_id = g.hospital_id
  2503. AND a.behospital_code = c.behospital_code
  2504. AND a.behospital_code = d.behospital_code
  2505. AND d.cases_id = e.cases_id
  2506. AND d.cases_entry_id = e.id
  2507. AND a.beh_dept_id = f.dept_id
  2508. AND f.parent_dept_id = g.dept_id
  2509. <if test="isPlacefile != null and isPlacefile != ''">
  2510. and a.is_placefile = #{isPlacefile}
  2511. </if>
  2512. <![CDATA[AND a.qc_type_id <>0 ]]>
  2513. <if test="hospitalId != null and hospitalId != ''">
  2514. AND a.hospital_id = #{hospitalId}
  2515. </if>
  2516. <if test="isPlacefile != null and isPlacefile == 0">
  2517. <if test="startDate != null and startDate != ''">
  2518. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2519. </if>
  2520. <if test="endDate != null and endDate != ''">
  2521. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2522. </if>
  2523. </if>
  2524. <if test="isPlacefile != null and isPlacefile == 1">
  2525. <if test="startDate != null and startDate != ''">
  2526. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2527. </if>
  2528. <if test="endDate != null and endDate != ''">
  2529. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2530. </if>
  2531. </if>
  2532. <if test="level != null and level != ''">
  2533. and c.level = #{level}
  2534. </if>
  2535. <if test="deptName != null and deptName != ''">
  2536. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2537. </if>
  2538. <if test="deptClass != null and deptClass != ''">
  2539. and g.dept_name = #{deptClass}
  2540. </if>
  2541. GROUP BY
  2542. a.beh_dept_id,
  2543. a.beh_dept_name,
  2544. g.dept_id,
  2545. g.dept_name
  2546. ) t2
  2547. WHERE
  2548. t1.deptId = t2.deptId
  2549. AND t1.deptName = t2.deptName
  2550. AND t1.deptClassId = t2.deptClassId
  2551. AND t1.deptClass = t2.deptClass
  2552. <if test="asc != null and asc !=''">
  2553. order by
  2554. <choose>
  2555. <when test='asc=="deptId"'>deptId asc</when>
  2556. <when test='asc=="deptName"'>deptName asc</when>
  2557. <when test='asc=="deptClassId"'>deptClassId asc</when>
  2558. <when test='asc=="deptClass"'>deptClass asc</when>
  2559. <when test='asc=="entryNum"'>entryNum asc</when>
  2560. <when test='asc=="mrNum"'>mrNum asc</when>
  2561. <when test='asc=="totleValue"'>totleValue asc</when>
  2562. <when test='asc=="averageValue"'>averageValue asc</when>
  2563. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2564. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2565. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2566. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2567. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2568. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2569. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2570. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2571. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2572. <otherwise>deptName asc</otherwise>
  2573. </choose>
  2574. </if>
  2575. <if test="desc != null and desc!=''">
  2576. order by
  2577. <choose>
  2578. <when test='desc=="deptId"'>deptId desc</when>
  2579. <when test='desc=="deptName"'>deptName desc</when>
  2580. <when test='desc=="deptClassId"'>deptClassId desc</when>
  2581. <when test='desc=="deptClass"'>deptClass desc</when>
  2582. <when test='desc=="entryNum"'>entryNum desc</when>
  2583. <when test='desc=="mrNum"'>mrNum desc</when>
  2584. <when test='desc=="totleValue"'>totleValue desc</when>
  2585. <when test='desc=="averageValue"'>averageValue desc</when>
  2586. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2587. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2588. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2589. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2590. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2591. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2592. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2593. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2594. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2595. <otherwise>deptName desc</otherwise>
  2596. </choose>
  2597. </if>
  2598. </select>
  2599. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  2600. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2601. select
  2602. m1.deptId,
  2603. m1.deptName,
  2604. m1.deptClassId,
  2605. m1.deptClass,
  2606. m1.entryNum,
  2607. m2.sameNum,
  2608. m1.mrNum,
  2609. m2.sameMrNum,
  2610. m1.totleValue,
  2611. m2.sameTotleValue,
  2612. m1.averageValue,
  2613. m2.sameAvgValue,
  2614. m1.firstLevelNum,
  2615. m2.sameFirstLevelNum,
  2616. m1.secondLevelNum,
  2617. m2.sameSecondLevelNum,
  2618. m1.thirdLevelNum,
  2619. m2.sameThirdLevelNum,
  2620. m1.firstLevelPercent,
  2621. m2.sameFirstLevelPercent,
  2622. m1.secondLevelPercent,
  2623. m2.sameSecondLevelPercent,
  2624. m1.thirdLevelPercent,
  2625. m2.sameThirdLevelPercent,
  2626. m1.firstLevelPercentStr,
  2627. m2.sameFirstLevelPercentStr,
  2628. m1.secondLevelPercentStr,
  2629. m2.sameSecondLevelPercentStr,
  2630. m1.thirdLevelPercentStr,
  2631. m2.sameThirdLevelPercentStr
  2632. from (
  2633. SELECT
  2634. t1.deptId,
  2635. t1.deptName,
  2636. t1.deptClassId,
  2637. t1.deptClass,
  2638. t2.entryNum,
  2639. t1.mrNum,
  2640. t1.totleValue,
  2641. t1.averageValue,
  2642. t1.firstLevelNum,
  2643. t1.secondLevelNum,
  2644. t1.thirdLevelNum,
  2645. t1.firstLevelPercent,
  2646. t1.secondLevelPercent,
  2647. t1.thirdLevelPercent,
  2648. t1.firstLevelPercentStr,
  2649. t1.secondLevelPercentStr,
  2650. t1.thirdLevelPercentStr
  2651. FROM
  2652. (
  2653. SELECT
  2654. tt1.deptId,
  2655. tt1.deptName,
  2656. e.dept_id AS deptClassId,
  2657. e.dept_name AS deptClass,
  2658. count(*) AS mrNum,
  2659. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2660. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2661. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2662. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2663. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2664. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2665. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2666. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2667. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2668. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2669. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2670. FROM
  2671. (
  2672. SELECT
  2673. a.beh_dept_id AS deptId,
  2674. a.beh_dept_name AS deptName,
  2675. d.parent_dept_id AS parentDeptId,
  2676. a.hospital_id AS hospitalId,
  2677. a.behospital_code AS behospitalCode,
  2678. c.score_res AS score,
  2679. c.LEVEL
  2680. FROM
  2681. med_behospital_info a,
  2682. med_qcresult_info c,
  2683. bas_dept_info d
  2684. WHERE
  2685. a.is_deleted = 'N'
  2686. AND c.is_deleted = 'N'
  2687. AND d.is_deleted = 'N'
  2688. AND a.hospital_id = c.hospital_id
  2689. AND a.hospital_id = d.hospital_id
  2690. AND a.behospital_code = c.behospital_code
  2691. AND a.beh_dept_id = d.dept_id
  2692. <if test="isPlacefile != null and isPlacefile != ''">
  2693. and a.is_placefile = #{isPlacefile}
  2694. </if>
  2695. AND a.qc_type_id != 0
  2696. <if test="hospitalId != null and hospitalId != ''">
  2697. AND a.hospital_id = #{hospitalId}
  2698. </if>
  2699. <if test="isPlacefile != null and isPlacefile == 0">
  2700. <if test="startDate != null and startDate != ''">
  2701. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2702. </if>
  2703. <if test="endDate != null and endDate != ''">
  2704. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2705. </if>
  2706. </if>
  2707. <if test="isPlacefile != null and isPlacefile == 1">
  2708. <if test="startDate != null and startDate != ''">
  2709. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2710. </if>
  2711. <if test="endDate != null and endDate != ''">
  2712. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2713. </if>
  2714. </if>
  2715. <if test="level != null and level != ''">
  2716. and c.level = #{level}
  2717. </if>
  2718. <if test="deptName != null and deptName != ''">
  2719. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2720. </if>
  2721. ) tt1
  2722. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2723. AND e.is_deleted = 'N'
  2724. AND tt1.hospitalId = e.hospital_id
  2725. <if test="deptClass != null and deptClass != ''">
  2726. WHERE e.dept_name = #{deptClass}
  2727. </if>
  2728. GROUP BY
  2729. tt1.deptId,
  2730. tt1.deptName,
  2731. e.dept_id,
  2732. e.dept_name
  2733. ) t1,
  2734. (
  2735. SELECT
  2736. tt2.deptId,
  2737. tt2.deptName,
  2738. g.dept_id AS deptClassId,
  2739. g.dept_name AS deptClass,
  2740. count( * ) AS entryNum
  2741. FROM
  2742. (
  2743. SELECT
  2744. a.beh_dept_id AS deptId,
  2745. a.beh_dept_name AS deptName,
  2746. f.parent_dept_id AS parentDeptId,
  2747. a.hospital_id AS hospitalId,
  2748. a.behospital_code AS behospitalCode
  2749. FROM
  2750. med_behospital_info a,
  2751. med_qcresult_info c,
  2752. med_qcresult_detail d,
  2753. qc_cases_entry e,
  2754. bas_dept_info f
  2755. WHERE
  2756. a.is_deleted = 'N'
  2757. AND c.is_deleted = 'N'
  2758. AND d.is_deleted = 'N'
  2759. AND e.is_deleted = 'N'
  2760. AND f.is_deleted = 'N'
  2761. AND a.hospital_id = c.hospital_id
  2762. AND a.hospital_id = d.hospital_id
  2763. AND a.hospital_id = f.hospital_id
  2764. AND a.behospital_code = c.behospital_code
  2765. AND a.behospital_code = d.behospital_code
  2766. AND d.cases_id = e.cases_id
  2767. AND d.cases_entry_id = e.id
  2768. AND a.beh_dept_id = f.dept_id
  2769. <if test="isPlacefile != null and isPlacefile != ''">
  2770. and a.is_placefile = #{isPlacefile}
  2771. </if>
  2772. AND a.qc_type_id != 0
  2773. <if test="hospitalId != null and hospitalId != ''">
  2774. AND a.hospital_id = #{hospitalId}
  2775. </if>
  2776. <if test="isPlacefile != null and isPlacefile == 0">
  2777. <if test="startDate != null and startDate != ''">
  2778. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2779. </if>
  2780. <if test="endDate != null and endDate != ''">
  2781. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2782. </if>
  2783. </if>
  2784. <if test="isPlacefile != null and isPlacefile == 1">
  2785. <if test="startDate != null and startDate != ''">
  2786. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2787. </if>
  2788. <if test="endDate != null and endDate != ''">
  2789. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2790. </if>
  2791. </if>
  2792. <if test="level != null and level != ''">
  2793. and c.level = #{level}
  2794. </if>
  2795. <if test="deptName != null and deptName != ''">
  2796. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2797. </if>
  2798. ) tt2
  2799. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2800. AND g.is_deleted = 'N'
  2801. AND tt2.hospitalId = g.hospital_id
  2802. <if test="deptClass != null and deptClass != ''">
  2803. WHERE g.dept_name = #{deptClass}
  2804. </if>
  2805. GROUP BY
  2806. tt2.deptId,
  2807. tt2.deptName,
  2808. g.dept_id,
  2809. g.dept_name
  2810. ) t2
  2811. WHERE
  2812. t1.deptId = t2.deptId
  2813. AND t1.deptName = t2.deptName)m1 left join
  2814. ( SELECT
  2815. t1.deptId,
  2816. t1.deptName,
  2817. t1.deptClassId,
  2818. t1.deptClass,
  2819. t2.entryNum as sameNum,
  2820. t1.mrNum as sameMrNum,
  2821. t1.totleValue as sameTotleValue,
  2822. t1.averageValue as sameAvgValue,
  2823. t1.firstLevelNum as sameFirstLevelNum,
  2824. t1.secondLevelNum as sameSecondLevelNum,
  2825. t1.thirdLevelNum as sameThirdLevelNum,
  2826. t1.firstLevelPercent as sameFirstLevelPercent,
  2827. t1.secondLevelPercent as sameSecondLevelPercent,
  2828. t1.thirdLevelPercent as sameThirdLevelPercent,
  2829. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2830. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2831. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2832. FROM
  2833. (
  2834. SELECT
  2835. tt1.deptId,
  2836. tt1.deptName,
  2837. e.dept_id AS deptClassId,
  2838. e.dept_name AS deptClass,
  2839. count(*) AS mrNum,
  2840. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2841. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2842. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2843. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2844. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2845. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2846. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2847. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2848. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2849. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2850. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2851. FROM
  2852. (
  2853. SELECT
  2854. a.beh_dept_id AS deptId,
  2855. a.beh_dept_name AS deptName,
  2856. d.parent_dept_id AS parentDeptId,
  2857. a.hospital_id AS hospitalId,
  2858. a.behospital_code AS behospitalCode,
  2859. c.score_res AS score,
  2860. c.LEVEL
  2861. FROM
  2862. med_behospital_info a,
  2863. med_qcresult_info c,
  2864. bas_dept_info d
  2865. WHERE
  2866. a.is_deleted = 'N'
  2867. AND c.is_deleted = 'N'
  2868. AND d.is_deleted = 'N'
  2869. AND a.hospital_id = c.hospital_id
  2870. AND a.hospital_id = d.hospital_id
  2871. AND a.behospital_code = c.behospital_code
  2872. AND a.beh_dept_id = d.dept_id
  2873. <if test="isPlacefile != null and isPlacefile != ''">
  2874. and a.is_placefile = #{isPlacefile}
  2875. </if>
  2876. AND a.qc_type_id != 0
  2877. <if test="hospitalId != null and hospitalId != ''">
  2878. AND a.hospital_id = #{hospitalId}
  2879. </if>
  2880. <if test="isPlacefile != null and isPlacefile == 0">
  2881. <if test="lastStartDate != null and lastStartDate != ''">
  2882. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2883. </if>
  2884. <if test="lastEndDate != null and lastEndDate != ''">
  2885. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2886. </if>
  2887. </if>
  2888. <if test="isPlacefile != null and isPlacefile == 1">
  2889. <if test="lastStartDate != null and lastStartDate != ''">
  2890. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2891. </if>
  2892. <if test="lastEndDate != null and lastEndDate != ''">
  2893. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2894. </if>
  2895. </if>
  2896. <if test="level != null and level != ''">
  2897. and c.level = #{level}
  2898. </if>
  2899. <if test="deptName != null and deptName != ''">
  2900. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2901. </if>
  2902. ) tt1
  2903. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2904. AND e.is_deleted = 'N'
  2905. AND tt1.hospitalId = e.hospital_id
  2906. <if test="deptClass != null and deptClass != ''">
  2907. WHERE e.dept_name = #{deptClass}
  2908. </if>
  2909. GROUP BY
  2910. tt1.deptId,
  2911. tt1.deptName,
  2912. e.dept_id,
  2913. e.dept_name
  2914. ) t1,
  2915. (
  2916. SELECT
  2917. tt2.deptId,
  2918. tt2.deptName,
  2919. g.dept_id AS deptClassId,
  2920. g.dept_name AS deptClass,
  2921. count( * ) AS entryNum
  2922. FROM
  2923. (
  2924. SELECT
  2925. a.beh_dept_id AS deptId,
  2926. a.beh_dept_name AS deptName,
  2927. f.parent_dept_id AS parentDeptId,
  2928. a.hospital_id AS hospitalId,
  2929. a.behospital_code AS behospitalCode
  2930. FROM
  2931. med_behospital_info a,
  2932. med_qcresult_info c,
  2933. med_qcresult_detail d,
  2934. qc_cases_entry e,
  2935. bas_dept_info f
  2936. WHERE
  2937. a.is_deleted = 'N'
  2938. AND c.is_deleted = 'N'
  2939. AND d.is_deleted = 'N'
  2940. AND e.is_deleted = 'N'
  2941. AND f.is_deleted = 'N'
  2942. AND a.hospital_id = c.hospital_id
  2943. AND a.hospital_id = d.hospital_id
  2944. AND a.hospital_id = f.hospital_id
  2945. AND a.behospital_code = c.behospital_code
  2946. AND a.behospital_code = d.behospital_code
  2947. AND d.cases_id = e.cases_id
  2948. AND d.cases_entry_id = e.id
  2949. AND a.beh_dept_id = f.dept_id
  2950. <if test="isPlacefile != null and isPlacefile != ''">
  2951. and a.is_placefile = #{isPlacefile}
  2952. </if>
  2953. AND a.qc_type_id != 0
  2954. <if test="hospitalId != null and hospitalId != ''">
  2955. AND a.hospital_id = #{hospitalId}
  2956. </if>
  2957. <if test="isPlacefile != null and isPlacefile == 0">
  2958. <if test="lastStartDate != null and lastStartDate != ''">
  2959. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2960. </if>
  2961. <if test="lastEndDate != null and lastEndDate != ''">
  2962. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2963. </if>
  2964. </if>
  2965. <if test="isPlacefile != null and isPlacefile == 1">
  2966. <if test="lastStartDate != null and lastStartDate != ''">
  2967. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2968. </if>
  2969. <if test="lastEndDate != null and lastEndDate != ''">
  2970. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2971. </if>
  2972. </if>
  2973. <if test="level != null and level != ''">
  2974. and c.level = #{level}
  2975. </if>
  2976. <if test="deptName != null and deptName != ''">
  2977. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2978. </if>
  2979. ) tt2
  2980. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2981. AND g.is_deleted = 'N'
  2982. AND tt2.hospitalId = g.hospital_id
  2983. <if test="deptClass != null and deptClass != ''">
  2984. WHERE g.dept_name = #{deptClass}
  2985. </if>
  2986. GROUP BY
  2987. tt2.deptId,
  2988. tt2.deptName,
  2989. g.dept_id,
  2990. g.dept_name
  2991. ) t2
  2992. WHERE
  2993. t1.deptId = t2.deptId
  2994. AND t1.deptName = t2.deptName)m2
  2995. on
  2996. m1.deptId = m2.deptId
  2997. and m1.deptName = m2.deptName
  2998. <if test="asc != null and asc !=''">
  2999. order by
  3000. <choose>
  3001. <when test='asc=="deptId"'>m1.deptId asc</when>
  3002. <when test='asc=="deptName"'>m1.deptName asc</when>
  3003. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  3004. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  3005. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3006. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3007. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3008. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3009. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3010. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3011. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3012. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3013. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3014. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3015. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3016. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3017. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3018. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3019. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3020. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3021. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3022. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3023. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3024. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3025. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3026. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3027. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3028. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3029. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3030. <otherwise>deptName asc</otherwise>
  3031. </choose>
  3032. </if>
  3033. <if test="desc != null and desc!=''">
  3034. order by
  3035. <choose>
  3036. <when test='desc=="deptId"'>m1.deptId desc</when>
  3037. <when test='desc=="deptName"'>m1.deptName desc</when>
  3038. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  3039. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  3040. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3041. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3042. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3043. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3044. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3045. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3046. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3047. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3048. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3049. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3050. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3051. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3052. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3053. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3054. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3055. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3056. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3057. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3058. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3059. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3060. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3061. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3062. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3063. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3064. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3065. <otherwise>deptName desc</otherwise>
  3066. </choose>
  3067. </if>
  3068. </select>
  3069. <!-- 病案首页合格率占比 -全院-->
  3070. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  3071. resultType="com.diagbot.dto.HomePageNumDTO">
  3072. SELECT
  3073. t1.deptId,
  3074. t1.deptName,
  3075. t2.entryNum,
  3076. t1.mrNum,
  3077. t1.totleValue,
  3078. t1.averageValue,
  3079. t1.firstLevelNum,
  3080. t1.secondLevelNum,
  3081. t1.firstLevelPercent,
  3082. t1.secondLevelPercent,
  3083. t1.firstLevelPercentStr,
  3084. t1.secondLevelPercentStr,
  3085. t3.emptyNum,
  3086. t3.errorNum,
  3087. t3.entryTotleNum,
  3088. t3.emptyPercent,
  3089. t3.errorPercent,
  3090. t3.emptyPercentStr,
  3091. t3.errorPercentStr
  3092. FROM
  3093. (
  3094. SELECT
  3095. a.beh_dept_id AS deptId,
  3096. a.beh_dept_name AS deptName,
  3097. count( * ) AS mrNum,
  3098. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3099. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3100. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3101. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3102. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3103. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3104. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3105. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3106. FROM
  3107. med_behospital_info a,
  3108. med_qcresult_cases c
  3109. WHERE
  3110. a.is_deleted = 'N'
  3111. AND c.is_deleted = 'N'
  3112. AND a.hospital_id = c.hospital_id
  3113. AND a.behospital_code = c.behospital_code
  3114. AND c.cases_id = 243
  3115. <if test="isPlacefile != null and isPlacefile != ''">
  3116. and a.is_placefile = #{isPlacefile}
  3117. </if>
  3118. AND a.qc_type_id != 0
  3119. <if test="hospitalId != null and hospitalId != ''">
  3120. AND a.hospital_id = #{hospitalId}
  3121. </if>
  3122. <if test="isPlacefile != null and isPlacefile == 0">
  3123. <if test="startDate != null and startDate != ''">
  3124. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3125. </if>
  3126. <if test="endDate != null and endDate != ''">
  3127. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3128. </if>
  3129. </if>
  3130. <if test="isPlacefile != null and isPlacefile == 1">
  3131. <if test="startDate != null and startDate != ''">
  3132. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3133. </if>
  3134. <if test="endDate != null and endDate != ''">
  3135. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3136. </if>
  3137. </if>
  3138. <if test="level != null and level != ''">
  3139. and c.level = #{level}
  3140. </if>
  3141. <if test="deptName != null and deptName != ''">
  3142. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3143. </if>
  3144. GROUP BY
  3145. a.beh_dept_id,
  3146. a.beh_dept_name
  3147. ) t1,
  3148. (
  3149. SELECT
  3150. a.beh_dept_id AS deptId,
  3151. a.beh_dept_name AS deptName,
  3152. count( * ) AS entryNum
  3153. FROM
  3154. med_behospital_info a,
  3155. med_qcresult_cases c,
  3156. med_qcresult_detail d,
  3157. qc_cases_entry e
  3158. WHERE
  3159. a.is_deleted = 'N'
  3160. AND c.is_deleted = 'N'
  3161. AND d.is_deleted = 'N'
  3162. AND e.is_deleted = 'N'
  3163. AND a.hospital_id = c.hospital_id
  3164. AND a.hospital_id = d.hospital_id
  3165. AND a.behospital_code = c.behospital_code
  3166. AND a.behospital_code = d.behospital_code
  3167. AND c.cases_id = d.cases_id
  3168. AND d.cases_id = e.cases_id
  3169. AND d.cases_entry_id = e.id
  3170. AND d.cases_id = 243
  3171. <if test="isPlacefile != null and isPlacefile != ''">
  3172. and a.is_placefile = #{isPlacefile}
  3173. </if>
  3174. AND a.qc_type_id != 0
  3175. <if test="hospitalId != null and hospitalId != ''">
  3176. AND a.hospital_id = #{hospitalId}
  3177. </if>
  3178. <if test="isPlacefile != null and isPlacefile == 0">
  3179. <if test="startDate != null and startDate != ''">
  3180. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3181. </if>
  3182. <if test="endDate != null and endDate != ''">
  3183. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3184. </if>
  3185. </if>
  3186. <if test="isPlacefile != null and isPlacefile == 1">
  3187. <if test="startDate != null and startDate != ''">
  3188. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3189. </if>
  3190. <if test="endDate != null and endDate != ''">
  3191. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3192. </if>
  3193. </if>
  3194. <if test="level != null and level != ''">
  3195. and c.level = #{level}
  3196. </if>
  3197. <if test="deptName != null and deptName != ''">
  3198. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3199. </if>
  3200. GROUP BY
  3201. a.beh_dept_id,
  3202. a.beh_dept_name
  3203. ) t2,(
  3204. SELECT
  3205. h1.deptId,
  3206. h1.deptName,
  3207. h1.emptyNum,
  3208. h1.errorNum,
  3209. h1.mrNum,
  3210. h2.entryNum,
  3211. h1.mrNum * h2.entryNum AS entryTotleNum,
  3212. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3213. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3214. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3215. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3216. FROM
  3217. (
  3218. SELECT
  3219. a.beh_dept_id AS deptId,
  3220. a.beh_dept_name AS deptName,
  3221. sum( d.rule_type = 1 ) AS emptyNum,
  3222. sum( d.rule_type = 2 ) AS errorNum,
  3223. count( DISTINCT a.behospital_code ) AS mrNum
  3224. FROM
  3225. med_behospital_info a,
  3226. med_qcresult_cases b,
  3227. med_qcresult_detail c,
  3228. qc_cases_entry d
  3229. WHERE
  3230. a.is_deleted = 'N'
  3231. AND b.is_deleted = 'N'
  3232. AND c.is_deleted = 'N'
  3233. AND d.is_deleted = 'N'
  3234. AND a.hospital_id = b.hospital_id
  3235. AND a.hospital_id = c.hospital_id
  3236. AND a.behospital_code = b.behospital_code
  3237. AND a.behospital_code = c.behospital_code
  3238. AND b.cases_id = c.cases_id
  3239. AND c.cases_id = d.cases_id
  3240. AND c.cases_entry_id = d.id
  3241. <if test="isPlacefile != null and isPlacefile != ''">
  3242. and a.is_placefile = #{isPlacefile}
  3243. </if>
  3244. AND d.cases_id = 243
  3245. AND a.qc_type_id != 0
  3246. <if test="hospitalId != null and hospitalId != ''">
  3247. AND a.hospital_id = #{hospitalId}
  3248. </if>
  3249. <if test="isPlacefile != null and isPlacefile == 0">
  3250. <if test="startDate != null and startDate != ''">
  3251. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3252. </if>
  3253. <if test="endDate != null and endDate != ''">
  3254. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3255. </if>
  3256. </if>
  3257. <if test="isPlacefile != null and isPlacefile == 1">
  3258. <if test="startDate != null and startDate != ''">
  3259. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3260. </if>
  3261. <if test="endDate != null and endDate != ''">
  3262. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3263. </if>
  3264. </if>
  3265. <if test="level != null and level != ''">
  3266. and b.level = #{level}
  3267. </if>
  3268. <if test="deptName != null and deptName != ''">
  3269. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3270. </if>
  3271. GROUP BY
  3272. a.beh_dept_id,
  3273. a.beh_dept_name
  3274. ) h1,(
  3275. SELECT
  3276. count(*) AS entryNum
  3277. FROM
  3278. qc_cases_entry
  3279. WHERE
  3280. is_deleted = 'N'
  3281. AND cases_id = 243
  3282. ) h2
  3283. ) t3
  3284. WHERE
  3285. t1.deptId = t2.deptId
  3286. AND t1.deptId = t3.deptId
  3287. AND t1.deptName = t2.deptName
  3288. AND t1.deptName = t3.deptName
  3289. <if test="asc != null and asc !=''">
  3290. order by
  3291. <choose>
  3292. <when test='asc=="deptId"'>deptId asc</when>
  3293. <when test='asc=="deptName"'>deptName asc</when>
  3294. <when test='asc=="entryNum"'>entryNum asc</when>
  3295. <when test='asc=="mrNum"'>mrNum asc</when>
  3296. <when test='asc=="totleValue"'>totleValue asc</when>
  3297. <when test='asc=="averageValue"'>averageValue asc</when>
  3298. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3299. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3300. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3301. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3302. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3303. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3304. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3305. <when test='asc=="errorNum"'>errorNum asc</when>
  3306. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3307. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3308. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3309. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3310. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3311. <otherwise>deptName asc</otherwise>
  3312. </choose>
  3313. </if>
  3314. <if test="desc != null and desc!=''">
  3315. order by
  3316. <choose>
  3317. <when test='desc=="deptId"'>deptId desc</when>
  3318. <when test='desc=="deptName"'>deptName desc</when>
  3319. <when test='desc=="entryNum"'>entryNum desc</when>
  3320. <when test='desc=="mrNum"'>mrNum desc</when>
  3321. <when test='desc=="totleValue"'>totleValue desc</when>
  3322. <when test='desc=="averageValue"'>averageValue desc</when>
  3323. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3324. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3325. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3326. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3327. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3328. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3329. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3330. <when test='desc=="errorNum"'>errorNum desc</when>
  3331. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3332. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3333. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3334. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3335. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3336. <otherwise>deptName desc</otherwise>
  3337. </choose>
  3338. </if>
  3339. </select>
  3340. <!-- 医师病案首页合格率占比 湘雅定制-->
  3341. <select id="homePageLevelStatisticsXY" resultType="com.diagbot.dto.HomePageNumXYDTO">
  3342. SELECT
  3343. tt1.*,
  3344. tt2.entryNum,
  3345. tt2.emptyNum,
  3346. tt2.errorNum,
  3347. tt2.entryTotleNum,
  3348. tt2.emptyPercent,
  3349. tt2.errorPercent,
  3350. tt2.emptyPercentStr,
  3351. tt2.errorPercentStr
  3352. FROM(
  3353. select
  3354. t1.deptId,
  3355. t1.deptName,
  3356. t1.doctorName,
  3357. t1.professor,
  3358. sum(t1.mrNum) as mrNum,
  3359. sum(t1.totleValue)as totleValue,
  3360. ROUND(CAST(sum(t1.totleValue)/sum(t1.mrNum) AS DECIMAL ( 18, 2 )), 2) AS averageValue,
  3361. sum(t1.firstLevelNum)as firstLevelNum,
  3362. sum(t1.secondLevelNum)as secondLevelNum,
  3363. ROUND(sum(t1.firstLevelNum)/sum(t1.mrNum),4) as firstLevelPercent,
  3364. ROUND(sum(t1.secondLevelNum)/sum(t1.mrNum),4) as secondLevelPercent,
  3365. concat( ROUND( sum(t1.firstLevelNum)/sum(t1.mrNum)* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3366. concat( ROUND( sum(t1.secondLevelNum)/sum(t1.mrNum)* 100, 2 ),'%' ) AS secondLevelPercentStr
  3367. from
  3368. (
  3369. SELECT
  3370. a.beh_dept_id AS deptId,
  3371. a.beh_dept_name AS deptName,
  3372. case
  3373. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  3374. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3375. b.director_doctor != '' and b.director_doctor is not null
  3376. then b.director_doctor
  3377. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3378. (b.director_doctor = '' or b.director_doctor is null) and
  3379. b.behospital_doctor != '' and b.behospital_doctor is not null
  3380. then b.behospital_doctor end as doctorName,
  3381. case
  3382. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  3383. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3384. b.director_doctor != '' and b.director_doctor is not null
  3385. then '主任医师'
  3386. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3387. (b.director_doctor = '' or b.director_doctor is null) and
  3388. b.behospital_doctor != '' and b.behospital_doctor is not null
  3389. then '住院医师' end as professor,
  3390. count( * ) AS mrNum,
  3391. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3392. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3393. count(case when c.`level` = '合格' then 1 end) AS firstLevelNum,
  3394. count(case when c.`level` = '不合格' then 1 end) AS secondLevelNum
  3395. FROM
  3396. med_behospital_info a,
  3397. med_home_page b,
  3398. med_qcresult_cases c
  3399. WHERE
  3400. a.is_deleted = 'N'
  3401. AND c.is_deleted = 'N'
  3402. AND b.is_deleted = 'N'
  3403. AND a.hospital_id = b.hospital_id
  3404. AND a.hospital_id = c.hospital_id
  3405. AND a.behospital_code = b.behospital_code
  3406. AND a.behospital_code = c.behospital_code
  3407. AND c.cases_id = 243
  3408. <if test="isPlacefile != null and isPlacefile != ''">
  3409. and a.is_placefile = #{isPlacefile}
  3410. </if>
  3411. AND a.qc_type_id != 0
  3412. <if test="hospitalId != null and hospitalId != ''">
  3413. AND a.hospital_id = #{hospitalId}
  3414. </if>
  3415. <if test="isPlacefile != null and isPlacefile == 0">
  3416. <if test="startDate != null and startDate != ''">
  3417. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3418. </if>
  3419. <if test="endDate != null and endDate != ''">
  3420. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3421. </if>
  3422. </if>
  3423. <if test="isPlacefile != null and isPlacefile == 1">
  3424. <if test="startDate != null and startDate != ''">
  3425. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3426. </if>
  3427. <if test="endDate != null and endDate != ''">
  3428. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3429. </if>
  3430. </if>
  3431. <if test="deptName != null and deptName != ''">
  3432. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3433. </if>
  3434. <if test="deptId != null and deptId != ''">
  3435. and a.beh_dept_id = #{deptId}
  3436. </if>
  3437. GROUP BY
  3438. a.beh_dept_id,
  3439. a.beh_dept_name,
  3440. b.attending_doctor,
  3441. b.director_doctor,
  3442. b.behospital_doctor
  3443. ) t1
  3444. group by t1.deptId,t1.deptName,t1.doctorName,t1.professor
  3445. )tt1,
  3446. (
  3447. select
  3448. t2.deptId,
  3449. t2.deptName,
  3450. t2.doctorName,
  3451. t2.professor,
  3452. sum(t2.entryNum)as entryNum,
  3453. sum(t2.emptyNum)as emptyNum,
  3454. sum(t2.errorNum)as errorNum,
  3455. sum(t2.mrNum) * t2.entryNumSec AS entryTotleNum,
  3456. ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.emptyNum) ) / ( sum(t2.mrNum) * t2.entryNumSec ), 4 ) AS emptyPercent,
  3457. ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.errorNum) ) / ( sum(t2.mrNum) * t2.entryNumSec ), 4 ) AS errorPercent,
  3458. CONCAT( ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.emptyNum) ) / ( sum(t2.mrNum) * t2.entryNumSec )* 100, 2 ), '%' ) AS emptyPercentStr,
  3459. CONCAT( ROUND( ( sum(t2.mrNum) * t2.entryNumSec - sum(t2.errorNum) ) / ( sum(t2.mrNum) * t2.entryNumSec )* 100, 2 ), '%' ) AS errorPercentStr
  3460. from (
  3461. select m1.*,m2.entryNum as entryNumSec from (
  3462. SELECT
  3463. a.beh_dept_id AS deptId,
  3464. a.beh_dept_name AS deptName,
  3465. case
  3466. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  3467. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3468. b.director_doctor != '' and b.director_doctor is not null
  3469. then b.director_doctor
  3470. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3471. (b.director_doctor = '' or b.director_doctor is null) and
  3472. b.behospital_doctor != '' and b.behospital_doctor is not null
  3473. then b.behospital_doctor end as doctorName,
  3474. case
  3475. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  3476. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3477. b.director_doctor != '' and b.director_doctor is not null
  3478. then '主任医师'
  3479. when (b.attending_doctor = '' or b.attending_doctor is null) and
  3480. (b.director_doctor = '' or b.director_doctor is null) and
  3481. b.behospital_doctor != '' and b.behospital_doctor is not null
  3482. then '住院医师' end as professor,
  3483. count( * ) AS entryNum,
  3484. count(case when e.rule_type = 1 then 1 end) AS emptyNum,
  3485. count(case when e.rule_type = 2 then 1 end) AS errorNum,
  3486. count( DISTINCT a.behospital_code ) AS mrNum
  3487. FROM
  3488. med_behospital_info a,
  3489. med_home_page b,
  3490. med_qcresult_cases c,
  3491. med_qcresult_detail d,
  3492. qc_cases_entry e
  3493. WHERE
  3494. a.is_deleted = 'N'
  3495. AND b.is_deleted = 'N'
  3496. AND c.is_deleted = 'N'
  3497. AND d.is_deleted = 'N'
  3498. AND e.is_deleted = 'N'
  3499. AND a.hospital_id = b.hospital_id
  3500. AND a.hospital_id = c.hospital_id
  3501. AND a.hospital_id = d.hospital_id
  3502. AND a.behospital_code = b.behospital_code
  3503. AND a.behospital_code = c.behospital_code
  3504. AND a.behospital_code = d.behospital_code
  3505. AND c.cases_id = d.cases_id
  3506. AND d.cases_id = e.cases_id
  3507. AND d.cases_entry_id = e.id
  3508. AND d.cases_id = 243
  3509. <if test="isPlacefile != null and isPlacefile != ''">
  3510. and a.is_placefile = #{isPlacefile}
  3511. </if>
  3512. AND a.qc_type_id != 0
  3513. <if test="hospitalId != null and hospitalId != ''">
  3514. AND a.hospital_id = #{hospitalId}
  3515. </if>
  3516. <if test="isPlacefile != null and isPlacefile == 0">
  3517. <if test="startDate != null and startDate != ''">
  3518. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3519. </if>
  3520. <if test="endDate != null and endDate != ''">
  3521. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3522. </if>
  3523. </if>
  3524. <if test="isPlacefile != null and isPlacefile == 1">
  3525. <if test="startDate != null and startDate != ''">
  3526. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3527. </if>
  3528. <if test="endDate != null and endDate != ''">
  3529. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3530. </if>
  3531. </if>
  3532. <if test="deptName != null and deptName != ''">
  3533. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3534. </if>
  3535. <if test="deptId != null and deptId != ''">
  3536. and a.beh_dept_id = #{deptId}
  3537. </if>
  3538. GROUP BY
  3539. a.beh_dept_id,
  3540. a.beh_dept_name,
  3541. b.attending_doctor,
  3542. b.director_doctor,
  3543. b.behospital_doctor
  3544. )m1,(
  3545. SELECT
  3546. count(*) AS entryNum
  3547. FROM
  3548. qc_cases_entry
  3549. WHERE
  3550. is_deleted = 'N'
  3551. AND cases_id = 243
  3552. )m2) t2
  3553. group by t2.deptId,t2.deptName,t2.doctorName,t2.professor
  3554. ) tt2
  3555. WHERE
  3556. tt1.deptId = tt2.deptId
  3557. AND tt1.deptName = tt2.deptName
  3558. AND tt1.doctorName= tt2.doctorName
  3559. AND tt1.professor = tt2.professor
  3560. AND tt1.professor != ''
  3561. and tt1.professor is not null
  3562. <if test="doctorName != null and doctorName != ''">
  3563. and tt1.doctorName like CONCAT('%',#{doctorName},'%')
  3564. </if>
  3565. <if test="professor != null and professor != ''">
  3566. and tt1.professor = #{professor}
  3567. </if>
  3568. </select>
  3569. <!-- 各科室缺陷占比-科室 -->
  3570. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3571. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3572. SELECT
  3573. m1.doctorId,
  3574. m1.doctorName,
  3575. m1.entryNum,
  3576. m2.sameNum,
  3577. m1.mrNum,
  3578. m2.sameMrNum,
  3579. m1.totleValue,
  3580. m2.sameTotleValue,
  3581. m1.averageValue,
  3582. m2.sameAvgValue,
  3583. m1.firstLevelNum,
  3584. m2.sameFirstLevelNum,
  3585. m1.secondLevelNum,
  3586. m2.sameSecondLevelNum,
  3587. m1.thirdLevelNum,
  3588. m2.sameThirdLevelNum,
  3589. m1.firstLevelPercent,
  3590. m2.sameFirstLevelPercent,
  3591. m1.secondLevelPercent,
  3592. m2.sameSecondLevelPercent,
  3593. m1.thirdLevelPercent,
  3594. m2.sameThirdLevelPercent,
  3595. m1.firstLevelPercentStr,
  3596. m2.sameFirstLevelPercentStr,
  3597. m1.secondLevelPercentStr,
  3598. m2.sameSecondLevelPercentStr,
  3599. m1.thirdLevelPercentStr,
  3600. m2.sameThirdLevelPercentStr
  3601. FROM
  3602. (
  3603. SELECT
  3604. t1.doctorId,
  3605. t1.doctorName,
  3606. t2.entryNum,
  3607. t1.mrNum,
  3608. t1.totleValue,
  3609. t1.averageValue,
  3610. t1.firstLevelNum,
  3611. t1.secondLevelNum,
  3612. t1.thirdLevelNum,
  3613. t1.firstLevelPercent,
  3614. t1.secondLevelPercent,
  3615. t1.thirdLevelPercent,
  3616. t1.firstLevelPercentStr,
  3617. t1.secondLevelPercentStr,
  3618. t1.thirdLevelPercentStr
  3619. FROM
  3620. (
  3621. SELECT
  3622. a.doctor_id AS doctorId,
  3623. a.doctor_name AS doctorName,
  3624. count(*) AS mrNum,
  3625. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3626. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3627. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3628. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3629. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3630. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3631. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3632. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3633. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3634. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3635. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3636. FROM
  3637. med_behospital_info a,
  3638. med_qcresult_info c,
  3639. sys_user_dept e
  3640. WHERE
  3641. a.is_deleted = 'N'
  3642. AND c.is_deleted = 'N'
  3643. AND e.is_deleted = 'N'
  3644. AND a.hospital_id = c.hospital_id
  3645. AND a.behospital_code = c.behospital_code
  3646. AND a.beh_dept_id = e.dept_id
  3647. <if test="isPlacefile != null and isPlacefile != ''">
  3648. and a.is_placefile = #{isPlacefile}
  3649. </if>
  3650. AND a.qc_type_id != 0
  3651. <if test="hospitalId != null and hospitalId != ''">
  3652. AND a.hospital_id = #{hospitalId}
  3653. </if>
  3654. <if test="isPlacefile != null and isPlacefile == 0">
  3655. <if test="startDate != null and startDate != ''">
  3656. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3657. </if>
  3658. <if test="endDate != null and endDate != ''">
  3659. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3660. </if>
  3661. </if>
  3662. <if test="isPlacefile != null and isPlacefile == 1">
  3663. <if test="startDate != null and startDate != ''">
  3664. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3665. </if>
  3666. <if test="endDate != null and endDate != ''">
  3667. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3668. </if>
  3669. </if>
  3670. <if test="level != null and level != ''">
  3671. and c.level = #{level}
  3672. </if>
  3673. <if test="doctorName != null and doctorName != ''">
  3674. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3675. </if>
  3676. <if test="userId!=null and userId !=''">
  3677. AND e.user_id = #{userId}
  3678. </if>
  3679. <if test="deptName != null and deptName != ''">
  3680. and a.beh_dept_name = #{deptName}
  3681. </if>
  3682. GROUP BY
  3683. a.doctor_id,
  3684. a.doctor_name
  3685. ) t1,
  3686. (
  3687. SELECT
  3688. a.doctor_id AS doctorId,
  3689. a.doctor_name AS doctorName,
  3690. count( * ) AS entryNum
  3691. FROM
  3692. med_behospital_info a,
  3693. med_qcresult_info c,
  3694. med_qcresult_detail d,
  3695. qc_cases_entry e,
  3696. sys_user_dept f
  3697. WHERE
  3698. a.is_deleted = 'N'
  3699. AND c.is_deleted = 'N'
  3700. AND d.is_deleted = 'N'
  3701. AND e.is_deleted = 'N'
  3702. AND f.is_deleted = 'N'
  3703. AND a.hospital_id = c.hospital_id
  3704. AND a.hospital_id = d.hospital_id
  3705. AND a.behospital_code = c.behospital_code
  3706. AND a.behospital_code = d.behospital_code
  3707. AND d.cases_id = e.cases_id
  3708. AND d.cases_entry_id = e.id
  3709. AND a.beh_dept_id = f.dept_id
  3710. <if test="isPlacefile != null and isPlacefile != ''">
  3711. and a.is_placefile = #{isPlacefile}
  3712. </if>
  3713. AND a.qc_type_id != 0
  3714. <if test="hospitalId != null and hospitalId != ''">
  3715. AND a.hospital_id = #{hospitalId}
  3716. </if>
  3717. <if test="isPlacefile != null and isPlacefile == 0">
  3718. <if test="startDate != null and startDate != ''">
  3719. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3720. </if>
  3721. <if test="endDate != null and endDate != ''">
  3722. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3723. </if>
  3724. </if>
  3725. <if test="isPlacefile != null and isPlacefile == 1">
  3726. <if test="startDate != null and startDate != ''">
  3727. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3728. </if>
  3729. <if test="endDate != null and endDate != ''">
  3730. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3731. </if>
  3732. </if>
  3733. <if test="level != null and level != ''">
  3734. and c.level = #{level}
  3735. </if>
  3736. <if test="doctorName != null and doctorName != ''">
  3737. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3738. </if>
  3739. <if test="userId!=null and userId !=''">
  3740. AND f.user_id = #{userId}
  3741. </if>
  3742. <if test="deptName != null and deptName != ''">
  3743. and a.beh_dept_name = #{deptName}
  3744. </if>
  3745. GROUP BY
  3746. a.doctor_id,
  3747. a.doctor_name
  3748. ) t2
  3749. WHERE
  3750. t1.doctorId = t2.doctorId
  3751. AND t1.doctorName = t2.doctorName
  3752. )m1 left join
  3753. ( SELECT
  3754. t1.doctorId,
  3755. t1.doctorName,
  3756. t2.entryNum as sameNum,
  3757. t1.mrNum as sameMrNum,
  3758. t1.totleValue as sameTotleValue,
  3759. t1.averageValue as sameAvgValue,
  3760. t1.firstLevelNum as sameFirstLevelNum,
  3761. t1.secondLevelNum as sameSecondLevelNum,
  3762. t1.thirdLevelNum as sameThirdLevelNum,
  3763. t1.firstLevelPercent as sameFirstLevelPercent,
  3764. t1.secondLevelPercent as sameSecondLevelPercent,
  3765. t1.thirdLevelPercent as sameThirdLevelPercent,
  3766. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3767. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3768. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3769. FROM
  3770. (
  3771. SELECT
  3772. a.doctor_id AS doctorId,
  3773. a.doctor_name AS doctorName,
  3774. count(*) AS mrNum,
  3775. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3776. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3777. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3778. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3779. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3780. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3781. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3782. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3783. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3784. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3785. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3786. FROM
  3787. med_behospital_info a,
  3788. med_qcresult_info c,
  3789. sys_user_dept e
  3790. WHERE
  3791. a.is_deleted = 'N'
  3792. AND c.is_deleted = 'N'
  3793. AND e.is_deleted = 'N'
  3794. AND a.hospital_id = c.hospital_id
  3795. AND a.behospital_code = c.behospital_code
  3796. AND a.beh_dept_id = e.dept_id
  3797. <if test="isPlacefile != null and isPlacefile != ''">
  3798. and a.is_placefile = #{isPlacefile}
  3799. </if>
  3800. AND a.qc_type_id != 0
  3801. <if test="hospitalId != null and hospitalId != ''">
  3802. AND a.hospital_id = #{hospitalId}
  3803. </if>
  3804. <if test="isPlacefile != null and isPlacefile == 0">
  3805. <if test="lastStartDate != null and lastStartDate != ''">
  3806. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3807. </if>
  3808. <if test="lastEndDate != null and lastEndDate != ''">
  3809. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3810. </if>
  3811. </if>
  3812. <if test="isPlacefile != null and isPlacefile == 1">
  3813. <if test="lastStartDate != null and lastStartDate != ''">
  3814. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3815. </if>
  3816. <if test="lastEndDate != null and lastEndDate != ''">
  3817. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3818. </if>
  3819. </if>
  3820. <if test="level != null and level != ''">
  3821. and c.level = #{level}
  3822. </if>
  3823. <if test="doctorName != null and doctorName != ''">
  3824. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3825. </if>
  3826. <if test="userId!=null and userId !=''">
  3827. AND e.user_id = #{userId}
  3828. </if>
  3829. <if test="deptName != null and deptName != ''">
  3830. and a.beh_dept_name = #{deptName}
  3831. </if>
  3832. GROUP BY
  3833. a.doctor_id,
  3834. a.doctor_name
  3835. ) t1,
  3836. (
  3837. SELECT
  3838. a.doctor_id AS doctorId,
  3839. a.doctor_name AS doctorName,
  3840. count( * ) AS entryNum
  3841. FROM
  3842. med_behospital_info a,
  3843. med_qcresult_info c,
  3844. med_qcresult_detail d,
  3845. qc_cases_entry e,
  3846. sys_user_dept f
  3847. WHERE
  3848. a.is_deleted = 'N'
  3849. AND c.is_deleted = 'N'
  3850. AND d.is_deleted = 'N'
  3851. AND e.is_deleted = 'N'
  3852. AND f.is_deleted = 'N'
  3853. AND a.hospital_id = c.hospital_id
  3854. AND a.hospital_id = d.hospital_id
  3855. AND a.behospital_code = c.behospital_code
  3856. AND a.behospital_code = d.behospital_code
  3857. AND d.cases_id = e.cases_id
  3858. AND d.cases_entry_id = e.id
  3859. AND a.beh_dept_id = f.dept_id
  3860. <if test="isPlacefile != null and isPlacefile != ''">
  3861. and a.is_placefile = #{isPlacefile}
  3862. </if>
  3863. AND a.qc_type_id != 0
  3864. <if test="hospitalId != null and hospitalId != ''">
  3865. AND a.hospital_id = #{hospitalId}
  3866. </if>
  3867. <if test="isPlacefile != null and isPlacefile == 0">
  3868. <if test="lastStartDate != null and lastStartDate != ''">
  3869. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3870. </if>
  3871. <if test="lastEndDate != null and lastEndDate != ''">
  3872. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3873. </if>
  3874. </if>
  3875. <if test="isPlacefile != null and isPlacefile == 1">
  3876. <if test="lastStartDate != null and lastStartDate != ''">
  3877. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3878. </if>
  3879. <if test="lastEndDate != null and lastEndDate != ''">
  3880. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3881. </if>
  3882. </if>
  3883. <if test="level != null and level != ''">
  3884. and c.level = #{level}
  3885. </if>
  3886. <if test="doctorName != null and doctorName != ''">
  3887. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3888. </if>
  3889. <if test="userId!=null and userId !=''">
  3890. AND f.user_id = #{userId}
  3891. </if>
  3892. <if test="deptName != null and deptName != ''">
  3893. and a.beh_dept_name = #{deptName}
  3894. </if>
  3895. GROUP BY
  3896. a.doctor_id,
  3897. a.doctor_name
  3898. ) t2
  3899. WHERE
  3900. t1.doctorId = t2.doctorId
  3901. AND t1.doctorName = t2.doctorName
  3902. )m2
  3903. on
  3904. m1.doctorId = m2.doctorId
  3905. AND m1.doctorName = m2.doctorName
  3906. <if test="asc != null and asc !=''">
  3907. order by
  3908. <choose>
  3909. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3910. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3911. <when test='asc=="name"'>m1.doctorName asc</when>
  3912. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3913. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3914. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3915. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3916. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3917. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3918. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3919. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3920. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3921. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3922. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3923. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3924. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3925. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3926. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3927. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3928. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3929. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3930. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3931. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3932. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3933. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3934. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3935. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3936. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3937. <otherwise>doctorName asc</otherwise>
  3938. </choose>
  3939. </if>
  3940. <if test="desc != null and desc!=''">
  3941. order by
  3942. <choose>
  3943. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3944. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3945. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3946. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3947. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3948. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3949. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3950. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3951. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3952. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3953. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3954. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3955. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3956. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3957. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3958. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3959. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3960. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3961. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3962. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3963. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3964. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3965. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3966. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3967. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3968. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3969. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3970. <otherwise>doctorName desc</otherwise>
  3971. </choose>
  3972. </if>
  3973. </select>
  3974. <!-- 病案首页合格率占比-科室 -->
  3975. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3976. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3977. SELECT
  3978. t1.doctorId,
  3979. t1.doctorName,
  3980. t2.entryNum,
  3981. t1.mrNum,
  3982. t1.totleValue,
  3983. t1.averageValue,
  3984. t1.firstLevelNum,
  3985. t1.secondLevelNum,
  3986. t1.firstLevelPercent,
  3987. t1.secondLevelPercent,
  3988. t1.firstLevelPercentStr,
  3989. t1.secondLevelPercentStr,
  3990. t3.emptyNum,
  3991. t3.errorNum,
  3992. t3.entryTotleNum,
  3993. t3.emptyPercent,
  3994. t3.errorPercent,
  3995. t3.emptyPercentStr,
  3996. t3.errorPercentStr
  3997. FROM
  3998. (
  3999. SELECT
  4000. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4001. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4002. count( * ) AS mrNum,
  4003. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  4004. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  4005. sum( c.`level` = '合格' ) AS firstLevelNum,
  4006. sum( c.`level` = '不合格' ) AS secondLevelNum,
  4007. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  4008. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  4009. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  4010. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  4011. FROM
  4012. med_behospital_info a,
  4013. med_qcresult_cases c,
  4014. sys_user_dept f
  4015. WHERE
  4016. a.is_deleted = 'N'
  4017. AND c.is_deleted = 'N'
  4018. AND f.is_deleted = 'N'
  4019. AND a.hospital_id = c.hospital_id
  4020. AND a.behospital_code = c.behospital_code
  4021. AND a.beh_dept_id = f.dept_id
  4022. AND c.cases_id = 243
  4023. <if test="isPlacefile != null and isPlacefile != ''">
  4024. and a.is_placefile = #{isPlacefile}
  4025. </if>
  4026. <![CDATA[AND a.qc_type_id <>0 ]]>
  4027. <if test="hospitalId != null and hospitalId != ''">
  4028. AND a.hospital_id = #{hospitalId}
  4029. </if>
  4030. <if test="isPlacefile != null and isPlacefile == 0">
  4031. <if test="startDate != null and startDate != ''">
  4032. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4033. </if>
  4034. <if test="endDate != null and endDate != ''">
  4035. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4036. </if>
  4037. </if>
  4038. <if test="isPlacefile != null and isPlacefile == 1">
  4039. <if test="startDate != null and startDate != ''">
  4040. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4041. </if>
  4042. <if test="endDate != null and endDate != ''">
  4043. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4044. </if>
  4045. </if>
  4046. <if test="level != null and level != ''">
  4047. and c.level = #{level}
  4048. </if>
  4049. <if test="name != null and name != ''">
  4050. <if test="name == '未知'">
  4051. and (a.doctor_name is null or a.doctor_name='')
  4052. </if>
  4053. <if test="name != '未知'">
  4054. and a.doctor_name like CONCAT('%',#{name},'%')
  4055. </if>
  4056. </if>
  4057. <if test="userId!=null and userId !=''">
  4058. AND f.user_id = #{userId}
  4059. </if>
  4060. <if test="deptName!=null and deptName !=''">
  4061. AND a.beh_dept_name = #{deptName}
  4062. </if>
  4063. <if test="deptId!=null and deptId !=''">
  4064. AND a.beh_dept_id = #{deptId}
  4065. </if>
  4066. <if test="doctorId != null and doctorId != ''">
  4067. AND a.doctor_id = #{doctorId}
  4068. </if>
  4069. <if test="doctorName != null and doctorName != ''">
  4070. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4071. </if>
  4072. <if test="name != null and name != ''">
  4073. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4074. </if>
  4075. GROUP BY
  4076. a.doctor_id,
  4077. a.doctor_name
  4078. ) t1,
  4079. (
  4080. SELECT
  4081. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4082. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4083. count( * ) AS entryNum
  4084. FROM
  4085. med_behospital_info a,
  4086. med_qcresult_cases c,
  4087. med_qcresult_detail d,
  4088. qc_cases_entry e,
  4089. sys_user_dept f
  4090. WHERE
  4091. a.is_deleted = 'N'
  4092. AND c.is_deleted = 'N'
  4093. AND d.is_deleted = 'N'
  4094. AND e.is_deleted = 'N'
  4095. AND f.is_deleted = 'N'
  4096. AND a.hospital_id = c.hospital_id
  4097. AND a.hospital_id = d.hospital_id
  4098. AND a.behospital_code = c.behospital_code
  4099. AND a.behospital_code = d.behospital_code
  4100. AND a.beh_dept_id = f.dept_id
  4101. AND c.cases_id = d.cases_id
  4102. AND d.cases_id = e.cases_id
  4103. AND d.cases_entry_id = e.id
  4104. AND c.cases_id = 243
  4105. <if test="isPlacefile != null and isPlacefile != ''">
  4106. and a.is_placefile = #{isPlacefile}
  4107. </if>
  4108. <![CDATA[AND a.qc_type_id <>0 ]]>
  4109. <if test="hospitalId != null and hospitalId != ''">
  4110. AND a.hospital_id = #{hospitalId}
  4111. </if>
  4112. <if test="isPlacefile != null and isPlacefile == 0">
  4113. <if test="startDate != null and startDate != ''">
  4114. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4115. </if>
  4116. <if test="endDate != null and endDate != ''">
  4117. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4118. </if>
  4119. </if>
  4120. <if test="isPlacefile != null and isPlacefile == 1">
  4121. <if test="startDate != null and startDate != ''">
  4122. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4123. </if>
  4124. <if test="endDate != null and endDate != ''">
  4125. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4126. </if>
  4127. </if>
  4128. <if test="level != null and level != ''">
  4129. and c.level = #{level}
  4130. </if>
  4131. <if test="name != null and name != ''">
  4132. <if test="name == '未知'">
  4133. and (a.doctor_name is null or a.doctor_name='')
  4134. </if>
  4135. <if test="name != '未知'">
  4136. and a.doctor_name like CONCAT('%',#{name},'%')
  4137. </if>
  4138. </if>
  4139. <if test="userId!=null and userId !=''">
  4140. AND f.user_id = #{userId}
  4141. </if>
  4142. <if test="deptName!=null and deptName !=''">
  4143. AND a.beh_dept_name = #{deptName}
  4144. </if>
  4145. <if test="deptId!=null and deptId !=''">
  4146. AND a.beh_dept_id = #{deptId}
  4147. </if>
  4148. <if test="doctorId != null and doctorId != ''">
  4149. AND a.doctor_id = #{doctorId}
  4150. </if>
  4151. <if test="doctorName != null and doctorName != ''">
  4152. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4153. </if>
  4154. <if test="name != null and name != ''">
  4155. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4156. </if>
  4157. GROUP BY
  4158. a.doctor_id,
  4159. a.doctor_name
  4160. ) t2,(
  4161. SELECT
  4162. h1.doctorId,
  4163. h1.doctorName,
  4164. h1.emptyNum,
  4165. h1.errorNum,
  4166. h1.mrNum,
  4167. h2.entryNum,
  4168. h1.mrNum * h2.entryNum AS entryTotleNum,
  4169. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  4170. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  4171. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  4172. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  4173. FROM
  4174. (
  4175. SELECT
  4176. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4177. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4178. sum( d.rule_type = 1 ) AS emptyNum,
  4179. sum( d.rule_type = 2 ) AS errorNum,
  4180. count( DISTINCT a.behospital_code ) AS mrNum
  4181. FROM
  4182. med_behospital_info a,
  4183. med_qcresult_cases b,
  4184. med_qcresult_detail c,
  4185. qc_cases_entry d,
  4186. sys_user_dept e
  4187. WHERE
  4188. a.is_deleted = 'N'
  4189. AND b.is_deleted = 'N'
  4190. AND c.is_deleted = 'N'
  4191. AND d.is_deleted = 'N'
  4192. AND e.is_deleted = 'N'
  4193. AND a.hospital_id = b.hospital_id
  4194. AND a.hospital_id = c.hospital_id
  4195. AND a.hospital_id = e.hospital_id
  4196. AND a.behospital_code = b.behospital_code
  4197. AND a.behospital_code = c.behospital_code
  4198. AND b.cases_id = c.cases_id
  4199. AND c.cases_id = d.cases_id
  4200. AND c.cases_entry_id = d.id
  4201. AND a.beh_dept_id = e.dept_id
  4202. <if test="isPlacefile != null and isPlacefile != ''">
  4203. and a.is_placefile = #{isPlacefile}
  4204. </if>
  4205. AND d.cases_id = 243
  4206. <![CDATA[AND a.qc_type_id <>0 ]]>
  4207. <if test="hospitalId != null and hospitalId != ''">
  4208. AND a.hospital_id = #{hospitalId}
  4209. </if>
  4210. <if test="isPlacefile != null and isPlacefile == 0">
  4211. <if test="startDate != null and startDate != ''">
  4212. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4213. </if>
  4214. <if test="endDate != null and endDate != ''">
  4215. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4216. </if>
  4217. </if>
  4218. <if test="isPlacefile != null and isPlacefile == 1">
  4219. <if test="startDate != null and startDate != ''">
  4220. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4221. </if>
  4222. <if test="endDate != null and endDate != ''">
  4223. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4224. </if>
  4225. </if>
  4226. <if test="level != null and level != ''">
  4227. and b.level = #{level}
  4228. </if>
  4229. <if test="name != null and name != ''">
  4230. <if test="name == '未知'">
  4231. and (a.doctor_name is null or a.doctor_name='')
  4232. </if>
  4233. <if test="name != '未知'">
  4234. and a.doctor_name like CONCAT('%',#{name},'%')
  4235. </if>
  4236. </if>
  4237. <if test="userId!=null and userId !=''">
  4238. AND e.user_id = #{userId}
  4239. </if>
  4240. <if test="deptName!=null and deptName !=''">
  4241. AND a.beh_dept_name = #{deptName}
  4242. </if>
  4243. <if test="deptId!=null and deptId !=''">
  4244. AND a.beh_dept_id = #{deptId}
  4245. </if>
  4246. <if test="doctorId != null and doctorId != ''">
  4247. AND a.doctor_id = #{doctorId}
  4248. </if>
  4249. <if test="doctorName != null and doctorName != ''">
  4250. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4251. </if>
  4252. <if test="name != null and name != ''">
  4253. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4254. </if>
  4255. GROUP BY
  4256. a.doctor_id,
  4257. a.doctor_name
  4258. ) h1,(
  4259. SELECT
  4260. count(*) AS entryNum
  4261. FROM
  4262. qc_cases_entry
  4263. WHERE
  4264. is_deleted = 'N'
  4265. AND cases_id = 243
  4266. ) h2
  4267. ) t3
  4268. WHERE
  4269. t1.doctorId = t2.doctorId
  4270. AND t1.doctorId = t3.doctorId
  4271. AND t1.doctorName = t2.doctorName
  4272. AND t1.doctorName = t3.doctorName
  4273. <if test="asc != null and asc !=''">
  4274. order by
  4275. <choose>
  4276. <when test='asc=="doctorId"'>doctorId asc</when>
  4277. <when test='asc=="doctorName"'>doctorName asc</when>
  4278. <when test='asc=="entryNum"'>entryNum asc</when>
  4279. <when test='asc=="mrNum"'>mrNum asc</when>
  4280. <when test='asc=="totleValue"'>totleValue asc</when>
  4281. <when test='asc=="averageValue"'>averageValue asc</when>
  4282. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4283. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4284. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4285. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4286. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4287. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4288. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4289. <when test='asc=="errorNum"'>errorNum asc</when>
  4290. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4291. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4292. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4293. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4294. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4295. <otherwise>doctorName asc</otherwise>
  4296. </choose>
  4297. </if>
  4298. <if test="desc != null and desc!=''">
  4299. order by
  4300. <choose>
  4301. <when test='desc=="doctorId"'>doctorId desc</when>
  4302. <when test='desc=="doctorName"'>doctorName desc</when>
  4303. <when test='desc=="entryNum"'>entryNum desc</when>
  4304. <when test='desc=="mrNum"'>mrNum desc</when>
  4305. <when test='desc=="totleValue"'>totleValue desc</when>
  4306. <when test='desc=="averageValue"'>averageValue desc</when>
  4307. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4308. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4309. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4310. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4311. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4312. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4313. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4314. <when test='desc=="errorNum"'>errorNum desc</when>
  4315. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4316. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4317. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4318. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4319. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4320. <otherwise>doctorName desc</otherwise>
  4321. </choose>
  4322. </if>
  4323. </select>
  4324. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4325. <result column="behDeptName" property="behDeptName"/>
  4326. <result column="doctorName" property="doctorName"/>
  4327. <result column="avgScore" property="avgScore"/>
  4328. <collection property="excelBehospitalDTOS"
  4329. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  4330. <result column="patName" property="patName"/>
  4331. <result column="behospitalCode" property="behospitalCode"/>
  4332. <result column="behospitalDate" property="behospitalDate"/>
  4333. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4334. <result column="score" property="score"/>
  4335. <result column="scoreBn" property="scoreBn"/>
  4336. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4337. <result column="caseName" property="caseName"/>
  4338. <collection property="exportExcelMsgDTOS"
  4339. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4340. <result column="msg" property="msg"/>
  4341. </collection>
  4342. </collection>
  4343. </collection>
  4344. </resultMap>
  4345. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  4346. <result column="behDeptName" property="behDeptName"/>
  4347. <result column="avgScore" property="avgScore"/>
  4348. <collection property="excelBehospitalDTOS"
  4349. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  4350. <result column="doctorName" property="doctorName"/>
  4351. <result column="patName" property="patName"/>
  4352. <result column="behospitalCode" property="behospitalCode"/>
  4353. <result column="behospitalDate" property="behospitalDate"/>
  4354. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4355. <result column="score" property="score"/>
  4356. <result column="scoreBn" property="scoreBn"/>
  4357. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4358. <result column="caseName" property="caseName"/>
  4359. <collection property="exportExcelMsgDTOS"
  4360. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4361. <result column="msg" property="msg"/>
  4362. </collection>
  4363. </collection>
  4364. </collection>
  4365. </resultMap>
  4366. <select id="exportExcel" resultMap="ExportExcelMap">
  4367. SELECT DISTINCT
  4368. t1.beh_dept_name AS behDeptName,
  4369. t1.beh_doctor_name AS doctorName,
  4370. t1.`name` AS patName,
  4371. t1.behospital_code AS behospitalCode,
  4372. t1.behospital_date AS behospitalDate,
  4373. t1.leave_hospital_date AS leaveHospitalDate,
  4374. t2.score_res AS score,
  4375. "1" AS avgScore,
  4376. t4.`name` AS caseName,
  4377. t3.msg AS msg
  4378. FROM
  4379. med_behospital_info t1,
  4380. med_qcresult_info t2,
  4381. med_qcresult_detail t3,
  4382. qc_cases t4
  4383. WHERE
  4384. t1.is_deleted = 'N'
  4385. AND t2.is_deleted = 'N'
  4386. AND t3.is_deleted = 'N'
  4387. AND t4.is_deleted = 'N'
  4388. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4389. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4390. AND t1.hospital_id = t2.hospital_id
  4391. AND t1.behospital_code = t2.behospital_code
  4392. AND t1.hospital_id = t3.hospital_id
  4393. AND t1.behospital_code = t3.behospital_code
  4394. AND t3.cases_id = t4.id
  4395. ORDER BY
  4396. t1.beh_dept_id ASC,
  4397. t1.leave_hospital_date DESC,
  4398. t1.behospital_code ASC,
  4399. t4.`name` ASC
  4400. </select>
  4401. <!-- 质控评分导出到excel-->
  4402. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4403. SELECT * FROM (
  4404. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4405. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4406. g.check_type AS ch_type,
  4407. h.check_type AS mr_type,
  4408. g.check_name AS ch_name,
  4409. h.check_name AS mr_name,
  4410. g.check_time AS ch_time,
  4411. h.check_time AS mr_time
  4412. FROM (
  4413. SELECT
  4414. t1.behDeptId,
  4415. t1.behDeptName,
  4416. t1.doctorName,
  4417. t1.patName,
  4418. t1.behospitalCode,
  4419. t1.hospitalId,
  4420. t1.behospitalDate,
  4421. t1.leaveHospitalDate,
  4422. t1.score,
  4423. <if test="radioCheck !=null and radioCheck == 1">
  4424. t1.msg,
  4425. t1.caseName,
  4426. </if>
  4427. t1.scoreBn,
  4428. t2.avgScore
  4429. FROM
  4430. (
  4431. SELECT
  4432. a.doctor_name AS doctorName,
  4433. a.`name` AS patName,
  4434. a.behospital_code AS behospitalCode,
  4435. a.behospital_date AS behospitalDate,
  4436. a.leave_hospital_date AS leaveHospitalDate,
  4437. b.score_res AS score,
  4438. e.score_res as scoreBn,
  4439. <if test="radioCheck !=null and radioCheck == 1">
  4440. c.msg AS msg,
  4441. d.NAME AS caseName,
  4442. </if>
  4443. a.beh_dept_id AS behDeptId,
  4444. a.beh_dept_name AS behDeptName,
  4445. a.hospital_id AS hospitalId
  4446. FROM
  4447. med_behospital_info a
  4448. RIGHT JOIN
  4449. med_qcresult_info b
  4450. ON a.hospital_id = b.hospital_id
  4451. AND a.is_deleted = 'N'
  4452. AND b.is_deleted = 'N'
  4453. AND a.behospital_code = b.behospital_code
  4454. <if test="radioCheck !=null and radioCheck == 1">
  4455. LEFT JOIN
  4456. med_qcresult_detail c
  4457. ON c.is_deleted = 'N'
  4458. AND b.behospital_code = c.behospital_code
  4459. AND b.hospital_id = c.hospital_id
  4460. LEFT JOIN
  4461. qc_cases d
  4462. on d.is_deleted = 'N'
  4463. AND c.cases_id = d.id
  4464. </if>
  4465. LEFT JOIN med_qcresult_cases e
  4466. on b.behospital_code = e.behospital_code
  4467. and b.hospital_id = e.hospital_id
  4468. AND e.is_deleted = 'N'
  4469. and e.cases_id = 243
  4470. WHERE
  4471. 1=1
  4472. <if test="isPlacefile != null and isPlacefile != ''">
  4473. and a.is_placefile = #{isPlacefile}
  4474. </if>
  4475. <![CDATA[AND a.qc_type_id <>0 ]]>
  4476. <if test="hospitalId != null and hospitalId != ''">
  4477. AND a.hospital_id = #{hospitalId}
  4478. </if>
  4479. <if test="diagnose != null and diagnose != ''">
  4480. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4481. </if>
  4482. <if test="behosDateStart != null">
  4483. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4484. </if>
  4485. <if test="behosDateEnd != null">
  4486. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4487. </if>
  4488. <if test="leaveHosDateStart != null ">
  4489. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4490. </if>
  4491. <if test="leaveHosDateEnd != null ">
  4492. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4493. </if>
  4494. <if test="behospitalCode != null and behospitalCode != ''">
  4495. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4496. </if>
  4497. <if test="level != null and level != ''">
  4498. AND b.level = #{level}
  4499. </if>
  4500. <if test="doctorName != null and doctorName != ''">
  4501. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4502. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4503. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4504. </if>
  4505. <if test="doctorCode != null and doctorCode != ''">
  4506. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4507. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4508. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4509. </if>
  4510. <if test="deptName != null and deptName != ''">
  4511. and a.beh_dept_name = #{deptName}
  4512. </if>
  4513. <if test="name != null and name != ''">
  4514. AND a.name like CONCAT('%',#{name},'%')
  4515. </if>
  4516. ) t1,
  4517. (
  4518. SELECT
  4519. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4520. a.beh_dept_id AS behDeptId,
  4521. a.beh_dept_name AS behDeptName
  4522. FROM
  4523. med_behospital_info a,
  4524. med_qcresult_info b
  4525. WHERE
  4526. a.is_deleted = 'N'
  4527. AND b.is_deleted = 'N'
  4528. AND a.hospital_id = b.hospital_id
  4529. AND a.behospital_code = b.behospital_code
  4530. <if test="isPlacefile != null and isPlacefile != ''">
  4531. and a.is_placefile = #{isPlacefile}
  4532. </if>
  4533. <![CDATA[AND a.qc_type_id <>0 ]]>
  4534. <if test="hospitalId != null and hospitalId != ''">
  4535. AND a.hospital_id = #{hospitalId}
  4536. </if>
  4537. <if test="diagnose != null and diagnose != ''">
  4538. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4539. </if>
  4540. <if test="behosDateStart != null">
  4541. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4542. </if>
  4543. <if test="behosDateEnd != null">
  4544. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4545. </if>
  4546. <if test="leaveHosDateStart != null ">
  4547. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4548. </if>
  4549. <if test="leaveHosDateEnd != null ">
  4550. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4551. </if>
  4552. <if test="behospitalCode != null and behospitalCode != ''">
  4553. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4554. </if>
  4555. <if test="level != null and level != ''">
  4556. AND b.level = #{level}
  4557. </if>
  4558. <if test="doctorName != null and doctorName != ''">
  4559. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4560. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4561. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4562. </if>
  4563. <if test="doctorCode != null and doctorCode != ''">
  4564. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4565. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4566. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4567. </if>
  4568. <if test="deptName != null and deptName != ''">
  4569. and a.beh_dept_name = #{deptName}
  4570. </if>
  4571. <if test="name != null and name != ''">
  4572. AND a.name like CONCAT('%',#{name},'%')
  4573. </if>
  4574. GROUP BY
  4575. a.beh_dept_id,
  4576. a.beh_dept_name
  4577. ) t2
  4578. WHERE
  4579. t1.behDeptId = t2.behDeptId
  4580. AND t1.behDeptName = t2.behDeptName
  4581. ORDER BY
  4582. t1.behDeptName,
  4583. t1.doctorName,
  4584. t1.patName,
  4585. <if test="radioCheck !=null and radioCheck == 1">
  4586. t1.caseName,
  4587. </if>
  4588. t1.behospitalCode
  4589. )tp
  4590. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4591. ON tp.behospitalCode = g.behospital_code
  4592. AND tp.hospitalId = g.hospital_id
  4593. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4594. ON tp.behospitalCode = h.behospital_code
  4595. AND tp.hospitalId = h.hospital_id
  4596. ) tu
  4597. WHERE tu.behospitalCode IS NOT NULL
  4598. <if test="checkStatus != null ">
  4599. and tu.check_status = #{checkStatus}
  4600. </if>
  4601. <if test="mrStatus != null ">
  4602. AND tu.mr_status = #{mrStatus}
  4603. </if>
  4604. <if test="chName != null and chName !=''">
  4605. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4606. </if>
  4607. <if test="mrName != null and mrName !=''">
  4608. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4609. </if>
  4610. <if test="chTimeStart != null">
  4611. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4612. </if>
  4613. <if test="chTimeEnd != null">
  4614. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4615. </if>
  4616. <if test="mrTimeStart != null">
  4617. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4618. </if>
  4619. <if test="mrTimeEnd != null">
  4620. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4621. </if>
  4622. </select>
  4623. <!-- 科室质控评分导出到excel-->
  4624. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4625. SELECT * FROM (
  4626. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4627. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4628. g.check_type AS ch_type,
  4629. h.check_type AS mr_type,
  4630. g.check_name AS ch_name,
  4631. h.check_name AS mr_name,
  4632. g.check_time AS ch_time,
  4633. h.check_time AS mr_time
  4634. FROM (
  4635. SELECT
  4636. t1.behDeptId,
  4637. t1.behDeptName,
  4638. t1.doctorName,
  4639. t1.patName,
  4640. t1.behospitalCode,
  4641. t1.hospitalId,
  4642. t1.behospitalDate,
  4643. t1.leaveHospitalDate,
  4644. t1.score,
  4645. t2.avgScore,
  4646. <if test="radioCheck !=null and radioCheck == 1">
  4647. t1.msg,
  4648. t1.caseName,
  4649. </if>
  4650. e.score_res as scoreBn
  4651. FROM
  4652. (
  4653. SELECT
  4654. a.doctor_name AS doctorName,
  4655. a.`name` AS patName,
  4656. a.behospital_code AS behospitalCode,
  4657. a.hospital_id AS hospital_id,
  4658. a.behospital_date AS behospitalDate,
  4659. a.leave_hospital_date AS leaveHospitalDate,
  4660. b.score_res AS score,
  4661. <if test="radioCheck !=null and radioCheck == 1">
  4662. c.msg AS msg,
  4663. d.NAME AS caseName,
  4664. </if>
  4665. a.beh_dept_id AS behDeptId,
  4666. a.beh_dept_name AS behDeptName,
  4667. a.hospital_id AS hospitalId
  4668. FROM
  4669. med_behospital_info a,
  4670. med_qcresult_info b,
  4671. med_qcresult_detail c,
  4672. qc_cases d,
  4673. sys_user_dept e
  4674. WHERE
  4675. a.is_deleted = 'N'
  4676. AND b.is_deleted = 'N'
  4677. AND c.is_deleted = 'N'
  4678. AND d.is_deleted = 'N'
  4679. AND e.is_deleted = 'N'
  4680. AND a.hospital_id = b.hospital_id
  4681. AND a.hospital_id = c.hospital_id
  4682. AND a.hospital_id = e.hospital_id
  4683. AND a.behospital_code = b.behospital_code
  4684. AND a.behospital_code = c.behospital_code
  4685. AND c.cases_id = d.id
  4686. AND a.beh_dept_id = e.dept_id
  4687. <if test="diagnose != null and diagnose != ''">
  4688. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4689. </if>
  4690. <if test="isPlacefile != null and isPlacefile != ''">
  4691. and a.is_placefile = #{isPlacefile}
  4692. </if>
  4693. <![CDATA[AND a.qc_type_id <>0 ]]>
  4694. <if test="hospitalId != null and hospitalId != ''">
  4695. AND a.hospital_id = #{hospitalId}
  4696. </if>
  4697. <if test="userId != null ">
  4698. AND e.user_id = #{userId}
  4699. </if>
  4700. <if test="behosDateStart != null">
  4701. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4702. </if>
  4703. <if test="behosDateEnd != null">
  4704. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4705. </if>
  4706. <if test="leaveHosDateStart != null ">
  4707. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4708. </if>
  4709. <if test="leaveHosDateEnd != null ">
  4710. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4711. </if>
  4712. <if test="behospitalCode != null and behospitalCode != ''">
  4713. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4714. </if>
  4715. <if test="level != null and level != ''">
  4716. AND b.level = #{level}
  4717. </if>
  4718. <if test="doctorName != null and doctorName != ''">
  4719. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4720. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4721. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4722. </if>
  4723. <if test="doctorCode != null and doctorCode != ''">
  4724. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4725. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4726. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4727. </if>
  4728. <if test="deptName != null and deptName != ''">
  4729. and a.beh_dept_name = #{deptName}
  4730. </if>
  4731. <if test="name != null and name != ''">
  4732. AND a.name like CONCAT('%',#{name},'%')
  4733. </if>
  4734. ) t1
  4735. LEFT JOIN med_qcresult_cases e
  4736. on t1.behospitalCode = e.behospital_code
  4737. and t1.hospital_id = e.hospital_id
  4738. AND e.is_deleted = 'N'
  4739. and e.cases_id = 243,
  4740. (
  4741. SELECT
  4742. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4743. a.beh_dept_id AS behDeptId,
  4744. a.beh_dept_name AS behDeptName
  4745. FROM
  4746. med_behospital_info a,
  4747. med_qcresult_info b,
  4748. sys_user_dept c
  4749. WHERE
  4750. a.is_deleted = 'N'
  4751. AND b.is_deleted = 'N'
  4752. AND c.is_deleted = 'N'
  4753. AND a.hospital_id = b.hospital_id
  4754. AND a.hospital_id = c.hospital_id
  4755. AND a.behospital_code = b.behospital_code
  4756. AND a.beh_dept_id = c.dept_id
  4757. <if test="diagnose != null and diagnose != ''">
  4758. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4759. </if>
  4760. <if test="isPlacefile != null and isPlacefile != ''">
  4761. and a.is_placefile = #{isPlacefile}
  4762. </if>
  4763. <![CDATA[AND a.qc_type_id <>0 ]]>
  4764. <if test="hospitalId != null and hospitalId != ''">
  4765. AND a.hospital_id = #{hospitalId}
  4766. </if>
  4767. <if test="userId != null ">
  4768. AND c.user_id = #{userId}
  4769. </if>
  4770. <if test="behosDateStart != null">
  4771. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4772. </if>
  4773. <if test="behosDateEnd != null">
  4774. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4775. </if>
  4776. <if test="leaveHosDateStart != null ">
  4777. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4778. </if>
  4779. <if test="leaveHosDateEnd != null ">
  4780. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4781. </if>
  4782. <if test="behospitalCode != null and behospitalCode != ''">
  4783. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4784. </if>
  4785. <if test="level != null and level != ''">
  4786. AND b.level = #{level}
  4787. </if>
  4788. <if test="doctorName != null and doctorName != ''">
  4789. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4790. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4791. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4792. </if>
  4793. <if test="doctorCode != null and doctorCode != ''">
  4794. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4795. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4796. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4797. </if>
  4798. <if test="deptName != null and deptName != ''">
  4799. and a.beh_dept_name = #{deptName}
  4800. </if>
  4801. <if test="name != null and name != ''">
  4802. AND a.name like CONCAT('%',#{name},'%')
  4803. </if>
  4804. GROUP BY
  4805. a.beh_dept_id,
  4806. a.beh_dept_name
  4807. ) t2
  4808. WHERE
  4809. t1.behDeptId = t2.behDeptId
  4810. AND t1.behDeptName = t2.behDeptName
  4811. ORDER BY
  4812. t1.behDeptName,
  4813. t1.doctorName,
  4814. t1.patName,
  4815. <if test="radioCheck !=null and radioCheck == 1">
  4816. t1.caseName,
  4817. </if>
  4818. t1.behospitalCode
  4819. )tp
  4820. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4821. ON tp.behospitalCode = g.behospital_code
  4822. AND tp.hospitalId = g.hospital_id
  4823. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4824. ON tp.behospitalCode = h.behospital_code
  4825. AND tp.hospitalId = h.hospital_id
  4826. ) tu
  4827. WHERE tu.behospitalCode IS NOT NULL
  4828. <if test="checkStatus != null ">
  4829. and tu.check_status = #{checkStatus}
  4830. </if>
  4831. <if test="mrStatus != null ">
  4832. AND tu.mr_status = #{mrStatus}
  4833. </if>
  4834. <if test="chName != null and chName !=''">
  4835. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4836. </if>
  4837. <if test="mrName != null and mrName !=''">
  4838. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4839. </if>
  4840. <if test="chTimeStart != null">
  4841. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4842. </if>
  4843. <if test="chTimeEnd != null">
  4844. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4845. </if>
  4846. <if test="mrTimeStart != null">
  4847. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4848. </if>
  4849. <if test="mrTimeEnd != null">
  4850. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4851. </if>
  4852. </select>
  4853. <!-- 个人质控评分导出到excel-->
  4854. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4855. SELECT * FROM (
  4856. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4857. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4858. g.check_type AS ch_type,
  4859. h.check_type AS mr_type,
  4860. g.check_name AS ch_name,
  4861. h.check_name AS mr_name,
  4862. g.check_time AS ch_time,
  4863. h.check_time AS mr_time
  4864. FROM (
  4865. SELECT
  4866. t1.behDeptId,
  4867. t1.behDeptName,
  4868. t1.doctorName,
  4869. t1.patName,
  4870. t1.behospitalCode,
  4871. t1.hospitalId,
  4872. t1.behospitalDate,
  4873. t1.leaveHospitalDate,
  4874. t1.score,
  4875. t2.avgScore,
  4876. <if test="radioCheck !=null and radioCheck == 1">
  4877. t1.msg,
  4878. t1.caseName,
  4879. </if>
  4880. e.score_res as scoreBn
  4881. FROM
  4882. (
  4883. SELECT
  4884. a.doctor_name AS doctorName,
  4885. a.beh_doctor_name,
  4886. a.director_doctor_name,
  4887. a.`name` AS patName,
  4888. a.behospital_code AS behospitalCode,
  4889. a.behospital_date AS behospitalDate,
  4890. a.leave_hospital_date AS leaveHospitalDate,
  4891. b.score_res AS score,
  4892. <if test="radioCheck !=null and radioCheck == 1">
  4893. c.msg AS msg,
  4894. d.NAME AS caseName,
  4895. </if>
  4896. a.beh_dept_id AS behDeptId,
  4897. a.beh_dept_name AS behDeptName,
  4898. a.hospital_id AS hospitalId
  4899. FROM
  4900. med_behospital_info a,
  4901. med_qcresult_info b,
  4902. med_qcresult_detail c,
  4903. qc_cases d,
  4904. sys_user u,
  4905. sys_user_hospital uh
  4906. WHERE
  4907. a.is_deleted = 'N'
  4908. AND b.is_deleted = 'N'
  4909. AND c.is_deleted = 'N'
  4910. AND d.is_deleted = 'N'
  4911. AND u.is_deleted = 'N'
  4912. AND uh.is_deleted = 'N'
  4913. AND a.hospital_id = b.hospital_id
  4914. AND a.hospital_id = c.hospital_id
  4915. AND a.behospital_code = b.behospital_code
  4916. AND a.behospital_code = c.behospital_code
  4917. AND u.id = uh.user_id
  4918. AND a.hospital_id = uh.hospital_id
  4919. <if test="userId != null and userId != ''">
  4920. AND u.id = #{userId}
  4921. </if>
  4922. <if test="isPlacefile != null and isPlacefile != ''">
  4923. and a.is_placefile = #{isPlacefile}
  4924. </if>
  4925. <![CDATA[AND a.qc_type_id <>0 ]]>
  4926. <if test="hospitalId != null and hospitalId != ''">
  4927. AND a.hospital_id = #{hospitalId}
  4928. </if>
  4929. <if test="diagnose != null and diagnose != ''">
  4930. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4931. </if>
  4932. <if test="behosDateStart != null">
  4933. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4934. </if>
  4935. <if test="behosDateEnd != null">
  4936. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4937. </if>
  4938. <if test="leaveHosDateStart != null ">
  4939. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4940. </if>
  4941. <if test="leaveHosDateEnd != null ">
  4942. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4943. </if>
  4944. <if test="behospitalCode != null and behospitalCode != ''">
  4945. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4946. </if>
  4947. <if test="level != null and level != ''">
  4948. AND b.level = #{level}
  4949. </if>
  4950. <if test="doctorName != null and doctorName != ''">
  4951. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4952. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4953. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4954. </if>
  4955. <if test="doctorCode != null and doctorCode != ''">
  4956. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4957. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4958. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4959. </if>
  4960. <if test="deptId != null and deptId != ''">
  4961. AND a.beh_dept_id = #{deptId}
  4962. </if>
  4963. <if test="deptName != null and deptName != ''">
  4964. and a.beh_dept_name = #{deptName}
  4965. </if>
  4966. <if test="name != null and name != ''">
  4967. AND a.name like CONCAT('%',#{name},'%')
  4968. </if>
  4969. ) t1 LEFT JOIN med_qcresult_cases e
  4970. on t1.behospitalCode = e.behospital_code
  4971. and t1.hospitalId = e.hospital_id
  4972. AND e.is_deleted = 'N'
  4973. and e.cases_id = 243,
  4974. (
  4975. SELECT
  4976. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4977. a.beh_dept_id AS behDeptId,
  4978. a.beh_dept_name AS behDeptName
  4979. FROM
  4980. med_behospital_info a,
  4981. med_qcresult_info b,
  4982. sys_user u,
  4983. sys_user_hospital uh
  4984. WHERE
  4985. a.is_deleted = 'N'
  4986. AND b.is_deleted = 'N'
  4987. AND u.is_deleted = 'N'
  4988. AND uh.is_deleted = 'N'
  4989. AND a.hospital_id = b.hospital_id
  4990. AND a.behospital_code = b.behospital_code
  4991. AND u.id = uh.user_id
  4992. AND a.hospital_id = uh.hospital_id
  4993. and (a.doctor_name = u.linkman
  4994. or a.beh_doctor_name = u.linkman
  4995. or a.director_doctor_name = u.linkman)
  4996. <if test="userId != null and userId != ''">
  4997. AND u.id = #{userId}
  4998. </if>
  4999. <if test="diagnose != null and diagnose != ''">
  5000. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5001. </if>
  5002. <if test="isPlacefile != null and isPlacefile != ''">
  5003. and a.is_placefile = #{isPlacefile}
  5004. </if>
  5005. <![CDATA[AND a.qc_type_id <>0 ]]>
  5006. <if test="hospitalId != null and hospitalId != ''">
  5007. AND a.hospital_id = #{hospitalId}
  5008. </if>
  5009. <if test="behosDateStart != null">
  5010. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5011. </if>
  5012. <if test="behosDateEnd != null">
  5013. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5014. </if>
  5015. <if test="leaveHosDateStart != null ">
  5016. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  5017. </if>
  5018. <if test="leaveHosDateEnd != null ">
  5019. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  5020. </if>
  5021. <if test="behospitalCode != null and behospitalCode != ''">
  5022. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5023. </if>
  5024. <if test="level != null and level != ''">
  5025. AND b.level = #{level}
  5026. </if>
  5027. <if test="doctorName != null and doctorName != ''">
  5028. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5029. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5030. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5031. </if>
  5032. <if test="doctorCode != null and doctorCode != ''">
  5033. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5034. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5035. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5036. </if>
  5037. <if test="deptId != null and deptId != ''">
  5038. AND a.beh_dept_id = #{deptId}
  5039. </if>
  5040. <if test="deptName != null and deptName != ''">
  5041. and a.beh_dept_name = #{deptName}
  5042. </if>
  5043. <if test="name != null and name != ''">
  5044. AND a.name like CONCAT('%',#{name},'%')
  5045. </if>
  5046. ) t2
  5047. WHERE
  5048. t1.behDeptId = t2.behDeptId
  5049. AND t1.behDeptName = t2.behDeptName
  5050. ORDER BY
  5051. t1.behDeptName,
  5052. t1.doctorName,
  5053. t1.patName,
  5054. <if test="radioCheck !=null and radioCheck == 1">
  5055. t1.caseName,
  5056. </if>
  5057. t1.behospitalCode
  5058. )tp
  5059. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5060. ON tp.behospitalCode = g.behospital_code
  5061. AND tp.hospitalId = g.hospital_id
  5062. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5063. ON tp.behospitalCode = h.behospital_code
  5064. AND tp.hospitalId = h.hospital_id
  5065. ) tu
  5066. WHERE tu.behospitalCode IS NOT NULL
  5067. <if test="checkStatus != null ">
  5068. and tu.check_status = #{checkStatus}
  5069. </if>
  5070. <if test="mrStatus != null ">
  5071. AND tu.mr_status = #{mrStatus}
  5072. </if>
  5073. <if test="chName != null and chName !=''">
  5074. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5075. </if>
  5076. <if test="mrName != null and mrName !=''">
  5077. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5078. </if>
  5079. <if test="chTimeStart != null">
  5080. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5081. </if>
  5082. <if test="chTimeEnd != null">
  5083. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5084. </if>
  5085. <if test="mrTimeStart != null">
  5086. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5087. </if>
  5088. <if test="mrTimeEnd != null">
  5089. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5090. </if>
  5091. </select>
  5092. <!-- 医疗组质控评分导出到excel-->
  5093. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  5094. SELECT * FROM (
  5095. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  5096. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  5097. g.check_type AS ch_type,
  5098. h.check_type AS mr_type,
  5099. g.check_name AS ch_name,
  5100. h.check_name AS mr_name,
  5101. g.check_time AS ch_time,
  5102. h.check_time AS mr_time
  5103. FROM (
  5104. SELECT
  5105. t1.behDeptId,
  5106. t1.behDeptName,
  5107. t1.doctorName,
  5108. t1.patName,
  5109. t1.behospitalCode,
  5110. t1.hospitalId,
  5111. t1.behospitalDate,
  5112. t1.leaveHospitalDate,
  5113. t1.score,
  5114. t2.avgScore,
  5115. <if test="radioCheck !=null and radioCheck == 1">
  5116. t1.msg,
  5117. t1.caseName,
  5118. </if>
  5119. e.score_res as scoreBn
  5120. FROM
  5121. (
  5122. SELECT
  5123. a.doctor_name AS doctorName,
  5124. a.`name` AS patName,
  5125. a.behospital_code AS behospitalCode,
  5126. a.behospital_date AS behospitalDate,
  5127. a.leave_hospital_date AS leaveHospitalDate,
  5128. b.score_res AS score,
  5129. <if test="radioCheck !=null and radioCheck == 1">
  5130. c.msg AS msg,
  5131. d.NAME AS caseName,
  5132. </if>
  5133. a.beh_dept_id AS behDeptId,
  5134. a.beh_dept_name AS behDeptName,
  5135. a.hospital_id AS hospitalId
  5136. FROM
  5137. med_behospital_info a,
  5138. med_qcresult_info b,
  5139. med_qcresult_detail c,
  5140. qc_cases d
  5141. WHERE
  5142. a.is_deleted = 'N'
  5143. AND b.is_deleted = 'N'
  5144. AND c.is_deleted = 'N'
  5145. AND d.is_deleted = 'N'
  5146. AND a.hospital_id = b.hospital_id
  5147. AND a.hospital_id = c.hospital_id
  5148. AND a.behospital_code = b.behospital_code
  5149. AND a.behospital_code = c.behospital_code
  5150. AND c.cases_id = d.id
  5151. <if test="isPlacefile != null and isPlacefile != ''">
  5152. and a.is_placefile = #{isPlacefile}
  5153. </if>
  5154. AND a.doctor_id in
  5155. (SELECT doctor_id FROM `bas_doctor_info`
  5156. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5157. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5158. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5159. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5160. and c1.username = c3.doctor_id
  5161. and c2.hospital_id = #{hospitalId}
  5162. and c1.id = #{userId}
  5163. ))
  5164. <![CDATA[AND a.qc_type_id <>0 ]]>
  5165. <if test="hospitalId != null and hospitalId != ''">
  5166. AND a.hospital_id = #{hospitalId}
  5167. </if>
  5168. <if test="diagnose != null and diagnose != ''">
  5169. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5170. </if>
  5171. <if test="behosDateStart != null">
  5172. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5173. </if>
  5174. <if test="behosDateEnd != null">
  5175. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5176. </if>
  5177. <if test="leaveHosDateStart != null ">
  5178. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5179. </if>
  5180. <if test="leaveHosDateEnd != null ">
  5181. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5182. </if>
  5183. <if test="behospitalCode != null and behospitalCode != ''">
  5184. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5185. </if>
  5186. <if test="level != null and level != ''">
  5187. AND b.level = #{level}
  5188. </if>
  5189. <if test="doctorName != null and doctorName != ''">
  5190. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5191. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5192. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5193. </if>
  5194. <if test="doctorCode != null and doctorCode != ''">
  5195. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5196. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5197. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5198. </if>
  5199. <if test="deptId != null and deptId != ''">
  5200. AND a.beh_dept_id = #{deptId}
  5201. </if>
  5202. <if test="name != null and name != ''">
  5203. AND a.name like CONCAT('%',#{name},'%')
  5204. </if>
  5205. ) t1 LEFT JOIN med_qcresult_cases e
  5206. on t1.behospitalCode = e.behospital_code
  5207. and t1.hospitalId = e.hospital_id
  5208. AND e.is_deleted = 'N'
  5209. and e.cases_id = 243,
  5210. (
  5211. SELECT
  5212. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5213. a.beh_dept_id AS behDeptId,
  5214. a.beh_dept_name AS behDeptName
  5215. FROM
  5216. med_behospital_info a,
  5217. med_qcresult_info b
  5218. WHERE
  5219. a.is_deleted = 'N'
  5220. AND a.doctor_id in
  5221. (SELECT doctor_id FROM `bas_doctor_info`
  5222. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5223. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5224. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5225. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5226. and c1.username = c3.doctor_id
  5227. and c2.hospital_id = #{hospitalId}
  5228. and c1.id = #{userId}
  5229. ))
  5230. AND b.is_deleted = 'N'
  5231. AND a.hospital_id = b.hospital_id
  5232. AND a.behospital_code = b.behospital_code
  5233. <if test="diagnose != null and diagnose != ''">
  5234. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5235. </if>
  5236. <if test="isPlacefile != null and isPlacefile != ''">
  5237. and a.is_placefile = #{isPlacefile}
  5238. </if>
  5239. <![CDATA[AND a.qc_type_id <>0 ]]>
  5240. <if test="hospitalId != null and hospitalId != ''">
  5241. AND a.hospital_id = #{hospitalId}
  5242. </if>
  5243. <if test="behosDateStart != null">
  5244. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5245. </if>
  5246. <if test="behosDateEnd != null">
  5247. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5248. </if>
  5249. <if test="leaveHosDateStart != null ">
  5250. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5251. </if>
  5252. <if test="leaveHosDateEnd != null ">
  5253. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5254. </if>
  5255. <if test="behospitalCode != null and behospitalCode != ''">
  5256. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5257. </if>
  5258. <if test="level != null and level != ''">
  5259. AND b.level = #{level}
  5260. </if>
  5261. <if test="doctorName != null and doctorName != ''">
  5262. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5263. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5264. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5265. </if>
  5266. <if test="doctorCode != null and doctorCode != ''">
  5267. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5268. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5269. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5270. </if>
  5271. <if test="deptId != null and deptId != ''">
  5272. AND a.beh_dept_id = #{deptId}
  5273. </if>
  5274. <if test="name != null and name != ''">
  5275. AND a.name like CONCAT('%',#{name},'%')
  5276. </if>
  5277. GROUP BY
  5278. a.beh_dept_id,
  5279. a.beh_dept_name
  5280. ) t2
  5281. WHERE
  5282. t1.behDeptId = t2.behDeptId
  5283. AND t1.behDeptName = t2.behDeptName
  5284. ORDER BY
  5285. t1.behDeptName,
  5286. t1.doctorName,
  5287. t1.patName,
  5288. <if test="radioCheck !=null and radioCheck == 1">
  5289. t1.caseName,
  5290. </if>
  5291. t1.behospitalCode
  5292. )tp
  5293. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5294. ON tp.behospitalCode = g.behospital_code
  5295. AND tp.hospitalId = g.hospital_id
  5296. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5297. ON tp.behospitalCode = h.behospital_code
  5298. AND tp.hospitalId = h.hospital_id
  5299. ) tu
  5300. WHERE tu.behospitalCode IS NOT NULL
  5301. <if test="checkStatus != null ">
  5302. and tu.check_status = #{checkStatus}
  5303. </if>
  5304. <if test="mrStatus != null ">
  5305. AND tu.mr_status = #{mrStatus}
  5306. </if>
  5307. <if test="chName != null and chName !=''">
  5308. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5309. </if>
  5310. <if test="mrName != null and mrName !=''">
  5311. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5312. </if>
  5313. <if test="chTimeStart != null">
  5314. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5315. </if>
  5316. <if test="chTimeEnd != null">
  5317. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5318. </if>
  5319. <if test="mrTimeStart != null">
  5320. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5321. </if>
  5322. <if test="mrTimeEnd != null">
  5323. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5324. </if>
  5325. </select>
  5326. <!-- 条目缺陷质控评分页(内页)湘雅-->
  5327. <select id="qcResultShortXYPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5328. SELECT t.*
  5329. FROM
  5330. (SELECT DISTINCT
  5331. t1.hospital_id AS hospitalId,
  5332. t1.behospital_code AS behospitalCode,
  5333. t1.bed_code AS bedCode,
  5334. t1.LEVEL AS LEVEL,
  5335. t1.grade_type AS gradeType,
  5336. t1.score_res AS scoreRes,
  5337. t1.scoreBn,
  5338. t1.NAME AS NAME,
  5339. t1.sex AS sex,
  5340. t1.beh_dept_id AS behDeptId,
  5341. t1.beh_dept_name AS behDeptName,
  5342. t1.doctor_name AS doctorName,
  5343. t1.birthday AS birthday,
  5344. t1.behospital_date AS behospitalDate,
  5345. t1.leave_hospital_date AS leaveHospitalDate,
  5346. t1.placefile_date AS placefileDate,
  5347. t1.gmt_create AS gradeTime,
  5348. t1.diagnose,
  5349. t1.ward_name AS wardName,
  5350. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5351. t1.file_code AS fileCode,
  5352. t1.checkStatus,
  5353. t1.mrStatus,
  5354. t1.chName,
  5355. t1.mrName,
  5356. t1.chTime,
  5357. t1.mrTime
  5358. FROM
  5359. (
  5360. SELECT DISTINCT
  5361. tt1.*
  5362. FROM
  5363. (SELECT
  5364. be.*,
  5365. ifnull(mci.status,0) AS checkStatus,
  5366. ifnull(hm_mci.status,0) AS mrStatus,
  5367. mci.check_name as chName,
  5368. e.score_res as scoreBn,
  5369. hm_mci.check_name as mrName,
  5370. mci.gmt_create as chTime,
  5371. hm_mci.gmt_create as mrTime
  5372. FROM
  5373. (
  5374. SELECT DISTINCT
  5375. a.hospital_id,
  5376. a.behospital_code,
  5377. a.bed_code,
  5378. a.file_code,
  5379. b.LEVEL,
  5380. b.grade_type,
  5381. b.score_res,
  5382. a.NAME,
  5383. a.sex,
  5384. a.beh_dept_id,
  5385. a.beh_dept_name,
  5386. a.birthday,
  5387. a.behospital_date,
  5388. a.leave_hospital_date,
  5389. case
  5390. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  5391. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5392. e.director_doctor != '' and e.director_doctor is not null
  5393. then e.director_doctor
  5394. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5395. (e.director_doctor = '' or e.director_doctor is null) and
  5396. e.behospital_doctor != '' and e.behospital_doctor is not null
  5397. then e.behospital_doctor end as doctor_name,
  5398. a.diagnose,
  5399. a.placefile_date,
  5400. a.ward_name,
  5401. b.gmt_create
  5402. FROM
  5403. med_behospital_info a,
  5404. med_qcresult_info b,
  5405. med_qcresult_detail c,
  5406. qc_cases_entry d,
  5407. med_home_page e
  5408. WHERE
  5409. a.is_deleted = 'N'
  5410. AND b.is_deleted = 'N'
  5411. AND c.is_deleted = 'N'
  5412. AND d.is_deleted = 'N'
  5413. AND e.is_deleted = 'N'
  5414. AND a.hospital_id = b.hospital_id
  5415. AND a.hospital_id = c.hospital_id
  5416. AND a.hospital_id = e.hospital_id
  5417. AND a.behospital_code = b.behospital_code
  5418. AND a.behospital_code = c.behospital_code
  5419. AND a.behospital_code = e.behospital_code
  5420. AND c.cases_id = d.cases_id
  5421. AND c.cases_entry_id = d.id
  5422. AND a.qc_type_id != 0
  5423. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5424. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5425. </if>
  5426. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5427. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5428. </if>
  5429. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5430. <if test="qcResultShortPageVO.startDate != null ">
  5431. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5432. </if>
  5433. <if test="qcResultShortPageVO.endDate != null ">
  5434. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5435. </if>
  5436. </if>
  5437. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5438. <if test="qcResultShortPageVO.startDate != null ">
  5439. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5440. </if>
  5441. <if test="qcResultShortPageVO.endDate != null">
  5442. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5443. </if>
  5444. </if>
  5445. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5446. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5447. </if>
  5448. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5449. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5450. </if>
  5451. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  5452. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  5453. </if>
  5454. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5455. AND b.`level` = #{qcResultShortPageVO.level}
  5456. </if>
  5457. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5458. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5459. </if>
  5460. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5461. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5462. </if>
  5463. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5464. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5465. </if>
  5466. <if test="qcResultShortPageVO.casesEntryId != null ">
  5467. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5468. </if>
  5469. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5470. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5471. </if>
  5472. <if test="qcResultShortPageVO.casesId != null">
  5473. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5474. </if>
  5475. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5476. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  5477. </if>
  5478. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5479. AND(case
  5480. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  5481. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5482. e.director_doctor != '' and e.director_doctor is not null
  5483. then e.director_doctor
  5484. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5485. (e.director_doctor = '' or e.director_doctor is null) and
  5486. e.behospital_doctor != '' and e.behospital_doctor is not null
  5487. then e.behospital_doctor end ) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5488. </if>
  5489. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  5490. AND(case
  5491. when e.attending_doctor != '' and e.attending_doctor is not null then '主治医师'
  5492. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5493. e.director_doctor != '' and e.director_doctor is not null
  5494. then '主任医师'
  5495. when (e.attending_doctor = '' or e.attending_doctor is null) and
  5496. (e.director_doctor = '' or e.director_doctor is null) and
  5497. e.behospital_doctor != '' and e.behospital_doctor is not null
  5498. then '住院医师' end) = #{qcResultShortPageVO.professor}
  5499. </if>
  5500. <if test="qcResultShortPageVO.isReject != null">
  5501. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5502. </if>
  5503. <if test="qcResultShortPageVO.ruleType != null">
  5504. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5505. </if>
  5506. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5507. AND TIMESTAMPDIFF(
  5508. DAY,
  5509. DATE( a.behospital_date ),
  5510. DATE( a.leave_hospital_date ))> 30
  5511. </if>
  5512. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5513. AND TIMESTAMPDIFF(
  5514. DAY,
  5515. DATE( a.behospital_date ),
  5516. DATE( a.leave_hospital_date ))> 31
  5517. </if>
  5518. )be
  5519. left join med_check_info mci
  5520. on mci.is_deleted = 'N'
  5521. and mci.check_type = 0
  5522. and be.hospital_id = mci.hospital_id
  5523. and be.behospital_code = mci.behospital_code
  5524. left join med_check_info hm_mci
  5525. on hm_mci.is_deleted = 'N'
  5526. and hm_mci.check_type = 1
  5527. and be.hospital_id = hm_mci.hospital_id
  5528. and be.behospital_code = hm_mci.behospital_code
  5529. LEFT JOIN med_qcresult_cases e
  5530. on be.behospital_code = e.behospital_code
  5531. and be.hospital_id = e.hospital_id
  5532. AND e.is_deleted = 'N'
  5533. and e.cases_id = 243
  5534. )tt1
  5535. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5536. ,med_medical_record tt2
  5537. WHERE
  5538. tt2.is_deleted = 'N'
  5539. AND tt1.hospital_id = tt2.hospital_id
  5540. AND tt1.behospital_code = tt2.behospital_code
  5541. AND tt2.mode_id = 30
  5542. </if>
  5543. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5544. ,med_crisis_info tt2
  5545. WHERE
  5546. tt2.is_deleted = 'N'
  5547. AND tt1.hospital_id = tt2.hospital_id
  5548. AND tt1.behospital_code = tt2.behospital_code
  5549. </if>
  5550. ) t1
  5551. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5552. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5553. AND t1.behospital_code = t2.behospital_code
  5554. AND t2.is_deleted = 'N'
  5555. </if>
  5556. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5557. , med_home_page t2
  5558. , med_home_operation_info t3
  5559. WHERE t1.hospital_id = t2.hospital_id
  5560. AND t1.behospital_code = t2.behospital_code
  5561. AND t2.home_page_id = t3.home_page_id
  5562. AND t2.is_deleted = 'N'
  5563. AND t3.is_deleted = 'N'
  5564. </if>
  5565. ) t
  5566. where 1=1
  5567. <if test="qcResultShortPageVO.checkStatus != null">
  5568. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5569. </if>
  5570. <if test="qcResultShortPageVO.mrStatus != null">
  5571. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5572. </if>
  5573. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5574. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5575. </if>
  5576. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5577. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5578. </if>
  5579. <if test="qcResultShortPageVO.chTimeStart != null ">
  5580. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5581. </if>
  5582. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5583. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5584. </if>
  5585. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5586. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5587. </if>
  5588. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5589. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5590. </if>
  5591. </select>
  5592. <!-- 条目缺陷质控评分页(内页)-->
  5593. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5594. SELECT t.*
  5595. FROM
  5596. (SELECT DISTINCT
  5597. t1.hospital_id AS hospitalId,
  5598. t1.behospital_code AS behospitalCode,
  5599. t1.bed_code AS bedCode,
  5600. t1.LEVEL AS LEVEL,
  5601. t1.grade_type AS gradeType,
  5602. t1.score_res AS scoreRes,
  5603. t1.scoreBn,
  5604. t1.NAME AS NAME,
  5605. t1.sex AS sex,
  5606. t1.beh_dept_id AS behDeptId,
  5607. t1.beh_dept_name AS behDeptName,
  5608. t1.doctor_id AS doctorId,
  5609. t1.doctor_name AS doctorName,
  5610. t1.beh_doctor_id AS behDoctorId,
  5611. t1.beh_doctor_name AS behDoctorName,
  5612. t1.director_doctor_id AS directorDoctorId,
  5613. t1.director_doctor_name AS directorDoctorName,
  5614. t1.birthday AS birthday,
  5615. t1.behospital_date AS behospitalDate,
  5616. t1.leave_hospital_date AS leaveHospitalDate,
  5617. t1.placefile_date AS placefileDate,
  5618. t1.gmt_create AS gradeTime,
  5619. t1.diagnose,
  5620. t1.ward_name AS wardName,
  5621. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5622. t1.file_code AS fileCode,
  5623. t1.checkStatus,
  5624. t1.mrStatus,
  5625. t1.chName,
  5626. t1.mrName,
  5627. t1.chTime,
  5628. t1.mrTime
  5629. FROM
  5630. (
  5631. SELECT DISTINCT
  5632. tt1.*
  5633. FROM
  5634. (SELECT
  5635. be.*,
  5636. ifnull(mci.status,0) AS checkStatus,
  5637. ifnull(hm_mci.status,0) AS mrStatus,
  5638. mci.check_name as chName,
  5639. e.score_res as scoreBn,
  5640. hm_mci.check_name as mrName,
  5641. mci.gmt_create as chTime,
  5642. hm_mci.gmt_create as mrTime
  5643. FROM
  5644. (
  5645. SELECT DISTINCT
  5646. a.hospital_id,
  5647. a.behospital_code,
  5648. a.bed_code,
  5649. a.file_code,
  5650. b.LEVEL,
  5651. b.grade_type,
  5652. b.score_res,
  5653. a.NAME,
  5654. a.sex,
  5655. a.beh_dept_id,
  5656. a.beh_dept_name,
  5657. a.birthday,
  5658. a.behospital_date,
  5659. a.leave_hospital_date,
  5660. a.doctor_id,
  5661. a.doctor_name,
  5662. a.beh_doctor_id,
  5663. a.beh_doctor_name,
  5664. a.director_doctor_id,
  5665. a.director_doctor_name,
  5666. a.diagnose,
  5667. a.placefile_date,
  5668. a.ward_name,
  5669. b.gmt_create
  5670. FROM
  5671. med_behospital_info a,
  5672. med_qcresult_info b,
  5673. med_qcresult_detail c,
  5674. qc_cases_entry d
  5675. WHERE
  5676. a.is_deleted = 'N'
  5677. AND b.is_deleted = 'N'
  5678. AND c.is_deleted = 'N'
  5679. AND d.is_deleted = 'N'
  5680. AND a.hospital_id = b.hospital_id
  5681. AND a.hospital_id = c.hospital_id
  5682. AND a.behospital_code = b.behospital_code
  5683. AND a.behospital_code = c.behospital_code
  5684. AND c.cases_id = d.cases_id
  5685. AND c.cases_entry_id = d.id
  5686. AND a.qc_type_id != 0
  5687. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5688. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5689. </if>
  5690. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5691. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5692. </if>
  5693. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5694. <if test="qcResultShortPageVO.startDate != null ">
  5695. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5696. </if>
  5697. <if test="qcResultShortPageVO.endDate != null ">
  5698. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5699. </if>
  5700. </if>
  5701. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5702. <if test="qcResultShortPageVO.startDate != null ">
  5703. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5704. </if>
  5705. <if test="qcResultShortPageVO.endDate != null">
  5706. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5707. </if>
  5708. </if>
  5709. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5710. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5711. </if>
  5712. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5713. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5714. </if>
  5715. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5716. AND b.`level` = #{qcResultShortPageVO.level}
  5717. </if>
  5718. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5719. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5720. </if>
  5721. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5722. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5723. </if>
  5724. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5725. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5726. </if>
  5727. <if test="qcResultShortPageVO.casesEntryId != null ">
  5728. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5729. </if>
  5730. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5731. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5732. </if>
  5733. <if test="qcResultShortPageVO.casesId != null">
  5734. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5735. </if>
  5736. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5737. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5738. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5739. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5740. </if>
  5741. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5742. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5743. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5744. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5745. </if>
  5746. <if test="qcResultShortPageVO.isReject != null">
  5747. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5748. </if>
  5749. <if test="qcResultShortPageVO.ruleType != null">
  5750. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5751. </if>
  5752. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5753. AND TIMESTAMPDIFF(
  5754. DAY,
  5755. DATE( a.behospital_date ),
  5756. DATE( a.leave_hospital_date ))> 30
  5757. </if>
  5758. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5759. AND TIMESTAMPDIFF(
  5760. DAY,
  5761. DATE( a.behospital_date ),
  5762. DATE( a.leave_hospital_date ))> 31
  5763. </if>
  5764. )be
  5765. left join med_check_info mci
  5766. on mci.is_deleted = 'N'
  5767. and mci.check_type = 0
  5768. and be.hospital_id = mci.hospital_id
  5769. and be.behospital_code = mci.behospital_code
  5770. left join med_check_info hm_mci
  5771. on hm_mci.is_deleted = 'N'
  5772. and hm_mci.check_type = 1
  5773. and be.hospital_id = hm_mci.hospital_id
  5774. and be.behospital_code = hm_mci.behospital_code
  5775. LEFT JOIN med_qcresult_cases e
  5776. on be.behospital_code = e.behospital_code
  5777. and be.hospital_id = e.hospital_id
  5778. AND e.is_deleted = 'N'
  5779. and e.cases_id = 243
  5780. )tt1
  5781. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5782. ,med_medical_record tt2
  5783. WHERE
  5784. tt2.is_deleted = 'N'
  5785. AND tt1.hospital_id = tt2.hospital_id
  5786. AND tt1.behospital_code = tt2.behospital_code
  5787. AND tt2.mode_id = 30
  5788. </if>
  5789. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5790. ,med_crisis_info tt2
  5791. WHERE
  5792. tt2.is_deleted = 'N'
  5793. AND tt1.hospital_id = tt2.hospital_id
  5794. AND tt1.behospital_code = tt2.behospital_code
  5795. </if>
  5796. ) t1
  5797. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5798. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5799. AND t1.behospital_code = t2.behospital_code
  5800. AND t2.is_deleted = 'N'
  5801. </if>
  5802. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5803. , med_home_page t2
  5804. , med_home_operation_info t3
  5805. WHERE t1.hospital_id = t2.hospital_id
  5806. AND t1.behospital_code = t2.behospital_code
  5807. AND t2.home_page_id = t3.home_page_id
  5808. AND t2.is_deleted = 'N'
  5809. AND t3.is_deleted = 'N'
  5810. </if>
  5811. ) t
  5812. where 1=1
  5813. <if test="qcResultShortPageVO.checkStatus != null">
  5814. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5815. </if>
  5816. <if test="qcResultShortPageVO.mrStatus != null">
  5817. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5818. </if>
  5819. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5820. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5821. </if>
  5822. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5823. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5824. </if>
  5825. <if test="qcResultShortPageVO.chTimeStart != null ">
  5826. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5827. </if>
  5828. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5829. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5830. </if>
  5831. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5832. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5833. </if>
  5834. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5835. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5836. </if>
  5837. </select>
  5838. <!-- 条目缺陷质控评分页-科室(内页)-->
  5839. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5840. SELECT t.*
  5841. FROM
  5842. (SELECT DISTINCT
  5843. t1.hospital_id AS hospitalId,
  5844. t1.behospital_code AS behospitalCode,
  5845. t1.bed_code AS bedCode,
  5846. t1.LEVEL AS LEVEL,
  5847. t1.grade_type AS gradeType,
  5848. t1.score_res AS scoreRes,
  5849. t1.scoreBn,
  5850. t1.NAME AS NAME,
  5851. t1.sex AS sex,
  5852. t1.beh_dept_id AS behDeptId,
  5853. t1.beh_dept_name AS behDeptName,
  5854. t1.doctor_id AS doctorId,
  5855. t1.doctor_name AS doctorName,
  5856. t1.beh_doctor_id AS behDoctorId,
  5857. t1.beh_doctor_name AS behDoctorName,
  5858. t1.director_doctor_id AS directorDoctorId,
  5859. t1.director_doctor_name AS directorDoctorName,
  5860. t1.birthday AS birthday,
  5861. t1.behospital_date AS behospitalDate,
  5862. t1.leave_hospital_date AS leaveHospitalDate,
  5863. t1.placefile_date AS placefileDate,
  5864. t1.gmt_create AS gradeTime,
  5865. t1.diagnose,
  5866. t1.ward_name AS wardName,
  5867. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5868. t1.file_code AS fileCode,
  5869. t1.checkStatus,
  5870. t1.mrStatus,
  5871. t1.chName,
  5872. t1.mrName,
  5873. t1.chTime,
  5874. t1.mrTime
  5875. FROM
  5876. (
  5877. SELECT DISTINCT
  5878. tt1.*
  5879. FROM
  5880. (SELECT
  5881. be.*,
  5882. ifnull(mci.status,0) AS checkStatus,
  5883. ifnull(hm_mci.status,0) AS mrStatus,
  5884. mci.check_name as chName,
  5885. e.score_res as scoreBn,
  5886. hm_mci.check_name as mrName,
  5887. mci.gmt_create as chTime,
  5888. hm_mci.gmt_create as mrTime
  5889. FROM
  5890. (
  5891. SELECT DISTINCT
  5892. a.hospital_id,
  5893. a.behospital_code,
  5894. a.bed_code,
  5895. a.file_code,
  5896. b.LEVEL,
  5897. b.grade_type,
  5898. b.score_res,
  5899. a.NAME,
  5900. a.sex,
  5901. a.beh_dept_id,
  5902. a.beh_dept_name,
  5903. a.birthday,
  5904. a.behospital_date,
  5905. a.leave_hospital_date,
  5906. a.doctor_id,
  5907. a.doctor_name,
  5908. a.beh_doctor_id,
  5909. a.beh_doctor_name,
  5910. a.director_doctor_id,
  5911. a.director_doctor_name,
  5912. a.diagnose,
  5913. a.placefile_date,
  5914. a.ward_name,
  5915. b.gmt_create
  5916. FROM
  5917. med_behospital_info a,
  5918. med_qcresult_info b,
  5919. med_qcresult_detail c,
  5920. qc_cases_entry d,
  5921. sys_user_dept e
  5922. WHERE
  5923. a.is_deleted = 'N'
  5924. AND b.is_deleted = 'N'
  5925. AND c.is_deleted = 'N'
  5926. AND d.is_deleted = 'N'
  5927. AND e.is_deleted = 'N'
  5928. AND a.hospital_id = b.hospital_id
  5929. AND a.hospital_id = c.hospital_id
  5930. AND a.hospital_id = e.hospital_id
  5931. AND a.behospital_code = b.behospital_code
  5932. AND a.behospital_code = c.behospital_code
  5933. AND a.beh_dept_id = e.dept_id
  5934. AND c.cases_id = d.cases_id
  5935. AND c.cases_entry_id = d.id
  5936. AND a.qc_type_id != 0
  5937. <if test="qcResultShortPageVO.userId!=null">
  5938. AND e.user_id = #{qcResultShortPageVO.userId}
  5939. </if>
  5940. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5941. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5942. </if>
  5943. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5944. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5945. </if>
  5946. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5947. <if test="qcResultShortPageVO.startDate != null ">
  5948. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5949. </if>
  5950. <if test="qcResultShortPageVO.endDate != null ">
  5951. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5952. </if>
  5953. </if>
  5954. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5955. <if test="qcResultShortPageVO.startDate != null ">
  5956. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5957. </if>
  5958. <if test="qcResultShortPageVO.endDate != null">
  5959. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5960. </if>
  5961. </if>
  5962. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5963. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5964. </if>
  5965. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5966. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5967. </if>
  5968. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  5969. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  5970. </if>
  5971. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5972. AND b.`level` = #{qcResultShortPageVO.level}
  5973. </if>
  5974. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5975. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5976. </if>
  5977. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5978. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5979. </if>
  5980. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5981. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5982. </if>
  5983. <if test="qcResultShortPageVO.casesEntryId != null ">
  5984. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5985. </if>
  5986. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5987. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5988. </if>
  5989. <if test="qcResultShortPageVO.casesId != null">
  5990. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5991. </if>
  5992. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5993. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  5994. </if>
  5995. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5996. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5997. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5998. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5999. </if>
  6000. <if test="qcResultShortPageVO.isReject != null">
  6001. AND c.is_reject = #{qcResultShortPageVO.isReject}
  6002. </if>
  6003. <if test="qcResultShortPageVO.ruleType != null">
  6004. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  6005. </if>
  6006. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  6007. AND TIMESTAMPDIFF(
  6008. DAY,
  6009. DATE( a.behospital_date ),
  6010. DATE( a.leave_hospital_date ))> 30
  6011. </if>
  6012. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  6013. AND TIMESTAMPDIFF(
  6014. DAY,
  6015. DATE( a.behospital_date ),
  6016. DATE( a.leave_hospital_date ))> 31
  6017. </if>
  6018. )be
  6019. left join med_check_info mci
  6020. on mci.is_deleted = 'N'
  6021. and mci.check_type = 0
  6022. and be.hospital_id = mci.hospital_id
  6023. and be.behospital_code = mci.behospital_code
  6024. left join med_check_info hm_mci
  6025. on hm_mci.is_deleted = 'N'
  6026. and hm_mci.check_type = 1
  6027. and be.hospital_id = hm_mci.hospital_id
  6028. and be.behospital_code = hm_mci.behospital_code
  6029. LEFT JOIN med_qcresult_cases e
  6030. on be.behospital_code = e.behospital_code
  6031. and be.hospital_id = e.hospital_id
  6032. AND e.is_deleted = 'N'
  6033. and e.cases_id = 243
  6034. )tt1
  6035. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  6036. ,med_medical_record tt2
  6037. WHERE
  6038. tt2.is_deleted = 'N'
  6039. AND tt1.hospital_id = tt2.hospital_id
  6040. AND tt1.behospital_code = tt2.behospital_code
  6041. AND tt2.mode_id = 30
  6042. </if>
  6043. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  6044. ,med_crisis_info tt2
  6045. WHERE
  6046. tt2.is_deleted = 'N'
  6047. AND tt1.hospital_id = tt2.hospital_id
  6048. AND tt1.behospital_code = tt2.behospital_code
  6049. </if>
  6050. ) t1
  6051. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  6052. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  6053. AND t1.behospital_code = t2.behospital_code
  6054. AND t2.is_deleted = 'N'
  6055. </if>
  6056. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  6057. , med_home_page t2
  6058. , med_home_operation_info t3
  6059. WHERE t1.hospital_id = t2.hospital_id
  6060. AND t1.behospital_code = t2.behospital_code
  6061. AND t2.home_page_id = t3.home_page_id
  6062. AND t2.is_deleted = 'N'
  6063. AND t3.is_deleted = 'N'
  6064. </if>
  6065. ) t
  6066. where 1=1
  6067. <if test="qcResultShortPageVO.checkStatus != null">
  6068. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6069. </if>
  6070. <if test="qcResultShortPageVO.mrStatus != null">
  6071. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6072. </if>
  6073. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6074. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6075. </if>
  6076. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6077. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6078. </if>
  6079. <if test="qcResultShortPageVO.chTimeStart != null ">
  6080. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6081. </if>
  6082. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6083. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6084. </if>
  6085. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6086. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6087. </if>
  6088. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6089. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6090. </if>
  6091. </select>
  6092. <update id="updateBatchByKey">
  6093. <foreach collection="list" item="item" separator=";">
  6094. update med_behospital_info
  6095. <set>
  6096. <if test="item.name != null">
  6097. name = #{item.name},
  6098. </if>
  6099. <if test="item.sex != null">
  6100. sex = #{item.sex},
  6101. </if>
  6102. <if test="item.birthday != null">
  6103. birthday = #{item.birthday},
  6104. </if>
  6105. <if test="item.fileCode != null">
  6106. file_code = #{item.fileCode},
  6107. </if>
  6108. <if test="item.qcTypeId != null">
  6109. qc_type_id = #{item.qcTypeId},
  6110. </if>
  6111. <if test="item.wardCode != null">
  6112. ward_code = #{item.wardCode},
  6113. </if>
  6114. <if test="item.wardName != null">
  6115. ward_name = #{item.wardName},
  6116. </if>
  6117. <if test="item.behDeptId != null">
  6118. beh_dept_id = #{item.behDeptId},
  6119. </if>
  6120. <if test="item.behDeptName != null">
  6121. beh_dept_name = #{item.behDeptName},
  6122. </if>
  6123. <if test="item.bedCode != null">
  6124. bed_code = #{item.bedCode},
  6125. </if>
  6126. <if test="item.bedName != null">
  6127. bed_name = #{item.bedName},
  6128. </if>
  6129. <if test="item.insuranceName != null">
  6130. insurance_name = #{item.insuranceName},
  6131. </if>
  6132. <if test="item.jobType != null">
  6133. job_type = #{item.jobType},
  6134. </if>
  6135. <if test="item.behospitalDate != null">
  6136. behospital_date = #{item.behospitalDate},
  6137. </if>
  6138. <if test="item.leaveHospitalDate != null">
  6139. leave_hospital_date = #{item.leaveHospitalDate},
  6140. </if>
  6141. <if test="item.diagnoseIcd != null">
  6142. diagnose_icd = #{item.diagnoseIcd},
  6143. </if>
  6144. <if test="item.diagnose != null">
  6145. diagnose = #{item.diagnose},
  6146. </if>
  6147. <if test="item.behDoctorId != null">
  6148. beh_doctor_id = #{item.behDoctorId},
  6149. </if>
  6150. <if test="item.behDoctorName != null">
  6151. beh_doctor_name = #{item.behDoctorName},
  6152. </if>
  6153. <if test="item.doctorId != null">
  6154. doctor_id = #{item.doctorId},
  6155. </if>
  6156. <if test="item.doctorName != null">
  6157. doctor_name = #{item.doctorName},
  6158. </if>
  6159. <if test="item.directorDoctorId != null">
  6160. director_doctor_id = #{item.directorDoctorId},
  6161. </if>
  6162. <if test="item.directorDoctorName != null">
  6163. director_doctor_name = #{item.directorDoctorName},
  6164. </if>
  6165. <if test="item.placefileDate != null">
  6166. placefile_date = #{item.placefileDate},
  6167. </if>
  6168. <if test="item.isPlacefile != null">
  6169. is_placefile = #{item.isPlacefile},
  6170. </if>
  6171. <if test="item.gmtModified != null">
  6172. gmt_modified = #{item.gmtModified},
  6173. </if>
  6174. <if test="item.modifier != null">
  6175. modifier = #{item.modifier},
  6176. </if>
  6177. </set>
  6178. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  6179. </foreach>
  6180. </update>
  6181. <!-- 关键条目缺陷统计报表-->
  6182. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  6183. SELECT
  6184. deptId,
  6185. deptName,
  6186. consultationMRNum,
  6187. consultationNum,
  6188. 2511 AS consultationEntryId,
  6189. '普通会诊未在24小时内完成' AS consultationEntryName,
  6190. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6191. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6192. operationMRNum,
  6193. 2594 AS operationNameEntryId,
  6194. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6195. operationNameNum,
  6196. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6197. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6198. 2973 AS operationTimeEntryId,
  6199. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6200. operationTimeNum,
  6201. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6202. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6203. 2930 AS operation15MinuteEntryId,
  6204. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6205. operation15MinuteNum,
  6206. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6207. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6208. 2419 AS crisisEntryId,
  6209. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6210. crisisMRNum,
  6211. crisisNum,
  6212. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6213. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6214. 2495 AS stageSummaryEntryId,
  6215. '无阶段小结' AS stageSummaryEntryName,
  6216. stageSummaryMRNum,
  6217. stageSummaryNum,
  6218. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6219. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6220. beHosGT31DaysMRNum
  6221. FROM
  6222. (
  6223. SELECT
  6224. tt.deptId,
  6225. tt.deptName,
  6226. sum( tt.consultationNum ) AS consultationNum,
  6227. sum( tt.consultationMRNum ) AS consultationMRNum,
  6228. sum( tt.operationNameNum ) AS operationNameNum,
  6229. sum( tt.operationTimeNum ) AS operationTimeNum,
  6230. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6231. sum( tt.operationMRNum ) AS operationMRNum,
  6232. sum( tt.crisisNum ) AS crisisNum,
  6233. sum( tt.crisisMRNum ) AS crisisMRNum,
  6234. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6235. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6236. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6237. FROM
  6238. (
  6239. (
  6240. SELECT
  6241. c.beh_dept_id AS deptId,
  6242. c.beh_dept_name AS deptName,
  6243. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6244. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6245. 0 AS operationNameNum,
  6246. 0 AS operationTimeNum,
  6247. 0 AS operation15MinuteNum,
  6248. 0 AS operationMRNum,
  6249. 0 AS crisisNum,
  6250. 0 AS crisisMRNum,
  6251. 0 AS stageSummaryNum,
  6252. 0 AS stageSummaryMRNum,
  6253. 0 AS beHosGT31DaysMRNum
  6254. FROM
  6255. (
  6256. SELECT DISTINCT
  6257. a.hospital_id,
  6258. a.behospital_code,
  6259. a.beh_dept_name,
  6260. a.beh_dept_id
  6261. FROM
  6262. med_behospital_info a,
  6263. med_medical_record b
  6264. WHERE
  6265. a.is_deleted = 'N'
  6266. AND b.is_deleted = 'N'
  6267. AND a.hospital_id = b.hospital_id
  6268. AND a.behospital_code = b.behospital_code
  6269. AND b.mode_id = 30
  6270. <if test="isPlacefile != null and isPlacefile != ''">
  6271. and a.is_placefile = #{isPlacefile}
  6272. </if>
  6273. AND a.qc_type_id != 0
  6274. <if test="hospitalId != null and hospitalId != ''">
  6275. AND a.hospital_id = #{hospitalId}
  6276. </if>
  6277. <if test="isPlacefile != null and isPlacefile == 0">
  6278. <if test="startDate != null ">
  6279. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6280. </if>
  6281. <if test="endDate != null ">
  6282. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6283. </if>
  6284. </if>
  6285. <if test="isPlacefile != null and isPlacefile == 1">
  6286. <if test="startDate != null ">
  6287. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6288. </if>
  6289. <if test="endDate != null ">
  6290. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6291. </if>
  6292. </if>
  6293. <if test="deptName != null and deptName != ''">
  6294. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6295. </if>
  6296. ) c
  6297. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6298. AND c.hospital_id = d.hospital_id
  6299. AND c.behospital_code = d.behospital_code
  6300. GROUP BY
  6301. c.beh_dept_id,
  6302. c.beh_dept_name
  6303. ) UNION
  6304. (
  6305. SELECT
  6306. d.beh_dept_id AS deptId,
  6307. d.beh_dept_name AS deptName,
  6308. 0 AS consultationNum,
  6309. 0 AS consultationMRNum,
  6310. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6311. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6312. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6313. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6314. 0 AS crisisNum,
  6315. 0 AS crisisMRNum,
  6316. 0 AS stageSummaryNum,
  6317. 0 AS stageSummaryMRNum,
  6318. 0 AS beHosGT31DaysMRNum
  6319. FROM
  6320. (
  6321. SELECT DISTINCT
  6322. a.hospital_id,
  6323. a.behospital_code,
  6324. a.beh_dept_name,
  6325. a.beh_dept_id
  6326. FROM
  6327. med_behospital_info a,
  6328. med_home_page b,
  6329. med_home_operation_info c
  6330. WHERE
  6331. a.is_deleted = 'N'
  6332. AND b.is_deleted = 'N'
  6333. AND c.is_deleted = 'N'
  6334. AND a.hospital_id = b.hospital_id
  6335. AND a.hospital_id = c.hospital_id
  6336. AND a.behospital_code = b.behospital_code
  6337. AND b.home_page_id = c.home_page_id
  6338. <if test="isPlacefile != null and isPlacefile != ''">
  6339. and a.is_placefile = #{isPlacefile}
  6340. </if>
  6341. AND a.qc_type_id != 0
  6342. <if test="hospitalId != null and hospitalId != ''">
  6343. AND a.hospital_id = #{hospitalId}
  6344. </if>
  6345. <if test="isPlacefile != null and isPlacefile == 0">
  6346. <if test="startDate != null ">
  6347. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6348. </if>
  6349. <if test="endDate != null ">
  6350. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6351. </if>
  6352. </if>
  6353. <if test="isPlacefile != null and isPlacefile == 1">
  6354. <if test="startDate != null ">
  6355. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6356. </if>
  6357. <if test="endDate != null ">
  6358. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6359. </if>
  6360. </if>
  6361. <if test="deptName != null and deptName != ''">
  6362. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6363. </if>
  6364. ) d
  6365. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6366. AND d.hospital_id = e.hospital_id
  6367. AND d.behospital_code = e.behospital_code
  6368. GROUP BY
  6369. d.beh_dept_id,
  6370. d.beh_dept_name
  6371. ) UNION
  6372. (
  6373. SELECT
  6374. c.beh_dept_id AS deptId,
  6375. c.beh_dept_name AS deptName,
  6376. 0 AS consultationNum,
  6377. 0 AS consultationMRNum,
  6378. 0 AS operationNameNum,
  6379. 0 AS operationTimeNum,
  6380. 0 AS operation15MinuteNum,
  6381. 0 AS operationMRNum,
  6382. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6383. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6384. 0 AS stageSummaryNum,
  6385. 0 AS stageSummaryMRNum,
  6386. 0 AS beHosGT31DaysMRNum
  6387. FROM
  6388. (
  6389. SELECT DISTINCT
  6390. a.hospital_id,
  6391. a.behospital_code,
  6392. a.beh_dept_name,
  6393. a.beh_dept_id
  6394. FROM
  6395. med_behospital_info a,
  6396. med_crisis_info b
  6397. WHERE
  6398. a.is_deleted = 'N'
  6399. AND b.is_deleted = 'N'
  6400. AND a.hospital_id = b.hospital_id
  6401. AND a.behospital_code = b.behospital_code
  6402. <if test="isPlacefile != null and isPlacefile != ''">
  6403. and a.is_placefile = #{isPlacefile}
  6404. </if>
  6405. AND a.qc_type_id != 0
  6406. <if test="hospitalId != null and hospitalId != ''">
  6407. AND a.hospital_id = #{hospitalId}
  6408. </if>
  6409. <if test="isPlacefile != null and isPlacefile == 0">
  6410. <if test="startDate != null ">
  6411. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6412. </if>
  6413. <if test="endDate != null ">
  6414. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6415. </if>
  6416. </if>
  6417. <if test="isPlacefile != null and isPlacefile == 1">
  6418. <if test="startDate != null ">
  6419. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6420. </if>
  6421. <if test="endDate != null ">
  6422. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6423. </if>
  6424. </if>
  6425. <if test="deptName != null and deptName != ''">
  6426. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6427. </if>
  6428. ) c
  6429. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6430. AND c.hospital_id = d.hospital_id
  6431. AND c.behospital_code = d.behospital_code
  6432. GROUP BY
  6433. c.beh_dept_id,
  6434. c.beh_dept_name
  6435. ) UNION
  6436. (
  6437. SELECT
  6438. b.beh_dept_id AS deptId,
  6439. b.beh_dept_name AS deptName,
  6440. 0 AS consultationNum,
  6441. 0 AS consultationMRNum,
  6442. 0 AS operationNameNum,
  6443. 0 AS operationTimeNum,
  6444. 0 AS operation15MinuteNum,
  6445. 0 AS operationMRNum,
  6446. 0 AS crisisNum,
  6447. 0 AS crisisMRNum,
  6448. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6449. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6450. 0 AS beHosGT31DaysMRNum
  6451. FROM
  6452. (
  6453. SELECT DISTINCT
  6454. a.hospital_id,
  6455. a.behospital_code,
  6456. a.beh_dept_name,
  6457. a.beh_dept_id
  6458. FROM
  6459. med_behospital_info a
  6460. WHERE
  6461. a.is_deleted = 'N'
  6462. AND TIMESTAMPDIFF(
  6463. DAY,
  6464. DATE( behospital_date ),
  6465. DATE( leave_hospital_date ))> 30
  6466. <if test="isPlacefile != null and isPlacefile != ''">
  6467. and a.is_placefile = #{isPlacefile}
  6468. </if>
  6469. AND a.qc_type_id != 0
  6470. <if test="hospitalId != null and hospitalId != ''">
  6471. AND a.hospital_id = #{hospitalId}
  6472. </if>
  6473. <if test="isPlacefile != null and isPlacefile == 0">
  6474. <if test="startDate != null ">
  6475. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6476. </if>
  6477. <if test="endDate != null ">
  6478. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6479. </if>
  6480. </if>
  6481. <if test="isPlacefile != null and isPlacefile == 1">
  6482. <if test="startDate != null ">
  6483. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6484. </if>
  6485. <if test="endDate != null ">
  6486. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6487. </if>
  6488. </if>
  6489. <if test="deptName != null and deptName != ''">
  6490. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6491. </if>
  6492. ) b
  6493. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6494. AND b.hospital_id = c.hospital_id
  6495. AND b.behospital_code = c.behospital_code
  6496. GROUP BY
  6497. b.beh_dept_id,
  6498. b.beh_dept_name
  6499. ) UNION
  6500. (
  6501. SELECT
  6502. b.beh_dept_id AS deptId,
  6503. b.beh_dept_name AS deptName,
  6504. 0 AS consultationNum,
  6505. 0 AS consultationMRNum,
  6506. 0 AS operationNameNum,
  6507. 0 AS operationTimeNum,
  6508. 0 AS operation15MinuteNum,
  6509. 0 AS operationMRNum,
  6510. 0 AS crisisNum,
  6511. 0 AS crisisMRNum,
  6512. 0 AS stageSummaryNum,
  6513. 0 AS stageSummaryMRNum,
  6514. count(*) AS beHosGT31DaysMRNum
  6515. FROM
  6516. (
  6517. SELECT DISTINCT
  6518. a.hospital_id,
  6519. a.behospital_code,
  6520. a.beh_dept_name,
  6521. a.beh_dept_id
  6522. FROM
  6523. med_behospital_info a,
  6524. med_qcresult_info b,
  6525. med_qcresult_detail c,
  6526. qc_cases_entry d
  6527. WHERE
  6528. a.is_deleted = 'N'
  6529. AND b.is_deleted = 'N'
  6530. AND c.is_deleted = 'N'
  6531. AND d.is_deleted = 'N'
  6532. AND a.hospital_id = b.hospital_id
  6533. AND a.hospital_id = c.hospital_id
  6534. AND a.behospital_code = b.behospital_code
  6535. AND a.behospital_code = c.behospital_code
  6536. AND c.cases_id = d.cases_id
  6537. AND c.cases_entry_id = d.id
  6538. AND TIMESTAMPDIFF(
  6539. DAY,
  6540. DATE( behospital_date ),
  6541. DATE( leave_hospital_date ))> 31
  6542. <if test="isPlacefile != null and isPlacefile != ''">
  6543. and a.is_placefile = #{isPlacefile}
  6544. </if>
  6545. AND a.qc_type_id != 0
  6546. <if test="hospitalId != null and hospitalId != ''">
  6547. AND a.hospital_id = #{hospitalId}
  6548. </if>
  6549. <if test="isPlacefile != null and isPlacefile == 0">
  6550. <if test="startDate != null ">
  6551. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6552. </if>
  6553. <if test="endDate != null ">
  6554. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6555. </if>
  6556. </if>
  6557. <if test="isPlacefile != null and isPlacefile == 1">
  6558. <if test="startDate != null ">
  6559. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6560. </if>
  6561. <if test="endDate != null ">
  6562. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6563. </if>
  6564. </if>
  6565. <if test="deptName != null and deptName != ''">
  6566. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6567. </if>
  6568. ) b
  6569. GROUP BY
  6570. b.beh_dept_id,
  6571. b.beh_dept_name
  6572. )
  6573. ) tt
  6574. GROUP BY
  6575. tt.deptId,
  6576. tt.deptName
  6577. ) t
  6578. <if test="asc != null and asc !=''">
  6579. order by
  6580. <choose>
  6581. <when test='asc=="deptId"'>deptId asc</when>
  6582. <when test='asc=="deptName"'>deptName asc</when>
  6583. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6584. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6585. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6586. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6587. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6588. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6589. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6590. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6591. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6592. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6593. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6594. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6595. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6596. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6597. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6598. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6599. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6600. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6601. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6602. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6603. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6604. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6605. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6606. <otherwise>deptName asc</otherwise>
  6607. </choose>
  6608. </if>
  6609. <if test="desc != null and desc!=''">
  6610. order by
  6611. <choose>
  6612. <when test='desc=="deptId"'>deptId desc</when>
  6613. <when test='desc=="deptName"'>deptName desc</when>
  6614. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6615. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6616. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6617. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6618. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6619. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6620. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6621. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6622. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6623. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6624. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6625. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6626. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6627. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6628. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6629. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6630. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6631. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6632. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6633. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6634. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6635. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6636. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6637. <otherwise>deptName desc</otherwise>
  6638. </choose>
  6639. </if>
  6640. </select>
  6641. <!-- 关键条目缺陷统计报表-科室-->
  6642. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6643. SELECT
  6644. deptId,
  6645. deptName,
  6646. doctorName,
  6647. consultationMRNum,
  6648. consultationNum,
  6649. 2511 AS consultationEntryId,
  6650. '普通会诊未在24小时内完成' AS consultationEntryName,
  6651. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6652. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6653. operationMRNum,
  6654. 2594 AS operationNameEntryId,
  6655. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6656. operationNameNum,
  6657. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6658. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6659. 2973 AS operationTimeEntryId,
  6660. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6661. operationTimeNum,
  6662. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6663. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6664. 2930 AS operation15MinuteEntryId,
  6665. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6666. operation15MinuteNum,
  6667. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6668. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6669. 2419 AS crisisEntryId,
  6670. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6671. crisisMRNum,
  6672. crisisNum,
  6673. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6674. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6675. 2495 AS stageSummaryEntryId,
  6676. '无阶段小结' AS stageSummaryEntryName,
  6677. stageSummaryMRNum,
  6678. stageSummaryNum,
  6679. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6680. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6681. beHosGT31DaysMRNum
  6682. FROM
  6683. (
  6684. SELECT
  6685. tt.deptId,
  6686. tt.deptName,
  6687. tt.doctorId,
  6688. tt.doctorName,
  6689. sum( tt.consultationNum ) AS consultationNum,
  6690. sum( tt.consultationMRNum ) AS consultationMRNum,
  6691. sum( tt.operationNameNum ) AS operationNameNum,
  6692. sum( tt.operationTimeNum ) AS operationTimeNum,
  6693. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6694. sum( tt.operationMRNum ) AS operationMRNum,
  6695. sum( tt.crisisNum ) AS crisisNum,
  6696. sum( tt.crisisMRNum ) AS crisisMRNum,
  6697. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6698. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6699. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6700. FROM
  6701. (
  6702. (
  6703. SELECT
  6704. c.beh_dept_id AS deptId,
  6705. c.beh_dept_name AS deptName,
  6706. c.doctorId,
  6707. c.doctorName,
  6708. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6709. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6710. 0 AS operationNameNum,
  6711. 0 AS operationTimeNum,
  6712. 0 AS operation15MinuteNum,
  6713. 0 AS operationMRNum,
  6714. 0 AS crisisNum,
  6715. 0 AS crisisMRNum,
  6716. 0 AS stageSummaryNum,
  6717. 0 AS stageSummaryMRNum,
  6718. 0 AS beHosGT31DaysMRNum
  6719. FROM
  6720. (
  6721. SELECT DISTINCT
  6722. a.hospital_id,
  6723. a.behospital_code,
  6724. a.beh_dept_name,
  6725. a.beh_dept_id,
  6726. a.doctor_id as doctorId,
  6727. a.doctor_name as doctorName
  6728. FROM
  6729. med_behospital_info a,
  6730. med_medical_record b,
  6731. sys_user_dept c
  6732. WHERE
  6733. a.is_deleted = 'N'
  6734. AND b.is_deleted = 'N'
  6735. AND c.is_deleted = 'N'
  6736. AND a.hospital_id = b.hospital_id
  6737. AND a.hospital_id = c.hospital_id
  6738. AND a.behospital_code = b.behospital_code
  6739. AND a.beh_dept_id = c.dept_id
  6740. AND b.mode_id = 30
  6741. <if test="userId!=null">
  6742. AND c.user_id = #{userId}
  6743. </if>
  6744. <if test="isPlacefile != null and isPlacefile != ''">
  6745. and a.is_placefile = #{isPlacefile}
  6746. </if>
  6747. AND a.qc_type_id != 0
  6748. <if test="hospitalId != null and hospitalId != ''">
  6749. AND a.hospital_id = #{hospitalId}
  6750. </if>
  6751. <if test="isPlacefile != null and isPlacefile == 0">
  6752. <if test="startDate != null ">
  6753. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6754. </if>
  6755. <if test="endDate != null ">
  6756. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6757. </if>
  6758. </if>
  6759. <if test="isPlacefile != null and isPlacefile == 1">
  6760. <if test="startDate != null ">
  6761. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6762. </if>
  6763. <if test="endDate != null ">
  6764. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6765. </if>
  6766. </if>
  6767. <if test="doctorName != null and doctorName != ''">
  6768. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6769. </if>
  6770. <if test="deptName != null and deptName != ''">
  6771. AND a.beh_dept_name = #{deptName}
  6772. </if>
  6773. ) c
  6774. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6775. AND c.hospital_id = d.hospital_id
  6776. AND c.behospital_code = d.behospital_code
  6777. GROUP BY
  6778. c.doctorId,
  6779. c.doctorName
  6780. ) UNION
  6781. (
  6782. SELECT
  6783. d.beh_dept_id AS deptId,
  6784. d.beh_dept_name AS deptName,
  6785. d.doctor_id as doctorId,
  6786. d.doctor_name as doctorName,
  6787. 0 AS consultationNum,
  6788. 0 AS consultationMRNum,
  6789. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6790. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6791. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6792. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6793. 0 AS crisisNum,
  6794. 0 AS crisisMRNum,
  6795. 0 AS stageSummaryNum,
  6796. 0 AS stageSummaryMRNum,
  6797. 0 AS beHosGT31DaysMRNum
  6798. FROM
  6799. (
  6800. SELECT DISTINCT
  6801. a.hospital_id,
  6802. a.behospital_code,
  6803. a.beh_dept_name,
  6804. a.beh_dept_id,
  6805. a.doctor_id,
  6806. a.doctor_name
  6807. FROM
  6808. med_behospital_info a,
  6809. med_home_page b,
  6810. med_home_operation_info c,
  6811. sys_user_dept d
  6812. WHERE
  6813. a.is_deleted = 'N'
  6814. AND b.is_deleted = 'N'
  6815. AND c.is_deleted = 'N'
  6816. AND d.is_deleted = 'N'
  6817. AND a.hospital_id = b.hospital_id
  6818. AND a.hospital_id = c.hospital_id
  6819. AND a.hospital_id = d.hospital_id
  6820. AND a.behospital_code = b.behospital_code
  6821. AND b.home_page_id = c.home_page_id
  6822. AND a.beh_dept_id = d.dept_id
  6823. <if test="userId!=null">
  6824. AND d.user_id = #{userId}
  6825. </if>
  6826. <if test="isPlacefile != null and isPlacefile != ''">
  6827. and a.is_placefile = #{isPlacefile}
  6828. </if>
  6829. AND a.qc_type_id != 0
  6830. <if test="hospitalId != null and hospitalId != ''">
  6831. AND a.hospital_id = #{hospitalId}
  6832. </if>
  6833. <if test="isPlacefile != null and isPlacefile == 0">
  6834. <if test="startDate != null ">
  6835. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6836. </if>
  6837. <if test="endDate != null ">
  6838. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6839. </if>
  6840. </if>
  6841. <if test="isPlacefile != null and isPlacefile == 1">
  6842. <if test="startDate != null ">
  6843. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6844. </if>
  6845. <if test="endDate != null ">
  6846. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6847. </if>
  6848. </if>
  6849. <if test="doctorName != null and doctorName != ''">
  6850. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6851. </if>
  6852. <if test="deptName != null and deptName != ''">
  6853. AND a.beh_dept_name = #{deptName}
  6854. </if>
  6855. ) d
  6856. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6857. AND d.hospital_id = e.hospital_id
  6858. AND d.behospital_code = e.behospital_code
  6859. GROUP BY
  6860. d.doctor_id,
  6861. d.doctor_name
  6862. ) UNION
  6863. (
  6864. SELECT
  6865. c.beh_dept_id AS deptId,
  6866. c.beh_dept_name AS deptName,
  6867. c.doctor_id as doctorId,
  6868. c.doctor_name as doctorName,
  6869. 0 AS consultationNum,
  6870. 0 AS consultationMRNum,
  6871. 0 AS operationNameNum,
  6872. 0 AS operationTimeNum,
  6873. 0 AS operation15MinuteNum,
  6874. 0 AS operationMRNum,
  6875. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6876. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6877. 0 AS stageSummaryNum,
  6878. 0 AS stageSummaryMRNum,
  6879. 0 AS beHosGT31DaysMRNum
  6880. FROM
  6881. (
  6882. SELECT DISTINCT
  6883. a.hospital_id,
  6884. a.behospital_code,
  6885. a.beh_dept_name,
  6886. a.beh_dept_id,
  6887. a.doctor_id,
  6888. a.doctor_name
  6889. FROM
  6890. med_behospital_info a,
  6891. med_crisis_info b,
  6892. sys_user_dept c
  6893. WHERE
  6894. a.is_deleted = 'N'
  6895. AND b.is_deleted = 'N'
  6896. AND c.is_deleted = 'N'
  6897. AND a.hospital_id = b.hospital_id
  6898. AND a.hospital_id = c.hospital_id
  6899. AND a.behospital_code = b.behospital_code
  6900. AND a.beh_dept_id = c.dept_id
  6901. <if test="userId!=null">
  6902. AND c.user_id = #{userId}
  6903. </if>
  6904. <if test="isPlacefile != null and isPlacefile != ''">
  6905. and a.is_placefile = #{isPlacefile}
  6906. </if>
  6907. AND a.qc_type_id != 0
  6908. <if test="hospitalId != null and hospitalId != ''">
  6909. AND a.hospital_id = #{hospitalId}
  6910. </if>
  6911. <if test="isPlacefile != null and isPlacefile == 0">
  6912. <if test="startDate != null ">
  6913. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6914. </if>
  6915. <if test="endDate != null ">
  6916. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6917. </if>
  6918. </if>
  6919. <if test="isPlacefile != null and isPlacefile == 1">
  6920. <if test="startDate != null ">
  6921. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6922. </if>
  6923. <if test="endDate != null ">
  6924. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6925. </if>
  6926. </if>
  6927. <if test="doctorName != null and doctorName != ''">
  6928. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6929. </if>
  6930. <if test="deptName != null and deptName != ''">
  6931. AND a.beh_dept_name = #{deptName}
  6932. </if>
  6933. ) c
  6934. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6935. AND c.hospital_id = d.hospital_id
  6936. AND c.behospital_code = d.behospital_code
  6937. GROUP BY
  6938. c.doctor_id,
  6939. c.doctor_name
  6940. ) UNION
  6941. (
  6942. SELECT
  6943. b.beh_dept_id AS deptId,
  6944. b.beh_dept_name AS deptName,
  6945. b.doctor_id as doctorId,
  6946. b.doctor_name as doctorName,
  6947. 0 AS consultationNum,
  6948. 0 AS consultationMRNum,
  6949. 0 AS operationNameNum,
  6950. 0 AS operationTimeNum,
  6951. 0 AS operation15MinuteNum,
  6952. 0 AS operationMRNum,
  6953. 0 AS crisisNum,
  6954. 0 AS crisisMRNum,
  6955. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6956. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6957. 0 AS beHosGT31DaysMRNum
  6958. FROM
  6959. (
  6960. SELECT DISTINCT
  6961. a.hospital_id,
  6962. a.behospital_code,
  6963. a.beh_dept_name,
  6964. a.beh_dept_id,
  6965. a.doctor_id,
  6966. a.doctor_name
  6967. FROM
  6968. med_behospital_info a,
  6969. sys_user_dept b
  6970. WHERE
  6971. a.is_deleted = 'N'
  6972. AND b.is_deleted = 'N'
  6973. AND a.hospital_id = b.hospital_id
  6974. AND a.beh_dept_id = b.dept_id
  6975. AND TIMESTAMPDIFF(
  6976. DAY,
  6977. DATE( behospital_date ),
  6978. DATE( leave_hospital_date ))> 30
  6979. <if test="userId!=null">
  6980. AND b.user_id = #{userId}
  6981. </if>
  6982. <if test="isPlacefile != null and isPlacefile != ''">
  6983. and a.is_placefile = #{isPlacefile}
  6984. </if>
  6985. AND a.qc_type_id != 0
  6986. <if test="hospitalId != null and hospitalId != ''">
  6987. AND a.hospital_id = #{hospitalId}
  6988. </if>
  6989. <if test="isPlacefile != null and isPlacefile == 0">
  6990. <if test="startDate != null ">
  6991. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6992. </if>
  6993. <if test="endDate != null ">
  6994. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6995. </if>
  6996. </if>
  6997. <if test="isPlacefile != null and isPlacefile == 1">
  6998. <if test="startDate != null ">
  6999. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7000. </if>
  7001. <if test="endDate != null ">
  7002. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7003. </if>
  7004. </if>
  7005. <if test="doctorName != null and doctorName != ''">
  7006. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  7007. </if>
  7008. <if test="deptName != null and deptName != ''">
  7009. AND a.beh_dept_name = #{deptName}
  7010. </if>
  7011. ) b
  7012. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  7013. AND b.hospital_id = c.hospital_id
  7014. AND b.behospital_code = c.behospital_code
  7015. GROUP BY
  7016. b.doctor_id,
  7017. b.doctor_name
  7018. ) UNION
  7019. (
  7020. SELECT
  7021. b.beh_dept_id AS deptId,
  7022. b.beh_dept_name AS deptName,
  7023. b.doctor_id as doctorId,
  7024. b.doctor_name as doctorName,
  7025. 0 AS consultationNum,
  7026. 0 AS consultationMRNum,
  7027. 0 AS operationNameNum,
  7028. 0 AS operationTimeNum,
  7029. 0 AS operation15MinuteNum,
  7030. 0 AS operationMRNum,
  7031. 0 AS crisisNum,
  7032. 0 AS crisisMRNum,
  7033. 0 AS stageSummaryNum,
  7034. 0 AS stageSummaryMRNum,
  7035. count(*) AS beHosGT31DaysMRNum
  7036. FROM
  7037. (
  7038. SELECT DISTINCT
  7039. a.hospital_id,
  7040. a.behospital_code,
  7041. a.beh_dept_name,
  7042. a.beh_dept_id,
  7043. a.doctor_id,
  7044. a.doctor_name
  7045. FROM
  7046. med_behospital_info a,
  7047. med_qcresult_info b,
  7048. med_qcresult_detail c,
  7049. qc_cases_entry d,
  7050. sys_user_dept e
  7051. WHERE
  7052. a.is_deleted = 'N'
  7053. AND b.is_deleted = 'N'
  7054. AND c.is_deleted = 'N'
  7055. AND d.is_deleted = 'N'
  7056. AND e.is_deleted = 'N'
  7057. AND a.hospital_id = b.hospital_id
  7058. AND a.hospital_id = c.hospital_id
  7059. AND a.hospital_id = e.hospital_id
  7060. AND a.behospital_code = b.behospital_code
  7061. AND a.behospital_code = c.behospital_code
  7062. AND c.cases_id = d.cases_id
  7063. AND c.cases_entry_id = d.id
  7064. AND a.beh_dept_id = e.dept_id
  7065. AND TIMESTAMPDIFF(
  7066. DAY,
  7067. DATE( behospital_date ),
  7068. DATE( leave_hospital_date ))> 31
  7069. <if test="userId!=null">
  7070. AND e.user_id = #{userId}
  7071. </if>
  7072. <if test="isPlacefile != null and isPlacefile != ''">
  7073. and a.is_placefile = #{isPlacefile}
  7074. </if>
  7075. AND a.qc_type_id != 0
  7076. <if test="hospitalId != null and hospitalId != ''">
  7077. AND a.hospital_id = #{hospitalId}
  7078. </if>
  7079. <if test="isPlacefile != null and isPlacefile == 0">
  7080. <if test="startDate != null ">
  7081. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7082. </if>
  7083. <if test="endDate != null ">
  7084. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7085. </if>
  7086. </if>
  7087. <if test="isPlacefile != null and isPlacefile == 1">
  7088. <if test="startDate != null ">
  7089. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7090. </if>
  7091. <if test="endDate != null ">
  7092. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7093. </if>
  7094. </if>
  7095. <if test="doctorName != null and doctorName != ''">
  7096. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  7097. </if>
  7098. <if test="deptName != null and deptName != ''">
  7099. AND a.beh_dept_name = #{deptName}
  7100. </if>
  7101. ) b
  7102. GROUP BY
  7103. b.doctor_id,
  7104. b.doctor_name
  7105. )
  7106. ) tt
  7107. GROUP BY
  7108. tt.doctorName
  7109. ) t
  7110. <if test="asc != null and asc !=''">
  7111. order by
  7112. <choose>
  7113. <when test='asc=="deptId"'>deptId asc</when>
  7114. <when test='asc=="deptName"'>deptName asc</when>
  7115. <when test='asc=="doctorName"'>doctorName asc</when>
  7116. <when test='asc=="consultationNum"'>consultationNum asc</when>
  7117. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  7118. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  7119. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  7120. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  7121. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  7122. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  7123. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  7124. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  7125. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  7126. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  7127. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  7128. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  7129. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  7130. <when test='asc=="crisisNum"'>crisisNum asc</when>
  7131. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  7132. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  7133. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  7134. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  7135. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  7136. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  7137. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  7138. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  7139. <otherwise>doctorName asc</otherwise>
  7140. </choose>
  7141. </if>
  7142. <if test="desc != null and desc!=''">
  7143. order by
  7144. <choose>
  7145. <when test='desc=="deptId"'>deptId desc</when>
  7146. <when test='desc=="doctorName"'>doctorName desc</when>
  7147. <when test='desc=="deptName"'>deptName desc</when>
  7148. <when test='desc=="consultationNum"'>consultationNum desc</when>
  7149. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  7150. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  7151. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  7152. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  7153. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  7154. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  7155. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  7156. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  7157. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  7158. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  7159. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  7160. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  7161. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  7162. <when test='desc=="crisisNum"'>crisisNum desc</when>
  7163. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  7164. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  7165. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  7166. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  7167. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  7168. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  7169. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  7170. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  7171. <otherwise>doctorName desc</otherwise>
  7172. </choose>
  7173. </if>
  7174. </select>
  7175. <!-- 非医嘱离院病人记录-->
  7176. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  7177. SELECT
  7178. count(*)
  7179. FROM
  7180. med_behospital_info a,
  7181. med_home_page b
  7182. WHERE
  7183. a.is_deleted = 'N'
  7184. AND b.is_deleted = 'N'
  7185. AND a.hospital_id = b.hospital_id
  7186. AND a.behospital_code = b.behospital_code
  7187. AND b.leave_hospital_type = '非医嘱离院'
  7188. <if test="isPlacefile != null and isPlacefile != ''">
  7189. and a.is_placefile = #{isPlacefile}
  7190. </if>
  7191. AND a.qc_type_id != 0
  7192. <if test="hospitalId != null and hospitalId != ''">
  7193. AND a.hospital_id = #{hospitalId}
  7194. </if>
  7195. <if test="isPlacefile != null and isPlacefile == 0">
  7196. <if test="startDate != null and startDate != ''">
  7197. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7198. </if>
  7199. <if test="endDate != null and endDate != ''">
  7200. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7201. </if>
  7202. </if>
  7203. <if test="isPlacefile != null and isPlacefile == 1">
  7204. <if test="startDate != null and startDate != ''">
  7205. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7206. </if>
  7207. <if test="endDate != null and endDate != ''">
  7208. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7209. </if>
  7210. </if>
  7211. </select>
  7212. <!-- 31天内再入院记录-->
  7213. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  7214. SELECT
  7215. count(*)
  7216. FROM
  7217. (
  7218. SELECT
  7219. r1.file_code,
  7220. r1.diagnose,
  7221. r1.behospital_code AS behospitalCode,
  7222. r1.behospital_date AS behospitalDate,
  7223. r1.leave_hospital_date AS leaveHospitalDate,
  7224. r2.behospital_code AS lastBehospitalCode,
  7225. r2.behospital_date AS lastBehospitalDate,
  7226. r2.leave_hospital_date AS lastLeaveHospitalDate,
  7227. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  7228. FROM
  7229. (
  7230. SELECT
  7231. ( @rownum := @rownum + 1 ) AS rownum,
  7232. t1.file_code,
  7233. t1.diagnose,
  7234. t1.behospital_code,
  7235. t1.behospital_date,
  7236. t1.leave_hospital_date
  7237. FROM
  7238. (
  7239. SELECT
  7240. tt1.file_code,
  7241. tt1.diagnose,
  7242. tt2.behospital_code,
  7243. tt2.behospital_date,
  7244. tt2.leave_hospital_date
  7245. FROM
  7246. (
  7247. SELECT
  7248. a.file_code,
  7249. a.diagnose
  7250. FROM
  7251. med_behospital_info a
  7252. WHERE
  7253. a.is_deleted = 'N'
  7254. <if test="isPlacefile != null and isPlacefile != ''">
  7255. and a.is_placefile = #{isPlacefile}
  7256. </if>
  7257. AND a.qc_type_id != 0
  7258. AND IFNULL( a.diagnose, '' )!= ''
  7259. AND IFNULL( a.file_code, '' )!= ''
  7260. <if test="hospitalId != null and hospitalId != ''">
  7261. AND a.hospital_id = #{hospitalId}
  7262. </if>
  7263. <if test="isPlacefile != null and isPlacefile == 0">
  7264. <if test="startDate != null and startDate != ''">
  7265. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7266. </if>
  7267. <if test="endDate != null and endDate != ''">
  7268. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7269. </if>
  7270. </if>
  7271. <if test="isPlacefile != null and isPlacefile == 1">
  7272. <if test="startDate != null and startDate != ''">
  7273. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7274. </if>
  7275. <if test="endDate != null and endDate != ''">
  7276. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7277. </if>
  7278. </if>
  7279. GROUP BY
  7280. a.file_code,
  7281. a.diagnose
  7282. HAVING
  7283. count(*)> 1
  7284. ) tt1,
  7285. med_behospital_info tt2
  7286. WHERE
  7287. tt2.is_deleted = 'N'
  7288. <if test="isPlacefile != null and isPlacefile != ''">
  7289. and tt2.is_placefile = #{isPlacefile}
  7290. </if>
  7291. AND tt2.qc_type_id != 0
  7292. AND tt1.file_code = tt2.file_code
  7293. AND tt1.diagnose = tt2.diagnose
  7294. <if test="hospitalId != null and hospitalId != ''">
  7295. AND tt2.hospital_id = #{hospitalId}
  7296. </if>
  7297. <if test="isPlacefile != null and isPlacefile == 0">
  7298. <if test="startDate != null and startDate != ''">
  7299. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7300. </if>
  7301. <if test="endDate != null and endDate != ''">
  7302. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7303. </if>
  7304. </if>
  7305. <if test="isPlacefile != null and isPlacefile == 1">
  7306. <if test="startDate != null and startDate != ''">
  7307. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7308. </if>
  7309. <if test="endDate != null and endDate != ''">
  7310. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7311. </if>
  7312. </if>
  7313. ORDER BY
  7314. tt1.file_code,
  7315. tt1.diagnose,
  7316. tt2.behospital_date DESC
  7317. ) t1,
  7318. ( SELECT @rownum := 0 ) r
  7319. ) r1
  7320. LEFT JOIN (
  7321. SELECT
  7322. ( @INDEX := @INDEX + 1 ) AS rownum,
  7323. t2.file_code,
  7324. t2.diagnose,
  7325. t2.behospital_code,
  7326. t2.behospital_date,
  7327. t2.leave_hospital_date
  7328. FROM
  7329. (
  7330. SELECT
  7331. tt1.file_code,
  7332. tt1.diagnose,
  7333. tt2.behospital_code,
  7334. tt2.behospital_date,
  7335. tt2.leave_hospital_date
  7336. FROM
  7337. (
  7338. SELECT
  7339. a.file_code,
  7340. a.diagnose
  7341. FROM
  7342. med_behospital_info a
  7343. WHERE
  7344. a.is_deleted = 'N'
  7345. <if test="isPlacefile != null and isPlacefile != ''">
  7346. and a.is_placefile = #{isPlacefile}
  7347. </if>
  7348. AND a.qc_type_id != 0
  7349. AND IFNULL( a.diagnose, '' )!= ''
  7350. AND IFNULL( a.file_code, '' )!= ''
  7351. <if test="hospitalId != null and hospitalId != ''">
  7352. AND a.hospital_id = #{hospitalId}
  7353. </if>
  7354. <if test="isPlacefile != null and isPlacefile == 0">
  7355. <if test="startDate != null and startDate != ''">
  7356. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7357. </if>
  7358. <if test="endDate != null and endDate != ''">
  7359. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7360. </if>
  7361. </if>
  7362. <if test="isPlacefile != null and isPlacefile == 1">
  7363. <if test="startDate != null and startDate != ''">
  7364. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7365. </if>
  7366. <if test="endDate != null and endDate != ''">
  7367. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7368. </if>
  7369. </if>
  7370. GROUP BY
  7371. a.file_code,
  7372. a.diagnose
  7373. HAVING
  7374. count(*)> 1
  7375. ) tt1,
  7376. med_behospital_info tt2
  7377. WHERE
  7378. tt2.is_deleted = 'N'
  7379. <if test="isPlacefile != null and isPlacefile != ''">
  7380. and tt2.is_placefile = #{isPlacefile}
  7381. </if>
  7382. AND tt2.qc_type_id != 0
  7383. AND tt1.file_code = tt2.file_code
  7384. AND tt1.diagnose = tt2.diagnose
  7385. <if test="hospitalId != null and hospitalId != ''">
  7386. AND tt2.hospital_id = #{hospitalId}
  7387. </if>
  7388. <if test="isPlacefile != null and isPlacefile == 0">
  7389. <if test="startDate != null and startDate != ''">
  7390. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7391. </if>
  7392. <if test="endDate != null and endDate != ''">
  7393. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7394. </if>
  7395. </if>
  7396. <if test="isPlacefile != null and isPlacefile == 1">
  7397. <if test="startDate != null and startDate != ''">
  7398. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7399. </if>
  7400. <if test="endDate != null and endDate != ''">
  7401. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7402. </if>
  7403. </if>
  7404. ORDER BY
  7405. tt1.file_code,
  7406. tt1.diagnose,
  7407. tt2.behospital_date DESC
  7408. ) t2,(
  7409. SELECT
  7410. @INDEX := 0
  7411. ) r
  7412. ) r2 ON r1.file_code = r2.file_code
  7413. AND r1.rownum = r2.rownum - 1
  7414. ) t
  7415. WHERE
  7416. t.diffDays IS NOT NULL
  7417. AND t.diffDays BETWEEN 0
  7418. AND 31
  7419. </select>
  7420. <!-- 病案首页质控病历数统计-全院(首页)-->
  7421. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  7422. SELECT
  7423. count( * ) AS mrNum,
  7424. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  7425. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  7426. SUM( c.`level` = '合格' ) AS firstLevelNum,
  7427. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  7428. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  7429. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  7430. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  7431. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  7432. FROM
  7433. med_behospital_info a,
  7434. med_qcresult_cases c
  7435. WHERE
  7436. a.is_deleted = 'N'
  7437. AND c.is_deleted = 'N'
  7438. AND a.hospital_id = c.hospital_id
  7439. AND a.behospital_code = c.behospital_code
  7440. AND c.cases_id = 243
  7441. <if test="isPlacefile != null and isPlacefile != ''">
  7442. and a.is_placefile = #{isPlacefile}
  7443. </if>
  7444. AND a.qc_type_id != 0
  7445. <if test="hospitalId != null and hospitalId != ''">
  7446. AND a.hospital_id = #{hospitalId}
  7447. </if>
  7448. <if test="isPlacefile != null and isPlacefile == 0">
  7449. <if test="startDate != null and startDate != ''">
  7450. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7451. </if>
  7452. <if test="endDate != null and endDate != ''">
  7453. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7454. </if>
  7455. </if>
  7456. <if test="isPlacefile != null and isPlacefile == 1">
  7457. <if test="startDate != null and startDate != ''">
  7458. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7459. </if>
  7460. <if test="endDate != null and endDate != ''">
  7461. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7462. </if>
  7463. </if>
  7464. </select>
  7465. <!-- 病案首页完整率统计-全院(首页)-->
  7466. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  7467. SELECT
  7468. h1.emptyNum,
  7469. h1.mrNum,
  7470. h2.entryNum,
  7471. h1.mrNum * h2.entryNum AS entryTotleNum,
  7472. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  7473. CONCAT(
  7474. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  7475. '%'
  7476. ) AS emptyPercentStr
  7477. FROM
  7478. (
  7479. SELECT
  7480. sum( d.rule_type = 1 ) AS emptyNum,
  7481. count( DISTINCT a.behospital_code ) AS mrNum
  7482. FROM
  7483. med_behospital_info a,
  7484. med_qcresult_cases b,
  7485. med_qcresult_detail c,
  7486. qc_cases_entry d
  7487. WHERE
  7488. a.is_deleted = 'N'
  7489. AND b.is_deleted = 'N'
  7490. AND c.is_deleted = 'N'
  7491. AND d.is_deleted = 'N'
  7492. AND a.hospital_id = b.hospital_id
  7493. AND a.hospital_id = c.hospital_id
  7494. AND a.behospital_code = b.behospital_code
  7495. AND a.behospital_code = c.behospital_code
  7496. AND b.cases_id = c.cases_id
  7497. AND c.cases_id = d.cases_id
  7498. AND c.cases_entry_id = d.id
  7499. <if test="isPlacefile != null and isPlacefile != ''">
  7500. and a.is_placefile = #{isPlacefile}
  7501. </if>
  7502. AND d.cases_id = 243
  7503. AND a.qc_type_id != 0
  7504. <if test="hospitalId != null and hospitalId != ''">
  7505. AND a.hospital_id = #{hospitalId}
  7506. </if>
  7507. <if test="isPlacefile != null and isPlacefile == 0">
  7508. <if test="startDate != null and startDate != ''">
  7509. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7510. </if>
  7511. <if test="endDate != null and endDate != ''">
  7512. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7513. </if>
  7514. </if>
  7515. <if test="isPlacefile != null and isPlacefile == 1">
  7516. <if test="startDate != null and startDate != ''">
  7517. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7518. </if>
  7519. <if test="endDate != null and endDate != ''">
  7520. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7521. </if>
  7522. </if>
  7523. ) h1,(
  7524. SELECT
  7525. count(*) AS entryNum
  7526. FROM
  7527. qc_cases_entry
  7528. WHERE
  7529. is_deleted = 'N'
  7530. AND cases_id = 243
  7531. ) h2
  7532. </select>
  7533. <!-- 离院病人评分详情页-->
  7534. <select id="getAge" resultType="java.util.Map">
  7535. SELECT
  7536. a.behospital_code as behospitalCode,
  7537. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  7538. FROM
  7539. med_home_page a
  7540. WHERE
  7541. a.is_deleted = 'N'
  7542. AND a.hospital_id = #{hospitalId}
  7543. AND a.behospital_code IN
  7544. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  7545. '${item}'
  7546. </foreach>
  7547. </select>
  7548. <!-- 离院病人评分详情页-->
  7549. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7550. SELECT
  7551. t.*
  7552. FROM
  7553. (SELECT DISTINCT
  7554. t1.hospital_id AS hospitalId,
  7555. t1.behospital_code AS behospitalCode,
  7556. t1.bed_code AS bedCode,
  7557. t1.LEVEL AS LEVEL,
  7558. t1.grade_type AS gradeType,
  7559. t1.score_res AS scoreRes,
  7560. t1.scoreBn,
  7561. t1.NAME AS NAME,
  7562. t1.sex AS sex,
  7563. t1.beh_dept_id AS behDeptId,
  7564. t1.beh_dept_name AS behDeptName,
  7565. t1.doctor_id AS doctorId,
  7566. t1.doctor_name AS doctorName,
  7567. t1.beh_doctor_id AS behDoctorId,
  7568. t1.beh_doctor_name AS behDoctorName,
  7569. t1.director_doctor_id AS directorDoctorId,
  7570. t1.director_doctor_name AS directorDoctorName,
  7571. t1.birthday AS birthday,
  7572. t1.behospital_date AS behospitalDate,
  7573. t1.leave_hospital_date AS leaveHospitalDate,
  7574. t1.placefile_date AS placefileDate,
  7575. t1.gmt_create AS gradeTime,
  7576. t1.diagnose,
  7577. t1.ward_name AS wardName,
  7578. t1.checkStatus,
  7579. t1.mrStatus,
  7580. t1.chName,
  7581. t1.mrName,
  7582. t1.chTime,
  7583. t1.mrTime,
  7584. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7585. t1.file_code AS fileCode
  7586. FROM
  7587. (
  7588. SELECT be.*,
  7589. ifnull(mci.status,0) AS checkStatus,
  7590. ifnull(hm_mci.status,0) AS mrStatus,
  7591. mci.check_name as chName,
  7592. e.score_res as scoreBn,
  7593. hm_mci.check_name as mrName,
  7594. mci.gmt_create as chTime,
  7595. hm_mci.gmt_create as mrTime
  7596. FROM
  7597. (
  7598. SELECT DISTINCT
  7599. tt1.*
  7600. FROM
  7601. (
  7602. SELECT
  7603. b.*,
  7604. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7605. c.grade_type,
  7606. c.score_res,
  7607. c.gmt_create
  7608. FROM
  7609. (
  7610. SELECT DISTINCT
  7611. a.hospital_id,
  7612. a.behospital_code,
  7613. a.bed_code,
  7614. a.NAME,
  7615. a.sex,
  7616. a.beh_dept_id,
  7617. a.beh_dept_name,
  7618. a.birthday,
  7619. a.behospital_date,
  7620. a.leave_hospital_date,
  7621. a.doctor_id,
  7622. a.doctor_name,
  7623. a.beh_doctor_id,
  7624. a.beh_doctor_name,
  7625. a.director_doctor_id,
  7626. a.director_doctor_name,
  7627. a.diagnose,
  7628. a.placefile_date,
  7629. a.ward_name,
  7630. a.file_code
  7631. FROM
  7632. med_behospital_info a
  7633. WHERE
  7634. a.is_deleted = 'N'
  7635. AND a.qc_type_id != 0
  7636. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7637. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7638. </if>
  7639. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7640. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7641. </if>
  7642. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7643. <if test="qcResultShortPageVO.startDate != null ">
  7644. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7645. </if>
  7646. <if test="qcResultShortPageVO.endDate != null ">
  7647. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7648. </if>
  7649. </if>
  7650. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7651. <if test="qcResultShortPageVO.startDate != null ">
  7652. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7653. </if>
  7654. <if test="qcResultShortPageVO.endDate != null">
  7655. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7656. </if>
  7657. </if>
  7658. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7659. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7660. </if>
  7661. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7662. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7663. </if>
  7664. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7665. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7666. </if>
  7667. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7668. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7669. </if>
  7670. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7671. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7672. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7673. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7674. </if>
  7675. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7676. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7677. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7678. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7679. </if>
  7680. ) b
  7681. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7682. AND b.hospital_id = c.hospital_id
  7683. AND b.behospital_code = c.behospital_code
  7684. ) tt1
  7685. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7686. ,med_medical_record tt2,
  7687. qc_mode tt3
  7688. WHERE
  7689. tt2.is_deleted = 'N'
  7690. AND tt3.is_deleted = 'N'
  7691. AND tt1.hospital_id = tt2.hospital_id
  7692. AND tt1.behospital_code = tt2.behospital_code
  7693. AND tt2.mode_id = tt3.id
  7694. AND tt3.`name` = '手术记录'
  7695. </if>
  7696. ) be
  7697. left join med_check_info mci
  7698. on mci.is_deleted = 'N'
  7699. and mci.check_type = 0
  7700. and be.hospital_id = mci.hospital_id
  7701. and be.behospital_code = mci.behospital_code
  7702. left join med_check_info hm_mci
  7703. on hm_mci.is_deleted = 'N'
  7704. and hm_mci.check_type = 1
  7705. and be.hospital_id = hm_mci.hospital_id
  7706. and be.behospital_code = hm_mci.behospital_code
  7707. LEFT JOIN med_qcresult_cases e
  7708. on be.behospital_code = e.behospital_code
  7709. and be.hospital_id = e.hospital_id
  7710. AND e.is_deleted = 'N'
  7711. and e.cases_id = 243
  7712. )t1
  7713. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7714. ,med_home_page t2
  7715. WHERE
  7716. t2.is_deleted = 'N'
  7717. AND t1.hospital_id = t2.hospital_id
  7718. AND t1.behospital_code = t2.behospital_code
  7719. AND (
  7720. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7721. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7722. )
  7723. </if>
  7724. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7725. , med_medical_record b,
  7726. med_medical_record_content c,
  7727. med_home_page t2
  7728. WHERE
  7729. b.is_deleted = 'N'
  7730. and c.is_deleted = 'N'
  7731. and t2.is_deleted = 'N'
  7732. and t1.hospital_id = b.hospital_id
  7733. and t1.hospital_id = c.hospital_id
  7734. and t1.hospital_id = t2.hospital_id
  7735. AND t1.behospital_code = b.behospital_code
  7736. AND t1.behospital_code = t2.behospital_code
  7737. AND b.rec_id = c.rec_id
  7738. and b.mode_id = '24'
  7739. </if>
  7740. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7741. ,med_home_page t2
  7742. WHERE
  7743. t2.is_deleted = 'N'
  7744. AND t1.hospital_id = t2.hospital_id
  7745. AND t1.behospital_code = t2.behospital_code
  7746. AND t2.leave_hospital_type = '非医嘱离院'
  7747. </if>
  7748. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7749. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7750. AND t1.hospital_id = t2.hospital_id
  7751. AND t1.behospital_code = t2.behospital_code
  7752. </if>
  7753. )t
  7754. where 1=1
  7755. <if test="qcResultShortPageVO.checkStatus != null">
  7756. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7757. </if>
  7758. <if test="qcResultShortPageVO.mrStatus != null">
  7759. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7760. </if>
  7761. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7762. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7763. </if>
  7764. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7765. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7766. </if>
  7767. <if test="qcResultShortPageVO.chTimeStart != null ">
  7768. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7769. </if>
  7770. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7771. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7772. </if>
  7773. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7774. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7775. </if>
  7776. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7777. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7778. </if>
  7779. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7780. AND t.`level` = #{qcResultShortPageVO.level}
  7781. </if>
  7782. </select>
  7783. <!-- 离院病人评分详情页-科室-->
  7784. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  7785. SELECT
  7786. t.*
  7787. FROM
  7788. (SELECT DISTINCT
  7789. t1.hospital_id AS hospitalId,
  7790. t1.behospital_code AS behospitalCode,
  7791. t1.bed_code AS bedCode,
  7792. t1.LEVEL AS LEVEL,
  7793. t1.grade_type AS gradeType,
  7794. t1.score_res AS scoreRes,
  7795. t1.scoreBn,
  7796. t1.NAME AS NAME,
  7797. t1.sex AS sex,
  7798. t1.beh_dept_id AS behDeptId,
  7799. t1.beh_dept_name AS behDeptName,
  7800. t1.doctor_id AS doctorId,
  7801. t1.doctor_name AS doctorName,
  7802. t1.beh_doctor_id AS behDoctorId,
  7803. t1.beh_doctor_name AS behDoctorName,
  7804. t1.director_doctor_id AS directorDoctorId,
  7805. t1.director_doctor_name AS directorDoctorName,
  7806. t1.birthday AS birthday,
  7807. t1.behospital_date AS behospitalDate,
  7808. t1.leave_hospital_date AS leaveHospitalDate,
  7809. t1.placefile_date AS placefileDate,
  7810. t1.gmt_create AS gradeTime,
  7811. t1.diagnose,
  7812. t1.ward_name AS wardName,
  7813. t1.checkStatus,
  7814. t1.mrStatus,
  7815. t1.chName,
  7816. t1.mrName,
  7817. t1.chTime,
  7818. t1.mrTime,
  7819. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7820. t1.file_code AS fileCode
  7821. FROM
  7822. (
  7823. SELECT be.*,
  7824. ifnull(mci.status,0) AS checkStatus,
  7825. ifnull(hm_mci.status,0) AS mrStatus,
  7826. mci.check_name as chName,
  7827. e.score_res as scoreBn,
  7828. hm_mci.check_name as mrName,
  7829. mci.gmt_create as chTime,
  7830. hm_mci.gmt_create as mrTime
  7831. FROM
  7832. (
  7833. SELECT DISTINCT
  7834. tt1.*
  7835. FROM
  7836. (
  7837. SELECT
  7838. b.*,
  7839. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7840. c.grade_type,
  7841. c.score_res,
  7842. c.gmt_create
  7843. FROM
  7844. (
  7845. SELECT DISTINCT
  7846. a.hospital_id,
  7847. a.behospital_code,
  7848. a.bed_code,
  7849. a.NAME,
  7850. a.sex,
  7851. a.beh_dept_id,
  7852. a.beh_dept_name,
  7853. a.birthday,
  7854. a.behospital_date,
  7855. a.leave_hospital_date,
  7856. a.doctor_id,
  7857. a.doctor_name,
  7858. a.beh_doctor_id,
  7859. a.beh_doctor_name,
  7860. a.director_doctor_id,
  7861. a.director_doctor_name,
  7862. a.diagnose,
  7863. a.placefile_date,
  7864. a.ward_name,
  7865. a.file_code
  7866. FROM
  7867. med_behospital_info a,
  7868. sys_user_dept b
  7869. WHERE
  7870. a.is_deleted = 'N'
  7871. AND b.is_deleted = 'N'
  7872. AND a.hospital_id = b.hospital_id
  7873. AND a.beh_dept_id = b.dept_id
  7874. AND a.qc_type_id != 0
  7875. <if test="qcResultShortPageVO.userId!=null">
  7876. AND b.user_id = #{qcResultShortPageVO.userId}
  7877. </if>
  7878. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7879. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7880. </if>
  7881. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7882. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7883. </if>
  7884. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7885. <if test="qcResultShortPageVO.startDate != null ">
  7886. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7887. </if>
  7888. <if test="qcResultShortPageVO.endDate != null ">
  7889. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7890. </if>
  7891. </if>
  7892. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7893. <if test="qcResultShortPageVO.startDate != null ">
  7894. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7895. </if>
  7896. <if test="qcResultShortPageVO.endDate != null">
  7897. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7898. </if>
  7899. </if>
  7900. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7901. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7902. </if>
  7903. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7904. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7905. </if>
  7906. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7907. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7908. </if>
  7909. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7910. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7911. </if>
  7912. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7913. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7914. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7915. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7916. </if>
  7917. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7918. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7919. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7920. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7921. </if>
  7922. ) b
  7923. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7924. AND b.hospital_id = c.hospital_id
  7925. AND b.behospital_code = c.behospital_code
  7926. ) tt1
  7927. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7928. ,med_medical_record tt2,
  7929. qc_mode tt3
  7930. WHERE
  7931. tt2.is_deleted = 'N'
  7932. AND tt3.is_deleted = 'N'
  7933. AND tt1.hospital_id = tt2.hospital_id
  7934. AND tt1.behospital_code = tt2.behospital_code
  7935. AND tt2.mode_id = tt3.id
  7936. AND tt3.`name` = '手术记录'
  7937. </if>
  7938. ) be
  7939. left join med_check_info mci
  7940. on mci.is_deleted = 'N'
  7941. and mci.check_type = 0
  7942. and be.hospital_id = mci.hospital_id
  7943. and be.behospital_code = mci.behospital_code
  7944. left join med_check_info hm_mci
  7945. on hm_mci.is_deleted = 'N'
  7946. and hm_mci.check_type = 1
  7947. and be.hospital_id = hm_mci.hospital_id
  7948. and be.behospital_code = hm_mci.behospital_code
  7949. LEFT JOIN med_qcresult_cases e
  7950. on be.behospital_code = e.behospital_code
  7951. and be.hospital_id = e.hospital_id
  7952. AND e.is_deleted = 'N'
  7953. and e.cases_id = 243
  7954. )t1
  7955. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7956. ,med_home_page t2
  7957. WHERE
  7958. t2.is_deleted = 'N'
  7959. AND t1.hospital_id = t2.hospital_id
  7960. AND t1.behospital_code = t2.behospital_code
  7961. AND (
  7962. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7963. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7964. )
  7965. </if>
  7966. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7967. , med_medical_record b,
  7968. med_medical_record_content c,
  7969. med_home_page t2
  7970. WHERE
  7971. b.is_deleted = 'N'
  7972. and c.is_deleted = 'N'
  7973. and t2.is_deleted = 'N'
  7974. and t1.hospital_id = b.hospital_id
  7975. and t1.hospital_id = c.hospital_id
  7976. and t1.hospital_id = t2.hospital_id
  7977. AND t1.behospital_code = b.behospital_code
  7978. AND t1.behospital_code = t2.behospital_code
  7979. AND b.rec_id = c.rec_id
  7980. and b.mode_id = '24'
  7981. </if>
  7982. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7983. ,med_home_page t2
  7984. WHERE
  7985. t2.is_deleted = 'N'
  7986. AND t1.hospital_id = t2.hospital_id
  7987. AND t1.behospital_code = t2.behospital_code
  7988. AND t2.leave_hospital_type = '非医嘱离院'
  7989. </if>
  7990. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7991. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7992. AND t1.hospital_id = t2.hospital_id
  7993. AND t1.behospital_code = t2.behospital_code
  7994. </if>
  7995. )t
  7996. where 1=1
  7997. <if test="qcResultShortPageVO.checkStatus != null">
  7998. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7999. </if>
  8000. <if test="qcResultShortPageVO.mrStatus != null">
  8001. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8002. </if>
  8003. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8004. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8005. </if>
  8006. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8007. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8008. </if>
  8009. <if test="qcResultShortPageVO.chTimeStart != null ">
  8010. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8011. </if>
  8012. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8013. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8014. </if>
  8015. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8016. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8017. </if>
  8018. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8019. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8020. </if>
  8021. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8022. AND t.`level` = #{qcResultShortPageVO.level}
  8023. </if>
  8024. </select>
  8025. <!-- 病案首页改善率统计(首页)-->
  8026. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  8027. SELECT
  8028. t2.homePageMRNum,
  8029. t1.improveNum,
  8030. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  8031. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8032. t1.improveToPassNum,
  8033. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  8034. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8035. t1.improveToFullNum,
  8036. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  8037. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8038. FROM
  8039. (
  8040. SELECT
  8041. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8042. sum( d.score_res = 20 ) AS improveToFullNum,
  8043. count(*) AS improveNum
  8044. FROM
  8045. med_behospital_info a,
  8046. med_home_page b,
  8047. med_qcresult_info c,
  8048. med_qcresult_cases d,
  8049. (
  8050. SELECT
  8051. m4.*
  8052. FROM
  8053. med_behospital_info m1,
  8054. med_home_page m2,
  8055. med_qcresult_info m3,
  8056. med_qcresult_cases m4
  8057. WHERE
  8058. m1.is_deleted = 'N'
  8059. AND m2.is_deleted = 'N'
  8060. AND m3.is_deleted = 'Y'
  8061. AND m4.is_deleted = 'Y'
  8062. AND m1.hospital_id = m2.hospital_id
  8063. AND m1.hospital_id = m3.hospital_id
  8064. AND m1.hospital_id = m4.hospital_id
  8065. AND m1.behospital_code = m2.behospital_code
  8066. AND m1.behospital_code = m3.behospital_code
  8067. AND m1.behospital_code = m4.behospital_code
  8068. AND m3.gmt_create = m4.gmt_create
  8069. AND m3.have_home_page = 1
  8070. AND m4.cases_id = 243
  8071. <if test="isPlacefile != null and isPlacefile != ''">
  8072. and m1.is_placefile = #{isPlacefile}
  8073. </if>
  8074. AND m1.qc_type_id != 0
  8075. <if test="hospitalId != null and hospitalId != ''">
  8076. AND m1.hospital_id = #{hospitalId}
  8077. </if>
  8078. <if test="isPlacefile != null and isPlacefile == 0">
  8079. <if test="startDate != null and startDate != ''">
  8080. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8081. </if>
  8082. <if test="endDate != null and endDate != ''">
  8083. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8084. </if>
  8085. </if>
  8086. <if test="isPlacefile != null and isPlacefile == 1">
  8087. <if test="startDate != null and startDate != ''">
  8088. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8089. </if>
  8090. <if test="endDate != null and endDate != ''">
  8091. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8092. </if>
  8093. </if>
  8094. GROUP BY
  8095. m1.behospital_code
  8096. ORDER BY
  8097. m1.behospital_code,
  8098. m4.gmt_create
  8099. ) e
  8100. WHERE
  8101. a.is_deleted = 'N'
  8102. AND b.is_deleted = 'N'
  8103. AND c.is_deleted = 'N'
  8104. AND d.is_deleted = 'N'
  8105. AND a.hospital_id = b.hospital_id
  8106. AND a.hospital_id = c.hospital_id
  8107. AND a.hospital_id = d.hospital_id
  8108. AND a.hospital_id = e.hospital_id
  8109. AND a.behospital_code = b.behospital_code
  8110. AND a.behospital_code = c.behospital_code
  8111. AND a.behospital_code = d.behospital_code
  8112. AND a.behospital_code = e.behospital_code
  8113. AND d.cases_id = 243
  8114. AND d.score_res > e.score_res
  8115. <if test="isPlacefile != null and isPlacefile != ''">
  8116. and a.is_placefile = #{isPlacefile}
  8117. </if>
  8118. AND a.qc_type_id != 0
  8119. <if test="hospitalId != null and hospitalId != ''">
  8120. AND a.hospital_id = #{hospitalId}
  8121. </if>
  8122. <if test="isPlacefile != null and isPlacefile == 0">
  8123. <if test="startDate != null and startDate != ''">
  8124. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8125. </if>
  8126. <if test="endDate != null and endDate != ''">
  8127. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8128. </if>
  8129. </if>
  8130. <if test="isPlacefile != null and isPlacefile == 1">
  8131. <if test="startDate != null and startDate != ''">
  8132. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8133. </if>
  8134. <if test="endDate != null and endDate != ''">
  8135. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8136. </if>
  8137. </if>
  8138. ) t1,
  8139. (
  8140. SELECT
  8141. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8142. FROM
  8143. med_behospital_info a,
  8144. med_home_page b,
  8145. med_qcresult_info c
  8146. WHERE
  8147. a.is_deleted = 'N'
  8148. AND b.is_deleted = 'N'
  8149. AND a.hospital_id = b.hospital_id
  8150. AND a.hospital_id = c.hospital_id
  8151. AND a.behospital_code = b.behospital_code
  8152. AND a.behospital_code = c.behospital_code
  8153. AND a.qc_type_id != 0
  8154. <if test="isPlacefile != null and isPlacefile != ''">
  8155. and a.is_placefile = #{isPlacefile}
  8156. </if>
  8157. <if test="hospitalId != null and hospitalId != ''">
  8158. AND a.hospital_id = #{hospitalId}
  8159. </if>
  8160. <if test="isPlacefile != null and isPlacefile == 0">
  8161. <if test="startDate != null and startDate != ''">
  8162. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8163. </if>
  8164. <if test="endDate != null and endDate != ''">
  8165. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8166. </if>
  8167. </if>
  8168. <if test="isPlacefile != null and isPlacefile == 1">
  8169. <if test="startDate != null and startDate != ''">
  8170. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8171. </if>
  8172. <if test="endDate != null and endDate != ''">
  8173. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8174. </if>
  8175. </if>
  8176. ) t2
  8177. </select>
  8178. <!-- 质控核查统计(内页)-->
  8179. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  8180. SELECT
  8181. t.*
  8182. FROM
  8183. (SELECT
  8184. mr.beh_dept_id AS deptId,
  8185. mr.beh_dept_name AS deptName,
  8186. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8187. ck.checkedNum AS checkedNum,
  8188. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8189. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8190. hmmr_t.homePageMRNum,
  8191. improve_t.improveNum,
  8192. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8193. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8194. improve_t.improveToPassNum,
  8195. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8196. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8197. improve_t.improveToFullNum,
  8198. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8199. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8200. FROM
  8201. (
  8202. SELECT
  8203. a.beh_dept_id,
  8204. a.beh_dept_name,
  8205. count(*) AS mrNum
  8206. FROM
  8207. med_behospital_info a,
  8208. med_qcresult_info b
  8209. WHERE
  8210. a.is_deleted = 'N'
  8211. AND b.is_deleted = 'N'
  8212. AND a.hospital_id = b.hospital_id
  8213. AND a.behospital_code = b.behospital_code
  8214. AND a.qc_type_id != 0
  8215. <if test="isPlacefile != null and isPlacefile != ''">
  8216. and a.is_placefile = #{isPlacefile}
  8217. </if>
  8218. <if test="hospitalId != null and hospitalId != ''">
  8219. AND a.hospital_id = #{hospitalId}
  8220. </if>
  8221. <if test="isPlacefile != null and isPlacefile == 0">
  8222. <if test="startDate != null and startDate != ''">
  8223. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8224. </if>
  8225. <if test="endDate != null and endDate != ''">
  8226. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8227. </if>
  8228. </if>
  8229. <if test="isPlacefile != null and isPlacefile == 1">
  8230. <if test="startDate != null and startDate != ''">
  8231. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8232. </if>
  8233. <if test="endDate != null and endDate != ''">
  8234. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8235. </if>
  8236. </if>
  8237. <if test="deptName != null and deptName != ''">
  8238. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8239. </if>
  8240. GROUP BY
  8241. a.beh_dept_id,
  8242. a.beh_dept_name
  8243. ) mr
  8244. LEFT JOIN (
  8245. SELECT
  8246. a.beh_dept_id,
  8247. a.beh_dept_name,
  8248. count(*) AS checkedNum
  8249. FROM
  8250. med_behospital_info a,
  8251. med_qcresult_info b,
  8252. med_check_info c
  8253. WHERE
  8254. a.is_deleted = 'N'
  8255. AND b.is_deleted = 'N'
  8256. AND c.is_deleted = 'N'
  8257. AND a.hospital_id = b.hospital_id
  8258. AND a.hospital_id = c.hospital_id
  8259. AND a.behospital_code = b.behospital_code
  8260. AND a.behospital_code = c.behospital_code
  8261. AND a.qc_type_id != 0
  8262. AND ifnull(c.`status`,0) = 1
  8263. AND c.check_type in (0,2)
  8264. <if test="isPlacefile != null and isPlacefile != ''">
  8265. and a.is_placefile = #{isPlacefile}
  8266. </if>
  8267. <if test="hospitalId != null and hospitalId != ''">
  8268. AND a.hospital_id = #{hospitalId}
  8269. </if>
  8270. <if test="isPlacefile != null and isPlacefile == 0">
  8271. <if test="startDate != null and startDate != ''">
  8272. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8273. </if>
  8274. <if test="endDate != null and endDate != ''">
  8275. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8276. </if>
  8277. </if>
  8278. <if test="isPlacefile != null and isPlacefile == 1">
  8279. <if test="startDate != null and startDate != ''">
  8280. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8281. </if>
  8282. <if test="endDate != null and endDate != ''">
  8283. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8284. </if>
  8285. </if>
  8286. <if test="deptName != null and deptName != ''">
  8287. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8288. </if>
  8289. GROUP BY
  8290. a.beh_dept_id,
  8291. a.beh_dept_name
  8292. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  8293. AND mr.beh_dept_name = ck.beh_dept_name
  8294. LEFT JOIN (
  8295. SELECT
  8296. a.beh_dept_id,
  8297. a.beh_dept_name,
  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. <if test="deptName != null and deptName != ''">
  8334. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8335. </if>
  8336. GROUP BY
  8337. a.beh_dept_id,
  8338. a.beh_dept_name
  8339. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  8340. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  8341. LEFT JOIN (
  8342. SELECT
  8343. a.beh_dept_id,
  8344. a.beh_dept_name,
  8345. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8346. sum( d.score_res = 20 ) AS improveToFullNum,
  8347. count(*) AS improveNum
  8348. FROM
  8349. med_behospital_info a,
  8350. med_home_page b,
  8351. med_qcresult_info c,
  8352. med_qcresult_cases d,
  8353. (
  8354. SELECT
  8355. m4.*
  8356. FROM
  8357. med_behospital_info m1,
  8358. med_home_page m2,
  8359. med_qcresult_info m3,
  8360. med_qcresult_cases m4
  8361. WHERE
  8362. m1.is_deleted = 'N'
  8363. AND m2.is_deleted = 'N'
  8364. AND m3.is_deleted = 'Y'
  8365. AND m4.is_deleted = 'Y'
  8366. AND m1.hospital_id = m2.hospital_id
  8367. AND m1.hospital_id = m3.hospital_id
  8368. AND m1.hospital_id = m4.hospital_id
  8369. AND m1.behospital_code = m2.behospital_code
  8370. AND m1.behospital_code = m3.behospital_code
  8371. AND m1.behospital_code = m4.behospital_code
  8372. AND m3.gmt_create = m4.gmt_create
  8373. AND m3.have_home_page = 1
  8374. AND m4.cases_id = 243
  8375. <if test="isPlacefile != null and isPlacefile != ''">
  8376. and m1.is_placefile = #{isPlacefile}
  8377. </if>
  8378. AND m1.qc_type_id != 0
  8379. <if test="hospitalId != null and hospitalId != ''">
  8380. AND m1.hospital_id = #{hospitalId}
  8381. </if>
  8382. <if test="isPlacefile != null and isPlacefile == 0">
  8383. <if test="startDate != null and startDate != ''">
  8384. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8385. </if>
  8386. <if test="endDate != null and endDate != ''">
  8387. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8388. </if>
  8389. </if>
  8390. <if test="isPlacefile != null and isPlacefile == 1">
  8391. <if test="startDate != null and startDate != ''">
  8392. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8393. </if>
  8394. <if test="endDate != null and endDate != ''">
  8395. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8396. </if>
  8397. </if>
  8398. <if test="deptName != null and deptName != ''">
  8399. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8400. </if>
  8401. GROUP BY
  8402. m1.behospital_code
  8403. ORDER BY
  8404. m1.behospital_code,
  8405. m4.gmt_create
  8406. ) e
  8407. WHERE
  8408. a.is_deleted = 'N'
  8409. AND b.is_deleted = 'N'
  8410. AND c.is_deleted = 'N'
  8411. AND d.is_deleted = 'N'
  8412. AND a.hospital_id = b.hospital_id
  8413. AND a.hospital_id = c.hospital_id
  8414. AND a.hospital_id = d.hospital_id
  8415. AND a.hospital_id = e.hospital_id
  8416. AND a.behospital_code = b.behospital_code
  8417. AND a.behospital_code = c.behospital_code
  8418. AND a.behospital_code = d.behospital_code
  8419. AND a.behospital_code = e.behospital_code
  8420. AND d.cases_id = 243
  8421. AND d.score_res > e.score_res
  8422. <if test="hospitalId != null and hospitalId != ''">
  8423. AND a.hospital_id = #{hospitalId}
  8424. </if>
  8425. <if test="isPlacefile != null and isPlacefile == 0">
  8426. <if test="startDate != null and startDate != ''">
  8427. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8428. </if>
  8429. <if test="endDate != null and endDate != ''">
  8430. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8431. </if>
  8432. </if>
  8433. <if test="isPlacefile != null and isPlacefile == 1">
  8434. <if test="startDate != null and startDate != ''">
  8435. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8436. </if>
  8437. <if test="endDate != null and endDate != ''">
  8438. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8439. </if>
  8440. </if>
  8441. <if test="deptName != null and deptName != ''">
  8442. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8443. </if>
  8444. GROUP BY
  8445. a.beh_dept_id,
  8446. a.beh_dept_name
  8447. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  8448. AND mr.beh_dept_name = improve_t.beh_dept_name
  8449. ) t
  8450. <if test="asc != null and asc !=''">
  8451. order by
  8452. <choose>
  8453. <when test='asc=="deptId"'>deptId asc</when>
  8454. <when test='asc=="deptName"'>deptName asc</when>
  8455. <when test='asc=="mrNum"'>mrNum asc</when>
  8456. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8457. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8458. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8459. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8460. <when test='asc=="improveNum"'>improveNum asc</when>
  8461. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8462. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8463. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8464. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8465. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8466. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8467. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8468. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8469. <otherwise>deptName asc</otherwise>
  8470. </choose>
  8471. </if>
  8472. <if test="desc != null and desc!=''">
  8473. order by
  8474. <choose>
  8475. <when test='desc=="deptId"'>deptId desc</when>
  8476. <when test='desc=="deptName"'>deptName desc</when>
  8477. <when test='desc=="mrNum"'>mrNum desc</when>
  8478. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8479. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8480. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8481. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8482. <when test='desc=="improveNum"'>improveNum desc</when>
  8483. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8484. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8485. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8486. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8487. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8488. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8489. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8490. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8491. <otherwise>deptName desc</otherwise>
  8492. </choose>
  8493. </if>
  8494. </select>
  8495. <!-- 质控核查统计-科室(内页)-->
  8496. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  8497. SELECT
  8498. t.*
  8499. FROM
  8500. (SELECT
  8501. mr.beh_dept_id AS deptId,
  8502. mr.beh_dept_name AS deptName,
  8503. mr.doctorId,
  8504. mr.doctorName,
  8505. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8506. ck.checkedNum AS checkedNum,
  8507. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8508. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8509. hmmr_t.homePageMRNum,
  8510. improve_t.improveNum,
  8511. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8512. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8513. improve_t.improveToPassNum,
  8514. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8515. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8516. improve_t.improveToFullNum,
  8517. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8518. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8519. FROM
  8520. (
  8521. SELECT
  8522. a.beh_dept_id,
  8523. a.beh_dept_name,
  8524. a.doctor_id as doctorId,
  8525. a.doctor_name as doctorName,
  8526. count(*) AS mrNum
  8527. FROM
  8528. med_behospital_info a,
  8529. med_qcresult_info b,
  8530. sys_user_dept c
  8531. WHERE
  8532. a.is_deleted = 'N'
  8533. AND b.is_deleted = 'N'
  8534. AND c.is_deleted = 'N'
  8535. AND a.hospital_id = b.hospital_id
  8536. AND a.hospital_id = c.hospital_id
  8537. AND a.beh_dept_id = c.dept_id
  8538. AND a.behospital_code = b.behospital_code
  8539. AND a.qc_type_id != 0
  8540. <if test="userId!=null">
  8541. AND c.user_id = #{userId}
  8542. </if>
  8543. <if test="isPlacefile != null and isPlacefile != ''">
  8544. and a.is_placefile = #{isPlacefile}
  8545. </if>
  8546. <if test="hospitalId != null and hospitalId != ''">
  8547. AND a.hospital_id = #{hospitalId}
  8548. </if>
  8549. <if test="isPlacefile != null and isPlacefile == 0">
  8550. <if test="startDate != null and startDate != ''">
  8551. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8552. </if>
  8553. <if test="endDate != null and endDate != ''">
  8554. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8555. </if>
  8556. </if>
  8557. <if test="isPlacefile != null and isPlacefile == 1">
  8558. <if test="startDate != null and startDate != ''">
  8559. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8560. </if>
  8561. <if test="endDate != null and endDate != ''">
  8562. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8563. </if>
  8564. </if>
  8565. <if test="deptName != null and deptName != ''">
  8566. and a.beh_dept_name = #{deptName}
  8567. </if>
  8568. <if test="doctorName != null and doctorName != ''">
  8569. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8570. </if>
  8571. GROUP BY
  8572. a.doctor_id,
  8573. a.doctor_name
  8574. ) mr
  8575. LEFT JOIN (
  8576. SELECT
  8577. a.beh_dept_id,
  8578. a.beh_dept_name,
  8579. a.doctor_id as doctorId,
  8580. a.doctor_name as doctorName,
  8581. count(*) AS checkedNum
  8582. FROM
  8583. med_behospital_info a,
  8584. med_qcresult_info b,
  8585. med_check_info c,
  8586. sys_user_dept d
  8587. WHERE
  8588. a.is_deleted = 'N'
  8589. AND b.is_deleted = 'N'
  8590. AND c.is_deleted = 'N'
  8591. AND d.is_deleted = 'N'
  8592. AND a.hospital_id = b.hospital_id
  8593. AND a.hospital_id = c.hospital_id
  8594. AND a.hospital_id = d.hospital_id
  8595. AND a.behospital_code = b.behospital_code
  8596. AND a.behospital_code = c.behospital_code
  8597. AND a.beh_dept_id = d.dept_id
  8598. AND a.qc_type_id != 0
  8599. AND ifnull(c.`status`,0) = 1
  8600. AND c.check_type = 0
  8601. <if test="userId!=null">
  8602. AND d.user_id = #{userId}
  8603. </if>
  8604. <if test="isPlacefile != null and isPlacefile != ''">
  8605. and a.is_placefile = #{isPlacefile}
  8606. </if>
  8607. <if test="hospitalId != null and hospitalId != ''">
  8608. AND a.hospital_id = #{hospitalId}
  8609. </if>
  8610. <if test="isPlacefile != null and isPlacefile == 0">
  8611. <if test="startDate != null and startDate != ''">
  8612. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8613. </if>
  8614. <if test="endDate != null and endDate != ''">
  8615. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8616. </if>
  8617. </if>
  8618. <if test="isPlacefile != null and isPlacefile == 1">
  8619. <if test="startDate != null and startDate != ''">
  8620. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8621. </if>
  8622. <if test="endDate != null and endDate != ''">
  8623. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8624. </if>
  8625. </if>
  8626. <if test="deptName != null and deptName != ''">
  8627. and a.beh_dept_name = #{deptName}
  8628. </if>
  8629. <if test="doctorName != null and doctorName != ''">
  8630. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8631. </if>
  8632. GROUP BY
  8633. a.doctor_id,
  8634. a.doctor_name
  8635. ) ck ON mr.doctorId = ck.doctorId
  8636. AND mr.doctorName = ck.doctorName
  8637. LEFT JOIN (
  8638. SELECT
  8639. a.beh_dept_id,
  8640. a.beh_dept_name,
  8641. a.doctor_id as doctorId,
  8642. a.doctor_name as doctorName,
  8643. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8644. FROM
  8645. med_behospital_info a,
  8646. med_home_page b,
  8647. med_qcresult_info c,
  8648. sys_user_dept d
  8649. WHERE
  8650. a.is_deleted = 'N'
  8651. AND b.is_deleted = 'N'
  8652. AND c.is_deleted = 'N'
  8653. AND d.is_deleted = 'N'
  8654. AND a.hospital_id = b.hospital_id
  8655. AND a.hospital_id = c.hospital_id
  8656. AND a.hospital_id = d.hospital_id
  8657. AND a.behospital_code = b.behospital_code
  8658. AND a.behospital_code = c.behospital_code
  8659. AND a.beh_dept_id = d.dept_id
  8660. AND a.qc_type_id != 0
  8661. <if test="userId!=null">
  8662. AND d.user_id = #{userId}
  8663. </if>
  8664. <if test="isPlacefile != null and isPlacefile != ''">
  8665. and a.is_placefile = #{isPlacefile}
  8666. </if>
  8667. <if test="hospitalId != null and hospitalId != ''">
  8668. AND a.hospital_id = #{hospitalId}
  8669. </if>
  8670. <if test="isPlacefile != null and isPlacefile == 0">
  8671. <if test="startDate != null and startDate != ''">
  8672. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8673. </if>
  8674. <if test="endDate != null and endDate != ''">
  8675. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8676. </if>
  8677. </if>
  8678. <if test="isPlacefile != null and isPlacefile == 1">
  8679. <if test="startDate != null and startDate != ''">
  8680. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8681. </if>
  8682. <if test="endDate != null and endDate != ''">
  8683. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8684. </if>
  8685. </if>
  8686. <if test="deptName != null and deptName != ''">
  8687. and a.beh_dept_name = #{deptName}
  8688. </if>
  8689. <if test="doctorName != null and doctorName != ''">
  8690. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8691. </if>
  8692. GROUP BY
  8693. a.doctor_id,
  8694. a.doctor_name
  8695. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8696. AND mr.doctorName = hmmr_t.doctorName
  8697. LEFT JOIN (
  8698. SELECT
  8699. a.beh_dept_id,
  8700. a.beh_dept_name,
  8701. a.doctor_id as doctorId,
  8702. a.doctor_name as doctorName,
  8703. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8704. sum( d.score_res = 20 ) AS improveToFullNum,
  8705. count(*) AS improveNum
  8706. FROM
  8707. med_behospital_info a,
  8708. med_home_page b,
  8709. med_qcresult_info c,
  8710. med_qcresult_cases d,
  8711. sys_user_dept f,
  8712. (
  8713. SELECT
  8714. m4.*
  8715. FROM
  8716. med_behospital_info m1,
  8717. med_home_page m2,
  8718. med_qcresult_info m3,
  8719. med_qcresult_cases m4
  8720. WHERE
  8721. m1.is_deleted = 'N'
  8722. AND m2.is_deleted = 'N'
  8723. AND m3.is_deleted = 'Y'
  8724. AND m4.is_deleted = 'Y'
  8725. AND m1.hospital_id = m2.hospital_id
  8726. AND m1.hospital_id = m3.hospital_id
  8727. AND m1.hospital_id = m4.hospital_id
  8728. AND m1.behospital_code = m2.behospital_code
  8729. AND m1.behospital_code = m3.behospital_code
  8730. AND m1.behospital_code = m4.behospital_code
  8731. AND m3.gmt_create = m4.gmt_create
  8732. AND m3.have_home_page = 1
  8733. AND m4.cases_id = 243
  8734. <if test="isPlacefile != null and isPlacefile != ''">
  8735. and m1.is_placefile = #{isPlacefile}
  8736. </if>
  8737. AND m1.qc_type_id != 0
  8738. <if test="hospitalId != null and hospitalId != ''">
  8739. AND m1.hospital_id = #{hospitalId}
  8740. </if>
  8741. <if test="isPlacefile != null and isPlacefile == 0">
  8742. <if test="startDate != null and startDate != ''">
  8743. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8744. </if>
  8745. <if test="endDate != null and endDate != ''">
  8746. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8747. </if>
  8748. </if>
  8749. <if test="isPlacefile != null and isPlacefile == 1">
  8750. <if test="startDate != null and startDate != ''">
  8751. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8752. </if>
  8753. <if test="endDate != null and endDate != ''">
  8754. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8755. </if>
  8756. </if>
  8757. <if test="deptName != null and deptName != ''">
  8758. and m1.beh_dept_name = #{deptName}
  8759. </if>
  8760. GROUP BY
  8761. m1.behospital_code
  8762. ORDER BY
  8763. m1.behospital_code,
  8764. m4.gmt_create
  8765. ) e
  8766. WHERE
  8767. a.is_deleted = 'N'
  8768. AND b.is_deleted = 'N'
  8769. AND c.is_deleted = 'N'
  8770. AND d.is_deleted = 'N'
  8771. AND f.is_deleted = 'N'
  8772. AND a.hospital_id = b.hospital_id
  8773. AND a.hospital_id = c.hospital_id
  8774. AND a.hospital_id = d.hospital_id
  8775. AND a.hospital_id = e.hospital_id
  8776. AND a.hospital_id = f.hospital_id
  8777. AND a.behospital_code = b.behospital_code
  8778. AND a.behospital_code = c.behospital_code
  8779. AND a.behospital_code = d.behospital_code
  8780. AND a.behospital_code = e.behospital_code
  8781. AND a.beh_dept_id = f.dept_id
  8782. <if test="userId!=null">
  8783. AND f.user_id = #{userId}
  8784. </if>
  8785. AND d.cases_id = 243
  8786. AND d.score_res > e.score_res
  8787. <if test="hospitalId != null and hospitalId != ''">
  8788. AND a.hospital_id = #{hospitalId}
  8789. </if>
  8790. <if test="isPlacefile != null and isPlacefile == 0">
  8791. <if test="startDate != null and startDate != ''">
  8792. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8793. </if>
  8794. <if test="endDate != null and endDate != ''">
  8795. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8796. </if>
  8797. </if>
  8798. <if test="isPlacefile != null and isPlacefile == 1">
  8799. <if test="startDate != null and startDate != ''">
  8800. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8801. </if>
  8802. <if test="endDate != null and endDate != ''">
  8803. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8804. </if>
  8805. </if>
  8806. <if test="doctorName != null and doctorName != ''">
  8807. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8808. </if>
  8809. <if test="deptName != null and deptName != ''">
  8810. and a.beh_dept_name = #{deptName}
  8811. </if>
  8812. GROUP BY
  8813. a.doctor_id,
  8814. a.doctor_name
  8815. ) improve_t ON mr.doctorId = improve_t.doctorId
  8816. AND mr.doctorName = improve_t.doctorName
  8817. ) t
  8818. <if test="asc != null and asc !=''">
  8819. order by
  8820. <choose>
  8821. <when test='asc=="deptId"'>deptId asc</when>
  8822. <when test='asc=="deptName"'>deptName asc</when>
  8823. <when test='asc=="doctorName"'>doctorName asc</when>
  8824. <when test='asc=="mrNum"'>mrNum asc</when>
  8825. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8826. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8827. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8828. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8829. <when test='asc=="improveNum"'>improveNum asc</when>
  8830. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8831. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8832. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8833. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8834. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8835. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8836. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8837. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8838. <otherwise>doctorName asc</otherwise>
  8839. </choose>
  8840. </if>
  8841. <if test="desc != null and desc!=''">
  8842. order by
  8843. <choose>
  8844. <when test='desc=="deptId"'>deptId desc</when>
  8845. <when test='desc=="deptName"'>deptName desc</when>
  8846. <when test='desc=="doctorName"'>doctorName desc</when>
  8847. <when test='desc=="mrNum"'>mrNum desc</when>
  8848. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8849. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8850. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8851. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8852. <when test='desc=="improveNum"'>improveNum desc</when>
  8853. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8854. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8855. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8856. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8857. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8858. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8859. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8860. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8861. <otherwise>deptName desc</otherwise>
  8862. </choose>
  8863. </if>
  8864. </select>
  8865. <!-- 离院病人评分详情页导出-->
  8866. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  8867. SELECT
  8868. f1.behDeptId,
  8869. f1.behDeptName,
  8870. f1.doctorName,
  8871. f1.patName,
  8872. f1.behospitalCode,
  8873. f1.hospitalId,
  8874. f1.behospitalDate,
  8875. f1.leaveHospitalDate,
  8876. f1.score,
  8877. f2.avgScore,
  8878. f1.scoreBn,
  8879. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8880. f1.msg,
  8881. f1.caseName,
  8882. </if>
  8883. f1.checkStatus,
  8884. f1.mrStatus,
  8885. f1.chName,
  8886. f1.mrName,
  8887. f1.chTime,
  8888. f1.mrTime
  8889. FROM
  8890. (SELECT
  8891. t.doctorName,
  8892. t.`name` AS patName,
  8893. t.behospitalCode AS behospitalCode,
  8894. t.behospitalDate AS behospitalDate,
  8895. t.leaveHospitalDate AS leaveHospitalDate,
  8896. qi.score_res AS score,
  8897. t.scoreBn,
  8898. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8899. qd.msg AS msg,
  8900. qc.NAME AS caseName,
  8901. </if>
  8902. t.behDeptId,
  8903. t.behDeptName,
  8904. t.hospitalId,
  8905. t.checkStatus,
  8906. t.mrStatus,
  8907. t.chName,
  8908. t.mrName,
  8909. t.chTime,
  8910. t.mrTime
  8911. FROM
  8912. (SELECT DISTINCT
  8913. t1.hospital_id AS hospitalId,
  8914. t1.behospital_code AS behospitalCode,
  8915. t1.bed_code AS bedCode,
  8916. t1.LEVEL AS LEVEL,
  8917. t1.grade_type AS gradeType,
  8918. t1.score_res AS scoreRes,
  8919. t1.scoreBn,
  8920. t1.NAME AS NAME,
  8921. t1.sex AS sex,
  8922. t1.beh_dept_id AS behDeptId,
  8923. t1.beh_dept_name AS behDeptName,
  8924. t1.doctor_id AS doctorId,
  8925. t1.doctor_name AS doctorName,
  8926. t1.beh_doctor_id AS behDoctorId,
  8927. t1.beh_doctor_name AS behDoctorName,
  8928. t1.director_doctor_id AS directorDoctorId,
  8929. t1.director_doctor_name AS directorDoctorName,
  8930. t1.birthday AS birthday,
  8931. t1.behospital_date AS behospitalDate,
  8932. t1.leave_hospital_date AS leaveHospitalDate,
  8933. t1.placefile_date AS placefileDate,
  8934. t1.gmt_create AS gradeTime,
  8935. t1.diagnose,
  8936. t1.ward_name AS wardName,
  8937. t1.checkStatus,
  8938. t1.mrStatus,
  8939. t1.chName,
  8940. t1.mrName,
  8941. t1.chTime,
  8942. t1.mrTime,
  8943. t2.age,
  8944. t1.file_code AS fileCode
  8945. FROM
  8946. (
  8947. SELECT be.*,
  8948. ifnull(mci.status,0) AS checkStatus,
  8949. ifnull(hm_mci.status,0) AS mrStatus,
  8950. mci.check_name as chName,
  8951. e.score_res as scoreBn,
  8952. hm_mci.check_name as mrName,
  8953. mci.gmt_create as chTime,
  8954. hm_mci.gmt_create as mrTime
  8955. FROM
  8956. (
  8957. SELECT DISTINCT
  8958. tt1.*
  8959. FROM
  8960. (
  8961. SELECT
  8962. b.*,
  8963. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8964. c.grade_type,
  8965. c.score_res,
  8966. c.gmt_create
  8967. FROM
  8968. (
  8969. SELECT DISTINCT
  8970. a.hospital_id,
  8971. a.behospital_code,
  8972. a.bed_code,
  8973. a.NAME,
  8974. a.sex,
  8975. a.beh_dept_id,
  8976. a.beh_dept_name,
  8977. a.birthday,
  8978. a.behospital_date,
  8979. a.leave_hospital_date,
  8980. a.doctor_id,
  8981. a.doctor_name,
  8982. a.beh_doctor_id,
  8983. a.beh_doctor_name,
  8984. a.director_doctor_id,
  8985. a.director_doctor_name,
  8986. a.diagnose,
  8987. a.placefile_date,
  8988. a.ward_name,
  8989. a.file_code
  8990. FROM
  8991. med_behospital_info a
  8992. WHERE
  8993. a.is_deleted = 'N'
  8994. AND a.qc_type_id != 0
  8995. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8996. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8997. </if>
  8998. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8999. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9000. </if>
  9001. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9002. <if test="qcResultShortPageVO.startDate != null ">
  9003. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9004. </if>
  9005. <if test="qcResultShortPageVO.endDate != null ">
  9006. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9007. </if>
  9008. </if>
  9009. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9010. <if test="qcResultShortPageVO.startDate != null ">
  9011. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9012. </if>
  9013. <if test="qcResultShortPageVO.endDate != null">
  9014. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9015. </if>
  9016. </if>
  9017. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9018. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9019. </if>
  9020. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9021. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9022. </if>
  9023. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9024. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9025. </if>
  9026. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9027. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9028. </if>
  9029. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9030. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9031. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9032. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9033. </if>
  9034. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9035. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9036. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9037. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9038. </if>
  9039. ) b
  9040. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9041. AND b.hospital_id = c.hospital_id
  9042. AND b.behospital_code = c.behospital_code
  9043. ) tt1
  9044. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9045. ,med_medical_record tt2,
  9046. qc_mode tt3
  9047. WHERE
  9048. tt2.is_deleted = 'N'
  9049. AND tt3.is_deleted = 'N'
  9050. AND tt1.hospital_id = tt2.hospital_id
  9051. AND tt1.behospital_code = tt2.behospital_code
  9052. AND tt2.mode_id = tt3.id
  9053. AND tt3.`name` = '手术记录'
  9054. </if>
  9055. ) be
  9056. left join med_check_info mci
  9057. on mci.is_deleted = 'N'
  9058. and mci.check_type = 0
  9059. and be.hospital_id = mci.hospital_id
  9060. and be.behospital_code = mci.behospital_code
  9061. left join med_check_info hm_mci
  9062. on hm_mci.is_deleted = 'N'
  9063. and hm_mci.check_type = 1
  9064. and be.hospital_id = hm_mci.hospital_id
  9065. and be.behospital_code = hm_mci.behospital_code
  9066. LEFT JOIN med_qcresult_cases e
  9067. on be.behospital_code = e.behospital_code
  9068. and be.hospital_id = e.hospital_id
  9069. AND e.is_deleted = 'N'
  9070. and e.cases_id = 243
  9071. )t1
  9072. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9073. ,med_home_page t2
  9074. WHERE
  9075. t2.is_deleted = 'N'
  9076. AND t1.hospital_id = t2.hospital_id
  9077. AND t1.behospital_code = t2.behospital_code
  9078. AND (
  9079. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9080. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9081. )
  9082. </if>
  9083. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9084. ,med_home_page t2
  9085. WHERE
  9086. t2.is_deleted = 'N'
  9087. AND t1.hospital_id = t2.hospital_id
  9088. AND t1.behospital_code = t2.behospital_code
  9089. AND t2.return_to_type = '死亡'
  9090. </if>
  9091. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9092. ,med_home_page t2
  9093. WHERE
  9094. t2.is_deleted = 'N'
  9095. AND t1.hospital_id = t2.hospital_id
  9096. AND t1.behospital_code = t2.behospital_code
  9097. AND t2.leave_hospital_type = '非医嘱离院'
  9098. </if>
  9099. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9100. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9101. AND t1.hospital_id = t2.hospital_id
  9102. AND t1.behospital_code = t2.behospital_code
  9103. </if>
  9104. )t
  9105. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9106. AND t.hospitalId = qi.hospital_id
  9107. AND t.behospitalCode = qi.behospital_code
  9108. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9109. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9110. AND t.hospitalId = qd.hospital_id
  9111. AND t.behospitalCode = qd.behospital_code
  9112. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9113. AND qd.cases_id = qc.id
  9114. </if>
  9115. where 1=1
  9116. <if test="qcResultShortPageVO.checkStatus != null">
  9117. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9118. </if>
  9119. <if test="qcResultShortPageVO.mrStatus != null">
  9120. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9121. </if>
  9122. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9123. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9124. </if>
  9125. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9126. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9127. </if>
  9128. <if test="qcResultShortPageVO.chTimeStart != null ">
  9129. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9130. </if>
  9131. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9132. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9133. </if>
  9134. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9135. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9136. </if>
  9137. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9138. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9139. </if>
  9140. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9141. AND t.`level` = #{qcResultShortPageVO.level}
  9142. </if>)f1,(SELECT
  9143. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9144. t.behDeptId,
  9145. t.behDeptName
  9146. FROM
  9147. (SELECT DISTINCT
  9148. t1.hospital_id AS hospitalId,
  9149. t1.behospital_code AS behospitalCode,
  9150. t1.bed_code AS bedCode,
  9151. t1.LEVEL AS LEVEL,
  9152. t1.grade_type AS gradeType,
  9153. t1.score_res AS scoreRes,
  9154. t1.NAME AS NAME,
  9155. t1.sex AS sex,
  9156. t1.beh_dept_id AS behDeptId,
  9157. t1.beh_dept_name AS behDeptName,
  9158. t1.doctor_id AS doctorId,
  9159. t1.doctor_name AS doctorName,
  9160. t1.beh_doctor_id AS behDoctorId,
  9161. t1.beh_doctor_name AS behDoctorName,
  9162. t1.director_doctor_id AS directorDoctorId,
  9163. t1.director_doctor_name AS directorDoctorName,
  9164. t1.birthday AS birthday,
  9165. t1.behospital_date AS behospitalDate,
  9166. t1.leave_hospital_date AS leaveHospitalDate,
  9167. t1.placefile_date AS placefileDate,
  9168. t1.gmt_create AS gradeTime,
  9169. t1.diagnose,
  9170. t1.ward_name AS wardName,
  9171. t1.checkStatus,
  9172. t1.mrStatus,
  9173. t1.chName,
  9174. t1.mrName,
  9175. t1.chTime,
  9176. t1.mrTime,
  9177. t2.age,
  9178. t1.file_code AS fileCode
  9179. FROM
  9180. (
  9181. SELECT be.*,
  9182. ifnull(mci.status,0) AS checkStatus,
  9183. ifnull(hm_mci.status,0) AS mrStatus,
  9184. mci.check_name as chName,
  9185. hm_mci.check_name as mrName,
  9186. mci.gmt_create as chTime,
  9187. hm_mci.gmt_create as mrTime
  9188. FROM
  9189. (
  9190. SELECT DISTINCT
  9191. tt1.*
  9192. FROM
  9193. (
  9194. SELECT
  9195. b.*,
  9196. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9197. c.grade_type,
  9198. c.score_res,
  9199. c.gmt_create
  9200. FROM
  9201. (
  9202. SELECT DISTINCT
  9203. a.hospital_id,
  9204. a.behospital_code,
  9205. a.bed_code,
  9206. a.NAME,
  9207. a.sex,
  9208. a.beh_dept_id,
  9209. a.beh_dept_name,
  9210. a.birthday,
  9211. a.behospital_date,
  9212. a.leave_hospital_date,
  9213. a.doctor_id,
  9214. a.doctor_name,
  9215. a.beh_doctor_id,
  9216. a.beh_doctor_name,
  9217. a.director_doctor_id,
  9218. a.director_doctor_name,
  9219. a.diagnose,
  9220. a.placefile_date,
  9221. a.ward_name,
  9222. a.file_code
  9223. FROM
  9224. med_behospital_info a
  9225. WHERE
  9226. a.is_deleted = 'N'
  9227. AND a.qc_type_id != 0
  9228. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9229. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9230. </if>
  9231. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9232. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9233. </if>
  9234. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9235. <if test="qcResultShortPageVO.startDate != null ">
  9236. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9237. </if>
  9238. <if test="qcResultShortPageVO.endDate != null ">
  9239. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9240. </if>
  9241. </if>
  9242. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9243. <if test="qcResultShortPageVO.startDate != null ">
  9244. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9245. </if>
  9246. <if test="qcResultShortPageVO.endDate != null">
  9247. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9248. </if>
  9249. </if>
  9250. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9251. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9252. </if>
  9253. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9254. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9255. </if>
  9256. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9257. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9258. </if>
  9259. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9260. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9261. </if>
  9262. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9263. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9264. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9265. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9266. </if>
  9267. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9268. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9269. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9270. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9271. </if>
  9272. ) b
  9273. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9274. AND b.hospital_id = c.hospital_id
  9275. AND b.behospital_code = c.behospital_code
  9276. ) tt1
  9277. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9278. ,med_medical_record tt2,
  9279. qc_mode tt3
  9280. WHERE
  9281. tt2.is_deleted = 'N'
  9282. AND tt3.is_deleted = 'N'
  9283. AND tt1.hospital_id = tt2.hospital_id
  9284. AND tt1.behospital_code = tt2.behospital_code
  9285. AND tt2.mode_id = tt3.id
  9286. AND tt3.`name` = '手术记录'
  9287. </if>
  9288. ) be
  9289. left join med_check_info mci
  9290. on mci.is_deleted = 'N'
  9291. and mci.check_type = 0
  9292. and be.hospital_id = mci.hospital_id
  9293. and be.behospital_code = mci.behospital_code
  9294. left join med_check_info hm_mci
  9295. on hm_mci.is_deleted = 'N'
  9296. and hm_mci.check_type = 1
  9297. and be.hospital_id = hm_mci.hospital_id
  9298. and be.behospital_code = hm_mci.behospital_code
  9299. )t1
  9300. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9301. ,med_home_page t2
  9302. WHERE
  9303. t2.is_deleted = 'N'
  9304. AND t1.hospital_id = t2.hospital_id
  9305. AND t1.behospital_code = t2.behospital_code
  9306. AND (
  9307. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  9308. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9309. )
  9310. </if>
  9311. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9312. ,med_home_page t2
  9313. WHERE
  9314. t2.is_deleted = 'N'
  9315. AND t1.hospital_id = t2.hospital_id
  9316. AND t1.behospital_code = t2.behospital_code
  9317. AND t2.return_to_type = '死亡'
  9318. </if>
  9319. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9320. ,med_home_page t2
  9321. WHERE
  9322. t2.is_deleted = 'N'
  9323. AND t1.hospital_id = t2.hospital_id
  9324. AND t1.behospital_code = t2.behospital_code
  9325. AND t2.leave_hospital_type = '非医嘱离院'
  9326. </if>
  9327. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9328. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9329. AND t1.hospital_id = t2.hospital_id
  9330. AND t1.behospital_code = t2.behospital_code
  9331. </if>
  9332. )t
  9333. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9334. AND t.hospitalId = qi.hospital_id
  9335. AND t.behospitalCode = qi.behospital_code
  9336. where 1=1
  9337. <if test="qcResultShortPageVO.checkStatus != null">
  9338. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9339. </if>
  9340. <if test="qcResultShortPageVO.mrStatus != null">
  9341. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9342. </if>
  9343. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9344. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9345. </if>
  9346. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9347. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9348. </if>
  9349. <if test="qcResultShortPageVO.chTimeStart != null ">
  9350. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9351. </if>
  9352. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9353. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9354. </if>
  9355. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9356. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9357. </if>
  9358. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9359. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9360. </if>
  9361. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9362. AND t.`level` = #{qcResultShortPageVO.level}
  9363. </if>
  9364. GROUP BY
  9365. t.behDeptId,
  9366. t.behDeptName
  9367. )f2
  9368. WHERE
  9369. f1.behDeptId = f2.behDeptId
  9370. AND f1.behDeptName = f2.behDeptName
  9371. </select>
  9372. <!-- 离院病人评分详情页导出-科室-->
  9373. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  9374. SELECT
  9375. f1.behDeptId,
  9376. f1.behDeptName,
  9377. f1.doctorName,
  9378. f1.patName,
  9379. f1.behospitalCode,
  9380. f1.hospitalId,
  9381. f1.behospitalDate,
  9382. f1.leaveHospitalDate,
  9383. f1.score,
  9384. f2.avgScore,
  9385. f1.scoreBn,
  9386. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9387. f1.msg,
  9388. f1.caseName,
  9389. </if>
  9390. f1.checkStatus,
  9391. f1.mrStatus,
  9392. f1.chName,
  9393. f1.mrName,
  9394. f1.chTime,
  9395. f1.mrTime
  9396. FROM
  9397. (SELECT
  9398. t.doctorName,
  9399. t.doctorId,
  9400. t.`name` AS patName,
  9401. t.behospitalCode AS behospitalCode,
  9402. t.behospitalDate AS behospitalDate,
  9403. t.leaveHospitalDate AS leaveHospitalDate,
  9404. qi.score_res AS score,
  9405. t.scoreBn,
  9406. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9407. qd.msg AS msg,
  9408. qc.NAME AS caseName,
  9409. </if>
  9410. t.behDeptId,
  9411. t.behDeptName,
  9412. t.hospitalId,
  9413. t.checkStatus,
  9414. t.mrStatus,
  9415. t.chName,
  9416. t.mrName,
  9417. t.chTime,
  9418. t.mrTime
  9419. FROM
  9420. (SELECT DISTINCT
  9421. t1.hospital_id AS hospitalId,
  9422. t1.behospital_code AS behospitalCode,
  9423. t1.bed_code AS bedCode,
  9424. t1.LEVEL AS LEVEL,
  9425. t1.grade_type AS gradeType,
  9426. t1.score_res AS scoreRes,
  9427. t1.scoreBn,
  9428. t1.NAME AS NAME,
  9429. t1.sex AS sex,
  9430. t1.beh_dept_id AS behDeptId,
  9431. t1.beh_dept_name AS behDeptName,
  9432. t1.doctor_id AS doctorId,
  9433. t1.doctor_name AS doctorName,
  9434. t1.beh_doctor_id AS behDoctorId,
  9435. t1.beh_doctor_name AS behDoctorName,
  9436. t1.director_doctor_id AS directorDoctorId,
  9437. t1.director_doctor_name AS directorDoctorName,
  9438. t1.birthday AS birthday,
  9439. t1.behospital_date AS behospitalDate,
  9440. t1.leave_hospital_date AS leaveHospitalDate,
  9441. t1.placefile_date AS placefileDate,
  9442. t1.gmt_create AS gradeTime,
  9443. t1.diagnose,
  9444. t1.ward_name AS wardName,
  9445. t1.checkStatus,
  9446. t1.mrStatus,
  9447. t1.chName,
  9448. t1.mrName,
  9449. t1.chTime,
  9450. t1.mrTime,
  9451. t2.age,
  9452. t1.file_code AS fileCode
  9453. FROM
  9454. (
  9455. SELECT be.*,
  9456. ifnull(mci.status,0) AS checkStatus,
  9457. ifnull(hm_mci.status,0) AS mrStatus,
  9458. mci.check_name as chName,
  9459. e.score_res as scoreBn,
  9460. hm_mci.check_name as mrName,
  9461. mci.gmt_create as chTime,
  9462. hm_mci.gmt_create as mrTime
  9463. FROM
  9464. (
  9465. SELECT DISTINCT
  9466. tt1.*
  9467. FROM
  9468. (
  9469. SELECT
  9470. b.*,
  9471. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9472. c.grade_type,
  9473. c.score_res,
  9474. c.gmt_create
  9475. FROM
  9476. (
  9477. SELECT DISTINCT
  9478. a.hospital_id,
  9479. a.behospital_code,
  9480. a.bed_code,
  9481. a.NAME,
  9482. a.sex,
  9483. a.beh_dept_id,
  9484. a.beh_dept_name,
  9485. a.birthday,
  9486. a.behospital_date,
  9487. a.leave_hospital_date,
  9488. a.doctor_id,
  9489. a.doctor_name,
  9490. a.beh_doctor_id,
  9491. a.beh_doctor_name,
  9492. a.director_doctor_id,
  9493. a.director_doctor_name,
  9494. a.diagnose,
  9495. a.placefile_date,
  9496. a.ward_name,
  9497. a.file_code
  9498. FROM
  9499. med_behospital_info a,
  9500. sys_user_dept b
  9501. WHERE
  9502. a.is_deleted = 'N'
  9503. AND b.is_deleted = 'N'
  9504. AND a.hospital_id = b.hospital_id
  9505. AND a.beh_dept_id = b.dept_id
  9506. AND a.qc_type_id != 0
  9507. <if test="qcResultShortPageVO.userId!=null">
  9508. AND b.user_id = #{qcResultShortPageVO.userId}
  9509. </if>
  9510. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9511. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9512. </if>
  9513. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9514. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9515. </if>
  9516. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9517. <if test="qcResultShortPageVO.startDate != null ">
  9518. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9519. </if>
  9520. <if test="qcResultShortPageVO.endDate != null ">
  9521. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9522. </if>
  9523. </if>
  9524. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9525. <if test="qcResultShortPageVO.startDate != null ">
  9526. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9527. </if>
  9528. <if test="qcResultShortPageVO.endDate != null">
  9529. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9530. </if>
  9531. </if>
  9532. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9533. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9534. </if>
  9535. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9536. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9537. </if>
  9538. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9539. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9540. </if>
  9541. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9542. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9543. </if>
  9544. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9545. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9546. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9547. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9548. </if>
  9549. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9550. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9551. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9552. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9553. </if>
  9554. ) b
  9555. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9556. AND b.hospital_id = c.hospital_id
  9557. AND b.behospital_code = c.behospital_code
  9558. ) tt1
  9559. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9560. ,med_medical_record tt2,
  9561. qc_mode tt3
  9562. WHERE
  9563. tt2.is_deleted = 'N'
  9564. AND tt3.is_deleted = 'N'
  9565. AND tt1.hospital_id = tt2.hospital_id
  9566. AND tt1.behospital_code = tt2.behospital_code
  9567. AND tt2.mode_id = tt3.id
  9568. AND tt3.`name` = '手术记录'
  9569. </if>
  9570. ) be
  9571. left join med_check_info mci
  9572. on mci.is_deleted = 'N'
  9573. and mci.check_type = 0
  9574. and be.hospital_id = mci.hospital_id
  9575. and be.behospital_code = mci.behospital_code
  9576. left join med_check_info hm_mci
  9577. on hm_mci.is_deleted = 'N'
  9578. and hm_mci.check_type = 1
  9579. and be.hospital_id = hm_mci.hospital_id
  9580. and be.behospital_code = hm_mci.behospital_code
  9581. LEFT JOIN med_qcresult_cases e
  9582. on be.behospital_code = e.behospital_code
  9583. and be.hospital_id = e.hospital_id
  9584. AND e.is_deleted = 'N'
  9585. and e.cases_id = 243
  9586. )t1
  9587. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9588. ,med_home_page t2
  9589. WHERE
  9590. t2.is_deleted = 'N'
  9591. AND t1.hospital_id = t2.hospital_id
  9592. AND t1.behospital_code = t2.behospital_code
  9593. AND (
  9594. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9595. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9596. )
  9597. </if>
  9598. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9599. ,med_home_page t2
  9600. WHERE
  9601. t2.is_deleted = 'N'
  9602. AND t1.hospital_id = t2.hospital_id
  9603. AND t1.behospital_code = t2.behospital_code
  9604. AND t2.return_to_type = '死亡'
  9605. </if>
  9606. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9607. ,med_home_page t2
  9608. WHERE
  9609. t2.is_deleted = 'N'
  9610. AND t1.hospital_id = t2.hospital_id
  9611. AND t1.behospital_code = t2.behospital_code
  9612. AND t2.leave_hospital_type = '非医嘱离院'
  9613. </if>
  9614. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9615. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9616. AND t1.hospital_id = t2.hospital_id
  9617. AND t1.behospital_code = t2.behospital_code
  9618. </if>
  9619. )t
  9620. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9621. AND t.hospitalId = qi.hospital_id
  9622. AND t.behospitalCode = qi.behospital_code
  9623. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9624. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9625. AND t.hospitalId = qd.hospital_id
  9626. AND t.behospitalCode = qd.behospital_code
  9627. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9628. AND qd.cases_id = qc.id
  9629. </if>
  9630. where 1=1
  9631. <if test="qcResultShortPageVO.checkStatus != null">
  9632. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9633. </if>
  9634. <if test="qcResultShortPageVO.mrStatus != null">
  9635. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9636. </if>
  9637. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9638. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9639. </if>
  9640. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9641. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9642. </if>
  9643. <if test="qcResultShortPageVO.chTimeStart != null ">
  9644. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9645. </if>
  9646. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9647. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9648. </if>
  9649. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9650. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9651. </if>
  9652. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9653. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9654. </if>
  9655. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9656. AND t.`level` = #{qcResultShortPageVO.level}
  9657. </if>)f1,(SELECT
  9658. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9659. t.behDeptId,
  9660. t.behDeptName,
  9661. t.doctorId,
  9662. t.doctorName
  9663. FROM
  9664. (SELECT DISTINCT
  9665. t1.hospital_id AS hospitalId,
  9666. t1.behospital_code AS behospitalCode,
  9667. t1.bed_code AS bedCode,
  9668. t1.LEVEL AS LEVEL,
  9669. t1.grade_type AS gradeType,
  9670. t1.score_res AS scoreRes,
  9671. t1.NAME AS NAME,
  9672. t1.sex AS sex,
  9673. t1.beh_dept_id AS behDeptId,
  9674. t1.beh_dept_name AS behDeptName,
  9675. t1.doctor_id AS doctorId,
  9676. t1.doctor_name AS doctorName,
  9677. t1.beh_doctor_id AS behDoctorId,
  9678. t1.beh_doctor_name AS behDoctorName,
  9679. t1.director_doctor_id AS directorDoctorId,
  9680. t1.director_doctor_name AS directorDoctorName,
  9681. t1.birthday AS birthday,
  9682. t1.behospital_date AS behospitalDate,
  9683. t1.leave_hospital_date AS leaveHospitalDate,
  9684. t1.placefile_date AS placefileDate,
  9685. t1.gmt_create AS gradeTime,
  9686. t1.diagnose,
  9687. t1.ward_name AS wardName,
  9688. t1.checkStatus,
  9689. t1.mrStatus,
  9690. t1.chName,
  9691. t1.mrName,
  9692. t1.chTime,
  9693. t1.mrTime,
  9694. t2.age,
  9695. t1.file_code AS fileCode
  9696. FROM
  9697. (
  9698. SELECT be.*,
  9699. ifnull(mci.status,0) AS checkStatus,
  9700. ifnull(hm_mci.status,0) AS mrStatus,
  9701. mci.check_name as chName,
  9702. hm_mci.check_name as mrName,
  9703. mci.gmt_create as chTime,
  9704. hm_mci.gmt_create as mrTime
  9705. FROM
  9706. (
  9707. SELECT DISTINCT
  9708. tt1.*
  9709. FROM
  9710. (
  9711. SELECT
  9712. b.*,
  9713. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9714. c.grade_type,
  9715. c.score_res,
  9716. c.gmt_create
  9717. FROM
  9718. (
  9719. SELECT DISTINCT
  9720. a.hospital_id,
  9721. a.behospital_code,
  9722. a.bed_code,
  9723. a.NAME,
  9724. a.sex,
  9725. a.beh_dept_id,
  9726. a.beh_dept_name,
  9727. a.birthday,
  9728. a.behospital_date,
  9729. a.leave_hospital_date,
  9730. a.doctor_id,
  9731. a.doctor_name,
  9732. a.beh_doctor_id,
  9733. a.beh_doctor_name,
  9734. a.director_doctor_id,
  9735. a.director_doctor_name,
  9736. a.diagnose,
  9737. a.placefile_date,
  9738. a.ward_name,
  9739. a.file_code
  9740. FROM
  9741. med_behospital_info a,
  9742. sys_user_dept b
  9743. WHERE
  9744. a.is_deleted = 'N'
  9745. AND b.is_deleted = 'N'
  9746. AND a.hospital_id = b.hospital_id
  9747. AND a.beh_dept_id = b.dept_id
  9748. AND a.qc_type_id != 0
  9749. <if test="qcResultShortPageVO.userId!=null">
  9750. AND b.user_id = #{qcResultShortPageVO.userId}
  9751. </if>
  9752. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9753. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9754. </if>
  9755. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9756. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9757. </if>
  9758. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9759. <if test="qcResultShortPageVO.startDate != null ">
  9760. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9761. </if>
  9762. <if test="qcResultShortPageVO.endDate != null ">
  9763. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9764. </if>
  9765. </if>
  9766. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9767. <if test="qcResultShortPageVO.startDate != null ">
  9768. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9769. </if>
  9770. <if test="qcResultShortPageVO.endDate != null">
  9771. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9772. </if>
  9773. </if>
  9774. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9775. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9776. </if>
  9777. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9778. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9779. </if>
  9780. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9781. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9782. </if>
  9783. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9784. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9785. </if>
  9786. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9787. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9788. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9789. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9790. </if>
  9791. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9792. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9793. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9794. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9795. </if>
  9796. ) b
  9797. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9798. AND b.hospital_id = c.hospital_id
  9799. AND b.behospital_code = c.behospital_code
  9800. ) tt1
  9801. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9802. ,med_medical_record tt2,
  9803. qc_mode tt3
  9804. WHERE
  9805. tt2.is_deleted = 'N'
  9806. AND tt3.is_deleted = 'N'
  9807. AND tt1.hospital_id = tt2.hospital_id
  9808. AND tt1.behospital_code = tt2.behospital_code
  9809. AND tt2.mode_id = tt3.id
  9810. AND tt3.`name` = '手术记录'
  9811. </if>
  9812. ) be
  9813. left join med_check_info mci
  9814. on mci.is_deleted = 'N'
  9815. and mci.check_type = 0
  9816. and be.hospital_id = mci.hospital_id
  9817. and be.behospital_code = mci.behospital_code
  9818. left join med_check_info hm_mci
  9819. on hm_mci.is_deleted = 'N'
  9820. and hm_mci.check_type = 1
  9821. and be.hospital_id = hm_mci.hospital_id
  9822. and be.behospital_code = hm_mci.behospital_code
  9823. )t1
  9824. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9825. ,med_home_page t2
  9826. WHERE
  9827. t2.is_deleted = 'N'
  9828. AND t1.hospital_id = t2.hospital_id
  9829. AND t1.behospital_code = t2.behospital_code
  9830. AND (
  9831. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9832. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9833. )
  9834. </if>
  9835. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9836. ,med_home_page t2
  9837. WHERE
  9838. t2.is_deleted = 'N'
  9839. AND t1.hospital_id = t2.hospital_id
  9840. AND t1.behospital_code = t2.behospital_code
  9841. AND t2.return_to_type = '死亡'
  9842. </if>
  9843. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9844. ,med_home_page t2
  9845. WHERE
  9846. t2.is_deleted = 'N'
  9847. AND t1.hospital_id = t2.hospital_id
  9848. AND t1.behospital_code = t2.behospital_code
  9849. AND t2.leave_hospital_type = '非医嘱离院'
  9850. </if>
  9851. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9852. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9853. AND t1.hospital_id = t2.hospital_id
  9854. AND t1.behospital_code = t2.behospital_code
  9855. </if>
  9856. )t
  9857. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9858. AND t.hospitalId = qi.hospital_id
  9859. AND t.behospitalCode = qi.behospital_code
  9860. where 1=1
  9861. <if test="qcResultShortPageVO.checkStatus != null">
  9862. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9863. </if>
  9864. <if test="qcResultShortPageVO.mrStatus != null">
  9865. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9866. </if>
  9867. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9868. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9869. </if>
  9870. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9871. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9872. </if>
  9873. <if test="qcResultShortPageVO.chTimeStart != null ">
  9874. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9875. </if>
  9876. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9877. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9878. </if>
  9879. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9880. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9881. </if>
  9882. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9883. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9884. </if>
  9885. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9886. AND t.`level` = #{qcResultShortPageVO.level}
  9887. </if>
  9888. GROUP BY
  9889. t.behDeptId,
  9890. t.behDeptName,
  9891. t.doctorId,
  9892. t.doctorName
  9893. )f2
  9894. WHERE
  9895. f1.doctorId = f2.doctorId
  9896. AND f1.doctorName = f2.doctorName
  9897. </select>
  9898. <!--缺陷详情质控评分页导出-科室-->
  9899. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  9900. SELECT * from(
  9901. SELECT
  9902. f1.*,
  9903. f2.avgScore
  9904. FROM
  9905. (SELECT
  9906. t.*,
  9907. qi.score_res AS score,
  9908. qd.msg AS msg,
  9909. qc.NAME AS caseName
  9910. FROM
  9911. (SELECT DISTINCT
  9912. t1.hospital_id AS hospitalId,
  9913. t1.behospital_code AS behospitalCode,
  9914. t1.bed_code AS bedCode,
  9915. t1.LEVEL AS LEVEL,
  9916. t1.grade_type AS gradeType,
  9917. t1.score_res AS scoreRes,
  9918. t1.scoreBn AS scoreBn,
  9919. t1.NAME AS patName,
  9920. t1.sex AS sex,
  9921. t1.beh_dept_id AS behDeptId,
  9922. t1.beh_dept_name AS behDeptName,
  9923. t1.doctor_id AS doctorId,
  9924. t1.doctor_name AS doctorName,
  9925. t1.beh_doctor_id AS behDoctorId,
  9926. t1.beh_doctor_name AS behDoctorName,
  9927. t1.director_doctor_id AS directorDoctorId,
  9928. t1.director_doctor_name AS directorDoctorName,
  9929. t1.birthday AS birthday,
  9930. t1.behospital_date AS behospitalDate,
  9931. t1.leave_hospital_date AS leaveHospitalDate,
  9932. t1.placefile_date AS placefileDate,
  9933. t1.gmt_create AS gradeTime,
  9934. t1.diagnose AS diagnose,
  9935. t1.ward_name AS wardName,
  9936. t1.file_code AS fileCode,
  9937. t1.checkStatus AS checkStatus,
  9938. t1.mrStatus AS mrStatus,
  9939. t1.chName AS chName,
  9940. t1.mrName AS mrName,
  9941. t1.chTime AS chTime,
  9942. t1.mrTime AS mrTime
  9943. FROM
  9944. (
  9945. SELECT DISTINCT
  9946. tt1.*
  9947. FROM
  9948. (SELECT
  9949. be.*,
  9950. ifnull(mci.status,0) AS checkStatus,
  9951. ifnull(hm_mci.status,0) AS mrStatus,
  9952. mci.check_name as chName,
  9953. hm_mci.check_name as mrName,
  9954. mci.gmt_create as chTime,
  9955. e.score_res as scoreBn,
  9956. hm_mci.gmt_create as mrTime
  9957. FROM
  9958. (
  9959. SELECT DISTINCT
  9960. a.hospital_id,
  9961. a.behospital_code,
  9962. a.bed_code,
  9963. a.file_code,
  9964. b.LEVEL,
  9965. b.grade_type,
  9966. b.score_res,
  9967. a.NAME,
  9968. a.sex,
  9969. a.beh_dept_id,
  9970. a.beh_dept_name,
  9971. a.birthday,
  9972. a.behospital_date,
  9973. a.leave_hospital_date,
  9974. a.doctor_id,
  9975. a.doctor_name,
  9976. a.beh_doctor_id,
  9977. a.beh_doctor_name,
  9978. a.director_doctor_id,
  9979. a.director_doctor_name,
  9980. a.diagnose,
  9981. a.placefile_date,
  9982. a.ward_name,
  9983. b.gmt_create
  9984. FROM
  9985. med_behospital_info a,
  9986. med_qcresult_info b,
  9987. med_qcresult_detail c,
  9988. qc_cases_entry d,
  9989. sys_user_dept e
  9990. WHERE
  9991. a.is_deleted = 'N'
  9992. AND b.is_deleted = 'N'
  9993. AND c.is_deleted = 'N'
  9994. AND d.is_deleted = 'N'
  9995. AND e.is_deleted = 'N'
  9996. AND a.hospital_id = b.hospital_id
  9997. AND a.hospital_id = c.hospital_id
  9998. AND a.hospital_id = e.hospital_id
  9999. AND a.behospital_code = b.behospital_code
  10000. AND a.behospital_code = c.behospital_code
  10001. AND a.beh_dept_id = e.dept_id
  10002. AND c.cases_id = d.cases_id
  10003. AND c.cases_entry_id = d.id
  10004. AND a.qc_type_id != 0
  10005. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10006. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10007. </if>
  10008. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  10009. AND e.user_id = #{qcResultShortPageVO.userId}
  10010. </if>
  10011. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10012. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10013. </if>
  10014. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10015. <if test="qcResultShortPageVO.startDate != null ">
  10016. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10017. </if>
  10018. <if test="qcResultShortPageVO.endDate != null ">
  10019. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10020. </if>
  10021. </if>
  10022. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10023. <if test="qcResultShortPageVO.startDate != null ">
  10024. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10025. </if>
  10026. <if test="qcResultShortPageVO.endDate != null">
  10027. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10028. </if>
  10029. </if>
  10030. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10031. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10032. </if>
  10033. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10034. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10035. </if>
  10036. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10037. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10038. </if>
  10039. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10040. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10041. </if>
  10042. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10043. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10044. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10045. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10046. </if>
  10047. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10048. AND b.`level` = #{qcResultShortPageVO.level}
  10049. </if>
  10050. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10051. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10052. </if>
  10053. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10054. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10055. </if>
  10056. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10057. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  10058. </if>
  10059. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  10060. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10061. </if>
  10062. <if test="qcResultShortPageVO.isReject != null">
  10063. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10064. </if>
  10065. <if test="qcResultShortPageVO.ruleType != null">
  10066. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10067. </if>
  10068. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10069. AND TIMESTAMPDIFF(
  10070. DAY,
  10071. DATE( a.behospital_date ),
  10072. DATE( a.leave_hospital_date ))> 30
  10073. </if>
  10074. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10075. AND TIMESTAMPDIFF(
  10076. DAY,
  10077. DATE( a.behospital_date ),
  10078. DATE( a.leave_hospital_date ))> 31
  10079. </if>
  10080. )be
  10081. left join med_check_info mci
  10082. on mci.is_deleted = 'N'
  10083. and mci.check_type = 0
  10084. and be.hospital_id = mci.hospital_id
  10085. and be.behospital_code = mci.behospital_code
  10086. left join med_check_info hm_mci
  10087. on hm_mci.is_deleted = 'N'
  10088. and hm_mci.check_type = 1
  10089. and be.hospital_id = hm_mci.hospital_id
  10090. and be.behospital_code = hm_mci.behospital_code
  10091. LEFT JOIN med_qcresult_cases e
  10092. on be.behospital_code = e.behospital_code
  10093. and be.hospital_id = e.hospital_id
  10094. AND e.is_deleted = 'N'
  10095. and e.cases_id = 243
  10096. )tt1
  10097. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10098. ,med_medical_record tt2
  10099. WHERE
  10100. tt2.is_deleted = 'N'
  10101. AND tt1.hospital_id = tt2.hospital_id
  10102. AND tt1.behospital_code = tt2.behospital_code
  10103. AND tt2.mode_id = 30
  10104. </if>
  10105. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10106. ,med_crisis_info tt2
  10107. WHERE
  10108. tt2.is_deleted = 'N'
  10109. AND tt1.hospital_id = tt2.hospital_id
  10110. AND tt1.behospital_code = tt2.behospital_code
  10111. </if>
  10112. ) t1
  10113. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10114. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10115. AND t1.behospital_code = t2.behospital_code
  10116. AND t2.is_deleted = 'N'
  10117. </if>
  10118. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10119. , med_home_page t2
  10120. , med_home_operation_info t3
  10121. WHERE t1.hospital_id = t2.hospital_id
  10122. AND t1.behospital_code = t2.behospital_code
  10123. AND t2.home_page_id = t3.home_page_id
  10124. AND t2.is_deleted = 'N'
  10125. AND t3.is_deleted = 'N'
  10126. </if>
  10127. ) t
  10128. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10129. AND t.hospitalId = qi.hospital_id
  10130. AND t.behospitalCode = qi.behospital_code
  10131. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10132. AND t.hospitalId = qd.hospital_id
  10133. AND t.behospitalCode = qd.behospital_code
  10134. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10135. AND qd.cases_id = qc.id
  10136. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10137. AND qd.cases_id = qce.cases_id
  10138. AND qd.cases_entry_id = qce.id
  10139. where 1=1
  10140. <if test="qcResultShortPageVO.checkStatus != null">
  10141. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10142. </if>
  10143. <if test="qcResultShortPageVO.mrStatus != null">
  10144. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10145. </if>
  10146. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10147. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10148. </if>
  10149. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10150. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10151. </if>
  10152. <if test="qcResultShortPageVO.chTimeStart != null ">
  10153. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10154. </if>
  10155. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10156. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10157. </if>
  10158. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10159. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10160. </if>
  10161. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10162. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10163. </if>
  10164. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10165. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10166. </if>
  10167. <if test="qcResultShortPageVO.casesEntryId != null ">
  10168. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10169. </if>
  10170. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10171. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10172. </if>
  10173. <if test="qcResultShortPageVO.casesId != null">
  10174. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10175. </if>
  10176. )f1,
  10177. (SELECT
  10178. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10179. t.behDeptId,
  10180. t.behDeptName,
  10181. t.doctorId,
  10182. t.doctorName
  10183. FROM
  10184. (SELECT DISTINCT
  10185. t1.hospital_id AS hospitalId,
  10186. t1.behospital_code AS behospitalCode,
  10187. t1.bed_code AS bedCode,
  10188. t1.LEVEL AS LEVEL,
  10189. t1.grade_type AS gradeType,
  10190. t1.score_res AS scoreRes,
  10191. t1.NAME AS NAME,
  10192. t1.sex AS sex,
  10193. t1.beh_dept_id AS behDeptId,
  10194. t1.beh_dept_name AS behDeptName,
  10195. t1.doctor_id AS doctorId,
  10196. t1.doctor_name AS doctorName,
  10197. t1.beh_doctor_id AS behDoctorId,
  10198. t1.beh_doctor_name AS behDoctorName,
  10199. t1.director_doctor_id AS directorDoctorId,
  10200. t1.director_doctor_name AS directorDoctorName,
  10201. t1.birthday AS birthday,
  10202. t1.behospital_date AS behospitalDate,
  10203. t1.leave_hospital_date AS leaveHospitalDate,
  10204. t1.placefile_date AS placefileDate,
  10205. t1.gmt_create AS gradeTime,
  10206. t1.diagnose,
  10207. t1.ward_name AS wardName,
  10208. t2.age,
  10209. t1.file_code AS fileCode,
  10210. t1.checkStatus,
  10211. t1.mrStatus,
  10212. t1.chName,
  10213. t1.mrName,
  10214. t1.chTime,
  10215. t1.mrTime
  10216. FROM
  10217. (
  10218. SELECT DISTINCT
  10219. tt1.*
  10220. FROM
  10221. (SELECT
  10222. be.*,
  10223. ifnull(mci.status,0) AS checkStatus,
  10224. ifnull(hm_mci.status,0) AS mrStatus,
  10225. mci.check_name as chName,
  10226. hm_mci.check_name as mrName,
  10227. mci.gmt_create as chTime,
  10228. hm_mci.gmt_create as mrTime
  10229. FROM
  10230. (
  10231. SELECT DISTINCT
  10232. a.hospital_id,
  10233. a.behospital_code,
  10234. a.bed_code,
  10235. a.file_code,
  10236. b.LEVEL,
  10237. b.grade_type,
  10238. b.score_res,
  10239. a.NAME,
  10240. a.sex,
  10241. a.beh_dept_id,
  10242. a.beh_dept_name,
  10243. a.birthday,
  10244. a.behospital_date,
  10245. a.leave_hospital_date,
  10246. a.doctor_id,
  10247. a.doctor_name,
  10248. a.beh_doctor_id,
  10249. a.beh_doctor_name,
  10250. a.director_doctor_id,
  10251. a.director_doctor_name,
  10252. a.diagnose,
  10253. a.placefile_date,
  10254. a.ward_name,
  10255. b.gmt_create
  10256. FROM
  10257. med_behospital_info a,
  10258. med_qcresult_info b,
  10259. med_qcresult_detail c,
  10260. qc_cases_entry d,
  10261. sys_user_dept e
  10262. WHERE
  10263. a.is_deleted = 'N'
  10264. AND b.is_deleted = 'N'
  10265. AND c.is_deleted = 'N'
  10266. AND d.is_deleted = 'N'
  10267. AND e.is_deleted = 'N'
  10268. AND a.hospital_id = b.hospital_id
  10269. AND a.hospital_id = c.hospital_id
  10270. AND a.hospital_id = e.hospital_id
  10271. AND a.behospital_code = b.behospital_code
  10272. AND a.behospital_code = c.behospital_code
  10273. AND a.beh_dept_id = e.dept_id
  10274. AND c.cases_id = d.cases_id
  10275. AND c.cases_entry_id = d.id
  10276. AND a.qc_type_id != 0
  10277. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10278. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10279. </if>
  10280. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10281. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10282. </if>
  10283. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10284. <if test="qcResultShortPageVO.startDate != null ">
  10285. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10286. </if>
  10287. <if test="qcResultShortPageVO.endDate != null ">
  10288. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10289. </if>
  10290. </if>
  10291. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10292. <if test="qcResultShortPageVO.startDate != null ">
  10293. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10294. </if>
  10295. <if test="qcResultShortPageVO.endDate != null">
  10296. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10297. </if>
  10298. </if>
  10299. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10300. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10301. </if>
  10302. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10303. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10304. </if>
  10305. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10306. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10307. </if>
  10308. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10309. AND b.`level` = #{qcResultShortPageVO.level}
  10310. </if>
  10311. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10312. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10313. </if>
  10314. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10315. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10316. </if>
  10317. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10318. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10319. </if>
  10320. <if test="qcResultShortPageVO.casesEntryId != null ">
  10321. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10322. </if>
  10323. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10324. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10325. </if>
  10326. <if test="qcResultShortPageVO.casesId != null">
  10327. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10328. </if>
  10329. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10330. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10331. </if>
  10332. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10333. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10334. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10335. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10336. </if>
  10337. <if test="qcResultShortPageVO.isReject != null">
  10338. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10339. </if>
  10340. <if test="qcResultShortPageVO.ruleType != null">
  10341. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10342. </if>
  10343. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10344. AND TIMESTAMPDIFF(
  10345. DAY,
  10346. DATE( a.behospital_date ),
  10347. DATE( a.leave_hospital_date ))> 30
  10348. </if>
  10349. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10350. AND TIMESTAMPDIFF(
  10351. DAY,
  10352. DATE( a.behospital_date ),
  10353. DATE( a.leave_hospital_date ))> 31
  10354. </if>
  10355. )be
  10356. left join med_check_info mci
  10357. on mci.is_deleted = 'N'
  10358. and mci.check_type = 0
  10359. and be.hospital_id = mci.hospital_id
  10360. and be.behospital_code = mci.behospital_code
  10361. left join med_check_info hm_mci
  10362. on hm_mci.is_deleted = 'N'
  10363. and hm_mci.check_type = 1
  10364. and be.hospital_id = hm_mci.hospital_id
  10365. and be.behospital_code = hm_mci.behospital_code
  10366. )tt1
  10367. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10368. ,med_medical_record tt2
  10369. WHERE
  10370. tt2.is_deleted = 'N'
  10371. AND tt1.hospital_id = tt2.hospital_id
  10372. AND tt1.behospital_code = tt2.behospital_code
  10373. AND tt2.mode_id = 30
  10374. </if>
  10375. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10376. ,med_crisis_info tt2
  10377. WHERE
  10378. tt2.is_deleted = 'N'
  10379. AND tt1.hospital_id = tt2.hospital_id
  10380. AND tt1.behospital_code = tt2.behospital_code
  10381. </if>
  10382. ) t1
  10383. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10384. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10385. AND t1.behospital_code = t2.behospital_code
  10386. AND t2.is_deleted = 'N'
  10387. </if>
  10388. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10389. , med_home_page t2
  10390. , med_home_operation_info t3
  10391. WHERE t1.hospital_id = t2.hospital_id
  10392. AND t1.behospital_code = t2.behospital_code
  10393. AND t2.home_page_id = t3.home_page_id
  10394. AND t2.is_deleted = 'N'
  10395. AND t3.is_deleted = 'N'
  10396. </if>
  10397. ) t
  10398. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10399. AND t.hospitalId = qi.hospital_id
  10400. AND t.behospitalCode = qi.behospital_code
  10401. where 1=1
  10402. <if test="qcResultShortPageVO.checkStatus != null">
  10403. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10404. </if>
  10405. <if test="qcResultShortPageVO.mrStatus != null">
  10406. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10407. </if>
  10408. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10409. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10410. </if>
  10411. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10412. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10413. </if>
  10414. <if test="qcResultShortPageVO.chTimeStart != null ">
  10415. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10416. </if>
  10417. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10418. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10419. </if>
  10420. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10421. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10422. </if>
  10423. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10424. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10425. </if>
  10426. GROUP BY
  10427. t.behDeptId,
  10428. t.behDeptName,
  10429. t.doctorId,
  10430. t.doctorName
  10431. )f2
  10432. WHERE
  10433. f1.doctorId = f2.doctorId
  10434. AND f1.doctorName = f2.doctorName
  10435. )m
  10436. </select>
  10437. <!-- 条目缺陷评分详情页导出-->
  10438. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  10439. SELECT * from(
  10440. SELECT
  10441. f1.*,
  10442. f2.avgScore
  10443. FROM
  10444. (SELECT
  10445. t.*,
  10446. qi.score_res AS score,
  10447. qd.msg AS msg,
  10448. qc.NAME AS caseName
  10449. FROM
  10450. (SELECT DISTINCT
  10451. t1.hospital_id AS hospitalId,
  10452. t1.behospital_code AS behospitalCode,
  10453. t1.bed_code AS bedCode,
  10454. t1.LEVEL AS LEVEL,
  10455. t1.grade_type AS gradeType,
  10456. t1.score_res AS scoreRes,
  10457. t1.scoreBn AS scoreBn,
  10458. t1.NAME AS patName,
  10459. t1.sex AS sex,
  10460. t1.beh_dept_id AS behDeptId,
  10461. t1.beh_dept_name AS behDeptName,
  10462. t1.doctor_id AS doctorId,
  10463. t1.doctor_name AS doctorName,
  10464. t1.beh_doctor_id AS behDoctorId,
  10465. t1.beh_doctor_name AS behDoctorName,
  10466. t1.director_doctor_id AS directorDoctorId,
  10467. t1.director_doctor_name AS directorDoctorName,
  10468. t1.birthday AS birthday,
  10469. t1.behospital_date AS behospitalDate,
  10470. t1.leave_hospital_date AS leaveHospitalDate,
  10471. t1.placefile_date AS placefileDate,
  10472. t1.gmt_create AS gradeTime,
  10473. t1.diagnose AS diagnose,
  10474. t1.ward_name AS wardName,
  10475. t1.file_code AS fileCode,
  10476. t1.checkStatus AS checkStatus,
  10477. t1.mrStatus AS mrStatus,
  10478. t1.chName AS chName,
  10479. t1.mrName AS mrName,
  10480. t1.chTime AS chTime,
  10481. t1.mrTime AS mrTime
  10482. FROM
  10483. (
  10484. SELECT DISTINCT
  10485. tt1.*
  10486. FROM
  10487. (SELECT
  10488. be.*,
  10489. ifnull(mci.status,0) AS checkStatus,
  10490. ifnull(hm_mci.status,0) AS mrStatus,
  10491. mci.check_name as chName,
  10492. hm_mci.check_name as mrName,
  10493. mci.gmt_create as chTime,
  10494. e.score_res as scoreBn,
  10495. hm_mci.gmt_create as mrTime
  10496. FROM
  10497. (
  10498. SELECT DISTINCT
  10499. a.hospital_id,
  10500. a.behospital_code,
  10501. a.bed_code,
  10502. a.file_code,
  10503. b.LEVEL,
  10504. b.grade_type,
  10505. b.score_res,
  10506. a.NAME,
  10507. a.sex,
  10508. a.beh_dept_id,
  10509. a.beh_dept_name,
  10510. a.birthday,
  10511. a.behospital_date,
  10512. a.leave_hospital_date,
  10513. a.doctor_id,
  10514. a.doctor_name,
  10515. a.beh_doctor_id,
  10516. a.beh_doctor_name,
  10517. a.director_doctor_id,
  10518. a.director_doctor_name,
  10519. a.diagnose,
  10520. a.placefile_date,
  10521. a.ward_name,
  10522. b.gmt_create
  10523. FROM
  10524. med_behospital_info a,
  10525. med_qcresult_info b,
  10526. med_qcresult_detail c,
  10527. qc_cases_entry d
  10528. WHERE
  10529. a.is_deleted = 'N'
  10530. AND b.is_deleted = 'N'
  10531. AND c.is_deleted = 'N'
  10532. AND d.is_deleted = 'N'
  10533. AND a.hospital_id = b.hospital_id
  10534. AND a.hospital_id = c.hospital_id
  10535. AND a.behospital_code = b.behospital_code
  10536. AND a.behospital_code = c.behospital_code
  10537. AND c.cases_id = d.cases_id
  10538. AND c.cases_entry_id = d.id
  10539. AND a.qc_type_id != 0
  10540. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10541. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10542. </if>
  10543. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10544. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10545. </if>
  10546. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10547. <if test="qcResultShortPageVO.startDate != null ">
  10548. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10549. </if>
  10550. <if test="qcResultShortPageVO.endDate != null ">
  10551. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10552. </if>
  10553. </if>
  10554. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10555. <if test="qcResultShortPageVO.startDate != null ">
  10556. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10557. </if>
  10558. <if test="qcResultShortPageVO.endDate != null">
  10559. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10560. </if>
  10561. </if>
  10562. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10563. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10564. </if>
  10565. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10566. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10567. </if>
  10568. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10569. AND b.`level` = #{qcResultShortPageVO.level}
  10570. </if>
  10571. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10572. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10573. </if>
  10574. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10575. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10576. </if>
  10577. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10578. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10579. </if>
  10580. <if test="qcResultShortPageVO.casesEntryId != null ">
  10581. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10582. </if>
  10583. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10584. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10585. </if>
  10586. <if test="qcResultShortPageVO.casesId != null">
  10587. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10588. </if>
  10589. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10590. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10591. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10592. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10593. </if>
  10594. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10595. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10596. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10597. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10598. </if>
  10599. <if test="qcResultShortPageVO.isReject != null">
  10600. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10601. </if>
  10602. <if test="qcResultShortPageVO.ruleType != null">
  10603. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10604. </if>
  10605. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10606. AND TIMESTAMPDIFF(
  10607. DAY,
  10608. DATE( a.behospital_date ),
  10609. DATE( a.leave_hospital_date ))> 30
  10610. </if>
  10611. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10612. AND TIMESTAMPDIFF(
  10613. DAY,
  10614. DATE( a.behospital_date ),
  10615. DATE( a.leave_hospital_date ))> 31
  10616. </if>
  10617. )be
  10618. left join med_check_info mci
  10619. on mci.is_deleted = 'N'
  10620. and mci.check_type = 0
  10621. and be.hospital_id = mci.hospital_id
  10622. and be.behospital_code = mci.behospital_code
  10623. left join med_check_info hm_mci
  10624. on hm_mci.is_deleted = 'N'
  10625. and hm_mci.check_type = 1
  10626. and be.hospital_id = hm_mci.hospital_id
  10627. and be.behospital_code = hm_mci.behospital_code
  10628. LEFT JOIN med_qcresult_cases e
  10629. on be.behospital_code = e.behospital_code
  10630. and be.hospital_id = e.hospital_id
  10631. AND e.is_deleted = 'N'
  10632. and e.cases_id = 243
  10633. )tt1
  10634. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10635. ,med_medical_record tt2
  10636. WHERE
  10637. tt2.is_deleted = 'N'
  10638. AND tt1.hospital_id = tt2.hospital_id
  10639. AND tt1.behospital_code = tt2.behospital_code
  10640. AND tt2.mode_id = 30
  10641. </if>
  10642. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10643. ,med_crisis_info tt2
  10644. WHERE
  10645. tt2.is_deleted = 'N'
  10646. AND tt1.hospital_id = tt2.hospital_id
  10647. AND tt1.behospital_code = tt2.behospital_code
  10648. </if>
  10649. ) t1
  10650. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10651. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10652. AND t1.behospital_code = t2.behospital_code
  10653. AND t2.is_deleted = 'N'
  10654. </if>
  10655. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10656. , med_home_page t2
  10657. , med_home_operation_info t3
  10658. WHERE t1.hospital_id = t2.hospital_id
  10659. AND t1.behospital_code = t2.behospital_code
  10660. AND t2.home_page_id = t3.home_page_id
  10661. AND t2.is_deleted = 'N'
  10662. AND t3.is_deleted = 'N'
  10663. </if>
  10664. ) t
  10665. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10666. AND t.hospitalId = qi.hospital_id
  10667. AND t.behospitalCode = qi.behospital_code
  10668. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10669. AND t.hospitalId = qd.hospital_id
  10670. AND t.behospitalCode = qd.behospital_code
  10671. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10672. AND qd.cases_id = qc.id
  10673. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10674. AND qd.cases_id = qce.cases_id
  10675. AND qd.cases_entry_id = qce.id
  10676. where 1=1
  10677. <if test="qcResultShortPageVO.checkStatus != null">
  10678. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10679. </if>
  10680. <if test="qcResultShortPageVO.mrStatus != null">
  10681. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10682. </if>
  10683. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10684. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10685. </if>
  10686. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10687. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10688. </if>
  10689. <if test="qcResultShortPageVO.chTimeStart != null ">
  10690. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10691. </if>
  10692. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10693. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10694. </if>
  10695. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10696. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10697. </if>
  10698. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10699. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10700. </if>
  10701. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10702. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10703. </if>
  10704. <if test="qcResultShortPageVO.casesEntryId != null ">
  10705. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10706. </if>
  10707. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10708. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10709. </if>
  10710. <if test="qcResultShortPageVO.casesId != null">
  10711. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10712. </if>
  10713. )f1,
  10714. (SELECT
  10715. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10716. t.behDeptId,
  10717. t.behDeptName
  10718. FROM
  10719. (SELECT DISTINCT
  10720. t1.hospital_id AS hospitalId,
  10721. t1.behospital_code AS behospitalCode,
  10722. t1.bed_code AS bedCode,
  10723. t1.LEVEL AS LEVEL,
  10724. t1.grade_type AS gradeType,
  10725. t1.score_res AS scoreRes,
  10726. t1.NAME AS NAME,
  10727. t1.sex AS sex,
  10728. t1.beh_dept_id AS behDeptId,
  10729. t1.beh_dept_name AS behDeptName,
  10730. t1.doctor_id AS doctorId,
  10731. t1.doctor_name AS doctorName,
  10732. t1.beh_doctor_id AS behDoctorId,
  10733. t1.beh_doctor_name AS behDoctorName,
  10734. t1.director_doctor_id AS directorDoctorId,
  10735. t1.director_doctor_name AS directorDoctorName,
  10736. t1.birthday AS birthday,
  10737. t1.behospital_date AS behospitalDate,
  10738. t1.leave_hospital_date AS leaveHospitalDate,
  10739. t1.placefile_date AS placefileDate,
  10740. t1.gmt_create AS gradeTime,
  10741. t1.diagnose,
  10742. t1.ward_name AS wardName,
  10743. t2.age,
  10744. t1.file_code AS fileCode,
  10745. t1.checkStatus,
  10746. t1.mrStatus,
  10747. t1.chName,
  10748. t1.mrName,
  10749. t1.chTime,
  10750. t1.mrTime
  10751. FROM
  10752. (
  10753. SELECT DISTINCT
  10754. tt1.*
  10755. FROM
  10756. (SELECT
  10757. be.*,
  10758. ifnull(mci.status,0) AS checkStatus,
  10759. ifnull(hm_mci.status,0) AS mrStatus,
  10760. mci.check_name as chName,
  10761. hm_mci.check_name as mrName,
  10762. mci.gmt_create as chTime,
  10763. hm_mci.gmt_create as mrTime
  10764. FROM
  10765. (
  10766. SELECT DISTINCT
  10767. a.hospital_id,
  10768. a.behospital_code,
  10769. a.bed_code,
  10770. a.file_code,
  10771. b.LEVEL,
  10772. b.grade_type,
  10773. b.score_res,
  10774. a.NAME,
  10775. a.sex,
  10776. a.beh_dept_id,
  10777. a.beh_dept_name,
  10778. a.birthday,
  10779. a.behospital_date,
  10780. a.leave_hospital_date,
  10781. a.doctor_id,
  10782. a.doctor_name,
  10783. a.beh_doctor_id,
  10784. a.beh_doctor_name,
  10785. a.director_doctor_id,
  10786. a.director_doctor_name,
  10787. a.diagnose,
  10788. a.placefile_date,
  10789. a.ward_name,
  10790. b.gmt_create
  10791. FROM
  10792. med_behospital_info a,
  10793. med_qcresult_info b,
  10794. med_qcresult_detail c,
  10795. qc_cases_entry d
  10796. WHERE
  10797. a.is_deleted = 'N'
  10798. AND b.is_deleted = 'N'
  10799. AND c.is_deleted = 'N'
  10800. AND d.is_deleted = 'N'
  10801. AND a.hospital_id = b.hospital_id
  10802. AND a.hospital_id = c.hospital_id
  10803. AND a.behospital_code = b.behospital_code
  10804. AND a.behospital_code = c.behospital_code
  10805. AND c.cases_id = d.cases_id
  10806. AND c.cases_entry_id = d.id
  10807. AND a.qc_type_id != 0
  10808. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10809. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10810. </if>
  10811. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10812. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10813. </if>
  10814. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10815. <if test="qcResultShortPageVO.startDate != null ">
  10816. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10817. </if>
  10818. <if test="qcResultShortPageVO.endDate != null ">
  10819. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10820. </if>
  10821. </if>
  10822. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10823. <if test="qcResultShortPageVO.startDate != null ">
  10824. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10825. </if>
  10826. <if test="qcResultShortPageVO.endDate != null">
  10827. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10828. </if>
  10829. </if>
  10830. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10831. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10832. </if>
  10833. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10834. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10835. </if>
  10836. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10837. AND b.`level` = #{qcResultShortPageVO.level}
  10838. </if>
  10839. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10840. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10841. </if>
  10842. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10843. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10844. </if>
  10845. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10846. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10847. </if>
  10848. <if test="qcResultShortPageVO.casesEntryId != null ">
  10849. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10850. </if>
  10851. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10852. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10853. </if>
  10854. <if test="qcResultShortPageVO.casesId != null">
  10855. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10856. </if>
  10857. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10858. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10859. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10860. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10861. </if>
  10862. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10863. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10864. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10865. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10866. </if>
  10867. <if test="qcResultShortPageVO.isReject != null">
  10868. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10869. </if>
  10870. <if test="qcResultShortPageVO.ruleType != null">
  10871. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10872. </if>
  10873. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10874. AND TIMESTAMPDIFF(
  10875. DAY,
  10876. DATE( a.behospital_date ),
  10877. DATE( a.leave_hospital_date ))> 30
  10878. </if>
  10879. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10880. AND TIMESTAMPDIFF(
  10881. DAY,
  10882. DATE( a.behospital_date ),
  10883. DATE( a.leave_hospital_date ))> 31
  10884. </if>
  10885. )be
  10886. left join med_check_info mci
  10887. on mci.is_deleted = 'N'
  10888. and mci.check_type = 0
  10889. and be.hospital_id = mci.hospital_id
  10890. and be.behospital_code = mci.behospital_code
  10891. left join med_check_info hm_mci
  10892. on hm_mci.is_deleted = 'N'
  10893. and hm_mci.check_type = 1
  10894. and be.hospital_id = hm_mci.hospital_id
  10895. and be.behospital_code = hm_mci.behospital_code
  10896. )tt1
  10897. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10898. ,med_medical_record tt2
  10899. WHERE
  10900. tt2.is_deleted = 'N'
  10901. AND tt1.hospital_id = tt2.hospital_id
  10902. AND tt1.behospital_code = tt2.behospital_code
  10903. AND tt2.mode_id = 30
  10904. </if>
  10905. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10906. ,med_crisis_info tt2
  10907. WHERE
  10908. tt2.is_deleted = 'N'
  10909. AND tt1.hospital_id = tt2.hospital_id
  10910. AND tt1.behospital_code = tt2.behospital_code
  10911. </if>
  10912. ) t1
  10913. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10914. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10915. AND t1.behospital_code = t2.behospital_code
  10916. AND t2.is_deleted = 'N'
  10917. </if>
  10918. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10919. , med_home_page t2
  10920. , med_home_operation_info t3
  10921. WHERE t1.hospital_id = t2.hospital_id
  10922. AND t1.behospital_code = t2.behospital_code
  10923. AND t2.home_page_id = t3.home_page_id
  10924. AND t2.is_deleted = 'N'
  10925. AND t3.is_deleted = 'N'
  10926. </if>
  10927. ) t
  10928. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10929. AND t.hospitalId = qi.hospital_id
  10930. AND t.behospitalCode = qi.behospital_code
  10931. where 1=1
  10932. <if test="qcResultShortPageVO.checkStatus != null">
  10933. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10934. </if>
  10935. <if test="qcResultShortPageVO.mrStatus != null">
  10936. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10937. </if>
  10938. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10939. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10940. </if>
  10941. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10942. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10943. </if>
  10944. <if test="qcResultShortPageVO.chTimeStart != null ">
  10945. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10946. </if>
  10947. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10948. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10949. </if>
  10950. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10951. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10952. </if>
  10953. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10954. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10955. </if>
  10956. GROUP BY
  10957. t.behDeptId,
  10958. t.behDeptName
  10959. )f2
  10960. WHERE
  10961. f1.behDeptId = f2.behDeptId
  10962. AND f1.behDeptName = f2.behDeptName
  10963. )m
  10964. </select>
  10965. <!-- 条目缺陷评分详情页导出湘雅-->
  10966. <select id="qcResultShortXYPageExport" resultMap="ExportExcelMap">
  10967. SELECT * from(
  10968. SELECT
  10969. f1.*,
  10970. f2.avgScore
  10971. FROM
  10972. (SELECT
  10973. t.*,
  10974. qi.score_res AS score,
  10975. qd.msg AS msg,
  10976. qc.NAME AS caseName
  10977. FROM
  10978. (SELECT DISTINCT
  10979. t1.hospital_id AS hospitalId,
  10980. t1.behospital_code AS behospitalCode,
  10981. t1.bed_code AS bedCode,
  10982. t1.LEVEL AS LEVEL,
  10983. t1.grade_type AS gradeType,
  10984. t1.score_res AS scoreRes,
  10985. t1.scoreBn AS scoreBn,
  10986. t1.NAME AS patName,
  10987. t1.sex AS sex,
  10988. t1.beh_dept_id AS behDeptId,
  10989. t1.beh_dept_name AS behDeptName,
  10990. t1.doctor_name AS doctorName,
  10991. t1.birthday AS birthday,
  10992. t1.behospital_date AS behospitalDate,
  10993. t1.leave_hospital_date AS leaveHospitalDate,
  10994. t1.placefile_date AS placefileDate,
  10995. t1.gmt_create AS gradeTime,
  10996. t1.diagnose AS diagnose,
  10997. t1.ward_name AS wardName,
  10998. t1.file_code AS fileCode,
  10999. t1.checkStatus AS checkStatus,
  11000. t1.mrStatus AS mrStatus,
  11001. t1.chName AS chName,
  11002. t1.mrName AS mrName,
  11003. t1.chTime AS chTime,
  11004. t1.mrTime AS mrTime
  11005. FROM
  11006. (
  11007. SELECT DISTINCT
  11008. tt1.*
  11009. FROM
  11010. (SELECT
  11011. be.*,
  11012. ifnull(mci.status,0) AS checkStatus,
  11013. ifnull(hm_mci.status,0) AS mrStatus,
  11014. mci.check_name as chName,
  11015. hm_mci.check_name as mrName,
  11016. mci.gmt_create as chTime,
  11017. e.score_res as scoreBn,
  11018. hm_mci.gmt_create as mrTime
  11019. FROM
  11020. (
  11021. SELECT DISTINCT
  11022. a.hospital_id,
  11023. a.behospital_code,
  11024. a.bed_code,
  11025. a.file_code,
  11026. b.LEVEL,
  11027. b.grade_type,
  11028. b.score_res,
  11029. a.NAME,
  11030. a.sex,
  11031. a.beh_dept_id,
  11032. a.beh_dept_name,
  11033. a.birthday,
  11034. a.behospital_date,
  11035. a.leave_hospital_date,
  11036. case
  11037. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11038. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11039. e.director_doctor != '' and e.director_doctor is not null
  11040. then e.director_doctor
  11041. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11042. (e.director_doctor = '' or e.director_doctor is null) and
  11043. e.behospital_doctor != '' and e.behospital_doctor is not null
  11044. then e.behospital_doctor end as doctor_name,
  11045. a.diagnose,
  11046. a.placefile_date,
  11047. a.ward_name,
  11048. b.gmt_create
  11049. FROM
  11050. med_behospital_info a,
  11051. med_qcresult_info b,
  11052. med_qcresult_detail c,
  11053. qc_cases_entry d,
  11054. med_home_page e
  11055. WHERE
  11056. a.is_deleted = 'N'
  11057. AND b.is_deleted = 'N'
  11058. AND c.is_deleted = 'N'
  11059. AND d.is_deleted = 'N'
  11060. AND e.is_deleted = 'N'
  11061. AND a.hospital_id = b.hospital_id
  11062. AND a.hospital_id = c.hospital_id
  11063. AND a.hospital_id = e.hospital_id
  11064. AND a.behospital_code = b.behospital_code
  11065. AND a.behospital_code = c.behospital_code
  11066. AND a.behospital_code = e.behospital_code
  11067. AND c.cases_id = d.cases_id
  11068. AND c.cases_entry_id = d.id
  11069. AND a.qc_type_id != 0
  11070. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11071. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11072. </if>
  11073. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11074. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11075. </if>
  11076. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11077. <if test="qcResultShortPageVO.startDate != null ">
  11078. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11079. </if>
  11080. <if test="qcResultShortPageVO.endDate != null ">
  11081. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11082. </if>
  11083. </if>
  11084. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11085. <if test="qcResultShortPageVO.startDate != null ">
  11086. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11087. </if>
  11088. <if test="qcResultShortPageVO.endDate != null">
  11089. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11090. </if>
  11091. </if>
  11092. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11093. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11094. </if>
  11095. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11096. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11097. </if>
  11098. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  11099. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  11100. </if>
  11101. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11102. AND b.`level` = #{qcResultShortPageVO.level}
  11103. </if>
  11104. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11105. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11106. </if>
  11107. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11108. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11109. </if>
  11110. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11111. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11112. </if>
  11113. <if test="qcResultShortPageVO.casesEntryId != null ">
  11114. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11115. </if>
  11116. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11117. AND d.cases_name = #{qcResultShortPageVO.casesName}
  11118. </if>
  11119. <if test="qcResultShortPageVO.casesId != null">
  11120. AND d.cases_id = #{qcResultShortPageVO.casesId}
  11121. </if>
  11122. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11123. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  11124. </if>
  11125. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11126. AND(case
  11127. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11128. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11129. e.director_doctor != '' and e.director_doctor is not null
  11130. then e.director_doctor
  11131. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11132. (e.director_doctor = '' or e.director_doctor is null) and
  11133. e.behospital_doctor != '' and e.behospital_doctor is not null
  11134. then e.behospital_doctor end ) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11135. </if>
  11136. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  11137. AND(case
  11138. when e.attending_doctor != '' and e.attending_doctor is not null then '主治医师'
  11139. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11140. e.director_doctor != '' and e.director_doctor is not null
  11141. then '主任医师'
  11142. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11143. (e.director_doctor = '' or e.director_doctor is null) and
  11144. e.behospital_doctor != '' and e.behospital_doctor is not null
  11145. then '住院医师' end) = #{qcResultShortPageVO.professor}
  11146. </if>
  11147. <if test="qcResultShortPageVO.isReject != null">
  11148. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11149. </if>
  11150. <if test="qcResultShortPageVO.ruleType != null">
  11151. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11152. </if>
  11153. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  11154. AND TIMESTAMPDIFF(
  11155. DAY,
  11156. DATE( a.behospital_date ),
  11157. DATE( a.leave_hospital_date ))> 30
  11158. </if>
  11159. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  11160. AND TIMESTAMPDIFF(
  11161. DAY,
  11162. DATE( a.behospital_date ),
  11163. DATE( a.leave_hospital_date ))> 31
  11164. </if>
  11165. )be
  11166. left join med_check_info mci
  11167. on mci.is_deleted = 'N'
  11168. and mci.check_type = 0
  11169. and be.hospital_id = mci.hospital_id
  11170. and be.behospital_code = mci.behospital_code
  11171. left join med_check_info hm_mci
  11172. on hm_mci.is_deleted = 'N'
  11173. and hm_mci.check_type = 1
  11174. and be.hospital_id = hm_mci.hospital_id
  11175. and be.behospital_code = hm_mci.behospital_code
  11176. LEFT JOIN med_qcresult_cases e
  11177. on be.behospital_code = e.behospital_code
  11178. and be.hospital_id = e.hospital_id
  11179. AND e.is_deleted = 'N'
  11180. and e.cases_id = 243
  11181. )tt1
  11182. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  11183. ,med_medical_record tt2
  11184. WHERE
  11185. tt2.is_deleted = 'N'
  11186. AND tt1.hospital_id = tt2.hospital_id
  11187. AND tt1.behospital_code = tt2.behospital_code
  11188. AND tt2.mode_id = 30
  11189. </if>
  11190. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  11191. ,med_crisis_info tt2
  11192. WHERE
  11193. tt2.is_deleted = 'N'
  11194. AND tt1.hospital_id = tt2.hospital_id
  11195. AND tt1.behospital_code = tt2.behospital_code
  11196. </if>
  11197. ) t1
  11198. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  11199. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11200. AND t1.behospital_code = t2.behospital_code
  11201. AND t2.is_deleted = 'N'
  11202. </if>
  11203. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  11204. , med_home_page t2
  11205. , med_home_operation_info t3
  11206. WHERE t1.hospital_id = t2.hospital_id
  11207. AND t1.behospital_code = t2.behospital_code
  11208. AND t2.home_page_id = t3.home_page_id
  11209. AND t2.is_deleted = 'N'
  11210. AND t3.is_deleted = 'N'
  11211. </if>
  11212. ) t
  11213. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11214. AND t.hospitalId = qi.hospital_id
  11215. AND t.behospitalCode = qi.behospital_code
  11216. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  11217. AND t.hospitalId = qd.hospital_id
  11218. AND t.behospitalCode = qd.behospital_code
  11219. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  11220. AND qd.cases_id = qc.id
  11221. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  11222. AND qd.cases_id = qce.cases_id
  11223. AND qd.cases_entry_id = qce.id
  11224. where 1=1
  11225. <if test="qcResultShortPageVO.checkStatus != null">
  11226. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11227. </if>
  11228. <if test="qcResultShortPageVO.mrStatus != null">
  11229. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11230. </if>
  11231. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11232. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11233. </if>
  11234. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11235. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11236. </if>
  11237. <if test="qcResultShortPageVO.chTimeStart != null ">
  11238. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11239. </if>
  11240. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11241. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11242. </if>
  11243. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11244. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11245. </if>
  11246. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11247. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11248. </if>
  11249. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11250. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  11251. </if>
  11252. <if test="qcResultShortPageVO.casesEntryId != null ">
  11253. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  11254. </if>
  11255. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11256. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  11257. </if>
  11258. <if test="qcResultShortPageVO.casesId != null">
  11259. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  11260. </if>
  11261. )f1,
  11262. (SELECT
  11263. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  11264. t.behDeptId,
  11265. t.behDeptName
  11266. FROM
  11267. (SELECT DISTINCT
  11268. t1.hospital_id AS hospitalId,
  11269. t1.behospital_code AS behospitalCode,
  11270. t1.bed_code AS bedCode,
  11271. t1.LEVEL AS LEVEL,
  11272. t1.grade_type AS gradeType,
  11273. t1.score_res AS scoreRes,
  11274. t1.NAME AS NAME,
  11275. t1.sex AS sex,
  11276. t1.beh_dept_id AS behDeptId,
  11277. t1.beh_dept_name AS behDeptName,
  11278. t1.birthday AS birthday,
  11279. t1.behospital_date AS behospitalDate,
  11280. t1.leave_hospital_date AS leaveHospitalDate,
  11281. t1.placefile_date AS placefileDate,
  11282. t1.gmt_create AS gradeTime,
  11283. t1.diagnose,
  11284. t1.ward_name AS wardName,
  11285. t2.age,
  11286. t1.file_code AS fileCode,
  11287. t1.checkStatus,
  11288. t1.mrStatus,
  11289. t1.chName,
  11290. t1.mrName,
  11291. t1.chTime,
  11292. t1.mrTime
  11293. FROM
  11294. (
  11295. SELECT DISTINCT
  11296. tt1.*
  11297. FROM
  11298. (SELECT
  11299. be.*,
  11300. ifnull(mci.status,0) AS checkStatus,
  11301. ifnull(hm_mci.status,0) AS mrStatus,
  11302. mci.check_name as chName,
  11303. hm_mci.check_name as mrName,
  11304. mci.gmt_create as chTime,
  11305. hm_mci.gmt_create as mrTime
  11306. FROM
  11307. (
  11308. SELECT DISTINCT
  11309. a.hospital_id,
  11310. a.behospital_code,
  11311. a.bed_code,
  11312. a.file_code,
  11313. b.LEVEL,
  11314. b.grade_type,
  11315. b.score_res,
  11316. a.NAME,
  11317. a.sex,
  11318. a.beh_dept_id,
  11319. a.beh_dept_name,
  11320. a.birthday,
  11321. a.behospital_date,
  11322. a.leave_hospital_date,
  11323. a.diagnose,
  11324. a.placefile_date,
  11325. a.ward_name,
  11326. b.gmt_create
  11327. FROM
  11328. med_behospital_info a,
  11329. med_qcresult_info b,
  11330. med_qcresult_detail c,
  11331. qc_cases_entry d,
  11332. med_home_page e
  11333. WHERE
  11334. a.is_deleted = 'N'
  11335. AND b.is_deleted = 'N'
  11336. AND c.is_deleted = 'N'
  11337. AND d.is_deleted = 'N'
  11338. AND e.is_deleted = 'N'
  11339. AND a.hospital_id = b.hospital_id
  11340. AND a.hospital_id = c.hospital_id
  11341. AND a.hospital_id = e.hospital_id
  11342. AND a.behospital_code = b.behospital_code
  11343. AND a.behospital_code = c.behospital_code
  11344. AND a.behospital_code = e.behospital_code
  11345. AND c.cases_id = d.cases_id
  11346. AND c.cases_entry_id = d.id
  11347. AND a.qc_type_id != 0
  11348. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11349. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11350. </if>
  11351. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11352. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11353. </if>
  11354. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11355. <if test="qcResultShortPageVO.startDate != null ">
  11356. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11357. </if>
  11358. <if test="qcResultShortPageVO.endDate != null ">
  11359. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11360. </if>
  11361. </if>
  11362. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11363. <if test="qcResultShortPageVO.startDate != null ">
  11364. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11365. </if>
  11366. <if test="qcResultShortPageVO.endDate != null">
  11367. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11368. </if>
  11369. </if>
  11370. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11371. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11372. </if>
  11373. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11374. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11375. </if>
  11376. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  11377. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  11378. </if>
  11379. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11380. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  11381. </if>
  11382. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11383. AND b.`level` = #{qcResultShortPageVO.level}
  11384. </if>
  11385. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11386. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11387. </if>
  11388. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11389. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11390. </if>
  11391. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11392. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11393. </if>
  11394. <if test="qcResultShortPageVO.casesEntryId != null ">
  11395. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11396. </if>
  11397. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  11398. AND d.cases_name = #{qcResultShortPageVO.casesName}
  11399. </if>
  11400. <if test="qcResultShortPageVO.casesId != null">
  11401. AND d.cases_id = #{qcResultShortPageVO.casesId}
  11402. </if>
  11403. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11404. AND(case
  11405. when e.attending_doctor != '' and e.attending_doctor is not null then e.attending_doctor
  11406. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11407. e.director_doctor != '' and e.director_doctor is not null
  11408. then e.director_doctor
  11409. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11410. (e.director_doctor = '' or e.director_doctor is null) and
  11411. e.behospital_doctor != '' and e.behospital_doctor is not null
  11412. then e.behospital_doctor end ) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11413. </if>
  11414. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  11415. AND(case
  11416. when e.attending_doctor != '' and e.attending_doctor is not null then '主治医师'
  11417. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11418. e.director_doctor != '' and e.director_doctor is not null
  11419. then '主任医师'
  11420. when (e.attending_doctor = '' or e.attending_doctor is null) and
  11421. (e.director_doctor = '' or e.director_doctor is null) and
  11422. e.behospital_doctor != '' and e.behospital_doctor is not null
  11423. then '住院医师' end) = #{qcResultShortPageVO.professor}
  11424. </if>
  11425. <if test="qcResultShortPageVO.isReject != null">
  11426. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11427. </if>
  11428. <if test="qcResultShortPageVO.ruleType != null">
  11429. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11430. </if>
  11431. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  11432. AND TIMESTAMPDIFF(
  11433. DAY,
  11434. DATE( a.behospital_date ),
  11435. DATE( a.leave_hospital_date ))> 30
  11436. </if>
  11437. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  11438. AND TIMESTAMPDIFF(
  11439. DAY,
  11440. DATE( a.behospital_date ),
  11441. DATE( a.leave_hospital_date ))> 31
  11442. </if>
  11443. )be
  11444. left join med_check_info mci
  11445. on mci.is_deleted = 'N'
  11446. and mci.check_type = 0
  11447. and be.hospital_id = mci.hospital_id
  11448. and be.behospital_code = mci.behospital_code
  11449. left join med_check_info hm_mci
  11450. on hm_mci.is_deleted = 'N'
  11451. and hm_mci.check_type = 1
  11452. and be.hospital_id = hm_mci.hospital_id
  11453. and be.behospital_code = hm_mci.behospital_code
  11454. )tt1
  11455. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  11456. ,med_medical_record tt2
  11457. WHERE
  11458. tt2.is_deleted = 'N'
  11459. AND tt1.hospital_id = tt2.hospital_id
  11460. AND tt1.behospital_code = tt2.behospital_code
  11461. AND tt2.mode_id = 30
  11462. </if>
  11463. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  11464. ,med_crisis_info tt2
  11465. WHERE
  11466. tt2.is_deleted = 'N'
  11467. AND tt1.hospital_id = tt2.hospital_id
  11468. AND tt1.behospital_code = tt2.behospital_code
  11469. </if>
  11470. ) t1
  11471. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  11472. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11473. AND t1.behospital_code = t2.behospital_code
  11474. AND t2.is_deleted = 'N'
  11475. </if>
  11476. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  11477. , med_home_page t2
  11478. , med_home_operation_info t3
  11479. WHERE t1.hospital_id = t2.hospital_id
  11480. AND t1.behospital_code = t2.behospital_code
  11481. AND t2.home_page_id = t3.home_page_id
  11482. AND t2.is_deleted = 'N'
  11483. AND t3.is_deleted = 'N'
  11484. </if>
  11485. ) t
  11486. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11487. AND t.hospitalId = qi.hospital_id
  11488. AND t.behospitalCode = qi.behospital_code
  11489. where 1=1
  11490. <if test="qcResultShortPageVO.checkStatus != null">
  11491. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11492. </if>
  11493. <if test="qcResultShortPageVO.mrStatus != null">
  11494. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11495. </if>
  11496. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11497. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11498. </if>
  11499. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11500. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11501. </if>
  11502. <if test="qcResultShortPageVO.chTimeStart != null ">
  11503. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11504. </if>
  11505. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11506. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11507. </if>
  11508. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11509. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11510. </if>
  11511. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11512. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11513. </if>
  11514. GROUP BY
  11515. t.behDeptId,
  11516. t.behDeptName
  11517. )f2
  11518. WHERE
  11519. f1.behDeptId = f2.behDeptId
  11520. AND f1.behDeptName = f2.behDeptName
  11521. )m
  11522. </select>
  11523. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  11524. <result column="deptName" property="deptName"/>
  11525. <result column="deptId" property="deptId"/>
  11526. <result column="doctorGroup" property="doctorGroup"/>
  11527. <result column="doctorName" property="doctorName"/>
  11528. <result column="entry_2658_num" property="entry_2658_num"/>
  11529. <result column="entry_2686_num" property="entry_2686_num"/>
  11530. <result column="entry_2657_num" property="entry_2657_num"/>
  11531. <result column="entry_3010_num" property="entry_3010_num"/>
  11532. <result column="entry_2655_num" property="entry_2655_num"/>
  11533. <result column="entry_2654_num" property="entry_2654_num"/>
  11534. <result column="entry_2852_num" property="entry_2852_num"/>
  11535. <result column="entry_2287_num" property="entry_2287_num"/>
  11536. <result column="entry_3025_num" property="entry_3025_num"/>
  11537. <result column="entry_2170_num" property="entry_2170_num"/>
  11538. <result column="entry_2930_num" property="entry_2930_num"/>
  11539. <result column="entry_2900_num" property="entry_2900_num"/>
  11540. <result column="entry_2229_num" property="entry_2229_num"/>
  11541. <result column="entry_2217_num" property="entry_2217_num"/>
  11542. <result column="entry_2218_num" property="entry_2218_num"/>
  11543. <result column="entry_2220_num" property="entry_2220_num"/>
  11544. <result column="entry_2486_num" property="entry_2486_num"/>
  11545. <result column="entry_3063_num" property="entry_3063_num"/>
  11546. <result column="entry_3062_num" property="entry_3062_num"/>
  11547. <result column="entry_2495_num" property="entry_2495_num"/>
  11548. </resultMap>
  11549. <!-- 病历稽查表-->
  11550. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  11551. SELECT
  11552. a.beh_dept_id AS deptId,
  11553. a.beh_dept_name AS deptName,
  11554. a.doctor_name as doctorGroup,
  11555. a.doctor_name as doctorName,
  11556. sum(c.cases_entry_id = 2658) as entry_2658_num,
  11557. sum(c.cases_entry_id = 2686) as entry_2686_num,
  11558. sum(c.cases_entry_id = 2657) as entry_2657_num,
  11559. sum(c.cases_entry_id = 3010) as entry_3010_num,
  11560. sum(c.cases_entry_id = 2655) as entry_2655_num,
  11561. sum(c.cases_entry_id = 2654) as entry_2654_num,
  11562. sum(c.cases_entry_id = 2852) as entry_2852_num,
  11563. sum(c.cases_entry_id = 2287) as entry_2287_num,
  11564. sum(c.cases_entry_id = 3025) as entry_3025_num,
  11565. sum(c.cases_entry_id = 2170) as entry_2170_num,
  11566. sum(c.cases_entry_id = 2930) as entry_2930_num,
  11567. sum(c.cases_entry_id = 2900) as entry_2900_num,
  11568. sum(c.cases_entry_id = 2229) as entry_2229_num,
  11569. sum(c.cases_entry_id = 2217) as entry_2217_num,
  11570. sum(c.cases_entry_id = 2218) as entry_2218_num,
  11571. sum(c.cases_entry_id = 2220) as entry_2220_num,
  11572. sum(c.cases_entry_id = 2486) as entry_2486_num,
  11573. sum(c.cases_entry_id = 3063) as entry_3063_num,
  11574. sum(c.cases_entry_id = 3062) as entry_3062_num,
  11575. sum(c.cases_entry_id = 2495) as entry_2495_num
  11576. FROM
  11577. med_behospital_info a,
  11578. med_qcresult_info b,
  11579. med_qcresult_detail c,
  11580. qc_cases_entry d,
  11581. bas_doctor_info e
  11582. WHERE
  11583. a.is_deleted = 'N'
  11584. AND b.is_deleted = 'N'
  11585. AND c.is_deleted = 'N'
  11586. AND d.is_deleted = 'N'
  11587. AND e.is_deleted = 'N'
  11588. AND a.hospital_id = b.hospital_id
  11589. AND a.hospital_id = c.hospital_id
  11590. AND a.hospital_id = e.hospital_id
  11591. AND a.behospital_code = b.behospital_code
  11592. AND a.behospital_code = c.behospital_code
  11593. AND a.beh_dept_id = e.dept_id
  11594. AND c.cases_entry_id = d.id
  11595. and a.doctor_id=e.doctor_id
  11596. and e.group_id is not NULL
  11597. AND LENGTH(e.group_id)>0
  11598. AND a.qc_type_id != 0
  11599. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11600. and a.is_placefile = #{filterVO.isPlacefile}
  11601. </if>
  11602. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11603. AND a.hospital_id = #{filterVO.hospitalId}
  11604. </if>
  11605. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11606. <if test="filterVO.startDate != null ">
  11607. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11608. </if>
  11609. <if test="filterVO.endDate != null ">
  11610. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11611. </if>
  11612. </if>
  11613. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11614. <if test="filterVO.startDate != null ">
  11615. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11616. </if>
  11617. <if test="filterVO.endDate != null ">
  11618. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11619. </if>
  11620. </if>
  11621. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11622. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  11623. </if>
  11624. GROUP BY
  11625. a.beh_dept_id,
  11626. e.group_id,
  11627. a.doctor_id
  11628. </select>
  11629. <!-- 病历稽查表-科室-->
  11630. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  11631. SELECT
  11632. a.beh_dept_id AS deptId,
  11633. a.beh_dept_name AS deptName,
  11634. a.doctor_name as doctorName,
  11635. a.doctor_name as doctorGroup,
  11636. sum(c.cases_entry_id = 2658) as entry_2658_num,
  11637. sum(c.cases_entry_id = 2686) as entry_2686_num,
  11638. sum(c.cases_entry_id = 2657) as entry_2657_num,
  11639. sum(c.cases_entry_id = 3010) as entry_3010_num,
  11640. sum(c.cases_entry_id = 2655) as entry_2655_num,
  11641. sum(c.cases_entry_id = 2654) as entry_2654_num,
  11642. sum(c.cases_entry_id = 2852) as entry_2852_num,
  11643. sum(c.cases_entry_id = 2287) as entry_2287_num,
  11644. sum(c.cases_entry_id = 3025) as entry_3025_num,
  11645. sum(c.cases_entry_id = 2170) as entry_2170_num,
  11646. sum(c.cases_entry_id = 2930) as entry_2930_num,
  11647. sum(c.cases_entry_id = 2900) as entry_2900_num,
  11648. sum(c.cases_entry_id = 2229) as entry_2229_num,
  11649. sum(c.cases_entry_id = 2217) as entry_2217_num,
  11650. sum(c.cases_entry_id = 2218) as entry_2218_num,
  11651. sum(c.cases_entry_id = 2220) as entry_2220_num,
  11652. sum(c.cases_entry_id = 2486) as entry_2486_num,
  11653. sum(c.cases_entry_id = 3063) as entry_3063_num,
  11654. sum(c.cases_entry_id = 3062) as entry_3062_num,
  11655. sum(c.cases_entry_id = 2495) as entry_2495_num
  11656. FROM
  11657. med_behospital_info a,
  11658. med_qcresult_info b,
  11659. med_qcresult_detail c,
  11660. qc_cases_entry d,
  11661. bas_doctor_info e,
  11662. sys_user_dept f
  11663. WHERE
  11664. a.is_deleted = 'N'
  11665. AND b.is_deleted = 'N'
  11666. AND c.is_deleted = 'N'
  11667. AND d.is_deleted = 'N'
  11668. AND e.is_deleted = 'N'
  11669. AND f.is_deleted = 'N'
  11670. AND a.hospital_id = b.hospital_id
  11671. AND a.hospital_id = c.hospital_id
  11672. AND a.hospital_id = e.hospital_id
  11673. AND a.hospital_id = f.hospital_id
  11674. AND a.behospital_code = b.behospital_code
  11675. AND a.behospital_code = c.behospital_code
  11676. AND a.beh_dept_id = f.dept_id
  11677. AND c.cases_entry_id = d.id
  11678. and a.doctor_id=e.doctor_id
  11679. and e.group_id is not NULL
  11680. AND LENGTH(e.group_id)>0
  11681. AND a.qc_type_id != 0
  11682. <if test="filterVO.userId!=null">
  11683. AND f.user_id = #{filterVO.userId}
  11684. </if>
  11685. <if test="filterVO.name != null and filterVO.name != ''">
  11686. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11687. </if>
  11688. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11689. and a.is_placefile = #{filterVO.isPlacefile}
  11690. </if>
  11691. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11692. AND a.hospital_id = #{filterVO.hospitalId}
  11693. </if>
  11694. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11695. <if test="filterVO.startDate != null ">
  11696. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11697. </if>
  11698. <if test="filterVO.endDate != null ">
  11699. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11700. </if>
  11701. </if>
  11702. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11703. <if test="filterVO.startDate != null ">
  11704. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11705. </if>
  11706. <if test="filterVO.endDate != null ">
  11707. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11708. </if>
  11709. </if>
  11710. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11711. AND a.beh_dept_name = #{filterVO.deptName}
  11712. </if>
  11713. GROUP BY
  11714. a.beh_dept_id,
  11715. e.group_id,
  11716. a.doctor_name
  11717. </select>
  11718. <!-- 病历稽查表最新sql、id&&name-->
  11719. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  11720. SELECT
  11721. d.id,
  11722. d.name
  11723. from
  11724. qc_cases_entry d
  11725. where
  11726. 1=1
  11727. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  11728. and d.id in
  11729. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  11730. '${item}'
  11731. </foreach>
  11732. </if>
  11733. </select>
  11734. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  11735. <result column="deptName" property="deptName"/>
  11736. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  11737. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  11738. <result column="doctorName" property="doctorName"/>
  11739. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  11740. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  11741. <result column="RYJLW_24" property="ryjlw_24"/>
  11742. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  11743. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  11744. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  11745. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  11746. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  11747. <result column="QJJLW_6H" property="qjjlw_6h"/>
  11748. <result column="HZJLW_24H" property="hzjlw_24h"/>
  11749. <result column="SQTLXJW" property="sqtlxjw"/>
  11750. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  11751. <result column="XHSCW_30M" property="xhscw_30m"/>
  11752. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  11753. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  11754. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  11755. <result column="ZKJLW_24" property="zkjlw_24"/>
  11756. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  11757. <result column="SXHWJL" property="sxhwjl"/>
  11758. <result column="SXPJW_24" property="sxpjw_24"/>
  11759. <result column="WJZWJL" property="wjzwjl"/>
  11760. <result column="WYWWCXJ" property="wywwcxj"/>
  11761. </collection>
  11762. </collection>
  11763. </resultMap>
  11764. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  11765. <result column="deptName" property="deptName"/>
  11766. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  11767. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  11768. <result column="doctorGroup" property="doctorGroup"/>
  11769. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  11770. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  11771. <result column="doctorName" property="doctorName"/>
  11772. <result column="RYJLW_24" property="ryjlw_24"/>
  11773. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  11774. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  11775. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  11776. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  11777. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  11778. <result column="QJJLW_6H" property="qjjlw_6h"/>
  11779. <result column="HZJLW_24H" property="hzjlw_24h"/>
  11780. <result column="SQTLXJW" property="sqtlxjw"/>
  11781. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  11782. <result column="XHSCW_30M" property="xhscw_30m"/>
  11783. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  11784. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  11785. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  11786. <result column="ZKJLW_24" property="zkjlw_24"/>
  11787. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  11788. <result column="SXHWJL" property="sxhwjl"/>
  11789. <result column="SXPJW_24" property="sxpjw_24"/>
  11790. <result column="WJZWJL" property="wjzwjl"/>
  11791. <result column="WYWWCXJ" property="wywwcxj"/>
  11792. </collection>
  11793. </collection>
  11794. </resultMap>
  11795. <!-- 病历稽查表最新导出-->
  11796. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  11797. SELECT
  11798. a.beh_dept_id AS deptId,
  11799. a.beh_dept_name AS deptName,
  11800. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  11801. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  11802. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  11803. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  11804. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  11805. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  11806. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  11807. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  11808. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  11809. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  11810. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  11811. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  11812. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  11813. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  11814. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  11815. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  11816. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  11817. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  11818. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  11819. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  11820. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  11821. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  11822. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  11823. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  11824. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  11825. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  11826. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  11827. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  11828. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  11829. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  11830. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  11831. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  11832. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  11833. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  11834. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  11835. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  11836. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  11837. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  11838. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  11839. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  11840. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  11841. FROM
  11842. med_behospital_info a,
  11843. med_qcresult_info b,
  11844. med_qcresult_detail c,
  11845. qc_cases_entry d,
  11846. bas_doctor_info e
  11847. WHERE
  11848. a.is_deleted = 'N'
  11849. AND b.is_deleted = 'N'
  11850. AND c.is_deleted = 'N'
  11851. AND d.is_deleted = 'N'
  11852. AND e.is_deleted = 'N'
  11853. AND a.hospital_id = b.hospital_id
  11854. AND a.hospital_id = c.hospital_id
  11855. AND a.hospital_id = e.hospital_id
  11856. AND a.behospital_code = b.behospital_code
  11857. AND a.behospital_code = c.behospital_code
  11858. AND a.beh_dept_id = e.dept_id
  11859. AND c.cases_entry_id = d.id
  11860. and a.doctor_id=e.doctor_id
  11861. and e.group_id is not NULL
  11862. AND LENGTH(e.group_id)>0
  11863. AND a.qc_type_id != 0
  11864. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11865. and a.is_placefile = #{filterVO.isPlacefile}
  11866. </if>
  11867. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11868. AND a.hospital_id = #{filterVO.hospitalId}
  11869. </if>
  11870. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11871. <if test="filterVO.startDate != null ">
  11872. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11873. </if>
  11874. <if test="filterVO.endDate != null ">
  11875. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11876. </if>
  11877. </if>
  11878. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11879. <if test="filterVO.startDate != null ">
  11880. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11881. </if>
  11882. <if test="filterVO.endDate != null ">
  11883. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11884. </if>
  11885. </if>
  11886. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11887. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  11888. </if>
  11889. GROUP BY
  11890. a.beh_dept_id,
  11891. e.group_id
  11892. </select>
  11893. <!-- 病历稽查表最新导出-->
  11894. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  11895. SELECT
  11896. a.beh_dept_id AS deptId,
  11897. a.beh_dept_name AS deptName,
  11898. a.doctor_name as doctorGroup,
  11899. a.doctor_name as doctorName,
  11900. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  11901. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  11902. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  11903. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  11904. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  11905. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  11906. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  11907. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  11908. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  11909. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  11910. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  11911. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  11912. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  11913. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  11914. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  11915. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  11916. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  11917. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  11918. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  11919. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  11920. FROM
  11921. med_behospital_info a,
  11922. med_qcresult_info b,
  11923. med_qcresult_detail c,
  11924. qc_cases_entry d,
  11925. bas_doctor_info e,
  11926. sys_user_dept f
  11927. WHERE
  11928. a.is_deleted = 'N'
  11929. AND b.is_deleted = 'N'
  11930. AND c.is_deleted = 'N'
  11931. AND d.is_deleted = 'N'
  11932. AND e.is_deleted = 'N'
  11933. AND f.is_deleted = 'N'
  11934. AND a.hospital_id = b.hospital_id
  11935. AND a.hospital_id = c.hospital_id
  11936. AND a.hospital_id = e.hospital_id
  11937. AND a.hospital_id = f.hospital_id
  11938. AND a.behospital_code = b.behospital_code
  11939. AND a.behospital_code = c.behospital_code
  11940. AND a.beh_dept_id = f.dept_id
  11941. AND c.cases_entry_id = d.id
  11942. and a.doctor_id=e.doctor_id
  11943. and e.group_id is not NULL
  11944. AND LENGTH(e.group_id)>0
  11945. AND a.qc_type_id != 0
  11946. <if test="filterVO.userId!=null">
  11947. AND f.user_id = #{filterVO.userId}
  11948. </if>
  11949. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11950. and a.is_placefile = #{filterVO.isPlacefile}
  11951. </if>
  11952. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11953. AND a.hospital_id = #{filterVO.hospitalId}
  11954. </if>
  11955. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11956. <if test="filterVO.startDate != null ">
  11957. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11958. </if>
  11959. <if test="filterVO.endDate != null ">
  11960. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11961. </if>
  11962. </if>
  11963. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11964. <if test="filterVO.startDate != null ">
  11965. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11966. </if>
  11967. <if test="filterVO.endDate != null ">
  11968. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11969. </if>
  11970. </if>
  11971. <if test="filterVO.name != null and filterVO.name != ''">
  11972. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11973. </if>
  11974. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11975. AND a.beh_dept_name = #{filterVO.deptName}
  11976. </if>
  11977. GROUP BY
  11978. a.beh_dept_id,
  11979. e.group_id,
  11980. a.doctor_name
  11981. </select>
  11982. <!-- 未整改病历统计-->
  11983. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11984. SELECT
  11985. a.beh_dept_id AS deptId,
  11986. a.beh_dept_name AS deptName,
  11987. d.id AS casesEntryId,
  11988. d.NAME AS casesEntryName,
  11989. count(*) AS casesEntryNum
  11990. FROM
  11991. med_behospital_info a,
  11992. med_qcresult_info b,
  11993. med_qcresult_detail c,
  11994. qc_cases_entry d
  11995. WHERE
  11996. a.is_deleted = 'N'
  11997. AND b.is_deleted = 'N'
  11998. AND c.is_deleted = 'N'
  11999. AND d.is_deleted = 'N'
  12000. AND a.hospital_id = b.hospital_id
  12001. AND a.hospital_id = c.hospital_id
  12002. AND a.behospital_code = b.behospital_code
  12003. AND a.behospital_code = c.behospital_code
  12004. AND c.cases_entry_id = d.id
  12005. AND a.qc_type_id != 0
  12006. <if test="isPlacefile != null and isPlacefile != ''">
  12007. and a.is_placefile = #{isPlacefile}
  12008. </if>
  12009. <if test="hospitalId != null and hospitalId != ''">
  12010. AND a.hospital_id = #{hospitalId}
  12011. </if>
  12012. <if test="isPlacefile != null and isPlacefile == 0">
  12013. <if test="startDate != null ">
  12014. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12015. </if>
  12016. <if test="endDate != null ">
  12017. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12018. </if>
  12019. </if>
  12020. <if test="isPlacefile != null and isPlacefile == 1">
  12021. <if test="startDate != null ">
  12022. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12023. </if>
  12024. <if test="endDate != null ">
  12025. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12026. </if>
  12027. </if>
  12028. <if test="deptName != null and deptName != ''">
  12029. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  12030. </if>
  12031. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  12032. AND c.cases_entry_id IN
  12033. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  12034. #{item}
  12035. </foreach>
  12036. </if>
  12037. GROUP BY
  12038. a.beh_dept_id,
  12039. a.beh_dept_name,
  12040. c.cases_entry_id,
  12041. d.NAME
  12042. </select>
  12043. <!-- 未整改病历统计-科室-->
  12044. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  12045. SELECT
  12046. a.beh_dept_id AS deptId,
  12047. a.beh_dept_name AS deptName,
  12048. a.doctor_id as doctorId,
  12049. a.doctor_name as doctorName,
  12050. d.id AS casesEntryId,
  12051. d.NAME AS casesEntryName,
  12052. count(*) AS casesEntryNum
  12053. FROM
  12054. med_behospital_info a,
  12055. med_qcresult_info b,
  12056. med_qcresult_detail c,
  12057. qc_cases_entry d,
  12058. sys_user_dept f
  12059. WHERE
  12060. a.is_deleted = 'N'
  12061. AND b.is_deleted = 'N'
  12062. AND c.is_deleted = 'N'
  12063. AND d.is_deleted = 'N'
  12064. AND f.is_deleted = 'N'
  12065. AND a.hospital_id = b.hospital_id
  12066. AND a.hospital_id = c.hospital_id
  12067. AND a.hospital_id = f.hospital_id
  12068. AND a.behospital_code = b.behospital_code
  12069. AND a.behospital_code = c.behospital_code
  12070. AND a.beh_dept_id = f.dept_id
  12071. AND c.cases_entry_id = d.id
  12072. AND a.qc_type_id != 0
  12073. <if test="userId!=null">
  12074. AND f.user_id = #{userId}
  12075. </if>
  12076. <if test="isPlacefile != null and isPlacefile != ''">
  12077. and a.is_placefile = #{isPlacefile}
  12078. </if>
  12079. <if test="hospitalId != null and hospitalId != ''">
  12080. AND a.hospital_id = #{hospitalId}
  12081. </if>
  12082. <if test="isPlacefile != null and isPlacefile == 0">
  12083. <if test="startDate != null ">
  12084. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12085. </if>
  12086. <if test="endDate != null ">
  12087. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12088. </if>
  12089. </if>
  12090. <if test="isPlacefile != null and isPlacefile == 1">
  12091. <if test="startDate != null ">
  12092. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12093. </if>
  12094. <if test="endDate != null ">
  12095. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12096. </if>
  12097. </if>
  12098. <if test="deptName != null and deptName != ''">
  12099. AND a.beh_dept_name= #{deptName}
  12100. </if>
  12101. <if test="doctorName != null and doctorName != ''">
  12102. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  12103. </if>
  12104. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  12105. AND c.cases_entry_id IN
  12106. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  12107. #{item}
  12108. </foreach>
  12109. </if>
  12110. GROUP BY
  12111. a.doctor_id,
  12112. a.doctor_name,
  12113. c.cases_entry_id,
  12114. d.NAME
  12115. </select>
  12116. <!-- 不合格/合格数病历号(内页)科室-->
  12117. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  12118. SELECT t.*
  12119. FROM
  12120. (SELECT DISTINCT
  12121. t1.hospital_id AS hospitalId,
  12122. t1.behospital_code AS behospitalCode,
  12123. t1.bed_code AS bedCode,
  12124. t1.LEVEL AS LEVEL,
  12125. t1.grade_type AS gradeType,
  12126. t1.score_res AS scoreRes,
  12127. t1.scoreBn,
  12128. t1.NAME AS NAME,
  12129. t1.sex AS sex,
  12130. t1.beh_dept_id AS behDeptId,
  12131. t1.beh_dept_name AS behDeptName,
  12132. t1.doctor_id AS doctorId,
  12133. t1.doctor_name AS doctorName,
  12134. t1.beh_doctor_id AS behDoctorId,
  12135. t1.beh_doctor_name AS behDoctorName,
  12136. t1.director_doctor_id AS directorDoctorId,
  12137. t1.director_doctor_name AS directorDoctorName,
  12138. t1.birthday AS birthday,
  12139. t1.behospital_date AS behospitalDate,
  12140. t1.leave_hospital_date AS leaveHospitalDate,
  12141. t1.placefile_date AS placefileDate,
  12142. t1.gmt_create AS gradeTime,
  12143. t1.diagnose,
  12144. t1.ward_name AS wardName,
  12145. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12146. t1.file_code AS fileCode,
  12147. t1.checkStatus,
  12148. t1.mrStatus,
  12149. t1.chName,
  12150. t1.mrName,
  12151. t1.chTime,
  12152. t1.mrTime
  12153. FROM
  12154. (SELECT
  12155. be.*,
  12156. b.LEVEL,
  12157. b.grade_type,
  12158. b.score_res,
  12159. b.gmt_create,
  12160. ifnull(mci.status,0) AS checkStatus,
  12161. ifnull(hm_mci.status,0) AS mrStatus,
  12162. mci.check_name as chName,
  12163. hm_mci.check_name as mrName,
  12164. mci.gmt_create as chTime,
  12165. hm_mci.gmt_create as mrTime
  12166. FROM
  12167. (
  12168. SELECT DISTINCT
  12169. a.hospital_id,
  12170. a.behospital_code,
  12171. a.bed_code,
  12172. a.file_code,
  12173. e.score_res as scoreBn,
  12174. a.NAME,
  12175. a.sex,
  12176. a.beh_dept_id,
  12177. a.beh_dept_name,
  12178. a.birthday,
  12179. a.behospital_date,
  12180. a.leave_hospital_date,
  12181. a.doctor_id,
  12182. a.doctor_name,
  12183. a.beh_doctor_id,
  12184. a.beh_doctor_name,
  12185. a.director_doctor_id,
  12186. a.director_doctor_name,
  12187. a.diagnose,
  12188. a.placefile_date,
  12189. a.ward_name
  12190. FROM
  12191. med_behospital_info a,
  12192. sys_user_dept c,
  12193. med_qcresult_cases e
  12194. WHERE
  12195. a.is_deleted = 'N'
  12196. AND c.is_deleted = 'N'
  12197. AND e.is_deleted = 'N'
  12198. AND a.hospital_id = c.hospital_id
  12199. AND a.hospital_id = e.hospital_id
  12200. AND a.beh_dept_id = c.dept_id
  12201. AND a.behospital_code = e.behospital_code
  12202. AND a.qc_type_id != 0
  12203. AND e.cases_id = 243
  12204. <if test="userId!=null">
  12205. AND c.user_id = #{userId}
  12206. </if>
  12207. <if test="deptName != null and deptName != ''">
  12208. and a.beh_dept_name = #{deptName}
  12209. </if>
  12210. <if test="deptClass != null and deptClass != ''">
  12211. and a.beh_dept_id = #{deptClass}
  12212. </if>
  12213. <if test="deptId != null and deptId != ''">
  12214. and a.beh_dept_id = #{deptId}
  12215. </if>
  12216. <if test="titleName != null and titleName != '' ">
  12217. <if test="titleName == '不合格数'">
  12218. AND e.`level`='不合格'
  12219. </if>
  12220. <if test="titleName == '合格数'">
  12221. AND e.`level`='合格'
  12222. </if>
  12223. </if>
  12224. <if test="isPlacefile != null and isPlacefile != ''">
  12225. and a.is_placefile = #{isPlacefile}
  12226. </if>
  12227. <if test="doctorName != null and doctorName != ''">
  12228. AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  12229. OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  12230. OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%'))
  12231. </if>
  12232. <if test="hospitalId != null and hospitalId != ''">
  12233. AND a.hospital_id = #{hospitalId}
  12234. </if>
  12235. <if test="isPlacefile != null and isPlacefile == 0">
  12236. <if test="startDate != null ">
  12237. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12238. </if>
  12239. <if test="endDate != null ">
  12240. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12241. </if>
  12242. </if>
  12243. <if test="isPlacefile != null and isPlacefile == 1">
  12244. <if test="startDate != null ">
  12245. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12246. </if>
  12247. <if test="endDate != null">
  12248. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12249. </if>
  12250. </if>
  12251. <if test="diagnose != null and diagnose != ''">
  12252. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  12253. </if>
  12254. <if test="behospitalCode != null and behospitalCode != ''">
  12255. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  12256. </if>
  12257. <if test="patName != null and patName != ''">
  12258. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  12259. </if>
  12260. <if test="doctorId != null and doctorId != ''">
  12261. AND a.doctor_id = #{doctorId}
  12262. </if>
  12263. )be
  12264. left join med_check_info mci
  12265. on mci.is_deleted = 'N'
  12266. and mci.check_type = 0
  12267. and be.hospital_id = mci.hospital_id
  12268. and be.behospital_code = mci.behospital_code
  12269. left join med_check_info hm_mci
  12270. on hm_mci.is_deleted = 'N'
  12271. and hm_mci.check_type = 1
  12272. and be.hospital_id = hm_mci.hospital_id
  12273. and be.behospital_code = hm_mci.behospital_code
  12274. left join med_qcresult_info b
  12275. on b.is_deleted = 'N'
  12276. AND be.hospital_id = b.hospital_id
  12277. AND be.behospital_code = b.behospital_code
  12278. where
  12279. 1=1
  12280. <if test="level != null and level != ''">
  12281. AND b.`level` = #{level}
  12282. </if>
  12283. ) t1
  12284. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12285. AND t1.behospital_code = t2.behospital_code
  12286. AND t2.is_deleted = 'N'
  12287. ) t,
  12288. (
  12289. SELECT
  12290. a.doctor_id as doctorId,
  12291. a.doctor_name as doctorName
  12292. FROM
  12293. med_behospital_info a,
  12294. sys_user_dept b,
  12295. med_qcresult_cases c,
  12296. med_qcresult_detail d,
  12297. qc_cases_entry e
  12298. WHERE
  12299. a.is_deleted = 'N'
  12300. AND b.is_deleted = 'N'
  12301. AND c.is_deleted = 'N'
  12302. AND d.is_deleted = 'N'
  12303. AND e.is_deleted = 'N'
  12304. AND a.hospital_id = b.hospital_id
  12305. AND a.hospital_id = c.hospital_id
  12306. AND a.hospital_id = d.hospital_id
  12307. AND a.behospital_code = c.behospital_code
  12308. AND a.behospital_code = d.behospital_code
  12309. AND a.beh_dept_id = b.dept_id
  12310. AND c.cases_id = d.cases_id
  12311. AND d.cases_id = e.cases_id
  12312. AND d.cases_entry_id = e.id
  12313. AND d.cases_id = 243
  12314. AND a.qc_type_id != 0
  12315. <if test="userId!=null">
  12316. AND b.user_id = #{userId}
  12317. </if>
  12318. <if test="deptName != null and deptName != ''">
  12319. and a.beh_dept_name = #{deptName}
  12320. </if>
  12321. <if test="doctorName != null and doctorName != ''">
  12322. AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  12323. OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  12324. OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%'))
  12325. </if>
  12326. <if test="doctorId != null and doctorId != ''">
  12327. AND a.doctor_id = #{doctorId}
  12328. </if>
  12329. <if test="deptClass != null and deptClass != ''">
  12330. and a.beh_dept_id = #{deptClass}
  12331. </if>
  12332. <if test="deptId != null and deptId != ''">
  12333. and a.beh_dept_id = #{deptId}
  12334. </if>
  12335. <if test="isPlacefile != null and isPlacefile != ''">
  12336. and a.is_placefile = #{isPlacefile}
  12337. </if>
  12338. <if test="hospitalId != null and hospitalId != ''">
  12339. AND a.hospital_id = #{hospitalId}
  12340. </if>
  12341. <if test="isPlacefile != null and isPlacefile == 0">
  12342. <if test="startDate != null ">
  12343. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12344. </if>
  12345. <if test="endDate != null ">
  12346. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12347. </if>
  12348. </if>
  12349. <if test="isPlacefile != null and isPlacefile == 1">
  12350. <if test="startDate != null ">
  12351. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12352. </if>
  12353. <if test="endDate != null">
  12354. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12355. </if>
  12356. </if>
  12357. <if test="diagnose != null and diagnose != ''">
  12358. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  12359. </if>
  12360. <if test="behospitalCode != null and behospitalCode != ''">
  12361. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  12362. </if>
  12363. <if test="patName != null and patName != ''">
  12364. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  12365. </if>
  12366. GROUP BY
  12367. a.doctor_id,
  12368. a.doctor_name
  12369. ) t2
  12370. where
  12371. t.doctorId = t2.doctorId
  12372. AND t.doctorName = t2.doctorName
  12373. <if test="checkStatus != null">
  12374. AND t.checkStatus = #{checkStatus}
  12375. </if>
  12376. <if test="mrStatus != null">
  12377. AND t.mrStatus = #{mrStatus}
  12378. </if>
  12379. <if test="chName != null and chName!=''">
  12380. AND t.chName like concat('%', #{chName}, '%')
  12381. </if>
  12382. <if test="mrName != null and mrName!=''">
  12383. AND t.mrName like concat('%', #{mrName}, '%')
  12384. </if>
  12385. <if test="chTimeStart != null ">
  12386. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  12387. </if>
  12388. <if test="chTimeEnd != null ">
  12389. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  12390. </if>
  12391. <if test="mrTimeStart != null ">
  12392. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  12393. </if>
  12394. <if test="mrTimeEnd != null ">
  12395. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  12396. </if>
  12397. </select>
  12398. <!-- 不合格/合格数病历号(内页)全院-->
  12399. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12400. SELECT t.*
  12401. FROM
  12402. (SELECT DISTINCT
  12403. t1.hospital_id AS hospitalId,
  12404. t1.behospital_code AS behospitalCode,
  12405. t1.bed_code AS bedCode,
  12406. t1.LEVEL AS LEVEL,
  12407. t1.grade_type AS gradeType,
  12408. t1.score_res AS scoreRes,
  12409. t1.scoreBn,
  12410. t1.NAME AS NAME,
  12411. t1.sex AS sex,
  12412. t1.beh_dept_id AS behDeptId,
  12413. t1.beh_dept_name AS behDeptName,
  12414. t1.doctor_id AS doctorId,
  12415. t1.doctor_name AS doctorName,
  12416. t1.beh_doctor_id AS behDoctorId,
  12417. t1.beh_doctor_name AS behDoctorName,
  12418. t1.director_doctor_id AS directorDoctorId,
  12419. t1.director_doctor_name AS directorDoctorName,
  12420. t1.birthday AS birthday,
  12421. t1.behospital_date AS behospitalDate,
  12422. t1.leave_hospital_date AS leaveHospitalDate,
  12423. t1.placefile_date AS placefileDate,
  12424. t1.gmt_create AS gradeTime,
  12425. t1.diagnose,
  12426. t1.ward_name AS wardName,
  12427. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12428. t1.file_code AS fileCode,
  12429. t1.checkStatus,
  12430. t1.mrStatus,
  12431. t1.chName,
  12432. t1.mrName,
  12433. t1.chTime,
  12434. t1.mrTime
  12435. FROM
  12436. (SELECT
  12437. be.*,
  12438. b.LEVEL,
  12439. b.grade_type,
  12440. b.score_res,
  12441. b.gmt_create,
  12442. ifnull(mci.status,0) AS checkStatus,
  12443. ifnull(hm_mci.status,0) AS mrStatus,
  12444. mci.check_name as chName,
  12445. hm_mci.check_name as mrName,
  12446. mci.gmt_create as chTime,
  12447. hm_mci.gmt_create as mrTime
  12448. FROM
  12449. (
  12450. SELECT DISTINCT
  12451. a.hospital_id,
  12452. a.behospital_code,
  12453. a.bed_code,
  12454. a.file_code,
  12455. e.score_res as scoreBn,
  12456. a.NAME,
  12457. a.sex,
  12458. a.beh_dept_id,
  12459. a.beh_dept_name,
  12460. a.birthday,
  12461. a.behospital_date,
  12462. a.leave_hospital_date,
  12463. a.doctor_id,
  12464. a.doctor_name,
  12465. a.beh_doctor_id,
  12466. a.beh_doctor_name,
  12467. a.director_doctor_id,
  12468. a.director_doctor_name,
  12469. a.diagnose,
  12470. a.placefile_date,
  12471. a.ward_name
  12472. FROM
  12473. med_behospital_info a,
  12474. med_qcresult_cases e
  12475. WHERE
  12476. a.is_deleted = 'N'
  12477. AND e.is_deleted = 'N'
  12478. AND a.hospital_id = e.hospital_id
  12479. AND a.behospital_code = e.behospital_code
  12480. AND a.qc_type_id != 0
  12481. AND e.cases_id = 243
  12482. <if test="qcResultPageVO.titleName != null ">
  12483. <if test="qcResultPageVO.titleName == '不合格数'">
  12484. AND e.`level`='不合格'
  12485. </if>
  12486. <if test="qcResultPageVO.titleName == '合格数'">
  12487. AND e.`level`='合格'
  12488. </if>
  12489. </if>
  12490. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12491. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12492. </if>
  12493. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12494. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12495. </if>
  12496. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12497. <if test="qcResultPageVO.startDate != null ">
  12498. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12499. </if>
  12500. <if test="qcResultPageVO.endDate != null ">
  12501. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12502. </if>
  12503. </if>
  12504. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12505. <if test="qcResultPageVO.startDate != null ">
  12506. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12507. </if>
  12508. <if test="qcResultPageVO.endDate != null">
  12509. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12510. </if>
  12511. </if>
  12512. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12513. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12514. </if>
  12515. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12516. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  12517. </if>
  12518. <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
  12519. AND a.beh_dept_id = #{qcResultPageVO.deptId}
  12520. </if>
  12521. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12522. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12523. </if>
  12524. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12525. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12526. </if>
  12527. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12528. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12529. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12530. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  12531. </if>
  12532. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12533. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12534. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12535. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  12536. </if>
  12537. )be
  12538. left join med_check_info mci
  12539. on mci.is_deleted = 'N'
  12540. and mci.check_type = 0
  12541. and be.hospital_id = mci.hospital_id
  12542. and be.behospital_code = mci.behospital_code
  12543. left join med_check_info hm_mci
  12544. on hm_mci.is_deleted = 'N'
  12545. and hm_mci.check_type = 1
  12546. and be.hospital_id = hm_mci.hospital_id
  12547. and be.behospital_code = hm_mci.behospital_code
  12548. left join med_qcresult_info b
  12549. on b.is_deleted = 'N'
  12550. AND be.hospital_id = b.hospital_id
  12551. AND be.behospital_code = b.behospital_code
  12552. where
  12553. 1=1
  12554. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  12555. AND b.`level` = #{qcResultPageVO.level}
  12556. </if>
  12557. ) t1
  12558. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12559. AND t1.behospital_code = t2.behospital_code
  12560. AND t2.is_deleted = 'N'
  12561. ) t,
  12562. (
  12563. SELECT
  12564. a.beh_dept_id AS deptId,
  12565. a.beh_dept_name AS deptName
  12566. FROM
  12567. med_behospital_info a,
  12568. med_qcresult_cases c,
  12569. med_qcresult_detail d,
  12570. qc_cases_entry e
  12571. WHERE
  12572. a.is_deleted = 'N'
  12573. AND c.is_deleted = 'N'
  12574. AND d.is_deleted = 'N'
  12575. AND e.is_deleted = 'N'
  12576. AND a.hospital_id = c.hospital_id
  12577. AND a.hospital_id = d.hospital_id
  12578. AND a.behospital_code = c.behospital_code
  12579. AND a.behospital_code = d.behospital_code
  12580. AND c.cases_id = d.cases_id
  12581. AND d.cases_id = e.cases_id
  12582. AND d.cases_entry_id = e.id
  12583. AND d.cases_id = 243
  12584. AND a.qc_type_id != 0
  12585. <if test="qcResultPageVO.titleName != null ">
  12586. <if test="qcResultPageVO.titleName == '不合格数'">
  12587. AND c.`level`='不合格'
  12588. </if>
  12589. <if test="qcResultPageVO.titleName == '合格数'">
  12590. AND c.`level`='合格'
  12591. </if>
  12592. </if>
  12593. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12594. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12595. </if>
  12596. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12597. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12598. </if>
  12599. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12600. <if test="qcResultPageVO.startDate != null ">
  12601. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12602. </if>
  12603. <if test="qcResultPageVO.endDate != null ">
  12604. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12605. </if>
  12606. </if>
  12607. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12608. <if test="qcResultPageVO.startDate != null ">
  12609. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12610. </if>
  12611. <if test="qcResultPageVO.endDate != null">
  12612. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12613. </if>
  12614. </if>
  12615. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12616. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12617. </if>
  12618. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12619. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  12620. </if>
  12621. <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
  12622. AND a.beh_dept_id = #{qcResultPageVO.deptId}
  12623. </if>
  12624. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12625. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12626. </if>
  12627. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12628. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12629. </if>
  12630. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12631. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12632. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12633. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  12634. </if>
  12635. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12636. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12637. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12638. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  12639. </if>
  12640. GROUP BY
  12641. a.beh_dept_id,
  12642. a.beh_dept_name
  12643. ) t2
  12644. where
  12645. t.behDeptId = t2.deptId
  12646. AND t.behDeptName = t2.deptName
  12647. <if test="qcResultPageVO.checkStatus != null">
  12648. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  12649. </if>
  12650. <if test="qcResultPageVO.mrStatus != null">
  12651. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  12652. </if>
  12653. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  12654. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  12655. </if>
  12656. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  12657. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  12658. </if>
  12659. <if test="qcResultPageVO.chTimeStart != null ">
  12660. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  12661. </if>
  12662. <if test="qcResultPageVO.chTimeEnd != null ">
  12663. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  12664. </if>
  12665. <if test="qcResultPageVO.mrTimeStart != null ">
  12666. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  12667. </if>
  12668. <if test="qcResultPageVO.mrTimeEnd != null ">
  12669. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  12670. </if>
  12671. </select>
  12672. <!-- 不合格/合格数病历号XY(内页)全院-->
  12673. <select id="badLevelXYPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12674. SELECT t.*
  12675. FROM
  12676. (SELECT DISTINCT
  12677. t1.hospital_id AS hospitalId,
  12678. t1.behospital_code AS behospitalCode,
  12679. t1.bed_code AS bedCode,
  12680. t1.LEVEL AS LEVEL,
  12681. t1.grade_type AS gradeType,
  12682. t1.score_res AS scoreRes,
  12683. t1.scoreBn,
  12684. t1.doctorName,
  12685. t1.NAME AS NAME,
  12686. t1.sex AS sex,
  12687. t1.beh_dept_id AS behDeptId,
  12688. t1.beh_dept_name AS behDeptName,
  12689. t1.birthday AS birthday,
  12690. t1.behospital_date AS behospitalDate,
  12691. t1.leave_hospital_date AS leaveHospitalDate,
  12692. t1.placefile_date AS placefileDate,
  12693. t1.gmt_create AS gradeTime,
  12694. t1.diagnose,
  12695. t1.ward_name AS wardName,
  12696. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12697. t1.file_code AS fileCode,
  12698. t1.checkStatus,
  12699. t1.mrStatus,
  12700. t1.chName,
  12701. t1.mrName,
  12702. t1.chTime,
  12703. t1.mrTime
  12704. FROM
  12705. (SELECT
  12706. be.*,
  12707. b.LEVEL,
  12708. b.grade_type,
  12709. b.score_res,
  12710. b.gmt_create,
  12711. ifnull(mci.status,0) AS checkStatus,
  12712. ifnull(hm_mci.status,0) AS mrStatus,
  12713. mci.check_name as chName,
  12714. hm_mci.check_name as mrName,
  12715. mci.gmt_create as chTime,
  12716. hm_mci.gmt_create as mrTime
  12717. FROM
  12718. (
  12719. SELECT DISTINCT
  12720. a.hospital_id,
  12721. a.behospital_code,
  12722. a.bed_code,
  12723. a.file_code,
  12724. e.score_res as scoreBn,
  12725. a.NAME,
  12726. a.sex,
  12727. a.beh_dept_id,
  12728. a.beh_dept_name,
  12729. a.birthday,
  12730. a.behospital_date,
  12731. a.leave_hospital_date,
  12732. case
  12733. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  12734. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12735. b.director_doctor != '' and b.director_doctor is not null
  12736. then b.director_doctor
  12737. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12738. (b.director_doctor = '' or b.director_doctor is null) and
  12739. b.behospital_doctor != '' and b.behospital_doctor is not null
  12740. then b.behospital_doctor end as doctorName,
  12741. a.diagnose,
  12742. a.placefile_date,
  12743. a.ward_name
  12744. FROM
  12745. med_behospital_info a,
  12746. med_home_page b,
  12747. med_qcresult_cases e
  12748. WHERE
  12749. a.is_deleted = 'N'
  12750. AND b.is_deleted = 'N'
  12751. AND e.is_deleted = 'N'
  12752. AND a.hospital_id = b.hospital_id
  12753. AND a.hospital_id = e.hospital_id
  12754. AND a.behospital_code = b.behospital_code
  12755. AND a.behospital_code = e.behospital_code
  12756. AND a.qc_type_id != 0
  12757. AND e.cases_id = 243
  12758. <if test="qcResultPageVO.titleName != null ">
  12759. <if test="qcResultPageVO.titleName == '不合格数'">
  12760. AND e.`level`='不合格'
  12761. </if>
  12762. <if test="qcResultPageVO.titleName == '合格数'">
  12763. AND e.`level`='合格'
  12764. </if>
  12765. </if>
  12766. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12767. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12768. </if>
  12769. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12770. AND a.doctor_id = #{qcResultPageVO.doctorId}
  12771. </if>
  12772. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12773. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12774. </if>
  12775. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12776. <if test="qcResultPageVO.startDate != null ">
  12777. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12778. </if>
  12779. <if test="qcResultPageVO.endDate != null ">
  12780. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12781. </if>
  12782. </if>
  12783. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12784. <if test="qcResultPageVO.startDate != null ">
  12785. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12786. </if>
  12787. <if test="qcResultPageVO.endDate != null">
  12788. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12789. </if>
  12790. </if>
  12791. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12792. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12793. </if>
  12794. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12795. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  12796. </if>
  12797. <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
  12798. AND a.beh_dept_id = #{qcResultPageVO.deptId}
  12799. </if>
  12800. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12801. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12802. </if>
  12803. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12804. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12805. </if>
  12806. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12807. AND (case
  12808. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  12809. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12810. b.director_doctor != '' and b.director_doctor is not null
  12811. then b.director_doctor
  12812. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12813. (b.director_doctor = '' or b.director_doctor is null) and
  12814. b.behospital_doctor != '' and b.behospital_doctor is not null
  12815. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12816. </if>
  12817. <if test="qcResultPageVO.professor != null and qcResultPageVO.professor != ''">
  12818. AND (case
  12819. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  12820. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12821. b.director_doctor != '' and b.director_doctor is not null
  12822. then '主任医师'
  12823. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12824. (b.director_doctor = '' or b.director_doctor is null) and
  12825. b.behospital_doctor != '' and b.behospital_doctor is not null
  12826. then '住院医师' end) = #{qcResultPageVO.professor}
  12827. </if>
  12828. )be
  12829. left join med_check_info mci
  12830. on mci.is_deleted = 'N'
  12831. and mci.check_type = 0
  12832. and be.hospital_id = mci.hospital_id
  12833. and be.behospital_code = mci.behospital_code
  12834. left join med_check_info hm_mci
  12835. on hm_mci.is_deleted = 'N'
  12836. and hm_mci.check_type = 1
  12837. and be.hospital_id = hm_mci.hospital_id
  12838. and be.behospital_code = hm_mci.behospital_code
  12839. left join med_qcresult_info b
  12840. on b.is_deleted = 'N'
  12841. AND be.hospital_id = b.hospital_id
  12842. AND be.behospital_code = b.behospital_code
  12843. where
  12844. 1=1
  12845. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  12846. AND b.`level` = #{qcResultPageVO.level}
  12847. </if>
  12848. ) t1
  12849. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12850. AND t1.behospital_code = t2.behospital_code
  12851. AND t2.is_deleted = 'N'
  12852. ) t,
  12853. (
  12854. SELECT
  12855. a.beh_dept_id AS deptId,
  12856. a.beh_dept_name AS deptName
  12857. FROM
  12858. med_behospital_info a,
  12859. med_home_page b,
  12860. med_qcresult_cases c,
  12861. med_qcresult_detail d,
  12862. qc_cases_entry e
  12863. WHERE
  12864. a.is_deleted = 'N'
  12865. AND b.is_deleted = 'N'
  12866. AND c.is_deleted = 'N'
  12867. AND d.is_deleted = 'N'
  12868. AND e.is_deleted = 'N'
  12869. AND a.hospital_id = b.hospital_id
  12870. AND a.hospital_id = c.hospital_id
  12871. AND a.hospital_id = d.hospital_id
  12872. AND a.behospital_code = b.behospital_code
  12873. AND a.behospital_code = c.behospital_code
  12874. AND a.behospital_code = d.behospital_code
  12875. AND c.cases_id = d.cases_id
  12876. AND d.cases_id = e.cases_id
  12877. AND d.cases_entry_id = e.id
  12878. AND d.cases_id = 243
  12879. AND a.qc_type_id != 0
  12880. <if test="qcResultPageVO.titleName != null ">
  12881. <if test="qcResultPageVO.titleName == '不合格数'">
  12882. AND c.`level`='不合格'
  12883. </if>
  12884. <if test="qcResultPageVO.titleName == '合格数'">
  12885. AND c.`level`='合格'
  12886. </if>
  12887. </if>
  12888. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12889. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12890. </if>
  12891. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12892. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12893. </if>
  12894. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12895. <if test="qcResultPageVO.startDate != null ">
  12896. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12897. </if>
  12898. <if test="qcResultPageVO.endDate != null ">
  12899. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12900. </if>
  12901. </if>
  12902. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12903. <if test="qcResultPageVO.startDate != null ">
  12904. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12905. </if>
  12906. <if test="qcResultPageVO.endDate != null">
  12907. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12908. </if>
  12909. </if>
  12910. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12911. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12912. </if>
  12913. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12914. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  12915. </if>
  12916. <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
  12917. AND a.beh_dept_id = #{qcResultPageVO.deptId}
  12918. </if>
  12919. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12920. AND a.doctor_id = #{qcResultPageVO.doctorId}
  12921. </if>
  12922. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12923. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12924. </if>
  12925. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12926. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12927. </if>
  12928. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12929. AND (case
  12930. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  12931. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12932. b.director_doctor != '' and b.director_doctor is not null
  12933. then b.director_doctor
  12934. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12935. (b.director_doctor = '' or b.director_doctor is null) and
  12936. b.behospital_doctor != '' and b.behospital_doctor is not null
  12937. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12938. </if>
  12939. <if test="qcResultPageVO.professor != null and qcResultPageVO.professor != ''">
  12940. AND (case
  12941. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  12942. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12943. b.director_doctor != '' and b.director_doctor is not null
  12944. then '主任医师'
  12945. when (b.attending_doctor = '' or b.attending_doctor is null) and
  12946. (b.director_doctor = '' or b.director_doctor is null) and
  12947. b.behospital_doctor != '' and b.behospital_doctor is not null
  12948. then '住院医师' end) = #{qcResultPageVO.professor}
  12949. </if>
  12950. GROUP BY
  12951. a.beh_dept_id,
  12952. a.beh_dept_name
  12953. ) t2
  12954. where
  12955. t.behDeptId = t2.deptId
  12956. AND t.behDeptName = t2.deptName
  12957. <if test="qcResultPageVO.checkStatus != null">
  12958. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  12959. </if>
  12960. <if test="qcResultPageVO.mrStatus != null">
  12961. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  12962. </if>
  12963. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  12964. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  12965. </if>
  12966. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  12967. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  12968. </if>
  12969. <if test="qcResultPageVO.chTimeStart != null ">
  12970. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  12971. </if>
  12972. <if test="qcResultPageVO.chTimeEnd != null ">
  12973. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  12974. </if>
  12975. <if test="qcResultPageVO.mrTimeStart != null ">
  12976. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  12977. </if>
  12978. <if test="qcResultPageVO.mrTimeEnd != null ">
  12979. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  12980. </if>
  12981. </select>
  12982. <!-- 未整改病历质控评分页(内页)-->
  12983. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12984. SELECT t.*
  12985. FROM
  12986. (SELECT DISTINCT
  12987. t1.hospital_id AS hospitalId,
  12988. t1.behospital_code AS behospitalCode,
  12989. t1.bed_code AS bedCode,
  12990. t1.LEVEL AS LEVEL,
  12991. t1.grade_type AS gradeType,
  12992. t1.score_res AS scoreRes,
  12993. t1.scoreBn,
  12994. t1.NAME AS NAME,
  12995. t1.sex AS sex,
  12996. t1.beh_dept_id AS behDeptId,
  12997. t1.beh_dept_name AS behDeptName,
  12998. t1.doctor_id AS doctorId,
  12999. t1.doctor_name AS doctorName,
  13000. t1.beh_doctor_id AS behDoctorId,
  13001. t1.beh_doctor_name AS behDoctorName,
  13002. t1.director_doctor_id AS directorDoctorId,
  13003. t1.director_doctor_name AS directorDoctorName,
  13004. t1.birthday AS birthday,
  13005. t1.behospital_date AS behospitalDate,
  13006. t1.leave_hospital_date AS leaveHospitalDate,
  13007. t1.placefile_date AS placefileDate,
  13008. t1.gmt_create AS gradeTime,
  13009. t1.diagnose,
  13010. t1.ward_name AS wardName,
  13011. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  13012. t1.file_code AS fileCode,
  13013. t1.checkStatus,
  13014. t1.mrStatus,
  13015. t1.chName,
  13016. t1.mrName,
  13017. t1.chTime,
  13018. t1.mrTime
  13019. FROM
  13020. (SELECT
  13021. be.*,
  13022. ifnull(mci.status,0) AS checkStatus,
  13023. ifnull(hm_mci.status,0) AS mrStatus,
  13024. mci.check_name as chName,
  13025. e.score_res as scoreBn,
  13026. hm_mci.check_name as mrName,
  13027. mci.gmt_create as chTime,
  13028. hm_mci.gmt_create as mrTime
  13029. FROM
  13030. (
  13031. SELECT DISTINCT
  13032. a.hospital_id,
  13033. a.behospital_code,
  13034. a.bed_code,
  13035. a.file_code,
  13036. b.LEVEL,
  13037. b.grade_type,
  13038. b.score_res,
  13039. a.NAME,
  13040. a.sex,
  13041. a.beh_dept_id,
  13042. a.beh_dept_name,
  13043. a.birthday,
  13044. a.behospital_date,
  13045. a.leave_hospital_date,
  13046. a.doctor_id,
  13047. a.doctor_name,
  13048. a.beh_doctor_id,
  13049. a.beh_doctor_name,
  13050. a.director_doctor_id,
  13051. a.director_doctor_name,
  13052. a.diagnose,
  13053. a.placefile_date,
  13054. a.ward_name,
  13055. b.gmt_create
  13056. FROM
  13057. med_behospital_info a,
  13058. med_qcresult_info b,
  13059. med_qcresult_detail c,
  13060. qc_cases_entry d
  13061. WHERE
  13062. a.is_deleted = 'N'
  13063. AND b.is_deleted = 'N'
  13064. AND c.is_deleted = 'N'
  13065. AND d.is_deleted = 'N'
  13066. AND a.hospital_id = b.hospital_id
  13067. AND a.hospital_id = c.hospital_id
  13068. AND a.behospital_code = b.behospital_code
  13069. AND a.behospital_code = c.behospital_code
  13070. AND c.cases_id = d.cases_id
  13071. AND c.cases_entry_id = d.id
  13072. AND a.qc_type_id != 0
  13073. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13074. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13075. </if>
  13076. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13077. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13078. </if>
  13079. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13080. <if test="qcResultShortPageVO.startDate != null ">
  13081. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13082. </if>
  13083. <if test="qcResultShortPageVO.endDate != null ">
  13084. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13085. </if>
  13086. </if>
  13087. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13088. <if test="qcResultShortPageVO.startDate != null ">
  13089. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13090. </if>
  13091. <if test="qcResultShortPageVO.endDate != null">
  13092. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13093. </if>
  13094. </if>
  13095. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13096. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13097. </if>
  13098. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13099. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13100. </if>
  13101. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13102. AND b.`level` = #{qcResultShortPageVO.level}
  13103. </if>
  13104. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13105. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13106. </if>
  13107. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13108. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13109. </if>
  13110. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13111. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13112. </if>
  13113. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13114. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13115. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13116. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13117. </if>
  13118. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13119. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13120. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13121. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13122. </if>
  13123. <if test="qcResultShortPageVO.casesEntryId != null ">
  13124. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13125. </if>
  13126. <if test="qcResultShortPageVO.isReject != null">
  13127. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13128. </if>
  13129. <if test="qcResultShortPageVO.ruleType != null">
  13130. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13131. </if>
  13132. )be
  13133. left join med_check_info mci
  13134. on mci.is_deleted = 'N'
  13135. and mci.check_type = 0
  13136. and be.hospital_id = mci.hospital_id
  13137. and be.behospital_code = mci.behospital_code
  13138. left join med_check_info hm_mci
  13139. on hm_mci.is_deleted = 'N'
  13140. and hm_mci.check_type = 1
  13141. and be.hospital_id = hm_mci.hospital_id
  13142. and be.behospital_code = hm_mci.behospital_code
  13143. LEFT JOIN med_qcresult_cases e
  13144. on be.behospital_code = e.behospital_code
  13145. and be.hospital_id = e.hospital_id
  13146. AND e.is_deleted = 'N'
  13147. and e.cases_id = 243
  13148. ) t1
  13149. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13150. AND t1.behospital_code = t2.behospital_code
  13151. AND t2.is_deleted = 'N'
  13152. ) t
  13153. where 1=1
  13154. <if test="qcResultShortPageVO.checkStatus != null">
  13155. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13156. </if>
  13157. <if test="qcResultShortPageVO.mrStatus != null">
  13158. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13159. </if>
  13160. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13161. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13162. </if>
  13163. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13164. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13165. </if>
  13166. <if test="qcResultShortPageVO.chTimeStart != null ">
  13167. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13168. </if>
  13169. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13170. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13171. </if>
  13172. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13173. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13174. </if>
  13175. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13176. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13177. </if>
  13178. </select>
  13179. <!-- 未整改病历质控评分页-科室(内页)-->
  13180. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  13181. SELECT t.*
  13182. FROM
  13183. (SELECT DISTINCT
  13184. t1.hospital_id AS hospitalId,
  13185. t1.behospital_code AS behospitalCode,
  13186. t1.bed_code AS bedCode,
  13187. t1.LEVEL AS LEVEL,
  13188. t1.grade_type AS gradeType,
  13189. t1.score_res AS scoreRes,
  13190. t1.scoreBn,
  13191. t1.NAME AS NAME,
  13192. t1.sex AS sex,
  13193. t1.beh_dept_id AS behDeptId,
  13194. t1.beh_dept_name AS behDeptName,
  13195. t1.doctor_id AS doctorId,
  13196. t1.doctor_name AS doctorName,
  13197. t1.beh_doctor_id AS behDoctorId,
  13198. t1.beh_doctor_name AS behDoctorName,
  13199. t1.director_doctor_id AS directorDoctorId,
  13200. t1.director_doctor_name AS directorDoctorName,
  13201. t1.birthday AS birthday,
  13202. t1.behospital_date AS behospitalDate,
  13203. t1.leave_hospital_date AS leaveHospitalDate,
  13204. t1.placefile_date AS placefileDate,
  13205. t1.gmt_create AS gradeTime,
  13206. t1.diagnose,
  13207. t1.ward_name AS wardName,
  13208. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  13209. t1.file_code AS fileCode,
  13210. t1.checkStatus,
  13211. t1.mrStatus,
  13212. t1.chName,
  13213. t1.mrName,
  13214. t1.chTime,
  13215. t1.mrTime
  13216. FROM
  13217. (SELECT
  13218. be.*,
  13219. ifnull(mci.status,0) AS checkStatus,
  13220. ifnull(hm_mci.status,0) AS mrStatus,
  13221. mci.check_name as chName,
  13222. e.score_res as scoreBn,
  13223. hm_mci.check_name as mrName,
  13224. mci.gmt_create as chTime,
  13225. hm_mci.gmt_create as mrTime
  13226. FROM
  13227. (
  13228. SELECT DISTINCT
  13229. a.hospital_id,
  13230. a.behospital_code,
  13231. a.bed_code,
  13232. a.file_code,
  13233. b.LEVEL,
  13234. b.grade_type,
  13235. b.score_res,
  13236. a.NAME,
  13237. a.sex,
  13238. a.beh_dept_id,
  13239. a.beh_dept_name,
  13240. a.birthday,
  13241. a.behospital_date,
  13242. a.leave_hospital_date,
  13243. a.doctor_id,
  13244. a.doctor_name,
  13245. a.beh_doctor_id,
  13246. a.beh_doctor_name,
  13247. a.director_doctor_id,
  13248. a.director_doctor_name,
  13249. a.diagnose,
  13250. a.placefile_date,
  13251. a.ward_name,
  13252. b.gmt_create
  13253. FROM
  13254. med_behospital_info a,
  13255. med_qcresult_info b,
  13256. med_qcresult_detail c,
  13257. qc_cases_entry d,
  13258. sys_user_dept f
  13259. WHERE
  13260. a.is_deleted = 'N'
  13261. AND b.is_deleted = 'N'
  13262. AND c.is_deleted = 'N'
  13263. AND d.is_deleted = 'N'
  13264. AND f.is_deleted = 'N'
  13265. AND a.hospital_id = b.hospital_id
  13266. AND a.hospital_id = c.hospital_id
  13267. AND a.hospital_id = f.hospital_id
  13268. AND a.behospital_code = b.behospital_code
  13269. AND a.behospital_code = c.behospital_code
  13270. AND c.cases_id = d.cases_id
  13271. AND a.beh_dept_id = f.dept_id
  13272. AND c.cases_entry_id = d.id
  13273. AND a.qc_type_id != 0
  13274. <if test="qcResultShortPageVO.userId!=null">
  13275. AND f.user_id = #{qcResultShortPageVO.userId}
  13276. </if>
  13277. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13278. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13279. </if>
  13280. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13281. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13282. </if>
  13283. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13284. <if test="qcResultShortPageVO.startDate != null ">
  13285. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13286. </if>
  13287. <if test="qcResultShortPageVO.endDate != null ">
  13288. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13289. </if>
  13290. </if>
  13291. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13292. <if test="qcResultShortPageVO.startDate != null ">
  13293. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13294. </if>
  13295. <if test="qcResultShortPageVO.endDate != null">
  13296. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13297. </if>
  13298. </if>
  13299. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13300. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13301. </if>
  13302. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13303. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13304. </if>
  13305. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13306. AND b.`level` = #{qcResultShortPageVO.level}
  13307. </if>
  13308. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13309. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13310. </if>
  13311. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13312. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13313. </if>
  13314. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13315. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13316. </if>
  13317. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13318. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13319. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13320. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13321. </if>
  13322. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13323. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13324. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13325. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13326. </if>
  13327. <if test="qcResultShortPageVO.casesEntryId != null ">
  13328. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13329. </if>
  13330. <if test="qcResultShortPageVO.isReject != null">
  13331. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13332. </if>
  13333. <if test="qcResultShortPageVO.ruleType != null">
  13334. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13335. </if>
  13336. )be
  13337. left join med_check_info mci
  13338. on mci.is_deleted = 'N'
  13339. and mci.check_type = 0
  13340. and be.hospital_id = mci.hospital_id
  13341. and be.behospital_code = mci.behospital_code
  13342. left join med_check_info hm_mci
  13343. on hm_mci.is_deleted = 'N'
  13344. and hm_mci.check_type = 1
  13345. and be.hospital_id = hm_mci.hospital_id
  13346. and be.behospital_code = hm_mci.behospital_code
  13347. LEFT JOIN med_qcresult_cases e
  13348. on be.behospital_code = e.behospital_code
  13349. and be.hospital_id = e.hospital_id
  13350. AND e.is_deleted = 'N'
  13351. and e.cases_id = 243
  13352. ) t1
  13353. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13354. AND t1.behospital_code = t2.behospital_code
  13355. AND t2.is_deleted = 'N'
  13356. ) t
  13357. where 1=1
  13358. <if test="qcResultShortPageVO.checkStatus != null">
  13359. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13360. </if>
  13361. <if test="qcResultShortPageVO.mrStatus != null">
  13362. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13363. </if>
  13364. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13365. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13366. </if>
  13367. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13368. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13369. </if>
  13370. <if test="qcResultShortPageVO.chTimeStart != null ">
  13371. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13372. </if>
  13373. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13374. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13375. </if>
  13376. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13377. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13378. </if>
  13379. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13380. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13381. </if>
  13382. </select>
  13383. <!-- 病案首页不合格/合格数病历详情页导出-->
  13384. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  13385. SELECT
  13386. f1.behDeptId,
  13387. f1.behDeptName,
  13388. f1.doctorName,
  13389. f1.patName,
  13390. f1.behospitalCode,
  13391. f1.hospitalId,
  13392. f1.behospitalDate,
  13393. f1.leaveHospitalDate,
  13394. f1.score,
  13395. f1.scoreBn,
  13396. f2.avgScore,
  13397. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13398. f1.msg,
  13399. f1.caseName,
  13400. </if>
  13401. f1.checkStatus,
  13402. f1.mrStatus,
  13403. f1.chName,
  13404. f1.mrName,
  13405. f1.chTime,
  13406. f1.mrTime
  13407. FROM
  13408. (SELECT
  13409. t.doctorName,
  13410. t.`name` AS patName,
  13411. t.behospitalCode AS behospitalCode,
  13412. t.behospitalDate AS behospitalDate,
  13413. t.leaveHospitalDate AS leaveHospitalDate,
  13414. qi.score_res AS score,
  13415. t.scoreBn,
  13416. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13417. qd.msg AS msg,
  13418. qc.NAME AS caseName,
  13419. </if>
  13420. t.behDeptId,
  13421. t.behDeptName,
  13422. t.hospitalId,
  13423. t.checkStatus,
  13424. t.mrStatus,
  13425. t.chName,
  13426. t.mrName,
  13427. t.chTime,
  13428. t.mrTime
  13429. FROM
  13430. (SELECT DISTINCT
  13431. t1.hospital_id AS hospitalId,
  13432. t1.behospital_code AS behospitalCode,
  13433. t1.bed_code AS bedCode,
  13434. t1.LEVEL AS LEVEL,
  13435. t1.grade_type AS gradeType,
  13436. t1.score_res AS scoreRes,
  13437. t1.scoreBn,
  13438. t1.NAME AS NAME,
  13439. t1.sex AS sex,
  13440. t1.beh_dept_id AS behDeptId,
  13441. t1.beh_dept_name AS behDeptName,
  13442. t1.doctor_id AS doctorId,
  13443. t1.doctor_name AS doctorName,
  13444. t1.beh_doctor_id AS behDoctorId,
  13445. t1.beh_doctor_name AS behDoctorName,
  13446. t1.director_doctor_id AS directorDoctorId,
  13447. t1.director_doctor_name AS directorDoctorName,
  13448. t1.birthday AS birthday,
  13449. t1.behospital_date AS behospitalDate,
  13450. t1.leave_hospital_date AS leaveHospitalDate,
  13451. t1.placefile_date AS placefileDate,
  13452. t1.gmt_create AS gradeTime,
  13453. t1.diagnose,
  13454. t1.ward_name AS wardName,
  13455. t2.age,
  13456. t1.file_code AS fileCode,
  13457. t1.checkStatus,
  13458. t1.mrStatus,
  13459. t1.chName,
  13460. t1.mrName,
  13461. t1.chTime,
  13462. t1.mrTime
  13463. FROM
  13464. (SELECT
  13465. be.*,
  13466. b.LEVEL,
  13467. b.grade_type,
  13468. b.score_res,
  13469. b.gmt_create,
  13470. ifnull(mci.status,0) AS checkStatus,
  13471. ifnull(hm_mci.status,0) AS mrStatus,
  13472. mci.check_name as chName,
  13473. hm_mci.check_name as mrName,
  13474. mci.gmt_create as chTime,
  13475. hm_mci.gmt_create as mrTime
  13476. FROM
  13477. (
  13478. SELECT DISTINCT
  13479. a.hospital_id,
  13480. a.behospital_code,
  13481. a.bed_code,
  13482. a.file_code,
  13483. c.score_res as scoreBn,
  13484. c.cases_id,
  13485. a.NAME,
  13486. a.sex,
  13487. a.beh_dept_id,
  13488. a.beh_dept_name,
  13489. a.birthday,
  13490. a.behospital_date,
  13491. a.leave_hospital_date,
  13492. a.doctor_id,
  13493. a.doctor_name,
  13494. a.beh_doctor_id,
  13495. a.beh_doctor_name,
  13496. a.director_doctor_id,
  13497. a.director_doctor_name,
  13498. a.diagnose,
  13499. a.placefile_date,
  13500. a.ward_name
  13501. FROM
  13502. med_behospital_info a,
  13503. med_qcresult_cases c
  13504. WHERE
  13505. a.is_deleted = 'N'
  13506. AND c.is_deleted = 'N'
  13507. AND a.hospital_id = c.hospital_id
  13508. AND a.behospital_code = c.behospital_code
  13509. AND a.qc_type_id != 0
  13510. AND c.cases_id = 243
  13511. <if test="qcResultShortPageVO.titleName != null ">
  13512. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13513. AND c.`level`='不合格'
  13514. </if>
  13515. <if test="qcResultShortPageVO.titleName == '合格数'">
  13516. AND c.`level`='合格'
  13517. </if>
  13518. </if>
  13519. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13520. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13521. </if>
  13522. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13523. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13524. </if>
  13525. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13526. <if test="qcResultShortPageVO.startDate != null ">
  13527. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13528. </if>
  13529. <if test="qcResultShortPageVO.endDate != null ">
  13530. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13531. </if>
  13532. </if>
  13533. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13534. <if test="qcResultShortPageVO.startDate != null ">
  13535. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13536. </if>
  13537. <if test="qcResultShortPageVO.endDate != null">
  13538. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13539. </if>
  13540. </if>
  13541. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13542. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13543. </if>
  13544. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13545. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13546. </if>
  13547. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13548. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13549. </if>
  13550. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13551. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13552. </if>
  13553. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13554. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13555. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13556. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13557. </if>
  13558. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13559. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13560. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13561. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13562. </if>
  13563. )be
  13564. left join med_check_info mci
  13565. on mci.is_deleted = 'N'
  13566. and mci.check_type = 0
  13567. and be.hospital_id = mci.hospital_id
  13568. and be.behospital_code = mci.behospital_code
  13569. left join med_check_info hm_mci
  13570. on hm_mci.is_deleted = 'N'
  13571. and hm_mci.check_type = 1
  13572. and be.hospital_id = hm_mci.hospital_id
  13573. and be.behospital_code = hm_mci.behospital_code
  13574. left join med_qcresult_info b
  13575. on b.is_deleted = 'N'
  13576. AND be.hospital_id = b.hospital_id
  13577. AND be.behospital_code = b.behospital_code
  13578. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13579. AND b.`level` = #{qcResultShortPageVO.level}
  13580. </if>
  13581. left join qc_cases_entry d
  13582. on d.is_deleted = 'N'
  13583. AND be.cases_id = d.cases_id
  13584. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13585. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13586. </if>
  13587. <if test="qcResultShortPageVO.casesEntryId != null ">
  13588. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13589. </if>
  13590. <if test="qcResultShortPageVO.ruleType != null">
  13591. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13592. </if>
  13593. ) t1
  13594. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13595. AND t1.behospital_code = t2.behospital_code
  13596. AND t2.is_deleted = 'N'
  13597. ) t
  13598. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13599. AND t.hospitalId = qi.hospital_id
  13600. AND t.behospitalCode = qi.behospital_code
  13601. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13602. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13603. AND t.hospitalId = qd.hospital_id
  13604. AND t.behospitalCode = qd.behospital_code
  13605. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13606. AND qd.cases_id = qc.id
  13607. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13608. AND qd.cases_id = qce.cases_id
  13609. AND qd.cases_entry_id = qce.id
  13610. </if>
  13611. where 1=1
  13612. <if test="qcResultShortPageVO.checkStatus != null">
  13613. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13614. </if>
  13615. <if test="qcResultShortPageVO.mrStatus != null">
  13616. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13617. </if>
  13618. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13619. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13620. </if>
  13621. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13622. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13623. </if>
  13624. <if test="qcResultShortPageVO.chTimeStart != null ">
  13625. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13626. </if>
  13627. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13628. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13629. </if>
  13630. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13631. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13632. </if>
  13633. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13634. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13635. </if>
  13636. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13637. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13638. </if>
  13639. <if test="qcResultShortPageVO.casesEntryId != null ">
  13640. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13641. </if>
  13642. )f1,
  13643. (SELECT
  13644. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13645. t.behDeptId,
  13646. t.behDeptName
  13647. FROM
  13648. (SELECT DISTINCT
  13649. t1.hospital_id AS hospitalId,
  13650. t1.behospital_code AS behospitalCode,
  13651. t1.bed_code AS bedCode,
  13652. t1.LEVEL AS LEVEL,
  13653. t1.grade_type AS gradeType,
  13654. t1.score_res AS scoreRes,
  13655. t1.NAME AS NAME,
  13656. t1.sex AS sex,
  13657. t1.beh_dept_id AS behDeptId,
  13658. t1.beh_dept_name AS behDeptName,
  13659. t1.doctor_id AS doctorId,
  13660. t1.doctor_name AS doctorName,
  13661. t1.beh_doctor_id AS behDoctorId,
  13662. t1.beh_doctor_name AS behDoctorName,
  13663. t1.director_doctor_id AS directorDoctorId,
  13664. t1.director_doctor_name AS directorDoctorName,
  13665. t1.birthday AS birthday,
  13666. t1.behospital_date AS behospitalDate,
  13667. t1.leave_hospital_date AS leaveHospitalDate,
  13668. t1.placefile_date AS placefileDate,
  13669. t1.gmt_create AS gradeTime,
  13670. t1.diagnose,
  13671. t1.ward_name AS wardName,
  13672. t2.age,
  13673. t1.file_code AS fileCode,
  13674. t1.checkStatus,
  13675. t1.mrStatus,
  13676. t1.chName,
  13677. t1.mrName,
  13678. t1.chTime,
  13679. t1.mrTime
  13680. FROM
  13681. (SELECT
  13682. be.*,
  13683. b.grade_type,
  13684. b.score_res,
  13685. b.gmt_create,
  13686. b.LEVEL,
  13687. ifnull(mci.status,0) AS checkStatus,
  13688. ifnull(hm_mci.status,0) AS mrStatus,
  13689. mci.check_name as chName,
  13690. hm_mci.check_name as mrName,
  13691. mci.gmt_create as chTime,
  13692. hm_mci.gmt_create as mrTime
  13693. FROM
  13694. (
  13695. SELECT DISTINCT
  13696. a.hospital_id,
  13697. a.behospital_code,
  13698. a.bed_code,
  13699. a.file_code,
  13700. a.NAME,
  13701. a.sex,
  13702. a.beh_dept_id,
  13703. a.beh_dept_name,
  13704. a.birthday,
  13705. a.behospital_date,
  13706. a.leave_hospital_date,
  13707. a.doctor_id,
  13708. a.doctor_name,
  13709. a.beh_doctor_id,
  13710. a.beh_doctor_name,
  13711. a.director_doctor_id,
  13712. a.director_doctor_name,
  13713. a.diagnose,
  13714. a.placefile_date,
  13715. a.ward_name
  13716. FROM
  13717. med_behospital_info a,
  13718. med_qcresult_detail k,
  13719. med_qcresult_cases c,
  13720. qc_cases_entry d
  13721. WHERE
  13722. a.is_deleted = 'N'
  13723. AND c.is_deleted = 'N'
  13724. AND d.is_deleted = 'N'
  13725. AND a.hospital_id = c.hospital_id
  13726. AND a.behospital_code = c.behospital_code
  13727. AND c.cases_id = d.cases_id
  13728. AND a.hospital_id = k.hospital_id
  13729. AND a.behospital_code = k.behospital_code
  13730. AND c.cases_id = k.cases_id
  13731. AND k.cases_id = d.cases_id
  13732. AND k.cases_entry_id = d.id
  13733. <if test="qcResultShortPageVO.titleName != null ">
  13734. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13735. AND c.`level`='不合格'
  13736. </if>
  13737. <if test="qcResultShortPageVO.titleName == '合格数'">
  13738. AND c.`level`='合格'
  13739. </if>
  13740. </if>
  13741. AND a.qc_type_id != 0
  13742. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13743. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13744. </if>
  13745. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13746. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13747. </if>
  13748. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13749. <if test="qcResultShortPageVO.startDate != null ">
  13750. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13751. </if>
  13752. <if test="qcResultShortPageVO.endDate != null ">
  13753. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13754. </if>
  13755. </if>
  13756. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13757. <if test="qcResultShortPageVO.startDate != null ">
  13758. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13759. </if>
  13760. <if test="qcResultShortPageVO.endDate != null">
  13761. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13762. </if>
  13763. </if>
  13764. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13765. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13766. </if>
  13767. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13768. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13769. </if>
  13770. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13771. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13772. </if>
  13773. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13774. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13775. </if>
  13776. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13777. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13778. </if>
  13779. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13780. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13781. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13782. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13783. </if>
  13784. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13785. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13786. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13787. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13788. </if>
  13789. <if test="qcResultShortPageVO.casesEntryId != null ">
  13790. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13791. </if>
  13792. <if test="qcResultShortPageVO.ruleType != null">
  13793. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13794. </if>
  13795. )be
  13796. left join med_check_info mci
  13797. on mci.is_deleted = 'N'
  13798. and mci.check_type = 0
  13799. and be.hospital_id = mci.hospital_id
  13800. and be.behospital_code = mci.behospital_code
  13801. left join med_check_info hm_mci
  13802. on hm_mci.is_deleted = 'N'
  13803. and hm_mci.check_type = 1
  13804. and be.hospital_id = hm_mci.hospital_id
  13805. and be.behospital_code = hm_mci.behospital_code
  13806. left join med_qcresult_info b
  13807. on b.is_deleted = 'N'
  13808. AND be.hospital_id = b.hospital_id
  13809. AND be.behospital_code = b.behospital_code
  13810. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13811. AND b.`level` = #{qcResultShortPageVO.level}
  13812. </if>
  13813. ) t1
  13814. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13815. AND t1.behospital_code = t2.behospital_code
  13816. AND t2.is_deleted = 'N'
  13817. ) t
  13818. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13819. AND t.hospitalId = qi.hospital_id
  13820. AND t.behospitalCode = qi.behospital_code
  13821. where 1=1
  13822. <if test="qcResultShortPageVO.checkStatus != null">
  13823. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13824. </if>
  13825. <if test="qcResultShortPageVO.mrStatus != null">
  13826. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13827. </if>
  13828. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13829. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13830. </if>
  13831. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13832. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13833. </if>
  13834. <if test="qcResultShortPageVO.chTimeStart != null ">
  13835. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13836. </if>
  13837. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13838. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13839. </if>
  13840. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13841. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13842. </if>
  13843. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13844. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13845. </if>
  13846. GROUP BY
  13847. t.behDeptId,
  13848. t.behDeptName
  13849. )f2
  13850. WHERE
  13851. f1.behDeptId = f2.behDeptId
  13852. AND f1.behDeptName = f2.behDeptName
  13853. </select>
  13854. <!-- 病案首页不合格/合格数病历详情页XY导出-->
  13855. <select id="badLevelPageXYExport" resultMap="ExportExcelMap">
  13856. SELECT
  13857. f1.behDeptId,
  13858. f1.behDeptName,
  13859. f1.doctorName,
  13860. f1.patName,
  13861. f1.behospitalCode,
  13862. f1.hospitalId,
  13863. f1.behospitalDate,
  13864. f1.leaveHospitalDate,
  13865. f1.score,
  13866. f1.scoreBn,
  13867. f2.avgScore,
  13868. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13869. f1.msg,
  13870. f1.caseName,
  13871. </if>
  13872. f1.checkStatus,
  13873. f1.mrStatus,
  13874. f1.chName,
  13875. f1.mrName,
  13876. f1.chTime,
  13877. f1.mrTime
  13878. FROM
  13879. (SELECT
  13880. t.doctorName,
  13881. t.`name` AS patName,
  13882. t.behospitalCode AS behospitalCode,
  13883. t.behospitalDate AS behospitalDate,
  13884. t.leaveHospitalDate AS leaveHospitalDate,
  13885. qi.score_res AS score,
  13886. t.scoreBn,
  13887. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13888. qd.msg AS msg,
  13889. qc.NAME AS caseName,
  13890. </if>
  13891. t.behDeptId,
  13892. t.behDeptName,
  13893. t.hospitalId,
  13894. t.checkStatus,
  13895. t.mrStatus,
  13896. t.chName,
  13897. t.mrName,
  13898. t.chTime,
  13899. t.mrTime
  13900. FROM
  13901. (SELECT DISTINCT
  13902. t1.hospital_id AS hospitalId,
  13903. t1.behospital_code AS behospitalCode,
  13904. t1.bed_code AS bedCode,
  13905. t1.level,
  13906. t1.grade_type AS gradeType,
  13907. t1.score_res AS scoreRes,
  13908. t1.scoreBn,
  13909. t1.NAME AS NAME,
  13910. t1.sex AS sex,
  13911. t1.beh_dept_id AS behDeptId,
  13912. t1.beh_dept_name AS behDeptName,
  13913. t1.doctor_name AS doctorName,
  13914. t1.birthday AS birthday,
  13915. t1.behospital_date AS behospitalDate,
  13916. t1.leave_hospital_date AS leaveHospitalDate,
  13917. t1.placefile_date AS placefileDate,
  13918. t1.gmt_create AS gradeTime,
  13919. t1.diagnose,
  13920. t1.ward_name AS wardName,
  13921. t2.age,
  13922. t1.file_code AS fileCode,
  13923. t1.checkStatus,
  13924. t1.mrStatus,
  13925. t1.chName,
  13926. t1.mrName,
  13927. t1.chTime,
  13928. t1.mrTime
  13929. FROM
  13930. (SELECT
  13931. be.*,
  13932. b.level,
  13933. b.grade_type,
  13934. b.score_res,
  13935. b.gmt_create,
  13936. ifnull(mci.status,0) AS checkStatus,
  13937. ifnull(hm_mci.status,0) AS mrStatus,
  13938. mci.check_name as chName,
  13939. hm_mci.check_name as mrName,
  13940. mci.gmt_create as chTime,
  13941. hm_mci.gmt_create as mrTime
  13942. FROM
  13943. (
  13944. SELECT DISTINCT
  13945. a.hospital_id,
  13946. a.behospital_code,
  13947. a.bed_code,
  13948. a.file_code,
  13949. c.score_res as scoreBn,
  13950. c.cases_id,
  13951. a.NAME,
  13952. a.sex,
  13953. a.beh_dept_id,
  13954. a.beh_dept_name,
  13955. a.birthday,
  13956. a.behospital_date,
  13957. a.leave_hospital_date,
  13958. case
  13959. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  13960. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13961. b.director_doctor != '' and b.director_doctor is not null
  13962. then b.director_doctor
  13963. when (b.attending_doctor = '' or b.attending_doctor is null) and
  13964. (b.director_doctor = '' or b.director_doctor is null) and
  13965. b.behospital_doctor != '' and b.behospital_doctor is not null
  13966. then b.behospital_doctor end as doctor_name,
  13967. a.diagnose,
  13968. a.placefile_date,
  13969. a.ward_name
  13970. FROM
  13971. med_behospital_info a,
  13972. med_home_page b,
  13973. med_qcresult_cases c
  13974. WHERE
  13975. a.is_deleted = 'N'
  13976. AND b.is_deleted = 'N'
  13977. AND c.is_deleted = 'N'
  13978. AND a.hospital_id = b.hospital_id
  13979. AND a.hospital_id = c.hospital_id
  13980. AND a.behospital_code = b.behospital_code
  13981. AND a.behospital_code = c.behospital_code
  13982. AND a.qc_type_id != 0
  13983. AND c.cases_id = 243
  13984. <if test="qcResultShortPageVO.titleName != null ">
  13985. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13986. AND c.`level`='不合格'
  13987. </if>
  13988. <if test="qcResultShortPageVO.titleName == '合格数'">
  13989. AND c.`level`='合格'
  13990. </if>
  13991. </if>
  13992. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13993. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13994. </if>
  13995. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13996. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13997. </if>
  13998. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13999. <if test="qcResultShortPageVO.startDate != null ">
  14000. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14001. </if>
  14002. <if test="qcResultShortPageVO.endDate != null ">
  14003. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14004. </if>
  14005. </if>
  14006. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14007. <if test="qcResultShortPageVO.startDate != null ">
  14008. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14009. </if>
  14010. <if test="qcResultShortPageVO.endDate != null">
  14011. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14012. </if>
  14013. </if>
  14014. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14015. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14016. </if>
  14017. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14018. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14019. </if>
  14020. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14021. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14022. </if>
  14023. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14024. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14025. </if>
  14026. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14027. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14028. </if>
  14029. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14030. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14031. </if>
  14032. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14033. AND (case
  14034. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  14035. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14036. b.director_doctor != '' and b.director_doctor is not null
  14037. then b.director_doctor
  14038. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14039. (b.director_doctor = '' or b.director_doctor is null) and
  14040. b.behospital_doctor != '' and b.behospital_doctor is not null
  14041. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14042. </if>
  14043. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  14044. AND (case
  14045. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  14046. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14047. b.director_doctor != '' and b.director_doctor is not null
  14048. then '主任医师'
  14049. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14050. (b.director_doctor = '' or b.director_doctor is null) and
  14051. b.behospital_doctor != '' and b.behospital_doctor is not null
  14052. then '住院医师' end) = #{qcResultShortPageVO.professor}
  14053. </if>
  14054. )be
  14055. left join med_check_info mci
  14056. on mci.is_deleted = 'N'
  14057. and mci.check_type = 0
  14058. and be.hospital_id = mci.hospital_id
  14059. and be.behospital_code = mci.behospital_code
  14060. left join med_check_info hm_mci
  14061. on hm_mci.is_deleted = 'N'
  14062. and hm_mci.check_type = 1
  14063. and be.hospital_id = hm_mci.hospital_id
  14064. and be.behospital_code = hm_mci.behospital_code
  14065. left join med_qcresult_info b
  14066. on b.is_deleted = 'N'
  14067. AND be.hospital_id = b.hospital_id
  14068. AND be.behospital_code = b.behospital_code
  14069. left join qc_cases_entry d
  14070. on d.is_deleted = 'N'
  14071. AND be.cases_id = d.cases_id
  14072. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14073. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14074. </if>
  14075. <if test="qcResultShortPageVO.casesEntryId != null ">
  14076. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14077. </if>
  14078. <if test="qcResultShortPageVO.ruleType != null">
  14079. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14080. </if>
  14081. ) t1
  14082. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14083. AND t1.behospital_code = t2.behospital_code
  14084. AND t2.is_deleted = 'N'
  14085. ) t
  14086. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14087. AND t.hospitalId = qi.hospital_id
  14088. AND t.behospitalCode = qi.behospital_code
  14089. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14090. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14091. AND t.hospitalId = qd.hospital_id
  14092. AND t.behospitalCode = qd.behospital_code
  14093. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14094. AND qd.cases_id = qc.id
  14095. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  14096. AND qd.cases_id = qce.cases_id
  14097. AND qd.cases_entry_id = qce.id
  14098. </if>
  14099. where 1=1
  14100. <if test="qcResultShortPageVO.checkStatus != null">
  14101. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14102. </if>
  14103. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14104. AND t.level = #{qcResultShortPageVO.level}
  14105. </if>
  14106. <if test="qcResultShortPageVO.mrStatus != null">
  14107. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14108. </if>
  14109. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14110. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14111. </if>
  14112. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14113. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14114. </if>
  14115. <if test="qcResultShortPageVO.chTimeStart != null ">
  14116. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14117. </if>
  14118. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14119. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14120. </if>
  14121. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14122. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14123. </if>
  14124. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14125. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14126. </if>
  14127. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14128. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  14129. </if>
  14130. <if test="qcResultShortPageVO.casesEntryId != null ">
  14131. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  14132. </if>
  14133. )f1,
  14134. (SELECT
  14135. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14136. t.behDeptId,
  14137. t.behDeptName
  14138. FROM
  14139. (SELECT DISTINCT
  14140. t1.beh_dept_id AS behDeptId,
  14141. t1.beh_dept_name AS behDeptName,
  14142. t1.hospital_id as hospitalId,
  14143. t1.behospital_code as behospitalCode,
  14144. t1.`level`,
  14145. t1.checkStatus,
  14146. t1.mrStatus,
  14147. t1.chName,
  14148. t1.mrName,
  14149. t1.chTime,
  14150. t1.mrTime
  14151. FROM
  14152. (SELECT
  14153. be.*,
  14154. b.grade_type,
  14155. b.score_res,
  14156. b.`level`,
  14157. b.gmt_create,
  14158. ifnull(mci.status,0) AS checkStatus,
  14159. ifnull(hm_mci.status,0) AS mrStatus,
  14160. mci.check_name as chName,
  14161. hm_mci.check_name as mrName,
  14162. mci.gmt_create as chTime,
  14163. hm_mci.gmt_create as mrTime
  14164. FROM
  14165. (
  14166. SELECT DISTINCT
  14167. a.beh_dept_id,
  14168. a.beh_dept_name,
  14169. a.hospital_id,
  14170. a.behospital_code
  14171. FROM
  14172. med_behospital_info a,
  14173. med_home_page b,
  14174. med_qcresult_detail k,
  14175. med_qcresult_cases c,
  14176. qc_cases_entry d
  14177. WHERE
  14178. a.is_deleted = 'N'
  14179. AND b.is_deleted = 'N'
  14180. AND c.is_deleted = 'N'
  14181. AND d.is_deleted = 'N'
  14182. AND a.hospital_id = b.hospital_id
  14183. AND a.hospital_id = c.hospital_id
  14184. AND a.behospital_code = b.behospital_code
  14185. AND a.behospital_code = c.behospital_code
  14186. AND c.cases_id = d.cases_id
  14187. AND a.hospital_id = k.hospital_id
  14188. AND a.behospital_code = k.behospital_code
  14189. AND c.cases_id = k.cases_id
  14190. AND k.cases_id = d.cases_id
  14191. AND k.cases_entry_id = d.id
  14192. <if test="qcResultShortPageVO.titleName != null ">
  14193. <if test="qcResultShortPageVO.titleName == '不合格数'">
  14194. AND c.`level`='不合格'
  14195. </if>
  14196. <if test="qcResultShortPageVO.titleName == '合格数'">
  14197. AND c.`level`='合格'
  14198. </if>
  14199. </if>
  14200. AND a.qc_type_id != 0
  14201. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14202. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14203. </if>
  14204. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14205. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14206. </if>
  14207. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14208. <if test="qcResultShortPageVO.startDate != null ">
  14209. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14210. </if>
  14211. <if test="qcResultShortPageVO.endDate != null ">
  14212. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14213. </if>
  14214. </if>
  14215. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14216. <if test="qcResultShortPageVO.startDate != null ">
  14217. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14218. </if>
  14219. <if test="qcResultShortPageVO.endDate != null">
  14220. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14221. </if>
  14222. </if>
  14223. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14224. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14225. </if>
  14226. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14227. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14228. </if>
  14229. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14230. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14231. </if>
  14232. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14233. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14234. </if>
  14235. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14236. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14237. </if>
  14238. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14239. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14240. </if>
  14241. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14242. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14243. </if>
  14244. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14245. AND (case
  14246. when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
  14247. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14248. b.director_doctor != '' and b.director_doctor is not null
  14249. then b.director_doctor
  14250. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14251. (b.director_doctor = '' or b.director_doctor is null) and
  14252. b.behospital_doctor != '' and b.behospital_doctor is not null
  14253. then b.behospital_doctor end) LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14254. </if>
  14255. <if test="qcResultShortPageVO.professor != null and qcResultShortPageVO.professor != ''">
  14256. AND (case
  14257. when b.attending_doctor != '' and b.attending_doctor is not null then '主治医师'
  14258. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14259. b.director_doctor != '' and b.director_doctor is not null
  14260. then '主任医师'
  14261. when (b.attending_doctor = '' or b.attending_doctor is null) and
  14262. (b.director_doctor = '' or b.director_doctor is null) and
  14263. b.behospital_doctor != '' and b.behospital_doctor is not null
  14264. then '住院医师' end) = #{qcResultShortPageVO.professor}
  14265. </if>
  14266. <if test="qcResultShortPageVO.casesEntryId != null ">
  14267. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14268. </if>
  14269. <if test="qcResultShortPageVO.ruleType != null">
  14270. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14271. </if>
  14272. )be
  14273. left join med_check_info mci
  14274. on mci.is_deleted = 'N'
  14275. and mci.check_type = 0
  14276. and be.hospital_id = mci.hospital_id
  14277. and be.behospital_code = mci.behospital_code
  14278. left join med_check_info hm_mci
  14279. on hm_mci.is_deleted = 'N'
  14280. and hm_mci.check_type = 1
  14281. and be.hospital_id = hm_mci.hospital_id
  14282. and be.behospital_code = hm_mci.behospital_code
  14283. left join med_qcresult_info b
  14284. on b.is_deleted = 'N'
  14285. AND be.hospital_id = b.hospital_id
  14286. AND be.behospital_code = b.behospital_code
  14287. ) t1
  14288. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14289. AND t1.behospital_code = t2.behospital_code
  14290. AND t2.is_deleted = 'N'
  14291. ) t
  14292. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14293. AND t.hospitalId = qi.hospital_id
  14294. AND t.behospitalCode = qi.behospital_code
  14295. where 1=1
  14296. <if test="qcResultShortPageVO.checkStatus != null">
  14297. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14298. </if>
  14299. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14300. AND t.level = #{qcResultShortPageVO.level}
  14301. </if>
  14302. <if test="qcResultShortPageVO.mrStatus != null">
  14303. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14304. </if>
  14305. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14306. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14307. </if>
  14308. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14309. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14310. </if>
  14311. <if test="qcResultShortPageVO.chTimeStart != null ">
  14312. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14313. </if>
  14314. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14315. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14316. </if>
  14317. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14318. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14319. </if>
  14320. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14321. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14322. </if>
  14323. GROUP BY
  14324. t.behDeptId,
  14325. t.behDeptName
  14326. )f2
  14327. WHERE
  14328. f1.behDeptId = f2.behDeptId
  14329. AND f1.behDeptName = f2.behDeptName
  14330. </select>
  14331. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  14332. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  14333. SELECT
  14334. f1.behDeptId,
  14335. f1.behDeptName,
  14336. f1.doctorName,
  14337. f1.patName,
  14338. f1.behospitalCode,
  14339. f1.hospitalId,
  14340. f1.behospitalDate,
  14341. f1.leaveHospitalDate,
  14342. f1.score,
  14343. f1.scoreBn,
  14344. f2.avgScore,
  14345. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14346. f1.msg,
  14347. f1.caseName,
  14348. </if>
  14349. f1.checkStatus,
  14350. f1.mrStatus,
  14351. f1.chName,
  14352. f1.mrName,
  14353. f1.chTime,
  14354. f1.mrTime
  14355. FROM
  14356. (SELECT
  14357. t.doctorName AS doctorName,
  14358. t.doctorId,
  14359. t.`name` AS patName,
  14360. t.behospitalCode AS behospitalCode,
  14361. t.behospitalDate AS behospitalDate,
  14362. t.leaveHospitalDate AS leaveHospitalDate,
  14363. qi.score_res AS score,
  14364. t.scoreBn,
  14365. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14366. qd.msg AS msg,
  14367. qc.NAME AS caseName,
  14368. </if>
  14369. t.behDeptId,
  14370. t.behDeptName,
  14371. t.hospitalId,
  14372. t.checkStatus,
  14373. t.mrStatus,
  14374. t.chName,
  14375. t.mrName,
  14376. t.chTime,
  14377. t.mrTime
  14378. FROM
  14379. (SELECT DISTINCT
  14380. t1.hospital_id AS hospitalId,
  14381. t1.behospital_code AS behospitalCode,
  14382. t1.bed_code AS bedCode,
  14383. t1.LEVEL AS LEVEL,
  14384. t1.grade_type AS gradeType,
  14385. t1.score_res AS scoreRes,
  14386. t1.scoreBn,
  14387. t1.NAME AS NAME,
  14388. t1.sex AS sex,
  14389. t1.beh_dept_id AS behDeptId,
  14390. t1.beh_dept_name AS behDeptName,
  14391. t1.doctor_id AS doctorId,
  14392. t1.doctor_name AS doctorName,
  14393. t1.beh_doctor_id AS behDoctorId,
  14394. t1.beh_doctor_name AS behDoctorName,
  14395. t1.director_doctor_id AS directorDoctorId,
  14396. t1.director_doctor_name AS directorDoctorName,
  14397. t1.birthday AS birthday,
  14398. t1.behospital_date AS behospitalDate,
  14399. t1.leave_hospital_date AS leaveHospitalDate,
  14400. t1.placefile_date AS placefileDate,
  14401. t1.gmt_create AS gradeTime,
  14402. t1.diagnose,
  14403. t1.ward_name AS wardName,
  14404. t2.age,
  14405. t1.file_code AS fileCode,
  14406. t1.checkStatus,
  14407. t1.mrStatus,
  14408. t1.chName,
  14409. t1.mrName,
  14410. t1.chTime,
  14411. t1.mrTime
  14412. FROM
  14413. (SELECT
  14414. be.*,
  14415. b.LEVEL,
  14416. b.grade_type,
  14417. b.score_res,
  14418. b.gmt_create,
  14419. ifnull(mci.status,0) AS checkStatus,
  14420. ifnull(hm_mci.status,0) AS mrStatus,
  14421. mci.check_name as chName,
  14422. hm_mci.check_name as mrName,
  14423. mci.gmt_create as chTime,
  14424. hm_mci.gmt_create as mrTime
  14425. FROM
  14426. (
  14427. SELECT DISTINCT
  14428. a.hospital_id,
  14429. a.behospital_code,
  14430. a.bed_code,
  14431. a.file_code,
  14432. c.score_res as scoreBn,
  14433. c.cases_id,
  14434. a.NAME,
  14435. a.sex,
  14436. a.beh_dept_id,
  14437. a.beh_dept_name,
  14438. a.birthday,
  14439. a.behospital_date,
  14440. a.leave_hospital_date,
  14441. a.doctor_id,
  14442. a.doctor_name,
  14443. a.beh_doctor_id,
  14444. a.beh_doctor_name,
  14445. a.director_doctor_id,
  14446. a.director_doctor_name,
  14447. a.diagnose,
  14448. a.placefile_date,
  14449. a.ward_name
  14450. FROM
  14451. med_behospital_info a,
  14452. sys_user_dept b,
  14453. med_qcresult_cases c
  14454. WHERE
  14455. a.is_deleted = 'N'
  14456. AND b.is_deleted = 'N'
  14457. AND c.is_deleted = 'N'
  14458. AND a.hospital_id = b.hospital_id
  14459. AND a.beh_dept_id = b.dept_id
  14460. AND a.hospital_id = c.hospital_id
  14461. AND a.behospital_code = c.behospital_code
  14462. AND a.qc_type_id != 0
  14463. AND c.cases_id = 243
  14464. <if test="qcResultShortPageVO.userId!=null">
  14465. AND b.user_id = #{qcResultShortPageVO.userId}
  14466. </if>
  14467. <if test="qcResultShortPageVO.titleName != null ">
  14468. <if test="qcResultShortPageVO.titleName == '不合格数'">
  14469. AND c.`level`='不合格'
  14470. </if>
  14471. <if test="qcResultShortPageVO.titleName == '合格数'">
  14472. AND c.`level`='合格'
  14473. </if>
  14474. </if>
  14475. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14476. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14477. </if>
  14478. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14479. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14480. </if>
  14481. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14482. <if test="qcResultShortPageVO.startDate != null ">
  14483. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14484. </if>
  14485. <if test="qcResultShortPageVO.endDate != null ">
  14486. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14487. </if>
  14488. </if>
  14489. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14490. <if test="qcResultShortPageVO.startDate != null ">
  14491. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14492. </if>
  14493. <if test="qcResultShortPageVO.endDate != null">
  14494. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14495. </if>
  14496. </if>
  14497. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14498. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14499. </if>
  14500. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14501. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  14502. </if>
  14503. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14504. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14505. </if>
  14506. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14507. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14508. </if>
  14509. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14510. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14511. </if>
  14512. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14513. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14514. </if>
  14515. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14516. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14517. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14518. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14519. </if>
  14520. )be
  14521. left join med_check_info mci
  14522. on mci.is_deleted = 'N'
  14523. and mci.check_type = 0
  14524. and be.hospital_id = mci.hospital_id
  14525. and be.behospital_code = mci.behospital_code
  14526. left join med_check_info hm_mci
  14527. on hm_mci.is_deleted = 'N'
  14528. and hm_mci.check_type = 1
  14529. and be.hospital_id = hm_mci.hospital_id
  14530. and be.behospital_code = hm_mci.behospital_code
  14531. left join med_qcresult_info b
  14532. on b.is_deleted = 'N'
  14533. AND be.hospital_id = b.hospital_id
  14534. AND be.behospital_code = b.behospital_code
  14535. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14536. AND b.`level` = #{qcResultShortPageVO.level}
  14537. </if>
  14538. left join qc_cases_entry d
  14539. on d.is_deleted = 'N'
  14540. AND be.cases_id = d.cases_id
  14541. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14542. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14543. </if>
  14544. <if test="qcResultShortPageVO.casesEntryId != null ">
  14545. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14546. </if>
  14547. <if test="qcResultShortPageVO.ruleType != null">
  14548. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14549. </if>
  14550. ) t1
  14551. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14552. AND t1.behospital_code = t2.behospital_code
  14553. AND t2.is_deleted = 'N'
  14554. ) t
  14555. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14556. AND t.hospitalId = qi.hospital_id
  14557. AND t.behospitalCode = qi.behospital_code
  14558. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14559. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14560. AND t.hospitalId = qd.hospital_id
  14561. AND t.behospitalCode = qd.behospital_code
  14562. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14563. AND qd.cases_id = qc.id
  14564. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  14565. AND qd.cases_id = qce.cases_id
  14566. AND qd.cases_entry_id = qce.id
  14567. </if>
  14568. where 1=1
  14569. <if test="qcResultShortPageVO.checkStatus != null">
  14570. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14571. </if>
  14572. <if test="qcResultShortPageVO.mrStatus != null">
  14573. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14574. </if>
  14575. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14576. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14577. </if>
  14578. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14579. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14580. </if>
  14581. <if test="qcResultShortPageVO.chTimeStart != null ">
  14582. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14583. </if>
  14584. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14585. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14586. </if>
  14587. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14588. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14589. </if>
  14590. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14591. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14592. </if>
  14593. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14594. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  14595. </if>
  14596. <if test="qcResultShortPageVO.casesEntryId != null ">
  14597. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  14598. </if>
  14599. )f1,
  14600. (SELECT
  14601. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14602. t.doctorId,
  14603. t.doctorName
  14604. FROM
  14605. (SELECT DISTINCT
  14606. t1.hospital_id AS hospitalId,
  14607. t1.behospital_code AS behospitalCode,
  14608. t1.bed_code AS bedCode,
  14609. t1.LEVEL AS LEVEL,
  14610. t1.grade_type AS gradeType,
  14611. t1.score_res AS scoreRes,
  14612. t1.NAME AS NAME,
  14613. t1.sex AS sex,
  14614. t1.beh_dept_id AS behDeptId,
  14615. t1.beh_dept_name AS behDeptName,
  14616. t1.doctor_id AS doctorId,
  14617. t1.doctor_name AS doctorName,
  14618. t1.beh_doctor_id AS behDoctorId,
  14619. t1.beh_doctor_name AS behDoctorName,
  14620. t1.director_doctor_id AS directorDoctorId,
  14621. t1.director_doctor_name AS directorDoctorName,
  14622. t1.birthday AS birthday,
  14623. t1.behospital_date AS behospitalDate,
  14624. t1.leave_hospital_date AS leaveHospitalDate,
  14625. t1.placefile_date AS placefileDate,
  14626. t1.gmt_create AS gradeTime,
  14627. t1.diagnose,
  14628. t1.ward_name AS wardName,
  14629. t2.age,
  14630. t1.file_code AS fileCode,
  14631. t1.checkStatus,
  14632. t1.mrStatus,
  14633. t1.chName,
  14634. t1.mrName,
  14635. t1.chTime,
  14636. t1.mrTime
  14637. FROM
  14638. (SELECT
  14639. be.*,
  14640. b.grade_type,
  14641. b.score_res,
  14642. b.gmt_create,
  14643. b.LEVEL,
  14644. ifnull(mci.status,0) AS checkStatus,
  14645. ifnull(hm_mci.status,0) AS mrStatus,
  14646. mci.check_name as chName,
  14647. hm_mci.check_name as mrName,
  14648. mci.gmt_create as chTime,
  14649. hm_mci.gmt_create as mrTime
  14650. FROM
  14651. (
  14652. SELECT DISTINCT
  14653. a.hospital_id,
  14654. a.behospital_code,
  14655. a.bed_code,
  14656. a.file_code,
  14657. a.NAME,
  14658. a.sex,
  14659. a.beh_dept_id,
  14660. a.beh_dept_name,
  14661. a.birthday,
  14662. a.behospital_date,
  14663. a.leave_hospital_date,
  14664. a.doctor_id,
  14665. a.doctor_name,
  14666. a.beh_doctor_id,
  14667. a.beh_doctor_name,
  14668. a.director_doctor_id,
  14669. a.director_doctor_name,
  14670. a.diagnose,
  14671. a.placefile_date,
  14672. a.ward_name
  14673. FROM
  14674. med_behospital_info a,
  14675. med_qcresult_detail k,
  14676. sys_user_dept b,
  14677. med_qcresult_cases c,
  14678. qc_cases_entry d
  14679. WHERE
  14680. a.is_deleted = 'N'
  14681. AND b.is_deleted = 'N'
  14682. AND c.is_deleted = 'N'
  14683. AND d.is_deleted = 'N'
  14684. AND a.hospital_id = b.hospital_id
  14685. AND a.hospital_id = c.hospital_id
  14686. AND a.behospital_code = c.behospital_code
  14687. AND a.beh_dept_id = b.dept_id
  14688. AND c.cases_id = d.cases_id
  14689. AND a.hospital_id = k.hospital_id
  14690. AND a.behospital_code = k.behospital_code
  14691. AND c.cases_id = k.cases_id
  14692. AND k.cases_id = d.cases_id
  14693. AND k.cases_entry_id = d.id
  14694. AND a.qc_type_id != 0
  14695. <if test="qcResultShortPageVO.userId!=null">
  14696. AND b.user_id = #{qcResultShortPageVO.userId}
  14697. </if>
  14698. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14699. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14700. </if>
  14701. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14702. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14703. </if>
  14704. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14705. <if test="qcResultShortPageVO.startDate != null ">
  14706. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14707. </if>
  14708. <if test="qcResultShortPageVO.endDate != null ">
  14709. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14710. </if>
  14711. </if>
  14712. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14713. <if test="qcResultShortPageVO.startDate != null ">
  14714. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14715. </if>
  14716. <if test="qcResultShortPageVO.endDate != null">
  14717. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14718. </if>
  14719. </if>
  14720. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14721. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14722. </if>
  14723. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14724. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  14725. </if>
  14726. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14727. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14728. </if>
  14729. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14730. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14731. </if>
  14732. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14733. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14734. </if>
  14735. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14736. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14737. </if>
  14738. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14739. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14740. </if>
  14741. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14742. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14743. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14744. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14745. </if>
  14746. <if test="qcResultShortPageVO.casesEntryId != null ">
  14747. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14748. </if>
  14749. <if test="qcResultShortPageVO.ruleType != null">
  14750. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14751. </if>
  14752. )be
  14753. left join med_check_info mci
  14754. on mci.is_deleted = 'N'
  14755. and mci.check_type = 0
  14756. and be.hospital_id = mci.hospital_id
  14757. and be.behospital_code = mci.behospital_code
  14758. left join med_check_info hm_mci
  14759. on hm_mci.is_deleted = 'N'
  14760. and hm_mci.check_type = 1
  14761. and be.hospital_id = hm_mci.hospital_id
  14762. and be.behospital_code = hm_mci.behospital_code
  14763. left join med_qcresult_info b
  14764. on b.is_deleted = 'N'
  14765. AND be.hospital_id = b.hospital_id
  14766. AND be.behospital_code = b.behospital_code
  14767. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14768. AND b.`level` = #{qcResultShortPageVO.level}
  14769. </if>
  14770. ) t1
  14771. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14772. AND t1.behospital_code = t2.behospital_code
  14773. AND t2.is_deleted = 'N'
  14774. ) t
  14775. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14776. AND t.hospitalId = qi.hospital_id
  14777. AND t.behospitalCode = qi.behospital_code
  14778. where 1=1
  14779. <if test="qcResultShortPageVO.checkStatus != null">
  14780. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14781. </if>
  14782. <if test="qcResultShortPageVO.mrStatus != null">
  14783. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14784. </if>
  14785. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14786. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14787. </if>
  14788. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14789. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14790. </if>
  14791. <if test="qcResultShortPageVO.chTimeStart != null ">
  14792. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14793. </if>
  14794. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14795. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14796. </if>
  14797. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14798. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14799. </if>
  14800. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14801. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14802. </if>
  14803. GROUP BY
  14804. t.behDeptId,
  14805. t.behDeptName,
  14806. t.doctorId,
  14807. t.doctorName
  14808. )f2
  14809. WHERE
  14810. f1.doctorId = f2.doctorId
  14811. AND f1.doctorName = f2.doctorName
  14812. </select>
  14813. <!-- 未整改病历缺陷评分详情页导出-->
  14814. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  14815. SELECT
  14816. f1.behDeptId,
  14817. f1.behDeptName,
  14818. f1.doctorName,
  14819. f1.patName,
  14820. f1.behospitalCode,
  14821. f1.hospitalId,
  14822. f1.behospitalDate,
  14823. f1.leaveHospitalDate,
  14824. f1.score,
  14825. f1.scoreBn,
  14826. f2.avgScore,
  14827. f1.msg,
  14828. f1.caseName,
  14829. f1.checkStatus,
  14830. f1.mrStatus,
  14831. f1.chName,
  14832. f1.mrName,
  14833. f1.chTime,
  14834. f1.mrTime
  14835. FROM
  14836. (SELECT
  14837. t.doctorName,
  14838. t.`name` AS patName,
  14839. t.behospitalCode AS behospitalCode,
  14840. t.behospitalDate AS behospitalDate,
  14841. t.leaveHospitalDate AS leaveHospitalDate,
  14842. qi.score_res AS score,
  14843. t.scoreBn,
  14844. qd.msg AS msg,
  14845. qc.NAME AS caseName,
  14846. t.behDeptId,
  14847. t.behDeptName,
  14848. t.hospitalId,
  14849. t.checkStatus,
  14850. t.mrStatus,
  14851. t.chName,
  14852. t.mrName,
  14853. t.chTime,
  14854. t.mrTime
  14855. FROM
  14856. (SELECT DISTINCT
  14857. t1.hospital_id AS hospitalId,
  14858. t1.behospital_code AS behospitalCode,
  14859. t1.bed_code AS bedCode,
  14860. t1.LEVEL AS LEVEL,
  14861. t1.grade_type AS gradeType,
  14862. t1.score_res AS scoreRes,
  14863. t1.scoreBn,
  14864. t1.NAME AS NAME,
  14865. t1.sex AS sex,
  14866. t1.beh_dept_id AS behDeptId,
  14867. t1.beh_dept_name AS behDeptName,
  14868. t1.doctor_id AS doctorId,
  14869. t1.doctor_name AS doctorName,
  14870. t1.beh_doctor_id AS behDoctorId,
  14871. t1.beh_doctor_name AS behDoctorName,
  14872. t1.director_doctor_id AS directorDoctorId,
  14873. t1.director_doctor_name AS directorDoctorName,
  14874. t1.birthday AS birthday,
  14875. t1.behospital_date AS behospitalDate,
  14876. t1.leave_hospital_date AS leaveHospitalDate,
  14877. t1.placefile_date AS placefileDate,
  14878. t1.gmt_create AS gradeTime,
  14879. t1.diagnose,
  14880. t1.ward_name AS wardName,
  14881. t2.age,
  14882. t1.file_code AS fileCode,
  14883. t1.checkStatus,
  14884. t1.mrStatus,
  14885. t1.chName,
  14886. t1.mrName,
  14887. t1.chTime,
  14888. t1.mrTime
  14889. FROM
  14890. (SELECT
  14891. be.*,
  14892. ifnull(mci.status,0) AS checkStatus,
  14893. ifnull(hm_mci.status,0) AS mrStatus,
  14894. mci.check_name as chName,
  14895. e.score_res as scoreBn,
  14896. hm_mci.check_name as mrName,
  14897. mci.gmt_create as chTime,
  14898. hm_mci.gmt_create as mrTime
  14899. FROM
  14900. (
  14901. SELECT DISTINCT
  14902. a.hospital_id,
  14903. a.behospital_code,
  14904. a.bed_code,
  14905. a.file_code,
  14906. b.LEVEL,
  14907. b.grade_type,
  14908. b.score_res,
  14909. a.NAME,
  14910. a.sex,
  14911. a.beh_dept_id,
  14912. a.beh_dept_name,
  14913. a.birthday,
  14914. a.behospital_date,
  14915. a.leave_hospital_date,
  14916. a.doctor_id,
  14917. a.doctor_name,
  14918. a.beh_doctor_id,
  14919. a.beh_doctor_name,
  14920. a.director_doctor_id,
  14921. a.director_doctor_name,
  14922. a.diagnose,
  14923. a.placefile_date,
  14924. a.ward_name,
  14925. b.gmt_create
  14926. FROM
  14927. med_behospital_info a,
  14928. med_qcresult_info b,
  14929. med_qcresult_detail c,
  14930. qc_cases_entry d
  14931. WHERE
  14932. a.is_deleted = 'N'
  14933. AND b.is_deleted = 'N'
  14934. AND c.is_deleted = 'N'
  14935. AND d.is_deleted = 'N'
  14936. AND a.hospital_id = b.hospital_id
  14937. AND a.hospital_id = c.hospital_id
  14938. AND a.behospital_code = b.behospital_code
  14939. AND a.behospital_code = c.behospital_code
  14940. AND c.cases_id = d.cases_id
  14941. AND c.cases_entry_id = d.id
  14942. AND a.qc_type_id != 0
  14943. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14944. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14945. </if>
  14946. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14947. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14948. </if>
  14949. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14950. <if test="qcResultShortPageVO.startDate != null ">
  14951. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14952. </if>
  14953. <if test="qcResultShortPageVO.endDate != null ">
  14954. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14955. </if>
  14956. </if>
  14957. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14958. <if test="qcResultShortPageVO.startDate != null ">
  14959. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14960. </if>
  14961. <if test="qcResultShortPageVO.endDate != null">
  14962. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14963. </if>
  14964. </if>
  14965. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14966. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14967. </if>
  14968. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14969. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14970. </if>
  14971. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14972. AND b.`level` = #{qcResultShortPageVO.level}
  14973. </if>
  14974. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14975. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14976. </if>
  14977. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14978. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14979. </if>
  14980. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14981. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14982. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14983. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14984. </if>
  14985. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14986. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14987. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14988. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14989. </if>
  14990. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14991. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14992. </if>
  14993. <if test="qcResultShortPageVO.casesEntryId != null ">
  14994. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14995. </if>
  14996. <if test="qcResultShortPageVO.isReject != null">
  14997. AND c.is_reject = #{qcResultShortPageVO.isReject}
  14998. </if>
  14999. <if test="qcResultShortPageVO.ruleType != null">
  15000. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15001. </if>
  15002. )be
  15003. left join med_check_info mci
  15004. on mci.is_deleted = 'N'
  15005. and mci.check_type = 0
  15006. and be.hospital_id = mci.hospital_id
  15007. and be.behospital_code = mci.behospital_code
  15008. left join med_check_info hm_mci
  15009. on hm_mci.is_deleted = 'N'
  15010. and hm_mci.check_type = 1
  15011. and be.hospital_id = hm_mci.hospital_id
  15012. and be.behospital_code = hm_mci.behospital_code
  15013. LEFT JOIN med_qcresult_cases e
  15014. on be.behospital_code = e.behospital_code
  15015. and be.hospital_id = e.hospital_id
  15016. AND e.is_deleted = 'N'
  15017. and e.cases_id = 243
  15018. ) t1
  15019. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15020. AND t1.behospital_code = t2.behospital_code
  15021. AND t2.is_deleted = 'N'
  15022. ) t
  15023. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15024. AND t.hospitalId = qi.hospital_id
  15025. AND t.behospitalCode = qi.behospital_code
  15026. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15027. AND t.hospitalId = qd.hospital_id
  15028. AND t.behospitalCode = qd.behospital_code
  15029. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15030. AND qd.cases_id = qc.id
  15031. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  15032. AND qd.cases_id = qce.cases_id
  15033. AND qd.cases_entry_id = qce.id
  15034. where 1=1
  15035. <if test="qcResultShortPageVO.checkStatus != null">
  15036. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15037. </if>
  15038. <if test="qcResultShortPageVO.mrStatus != null">
  15039. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15040. </if>
  15041. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15042. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15043. </if>
  15044. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15045. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15046. </if>
  15047. <if test="qcResultShortPageVO.chTimeStart != null ">
  15048. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15049. </if>
  15050. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15051. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15052. </if>
  15053. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15054. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15055. </if>
  15056. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15057. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15058. </if>
  15059. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15060. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  15061. </if>
  15062. <if test="qcResultShortPageVO.casesEntryId != null ">
  15063. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  15064. </if>
  15065. )f1,
  15066. (SELECT
  15067. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15068. t.behDeptId,
  15069. t.behDeptName
  15070. FROM
  15071. (SELECT DISTINCT
  15072. t1.hospital_id AS hospitalId,
  15073. t1.behospital_code AS behospitalCode,
  15074. t1.bed_code AS bedCode,
  15075. t1.LEVEL AS LEVEL,
  15076. t1.grade_type AS gradeType,
  15077. t1.score_res AS scoreRes,
  15078. t1.NAME AS NAME,
  15079. t1.sex AS sex,
  15080. t1.beh_dept_id AS behDeptId,
  15081. t1.beh_dept_name AS behDeptName,
  15082. t1.doctor_id AS doctorId,
  15083. t1.doctor_name AS doctorName,
  15084. t1.beh_doctor_id AS behDoctorId,
  15085. t1.beh_doctor_name AS behDoctorName,
  15086. t1.director_doctor_id AS directorDoctorId,
  15087. t1.director_doctor_name AS directorDoctorName,
  15088. t1.birthday AS birthday,
  15089. t1.behospital_date AS behospitalDate,
  15090. t1.leave_hospital_date AS leaveHospitalDate,
  15091. t1.placefile_date AS placefileDate,
  15092. t1.gmt_create AS gradeTime,
  15093. t1.diagnose,
  15094. t1.ward_name AS wardName,
  15095. t2.age,
  15096. t1.file_code AS fileCode,
  15097. t1.checkStatus,
  15098. t1.mrStatus,
  15099. t1.chName,
  15100. t1.mrName,
  15101. t1.chTime,
  15102. t1.mrTime
  15103. FROM
  15104. (SELECT
  15105. be.*,
  15106. ifnull(mci.status,0) AS checkStatus,
  15107. ifnull(hm_mci.status,0) AS mrStatus,
  15108. mci.check_name as chName,
  15109. hm_mci.check_name as mrName,
  15110. mci.gmt_create as chTime,
  15111. hm_mci.gmt_create as mrTime
  15112. FROM
  15113. (
  15114. SELECT DISTINCT
  15115. a.hospital_id,
  15116. a.behospital_code,
  15117. a.bed_code,
  15118. a.file_code,
  15119. b.LEVEL,
  15120. b.grade_type,
  15121. b.score_res,
  15122. a.NAME,
  15123. a.sex,
  15124. a.beh_dept_id,
  15125. a.beh_dept_name,
  15126. a.birthday,
  15127. a.behospital_date,
  15128. a.leave_hospital_date,
  15129. a.doctor_id,
  15130. a.doctor_name,
  15131. a.beh_doctor_id,
  15132. a.beh_doctor_name,
  15133. a.director_doctor_id,
  15134. a.director_doctor_name,
  15135. a.diagnose,
  15136. a.placefile_date,
  15137. a.ward_name,
  15138. b.gmt_create
  15139. FROM
  15140. med_behospital_info a,
  15141. med_qcresult_info b,
  15142. med_qcresult_detail c,
  15143. qc_cases_entry d
  15144. WHERE
  15145. a.is_deleted = 'N'
  15146. AND b.is_deleted = 'N'
  15147. AND c.is_deleted = 'N'
  15148. AND d.is_deleted = 'N'
  15149. AND a.hospital_id = b.hospital_id
  15150. AND a.hospital_id = c.hospital_id
  15151. AND a.behospital_code = b.behospital_code
  15152. AND a.behospital_code = c.behospital_code
  15153. AND c.cases_id = d.cases_id
  15154. AND c.cases_entry_id = d.id
  15155. AND a.qc_type_id != 0
  15156. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15157. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15158. </if>
  15159. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15160. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15161. </if>
  15162. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15163. <if test="qcResultShortPageVO.startDate != null ">
  15164. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15165. </if>
  15166. <if test="qcResultShortPageVO.endDate != null ">
  15167. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15168. </if>
  15169. </if>
  15170. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15171. <if test="qcResultShortPageVO.startDate != null ">
  15172. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15173. </if>
  15174. <if test="qcResultShortPageVO.endDate != null">
  15175. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15176. </if>
  15177. </if>
  15178. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15179. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15180. </if>
  15181. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15182. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15183. </if>
  15184. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15185. AND b.`level` = #{qcResultShortPageVO.level}
  15186. </if>
  15187. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15188. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15189. </if>
  15190. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15191. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15192. </if>
  15193. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15194. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  15195. </if>
  15196. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15197. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15198. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15199. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15200. </if>
  15201. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15202. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15203. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15204. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15205. </if>
  15206. <if test="qcResultShortPageVO.casesEntryId != null ">
  15207. AND d.id = #{qcResultShortPageVO.casesEntryId}
  15208. </if>
  15209. <if test="qcResultShortPageVO.isReject != null">
  15210. AND c.is_reject = #{qcResultShortPageVO.isReject}
  15211. </if>
  15212. <if test="qcResultShortPageVO.ruleType != null">
  15213. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15214. </if>
  15215. )be
  15216. left join med_check_info mci
  15217. on mci.is_deleted = 'N'
  15218. and mci.check_type = 0
  15219. and be.hospital_id = mci.hospital_id
  15220. and be.behospital_code = mci.behospital_code
  15221. left join med_check_info hm_mci
  15222. on hm_mci.is_deleted = 'N'
  15223. and hm_mci.check_type = 1
  15224. and be.hospital_id = hm_mci.hospital_id
  15225. and be.behospital_code = hm_mci.behospital_code
  15226. ) t1
  15227. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15228. AND t1.behospital_code = t2.behospital_code
  15229. AND t2.is_deleted = 'N'
  15230. ) t
  15231. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15232. AND t.hospitalId = qi.hospital_id
  15233. AND t.behospitalCode = qi.behospital_code
  15234. where 1=1
  15235. <if test="qcResultShortPageVO.checkStatus != null">
  15236. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15237. </if>
  15238. <if test="qcResultShortPageVO.mrStatus != null">
  15239. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15240. </if>
  15241. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15242. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15243. </if>
  15244. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15245. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15246. </if>
  15247. <if test="qcResultShortPageVO.chTimeStart != null ">
  15248. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15249. </if>
  15250. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15251. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15252. </if>
  15253. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15254. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15255. </if>
  15256. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15257. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15258. </if>
  15259. GROUP BY
  15260. t.behDeptId,
  15261. t.behDeptName
  15262. )f2
  15263. WHERE
  15264. f1.behDeptId = f2.behDeptId
  15265. AND f1.behDeptName = f2.behDeptName
  15266. </select>
  15267. <!-- 未整改病历缺陷评分详情页导出-科室-->
  15268. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  15269. SELECT
  15270. f1.behDeptId,
  15271. f1.behDeptName,
  15272. f1.doctorName,
  15273. f1.patName,
  15274. f1.behospitalCode,
  15275. f1.hospitalId,
  15276. f1.behospitalDate,
  15277. f1.leaveHospitalDate,
  15278. f1.score,
  15279. f1.scoreBn,
  15280. f2.avgScore,
  15281. f1.msg,
  15282. f1.caseName,
  15283. f1.checkStatus,
  15284. f1.mrStatus,
  15285. f1.chName,
  15286. f1.mrName,
  15287. f1.chTime,
  15288. f1.mrTime
  15289. FROM
  15290. (SELECT
  15291. t.doctorName,
  15292. t.doctorId,
  15293. t.`name` AS patName,
  15294. t.behospitalCode AS behospitalCode,
  15295. t.behospitalDate AS behospitalDate,
  15296. t.leaveHospitalDate AS leaveHospitalDate,
  15297. qi.score_res AS score,
  15298. t.scoreBn,
  15299. qd.msg AS msg,
  15300. qc.NAME AS caseName,
  15301. t.behDeptId,
  15302. t.behDeptName,
  15303. t.hospitalId,
  15304. t.checkStatus,
  15305. t.mrStatus,
  15306. t.chName,
  15307. t.mrName,
  15308. t.chTime,
  15309. t.mrTime
  15310. FROM
  15311. (SELECT DISTINCT
  15312. t1.hospital_id AS hospitalId,
  15313. t1.behospital_code AS behospitalCode,
  15314. t1.bed_code AS bedCode,
  15315. t1.LEVEL AS LEVEL,
  15316. t1.grade_type AS gradeType,
  15317. t1.score_res AS scoreRes,
  15318. t1.scoreBn,
  15319. t1.NAME AS NAME,
  15320. t1.sex AS sex,
  15321. t1.beh_dept_id AS behDeptId,
  15322. t1.beh_dept_name AS behDeptName,
  15323. t1.doctor_id AS doctorId,
  15324. t1.doctor_name AS doctorName,
  15325. t1.beh_doctor_id AS behDoctorId,
  15326. t1.beh_doctor_name AS behDoctorName,
  15327. t1.director_doctor_id AS directorDoctorId,
  15328. t1.director_doctor_name AS directorDoctorName,
  15329. t1.birthday AS birthday,
  15330. t1.behospital_date AS behospitalDate,
  15331. t1.leave_hospital_date AS leaveHospitalDate,
  15332. t1.placefile_date AS placefileDate,
  15333. t1.gmt_create AS gradeTime,
  15334. t1.diagnose,
  15335. t1.ward_name AS wardName,
  15336. t2.age,
  15337. t1.file_code AS fileCode,
  15338. t1.checkStatus,
  15339. t1.mrStatus,
  15340. t1.chName,
  15341. t1.mrName,
  15342. t1.chTime,
  15343. t1.mrTime
  15344. FROM
  15345. (SELECT
  15346. be.*,
  15347. ifnull(mci.status,0) AS checkStatus,
  15348. ifnull(hm_mci.status,0) AS mrStatus,
  15349. mci.check_name as chName,
  15350. e.score_res as scoreBn,
  15351. hm_mci.check_name as mrName,
  15352. mci.gmt_create as chTime,
  15353. hm_mci.gmt_create as mrTime
  15354. FROM
  15355. (
  15356. SELECT DISTINCT
  15357. a.hospital_id,
  15358. a.behospital_code,
  15359. a.bed_code,
  15360. a.file_code,
  15361. b.LEVEL,
  15362. b.grade_type,
  15363. b.score_res,
  15364. a.NAME,
  15365. a.sex,
  15366. a.beh_dept_id,
  15367. a.beh_dept_name,
  15368. a.birthday,
  15369. a.behospital_date,
  15370. a.leave_hospital_date,
  15371. a.doctor_id,
  15372. a.doctor_name,
  15373. a.beh_doctor_id,
  15374. a.beh_doctor_name,
  15375. a.director_doctor_id,
  15376. a.director_doctor_name,
  15377. a.diagnose,
  15378. a.placefile_date,
  15379. a.ward_name,
  15380. b.gmt_create
  15381. FROM
  15382. med_behospital_info a,
  15383. med_qcresult_info b,
  15384. med_qcresult_detail c,
  15385. qc_cases_entry d,
  15386. sys_user_dept f
  15387. WHERE
  15388. a.is_deleted = 'N'
  15389. AND b.is_deleted = 'N'
  15390. AND c.is_deleted = 'N'
  15391. AND d.is_deleted = 'N'
  15392. AND f.is_deleted = 'N'
  15393. AND a.hospital_id = b.hospital_id
  15394. AND a.hospital_id = c.hospital_id
  15395. AND a.hospital_id = f.hospital_id
  15396. AND a.behospital_code = b.behospital_code
  15397. AND a.behospital_code = c.behospital_code
  15398. AND c.cases_id = d.cases_id
  15399. AND c.cases_entry_id = d.id
  15400. AND a.beh_dept_id = f.dept_id
  15401. AND a.qc_type_id != 0
  15402. <if test="qcResultShortPageVO.userId!=null">
  15403. AND f.user_id = #{qcResultShortPageVO.userId}
  15404. </if>
  15405. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15406. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15407. </if>
  15408. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15409. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15410. </if>
  15411. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15412. <if test="qcResultShortPageVO.startDate != null ">
  15413. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15414. </if>
  15415. <if test="qcResultShortPageVO.endDate != null ">
  15416. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15417. </if>
  15418. </if>
  15419. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15420. <if test="qcResultShortPageVO.startDate != null ">
  15421. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15422. </if>
  15423. <if test="qcResultShortPageVO.endDate != null">
  15424. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15425. </if>
  15426. </if>
  15427. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15428. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15429. </if>
  15430. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15431. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15432. </if>
  15433. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15434. AND b.`level` = #{qcResultShortPageVO.level}
  15435. </if>
  15436. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15437. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15438. </if>
  15439. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15440. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15441. </if>
  15442. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15443. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15444. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15445. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15446. </if>
  15447. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15448. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15449. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15450. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15451. </if>
  15452. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15453. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  15454. </if>
  15455. <if test="qcResultShortPageVO.casesEntryId != null ">
  15456. AND d.id = #{qcResultShortPageVO.casesEntryId}
  15457. </if>
  15458. <if test="qcResultShortPageVO.isReject != null">
  15459. AND c.is_reject = #{qcResultShortPageVO.isReject}
  15460. </if>
  15461. <if test="qcResultShortPageVO.ruleType != null">
  15462. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15463. </if>
  15464. )be
  15465. left join med_check_info mci
  15466. on mci.is_deleted = 'N'
  15467. and mci.check_type = 0
  15468. and be.hospital_id = mci.hospital_id
  15469. and be.behospital_code = mci.behospital_code
  15470. left join med_check_info hm_mci
  15471. on hm_mci.is_deleted = 'N'
  15472. and hm_mci.check_type = 1
  15473. and be.hospital_id = hm_mci.hospital_id
  15474. and be.behospital_code = hm_mci.behospital_code
  15475. LEFT JOIN med_qcresult_cases e
  15476. on be.behospital_code = e.behospital_code
  15477. and be.hospital_id = e.hospital_id
  15478. AND e.is_deleted = 'N'
  15479. and e.cases_id = 243
  15480. ) t1
  15481. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15482. AND t1.behospital_code = t2.behospital_code
  15483. AND t2.is_deleted = 'N'
  15484. ) t
  15485. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15486. AND t.hospitalId = qi.hospital_id
  15487. AND t.behospitalCode = qi.behospital_code
  15488. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15489. AND t.hospitalId = qd.hospital_id
  15490. AND t.behospitalCode = qd.behospital_code
  15491. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15492. AND qd.cases_id = qc.id
  15493. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  15494. AND qd.cases_id = qce.cases_id
  15495. AND qd.cases_entry_id = qce.id
  15496. where 1=1
  15497. <if test="qcResultShortPageVO.checkStatus != null">
  15498. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15499. </if>
  15500. <if test="qcResultShortPageVO.mrStatus != null">
  15501. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15502. </if>
  15503. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15504. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15505. </if>
  15506. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15507. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15508. </if>
  15509. <if test="qcResultShortPageVO.chTimeStart != null ">
  15510. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15511. </if>
  15512. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15513. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15514. </if>
  15515. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15516. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15517. </if>
  15518. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15519. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15520. </if>
  15521. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15522. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  15523. </if>
  15524. <if test="qcResultShortPageVO.casesEntryId != null ">
  15525. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  15526. </if>
  15527. )f1,
  15528. (SELECT
  15529. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15530. t.behDeptId,
  15531. t.behDeptName,
  15532. t.doctorId,
  15533. t.doctorName
  15534. FROM
  15535. (SELECT DISTINCT
  15536. t1.hospital_id AS hospitalId,
  15537. t1.behospital_code AS behospitalCode,
  15538. t1.bed_code AS bedCode,
  15539. t1.LEVEL AS LEVEL,
  15540. t1.grade_type AS gradeType,
  15541. t1.score_res AS scoreRes,
  15542. t1.NAME AS NAME,
  15543. t1.sex AS sex,
  15544. t1.beh_dept_id AS behDeptId,
  15545. t1.beh_dept_name AS behDeptName,
  15546. t1.doctor_id AS doctorId,
  15547. t1.doctor_name AS doctorName,
  15548. t1.beh_doctor_id AS behDoctorId,
  15549. t1.beh_doctor_name AS behDoctorName,
  15550. t1.director_doctor_id AS directorDoctorId,
  15551. t1.director_doctor_name AS directorDoctorName,
  15552. t1.birthday AS birthday,
  15553. t1.behospital_date AS behospitalDate,
  15554. t1.leave_hospital_date AS leaveHospitalDate,
  15555. t1.placefile_date AS placefileDate,
  15556. t1.gmt_create AS gradeTime,
  15557. t1.diagnose,
  15558. t1.ward_name AS wardName,
  15559. t2.age,
  15560. t1.file_code AS fileCode,
  15561. t1.checkStatus,
  15562. t1.mrStatus,
  15563. t1.chName,
  15564. t1.mrName,
  15565. t1.chTime,
  15566. t1.mrTime
  15567. FROM
  15568. (SELECT
  15569. be.*,
  15570. ifnull(mci.status,0) AS checkStatus,
  15571. ifnull(hm_mci.status,0) AS mrStatus,
  15572. mci.check_name as chName,
  15573. hm_mci.check_name as mrName,
  15574. mci.gmt_create as chTime,
  15575. hm_mci.gmt_create as mrTime
  15576. FROM
  15577. (
  15578. SELECT DISTINCT
  15579. a.hospital_id,
  15580. a.behospital_code,
  15581. a.bed_code,
  15582. a.file_code,
  15583. b.LEVEL,
  15584. b.grade_type,
  15585. b.score_res,
  15586. a.NAME,
  15587. a.sex,
  15588. a.beh_dept_id,
  15589. a.beh_dept_name,
  15590. a.birthday,
  15591. a.behospital_date,
  15592. a.leave_hospital_date,
  15593. a.doctor_id,
  15594. a.doctor_name,
  15595. a.beh_doctor_id,
  15596. a.beh_doctor_name,
  15597. a.director_doctor_id,
  15598. a.director_doctor_name,
  15599. a.diagnose,
  15600. a.placefile_date,
  15601. a.ward_name,
  15602. b.gmt_create
  15603. FROM
  15604. med_behospital_info a,
  15605. med_qcresult_info b,
  15606. med_qcresult_detail c,
  15607. qc_cases_entry d,
  15608. sys_user_dept f
  15609. WHERE
  15610. a.is_deleted = 'N'
  15611. AND b.is_deleted = 'N'
  15612. AND c.is_deleted = 'N'
  15613. AND d.is_deleted = 'N'
  15614. AND f.is_deleted = 'N'
  15615. AND a.hospital_id = b.hospital_id
  15616. AND a.hospital_id = c.hospital_id
  15617. AND a.hospital_id = f.hospital_id
  15618. AND a.behospital_code = b.behospital_code
  15619. AND a.behospital_code = c.behospital_code
  15620. AND c.cases_id = d.cases_id
  15621. AND c.cases_entry_id = d.id
  15622. AND a.beh_dept_id = f.dept_id
  15623. AND a.qc_type_id != 0
  15624. <if test="qcResultShortPageVO.userId!=null">
  15625. AND f.user_id = #{qcResultShortPageVO.userId}
  15626. </if>
  15627. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15628. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15629. </if>
  15630. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15631. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15632. </if>
  15633. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15634. <if test="qcResultShortPageVO.startDate != null ">
  15635. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15636. </if>
  15637. <if test="qcResultShortPageVO.endDate != null ">
  15638. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15639. </if>
  15640. </if>
  15641. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15642. <if test="qcResultShortPageVO.startDate != null ">
  15643. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15644. </if>
  15645. <if test="qcResultShortPageVO.endDate != null">
  15646. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15647. </if>
  15648. </if>
  15649. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15650. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15651. </if>
  15652. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15653. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15654. </if>
  15655. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15656. AND b.`level` = #{qcResultShortPageVO.level}
  15657. </if>
  15658. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15659. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15660. </if>
  15661. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15662. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15663. </if>
  15664. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  15665. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  15666. </if>
  15667. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15668. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15669. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15670. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15671. </if>
  15672. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15673. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15674. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15675. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15676. </if>
  15677. <if test="qcResultShortPageVO.casesEntryId != null ">
  15678. AND d.id = #{qcResultShortPageVO.casesEntryId}
  15679. </if>
  15680. <if test="qcResultShortPageVO.isReject != null">
  15681. AND c.is_reject = #{qcResultShortPageVO.isReject}
  15682. </if>
  15683. <if test="qcResultShortPageVO.ruleType != null">
  15684. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  15685. </if>
  15686. )be
  15687. left join med_check_info mci
  15688. on mci.is_deleted = 'N'
  15689. and mci.check_type = 0
  15690. and be.hospital_id = mci.hospital_id
  15691. and be.behospital_code = mci.behospital_code
  15692. left join med_check_info hm_mci
  15693. on hm_mci.is_deleted = 'N'
  15694. and hm_mci.check_type = 1
  15695. and be.hospital_id = hm_mci.hospital_id
  15696. and be.behospital_code = hm_mci.behospital_code
  15697. ) t1
  15698. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15699. AND t1.behospital_code = t2.behospital_code
  15700. AND t2.is_deleted = 'N'
  15701. ) t
  15702. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15703. AND t.hospitalId = qi.hospital_id
  15704. AND t.behospitalCode = qi.behospital_code
  15705. where 1=1
  15706. <if test="qcResultShortPageVO.checkStatus != null">
  15707. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15708. </if>
  15709. <if test="qcResultShortPageVO.mrStatus != null">
  15710. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15711. </if>
  15712. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15713. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15714. </if>
  15715. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15716. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15717. </if>
  15718. <if test="qcResultShortPageVO.chTimeStart != null ">
  15719. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15720. </if>
  15721. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15722. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15723. </if>
  15724. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15725. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15726. </if>
  15727. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15728. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15729. </if>
  15730. GROUP BY
  15731. t.doctorId,
  15732. t.doctorName
  15733. )f2
  15734. WHERE
  15735. f1.doctorId = f2.doctorId
  15736. AND f1.doctorName = f2.doctorName
  15737. </select>
  15738. <!-- 31天再入院详情页-->
  15739. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  15740. SELECT
  15741. t.fileCode,
  15742. t.diagnose,
  15743. t.diagnoseName,
  15744. t.NAME,
  15745. t.sex,
  15746. t.hospitalId,
  15747. t.behDeptId,
  15748. t.behDeptName,
  15749. t.behospitalCode,
  15750. t.behospitalDate,
  15751. t.lastDiagnose,
  15752. t.lastDiagnoseName,
  15753. t.leaveHospitalDate,
  15754. t.lastBehDeptId,
  15755. t.lastBehDeptName,
  15756. t.lastBehospitalCode,
  15757. t.lastBehospitalDate,
  15758. t.lastLeaveHospitalDate,
  15759. t.diffDays,
  15760. mqi.score_res AS scoreRes,
  15761. mqi.LEVEL AS LEVEL,
  15762. mqi_last.score_res AS lastScoreRes,
  15763. mqi_last.LEVEL AS lastLevel,
  15764. mhp.total_fee AS totleFee,
  15765. mhp.behospital_day_num AS behospitalDayNum,
  15766. mhp.again_behospital_plan AS againBehospitalPlan,
  15767. IF(mhp.age is null, null,CONCAT( ifnull(mhp.age,'') ,ifnull(mhp.age_unit,'') ))as age,
  15768. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  15769. IF(mhp_last.age is null, null,CONCAT( ifnull(mhp_last.age,'') ,ifnull(mhp_last.age_unit,'') ))as lastAge,
  15770. mhp_last.total_fee AS lastTotleFee,
  15771. mhp_last.behospital_day_num AS lastBehospitalDayNum
  15772. FROM
  15773. (
  15774. SELECT
  15775. be.fileCode,
  15776. be.diagnose,
  15777. be.diagnoseName,
  15778. be.NAME,
  15779. be.sex,
  15780. be.hospitalId,
  15781. be.behDeptId,
  15782. be.behDeptName,
  15783. be.behospitalCode,
  15784. be.behospitalDate,
  15785. be.leaveHospitalDate,
  15786. be.lastDiagnose,
  15787. be.lastDiagnoseName,
  15788. be.lastBehDeptId,
  15789. be.lastBehDeptName,
  15790. be.lastBehospitalCode,
  15791. be.lastBehospitalDate,
  15792. be.lastLeaveHospitalDate,
  15793. be.diffDays
  15794. FROM
  15795. (
  15796. SELECT
  15797. r1.file_code AS fileCode,
  15798. r1.diagnose,
  15799. r1.diagnose_name AS diagnoseName,
  15800. r1.NAME,
  15801. r1.sex,
  15802. r1.hospital_id AS hospitalId,
  15803. r1.beh_dept_id AS behDeptId,
  15804. r1.beh_dept_name AS behDeptName,
  15805. r1.behospital_code AS behospitalCode,
  15806. r1.behospital_date AS behospitalDate,
  15807. r1.leave_hospital_date AS leaveHospitalDate,
  15808. r2.diagnose AS lastDiagnose,
  15809. r2.diagnose_name AS lastDiagnoseName,
  15810. r2.beh_dept_id AS lastBehDeptId,
  15811. r2.beh_dept_name AS lastBehDeptName,
  15812. r2.behospital_code AS lastBehospitalCode,
  15813. r2.behospital_date AS lastBehospitalDate,
  15814. r2.leave_hospital_date AS lastLeaveHospitalDate,
  15815. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  15816. FROM
  15817. (
  15818. SELECT
  15819. ( @rownum := @rownum + 1 ) AS rownum,
  15820. t1.file_code,
  15821. t1.behospital_code,
  15822. t1.diagnose,
  15823. t1.diagnose_name,
  15824. t1.NAME,
  15825. t1.sex,
  15826. t1.hospital_id,
  15827. t1.beh_dept_id,
  15828. t1.beh_dept_name,
  15829. t1.behospital_date,
  15830. t1.leave_hospital_date
  15831. FROM(
  15832. select
  15833. tt3.file_code,
  15834. tt3.behospital_code,
  15835. tt3.diagnose,
  15836. tt3.NAME,
  15837. tt3.sex,
  15838. tt3.hospital_id,
  15839. tt3.beh_dept_id,
  15840. tt3.beh_dept_name,
  15841. tt3.behospital_date,
  15842. tt3.leave_hospital_date,
  15843. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  15844. FROM(
  15845. SELECT
  15846. tt2.file_code,
  15847. tt2.diagnose,
  15848. tt2.NAME,
  15849. tt2.sex,
  15850. tt2.hospital_id,
  15851. tt2.beh_dept_id,
  15852. tt2.beh_dept_name,
  15853. tt2.behospital_code,
  15854. tt2.behospital_date,
  15855. tt2.leave_hospital_date
  15856. FROM
  15857. (
  15858. SELECT
  15859. a.file_code
  15860. FROM
  15861. med_behospital_info a
  15862. WHERE
  15863. a.is_deleted = 'N'
  15864. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15865. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  15866. </if>
  15867. AND a.qc_type_id != 0
  15868. AND IFNULL( a.diagnose, '' )!= ''
  15869. AND IFNULL( a.file_code, '' )!= ''
  15870. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15871. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  15872. </if>
  15873. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15874. <if test="reBeHosPageVO.startDate != null ">
  15875. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15876. </if>
  15877. <if test="reBeHosPageVO.endDate != null ">
  15878. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15879. </if>
  15880. </if>
  15881. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15882. <if test="reBeHosPageVO.startDate != null ">
  15883. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15884. </if>
  15885. <if test="reBeHosPageVO.endDate != null">
  15886. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15887. </if>
  15888. </if>
  15889. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15890. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15891. </if>
  15892. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15893. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  15894. </if>
  15895. GROUP BY
  15896. a.file_code
  15897. HAVING
  15898. count(*)> 1
  15899. ) tt1,
  15900. med_behospital_info tt2
  15901. WHERE
  15902. tt2.is_deleted = 'N'
  15903. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15904. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  15905. </if>
  15906. AND tt2.qc_type_id != 0
  15907. AND tt1.file_code = tt2.file_code
  15908. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15909. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  15910. </if>
  15911. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15912. <if test="reBeHosPageVO.startDate != null ">
  15913. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15914. </if>
  15915. <if test="reBeHosPageVO.endDate != null ">
  15916. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15917. </if>
  15918. </if>
  15919. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15920. <if test="reBeHosPageVO.startDate != null ">
  15921. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15922. </if>
  15923. <if test="reBeHosPageVO.endDate != null">
  15924. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15925. </if>
  15926. </if>
  15927. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15928. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15929. </if>
  15930. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15931. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  15932. </if>
  15933. ORDER BY
  15934. tt1.file_code,
  15935. tt2.behospital_date DESC)tt3
  15936. left join med_home_page tt4 on tt4.is_deleted = 'N'
  15937. AND tt3.hospital_id = tt4.hospital_id
  15938. AND tt3.behospital_code = tt4.behospital_code
  15939. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  15940. AND tt4.hospital_id = tt5.hospital_id
  15941. AND tt4.home_page_id = tt5.home_page_id
  15942. GROUP by tt3.behospital_code
  15943. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  15944. ) t1,
  15945. ( SELECT @rownum := 0 ) r
  15946. ) r1
  15947. LEFT JOIN (
  15948. SELECT
  15949. ( @INDEX := @INDEX + 1 ) AS rownum,
  15950. t1.file_code,
  15951. t1.behospital_code,
  15952. t1.diagnose,
  15953. t1.diagnose_name,
  15954. t1.NAME,
  15955. t1.sex,
  15956. t1.hospital_id,
  15957. t1.beh_dept_id,
  15958. t1.beh_dept_name,
  15959. t1.behospital_date,
  15960. t1.leave_hospital_date
  15961. FROM(
  15962. select
  15963. tt3.file_code,
  15964. tt3.behospital_code,
  15965. tt3.diagnose,
  15966. tt3.NAME,
  15967. tt3.sex,
  15968. tt3.hospital_id,
  15969. tt3.beh_dept_id,
  15970. tt3.beh_dept_name,
  15971. tt3.behospital_date,
  15972. tt3.leave_hospital_date,
  15973. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  15974. FROM(
  15975. SELECT
  15976. tt2.file_code,
  15977. tt2.diagnose,
  15978. tt2.NAME,
  15979. tt2.sex,
  15980. tt2.hospital_id,
  15981. tt2.beh_dept_id,
  15982. tt2.beh_dept_name,
  15983. tt2.behospital_code,
  15984. tt2.behospital_date,
  15985. tt2.leave_hospital_date
  15986. FROM
  15987. (
  15988. SELECT
  15989. a.file_code
  15990. FROM
  15991. med_behospital_info a
  15992. WHERE
  15993. a.is_deleted = 'N'
  15994. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15995. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  15996. </if>
  15997. AND a.qc_type_id != 0
  15998. AND IFNULL( a.diagnose, '' )!= ''
  15999. AND IFNULL( a.file_code, '' )!= ''
  16000. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16001. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  16002. </if>
  16003. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16004. <if test="reBeHosPageVO.startDate != null ">
  16005. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16006. </if>
  16007. <if test="reBeHosPageVO.endDate != null ">
  16008. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16009. </if>
  16010. </if>
  16011. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16012. <if test="reBeHosPageVO.startDate != null ">
  16013. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16014. </if>
  16015. <if test="reBeHosPageVO.endDate != null">
  16016. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16017. </if>
  16018. </if>
  16019. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16020. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16021. </if>
  16022. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16023. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  16024. </if>
  16025. GROUP BY
  16026. a.file_code
  16027. HAVING
  16028. count(*)> 1
  16029. ) tt1,
  16030. med_behospital_info tt2
  16031. WHERE
  16032. tt2.is_deleted = 'N'
  16033. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16034. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  16035. </if>
  16036. AND tt2.qc_type_id != 0
  16037. AND tt1.file_code = tt2.file_code
  16038. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16039. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  16040. </if>
  16041. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16042. <if test="reBeHosPageVO.startDate != null ">
  16043. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16044. </if>
  16045. <if test="reBeHosPageVO.endDate != null ">
  16046. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16047. </if>
  16048. </if>
  16049. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16050. <if test="reBeHosPageVO.startDate != null ">
  16051. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16052. </if>
  16053. <if test="reBeHosPageVO.endDate != null">
  16054. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16055. </if>
  16056. </if>
  16057. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16058. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16059. </if>
  16060. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16061. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  16062. </if>
  16063. ORDER BY
  16064. tt1.file_code,
  16065. tt2.behospital_date DESC)tt3
  16066. left join med_home_page tt4 on tt4.is_deleted = 'N'
  16067. AND tt3.hospital_id = tt4.hospital_id
  16068. AND tt3.behospital_code = tt4.behospital_code
  16069. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  16070. AND tt4.hospital_id = tt5.hospital_id
  16071. AND tt4.home_page_id = tt5.home_page_id
  16072. GROUP by tt3.behospital_code
  16073. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  16074. ) t1,
  16075. ( SELECT @INDEX := 0 ) r
  16076. ) r2 ON r1.file_code = r2.file_code
  16077. AND r1.rownum = r2.rownum - 1
  16078. ) be
  16079. WHERE
  16080. be.diffDays IS NOT NULL
  16081. AND be.diffDays BETWEEN 0
  16082. AND 31
  16083. ) t
  16084. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  16085. AND t.hospitalId = mqi.hospital_id
  16086. AND t.behospitalCode = mqi.behospital_code
  16087. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  16088. AND t.hospitalId = mqi_last.hospital_id
  16089. AND t.lastBehospitalCode = mqi_last.behospital_code
  16090. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  16091. AND t.hospitalId = mhp.hospital_id
  16092. AND t.behospitalCode = mhp.behospital_code
  16093. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  16094. AND t.hospitalId = mhp_last.hospital_id
  16095. AND t.lastBehospitalCode = mhp_last.behospital_code
  16096. </select>
  16097. <!-- 31天再入院详情页-科室-->
  16098. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  16099. SELECT
  16100. t.fileCode,
  16101. t.diagnose,
  16102. t.diagnoseName,
  16103. t.NAME,
  16104. t.sex,
  16105. t.hospitalId,
  16106. t.behDeptId,
  16107. t.behDeptName,
  16108. t.doctorId,
  16109. t.doctorName,
  16110. t.behospitalCode,
  16111. t.behospitalDate,
  16112. t.leaveHospitalDate,
  16113. t.lastDiagnose,
  16114. t.lastDiagnoseName,
  16115. t.lastBehDeptId,
  16116. t.lastBehDeptName,
  16117. t.lastDoctorName,
  16118. t.lastBehospitalCode,
  16119. t.lastBehospitalDate,
  16120. t.lastLeaveHospitalDate,
  16121. t.diffDays,
  16122. mqi.score_res AS scoreRes,
  16123. mqi.LEVEL AS LEVEL,
  16124. mqi_last.score_res AS lastScoreRes,
  16125. mqi_last.LEVEL AS lastLevel,
  16126. mhp.again_behospital_plan AS againBehospitalPlan,
  16127. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  16128. mhp.total_fee AS totleFee,
  16129. mhp.behospital_day_num AS behospitalDayNum,
  16130. mhp_last.total_fee AS lastTotleFee,
  16131. mhp_last.behospital_day_num AS lastBehospitalDayNum
  16132. FROM
  16133. (
  16134. SELECT
  16135. be.fileCode,
  16136. be.diagnose,
  16137. be.diagnoseName,
  16138. be.NAME,
  16139. be.sex,
  16140. be.hospitalId,
  16141. be.behDeptId,
  16142. be.behDeptName,
  16143. be.doctorId,
  16144. be.doctorName,
  16145. be.behospitalCode,
  16146. be.behospitalDate,
  16147. be.leaveHospitalDate,
  16148. be.lastDiagnose,
  16149. be.lastDiagnoseName,
  16150. be.lastBehDeptId,
  16151. be.lastBehDeptName,
  16152. be.lastDoctorId,
  16153. be.lastDoctorName,
  16154. be.lastBehospitalCode,
  16155. be.lastBehospitalDate,
  16156. be.lastLeaveHospitalDate,
  16157. be.diffDays
  16158. FROM
  16159. (
  16160. SELECT
  16161. r1.file_code AS fileCode,
  16162. r1.diagnose,
  16163. r1.diagnose_name AS diagnoseName,
  16164. r1.NAME,
  16165. r1.sex,
  16166. r1.hospital_id AS hospitalId,
  16167. r1.beh_dept_id AS behDeptId,
  16168. r1.beh_dept_name AS behDeptName,
  16169. r1.doctor_id as doctorId,
  16170. r1.doctor_name as doctorName,
  16171. r1.behospital_code AS behospitalCode,
  16172. r1.behospital_date AS behospitalDate,
  16173. r1.leave_hospital_date AS leaveHospitalDate,
  16174. r2.diagnose AS lastDiagnose,
  16175. r2.diagnose_name AS lastDiagnoseName,
  16176. r2.beh_dept_id AS lastBehDeptId,
  16177. r2.beh_dept_name AS lastBehDeptName,
  16178. r2.behospital_code AS lastBehospitalCode,
  16179. r2.behospital_date AS lastBehospitalDate,
  16180. r2.doctor_id as lastDoctorId,
  16181. r2.doctor_name as lastDoctorName,
  16182. r2.leave_hospital_date AS lastLeaveHospitalDate,
  16183. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  16184. FROM
  16185. (
  16186. SELECT
  16187. ( @rownum := @rownum + 1 ) AS rownum,
  16188. t1.file_code,
  16189. t1.NAME,
  16190. t1.sex,
  16191. t1.diagnose,
  16192. t1.diagnose_name,
  16193. t1.doctor_id,
  16194. t1.doctor_name,
  16195. t1.hospital_id,
  16196. t1.beh_dept_id,
  16197. t1.beh_dept_name,
  16198. t1.behospital_code,
  16199. t1.behospital_date,
  16200. t1.leave_hospital_date
  16201. FROM
  16202. (
  16203. select
  16204. tt3.file_code,
  16205. tt3.behospital_code,
  16206. tt3.diagnose,
  16207. tt3.NAME,
  16208. tt3.sex,
  16209. tt3.hospital_id,
  16210. tt3.beh_dept_id,
  16211. tt3.beh_dept_name,
  16212. tt3.doctor_id,
  16213. tt3.doctor_name,
  16214. tt3.behospital_date,
  16215. tt3.leave_hospital_date,
  16216. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  16217. FROM(
  16218. SELECT
  16219. tt1.file_code,
  16220. tt2.diagnose,
  16221. tt2.doctor_id,
  16222. tt2.doctor_name,
  16223. tt2.NAME,
  16224. tt2.sex,
  16225. tt2.hospital_id,
  16226. tt2.beh_dept_id,
  16227. tt2.beh_dept_name,
  16228. tt2.behospital_code,
  16229. tt2.behospital_date,
  16230. tt2.leave_hospital_date
  16231. FROM
  16232. (
  16233. SELECT
  16234. a.file_code
  16235. FROM
  16236. med_behospital_info a,
  16237. sys_user_dept c
  16238. WHERE
  16239. a.is_deleted = 'N'
  16240. AND c.is_deleted = 'N'
  16241. AND a.hospital_id = c.hospital_id
  16242. AND a.beh_dept_id = c.dept_id
  16243. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  16244. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  16245. </if>
  16246. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16247. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  16248. </if>
  16249. <if test="reBeHosPageVO.userId!=null">
  16250. AND c.user_id = #{reBeHosPageVO.userId}
  16251. </if>
  16252. AND a.qc_type_id != 0
  16253. AND IFNULL( a.diagnose, '' )!= ''
  16254. AND IFNULL( a.file_code, '' )!= ''
  16255. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16256. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  16257. </if>
  16258. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16259. <if test="reBeHosPageVO.startDate != null ">
  16260. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16261. </if>
  16262. <if test="reBeHosPageVO.endDate != null ">
  16263. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16264. </if>
  16265. </if>
  16266. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16267. <if test="reBeHosPageVO.startDate != null ">
  16268. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16269. </if>
  16270. <if test="reBeHosPageVO.endDate != null">
  16271. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16272. </if>
  16273. </if>
  16274. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16275. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16276. </if>
  16277. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16278. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  16279. </if>
  16280. GROUP BY
  16281. a.file_code
  16282. HAVING
  16283. count(*)> 1
  16284. ) tt1,
  16285. med_behospital_info tt2
  16286. WHERE
  16287. tt2.is_deleted = 'N'
  16288. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16289. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  16290. </if>
  16291. AND tt2.qc_type_id != 0
  16292. AND tt1.file_code = tt2.file_code
  16293. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16294. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  16295. </if>
  16296. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16297. <if test="reBeHosPageVO.startDate != null ">
  16298. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16299. </if>
  16300. <if test="reBeHosPageVO.endDate != null ">
  16301. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16302. </if>
  16303. </if>
  16304. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16305. <if test="reBeHosPageVO.startDate != null ">
  16306. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16307. </if>
  16308. <if test="reBeHosPageVO.endDate != null">
  16309. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16310. </if>
  16311. </if>
  16312. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16313. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16314. </if>
  16315. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16316. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  16317. </if>
  16318. ORDER BY
  16319. tt1.file_code,
  16320. tt2.behospital_date DESC)tt3
  16321. left join med_home_page tt4 on tt4.is_deleted = 'N'
  16322. AND tt3.hospital_id = tt4.hospital_id
  16323. AND tt3.behospital_code = tt4.behospital_code
  16324. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  16325. AND tt4.hospital_id = tt5.hospital_id
  16326. AND tt4.home_page_id = tt5.home_page_id
  16327. GROUP by tt3.behospital_code
  16328. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  16329. ) t1,
  16330. ( SELECT @rownum := 0 ) r
  16331. ) r1
  16332. LEFT JOIN (
  16333. SELECT
  16334. ( @INDEX := @INDEX + 1 ) AS rownum,
  16335. t1.file_code,
  16336. t1.NAME,
  16337. t1.sex,
  16338. t1.diagnose,
  16339. t1.diagnose_name,
  16340. t1.doctor_id,
  16341. t1.doctor_name,
  16342. t1.hospital_id,
  16343. t1.beh_dept_id,
  16344. t1.beh_dept_name,
  16345. t1.behospital_code,
  16346. t1.behospital_date,
  16347. t1.leave_hospital_date
  16348. FROM
  16349. (
  16350. select
  16351. tt3.file_code,
  16352. tt3.behospital_code,
  16353. tt3.diagnose,
  16354. tt3.NAME,
  16355. tt3.sex,
  16356. tt3.hospital_id,
  16357. tt3.beh_dept_id,
  16358. tt3.beh_dept_name,
  16359. tt3.doctor_id,
  16360. tt3.doctor_name,
  16361. tt3.behospital_date,
  16362. tt3.leave_hospital_date,
  16363. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  16364. FROM(
  16365. SELECT
  16366. tt1.file_code,
  16367. tt2.diagnose,
  16368. tt2.doctor_id,
  16369. tt2.doctor_name,
  16370. tt2.NAME,
  16371. tt2.sex,
  16372. tt2.hospital_id,
  16373. tt2.beh_dept_id,
  16374. tt2.beh_dept_name,
  16375. tt2.behospital_code,
  16376. tt2.behospital_date,
  16377. tt2.leave_hospital_date
  16378. FROM
  16379. (
  16380. SELECT
  16381. a.file_code
  16382. FROM
  16383. med_behospital_info a,
  16384. sys_user_dept c
  16385. WHERE
  16386. a.is_deleted = 'N'
  16387. AND c.is_deleted = 'N'
  16388. AND a.hospital_id = c.hospital_id
  16389. AND a.beh_dept_id = c.dept_id
  16390. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  16391. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  16392. </if>
  16393. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16394. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  16395. </if>
  16396. <if test="reBeHosPageVO.userId!=null">
  16397. AND c.user_id = #{reBeHosPageVO.userId}
  16398. </if>
  16399. AND a.qc_type_id != 0
  16400. AND IFNULL( a.diagnose, '' )!= ''
  16401. AND IFNULL( a.file_code, '' )!= ''
  16402. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16403. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  16404. </if>
  16405. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16406. <if test="reBeHosPageVO.startDate != null ">
  16407. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16408. </if>
  16409. <if test="reBeHosPageVO.endDate != null ">
  16410. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16411. </if>
  16412. </if>
  16413. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16414. <if test="reBeHosPageVO.startDate != null ">
  16415. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16416. </if>
  16417. <if test="reBeHosPageVO.endDate != null">
  16418. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16419. </if>
  16420. </if>
  16421. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16422. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16423. </if>
  16424. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16425. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  16426. </if>
  16427. GROUP BY
  16428. a.file_code
  16429. HAVING
  16430. count(*)> 1
  16431. ) tt1,
  16432. med_behospital_info tt2
  16433. WHERE
  16434. tt2.is_deleted = 'N'
  16435. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  16436. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  16437. </if>
  16438. AND tt2.qc_type_id != 0
  16439. AND tt1.file_code = tt2.file_code
  16440. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  16441. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  16442. </if>
  16443. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  16444. <if test="reBeHosPageVO.startDate != null ">
  16445. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  16446. </if>
  16447. <if test="reBeHosPageVO.endDate != null ">
  16448. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  16449. </if>
  16450. </if>
  16451. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  16452. <if test="reBeHosPageVO.startDate != null ">
  16453. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  16454. </if>
  16455. <if test="reBeHosPageVO.endDate != null">
  16456. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  16457. </if>
  16458. </if>
  16459. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  16460. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  16461. </if>
  16462. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  16463. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  16464. </if>
  16465. ORDER BY
  16466. tt1.file_code,
  16467. tt2.behospital_date DESC)tt3
  16468. left join med_home_page tt4 on tt4.is_deleted = 'N'
  16469. AND tt3.hospital_id = tt4.hospital_id
  16470. AND tt3.behospital_code = tt4.behospital_code
  16471. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  16472. AND tt4.hospital_id = tt5.hospital_id
  16473. AND tt4.home_page_id = tt5.home_page_id
  16474. GROUP by tt3.behospital_code
  16475. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  16476. ) t1,
  16477. ( SELECT @INDEX := 0 ) r
  16478. ) r2 ON r1.file_code = r2.file_code
  16479. AND r1.rownum = r2.rownum - 1
  16480. ) be
  16481. WHERE
  16482. be.diffDays IS NOT NULL
  16483. AND be.diffDays BETWEEN 0
  16484. AND 31
  16485. ) t
  16486. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  16487. AND t.hospitalId = mqi.hospital_id
  16488. AND t.behospitalCode = mqi.behospital_code
  16489. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  16490. AND t.hospitalId = mqi_last.hospital_id
  16491. AND t.lastBehospitalCode = mqi_last.behospital_code
  16492. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  16493. AND t.hospitalId = mhp.hospital_id
  16494. AND t.behospitalCode = mhp.behospital_code
  16495. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  16496. AND t.hospitalId = mhp_last.hospital_id
  16497. AND t.lastBehospitalCode = mhp_last.behospital_code
  16498. </select>
  16499. <!-- 单条条目缺陷统计-->
  16500. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  16501. SELECT
  16502. a.beh_dept_id AS id,
  16503. a.beh_dept_name AS NAME,
  16504. count(*) AS num
  16505. FROM
  16506. med_behospital_info a,
  16507. med_qcresult_detail b
  16508. WHERE
  16509. a.is_deleted = 'N'
  16510. AND b.is_deleted = 'N'
  16511. AND a.hospital_id = b.hospital_id
  16512. AND a.behospital_code = b.behospital_code
  16513. AND a.qc_type_id != 0
  16514. and b.cases_entry_id=2658
  16515. <if test="isPlacefile != null and isPlacefile != ''">
  16516. and a.is_placefile = #{isPlacefile}
  16517. </if>
  16518. <if test="hospitalId != null and hospitalId != ''">
  16519. AND a.hospital_id = #{hospitalId}
  16520. </if>
  16521. <if test="isPlacefile != null and isPlacefile == 0">
  16522. <if test="startDate != null and startDate != ''">
  16523. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  16524. </if>
  16525. <if test="endDate != null and endDate != ''">
  16526. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  16527. </if>
  16528. </if>
  16529. <if test="isPlacefile != null and isPlacefile == 1">
  16530. <if test="startDate != null and startDate != ''">
  16531. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  16532. </if>
  16533. <if test="endDate != null and endDate != ''">
  16534. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  16535. </if>
  16536. </if>
  16537. GROUP BY
  16538. a.beh_dept_id,
  16539. a.beh_dept_name
  16540. </select>
  16541. <!-- 单条条目缺陷统计-->
  16542. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  16543. SELECT
  16544. a.beh_dept_id AS deptId,
  16545. a.beh_dept_name AS deptName,
  16546. a.doctor_id as doctorId,
  16547. a.doctor_name as doctorName,
  16548. count(*) AS num
  16549. FROM
  16550. med_behospital_info a,
  16551. med_qcresult_detail b,
  16552. sys_user_dept c
  16553. WHERE
  16554. a.is_deleted = 'N'
  16555. AND b.is_deleted = 'N'
  16556. AND c.is_deleted = 'N'
  16557. AND a.hospital_id = b.hospital_id
  16558. AND a.hospital_id = c.hospital_id
  16559. AND a.behospital_code = b.behospital_code
  16560. AND a.beh_dept_id = c.dept_id
  16561. AND a.qc_type_id != 0
  16562. and b.cases_entry_id=2658
  16563. <if test="isPlacefile != null and isPlacefile != ''">
  16564. and a.is_placefile = #{isPlacefile}
  16565. </if>
  16566. <if test="hospitalId != null and hospitalId != ''">
  16567. AND a.hospital_id = #{hospitalId}
  16568. </if>
  16569. <if test="userId!=null">
  16570. AND c.user_id = #{userId}
  16571. </if>
  16572. <if test="isPlacefile != null and isPlacefile == 0">
  16573. <if test="startDate != null and startDate != ''">
  16574. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  16575. </if>
  16576. <if test="endDate != null and endDate != ''">
  16577. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  16578. </if>
  16579. </if>
  16580. <if test="isPlacefile != null and isPlacefile == 1">
  16581. <if test="startDate != null and startDate != ''">
  16582. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  16583. </if>
  16584. <if test="endDate != null and endDate != ''">
  16585. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  16586. </if>
  16587. </if>
  16588. GROUP BY
  16589. a.beh_dept_id,
  16590. a.beh_dept_name,
  16591. a.doctor_id,
  16592. a.doctor_name
  16593. </select>
  16594. <!-- 病案首页改善率质控评分页(内页)-->
  16595. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  16596. SELECT
  16597. t.*
  16598. FROM
  16599. (
  16600. SELECT DISTINCT
  16601. t1.hospital_id AS hospitalId,
  16602. t1.behospital_code AS behospitalCode,
  16603. t1.bed_code AS bedCode,
  16604. t1.LEVEL AS LEVEL,
  16605. t1.grade_type AS gradeType,
  16606. t1.score_res AS scoreRes,
  16607. t1.scoreBn,
  16608. t1.NAME AS NAME,
  16609. t1.sex AS sex,
  16610. t1.beh_dept_id AS behDeptId,
  16611. t1.beh_dept_name AS behDeptName,
  16612. t1.doctor_id AS doctorId,
  16613. t1.doctor_name AS doctorName,
  16614. t1.beh_doctor_id AS behDoctorId,
  16615. t1.beh_doctor_name AS behDoctorName,
  16616. t1.director_doctor_id AS directorDoctorId,
  16617. t1.director_doctor_name AS directorDoctorName,
  16618. t1.birthday AS birthday,
  16619. t1.behospital_date AS behospitalDate,
  16620. t1.leave_hospital_date AS leaveHospitalDate,
  16621. t1.placefile_date AS placefileDate,
  16622. t1.gmt_create AS gradeTime,
  16623. t1.diagnose,
  16624. t1.ward_name AS wardName,
  16625. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  16626. t1.file_code AS fileCode,
  16627. t1.checkStatus,
  16628. t1.chName,
  16629. t1.chTime
  16630. FROM
  16631. (
  16632. SELECT
  16633. be.*,
  16634. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16635. mci.check_name AS chName,
  16636. mci.gmt_create AS chTime
  16637. FROM
  16638. (
  16639. SELECT DISTINCT
  16640. a.hospital_id,
  16641. a.behospital_code,
  16642. a.bed_code,
  16643. a.file_code,
  16644. c.LEVEL,
  16645. c.grade_type,
  16646. c.score_res,
  16647. a.NAME,
  16648. a.sex,
  16649. a.beh_dept_id,
  16650. a.beh_dept_name,
  16651. a.birthday,
  16652. a.behospital_date,
  16653. a.leave_hospital_date,
  16654. a.doctor_id,
  16655. a.doctor_name,
  16656. a.beh_doctor_id,
  16657. a.beh_doctor_name,
  16658. a.director_doctor_id,
  16659. a.director_doctor_name,
  16660. a.diagnose,
  16661. a.placefile_date,
  16662. a.ward_name,
  16663. c.gmt_create,
  16664. d.score_res as scoreBn
  16665. FROM
  16666. med_behospital_info a,
  16667. med_home_page b,
  16668. med_qcresult_info c,
  16669. med_qcresult_cases d,
  16670. (
  16671. SELECT
  16672. m4.*
  16673. FROM
  16674. med_behospital_info m1,
  16675. med_home_page m2,
  16676. med_qcresult_info m3,
  16677. med_qcresult_cases m4
  16678. WHERE
  16679. m1.is_deleted = 'N'
  16680. AND m2.is_deleted = 'N'
  16681. AND m3.is_deleted = 'Y'
  16682. AND m4.is_deleted = 'Y'
  16683. AND m1.hospital_id = m2.hospital_id
  16684. AND m1.hospital_id = m3.hospital_id
  16685. AND m1.hospital_id = m4.hospital_id
  16686. AND m1.behospital_code = m2.behospital_code
  16687. AND m1.behospital_code = m3.behospital_code
  16688. AND m1.behospital_code = m4.behospital_code
  16689. AND m3.gmt_create = m4.gmt_create
  16690. AND m3.have_home_page = 1
  16691. AND m4.cases_id = 243
  16692. AND m1.qc_type_id != 0
  16693. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16694. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16695. </if>
  16696. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16697. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16698. </if>
  16699. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16700. <if test="qcResultShortPageVO.startDate != null ">
  16701. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16702. </if>
  16703. <if test="qcResultShortPageVO.endDate != null ">
  16704. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16705. </if>
  16706. </if>
  16707. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16708. <if test="qcResultShortPageVO.startDate != null">
  16709. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16710. </if>
  16711. <if test="qcResultShortPageVO.endDate != null ">
  16712. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16713. </if>
  16714. </if>
  16715. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16716. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16717. </if>
  16718. GROUP BY
  16719. m1.behospital_code
  16720. ORDER BY
  16721. m1.behospital_code,
  16722. m4.gmt_create
  16723. ) e
  16724. WHERE
  16725. a.is_deleted = 'N'
  16726. AND b.is_deleted = 'N'
  16727. AND c.is_deleted = 'N'
  16728. AND d.is_deleted = 'N'
  16729. AND a.hospital_id = b.hospital_id
  16730. AND a.hospital_id = c.hospital_id
  16731. AND a.hospital_id = d.hospital_id
  16732. AND a.hospital_id = e.hospital_id
  16733. AND a.behospital_code = b.behospital_code
  16734. AND a.behospital_code = c.behospital_code
  16735. AND a.behospital_code = d.behospital_code
  16736. AND a.behospital_code = e.behospital_code
  16737. AND d.cases_id = 243
  16738. AND d.score_res > e.score_res
  16739. AND a.qc_type_id != 0
  16740. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16741. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16742. </if>
  16743. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16744. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16745. </if>
  16746. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16747. <if test="qcResultShortPageVO.startDate != null ">
  16748. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16749. </if>
  16750. <if test="qcResultShortPageVO.endDate != null ">
  16751. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16752. </if>
  16753. </if>
  16754. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16755. <if test="qcResultShortPageVO.startDate != null ">
  16756. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16757. </if>
  16758. <if test="qcResultShortPageVO.endDate != null">
  16759. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16760. </if>
  16761. </if>
  16762. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16763. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16764. </if>
  16765. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16766. AND c.`level` = #{qcResultShortPageVO.level}
  16767. </if>
  16768. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16769. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16770. </if>
  16771. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16772. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16773. </if>
  16774. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16775. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16776. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16777. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16778. </if>
  16779. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16780. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16781. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16782. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16783. </if>
  16784. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16785. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16786. </if>
  16787. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16788. AND d.score_res = 20
  16789. </if>
  16790. ) be
  16791. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16792. AND mci.check_type in(0,2)
  16793. AND be.hospital_id = mci.hospital_id
  16794. AND be.behospital_code = mci.behospital_code
  16795. ) t1
  16796. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16797. AND t1.behospital_code = t2.behospital_code
  16798. AND t2.is_deleted = 'N'
  16799. ) t
  16800. WHERE
  16801. 1 = 1
  16802. <if test="qcResultShortPageVO.checkStatus != null">
  16803. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16804. </if>
  16805. <if test="qcResultShortPageVO.mrStatus != null">
  16806. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16807. </if>
  16808. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16809. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16810. </if>
  16811. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16812. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16813. </if>
  16814. <if test="qcResultShortPageVO.chTimeStart != null ">
  16815. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16816. </if>
  16817. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16818. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16819. </if>
  16820. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16821. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16822. </if>
  16823. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16824. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16825. </if>
  16826. </select>
  16827. <!-- 病案首页改善率质控评分页(内页)-科室-->
  16828. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  16829. SELECT
  16830. t.*
  16831. FROM
  16832. (
  16833. SELECT DISTINCT
  16834. t1.hospital_id AS hospitalId,
  16835. t1.behospital_code AS behospitalCode,
  16836. t1.bed_code AS bedCode,
  16837. t1.LEVEL AS LEVEL,
  16838. t1.grade_type AS gradeType,
  16839. t1.score_res AS scoreRes,
  16840. t1.NAME AS NAME,
  16841. t1.scoreBn,
  16842. t1.sex AS sex,
  16843. t1.beh_dept_id AS behDeptId,
  16844. t1.beh_dept_name AS behDeptName,
  16845. t1.doctor_id AS doctorId,
  16846. t1.doctor_name AS doctorName,
  16847. t1.beh_doctor_id AS behDoctorId,
  16848. t1.beh_doctor_name AS behDoctorName,
  16849. t1.director_doctor_id AS directorDoctorId,
  16850. t1.director_doctor_name AS directorDoctorName,
  16851. t1.birthday AS birthday,
  16852. t1.behospital_date AS behospitalDate,
  16853. t1.leave_hospital_date AS leaveHospitalDate,
  16854. t1.placefile_date AS placefileDate,
  16855. t1.gmt_create AS gradeTime,
  16856. t1.diagnose,
  16857. t1.ward_name AS wardName,
  16858. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  16859. t1.file_code AS fileCode,
  16860. t1.checkStatus,
  16861. t1.mrStatus,
  16862. t1.chName,
  16863. t1.mrName,
  16864. t1.chTime,
  16865. t1.mrTime
  16866. FROM
  16867. (
  16868. SELECT
  16869. be.*,
  16870. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16871. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16872. mci.check_name AS chName,
  16873. hm_mci.check_name AS mrName,
  16874. e.score_res as scoreBn,
  16875. mci.gmt_create AS chTime,
  16876. hm_mci.gmt_create AS mrTime
  16877. FROM
  16878. (
  16879. SELECT DISTINCT
  16880. a.hospital_id,
  16881. a.behospital_code,
  16882. a.bed_code,
  16883. a.file_code,
  16884. c.LEVEL,
  16885. c.grade_type,
  16886. c.score_res,
  16887. a.NAME,
  16888. a.sex,
  16889. a.beh_dept_id,
  16890. a.beh_dept_name,
  16891. a.birthday,
  16892. a.behospital_date,
  16893. a.leave_hospital_date,
  16894. a.doctor_id,
  16895. a.doctor_name,
  16896. a.beh_doctor_id,
  16897. a.beh_doctor_name,
  16898. a.director_doctor_id,
  16899. a.director_doctor_name,
  16900. a.diagnose,
  16901. a.placefile_date,
  16902. a.ward_name,
  16903. c.gmt_create
  16904. FROM
  16905. med_behospital_info a,
  16906. med_home_page b,
  16907. med_qcresult_info c,
  16908. med_qcresult_cases d,
  16909. sys_user_dept f,
  16910. (
  16911. SELECT
  16912. m4.*
  16913. FROM
  16914. med_behospital_info m1,
  16915. med_home_page m2,
  16916. med_qcresult_info m3,
  16917. med_qcresult_cases m4
  16918. WHERE
  16919. m1.is_deleted = 'N'
  16920. AND m2.is_deleted = 'N'
  16921. AND m3.is_deleted = 'Y'
  16922. AND m4.is_deleted = 'Y'
  16923. AND m1.hospital_id = m2.hospital_id
  16924. AND m1.hospital_id = m3.hospital_id
  16925. AND m1.hospital_id = m4.hospital_id
  16926. AND m1.behospital_code = m2.behospital_code
  16927. AND m1.behospital_code = m3.behospital_code
  16928. AND m1.behospital_code = m4.behospital_code
  16929. AND m3.gmt_create = m4.gmt_create
  16930. AND m3.have_home_page = 1
  16931. AND m4.cases_id = 243
  16932. AND m1.qc_type_id != 0
  16933. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16934. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16935. </if>
  16936. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16937. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16938. </if>
  16939. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16940. <if test="qcResultShortPageVO.startDate != null ">
  16941. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16942. </if>
  16943. <if test="qcResultShortPageVO.endDate != null ">
  16944. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16945. </if>
  16946. </if>
  16947. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16948. <if test="qcResultShortPageVO.startDate != null">
  16949. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16950. </if>
  16951. <if test="qcResultShortPageVO.endDate != null ">
  16952. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16953. </if>
  16954. </if>
  16955. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16956. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  16957. </if>
  16958. GROUP BY
  16959. m1.behospital_code
  16960. ORDER BY
  16961. m1.behospital_code,
  16962. m4.gmt_create
  16963. ) e
  16964. WHERE
  16965. a.is_deleted = 'N'
  16966. AND b.is_deleted = 'N'
  16967. AND c.is_deleted = 'N'
  16968. AND d.is_deleted = 'N'
  16969. AND f.is_deleted = 'N'
  16970. AND a.hospital_id = b.hospital_id
  16971. AND a.hospital_id = c.hospital_id
  16972. AND a.hospital_id = d.hospital_id
  16973. AND a.hospital_id = f.hospital_id
  16974. AND a.hospital_id = e.hospital_id
  16975. AND a.behospital_code = b.behospital_code
  16976. AND a.behospital_code = c.behospital_code
  16977. AND a.behospital_code = d.behospital_code
  16978. AND a.beh_dept_id = f.dept_id
  16979. AND a.behospital_code = e.behospital_code
  16980. AND d.cases_id = 243
  16981. AND d.score_res > e.score_res
  16982. AND a.qc_type_id != 0
  16983. <if test="qcResultShortPageVO.userId!=null">
  16984. AND f.user_id = #{qcResultShortPageVO.userId}
  16985. </if>
  16986. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16987. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16988. </if>
  16989. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16990. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16991. </if>
  16992. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16993. <if test="qcResultShortPageVO.startDate != null ">
  16994. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16995. </if>
  16996. <if test="qcResultShortPageVO.endDate != null ">
  16997. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16998. </if>
  16999. </if>
  17000. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17001. <if test="qcResultShortPageVO.startDate != null ">
  17002. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17003. </if>
  17004. <if test="qcResultShortPageVO.endDate != null">
  17005. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17006. </if>
  17007. </if>
  17008. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17009. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17010. </if>
  17011. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17012. AND c.`level` = #{qcResultShortPageVO.level}
  17013. </if>
  17014. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17015. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17016. </if>
  17017. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17018. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17019. </if>
  17020. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17021. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17022. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17023. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17024. </if>
  17025. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17026. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17027. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17028. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17029. </if>
  17030. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  17031. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  17032. </if>
  17033. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  17034. AND d.score_res = 20
  17035. </if>
  17036. ) be
  17037. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17038. AND mci.check_type = 0
  17039. AND be.hospital_id = mci.hospital_id
  17040. AND be.behospital_code = mci.behospital_code
  17041. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17042. AND hm_mci.check_type = 1
  17043. AND be.hospital_id = hm_mci.hospital_id
  17044. AND be.behospital_code = hm_mci.behospital_code
  17045. LEFT JOIN med_qcresult_cases e
  17046. on be.behospital_code = e.behospital_code
  17047. and be.hospital_id = e.hospital_id
  17048. AND e.is_deleted = 'N'
  17049. and e.cases_id = 243
  17050. ) t1
  17051. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17052. AND t1.behospital_code = t2.behospital_code
  17053. AND t2.is_deleted = 'N'
  17054. ) t
  17055. WHERE
  17056. 1 = 1
  17057. <if test="qcResultShortPageVO.checkStatus != null">
  17058. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17059. </if>
  17060. <if test="qcResultShortPageVO.mrStatus != null">
  17061. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17062. </if>
  17063. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17064. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17065. </if>
  17066. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17067. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17068. </if>
  17069. <if test="qcResultShortPageVO.chTimeStart != null ">
  17070. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17071. </if>
  17072. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17073. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17074. </if>
  17075. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17076. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17077. </if>
  17078. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17079. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17080. </if>
  17081. </select>
  17082. <!-- 质控核查质控评分页(内页)-->
  17083. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  17084. SELECT
  17085. t.*
  17086. FROM
  17087. (
  17088. SELECT DISTINCT
  17089. t1.hospital_id AS hospitalId,
  17090. t1.behospital_code AS behospitalCode,
  17091. t1.bed_code AS bedCode,
  17092. t1.LEVEL AS LEVEL,
  17093. t1.grade_type AS gradeType,
  17094. t1.score_res AS scoreRes,
  17095. t1.scoreBn,
  17096. t1.NAME AS NAME,
  17097. t1.sex AS sex,
  17098. t1.beh_dept_id AS behDeptId,
  17099. t1.beh_dept_name AS behDeptName,
  17100. t1.doctor_id AS doctorId,
  17101. t1.doctor_name AS doctorName,
  17102. t1.beh_doctor_id AS behDoctorId,
  17103. t1.beh_doctor_name AS behDoctorName,
  17104. t1.director_doctor_id AS directorDoctorId,
  17105. t1.director_doctor_name AS directorDoctorName,
  17106. t1.birthday AS birthday,
  17107. t1.behospital_date AS behospitalDate,
  17108. t1.leave_hospital_date AS leaveHospitalDate,
  17109. t1.placefile_date AS placefileDate,
  17110. t1.gmt_create AS gradeTime,
  17111. t1.diagnose,
  17112. t1.ward_name AS wardName,
  17113. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  17114. t1.file_code AS fileCode,
  17115. t1.checkStatus,
  17116. t1.chName,
  17117. t1.chTime
  17118. FROM
  17119. (
  17120. SELECT
  17121. be.*,
  17122. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17123. mci.check_name AS chName,
  17124. e.score_res as scoreBn,
  17125. mci.gmt_create AS chTime
  17126. FROM
  17127. (
  17128. SELECT DISTINCT
  17129. a.hospital_id,
  17130. a.behospital_code,
  17131. a.bed_code,
  17132. a.file_code,
  17133. b.LEVEL,
  17134. b.grade_type,
  17135. b.score_res,
  17136. a.NAME,
  17137. a.sex,
  17138. a.beh_dept_id,
  17139. a.beh_dept_name,
  17140. a.birthday,
  17141. a.behospital_date,
  17142. a.leave_hospital_date,
  17143. a.doctor_id,
  17144. a.doctor_name,
  17145. a.beh_doctor_id,
  17146. a.beh_doctor_name,
  17147. a.director_doctor_id,
  17148. a.director_doctor_name,
  17149. a.diagnose,
  17150. a.placefile_date,
  17151. a.ward_name,
  17152. b.gmt_create
  17153. FROM
  17154. med_behospital_info a,
  17155. med_qcresult_info b
  17156. WHERE
  17157. a.is_deleted = 'N'
  17158. AND b.is_deleted = 'N'
  17159. AND a.hospital_id = b.hospital_id
  17160. AND a.behospital_code = b.behospital_code
  17161. AND a.qc_type_id != 0
  17162. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17163. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17164. </if>
  17165. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17166. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17167. </if>
  17168. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17169. <if test="qcResultShortPageVO.startDate != null ">
  17170. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17171. </if>
  17172. <if test="qcResultShortPageVO.endDate != null ">
  17173. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17174. </if>
  17175. </if>
  17176. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17177. <if test="qcResultShortPageVO.startDate != null ">
  17178. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17179. </if>
  17180. <if test="qcResultShortPageVO.endDate != null">
  17181. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17182. </if>
  17183. </if>
  17184. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17185. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17186. </if>
  17187. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17188. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17189. </if>
  17190. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17191. AND b.`level` = #{qcResultShortPageVO.level}
  17192. </if>
  17193. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17194. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17195. </if>
  17196. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17197. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17198. </if>
  17199. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17200. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17201. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17202. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17203. </if>
  17204. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17205. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17206. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17207. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17208. </if>
  17209. ) be
  17210. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17211. AND mci.check_type in(0,2)
  17212. AND be.hospital_id = mci.hospital_id
  17213. AND be.behospital_code = mci.behospital_code
  17214. LEFT JOIN med_qcresult_cases e
  17215. on be.behospital_code = e.behospital_code
  17216. and be.hospital_id = e.hospital_id
  17217. AND e.is_deleted = 'N'
  17218. and e.cases_id = 243
  17219. ) t1
  17220. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17221. AND t1.behospital_code = t2.behospital_code
  17222. AND t2.is_deleted = 'N'
  17223. ) t
  17224. WHERE
  17225. 1 = 1
  17226. <if test="qcResultShortPageVO.checkStatus != null">
  17227. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17228. </if>
  17229. <if test="qcResultShortPageVO.mrStatus != null">
  17230. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17231. </if>
  17232. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17233. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17234. </if>
  17235. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17236. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17237. </if>
  17238. <if test="qcResultShortPageVO.chTimeStart != null ">
  17239. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17240. </if>
  17241. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17242. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17243. </if>
  17244. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17245. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17246. </if>
  17247. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17248. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17249. </if>
  17250. </select>
  17251. <!-- 质控核查质控评分页-科室(内页)-->
  17252. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  17253. SELECT
  17254. t.*
  17255. FROM
  17256. (
  17257. SELECT DISTINCT
  17258. t1.hospital_id AS hospitalId,
  17259. t1.behospital_code AS behospitalCode,
  17260. t1.bed_code AS bedCode,
  17261. t1.LEVEL AS LEVEL,
  17262. t1.grade_type AS gradeType,
  17263. t1.score_res AS scoreRes,
  17264. t1.scoreBn,
  17265. t1.NAME AS NAME,
  17266. t1.sex AS sex,
  17267. t1.beh_dept_id AS behDeptId,
  17268. t1.beh_dept_name AS behDeptName,
  17269. t1.doctor_id AS doctorId,
  17270. t1.doctor_name AS doctorName,
  17271. t1.beh_doctor_id AS behDoctorId,
  17272. t1.beh_doctor_name AS behDoctorName,
  17273. t1.director_doctor_id AS directorDoctorId,
  17274. t1.director_doctor_name AS directorDoctorName,
  17275. t1.birthday AS birthday,
  17276. t1.behospital_date AS behospitalDate,
  17277. t1.leave_hospital_date AS leaveHospitalDate,
  17278. t1.placefile_date AS placefileDate,
  17279. t1.gmt_create AS gradeTime,
  17280. t1.diagnose,
  17281. t1.ward_name AS wardName,
  17282. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  17283. t1.file_code AS fileCode,
  17284. t1.checkStatus,
  17285. t1.mrStatus,
  17286. t1.chName,
  17287. t1.mrName,
  17288. t1.chTime,
  17289. t1.mrTime
  17290. FROM
  17291. (
  17292. SELECT
  17293. be.*,
  17294. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17295. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17296. mci.check_name AS chName,
  17297. e.score_res as scoreBn,
  17298. hm_mci.check_name AS mrName,
  17299. mci.gmt_create AS chTime,
  17300. hm_mci.gmt_create AS mrTime
  17301. FROM
  17302. (
  17303. SELECT DISTINCT
  17304. a.hospital_id,
  17305. a.behospital_code,
  17306. a.bed_code,
  17307. a.file_code,
  17308. b.LEVEL,
  17309. b.grade_type,
  17310. b.score_res,
  17311. a.NAME,
  17312. a.sex,
  17313. a.beh_dept_id,
  17314. a.beh_dept_name,
  17315. a.birthday,
  17316. a.behospital_date,
  17317. a.leave_hospital_date,
  17318. a.doctor_id,
  17319. a.doctor_name,
  17320. a.beh_doctor_id,
  17321. a.beh_doctor_name,
  17322. a.director_doctor_id,
  17323. a.director_doctor_name,
  17324. a.diagnose,
  17325. a.placefile_date,
  17326. a.ward_name,
  17327. b.gmt_create
  17328. FROM
  17329. med_behospital_info a,
  17330. med_qcresult_info b,
  17331. sys_user_dept c
  17332. WHERE
  17333. a.is_deleted = 'N'
  17334. AND b.is_deleted = 'N'
  17335. AND c.is_deleted = 'N'
  17336. AND a.hospital_id = b.hospital_id
  17337. AND a.hospital_id = c.hospital_id
  17338. AND a.beh_dept_id = c.dept_id
  17339. AND a.behospital_code = b.behospital_code
  17340. AND a.qc_type_id != 0
  17341. <if test="qcResultShortPageVO.userId!=null">
  17342. AND c.user_id = #{qcResultShortPageVO.userId}
  17343. </if>
  17344. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17345. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17346. </if>
  17347. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17348. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17349. </if>
  17350. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17351. <if test="qcResultShortPageVO.startDate != null ">
  17352. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17353. </if>
  17354. <if test="qcResultShortPageVO.endDate != null ">
  17355. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17356. </if>
  17357. </if>
  17358. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17359. <if test="qcResultShortPageVO.startDate != null ">
  17360. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17361. </if>
  17362. <if test="qcResultShortPageVO.endDate != null">
  17363. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17364. </if>
  17365. </if>
  17366. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17367. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17368. </if>
  17369. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17370. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17371. </if>
  17372. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17373. AND b.`level` = #{qcResultShortPageVO.level}
  17374. </if>
  17375. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17376. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17377. </if>
  17378. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17379. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17380. </if>
  17381. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17382. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17383. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17384. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17385. </if>
  17386. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17387. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17388. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17389. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17390. </if>
  17391. ) be
  17392. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17393. AND mci.check_type = 0
  17394. AND be.hospital_id = mci.hospital_id
  17395. AND be.behospital_code = mci.behospital_code
  17396. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17397. AND hm_mci.check_type = 1
  17398. AND be.hospital_id = hm_mci.hospital_id
  17399. AND be.behospital_code = hm_mci.behospital_code
  17400. LEFT JOIN med_qcresult_cases e
  17401. on be.behospital_code = e.behospital_code
  17402. and be.hospital_id = e.hospital_id
  17403. AND e.is_deleted = 'N'
  17404. and e.cases_id = 243
  17405. ) t1
  17406. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17407. AND t1.behospital_code = t2.behospital_code
  17408. AND t2.is_deleted = 'N'
  17409. ) t
  17410. WHERE
  17411. 1 = 1
  17412. <if test="qcResultShortPageVO.checkStatus != null">
  17413. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17414. </if>
  17415. <if test="qcResultShortPageVO.mrStatus != null">
  17416. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17417. </if>
  17418. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17419. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17420. </if>
  17421. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17422. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17423. </if>
  17424. <if test="qcResultShortPageVO.chTimeStart != null ">
  17425. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17426. </if>
  17427. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17428. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17429. </if>
  17430. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17431. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17432. </if>
  17433. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17434. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17435. </if>
  17436. </select>
  17437. <!-- 病案首页改善率质控评分页导出-->
  17438. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  17439. SELECT
  17440. f1.behDeptId,
  17441. f1.behDeptName,
  17442. f1.patName,
  17443. f1.behospitalCode,
  17444. f1.hospitalId,
  17445. f1.behospitalDate,
  17446. f1.leaveHospitalDate,
  17447. f1.score,
  17448. f1.scoreBn,
  17449. f2.avgScore,
  17450. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17451. f1.msg,
  17452. f1.caseName,
  17453. </if>
  17454. f1.checkStatus,
  17455. f1.chName,
  17456. f1.chTime
  17457. FROM
  17458. (SELECT
  17459. t.doctorName AS behDoctorName,
  17460. t.`name` AS patName,
  17461. t.behospitalCode AS behospitalCode,
  17462. t.behospitalDate AS behospitalDate,
  17463. t.leaveHospitalDate AS leaveHospitalDate,
  17464. qi.score_res AS score,
  17465. t.scoreBn,
  17466. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17467. qd.msg AS msg,
  17468. qc.NAME AS caseName,
  17469. </if>
  17470. t.behDeptId,
  17471. t.behDeptName,
  17472. t.hospitalId,
  17473. t.checkStatus,
  17474. t.chName,
  17475. t.chTime
  17476. FROM
  17477. (
  17478. SELECT DISTINCT
  17479. t1.hospital_id AS hospitalId,
  17480. t1.behospital_code AS behospitalCode,
  17481. t1.bed_code AS bedCode,
  17482. t1.LEVEL AS LEVEL,
  17483. t1.grade_type AS gradeType,
  17484. t1.score_res AS scoreRes,
  17485. t1.scoreBn,
  17486. t1.NAME AS NAME,
  17487. t1.sex AS sex,
  17488. t1.beh_dept_id AS behDeptId,
  17489. t1.beh_dept_name AS behDeptName,
  17490. t1.doctor_id AS doctorId,
  17491. t1.doctor_name AS doctorName,
  17492. t1.beh_doctor_id AS behDoctorId,
  17493. t1.beh_doctor_name AS behDoctorName,
  17494. t1.director_doctor_id AS directorDoctorId,
  17495. t1.director_doctor_name AS directorDoctorName,
  17496. t1.birthday AS birthday,
  17497. t1.behospital_date AS behospitalDate,
  17498. t1.leave_hospital_date AS leaveHospitalDate,
  17499. t1.placefile_date AS placefileDate,
  17500. t1.gmt_create AS gradeTime,
  17501. t1.diagnose,
  17502. t1.ward_name AS wardName,
  17503. t2.age,
  17504. t1.file_code AS fileCode,
  17505. t1.checkStatus,
  17506. t1.chName,
  17507. t1.chTime
  17508. FROM
  17509. (
  17510. SELECT
  17511. be.*,
  17512. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17513. mci.check_name AS chName,
  17514. mci.gmt_create AS chTime
  17515. FROM
  17516. (
  17517. SELECT DISTINCT
  17518. a.hospital_id,
  17519. a.behospital_code,
  17520. a.bed_code,
  17521. a.file_code,
  17522. c.LEVEL,
  17523. c.grade_type,
  17524. c.score_res,
  17525. a.NAME,
  17526. a.sex,
  17527. a.beh_dept_id,
  17528. a.beh_dept_name,
  17529. a.birthday,
  17530. a.behospital_date,
  17531. a.leave_hospital_date,
  17532. a.doctor_id,
  17533. a.doctor_name,
  17534. a.beh_doctor_id,
  17535. a.beh_doctor_name,
  17536. a.director_doctor_id,
  17537. a.director_doctor_name,
  17538. a.diagnose,
  17539. a.placefile_date,
  17540. a.ward_name,
  17541. c.gmt_create,
  17542. d.score_res as scoreBn
  17543. FROM
  17544. med_behospital_info a,
  17545. med_home_page b,
  17546. med_qcresult_info c,
  17547. med_qcresult_cases d,
  17548. (
  17549. SELECT
  17550. m4.*
  17551. FROM
  17552. med_behospital_info m1,
  17553. med_home_page m2,
  17554. med_qcresult_info m3,
  17555. med_qcresult_cases m4
  17556. WHERE
  17557. m1.is_deleted = 'N'
  17558. AND m2.is_deleted = 'N'
  17559. AND m3.is_deleted = 'Y'
  17560. AND m4.is_deleted = 'Y'
  17561. AND m1.hospital_id = m2.hospital_id
  17562. AND m1.hospital_id = m3.hospital_id
  17563. AND m1.hospital_id = m4.hospital_id
  17564. AND m1.behospital_code = m2.behospital_code
  17565. AND m1.behospital_code = m3.behospital_code
  17566. AND m1.behospital_code = m4.behospital_code
  17567. AND m3.gmt_create = m4.gmt_create
  17568. AND m3.have_home_page = 1
  17569. AND m4.cases_id = 243
  17570. AND m1.qc_type_id != 0
  17571. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17572. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17573. </if>
  17574. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17575. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  17576. </if>
  17577. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17578. <if test="qcResultShortPageVO.startDate != null ">
  17579. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17580. </if>
  17581. <if test="qcResultShortPageVO.endDate != null ">
  17582. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17583. </if>
  17584. </if>
  17585. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17586. <if test="qcResultShortPageVO.startDate != null">
  17587. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17588. </if>
  17589. <if test="qcResultShortPageVO.endDate != null ">
  17590. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17591. </if>
  17592. </if>
  17593. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17594. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  17595. </if>
  17596. GROUP BY
  17597. m1.behospital_code
  17598. ORDER BY
  17599. m1.behospital_code,
  17600. m4.gmt_create
  17601. ) e
  17602. WHERE
  17603. a.is_deleted = 'N'
  17604. AND b.is_deleted = 'N'
  17605. AND c.is_deleted = 'N'
  17606. AND d.is_deleted = 'N'
  17607. AND a.hospital_id = b.hospital_id
  17608. AND a.hospital_id = c.hospital_id
  17609. AND a.hospital_id = d.hospital_id
  17610. AND a.hospital_id = e.hospital_id
  17611. AND a.behospital_code = b.behospital_code
  17612. AND a.behospital_code = c.behospital_code
  17613. AND a.behospital_code = d.behospital_code
  17614. AND a.behospital_code = e.behospital_code
  17615. AND d.cases_id = 243
  17616. AND d.score_res > e.score_res
  17617. AND a.qc_type_id != 0
  17618. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17619. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17620. </if>
  17621. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17622. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17623. </if>
  17624. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17625. <if test="qcResultShortPageVO.startDate != null ">
  17626. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17627. </if>
  17628. <if test="qcResultShortPageVO.endDate != null ">
  17629. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17630. </if>
  17631. </if>
  17632. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17633. <if test="qcResultShortPageVO.startDate != null ">
  17634. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17635. </if>
  17636. <if test="qcResultShortPageVO.endDate != null">
  17637. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17638. </if>
  17639. </if>
  17640. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17641. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17642. </if>
  17643. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17644. AND c.`level` = #{qcResultShortPageVO.level}
  17645. </if>
  17646. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17647. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17648. </if>
  17649. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17650. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17651. </if>
  17652. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17653. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17654. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17655. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17656. </if>
  17657. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17658. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17659. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17660. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17661. </if>
  17662. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  17663. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  17664. </if>
  17665. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  17666. AND d.score_res = 20
  17667. </if>
  17668. ) be
  17669. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17670. AND mci.check_type in(0,2)
  17671. AND be.hospital_id = mci.hospital_id
  17672. AND be.behospital_code = mci.behospital_code
  17673. ) t1
  17674. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17675. AND t1.behospital_code = t2.behospital_code
  17676. AND t2.is_deleted = 'N'
  17677. ) t
  17678. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17679. AND t.hospitalId = qi.hospital_id
  17680. AND t.behospitalCode = qi.behospital_code
  17681. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17682. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17683. AND t.hospitalId = qd.hospital_id
  17684. AND t.behospitalCode = qd.behospital_code
  17685. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17686. AND qd.cases_id = qc.id
  17687. </if>
  17688. where 1=1
  17689. <if test="qcResultShortPageVO.checkStatus != null">
  17690. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17691. </if>
  17692. <if test="qcResultShortPageVO.mrStatus != null">
  17693. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17694. </if>
  17695. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17696. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17697. </if>
  17698. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17699. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17700. </if>
  17701. <if test="qcResultShortPageVO.chTimeStart != null ">
  17702. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17703. </if>
  17704. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17705. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17706. </if>
  17707. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17708. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17709. </if>
  17710. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17711. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17712. </if>
  17713. )f1,
  17714. (SELECT
  17715. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17716. t.behDeptId,
  17717. t.behDeptName
  17718. FROM
  17719. (
  17720. SELECT DISTINCT
  17721. t1.hospital_id AS hospitalId,
  17722. t1.behospital_code AS behospitalCode,
  17723. t1.bed_code AS bedCode,
  17724. t1.LEVEL AS LEVEL,
  17725. t1.grade_type AS gradeType,
  17726. t1.score_res AS scoreRes,
  17727. t1.NAME AS NAME,
  17728. t1.sex AS sex,
  17729. t1.beh_dept_id AS behDeptId,
  17730. t1.beh_dept_name AS behDeptName,
  17731. t1.doctor_id AS doctorId,
  17732. t1.doctor_name AS doctorName,
  17733. t1.beh_doctor_id AS behDoctorId,
  17734. t1.beh_doctor_name AS behDoctorName,
  17735. t1.director_doctor_id AS directorDoctorId,
  17736. t1.director_doctor_name AS directorDoctorName,
  17737. t1.birthday AS birthday,
  17738. t1.behospital_date AS behospitalDate,
  17739. t1.leave_hospital_date AS leaveHospitalDate,
  17740. t1.placefile_date AS placefileDate,
  17741. t1.gmt_create AS gradeTime,
  17742. t1.diagnose,
  17743. t1.ward_name AS wardName,
  17744. t2.age,
  17745. t1.file_code AS fileCode,
  17746. t1.checkStatus,
  17747. t1.chName,
  17748. t1.chTime
  17749. FROM
  17750. (
  17751. SELECT
  17752. be.*,
  17753. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17754. mci.check_name AS chName,
  17755. mci.gmt_create AS chTime
  17756. FROM
  17757. (
  17758. SELECT DISTINCT
  17759. a.hospital_id,
  17760. a.behospital_code,
  17761. a.bed_code,
  17762. a.file_code,
  17763. c.LEVEL,
  17764. c.grade_type,
  17765. c.score_res,
  17766. a.NAME,
  17767. a.sex,
  17768. a.beh_dept_id,
  17769. a.beh_dept_name,
  17770. a.birthday,
  17771. a.behospital_date,
  17772. a.leave_hospital_date,
  17773. a.doctor_id,
  17774. a.doctor_name,
  17775. a.beh_doctor_id,
  17776. a.beh_doctor_name,
  17777. a.director_doctor_id,
  17778. a.director_doctor_name,
  17779. a.diagnose,
  17780. a.placefile_date,
  17781. a.ward_name,
  17782. c.gmt_create
  17783. FROM
  17784. med_behospital_info a,
  17785. med_home_page b,
  17786. med_qcresult_info c,
  17787. med_qcresult_cases d,
  17788. (
  17789. SELECT
  17790. m4.*
  17791. FROM
  17792. med_behospital_info m1,
  17793. med_home_page m2,
  17794. med_qcresult_info m3,
  17795. med_qcresult_cases m4
  17796. WHERE
  17797. m1.is_deleted = 'N'
  17798. AND m2.is_deleted = 'N'
  17799. AND m3.is_deleted = 'Y'
  17800. AND m4.is_deleted = 'Y'
  17801. AND m1.hospital_id = m2.hospital_id
  17802. AND m1.hospital_id = m3.hospital_id
  17803. AND m1.hospital_id = m4.hospital_id
  17804. AND m1.behospital_code = m2.behospital_code
  17805. AND m1.behospital_code = m3.behospital_code
  17806. AND m1.behospital_code = m4.behospital_code
  17807. AND m3.gmt_create = m4.gmt_create
  17808. AND m3.have_home_page = 1
  17809. AND m4.cases_id = 243
  17810. AND m1.qc_type_id != 0
  17811. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17812. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17813. </if>
  17814. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17815. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  17816. </if>
  17817. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17818. <if test="qcResultShortPageVO.startDate != null ">
  17819. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17820. </if>
  17821. <if test="qcResultShortPageVO.endDate != null ">
  17822. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17823. </if>
  17824. </if>
  17825. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17826. <if test="qcResultShortPageVO.startDate != null">
  17827. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17828. </if>
  17829. <if test="qcResultShortPageVO.endDate != null ">
  17830. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17831. </if>
  17832. </if>
  17833. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17834. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  17835. </if>
  17836. GROUP BY
  17837. m1.behospital_code
  17838. ORDER BY
  17839. m1.behospital_code,
  17840. m4.gmt_create
  17841. ) e
  17842. WHERE
  17843. a.is_deleted = 'N'
  17844. AND b.is_deleted = 'N'
  17845. AND c.is_deleted = 'N'
  17846. AND d.is_deleted = 'N'
  17847. AND a.hospital_id = b.hospital_id
  17848. AND a.hospital_id = c.hospital_id
  17849. AND a.hospital_id = d.hospital_id
  17850. AND a.hospital_id = e.hospital_id
  17851. AND a.behospital_code = b.behospital_code
  17852. AND a.behospital_code = c.behospital_code
  17853. AND a.behospital_code = d.behospital_code
  17854. AND a.behospital_code = e.behospital_code
  17855. AND d.cases_id = 243
  17856. AND d.score_res > e.score_res
  17857. AND a.qc_type_id != 0
  17858. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17859. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17860. </if>
  17861. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17862. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17863. </if>
  17864. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17865. <if test="qcResultShortPageVO.startDate != null ">
  17866. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17867. </if>
  17868. <if test="qcResultShortPageVO.endDate != null ">
  17869. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17870. </if>
  17871. </if>
  17872. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17873. <if test="qcResultShortPageVO.startDate != null ">
  17874. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17875. </if>
  17876. <if test="qcResultShortPageVO.endDate != null">
  17877. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17878. </if>
  17879. </if>
  17880. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17881. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17882. </if>
  17883. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17884. AND c.`level` = #{qcResultShortPageVO.level}
  17885. </if>
  17886. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17887. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17888. </if>
  17889. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17890. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17891. </if>
  17892. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17893. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17894. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17895. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17896. </if>
  17897. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17898. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17899. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17900. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17901. </if>
  17902. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  17903. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  17904. </if>
  17905. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  17906. AND d.score_res = 20
  17907. </if>
  17908. ) be
  17909. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17910. AND mci.check_type in(0,2)
  17911. AND be.hospital_id = mci.hospital_id
  17912. AND be.behospital_code = mci.behospital_code
  17913. ) t1
  17914. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17915. AND t1.behospital_code = t2.behospital_code
  17916. AND t2.is_deleted = 'N'
  17917. ) t
  17918. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17919. AND t.hospitalId = qi.hospital_id
  17920. AND t.behospitalCode = qi.behospital_code
  17921. where 1=1
  17922. <if test="qcResultShortPageVO.checkStatus != null">
  17923. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17924. </if>
  17925. <if test="qcResultShortPageVO.mrStatus != null">
  17926. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17927. </if>
  17928. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17929. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17930. </if>
  17931. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17932. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17933. </if>
  17934. <if test="qcResultShortPageVO.chTimeStart != null ">
  17935. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17936. </if>
  17937. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17938. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17939. </if>
  17940. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17941. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17942. </if>
  17943. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17944. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17945. </if>
  17946. GROUP BY
  17947. t.behDeptId,
  17948. t.behDeptName
  17949. )f2
  17950. WHERE
  17951. f1.behDeptId = f2.behDeptId
  17952. AND f1.behDeptName = f2.behDeptName
  17953. </select>
  17954. <!-- 病案首页改善率质控评分页导出-->
  17955. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  17956. SELECT
  17957. f1.behDeptId,
  17958. f1.behDeptName,
  17959. f1.doctorId,
  17960. f1.doctorName,
  17961. f1.patName,
  17962. f1.behospitalCode,
  17963. f1.hospitalId,
  17964. f1.scoreBn,
  17965. f1.behospitalDate,
  17966. f1.leaveHospitalDate,
  17967. f1.score,
  17968. f2.avgScore,
  17969. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17970. f1.msg,
  17971. f1.caseName,
  17972. </if>
  17973. f1.checkStatus,
  17974. f1.mrStatus,
  17975. f1.chName,
  17976. f1.mrName,
  17977. f1.chTime,
  17978. f1.mrTime
  17979. FROM
  17980. (SELECT
  17981. t.doctorId,
  17982. t.doctorName,
  17983. t.`name` AS patName,
  17984. t.behospitalCode AS behospitalCode,
  17985. t.behospitalDate AS behospitalDate,
  17986. t.leaveHospitalDate AS leaveHospitalDate,
  17987. qi.score_res AS score,
  17988. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17989. qd.msg AS msg,
  17990. qc.NAME AS caseName,
  17991. </if>
  17992. t.behDeptId,
  17993. t.behDeptName,
  17994. t.hospitalId,
  17995. t.checkStatus,
  17996. t.mrStatus,
  17997. t.chName,
  17998. t.mrName,
  17999. t.chTime,
  18000. t.mrTime
  18001. FROM
  18002. (
  18003. SELECT DISTINCT
  18004. t1.hospital_id AS hospitalId,
  18005. t1.behospital_code AS behospitalCode,
  18006. t1.bed_code AS bedCode,
  18007. t1.LEVEL AS LEVEL,
  18008. t1.grade_type AS gradeType,
  18009. t1.score_res AS scoreRes,
  18010. t1.NAME AS NAME,
  18011. t1.sex AS sex,
  18012. t1.beh_dept_id AS behDeptId,
  18013. t1.beh_dept_name AS behDeptName,
  18014. t1.doctor_id AS doctorId,
  18015. t1.doctor_name AS doctorName,
  18016. t1.beh_doctor_id AS behDoctorId,
  18017. t1.beh_doctor_name AS behDoctorName,
  18018. t1.director_doctor_id AS directorDoctorId,
  18019. t1.director_doctor_name AS directorDoctorName,
  18020. t1.birthday AS birthday,
  18021. t1.behospital_date AS behospitalDate,
  18022. t1.leave_hospital_date AS leaveHospitalDate,
  18023. t1.placefile_date AS placefileDate,
  18024. t1.gmt_create AS gradeTime,
  18025. t1.diagnose,
  18026. t1.ward_name AS wardName,
  18027. t1.scoreBn,
  18028. t1.file_code AS fileCode,
  18029. t1.checkStatus,
  18030. t1.mrStatus,
  18031. t1.chName,
  18032. t1.mrName,
  18033. t1.chTime,
  18034. t1.mrTime
  18035. FROM
  18036. (
  18037. SELECT
  18038. be.*,
  18039. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18040. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18041. mci.check_name AS chName,
  18042. e.score_res as scoreBn,
  18043. hm_mci.check_name AS mrName,
  18044. mci.gmt_create AS chTime,
  18045. hm_mci.gmt_create AS mrTime
  18046. FROM
  18047. (
  18048. SELECT DISTINCT
  18049. a.hospital_id,
  18050. a.behospital_code,
  18051. a.bed_code,
  18052. a.file_code,
  18053. c.LEVEL,
  18054. c.grade_type,
  18055. c.score_res,
  18056. a.NAME,
  18057. a.sex,
  18058. a.beh_dept_id,
  18059. a.beh_dept_name,
  18060. a.birthday,
  18061. a.behospital_date,
  18062. a.leave_hospital_date,
  18063. a.doctor_id,
  18064. a.doctor_name,
  18065. a.beh_doctor_id,
  18066. a.beh_doctor_name,
  18067. a.director_doctor_id,
  18068. a.director_doctor_name,
  18069. a.diagnose,
  18070. a.placefile_date,
  18071. a.ward_name,
  18072. c.gmt_create
  18073. FROM
  18074. med_behospital_info a,
  18075. med_home_page b,
  18076. med_qcresult_info c,
  18077. med_qcresult_cases d,
  18078. sys_user_dept f,
  18079. (
  18080. SELECT
  18081. m4.*
  18082. FROM
  18083. med_behospital_info m1,
  18084. med_home_page m2,
  18085. med_qcresult_info m3,
  18086. med_qcresult_cases m4
  18087. WHERE
  18088. m1.is_deleted = 'N'
  18089. AND m2.is_deleted = 'N'
  18090. AND m3.is_deleted = 'Y'
  18091. AND m4.is_deleted = 'Y'
  18092. AND m1.hospital_id = m2.hospital_id
  18093. AND m1.hospital_id = m3.hospital_id
  18094. AND m1.hospital_id = m4.hospital_id
  18095. AND m1.behospital_code = m2.behospital_code
  18096. AND m1.behospital_code = m3.behospital_code
  18097. AND m1.behospital_code = m4.behospital_code
  18098. AND m3.gmt_create = m4.gmt_create
  18099. AND m3.have_home_page = 1
  18100. AND m4.cases_id = 243
  18101. AND m1.qc_type_id != 0
  18102. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18103. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18104. </if>
  18105. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18106. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  18107. </if>
  18108. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18109. <if test="qcResultShortPageVO.startDate != null ">
  18110. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18111. </if>
  18112. <if test="qcResultShortPageVO.endDate != null ">
  18113. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18114. </if>
  18115. </if>
  18116. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18117. <if test="qcResultShortPageVO.startDate != null">
  18118. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18119. </if>
  18120. <if test="qcResultShortPageVO.endDate != null ">
  18121. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18122. </if>
  18123. </if>
  18124. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18125. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  18126. </if>
  18127. GROUP BY
  18128. m1.behospital_code
  18129. ORDER BY
  18130. m1.behospital_code,
  18131. m4.gmt_create
  18132. ) e
  18133. WHERE
  18134. a.is_deleted = 'N'
  18135. AND b.is_deleted = 'N'
  18136. AND c.is_deleted = 'N'
  18137. AND d.is_deleted = 'N'
  18138. AND f.is_deleted = 'N'
  18139. AND a.hospital_id = b.hospital_id
  18140. AND a.hospital_id = c.hospital_id
  18141. AND a.hospital_id = d.hospital_id
  18142. AND a.hospital_id = e.hospital_id
  18143. AND a.hospital_id = f.hospital_id
  18144. AND a.behospital_code = b.behospital_code
  18145. AND a.behospital_code = c.behospital_code
  18146. AND a.behospital_code = d.behospital_code
  18147. AND a.behospital_code = e.behospital_code
  18148. AND a.beh_dept_id = f.dept_id
  18149. AND d.cases_id = 243
  18150. AND d.score_res > e.score_res
  18151. AND a.qc_type_id != 0
  18152. <if test="qcResultShortPageVO.userId!=null">
  18153. AND f.user_id = #{qcResultShortPageVO.userId}
  18154. </if>
  18155. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18156. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18157. </if>
  18158. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18159. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18160. </if>
  18161. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18162. <if test="qcResultShortPageVO.startDate != null ">
  18163. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18164. </if>
  18165. <if test="qcResultShortPageVO.endDate != null ">
  18166. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18167. </if>
  18168. </if>
  18169. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18170. <if test="qcResultShortPageVO.startDate != null ">
  18171. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18172. </if>
  18173. <if test="qcResultShortPageVO.endDate != null">
  18174. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18175. </if>
  18176. </if>
  18177. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18178. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18179. </if>
  18180. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18181. AND c.`level` = #{qcResultShortPageVO.level}
  18182. </if>
  18183. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18184. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18185. </if>
  18186. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18187. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18188. </if>
  18189. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18190. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18191. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18192. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18193. </if>
  18194. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18195. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18196. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18197. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18198. </if>
  18199. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  18200. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  18201. </if>
  18202. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  18203. AND d.score_res = 20
  18204. </if>
  18205. ) be
  18206. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18207. AND mci.check_type = 0
  18208. AND be.hospital_id = mci.hospital_id
  18209. AND be.behospital_code = mci.behospital_code
  18210. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  18211. AND hm_mci.check_type = 1
  18212. AND be.hospital_id = hm_mci.hospital_id
  18213. AND be.behospital_code = hm_mci.behospital_code
  18214. LEFT JOIN med_qcresult_cases e
  18215. on be.behospital_code = e.behospital_code
  18216. and be.hospital_id = e.hospital_id
  18217. AND e.is_deleted = 'N'
  18218. and e.cases_id = 243
  18219. ) t1
  18220. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18221. AND t1.behospital_code = t2.behospital_code
  18222. AND t2.is_deleted = 'N'
  18223. ) t
  18224. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18225. AND t.hospitalId = qi.hospital_id
  18226. AND t.behospitalCode = qi.behospital_code
  18227. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18228. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  18229. AND t.hospitalId = qd.hospital_id
  18230. AND t.behospitalCode = qd.behospital_code
  18231. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  18232. AND qd.cases_id = qc.id
  18233. </if>
  18234. where 1=1
  18235. <if test="qcResultShortPageVO.checkStatus != null">
  18236. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18237. </if>
  18238. <if test="qcResultShortPageVO.mrStatus != null">
  18239. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18240. </if>
  18241. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18242. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18243. </if>
  18244. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18245. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18246. </if>
  18247. <if test="qcResultShortPageVO.chTimeStart != null ">
  18248. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18249. </if>
  18250. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18251. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18252. </if>
  18253. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18254. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18255. </if>
  18256. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18257. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18258. </if>
  18259. )f1,
  18260. (SELECT
  18261. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  18262. t.behDeptId,
  18263. t.behDeptName,
  18264. t.doctorId,
  18265. t.doctorName
  18266. FROM
  18267. (
  18268. SELECT DISTINCT
  18269. t1.hospital_id AS hospitalId,
  18270. t1.behospital_code AS behospitalCode,
  18271. t1.bed_code AS bedCode,
  18272. t1.LEVEL AS LEVEL,
  18273. t1.grade_type AS gradeType,
  18274. t1.score_res AS scoreRes,
  18275. t1.NAME AS NAME,
  18276. t1.sex AS sex,
  18277. t1.beh_dept_id AS behDeptId,
  18278. t1.beh_dept_name AS behDeptName,
  18279. t1.doctor_id AS doctorId,
  18280. t1.doctor_name AS doctorName,
  18281. t1.beh_doctor_id AS behDoctorId,
  18282. t1.beh_doctor_name AS behDoctorName,
  18283. t1.director_doctor_id AS directorDoctorId,
  18284. t1.director_doctor_name AS directorDoctorName,
  18285. t1.birthday AS birthday,
  18286. t1.behospital_date AS behospitalDate,
  18287. t1.leave_hospital_date AS leaveHospitalDate,
  18288. t1.placefile_date AS placefileDate,
  18289. t1.gmt_create AS gradeTime,
  18290. t1.diagnose,
  18291. t1.ward_name AS wardName,
  18292. t2.age,
  18293. t1.file_code AS fileCode,
  18294. t1.checkStatus,
  18295. t1.mrStatus,
  18296. t1.chName,
  18297. t1.mrName,
  18298. t1.chTime,
  18299. t1.mrTime
  18300. FROM
  18301. (
  18302. SELECT
  18303. be.*,
  18304. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18305. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18306. mci.check_name AS chName,
  18307. hm_mci.check_name AS mrName,
  18308. mci.gmt_create AS chTime,
  18309. hm_mci.gmt_create AS mrTime
  18310. FROM
  18311. (
  18312. SELECT DISTINCT
  18313. a.hospital_id,
  18314. a.behospital_code,
  18315. a.bed_code,
  18316. a.file_code,
  18317. c.LEVEL,
  18318. c.grade_type,
  18319. c.score_res,
  18320. a.NAME,
  18321. a.sex,
  18322. a.beh_dept_id,
  18323. a.beh_dept_name,
  18324. a.birthday,
  18325. a.behospital_date,
  18326. a.leave_hospital_date,
  18327. a.doctor_id,
  18328. a.doctor_name,
  18329. a.beh_doctor_id,
  18330. a.beh_doctor_name,
  18331. a.director_doctor_id,
  18332. a.director_doctor_name,
  18333. a.diagnose,
  18334. a.placefile_date,
  18335. a.ward_name,
  18336. c.gmt_create
  18337. FROM
  18338. med_behospital_info a,
  18339. med_home_page b,
  18340. med_qcresult_info c,
  18341. med_qcresult_cases d,
  18342. sys_user_dept f,
  18343. (
  18344. SELECT
  18345. m4.*
  18346. FROM
  18347. med_behospital_info m1,
  18348. med_home_page m2,
  18349. med_qcresult_info m3,
  18350. med_qcresult_cases m4
  18351. WHERE
  18352. m1.is_deleted = 'N'
  18353. AND m2.is_deleted = 'N'
  18354. AND m3.is_deleted = 'Y'
  18355. AND m4.is_deleted = 'Y'
  18356. AND m1.hospital_id = m2.hospital_id
  18357. AND m1.hospital_id = m3.hospital_id
  18358. AND m1.hospital_id = m4.hospital_id
  18359. AND m1.behospital_code = m2.behospital_code
  18360. AND m1.behospital_code = m3.behospital_code
  18361. AND m1.behospital_code = m4.behospital_code
  18362. AND m3.gmt_create = m4.gmt_create
  18363. AND m3.have_home_page = 1
  18364. AND m4.cases_id = 243
  18365. AND m1.qc_type_id != 0
  18366. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18367. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18368. </if>
  18369. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18370. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  18371. </if>
  18372. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18373. <if test="qcResultShortPageVO.startDate != null ">
  18374. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18375. </if>
  18376. <if test="qcResultShortPageVO.endDate != null ">
  18377. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18378. </if>
  18379. </if>
  18380. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18381. <if test="qcResultShortPageVO.startDate != null">
  18382. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18383. </if>
  18384. <if test="qcResultShortPageVO.endDate != null ">
  18385. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18386. </if>
  18387. </if>
  18388. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18389. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  18390. </if>
  18391. GROUP BY
  18392. m1.behospital_code
  18393. ORDER BY
  18394. m1.behospital_code,
  18395. m4.gmt_create
  18396. ) e
  18397. WHERE
  18398. a.is_deleted = 'N'
  18399. AND b.is_deleted = 'N'
  18400. AND c.is_deleted = 'N'
  18401. AND d.is_deleted = 'N'
  18402. AND f.is_deleted = 'N'
  18403. AND a.hospital_id = b.hospital_id
  18404. AND a.hospital_id = c.hospital_id
  18405. AND a.hospital_id = d.hospital_id
  18406. AND a.hospital_id = e.hospital_id
  18407. AND a.hospital_id = f.hospital_id
  18408. AND a.behospital_code = b.behospital_code
  18409. AND a.behospital_code = c.behospital_code
  18410. AND a.behospital_code = d.behospital_code
  18411. AND a.behospital_code = e.behospital_code
  18412. AND a.beh_dept_id = f.dept_id
  18413. AND d.cases_id = 243
  18414. AND d.score_res > e.score_res
  18415. AND a.qc_type_id != 0
  18416. <if test="qcResultShortPageVO.userId!=null">
  18417. AND f.user_id = #{qcResultShortPageVO.userId}
  18418. </if>
  18419. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18420. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18421. </if>
  18422. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18423. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18424. </if>
  18425. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18426. <if test="qcResultShortPageVO.startDate != null ">
  18427. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18428. </if>
  18429. <if test="qcResultShortPageVO.endDate != null ">
  18430. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18431. </if>
  18432. </if>
  18433. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18434. <if test="qcResultShortPageVO.startDate != null ">
  18435. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18436. </if>
  18437. <if test="qcResultShortPageVO.endDate != null">
  18438. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18439. </if>
  18440. </if>
  18441. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18442. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18443. </if>
  18444. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18445. AND c.`level` = #{qcResultShortPageVO.level}
  18446. </if>
  18447. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18448. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18449. </if>
  18450. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18451. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18452. </if>
  18453. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18454. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18455. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18456. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18457. </if>
  18458. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18459. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18460. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18461. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18462. </if>
  18463. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  18464. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  18465. </if>
  18466. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  18467. AND d.score_res = 20
  18468. </if>
  18469. ) be
  18470. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18471. AND mci.check_type = 0
  18472. AND be.hospital_id = mci.hospital_id
  18473. AND be.behospital_code = mci.behospital_code
  18474. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  18475. AND hm_mci.check_type = 1
  18476. AND be.hospital_id = hm_mci.hospital_id
  18477. AND be.behospital_code = hm_mci.behospital_code
  18478. ) t1
  18479. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18480. AND t1.behospital_code = t2.behospital_code
  18481. AND t2.is_deleted = 'N'
  18482. ) t
  18483. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18484. AND t.hospitalId = qi.hospital_id
  18485. AND t.behospitalCode = qi.behospital_code
  18486. where 1=1
  18487. <if test="qcResultShortPageVO.checkStatus != null">
  18488. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18489. </if>
  18490. <if test="qcResultShortPageVO.mrStatus != null">
  18491. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18492. </if>
  18493. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18494. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18495. </if>
  18496. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18497. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18498. </if>
  18499. <if test="qcResultShortPageVO.chTimeStart != null ">
  18500. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18501. </if>
  18502. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18503. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18504. </if>
  18505. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18506. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18507. </if>
  18508. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18509. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18510. </if>
  18511. GROUP BY
  18512. t.doctorId,
  18513. t.doctorName
  18514. )f2
  18515. WHERE
  18516. f1.doctorId = f2.doctorId
  18517. AND f1.doctorName = f2.doctorName
  18518. </select>
  18519. <!-- 质控核查质控评分页导出-->
  18520. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  18521. SELECT
  18522. f1.behDeptId,
  18523. f1.behDeptName,
  18524. f1.doctorName,
  18525. f1.patName,
  18526. f1.behospitalCode,
  18527. f1.hospitalId,
  18528. f1.behospitalDate,
  18529. f1.leaveHospitalDate,
  18530. f1.score,
  18531. f1.scoreBn,
  18532. f2.avgScore,
  18533. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18534. f1.msg,
  18535. f1.caseName,
  18536. </if>
  18537. f1.checkStatus,
  18538. f1.chName,
  18539. f1.chTime
  18540. FROM
  18541. (SELECT
  18542. t.doctorName,
  18543. t.`name` AS patName,
  18544. t.behospitalCode AS behospitalCode,
  18545. t.behospitalDate AS behospitalDate,
  18546. t.leaveHospitalDate AS leaveHospitalDate,
  18547. qi.score_res AS score,
  18548. t.scoreBn,
  18549. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18550. qd.msg AS msg,
  18551. qc.NAME AS caseName,
  18552. </if>
  18553. t.behDeptId,
  18554. t.behDeptName,
  18555. t.hospitalId,
  18556. t.checkStatus,
  18557. t.chName,
  18558. t.chTime
  18559. FROM
  18560. (
  18561. SELECT DISTINCT
  18562. t1.hospital_id AS hospitalId,
  18563. t1.behospital_code AS behospitalCode,
  18564. t1.bed_code AS bedCode,
  18565. t1.LEVEL AS LEVEL,
  18566. t1.grade_type AS gradeType,
  18567. t1.score_res AS scoreRes,
  18568. t1.scoreBn,
  18569. t1.NAME AS NAME,
  18570. t1.sex AS sex,
  18571. t1.beh_dept_id AS behDeptId,
  18572. t1.beh_dept_name AS behDeptName,
  18573. t1.doctor_id AS doctorId,
  18574. t1.doctor_name AS doctorName,
  18575. t1.beh_doctor_id AS behDoctorId,
  18576. t1.beh_doctor_name AS behDoctorName,
  18577. t1.director_doctor_id AS directorDoctorId,
  18578. t1.director_doctor_name AS directorDoctorName,
  18579. t1.birthday AS birthday,
  18580. t1.behospital_date AS behospitalDate,
  18581. t1.leave_hospital_date AS leaveHospitalDate,
  18582. t1.placefile_date AS placefileDate,
  18583. t1.gmt_create AS gradeTime,
  18584. t1.diagnose,
  18585. t1.ward_name AS wardName,
  18586. t2.age,
  18587. t1.file_code AS fileCode,
  18588. t1.checkStatus,
  18589. t1.chName,
  18590. t1.chTime
  18591. FROM
  18592. (
  18593. SELECT
  18594. be.*,
  18595. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18596. mci.check_name AS chName,
  18597. e.score_res as scoreBn,
  18598. mci.gmt_create AS chTime
  18599. FROM
  18600. (
  18601. SELECT DISTINCT
  18602. a.hospital_id,
  18603. a.behospital_code,
  18604. a.bed_code,
  18605. a.file_code,
  18606. b.LEVEL,
  18607. b.grade_type,
  18608. b.score_res,
  18609. a.NAME,
  18610. a.sex,
  18611. a.beh_dept_id,
  18612. a.beh_dept_name,
  18613. a.birthday,
  18614. a.behospital_date,
  18615. a.leave_hospital_date,
  18616. a.doctor_id,
  18617. a.doctor_name,
  18618. a.beh_doctor_id,
  18619. a.beh_doctor_name,
  18620. a.director_doctor_id,
  18621. a.director_doctor_name,
  18622. a.diagnose,
  18623. a.placefile_date,
  18624. a.ward_name,
  18625. b.gmt_create
  18626. FROM
  18627. med_behospital_info a,
  18628. med_qcresult_info b
  18629. WHERE
  18630. a.is_deleted = 'N'
  18631. AND b.is_deleted = 'N'
  18632. AND a.hospital_id = b.hospital_id
  18633. AND a.behospital_code = b.behospital_code
  18634. AND a.qc_type_id != 0
  18635. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18636. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18637. </if>
  18638. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18639. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18640. </if>
  18641. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18642. <if test="qcResultShortPageVO.startDate != null ">
  18643. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18644. </if>
  18645. <if test="qcResultShortPageVO.endDate != null ">
  18646. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18647. </if>
  18648. </if>
  18649. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18650. <if test="qcResultShortPageVO.startDate != null ">
  18651. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18652. </if>
  18653. <if test="qcResultShortPageVO.endDate != null">
  18654. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18655. </if>
  18656. </if>
  18657. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  18658. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  18659. </if>
  18660. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18661. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18662. </if>
  18663. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18664. AND c.`level` = #{qcResultShortPageVO.level}
  18665. </if>
  18666. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18667. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18668. </if>
  18669. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18670. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18671. </if>
  18672. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18673. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18674. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18675. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18676. </if>
  18677. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18678. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18679. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18680. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18681. </if>
  18682. ) be
  18683. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18684. AND mci.check_type in(0,2)
  18685. AND be.hospital_id = mci.hospital_id
  18686. AND be.behospital_code = mci.behospital_code
  18687. LEFT JOIN med_qcresult_cases e
  18688. on be.behospital_code = e.behospital_code
  18689. and be.hospital_id = e.hospital_id
  18690. AND e.is_deleted = 'N'
  18691. and e.cases_id = 243
  18692. ) t1
  18693. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18694. AND t1.behospital_code = t2.behospital_code
  18695. AND t2.is_deleted = 'N'
  18696. ) t
  18697. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18698. AND t.hospitalId = qi.hospital_id
  18699. AND t.behospitalCode = qi.behospital_code
  18700. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18701. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  18702. AND t.hospitalId = qd.hospital_id
  18703. AND t.behospitalCode = qd.behospital_code
  18704. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  18705. AND qd.cases_id = qc.id
  18706. </if>
  18707. where 1=1
  18708. <if test="qcResultShortPageVO.checkStatus != null">
  18709. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18710. </if>
  18711. <if test="qcResultShortPageVO.mrStatus != null">
  18712. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18713. </if>
  18714. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18715. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18716. </if>
  18717. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18718. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18719. </if>
  18720. <if test="qcResultShortPageVO.chTimeStart != null ">
  18721. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18722. </if>
  18723. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18724. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18725. </if>
  18726. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18727. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18728. </if>
  18729. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18730. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18731. </if>
  18732. )f1,
  18733. (SELECT
  18734. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  18735. t.behDeptId,
  18736. t.behDeptName
  18737. FROM
  18738. (
  18739. SELECT DISTINCT
  18740. t1.hospital_id AS hospitalId,
  18741. t1.behospital_code AS behospitalCode,
  18742. t1.bed_code AS bedCode,
  18743. t1.LEVEL AS LEVEL,
  18744. t1.grade_type AS gradeType,
  18745. t1.score_res AS scoreRes,
  18746. t1.NAME AS NAME,
  18747. t1.sex AS sex,
  18748. t1.beh_dept_id AS behDeptId,
  18749. t1.beh_dept_name AS behDeptName,
  18750. t1.doctor_id AS doctorId,
  18751. t1.doctor_name AS doctorName,
  18752. t1.beh_doctor_id AS behDoctorId,
  18753. t1.beh_doctor_name AS behDoctorName,
  18754. t1.director_doctor_id AS directorDoctorId,
  18755. t1.director_doctor_name AS directorDoctorName,
  18756. t1.birthday AS birthday,
  18757. t1.behospital_date AS behospitalDate,
  18758. t1.leave_hospital_date AS leaveHospitalDate,
  18759. t1.placefile_date AS placefileDate,
  18760. t1.gmt_create AS gradeTime,
  18761. t1.diagnose,
  18762. t1.ward_name AS wardName,
  18763. t2.age,
  18764. t1.file_code AS fileCode,
  18765. t1.checkStatus,
  18766. t1.chName,
  18767. t1.chTime
  18768. FROM
  18769. (
  18770. SELECT
  18771. be.*,
  18772. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18773. mci.check_name AS chName,
  18774. mci.gmt_create AS chTime
  18775. FROM
  18776. (
  18777. SELECT DISTINCT
  18778. a.hospital_id,
  18779. a.behospital_code,
  18780. a.bed_code,
  18781. a.file_code,
  18782. b.LEVEL,
  18783. b.grade_type,
  18784. b.score_res,
  18785. a.NAME,
  18786. a.sex,
  18787. a.beh_dept_id,
  18788. a.beh_dept_name,
  18789. a.birthday,
  18790. a.behospital_date,
  18791. a.leave_hospital_date,
  18792. a.doctor_id,
  18793. a.doctor_name,
  18794. a.beh_doctor_id,
  18795. a.beh_doctor_name,
  18796. a.director_doctor_id,
  18797. a.director_doctor_name,
  18798. a.diagnose,
  18799. a.placefile_date,
  18800. a.ward_name,
  18801. b.gmt_create
  18802. FROM
  18803. med_behospital_info a,
  18804. med_qcresult_info b
  18805. WHERE
  18806. a.is_deleted = 'N'
  18807. AND b.is_deleted = 'N'
  18808. AND a.hospital_id = b.hospital_id
  18809. AND a.behospital_code = b.behospital_code
  18810. AND a.qc_type_id != 0
  18811. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18812. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18813. </if>
  18814. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18815. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18816. </if>
  18817. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18818. <if test="qcResultShortPageVO.startDate != null ">
  18819. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18820. </if>
  18821. <if test="qcResultShortPageVO.endDate != null ">
  18822. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18823. </if>
  18824. </if>
  18825. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18826. <if test="qcResultShortPageVO.startDate != null ">
  18827. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18828. </if>
  18829. <if test="qcResultShortPageVO.endDate != null">
  18830. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18831. </if>
  18832. </if>
  18833. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  18834. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  18835. </if>
  18836. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18837. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18838. </if>
  18839. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18840. AND c.`level` = #{qcResultShortPageVO.level}
  18841. </if>
  18842. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18843. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18844. </if>
  18845. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18846. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18847. </if>
  18848. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18849. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18850. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  18851. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  18852. </if>
  18853. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18854. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18855. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  18856. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  18857. </if>
  18858. ) be
  18859. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18860. AND mci.check_type in(0,2)
  18861. AND be.hospital_id = mci.hospital_id
  18862. AND be.behospital_code = mci.behospital_code
  18863. ) t1
  18864. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18865. AND t1.behospital_code = t2.behospital_code
  18866. AND t2.is_deleted = 'N'
  18867. ) t
  18868. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18869. AND t.hospitalId = qi.hospital_id
  18870. AND t.behospitalCode = qi.behospital_code
  18871. where 1=1
  18872. <if test="qcResultShortPageVO.checkStatus != null">
  18873. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18874. </if>
  18875. <if test="qcResultShortPageVO.mrStatus != null">
  18876. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18877. </if>
  18878. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18879. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18880. </if>
  18881. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18882. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18883. </if>
  18884. <if test="qcResultShortPageVO.chTimeStart != null ">
  18885. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18886. </if>
  18887. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18888. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18889. </if>
  18890. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18891. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18892. </if>
  18893. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18894. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18895. </if>
  18896. GROUP BY
  18897. t.behDeptId,
  18898. t.behDeptName
  18899. )f2
  18900. WHERE
  18901. f1.behDeptId = f2.behDeptId
  18902. AND f1.behDeptName = f2.behDeptName
  18903. </select>
  18904. <!-- 质控核查质控评分页导出 -科室-->
  18905. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  18906. SELECT
  18907. f1.behDeptId,
  18908. f1.behDeptName,
  18909. f1.doctorName,
  18910. f1.doctorId,
  18911. f1.patName,
  18912. f1.behospitalCode,
  18913. f1.hospitalId,
  18914. f1.behospitalDate,
  18915. f1.leaveHospitalDate,
  18916. f1.score,
  18917. f1.scoreBn,
  18918. f2.avgScore,
  18919. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18920. f1.msg,
  18921. f1.caseName,
  18922. </if>
  18923. f1.checkStatus,
  18924. f1.mrStatus,
  18925. f1.chName,
  18926. f1.mrName,
  18927. f1.chTime,
  18928. f1.mrTime
  18929. FROM
  18930. (SELECT
  18931. t.doctorName,
  18932. t.doctorId,
  18933. t.`name` AS patName,
  18934. t.behospitalCode AS behospitalCode,
  18935. t.behospitalDate AS behospitalDate,
  18936. t.leaveHospitalDate AS leaveHospitalDate,
  18937. qi.score_res AS score,
  18938. t.scoreBn,
  18939. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  18940. qd.msg AS msg,
  18941. qc.NAME AS caseName,
  18942. </if>
  18943. t.behDeptId,
  18944. t.behDeptName,
  18945. t.hospitalId,
  18946. t.checkStatus,
  18947. t.mrStatus,
  18948. t.chName,
  18949. t.mrName,
  18950. t.chTime,
  18951. t.mrTime
  18952. FROM
  18953. (
  18954. SELECT DISTINCT
  18955. t1.hospital_id AS hospitalId,
  18956. t1.behospital_code AS behospitalCode,
  18957. t1.bed_code AS bedCode,
  18958. t1.LEVEL AS LEVEL,
  18959. t1.grade_type AS gradeType,
  18960. t1.score_res AS scoreRes,
  18961. t1.scoreBn,
  18962. t1.NAME AS NAME,
  18963. t1.sex AS sex,
  18964. t1.beh_dept_id AS behDeptId,
  18965. t1.beh_dept_name AS behDeptName,
  18966. t1.doctor_id AS doctorId,
  18967. t1.doctor_name AS doctorName,
  18968. t1.beh_doctor_id AS behDoctorId,
  18969. t1.beh_doctor_name AS behDoctorName,
  18970. t1.director_doctor_id AS directorDoctorId,
  18971. t1.director_doctor_name AS directorDoctorName,
  18972. t1.birthday AS birthday,
  18973. t1.behospital_date AS behospitalDate,
  18974. t1.leave_hospital_date AS leaveHospitalDate,
  18975. t1.placefile_date AS placefileDate,
  18976. t1.gmt_create AS gradeTime,
  18977. t1.diagnose,
  18978. t1.ward_name AS wardName,
  18979. t2.age,
  18980. t1.file_code AS fileCode,
  18981. t1.checkStatus,
  18982. t1.mrStatus,
  18983. t1.chName,
  18984. t1.mrName,
  18985. t1.chTime,
  18986. t1.mrTime
  18987. FROM
  18988. (
  18989. SELECT
  18990. be.*,
  18991. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18992. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18993. mci.check_name AS chName,
  18994. e.score_res as scoreBn,
  18995. hm_mci.check_name AS mrName,
  18996. mci.gmt_create AS chTime,
  18997. hm_mci.gmt_create AS mrTime
  18998. FROM
  18999. (
  19000. SELECT DISTINCT
  19001. a.hospital_id,
  19002. a.behospital_code,
  19003. a.bed_code,
  19004. a.file_code,
  19005. b.LEVEL,
  19006. b.grade_type,
  19007. b.score_res,
  19008. a.NAME,
  19009. a.sex,
  19010. a.beh_dept_id,
  19011. a.beh_dept_name,
  19012. a.birthday,
  19013. a.behospital_date,
  19014. a.leave_hospital_date,
  19015. a.doctor_id,
  19016. a.doctor_name,
  19017. a.beh_doctor_id,
  19018. a.beh_doctor_name,
  19019. a.director_doctor_id,
  19020. a.director_doctor_name,
  19021. a.diagnose,
  19022. a.placefile_date,
  19023. a.ward_name,
  19024. b.gmt_create
  19025. FROM
  19026. med_behospital_info a,
  19027. med_qcresult_info b,
  19028. sys_user_dept c
  19029. WHERE
  19030. a.is_deleted = 'N'
  19031. AND b.is_deleted = 'N'
  19032. AND c.is_deleted = 'N'
  19033. AND a.hospital_id = b.hospital_id
  19034. AND a.hospital_id = c.hospital_id
  19035. AND a.behospital_code = b.behospital_code
  19036. AND a.beh_dept_id = c.dept_id
  19037. AND a.qc_type_id != 0
  19038. <if test="qcResultShortPageVO.userId!=null">
  19039. AND c.user_id = #{qcResultShortPageVO.userId}
  19040. </if>
  19041. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  19042. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  19043. </if>
  19044. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  19045. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  19046. </if>
  19047. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  19048. <if test="qcResultShortPageVO.startDate != null ">
  19049. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  19050. </if>
  19051. <if test="qcResultShortPageVO.endDate != null ">
  19052. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  19053. </if>
  19054. </if>
  19055. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  19056. <if test="qcResultShortPageVO.startDate != null ">
  19057. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  19058. </if>
  19059. <if test="qcResultShortPageVO.endDate != null">
  19060. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  19061. </if>
  19062. </if>
  19063. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  19064. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  19065. </if>
  19066. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  19067. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  19068. </if>
  19069. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  19070. AND c.`level` = #{qcResultShortPageVO.level}
  19071. </if>
  19072. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  19073. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  19074. </if>
  19075. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  19076. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  19077. </if>
  19078. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  19079. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19080. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19081. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  19082. </if>
  19083. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  19084. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19085. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19086. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  19087. </if>
  19088. ) be
  19089. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  19090. AND mci.check_type = 0
  19091. AND be.hospital_id = mci.hospital_id
  19092. AND be.behospital_code = mci.behospital_code
  19093. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  19094. AND hm_mci.check_type = 1
  19095. AND be.hospital_id = hm_mci.hospital_id
  19096. AND be.behospital_code = hm_mci.behospital_code
  19097. LEFT JOIN med_qcresult_cases e
  19098. on be.behospital_code = e.behospital_code
  19099. and be.hospital_id = e.hospital_id
  19100. AND e.is_deleted = 'N'
  19101. and e.cases_id = 243
  19102. ) t1
  19103. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  19104. AND t1.behospital_code = t2.behospital_code
  19105. AND t2.is_deleted = 'N'
  19106. ) t
  19107. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  19108. AND t.hospitalId = qi.hospital_id
  19109. AND t.behospitalCode = qi.behospital_code
  19110. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  19111. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  19112. AND t.hospitalId = qd.hospital_id
  19113. AND t.behospitalCode = qd.behospital_code
  19114. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  19115. AND qd.cases_id = qc.id
  19116. </if>
  19117. where 1=1
  19118. <if test="qcResultShortPageVO.checkStatus != null">
  19119. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  19120. </if>
  19121. <if test="qcResultShortPageVO.mrStatus != null">
  19122. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  19123. </if>
  19124. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  19125. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  19126. </if>
  19127. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  19128. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  19129. </if>
  19130. <if test="qcResultShortPageVO.chTimeStart != null ">
  19131. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  19132. </if>
  19133. <if test="qcResultShortPageVO.chTimeEnd != null ">
  19134. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  19135. </if>
  19136. <if test="qcResultShortPageVO.mrTimeStart != null ">
  19137. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  19138. </if>
  19139. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  19140. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  19141. </if>
  19142. )f1,
  19143. (SELECT
  19144. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  19145. t.behDeptId,
  19146. t.behDeptName,
  19147. t.doctorId,
  19148. t.doctorName
  19149. FROM
  19150. (
  19151. SELECT DISTINCT
  19152. t1.hospital_id AS hospitalId,
  19153. t1.behospital_code AS behospitalCode,
  19154. t1.bed_code AS bedCode,
  19155. t1.LEVEL AS LEVEL,
  19156. t1.grade_type AS gradeType,
  19157. t1.score_res AS scoreRes,
  19158. t1.NAME AS NAME,
  19159. t1.sex AS sex,
  19160. t1.beh_dept_id AS behDeptId,
  19161. t1.beh_dept_name AS behDeptName,
  19162. t1.doctor_id AS doctorId,
  19163. t1.doctor_name AS doctorName,
  19164. t1.beh_doctor_id AS behDoctorId,
  19165. t1.beh_doctor_name AS behDoctorName,
  19166. t1.director_doctor_id AS directorDoctorId,
  19167. t1.director_doctor_name AS directorDoctorName,
  19168. t1.birthday AS birthday,
  19169. t1.behospital_date AS behospitalDate,
  19170. t1.leave_hospital_date AS leaveHospitalDate,
  19171. t1.placefile_date AS placefileDate,
  19172. t1.gmt_create AS gradeTime,
  19173. t1.diagnose,
  19174. t1.ward_name AS wardName,
  19175. t2.age,
  19176. t1.file_code AS fileCode,
  19177. t1.checkStatus,
  19178. t1.mrStatus,
  19179. t1.chName,
  19180. t1.mrName,
  19181. t1.chTime,
  19182. t1.mrTime
  19183. FROM
  19184. (
  19185. SELECT
  19186. be.*,
  19187. ifnull( mci.STATUS, 0 ) AS checkStatus,
  19188. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  19189. mci.check_name AS chName,
  19190. hm_mci.check_name AS mrName,
  19191. mci.gmt_create AS chTime,
  19192. hm_mci.gmt_create AS mrTime
  19193. FROM
  19194. (
  19195. SELECT DISTINCT
  19196. a.hospital_id,
  19197. a.behospital_code,
  19198. a.bed_code,
  19199. a.file_code,
  19200. b.LEVEL,
  19201. b.grade_type,
  19202. b.score_res,
  19203. a.NAME,
  19204. a.sex,
  19205. a.beh_dept_id,
  19206. a.beh_dept_name,
  19207. a.birthday,
  19208. a.behospital_date,
  19209. a.leave_hospital_date,
  19210. a.doctor_id,
  19211. a.doctor_name,
  19212. a.beh_doctor_id,
  19213. a.beh_doctor_name,
  19214. a.director_doctor_id,
  19215. a.director_doctor_name,
  19216. a.diagnose,
  19217. a.placefile_date,
  19218. a.ward_name,
  19219. b.gmt_create
  19220. FROM
  19221. med_behospital_info a,
  19222. med_qcresult_info b,
  19223. sys_user_dept c
  19224. WHERE
  19225. a.is_deleted = 'N'
  19226. AND b.is_deleted = 'N'
  19227. AND c.is_deleted = 'N'
  19228. AND a.hospital_id = b.hospital_id
  19229. AND a.hospital_id = c.hospital_id
  19230. AND a.behospital_code = b.behospital_code
  19231. AND a.beh_dept_id = c.dept_id
  19232. AND a.qc_type_id != 0
  19233. <if test="qcResultShortPageVO.userId!=null">
  19234. AND c.user_id = #{qcResultShortPageVO.userId}
  19235. </if>
  19236. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  19237. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  19238. </if>
  19239. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  19240. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  19241. </if>
  19242. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  19243. <if test="qcResultShortPageVO.startDate != null ">
  19244. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  19245. </if>
  19246. <if test="qcResultShortPageVO.endDate != null ">
  19247. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  19248. </if>
  19249. </if>
  19250. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  19251. <if test="qcResultShortPageVO.startDate != null ">
  19252. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  19253. </if>
  19254. <if test="qcResultShortPageVO.endDate != null">
  19255. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  19256. </if>
  19257. </if>
  19258. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  19259. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  19260. </if>
  19261. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  19262. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  19263. </if>
  19264. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  19265. AND c.`level` = #{qcResultShortPageVO.level}
  19266. </if>
  19267. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  19268. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  19269. </if>
  19270. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  19271. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  19272. </if>
  19273. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  19274. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19275. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  19276. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  19277. </if>
  19278. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  19279. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19280. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  19281. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  19282. </if>
  19283. ) be
  19284. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  19285. AND mci.check_type = 0
  19286. AND be.hospital_id = mci.hospital_id
  19287. AND be.behospital_code = mci.behospital_code
  19288. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  19289. AND hm_mci.check_type = 1
  19290. AND be.hospital_id = hm_mci.hospital_id
  19291. AND be.behospital_code = hm_mci.behospital_code
  19292. ) t1
  19293. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  19294. AND t1.behospital_code = t2.behospital_code
  19295. AND t2.is_deleted = 'N'
  19296. ) t
  19297. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  19298. AND t.hospitalId = qi.hospital_id
  19299. AND t.behospitalCode = qi.behospital_code
  19300. where 1=1
  19301. <if test="qcResultShortPageVO.checkStatus != null">
  19302. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  19303. </if>
  19304. <if test="qcResultShortPageVO.mrStatus != null">
  19305. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  19306. </if>
  19307. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  19308. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  19309. </if>
  19310. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  19311. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  19312. </if>
  19313. <if test="qcResultShortPageVO.chTimeStart != null ">
  19314. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  19315. </if>
  19316. <if test="qcResultShortPageVO.chTimeEnd != null ">
  19317. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  19318. </if>
  19319. <if test="qcResultShortPageVO.mrTimeStart != null ">
  19320. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  19321. </if>
  19322. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  19323. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  19324. </if>
  19325. GROUP BY
  19326. t.doctorId,
  19327. t.doctorName
  19328. )f2
  19329. WHERE
  19330. f1.doctorId = f2.doctorId
  19331. AND f1.doctorName = f2.doctorName
  19332. </select>
  19333. <!-- 入院,手术,出院病案情况-->
  19334. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19335. SELECT
  19336. count(
  19337. DISTINCT
  19338. CASE
  19339. WHEN q.type=5 THEN
  19340. a.behospital_code
  19341. ELSE
  19342. NULL
  19343. END
  19344. ) AS 'operationNote',
  19345. count(
  19346. DISTINCT
  19347. CASE
  19348. WHEN q.type = 4 THEN
  19349. a.behospital_code
  19350. ELSE
  19351. NULL
  19352. END
  19353. ) AS 'residentAdmitNote',
  19354. count(
  19355. DISTINCT
  19356. CASE
  19357. WHEN q.type = 6 THEN
  19358. a.behospital_code
  19359. ELSE
  19360. NULL
  19361. END
  19362. ) AS 'dischargeRecord',
  19363. count(
  19364. DISTINCT
  19365. CASE
  19366. WHEN q.type = 7 THEN
  19367. a.behospital_code
  19368. ELSE
  19369. NULL
  19370. END
  19371. ) AS 'medicalRecord'
  19372. FROM
  19373. (
  19374. SELECT
  19375. a.behospital_code,
  19376. a.cases_entry_id,
  19377. a.hospital_id
  19378. FROM
  19379. (
  19380. SELECT
  19381. a.behospital_code,
  19382. c.cases_entry_id,
  19383. a.hospital_id
  19384. FROM
  19385. (
  19386. SELECT
  19387. a.behospital_code,
  19388. a.hospital_id
  19389. FROM
  19390. med_behospital_info a,
  19391. med_qcresult_info c
  19392. WHERE
  19393. a.is_deleted = 'N'
  19394. AND c.is_deleted = 'N'
  19395. AND a.is_placefile = #{filterVO.isPlacefile}
  19396. <if test="filterVO.startDate != null and filterVO.endDate != null">
  19397. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  19398. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19399. </if>
  19400. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19401. AND a.behospital_code = c.behospital_code
  19402. AND a.hospital_id = #{filterVO.hospitalId}
  19403. AND a.hospital_id = c.hospital_id
  19404. ) a
  19405. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  19406. AND a.behospital_code = c.behospital_code
  19407. AND a.hospital_id = c.hospital_id
  19408. ) a
  19409. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  19410. AND d.is_deleted = 'N'
  19411. ) a
  19412. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  19413. AND a.hospital_id = q.hospital_id
  19414. </select>
  19415. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  19416. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19417. select
  19418. d.behospital_code behospitalCode,
  19419. b.operation_fee operationFee,
  19420. b.pathology_fee pathologyFee,
  19421. b.antibiosis_fee antibiosisFee
  19422. FROM
  19423. (
  19424. SELECT
  19425. a.behospital_code,
  19426. a.hospital_id,
  19427. a.behospital_date,
  19428. a.leave_hospital_date
  19429. FROM
  19430. med_behospital_info a,
  19431. med_qcresult_info c
  19432. WHERE
  19433. a.is_deleted = 'N'
  19434. AND c.is_deleted = 'N'
  19435. AND a.is_placefile = #{filterVO.isPlacefile}
  19436. <if test="filterVO.startDate != null and filterVO.endDate != null">
  19437. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  19438. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19439. </if>
  19440. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19441. AND a.hospital_id = c.hospital_id
  19442. AND a.hospital_id = #{filterVO.hospitalId}
  19443. and a.behospital_code = c.behospital_code
  19444. ) d
  19445. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  19446. AND d.hospital_id = b.hospital_id
  19447. AND b.is_deleted = 'N'
  19448. </select>
  19449. <!-- 关于触发规则不符合人数-->
  19450. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19451. SELECT
  19452. count(
  19453. DISTINCT
  19454. CASE
  19455. WHEN a.type=5 THEN
  19456. a.behospital_code
  19457. ELSE
  19458. NULL
  19459. END
  19460. ) AS 'operationNote',
  19461. count(
  19462. DISTINCT
  19463. CASE
  19464. WHEN a.type = 4 THEN
  19465. a.behospital_code
  19466. ELSE
  19467. NULL
  19468. END
  19469. ) AS 'residentAdmitNote',
  19470. count(
  19471. DISTINCT
  19472. CASE
  19473. WHEN a.type = 6 THEN
  19474. a.behospital_code
  19475. ELSE
  19476. NULL
  19477. END
  19478. ) AS 'dischargeRecord',
  19479. count(
  19480. DISTINCT
  19481. CASE
  19482. WHEN a.type = 7 THEN
  19483. a.behospital_code
  19484. ELSE
  19485. NULL
  19486. END
  19487. ) AS 'medicalRecord',
  19488. count(
  19489. DISTINCT
  19490. CASE
  19491. WHEN a.type=8 THEN
  19492. a.behospital_code
  19493. ELSE
  19494. NULL
  19495. END
  19496. ) AS 'CT',
  19497. count(
  19498. DISTINCT
  19499. CASE
  19500. WHEN a.type = 9 THEN
  19501. a.behospital_code
  19502. ELSE
  19503. NULL
  19504. END
  19505. ) AS 'MR',
  19506. count(
  19507. DISTINCT
  19508. CASE
  19509. WHEN a.type = 10 THEN
  19510. a.behospital_code
  19511. ELSE
  19512. NULL
  19513. END
  19514. ) AS 'operationPathologyFee',
  19515. count(
  19516. DISTINCT
  19517. CASE
  19518. WHEN a.type = 11 THEN
  19519. a.behospital_code
  19520. ELSE
  19521. NULL
  19522. END
  19523. ) AS 'bacterialCulture',
  19524. count(
  19525. DISTINCT
  19526. CASE
  19527. WHEN a.type = 12 THEN
  19528. a.behospital_code
  19529. ELSE
  19530. NULL
  19531. END
  19532. ) AS 'antibiosis',
  19533. count(
  19534. DISTINCT
  19535. CASE
  19536. WHEN a.type = 13 THEN
  19537. a.behospital_code
  19538. ELSE
  19539. NULL
  19540. END
  19541. ) AS 'chemotherapyMalignantTumors',
  19542. count(
  19543. DISTINCT
  19544. CASE
  19545. WHEN a.type = 15 THEN
  19546. a.behospital_code
  19547. ELSE
  19548. NULL
  19549. END
  19550. ) AS 'operationRecordNum',
  19551. count(
  19552. DISTINCT
  19553. CASE
  19554. WHEN a.type = 17 THEN
  19555. a.behospital_code
  19556. ELSE
  19557. NULL
  19558. END
  19559. ) AS 'bloodNum',
  19560. count(
  19561. DISTINCT
  19562. CASE
  19563. WHEN a.type = 18 THEN
  19564. a.behospital_code
  19565. ELSE
  19566. NULL
  19567. END
  19568. ) AS 'WardRoundNum',
  19569. count(
  19570. DISTINCT
  19571. CASE
  19572. WHEN a.type = 19 THEN
  19573. a.behospital_code
  19574. ELSE
  19575. NULL
  19576. END
  19577. ) AS 'rescueNum',
  19578. count(
  19579. DISTINCT
  19580. CASE
  19581. WHEN a.type = 22 THEN
  19582. a.behospital_code
  19583. ELSE
  19584. NULL
  19585. END
  19586. ) AS 'unreasonedCopyNum',
  19587. count(
  19588. DISTINCT
  19589. CASE
  19590. WHEN a.type = 14 THEN
  19591. a.behospital_code
  19592. ELSE
  19593. NULL
  19594. END
  19595. ) AS 'tumorRadiationNum',
  19596. count(
  19597. DISTINCT
  19598. CASE
  19599. WHEN a.type = 16 THEN
  19600. a.behospital_code
  19601. ELSE
  19602. NULL
  19603. END
  19604. ) AS 'implantsNum',
  19605. count(
  19606. DISTINCT
  19607. CASE
  19608. WHEN a.type = 23 THEN
  19609. a.behospital_code
  19610. ELSE
  19611. NULL
  19612. END
  19613. ) AS 'InformedNum'
  19614. FROM
  19615. (
  19616. SELECT
  19617. a.behospital_code,
  19618. a.hospital_id,
  19619. q.type
  19620. FROM
  19621. (
  19622. SELECT
  19623. a.behospital_code,
  19624. a.cases_entry_id,
  19625. a.hospital_id
  19626. FROM
  19627. (
  19628. SELECT
  19629. a.behospital_code,
  19630. c.cases_entry_id,
  19631. a.hospital_id
  19632. FROM
  19633. (
  19634. SELECT
  19635. a.behospital_code,
  19636. a.hospital_id
  19637. FROM
  19638. med_behospital_info a,
  19639. med_qcresult_info c
  19640. WHERE
  19641. a.is_deleted = 'N'
  19642. AND c.is_deleted = 'N'
  19643. AND a.is_placefile = #{filterVO.isPlacefile}
  19644. <if test="filterVO.startDate != null and filterVO.endDate != null">
  19645. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  19646. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19647. </if>
  19648. AND a.behospital_code = c.behospital_code
  19649. AND a.hospital_id = #{filterVO.hospitalId}
  19650. AND a.hospital_id = c.hospital_id
  19651. ) a
  19652. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  19653. AND a.behospital_code = c.behospital_code
  19654. AND a.hospital_id = c.hospital_id
  19655. ) a
  19656. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  19657. AND d.is_deleted = 'N'
  19658. ) a
  19659. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  19660. AND a.hospital_id = q.hospital_id
  19661. ) a
  19662. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  19663. AND r.relevance_type = a.type
  19664. AND r.is_deleted = 'N'
  19665. AND a.hospital_id = r.hospital_id
  19666. </select>
  19667. <!-- 跟病案首页关联的出院病历-->
  19668. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19669. SELECT
  19670. d.behospital_code,
  19671. d.behospital_date,
  19672. d.leave_hospital_date,
  19673. b.behospital_code AS b_code,
  19674. b.operation_fee,
  19675. b.antibiosis_fee,
  19676. b.pathology_fee
  19677. FROM
  19678. (
  19679. SELECT
  19680. a.behospital_code,
  19681. a.hospital_id,
  19682. a.behospital_date,
  19683. a.leave_hospital_date
  19684. FROM
  19685. med_behospital_info a,
  19686. med_qcresult_info c
  19687. WHERE
  19688. a.behospital_code = c.behospital_code
  19689. AND a.hospital_id = #{filterVO.hospitalId}
  19690. AND a.is_placefile = #{filterVO.isPlacefile}
  19691. AND a.hospital_id = c.hospital_id
  19692. AND a.is_deleted = 'N'
  19693. AND c.is_deleted = 'N'
  19694. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19695. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  19696. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  19697. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19698. </if>
  19699. ) d
  19700. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  19701. AND d.hospital_id = b.hospital_id
  19702. AND b.is_deleted = 'N'
  19703. where ISNULL(b.behospital_code)
  19704. </select>
  19705. <!-- 首页恶性肿瘤-->
  19706. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  19707. select
  19708. a.behospital_code,
  19709. a.hospital_id,
  19710. d.diagnose_name,
  19711. d.diagnose_type,
  19712. d.icd_code
  19713. from(
  19714. SELECT
  19715. d.behospital_code,
  19716. d.hospital_id,
  19717. b.home_page_id
  19718. FROM
  19719. (
  19720. SELECT
  19721. a.behospital_code,
  19722. a.hospital_id,
  19723. a.behospital_date,
  19724. a.leave_hospital_date
  19725. FROM
  19726. med_behospital_info a,
  19727. med_qcresult_info c
  19728. WHERE
  19729. a.behospital_code = c.behospital_code
  19730. AND a.hospital_id = #{filterVO.hospitalId}
  19731. AND a.is_placefile = #{filterVO.isPlacefile}
  19732. AND a.hospital_id = c.hospital_id
  19733. AND a.is_deleted = 'N'
  19734. AND c.is_deleted = 'N'
  19735. <![CDATA[ and a.qc_type_id <>'0' ]]>
  19736. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  19737. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  19738. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  19739. </if>
  19740. ) d
  19741. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  19742. AND d.hospital_id = b.hospital_id
  19743. AND b.is_deleted = 'N'
  19744. )a join
  19745. med_home_diagnose_info d on a.hospital_id=d.hospital_id
  19746. where a.home_page_id =d.home_page_id
  19747. and d.is_deleted ='N'
  19748. and d.diagnose_name like '%恶性肿瘤%'
  19749. and d.icd_code like 'C%'
  19750. </select>
  19751. <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
  19752. <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
  19753. SELECT
  19754. mbi.behospital_code behospitalCode,
  19755. mhp.age,
  19756. TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
  19757. TIMESTAMPDIFF(day,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageDay
  19758. FROM
  19759. med_behospital_info mbi
  19760. LEFT JOIN med_home_page mhp
  19761. ON mbi.behospital_code=mhp.behospital_code
  19762. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  19763. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
  19764. <if test="behospitalCodes !=null and behospitalCodes.size > 0">
  19765. and mbi.behospital_code in
  19766. <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
  19767. #{item}
  19768. </foreach>
  19769. </if>
  19770. </select>
  19771. </mapper>