BehospitalInfoMapper.xml 730 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261
  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. t4.*,
  3344. ifnull(bas.professor,'')as professor
  3345. FROM (
  3346. SELECT
  3347. t1.deptId,
  3348. t1.deptName,
  3349. t1.doctorId,
  3350. t1.doctorName,
  3351. t2.entryNum,
  3352. t1.mrNum,
  3353. t1.totleValue,
  3354. t1.averageValue,
  3355. t1.firstLevelNum,
  3356. t1.secondLevelNum,
  3357. t1.firstLevelPercent,
  3358. t1.secondLevelPercent,
  3359. t1.firstLevelPercentStr,
  3360. t1.secondLevelPercentStr,
  3361. t3.emptyNum,
  3362. t3.errorNum,
  3363. t3.entryTotleNum,
  3364. t3.emptyPercent,
  3365. t3.errorPercent,
  3366. t3.emptyPercentStr,
  3367. t3.errorPercentStr
  3368. FROM
  3369. (
  3370. SELECT
  3371. a.beh_dept_id AS deptId,
  3372. a.beh_dept_name AS deptName,
  3373. a.doctor_id AS doctorId,
  3374. a.doctor_name AS doctorName,
  3375. count( * ) AS mrNum,
  3376. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3377. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3378. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3379. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3380. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3381. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3382. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3383. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3384. FROM
  3385. med_behospital_info a,
  3386. med_qcresult_cases c
  3387. WHERE
  3388. a.is_deleted = 'N'
  3389. AND c.is_deleted = 'N'
  3390. AND a.hospital_id = c.hospital_id
  3391. AND a.behospital_code = c.behospital_code
  3392. AND c.cases_id = 243
  3393. <if test="isPlacefile != null and isPlacefile != ''">
  3394. and a.is_placefile = #{isPlacefile}
  3395. </if>
  3396. AND a.qc_type_id != 0
  3397. <if test="hospitalId != null and hospitalId != ''">
  3398. AND a.hospital_id = #{hospitalId}
  3399. </if>
  3400. <if test="isPlacefile != null and isPlacefile == 0">
  3401. <if test="startDate != null and startDate != ''">
  3402. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3403. </if>
  3404. <if test="endDate != null and endDate != ''">
  3405. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3406. </if>
  3407. </if>
  3408. <if test="isPlacefile != null and isPlacefile == 1">
  3409. <if test="startDate != null and startDate != ''">
  3410. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3411. </if>
  3412. <if test="endDate != null and endDate != ''">
  3413. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3414. </if>
  3415. </if>
  3416. <if test="deptName != null and deptName != ''">
  3417. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3418. </if>
  3419. <if test="doctorName != null and doctorName != ''">
  3420. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3421. </if>
  3422. GROUP BY
  3423. a.beh_dept_id,
  3424. a.beh_dept_name,
  3425. a.doctor_id
  3426. ) t1,
  3427. (
  3428. SELECT
  3429. a.beh_dept_id AS deptId,
  3430. a.beh_dept_name AS deptName,
  3431. a.doctor_id AS doctorId,
  3432. count( * ) AS entryNum
  3433. FROM
  3434. med_behospital_info a,
  3435. med_qcresult_cases c,
  3436. med_qcresult_detail d,
  3437. qc_cases_entry e
  3438. WHERE
  3439. a.is_deleted = 'N'
  3440. AND c.is_deleted = 'N'
  3441. AND d.is_deleted = 'N'
  3442. AND e.is_deleted = 'N'
  3443. AND a.hospital_id = c.hospital_id
  3444. AND a.hospital_id = d.hospital_id
  3445. AND a.behospital_code = c.behospital_code
  3446. AND a.behospital_code = d.behospital_code
  3447. AND c.cases_id = d.cases_id
  3448. AND d.cases_id = e.cases_id
  3449. AND d.cases_entry_id = e.id
  3450. AND d.cases_id = 243
  3451. <if test="isPlacefile != null and isPlacefile != ''">
  3452. and a.is_placefile = #{isPlacefile}
  3453. </if>
  3454. AND a.qc_type_id != 0
  3455. <if test="hospitalId != null and hospitalId != ''">
  3456. AND a.hospital_id = #{hospitalId}
  3457. </if>
  3458. <if test="isPlacefile != null and isPlacefile == 0">
  3459. <if test="startDate != null and startDate != ''">
  3460. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3461. </if>
  3462. <if test="endDate != null and endDate != ''">
  3463. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3464. </if>
  3465. </if>
  3466. <if test="isPlacefile != null and isPlacefile == 1">
  3467. <if test="startDate != null and startDate != ''">
  3468. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3469. </if>
  3470. <if test="endDate != null and endDate != ''">
  3471. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3472. </if>
  3473. </if>
  3474. <if test="deptName != null and deptName != ''">
  3475. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3476. </if>
  3477. <if test="doctorName != null and doctorName != ''">
  3478. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3479. </if>
  3480. GROUP BY
  3481. a.beh_dept_id,
  3482. a.beh_dept_name,
  3483. a.doctor_id
  3484. ) t2,(
  3485. SELECT
  3486. h1.deptId,
  3487. h1.deptName,
  3488. h1.doctorId,
  3489. h1.emptyNum,
  3490. h1.errorNum,
  3491. h1.mrNum,
  3492. h2.entryNum,
  3493. h1.mrNum * h2.entryNum AS entryTotleNum,
  3494. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3495. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3496. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3497. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3498. FROM
  3499. (
  3500. SELECT
  3501. a.beh_dept_id AS deptId,
  3502. a.beh_dept_name AS deptName,
  3503. a.doctor_id as doctorId,
  3504. sum( d.rule_type = 1 ) AS emptyNum,
  3505. sum( d.rule_type = 2 ) AS errorNum,
  3506. count( DISTINCT a.behospital_code ) AS mrNum
  3507. FROM
  3508. med_behospital_info a,
  3509. med_qcresult_cases b,
  3510. med_qcresult_detail c,
  3511. qc_cases_entry d
  3512. WHERE
  3513. a.is_deleted = 'N'
  3514. AND b.is_deleted = 'N'
  3515. AND c.is_deleted = 'N'
  3516. AND d.is_deleted = 'N'
  3517. AND a.hospital_id = b.hospital_id
  3518. AND a.hospital_id = c.hospital_id
  3519. AND a.behospital_code = b.behospital_code
  3520. AND a.behospital_code = c.behospital_code
  3521. AND b.cases_id = c.cases_id
  3522. AND c.cases_id = d.cases_id
  3523. AND c.cases_entry_id = d.id
  3524. <if test="isPlacefile != null and isPlacefile != ''">
  3525. and a.is_placefile = #{isPlacefile}
  3526. </if>
  3527. AND d.cases_id = 243
  3528. AND a.qc_type_id != 0
  3529. <if test="hospitalId != null and hospitalId != ''">
  3530. AND a.hospital_id = #{hospitalId}
  3531. </if>
  3532. <if test="isPlacefile != null and isPlacefile == 0">
  3533. <if test="startDate != null and startDate != ''">
  3534. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3535. </if>
  3536. <if test="endDate != null and endDate != ''">
  3537. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3538. </if>
  3539. </if>
  3540. <if test="isPlacefile != null and isPlacefile == 1">
  3541. <if test="startDate != null and startDate != ''">
  3542. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3543. </if>
  3544. <if test="endDate != null and endDate != ''">
  3545. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3546. </if>
  3547. </if>
  3548. <if test="deptName != null and deptName != ''">
  3549. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3550. </if>
  3551. <if test="doctorName != null and doctorName != ''">
  3552. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3553. </if>
  3554. GROUP BY
  3555. a.beh_dept_id,
  3556. a.beh_dept_name,
  3557. a.doctor_id
  3558. ) h1,(
  3559. SELECT
  3560. count(*) AS entryNum
  3561. FROM
  3562. qc_cases_entry
  3563. WHERE
  3564. is_deleted = 'N'
  3565. AND cases_id = 243
  3566. ) h2
  3567. ) t3
  3568. WHERE
  3569. t1.deptId = t2.deptId
  3570. AND t1.deptId = t3.deptId
  3571. AND t1.deptName = t2.deptName
  3572. AND t1.deptName = t3.deptName
  3573. AND t1.doctorId = t2.doctorId
  3574. AND t1.doctorId = t3.doctorId)t4
  3575. left join bas_doctor_info bas
  3576. on t4.doctorId = bas.doctor_id
  3577. -- and t4.deptId = bas.dept_id
  3578. and bas.is_deleted = 'N'
  3579. where 1=1
  3580. <if test="professor != null and professor != ''">
  3581. and bas.professor = #{professor}
  3582. </if>
  3583. </select>
  3584. <!-- 各科室缺陷占比-科室 -->
  3585. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3586. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3587. SELECT
  3588. m1.doctorId,
  3589. m1.doctorName,
  3590. m1.entryNum,
  3591. m2.sameNum,
  3592. m1.mrNum,
  3593. m2.sameMrNum,
  3594. m1.totleValue,
  3595. m2.sameTotleValue,
  3596. m1.averageValue,
  3597. m2.sameAvgValue,
  3598. m1.firstLevelNum,
  3599. m2.sameFirstLevelNum,
  3600. m1.secondLevelNum,
  3601. m2.sameSecondLevelNum,
  3602. m1.thirdLevelNum,
  3603. m2.sameThirdLevelNum,
  3604. m1.firstLevelPercent,
  3605. m2.sameFirstLevelPercent,
  3606. m1.secondLevelPercent,
  3607. m2.sameSecondLevelPercent,
  3608. m1.thirdLevelPercent,
  3609. m2.sameThirdLevelPercent,
  3610. m1.firstLevelPercentStr,
  3611. m2.sameFirstLevelPercentStr,
  3612. m1.secondLevelPercentStr,
  3613. m2.sameSecondLevelPercentStr,
  3614. m1.thirdLevelPercentStr,
  3615. m2.sameThirdLevelPercentStr
  3616. FROM
  3617. (
  3618. SELECT
  3619. t1.doctorId,
  3620. t1.doctorName,
  3621. t2.entryNum,
  3622. t1.mrNum,
  3623. t1.totleValue,
  3624. t1.averageValue,
  3625. t1.firstLevelNum,
  3626. t1.secondLevelNum,
  3627. t1.thirdLevelNum,
  3628. t1.firstLevelPercent,
  3629. t1.secondLevelPercent,
  3630. t1.thirdLevelPercent,
  3631. t1.firstLevelPercentStr,
  3632. t1.secondLevelPercentStr,
  3633. t1.thirdLevelPercentStr
  3634. FROM
  3635. (
  3636. SELECT
  3637. a.doctor_id AS doctorId,
  3638. a.doctor_name AS doctorName,
  3639. count(*) AS mrNum,
  3640. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3641. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3642. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3643. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3644. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3645. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3646. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3647. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3648. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3649. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3650. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3651. FROM
  3652. med_behospital_info a,
  3653. med_qcresult_info c,
  3654. sys_user_dept e
  3655. WHERE
  3656. a.is_deleted = 'N'
  3657. AND c.is_deleted = 'N'
  3658. AND e.is_deleted = 'N'
  3659. AND a.hospital_id = c.hospital_id
  3660. AND a.behospital_code = c.behospital_code
  3661. AND a.beh_dept_id = e.dept_id
  3662. <if test="isPlacefile != null and isPlacefile != ''">
  3663. and a.is_placefile = #{isPlacefile}
  3664. </if>
  3665. AND a.qc_type_id != 0
  3666. <if test="hospitalId != null and hospitalId != ''">
  3667. AND a.hospital_id = #{hospitalId}
  3668. </if>
  3669. <if test="isPlacefile != null and isPlacefile == 0">
  3670. <if test="startDate != null and startDate != ''">
  3671. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3672. </if>
  3673. <if test="endDate != null and endDate != ''">
  3674. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3675. </if>
  3676. </if>
  3677. <if test="isPlacefile != null and isPlacefile == 1">
  3678. <if test="startDate != null and startDate != ''">
  3679. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3680. </if>
  3681. <if test="endDate != null and endDate != ''">
  3682. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3683. </if>
  3684. </if>
  3685. <if test="level != null and level != ''">
  3686. and c.level = #{level}
  3687. </if>
  3688. <if test="doctorName != null and doctorName != ''">
  3689. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3690. </if>
  3691. <if test="userId!=null and userId !=''">
  3692. AND e.user_id = #{userId}
  3693. </if>
  3694. <if test="deptName != null and deptName != ''">
  3695. and a.beh_dept_name = #{deptName}
  3696. </if>
  3697. GROUP BY
  3698. a.doctor_id,
  3699. a.doctor_name
  3700. ) t1,
  3701. (
  3702. SELECT
  3703. a.doctor_id AS doctorId,
  3704. a.doctor_name AS doctorName,
  3705. count( * ) AS entryNum
  3706. FROM
  3707. med_behospital_info a,
  3708. med_qcresult_info c,
  3709. med_qcresult_detail d,
  3710. qc_cases_entry e,
  3711. sys_user_dept f
  3712. WHERE
  3713. a.is_deleted = 'N'
  3714. AND c.is_deleted = 'N'
  3715. AND d.is_deleted = 'N'
  3716. AND e.is_deleted = 'N'
  3717. AND f.is_deleted = 'N'
  3718. AND a.hospital_id = c.hospital_id
  3719. AND a.hospital_id = d.hospital_id
  3720. AND a.behospital_code = c.behospital_code
  3721. AND a.behospital_code = d.behospital_code
  3722. AND d.cases_id = e.cases_id
  3723. AND d.cases_entry_id = e.id
  3724. AND a.beh_dept_id = f.dept_id
  3725. <if test="isPlacefile != null and isPlacefile != ''">
  3726. and a.is_placefile = #{isPlacefile}
  3727. </if>
  3728. AND a.qc_type_id != 0
  3729. <if test="hospitalId != null and hospitalId != ''">
  3730. AND a.hospital_id = #{hospitalId}
  3731. </if>
  3732. <if test="isPlacefile != null and isPlacefile == 0">
  3733. <if test="startDate != null and startDate != ''">
  3734. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3735. </if>
  3736. <if test="endDate != null and endDate != ''">
  3737. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3738. </if>
  3739. </if>
  3740. <if test="isPlacefile != null and isPlacefile == 1">
  3741. <if test="startDate != null and startDate != ''">
  3742. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3743. </if>
  3744. <if test="endDate != null and endDate != ''">
  3745. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3746. </if>
  3747. </if>
  3748. <if test="level != null and level != ''">
  3749. and c.level = #{level}
  3750. </if>
  3751. <if test="doctorName != null and doctorName != ''">
  3752. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3753. </if>
  3754. <if test="userId!=null and userId !=''">
  3755. AND f.user_id = #{userId}
  3756. </if>
  3757. <if test="deptName != null and deptName != ''">
  3758. and a.beh_dept_name = #{deptName}
  3759. </if>
  3760. GROUP BY
  3761. a.doctor_id,
  3762. a.doctor_name
  3763. ) t2
  3764. WHERE
  3765. t1.doctorId = t2.doctorId
  3766. AND t1.doctorName = t2.doctorName
  3767. )m1 left join
  3768. ( SELECT
  3769. t1.doctorId,
  3770. t1.doctorName,
  3771. t2.entryNum as sameNum,
  3772. t1.mrNum as sameMrNum,
  3773. t1.totleValue as sameTotleValue,
  3774. t1.averageValue as sameAvgValue,
  3775. t1.firstLevelNum as sameFirstLevelNum,
  3776. t1.secondLevelNum as sameSecondLevelNum,
  3777. t1.thirdLevelNum as sameThirdLevelNum,
  3778. t1.firstLevelPercent as sameFirstLevelPercent,
  3779. t1.secondLevelPercent as sameSecondLevelPercent,
  3780. t1.thirdLevelPercent as sameThirdLevelPercent,
  3781. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3782. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3783. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3784. FROM
  3785. (
  3786. SELECT
  3787. a.doctor_id AS doctorId,
  3788. a.doctor_name AS doctorName,
  3789. count(*) AS mrNum,
  3790. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3791. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3792. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3793. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3794. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3795. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3796. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3797. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3798. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3799. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3800. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3801. FROM
  3802. med_behospital_info a,
  3803. med_qcresult_info c,
  3804. sys_user_dept e
  3805. WHERE
  3806. a.is_deleted = 'N'
  3807. AND c.is_deleted = 'N'
  3808. AND e.is_deleted = 'N'
  3809. AND a.hospital_id = c.hospital_id
  3810. AND a.behospital_code = c.behospital_code
  3811. AND a.beh_dept_id = e.dept_id
  3812. <if test="isPlacefile != null and isPlacefile != ''">
  3813. and a.is_placefile = #{isPlacefile}
  3814. </if>
  3815. AND a.qc_type_id != 0
  3816. <if test="hospitalId != null and hospitalId != ''">
  3817. AND a.hospital_id = #{hospitalId}
  3818. </if>
  3819. <if test="isPlacefile != null and isPlacefile == 0">
  3820. <if test="lastStartDate != null and lastStartDate != ''">
  3821. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3822. </if>
  3823. <if test="lastEndDate != null and lastEndDate != ''">
  3824. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3825. </if>
  3826. </if>
  3827. <if test="isPlacefile != null and isPlacefile == 1">
  3828. <if test="lastStartDate != null and lastStartDate != ''">
  3829. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3830. </if>
  3831. <if test="lastEndDate != null and lastEndDate != ''">
  3832. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3833. </if>
  3834. </if>
  3835. <if test="level != null and level != ''">
  3836. and c.level = #{level}
  3837. </if>
  3838. <if test="doctorName != null and doctorName != ''">
  3839. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3840. </if>
  3841. <if test="userId!=null and userId !=''">
  3842. AND e.user_id = #{userId}
  3843. </if>
  3844. <if test="deptName != null and deptName != ''">
  3845. and a.beh_dept_name = #{deptName}
  3846. </if>
  3847. GROUP BY
  3848. a.doctor_id,
  3849. a.doctor_name
  3850. ) t1,
  3851. (
  3852. SELECT
  3853. a.doctor_id AS doctorId,
  3854. a.doctor_name AS doctorName,
  3855. count( * ) AS entryNum
  3856. FROM
  3857. med_behospital_info a,
  3858. med_qcresult_info c,
  3859. med_qcresult_detail d,
  3860. qc_cases_entry e,
  3861. sys_user_dept f
  3862. WHERE
  3863. a.is_deleted = 'N'
  3864. AND c.is_deleted = 'N'
  3865. AND d.is_deleted = 'N'
  3866. AND e.is_deleted = 'N'
  3867. AND f.is_deleted = 'N'
  3868. AND a.hospital_id = c.hospital_id
  3869. AND a.hospital_id = d.hospital_id
  3870. AND a.behospital_code = c.behospital_code
  3871. AND a.behospital_code = d.behospital_code
  3872. AND d.cases_id = e.cases_id
  3873. AND d.cases_entry_id = e.id
  3874. AND a.beh_dept_id = f.dept_id
  3875. <if test="isPlacefile != null and isPlacefile != ''">
  3876. and a.is_placefile = #{isPlacefile}
  3877. </if>
  3878. AND a.qc_type_id != 0
  3879. <if test="hospitalId != null and hospitalId != ''">
  3880. AND a.hospital_id = #{hospitalId}
  3881. </if>
  3882. <if test="isPlacefile != null and isPlacefile == 0">
  3883. <if test="lastStartDate != null and lastStartDate != ''">
  3884. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3885. </if>
  3886. <if test="lastEndDate != null and lastEndDate != ''">
  3887. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3888. </if>
  3889. </if>
  3890. <if test="isPlacefile != null and isPlacefile == 1">
  3891. <if test="lastStartDate != null and lastStartDate != ''">
  3892. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3893. </if>
  3894. <if test="lastEndDate != null and lastEndDate != ''">
  3895. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3896. </if>
  3897. </if>
  3898. <if test="level != null and level != ''">
  3899. and c.level = #{level}
  3900. </if>
  3901. <if test="doctorName != null and doctorName != ''">
  3902. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3903. </if>
  3904. <if test="userId!=null and userId !=''">
  3905. AND f.user_id = #{userId}
  3906. </if>
  3907. <if test="deptName != null and deptName != ''">
  3908. and a.beh_dept_name = #{deptName}
  3909. </if>
  3910. GROUP BY
  3911. a.doctor_id,
  3912. a.doctor_name
  3913. ) t2
  3914. WHERE
  3915. t1.doctorId = t2.doctorId
  3916. AND t1.doctorName = t2.doctorName
  3917. )m2
  3918. on
  3919. m1.doctorId = m2.doctorId
  3920. AND m1.doctorName = m2.doctorName
  3921. <if test="asc != null and asc !=''">
  3922. order by
  3923. <choose>
  3924. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3925. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3926. <when test='asc=="name"'>m1.doctorName asc</when>
  3927. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3928. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3929. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3930. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3931. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3932. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3933. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3934. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3935. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3936. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3937. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3938. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3939. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3940. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3941. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3942. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3943. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3944. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3945. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3946. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3947. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3948. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3949. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3950. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3951. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3952. <otherwise>doctorName asc</otherwise>
  3953. </choose>
  3954. </if>
  3955. <if test="desc != null and desc!=''">
  3956. order by
  3957. <choose>
  3958. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3959. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3960. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3961. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3962. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3963. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3964. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3965. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3966. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3967. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3968. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3969. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3970. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3971. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3972. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3973. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3974. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3975. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3976. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3977. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3978. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3979. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3980. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3981. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3982. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3983. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3984. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3985. <otherwise>doctorName desc</otherwise>
  3986. </choose>
  3987. </if>
  3988. </select>
  3989. <!-- 病案首页合格率占比-科室 -->
  3990. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3991. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3992. SELECT
  3993. t1.doctorId,
  3994. t1.doctorName,
  3995. t2.entryNum,
  3996. t1.mrNum,
  3997. t1.totleValue,
  3998. t1.averageValue,
  3999. t1.firstLevelNum,
  4000. t1.secondLevelNum,
  4001. t1.firstLevelPercent,
  4002. t1.secondLevelPercent,
  4003. t1.firstLevelPercentStr,
  4004. t1.secondLevelPercentStr,
  4005. t3.emptyNum,
  4006. t3.errorNum,
  4007. t3.entryTotleNum,
  4008. t3.emptyPercent,
  4009. t3.errorPercent,
  4010. t3.emptyPercentStr,
  4011. t3.errorPercentStr
  4012. FROM
  4013. (
  4014. SELECT
  4015. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4016. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4017. count( * ) AS mrNum,
  4018. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  4019. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  4020. sum( c.`level` = '合格' ) AS firstLevelNum,
  4021. sum( c.`level` = '不合格' ) AS secondLevelNum,
  4022. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  4023. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  4024. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  4025. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  4026. FROM
  4027. med_behospital_info a,
  4028. med_qcresult_cases c,
  4029. sys_user_dept f
  4030. WHERE
  4031. a.is_deleted = 'N'
  4032. AND c.is_deleted = 'N'
  4033. AND f.is_deleted = 'N'
  4034. AND a.hospital_id = c.hospital_id
  4035. AND a.behospital_code = c.behospital_code
  4036. AND a.beh_dept_id = f.dept_id
  4037. AND c.cases_id = 243
  4038. <if test="isPlacefile != null and isPlacefile != ''">
  4039. and a.is_placefile = #{isPlacefile}
  4040. </if>
  4041. <![CDATA[AND a.qc_type_id <>0 ]]>
  4042. <if test="hospitalId != null and hospitalId != ''">
  4043. AND a.hospital_id = #{hospitalId}
  4044. </if>
  4045. <if test="isPlacefile != null and isPlacefile == 0">
  4046. <if test="startDate != null and startDate != ''">
  4047. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4048. </if>
  4049. <if test="endDate != null and endDate != ''">
  4050. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4051. </if>
  4052. </if>
  4053. <if test="isPlacefile != null and isPlacefile == 1">
  4054. <if test="startDate != null and startDate != ''">
  4055. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4056. </if>
  4057. <if test="endDate != null and endDate != ''">
  4058. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4059. </if>
  4060. </if>
  4061. <if test="level != null and level != ''">
  4062. and c.level = #{level}
  4063. </if>
  4064. <if test="name != null and name != ''">
  4065. <if test="name == '未知'">
  4066. and (a.doctor_name is null or a.doctor_name='')
  4067. </if>
  4068. <if test="name != '未知'">
  4069. and a.doctor_name like CONCAT('%',#{name},'%')
  4070. </if>
  4071. </if>
  4072. <if test="userId!=null and userId !=''">
  4073. AND f.user_id = #{userId}
  4074. </if>
  4075. <if test="deptName!=null and deptName !=''">
  4076. AND a.beh_dept_name = #{deptName}
  4077. </if>
  4078. <if test="name != null and name != ''">
  4079. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4080. </if>
  4081. GROUP BY
  4082. a.doctor_id,
  4083. a.doctor_name
  4084. ) t1,
  4085. (
  4086. SELECT
  4087. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4088. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4089. count( * ) AS entryNum
  4090. FROM
  4091. med_behospital_info a,
  4092. med_qcresult_cases c,
  4093. med_qcresult_detail d,
  4094. qc_cases_entry e,
  4095. sys_user_dept f
  4096. WHERE
  4097. a.is_deleted = 'N'
  4098. AND c.is_deleted = 'N'
  4099. AND d.is_deleted = 'N'
  4100. AND e.is_deleted = 'N'
  4101. AND f.is_deleted = 'N'
  4102. AND a.hospital_id = c.hospital_id
  4103. AND a.hospital_id = d.hospital_id
  4104. AND a.behospital_code = c.behospital_code
  4105. AND a.behospital_code = d.behospital_code
  4106. AND a.beh_dept_id = f.dept_id
  4107. AND c.cases_id = d.cases_id
  4108. AND d.cases_id = e.cases_id
  4109. AND d.cases_entry_id = e.id
  4110. AND c.cases_id = 243
  4111. <if test="isPlacefile != null and isPlacefile != ''">
  4112. and a.is_placefile = #{isPlacefile}
  4113. </if>
  4114. <![CDATA[AND a.qc_type_id <>0 ]]>
  4115. <if test="hospitalId != null and hospitalId != ''">
  4116. AND a.hospital_id = #{hospitalId}
  4117. </if>
  4118. <if test="isPlacefile != null and isPlacefile == 0">
  4119. <if test="startDate != null and startDate != ''">
  4120. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4121. </if>
  4122. <if test="endDate != null and endDate != ''">
  4123. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4124. </if>
  4125. </if>
  4126. <if test="isPlacefile != null and isPlacefile == 1">
  4127. <if test="startDate != null and startDate != ''">
  4128. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4129. </if>
  4130. <if test="endDate != null and endDate != ''">
  4131. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4132. </if>
  4133. </if>
  4134. <if test="level != null and level != ''">
  4135. and c.level = #{level}
  4136. </if>
  4137. <if test="name != null and name != ''">
  4138. <if test="name == '未知'">
  4139. and (a.doctor_name is null or a.doctor_name='')
  4140. </if>
  4141. <if test="name != '未知'">
  4142. and a.doctor_name like CONCAT('%',#{name},'%')
  4143. </if>
  4144. </if>
  4145. <if test="userId!=null and userId !=''">
  4146. AND f.user_id = #{userId}
  4147. </if>
  4148. <if test="deptName!=null and deptName !=''">
  4149. AND a.beh_dept_name = #{deptName}
  4150. </if>
  4151. <if test="name != null and name != ''">
  4152. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4153. </if>
  4154. GROUP BY
  4155. a.doctor_id,
  4156. a.doctor_name
  4157. ) t2,(
  4158. SELECT
  4159. h1.doctorId,
  4160. h1.doctorName,
  4161. h1.emptyNum,
  4162. h1.errorNum,
  4163. h1.mrNum,
  4164. h2.entryNum,
  4165. h1.mrNum * h2.entryNum AS entryTotleNum,
  4166. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  4167. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  4168. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  4169. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  4170. FROM
  4171. (
  4172. SELECT
  4173. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4174. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4175. sum( d.rule_type = 1 ) AS emptyNum,
  4176. sum( d.rule_type = 2 ) AS errorNum,
  4177. count( DISTINCT a.behospital_code ) AS mrNum
  4178. FROM
  4179. med_behospital_info a,
  4180. med_qcresult_cases b,
  4181. med_qcresult_detail c,
  4182. qc_cases_entry d,
  4183. sys_user_dept e
  4184. WHERE
  4185. a.is_deleted = 'N'
  4186. AND b.is_deleted = 'N'
  4187. AND c.is_deleted = 'N'
  4188. AND d.is_deleted = 'N'
  4189. AND e.is_deleted = 'N'
  4190. AND a.hospital_id = b.hospital_id
  4191. AND a.hospital_id = c.hospital_id
  4192. AND a.hospital_id = e.hospital_id
  4193. AND a.behospital_code = b.behospital_code
  4194. AND a.behospital_code = c.behospital_code
  4195. AND b.cases_id = c.cases_id
  4196. AND c.cases_id = d.cases_id
  4197. AND c.cases_entry_id = d.id
  4198. AND a.beh_dept_id = e.dept_id
  4199. <if test="isPlacefile != null and isPlacefile != ''">
  4200. and a.is_placefile = #{isPlacefile}
  4201. </if>
  4202. AND d.cases_id = 243
  4203. <![CDATA[AND a.qc_type_id <>0 ]]>
  4204. <if test="hospitalId != null and hospitalId != ''">
  4205. AND a.hospital_id = #{hospitalId}
  4206. </if>
  4207. <if test="isPlacefile != null and isPlacefile == 0">
  4208. <if test="startDate != null and startDate != ''">
  4209. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4210. </if>
  4211. <if test="endDate != null and endDate != ''">
  4212. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4213. </if>
  4214. </if>
  4215. <if test="isPlacefile != null and isPlacefile == 1">
  4216. <if test="startDate != null and startDate != ''">
  4217. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4218. </if>
  4219. <if test="endDate != null and endDate != ''">
  4220. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4221. </if>
  4222. </if>
  4223. <if test="level != null and level != ''">
  4224. and b.level = #{level}
  4225. </if>
  4226. <if test="name != null and name != ''">
  4227. <if test="name == '未知'">
  4228. and (a.doctor_name is null or a.doctor_name='')
  4229. </if>
  4230. <if test="name != '未知'">
  4231. and a.doctor_name like CONCAT('%',#{name},'%')
  4232. </if>
  4233. </if>
  4234. <if test="userId!=null and userId !=''">
  4235. AND e.user_id = #{userId}
  4236. </if>
  4237. <if test="deptName!=null and deptName !=''">
  4238. AND a.beh_dept_name = #{deptName}
  4239. </if>
  4240. <if test="name != null and name != ''">
  4241. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4242. </if>
  4243. GROUP BY
  4244. a.doctor_id,
  4245. a.doctor_name
  4246. ) h1,(
  4247. SELECT
  4248. count(*) AS entryNum
  4249. FROM
  4250. qc_cases_entry
  4251. WHERE
  4252. is_deleted = 'N'
  4253. AND cases_id = 243
  4254. ) h2
  4255. ) t3
  4256. WHERE
  4257. t1.doctorId = t2.doctorId
  4258. AND t1.doctorId = t3.doctorId
  4259. AND t1.doctorName = t2.doctorName
  4260. AND t1.doctorName = t3.doctorName
  4261. <if test="asc != null and asc !=''">
  4262. order by
  4263. <choose>
  4264. <when test='asc=="doctorId"'>doctorId asc</when>
  4265. <when test='asc=="doctorName"'>doctorName asc</when>
  4266. <when test='asc=="entryNum"'>entryNum asc</when>
  4267. <when test='asc=="mrNum"'>mrNum asc</when>
  4268. <when test='asc=="totleValue"'>totleValue asc</when>
  4269. <when test='asc=="averageValue"'>averageValue asc</when>
  4270. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4271. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4272. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4273. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4274. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4275. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4276. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4277. <when test='asc=="errorNum"'>errorNum asc</when>
  4278. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4279. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4280. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4281. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4282. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4283. <otherwise>doctorName asc</otherwise>
  4284. </choose>
  4285. </if>
  4286. <if test="desc != null and desc!=''">
  4287. order by
  4288. <choose>
  4289. <when test='desc=="doctorId"'>doctorId desc</when>
  4290. <when test='desc=="doctorName"'>doctorName desc</when>
  4291. <when test='desc=="entryNum"'>entryNum desc</when>
  4292. <when test='desc=="mrNum"'>mrNum desc</when>
  4293. <when test='desc=="totleValue"'>totleValue desc</when>
  4294. <when test='desc=="averageValue"'>averageValue desc</when>
  4295. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4296. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4297. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4298. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4299. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4300. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4301. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4302. <when test='desc=="errorNum"'>errorNum desc</when>
  4303. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4304. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4305. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4306. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4307. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4308. <otherwise>doctorName desc</otherwise>
  4309. </choose>
  4310. </if>
  4311. </select>
  4312. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4313. <result column="behDeptName" property="behDeptName"/>
  4314. <result column="doctorName" property="doctorName"/>
  4315. <result column="avgScore" property="avgScore"/>
  4316. <collection property="excelBehospitalDTOS"
  4317. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  4318. <result column="patName" property="patName"/>
  4319. <result column="behospitalCode" property="behospitalCode"/>
  4320. <result column="behospitalDate" property="behospitalDate"/>
  4321. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4322. <result column="score" property="score"/>
  4323. <result column="scoreBn" property="scoreBn"/>
  4324. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4325. <result column="caseName" property="caseName"/>
  4326. <collection property="exportExcelMsgDTOS"
  4327. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4328. <result column="msg" property="msg"/>
  4329. </collection>
  4330. </collection>
  4331. </collection>
  4332. </resultMap>
  4333. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  4334. <result column="behDeptName" property="behDeptName"/>
  4335. <result column="avgScore" property="avgScore"/>
  4336. <collection property="excelBehospitalDTOS"
  4337. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  4338. <result column="doctorName" property="doctorName"/>
  4339. <result column="patName" property="patName"/>
  4340. <result column="behospitalCode" property="behospitalCode"/>
  4341. <result column="behospitalDate" property="behospitalDate"/>
  4342. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4343. <result column="score" property="score"/>
  4344. <result column="scoreBn" property="scoreBn"/>
  4345. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4346. <result column="caseName" property="caseName"/>
  4347. <collection property="exportExcelMsgDTOS"
  4348. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4349. <result column="msg" property="msg"/>
  4350. </collection>
  4351. </collection>
  4352. </collection>
  4353. </resultMap>
  4354. <select id="exportExcel" resultMap="ExportExcelMap">
  4355. SELECT DISTINCT
  4356. t1.beh_dept_name AS behDeptName,
  4357. t1.beh_doctor_name AS doctorName,
  4358. t1.`name` AS patName,
  4359. t1.behospital_code AS behospitalCode,
  4360. t1.behospital_date AS behospitalDate,
  4361. t1.leave_hospital_date AS leaveHospitalDate,
  4362. t2.score_res AS score,
  4363. "1" AS avgScore,
  4364. t4.`name` AS caseName,
  4365. t3.msg AS msg
  4366. FROM
  4367. med_behospital_info t1,
  4368. med_qcresult_info t2,
  4369. med_qcresult_detail t3,
  4370. qc_cases t4
  4371. WHERE
  4372. t1.is_deleted = 'N'
  4373. AND t2.is_deleted = 'N'
  4374. AND t3.is_deleted = 'N'
  4375. AND t4.is_deleted = 'N'
  4376. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4377. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4378. AND t1.hospital_id = t2.hospital_id
  4379. AND t1.behospital_code = t2.behospital_code
  4380. AND t1.hospital_id = t3.hospital_id
  4381. AND t1.behospital_code = t3.behospital_code
  4382. AND t3.cases_id = t4.id
  4383. ORDER BY
  4384. t1.beh_dept_id ASC,
  4385. t1.leave_hospital_date DESC,
  4386. t1.behospital_code ASC,
  4387. t4.`name` ASC
  4388. </select>
  4389. <!-- 质控评分导出到excel-->
  4390. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4391. SELECT * FROM (
  4392. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4393. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4394. g.check_type AS ch_type,
  4395. h.check_type AS mr_type,
  4396. g.check_name AS ch_name,
  4397. h.check_name AS mr_name,
  4398. g.check_time AS ch_time,
  4399. h.check_time AS mr_time
  4400. FROM (
  4401. SELECT
  4402. t1.behDeptId,
  4403. t1.behDeptName,
  4404. t1.doctorName,
  4405. t1.patName,
  4406. t1.behospitalCode,
  4407. t1.hospitalId,
  4408. t1.behospitalDate,
  4409. t1.leaveHospitalDate,
  4410. t1.score,
  4411. <if test="radioCheck !=null and radioCheck == 1">
  4412. t1.msg,
  4413. t1.caseName,
  4414. </if>
  4415. t1.scoreBn,
  4416. t2.avgScore
  4417. FROM
  4418. (
  4419. SELECT
  4420. a.doctor_name AS doctorName,
  4421. a.`name` AS patName,
  4422. a.behospital_code AS behospitalCode,
  4423. a.behospital_date AS behospitalDate,
  4424. a.leave_hospital_date AS leaveHospitalDate,
  4425. b.score_res AS score,
  4426. e.score_res as scoreBn,
  4427. <if test="radioCheck !=null and radioCheck == 1">
  4428. c.msg AS msg,
  4429. d.NAME AS caseName,
  4430. </if>
  4431. a.beh_dept_id AS behDeptId,
  4432. a.beh_dept_name AS behDeptName,
  4433. a.hospital_id AS hospitalId
  4434. FROM
  4435. med_behospital_info a
  4436. RIGHT JOIN
  4437. med_qcresult_info b
  4438. ON a.hospital_id = b.hospital_id
  4439. AND a.is_deleted = 'N'
  4440. AND b.is_deleted = 'N'
  4441. AND a.behospital_code = b.behospital_code
  4442. <if test="radioCheck !=null and radioCheck == 1">
  4443. LEFT JOIN
  4444. med_qcresult_detail c
  4445. ON c.is_deleted = 'N'
  4446. AND b.behospital_code = c.behospital_code
  4447. AND b.hospital_id = c.hospital_id
  4448. LEFT JOIN
  4449. qc_cases d
  4450. on d.is_deleted = 'N'
  4451. AND c.cases_id = d.id
  4452. </if>
  4453. LEFT JOIN med_qcresult_cases e
  4454. on b.behospital_code = e.behospital_code
  4455. and b.hospital_id = e.hospital_id
  4456. AND e.is_deleted = 'N'
  4457. and e.cases_id = 243
  4458. WHERE
  4459. 1=1
  4460. <if test="isPlacefile != null and isPlacefile != ''">
  4461. and a.is_placefile = #{isPlacefile}
  4462. </if>
  4463. <![CDATA[AND a.qc_type_id <>0 ]]>
  4464. <if test="hospitalId != null and hospitalId != ''">
  4465. AND a.hospital_id = #{hospitalId}
  4466. </if>
  4467. <if test="diagnose != null and diagnose != ''">
  4468. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4469. </if>
  4470. <if test="behosDateStart != null">
  4471. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4472. </if>
  4473. <if test="behosDateEnd != null">
  4474. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4475. </if>
  4476. <if test="leaveHosDateStart != null ">
  4477. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4478. </if>
  4479. <if test="leaveHosDateEnd != null ">
  4480. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4481. </if>
  4482. <if test="behospitalCode != null and behospitalCode != ''">
  4483. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4484. </if>
  4485. <if test="level != null and level != ''">
  4486. AND b.level = #{level}
  4487. </if>
  4488. <if test="doctorName != null and doctorName != ''">
  4489. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4490. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4491. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4492. </if>
  4493. <if test="doctorCode != null and doctorCode != ''">
  4494. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4495. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4496. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4497. </if>
  4498. <if test="deptName != null and deptName != ''">
  4499. and a.beh_dept_name = #{deptName}
  4500. </if>
  4501. <if test="name != null and name != ''">
  4502. AND a.name like CONCAT('%',#{name},'%')
  4503. </if>
  4504. ) t1,
  4505. (
  4506. SELECT
  4507. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4508. a.beh_dept_id AS behDeptId,
  4509. a.beh_dept_name AS behDeptName
  4510. FROM
  4511. med_behospital_info a,
  4512. med_qcresult_info b
  4513. WHERE
  4514. a.is_deleted = 'N'
  4515. AND b.is_deleted = 'N'
  4516. AND a.hospital_id = b.hospital_id
  4517. AND a.behospital_code = b.behospital_code
  4518. <if test="isPlacefile != null and isPlacefile != ''">
  4519. and a.is_placefile = #{isPlacefile}
  4520. </if>
  4521. <![CDATA[AND a.qc_type_id <>0 ]]>
  4522. <if test="hospitalId != null and hospitalId != ''">
  4523. AND a.hospital_id = #{hospitalId}
  4524. </if>
  4525. <if test="diagnose != null and diagnose != ''">
  4526. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4527. </if>
  4528. <if test="behosDateStart != null">
  4529. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4530. </if>
  4531. <if test="behosDateEnd != null">
  4532. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4533. </if>
  4534. <if test="leaveHosDateStart != null ">
  4535. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4536. </if>
  4537. <if test="leaveHosDateEnd != null ">
  4538. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4539. </if>
  4540. <if test="behospitalCode != null and behospitalCode != ''">
  4541. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4542. </if>
  4543. <if test="level != null and level != ''">
  4544. AND b.level = #{level}
  4545. </if>
  4546. <if test="doctorName != null and doctorName != ''">
  4547. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4548. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4549. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4550. </if>
  4551. <if test="doctorCode != null and doctorCode != ''">
  4552. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4553. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4554. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4555. </if>
  4556. <if test="deptName != null and deptName != ''">
  4557. and a.beh_dept_name = #{deptName}
  4558. </if>
  4559. <if test="name != null and name != ''">
  4560. AND a.name like CONCAT('%',#{name},'%')
  4561. </if>
  4562. GROUP BY
  4563. a.beh_dept_id,
  4564. a.beh_dept_name
  4565. ) t2
  4566. WHERE
  4567. t1.behDeptId = t2.behDeptId
  4568. AND t1.behDeptName = t2.behDeptName
  4569. ORDER BY
  4570. t1.behDeptName,
  4571. t1.doctorName,
  4572. t1.patName,
  4573. <if test="radioCheck !=null and radioCheck == 1">
  4574. t1.caseName,
  4575. </if>
  4576. t1.behospitalCode
  4577. )tp
  4578. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4579. ON tp.behospitalCode = g.behospital_code
  4580. AND tp.hospitalId = g.hospital_id
  4581. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4582. ON tp.behospitalCode = h.behospital_code
  4583. AND tp.hospitalId = h.hospital_id
  4584. ) tu
  4585. WHERE tu.behospitalCode IS NOT NULL
  4586. <if test="checkStatus != null ">
  4587. and tu.check_status = #{checkStatus}
  4588. </if>
  4589. <if test="mrStatus != null ">
  4590. AND tu.mr_status = #{mrStatus}
  4591. </if>
  4592. <if test="chName != null and chName !=''">
  4593. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4594. </if>
  4595. <if test="mrName != null and mrName !=''">
  4596. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4597. </if>
  4598. <if test="chTimeStart != null">
  4599. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4600. </if>
  4601. <if test="chTimeEnd != null">
  4602. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4603. </if>
  4604. <if test="mrTimeStart != null">
  4605. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4606. </if>
  4607. <if test="mrTimeEnd != null">
  4608. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4609. </if>
  4610. </select>
  4611. <!-- 科室质控评分导出到excel-->
  4612. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4613. SELECT * FROM (
  4614. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4615. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4616. g.check_type AS ch_type,
  4617. h.check_type AS mr_type,
  4618. g.check_name AS ch_name,
  4619. h.check_name AS mr_name,
  4620. g.check_time AS ch_time,
  4621. h.check_time AS mr_time
  4622. FROM (
  4623. SELECT
  4624. t1.behDeptId,
  4625. t1.behDeptName,
  4626. t1.doctorName,
  4627. t1.patName,
  4628. t1.behospitalCode,
  4629. t1.hospitalId,
  4630. t1.behospitalDate,
  4631. t1.leaveHospitalDate,
  4632. t1.score,
  4633. t2.avgScore,
  4634. <if test="radioCheck !=null and radioCheck == 1">
  4635. t1.msg,
  4636. t1.caseName,
  4637. </if>
  4638. e.score_res as scoreBn
  4639. FROM
  4640. (
  4641. SELECT
  4642. a.doctor_name AS doctorName,
  4643. a.`name` AS patName,
  4644. a.behospital_code AS behospitalCode,
  4645. a.hospital_id AS hospital_id,
  4646. a.behospital_date AS behospitalDate,
  4647. a.leave_hospital_date AS leaveHospitalDate,
  4648. b.score_res AS score,
  4649. <if test="radioCheck !=null and radioCheck == 1">
  4650. c.msg AS msg,
  4651. d.NAME AS caseName,
  4652. </if>
  4653. a.beh_dept_id AS behDeptId,
  4654. a.beh_dept_name AS behDeptName,
  4655. a.hospital_id AS hospitalId
  4656. FROM
  4657. med_behospital_info a,
  4658. med_qcresult_info b,
  4659. med_qcresult_detail c,
  4660. qc_cases d,
  4661. sys_user_dept e
  4662. WHERE
  4663. a.is_deleted = 'N'
  4664. AND b.is_deleted = 'N'
  4665. AND c.is_deleted = 'N'
  4666. AND d.is_deleted = 'N'
  4667. AND e.is_deleted = 'N'
  4668. AND a.hospital_id = b.hospital_id
  4669. AND a.hospital_id = c.hospital_id
  4670. AND a.hospital_id = e.hospital_id
  4671. AND a.behospital_code = b.behospital_code
  4672. AND a.behospital_code = c.behospital_code
  4673. AND c.cases_id = d.id
  4674. AND a.beh_dept_id = e.dept_id
  4675. <if test="diagnose != null and diagnose != ''">
  4676. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4677. </if>
  4678. <if test="isPlacefile != null and isPlacefile != ''">
  4679. and a.is_placefile = #{isPlacefile}
  4680. </if>
  4681. <![CDATA[AND a.qc_type_id <>0 ]]>
  4682. <if test="hospitalId != null and hospitalId != ''">
  4683. AND a.hospital_id = #{hospitalId}
  4684. </if>
  4685. <if test="userId != null ">
  4686. AND e.user_id = #{userId}
  4687. </if>
  4688. <if test="behosDateStart != null">
  4689. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4690. </if>
  4691. <if test="behosDateEnd != null">
  4692. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4693. </if>
  4694. <if test="leaveHosDateStart != null ">
  4695. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4696. </if>
  4697. <if test="leaveHosDateEnd != null ">
  4698. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4699. </if>
  4700. <if test="behospitalCode != null and behospitalCode != ''">
  4701. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4702. </if>
  4703. <if test="level != null and level != ''">
  4704. AND b.level = #{level}
  4705. </if>
  4706. <if test="doctorName != null and doctorName != ''">
  4707. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4708. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4709. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4710. </if>
  4711. <if test="doctorCode != null and doctorCode != ''">
  4712. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4713. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4714. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4715. </if>
  4716. <if test="deptName != null and deptName != ''">
  4717. and a.beh_dept_name = #{deptName}
  4718. </if>
  4719. <if test="name != null and name != ''">
  4720. AND a.name like CONCAT('%',#{name},'%')
  4721. </if>
  4722. ) t1
  4723. LEFT JOIN med_qcresult_cases e
  4724. on t1.behospitalCode = e.behospital_code
  4725. and t1.hospital_id = e.hospital_id
  4726. AND e.is_deleted = 'N'
  4727. and e.cases_id = 243,
  4728. (
  4729. SELECT
  4730. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4731. a.beh_dept_id AS behDeptId,
  4732. a.beh_dept_name AS behDeptName
  4733. FROM
  4734. med_behospital_info a,
  4735. med_qcresult_info b,
  4736. sys_user_dept c
  4737. WHERE
  4738. a.is_deleted = 'N'
  4739. AND b.is_deleted = 'N'
  4740. AND c.is_deleted = 'N'
  4741. AND a.hospital_id = b.hospital_id
  4742. AND a.hospital_id = c.hospital_id
  4743. AND a.behospital_code = b.behospital_code
  4744. AND a.beh_dept_id = c.dept_id
  4745. <if test="diagnose != null and diagnose != ''">
  4746. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4747. </if>
  4748. <if test="isPlacefile != null and isPlacefile != ''">
  4749. and a.is_placefile = #{isPlacefile}
  4750. </if>
  4751. <![CDATA[AND a.qc_type_id <>0 ]]>
  4752. <if test="hospitalId != null and hospitalId != ''">
  4753. AND a.hospital_id = #{hospitalId}
  4754. </if>
  4755. <if test="userId != null ">
  4756. AND c.user_id = #{userId}
  4757. </if>
  4758. <if test="behosDateStart != null">
  4759. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4760. </if>
  4761. <if test="behosDateEnd != null">
  4762. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4763. </if>
  4764. <if test="leaveHosDateStart != null ">
  4765. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4766. </if>
  4767. <if test="leaveHosDateEnd != null ">
  4768. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4769. </if>
  4770. <if test="behospitalCode != null and behospitalCode != ''">
  4771. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4772. </if>
  4773. <if test="level != null and level != ''">
  4774. AND b.level = #{level}
  4775. </if>
  4776. <if test="doctorName != null and doctorName != ''">
  4777. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4778. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4779. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4780. </if>
  4781. <if test="doctorCode != null and doctorCode != ''">
  4782. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4783. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4784. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4785. </if>
  4786. <if test="deptName != null and deptName != ''">
  4787. and a.beh_dept_name = #{deptName}
  4788. </if>
  4789. <if test="name != null and name != ''">
  4790. AND a.name like CONCAT('%',#{name},'%')
  4791. </if>
  4792. GROUP BY
  4793. a.beh_dept_id,
  4794. a.beh_dept_name
  4795. ) t2
  4796. WHERE
  4797. t1.behDeptId = t2.behDeptId
  4798. AND t1.behDeptName = t2.behDeptName
  4799. ORDER BY
  4800. t1.behDeptName,
  4801. t1.doctorName,
  4802. t1.patName,
  4803. <if test="radioCheck !=null and radioCheck == 1">
  4804. t1.caseName,
  4805. </if>
  4806. t1.behospitalCode
  4807. )tp
  4808. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4809. ON tp.behospitalCode = g.behospital_code
  4810. AND tp.hospitalId = g.hospital_id
  4811. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4812. ON tp.behospitalCode = h.behospital_code
  4813. AND tp.hospitalId = h.hospital_id
  4814. ) tu
  4815. WHERE tu.behospitalCode IS NOT NULL
  4816. <if test="checkStatus != null ">
  4817. and tu.check_status = #{checkStatus}
  4818. </if>
  4819. <if test="mrStatus != null ">
  4820. AND tu.mr_status = #{mrStatus}
  4821. </if>
  4822. <if test="chName != null and chName !=''">
  4823. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4824. </if>
  4825. <if test="mrName != null and mrName !=''">
  4826. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4827. </if>
  4828. <if test="chTimeStart != null">
  4829. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4830. </if>
  4831. <if test="chTimeEnd != null">
  4832. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4833. </if>
  4834. <if test="mrTimeStart != null">
  4835. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4836. </if>
  4837. <if test="mrTimeEnd != null">
  4838. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4839. </if>
  4840. </select>
  4841. <!-- 个人质控评分导出到excel-->
  4842. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4843. SELECT * FROM (
  4844. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4845. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4846. g.check_type AS ch_type,
  4847. h.check_type AS mr_type,
  4848. g.check_name AS ch_name,
  4849. h.check_name AS mr_name,
  4850. g.check_time AS ch_time,
  4851. h.check_time AS mr_time
  4852. FROM (
  4853. SELECT
  4854. t1.behDeptId,
  4855. t1.behDeptName,
  4856. t1.doctorName,
  4857. t1.patName,
  4858. t1.behospitalCode,
  4859. t1.hospitalId,
  4860. t1.behospitalDate,
  4861. t1.leaveHospitalDate,
  4862. t1.score,
  4863. t2.avgScore,
  4864. <if test="radioCheck !=null and radioCheck == 1">
  4865. t1.msg,
  4866. t1.caseName,
  4867. </if>
  4868. e.score_res as scoreBn
  4869. FROM
  4870. (
  4871. SELECT
  4872. a.doctor_name AS doctorName,
  4873. a.beh_doctor_name,
  4874. a.director_doctor_name,
  4875. a.`name` AS patName,
  4876. a.behospital_code AS behospitalCode,
  4877. a.behospital_date AS behospitalDate,
  4878. a.leave_hospital_date AS leaveHospitalDate,
  4879. b.score_res AS score,
  4880. <if test="radioCheck !=null and radioCheck == 1">
  4881. c.msg AS msg,
  4882. d.NAME AS caseName,
  4883. </if>
  4884. a.beh_dept_id AS behDeptId,
  4885. a.beh_dept_name AS behDeptName,
  4886. a.hospital_id AS hospitalId
  4887. FROM
  4888. med_behospital_info a,
  4889. med_qcresult_info b,
  4890. med_qcresult_detail c,
  4891. qc_cases d,
  4892. sys_user u,
  4893. sys_user_hospital uh
  4894. WHERE
  4895. a.is_deleted = 'N'
  4896. AND b.is_deleted = 'N'
  4897. AND c.is_deleted = 'N'
  4898. AND d.is_deleted = 'N'
  4899. AND u.is_deleted = 'N'
  4900. AND uh.is_deleted = 'N'
  4901. AND a.hospital_id = b.hospital_id
  4902. AND a.hospital_id = c.hospital_id
  4903. AND a.behospital_code = b.behospital_code
  4904. AND a.behospital_code = c.behospital_code
  4905. AND u.id = uh.user_id
  4906. AND a.hospital_id = uh.hospital_id
  4907. <if test="userId != null and userId != ''">
  4908. AND u.id = #{userId}
  4909. </if>
  4910. <if test="isPlacefile != null and isPlacefile != ''">
  4911. and a.is_placefile = #{isPlacefile}
  4912. </if>
  4913. <![CDATA[AND a.qc_type_id <>0 ]]>
  4914. <if test="hospitalId != null and hospitalId != ''">
  4915. AND a.hospital_id = #{hospitalId}
  4916. </if>
  4917. <if test="diagnose != null and diagnose != ''">
  4918. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4919. </if>
  4920. <if test="behosDateStart != null">
  4921. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4922. </if>
  4923. <if test="behosDateEnd != null">
  4924. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4925. </if>
  4926. <if test="leaveHosDateStart != null ">
  4927. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4928. </if>
  4929. <if test="leaveHosDateEnd != null ">
  4930. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4931. </if>
  4932. <if test="behospitalCode != null and behospitalCode != ''">
  4933. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4934. </if>
  4935. <if test="level != null and level != ''">
  4936. AND b.level = #{level}
  4937. </if>
  4938. <if test="doctorName != null and doctorName != ''">
  4939. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4940. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4941. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4942. </if>
  4943. <if test="doctorCode != null and doctorCode != ''">
  4944. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4945. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4946. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4947. </if>
  4948. <if test="deptId != null and deptId != ''">
  4949. AND a.beh_dept_id = #{deptId}
  4950. </if>
  4951. <if test="deptName != null and deptName != ''">
  4952. and a.beh_dept_name = #{deptName}
  4953. </if>
  4954. <if test="name != null and name != ''">
  4955. AND a.name like CONCAT('%',#{name},'%')
  4956. </if>
  4957. ) t1 LEFT JOIN med_qcresult_cases e
  4958. on t1.behospitalCode = e.behospital_code
  4959. and t1.hospitalId = e.hospital_id
  4960. AND e.is_deleted = 'N'
  4961. and e.cases_id = 243,
  4962. (
  4963. SELECT
  4964. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4965. a.beh_dept_id AS behDeptId,
  4966. a.beh_dept_name AS behDeptName
  4967. FROM
  4968. med_behospital_info a,
  4969. med_qcresult_info b,
  4970. sys_user u,
  4971. sys_user_hospital uh
  4972. WHERE
  4973. a.is_deleted = 'N'
  4974. AND b.is_deleted = 'N'
  4975. AND u.is_deleted = 'N'
  4976. AND uh.is_deleted = 'N'
  4977. AND a.hospital_id = b.hospital_id
  4978. AND a.behospital_code = b.behospital_code
  4979. AND u.id = uh.user_id
  4980. AND a.hospital_id = uh.hospital_id
  4981. and (a.doctor_name = u.linkman
  4982. or a.beh_doctor_name = u.linkman
  4983. or a.director_doctor_name = u.linkman)
  4984. <if test="userId != null and userId != ''">
  4985. AND u.id = #{userId}
  4986. </if>
  4987. <if test="diagnose != null and diagnose != ''">
  4988. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4989. </if>
  4990. <if test="isPlacefile != null and isPlacefile != ''">
  4991. and a.is_placefile = #{isPlacefile}
  4992. </if>
  4993. <![CDATA[AND a.qc_type_id <>0 ]]>
  4994. <if test="hospitalId != null and hospitalId != ''">
  4995. AND a.hospital_id = #{hospitalId}
  4996. </if>
  4997. <if test="behosDateStart != null">
  4998. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4999. </if>
  5000. <if test="behosDateEnd != null">
  5001. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5002. </if>
  5003. <if test="leaveHosDateStart != null ">
  5004. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  5005. </if>
  5006. <if test="leaveHosDateEnd != null ">
  5007. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  5008. </if>
  5009. <if test="behospitalCode != null and behospitalCode != ''">
  5010. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5011. </if>
  5012. <if test="level != null and level != ''">
  5013. AND b.level = #{level}
  5014. </if>
  5015. <if test="doctorName != null and doctorName != ''">
  5016. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5017. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5018. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5019. </if>
  5020. <if test="doctorCode != null and doctorCode != ''">
  5021. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5022. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5023. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5024. </if>
  5025. <if test="deptId != null and deptId != ''">
  5026. AND a.beh_dept_id = #{deptId}
  5027. </if>
  5028. <if test="deptName != null and deptName != ''">
  5029. and a.beh_dept_name = #{deptName}
  5030. </if>
  5031. <if test="name != null and name != ''">
  5032. AND a.name like CONCAT('%',#{name},'%')
  5033. </if>
  5034. ) t2
  5035. WHERE
  5036. t1.behDeptId = t2.behDeptId
  5037. AND t1.behDeptName = t2.behDeptName
  5038. ORDER BY
  5039. t1.behDeptName,
  5040. t1.doctorName,
  5041. t1.patName,
  5042. <if test="radioCheck !=null and radioCheck == 1">
  5043. t1.caseName,
  5044. </if>
  5045. t1.behospitalCode
  5046. )tp
  5047. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5048. ON tp.behospitalCode = g.behospital_code
  5049. AND tp.hospitalId = g.hospital_id
  5050. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5051. ON tp.behospitalCode = h.behospital_code
  5052. AND tp.hospitalId = h.hospital_id
  5053. ) tu
  5054. WHERE tu.behospitalCode IS NOT NULL
  5055. <if test="checkStatus != null ">
  5056. and tu.check_status = #{checkStatus}
  5057. </if>
  5058. <if test="mrStatus != null ">
  5059. AND tu.mr_status = #{mrStatus}
  5060. </if>
  5061. <if test="chName != null and chName !=''">
  5062. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5063. </if>
  5064. <if test="mrName != null and mrName !=''">
  5065. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5066. </if>
  5067. <if test="chTimeStart != null">
  5068. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5069. </if>
  5070. <if test="chTimeEnd != null">
  5071. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5072. </if>
  5073. <if test="mrTimeStart != null">
  5074. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5075. </if>
  5076. <if test="mrTimeEnd != null">
  5077. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5078. </if>
  5079. </select>
  5080. <!-- 医疗组质控评分导出到excel-->
  5081. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  5082. SELECT * FROM (
  5083. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  5084. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  5085. g.check_type AS ch_type,
  5086. h.check_type AS mr_type,
  5087. g.check_name AS ch_name,
  5088. h.check_name AS mr_name,
  5089. g.check_time AS ch_time,
  5090. h.check_time AS mr_time
  5091. FROM (
  5092. SELECT
  5093. t1.behDeptId,
  5094. t1.behDeptName,
  5095. t1.doctorName,
  5096. t1.patName,
  5097. t1.behospitalCode,
  5098. t1.hospitalId,
  5099. t1.behospitalDate,
  5100. t1.leaveHospitalDate,
  5101. t1.score,
  5102. t2.avgScore,
  5103. <if test="radioCheck !=null and radioCheck == 1">
  5104. t1.msg,
  5105. t1.caseName,
  5106. </if>
  5107. e.score_res as scoreBn
  5108. FROM
  5109. (
  5110. SELECT
  5111. a.doctor_name AS doctorName,
  5112. a.`name` AS patName,
  5113. a.behospital_code AS behospitalCode,
  5114. a.behospital_date AS behospitalDate,
  5115. a.leave_hospital_date AS leaveHospitalDate,
  5116. b.score_res AS score,
  5117. <if test="radioCheck !=null and radioCheck == 1">
  5118. c.msg AS msg,
  5119. d.NAME AS caseName,
  5120. </if>
  5121. a.beh_dept_id AS behDeptId,
  5122. a.beh_dept_name AS behDeptName,
  5123. a.hospital_id AS hospitalId
  5124. FROM
  5125. med_behospital_info a,
  5126. med_qcresult_info b,
  5127. med_qcresult_detail c,
  5128. qc_cases d
  5129. WHERE
  5130. a.is_deleted = 'N'
  5131. AND b.is_deleted = 'N'
  5132. AND c.is_deleted = 'N'
  5133. AND d.is_deleted = 'N'
  5134. AND a.hospital_id = b.hospital_id
  5135. AND a.hospital_id = c.hospital_id
  5136. AND a.behospital_code = b.behospital_code
  5137. AND a.behospital_code = c.behospital_code
  5138. AND c.cases_id = d.id
  5139. <if test="isPlacefile != null and isPlacefile != ''">
  5140. and a.is_placefile = #{isPlacefile}
  5141. </if>
  5142. AND a.doctor_id in
  5143. (SELECT doctor_id FROM `bas_doctor_info`
  5144. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5145. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5146. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5147. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5148. and c1.username = c3.doctor_id
  5149. and c2.hospital_id = #{hospitalId}
  5150. and c1.id = #{userId}
  5151. ))
  5152. <![CDATA[AND a.qc_type_id <>0 ]]>
  5153. <if test="hospitalId != null and hospitalId != ''">
  5154. AND a.hospital_id = #{hospitalId}
  5155. </if>
  5156. <if test="diagnose != null and diagnose != ''">
  5157. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5158. </if>
  5159. <if test="behosDateStart != null">
  5160. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5161. </if>
  5162. <if test="behosDateEnd != null">
  5163. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5164. </if>
  5165. <if test="leaveHosDateStart != null ">
  5166. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5167. </if>
  5168. <if test="leaveHosDateEnd != null ">
  5169. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5170. </if>
  5171. <if test="behospitalCode != null and behospitalCode != ''">
  5172. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5173. </if>
  5174. <if test="level != null and level != ''">
  5175. AND b.level = #{level}
  5176. </if>
  5177. <if test="doctorName != null and doctorName != ''">
  5178. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5179. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5180. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5181. </if>
  5182. <if test="doctorCode != null and doctorCode != ''">
  5183. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5184. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5185. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5186. </if>
  5187. <if test="deptId != null and deptId != ''">
  5188. AND a.beh_dept_id = #{deptId}
  5189. </if>
  5190. <if test="name != null and name != ''">
  5191. AND a.name like CONCAT('%',#{name},'%')
  5192. </if>
  5193. ) t1 LEFT JOIN med_qcresult_cases e
  5194. on t1.behospitalCode = e.behospital_code
  5195. and t1.hospitalId = e.hospital_id
  5196. AND e.is_deleted = 'N'
  5197. and e.cases_id = 243,
  5198. (
  5199. SELECT
  5200. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5201. a.beh_dept_id AS behDeptId,
  5202. a.beh_dept_name AS behDeptName
  5203. FROM
  5204. med_behospital_info a,
  5205. med_qcresult_info b
  5206. WHERE
  5207. a.is_deleted = 'N'
  5208. AND a.doctor_id in
  5209. (SELECT doctor_id FROM `bas_doctor_info`
  5210. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5211. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5212. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5213. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5214. and c1.username = c3.doctor_id
  5215. and c2.hospital_id = #{hospitalId}
  5216. and c1.id = #{userId}
  5217. ))
  5218. AND b.is_deleted = 'N'
  5219. AND a.hospital_id = b.hospital_id
  5220. AND a.behospital_code = b.behospital_code
  5221. <if test="diagnose != null and diagnose != ''">
  5222. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5223. </if>
  5224. <if test="isPlacefile != null and isPlacefile != ''">
  5225. and a.is_placefile = #{isPlacefile}
  5226. </if>
  5227. <![CDATA[AND a.qc_type_id <>0 ]]>
  5228. <if test="hospitalId != null and hospitalId != ''">
  5229. AND a.hospital_id = #{hospitalId}
  5230. </if>
  5231. <if test="behosDateStart != null">
  5232. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5233. </if>
  5234. <if test="behosDateEnd != null">
  5235. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5236. </if>
  5237. <if test="leaveHosDateStart != null ">
  5238. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5239. </if>
  5240. <if test="leaveHosDateEnd != null ">
  5241. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5242. </if>
  5243. <if test="behospitalCode != null and behospitalCode != ''">
  5244. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5245. </if>
  5246. <if test="level != null and level != ''">
  5247. AND b.level = #{level}
  5248. </if>
  5249. <if test="doctorName != null and doctorName != ''">
  5250. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5251. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5252. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5253. </if>
  5254. <if test="doctorCode != null and doctorCode != ''">
  5255. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5256. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5257. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5258. </if>
  5259. <if test="deptId != null and deptId != ''">
  5260. AND a.beh_dept_id = #{deptId}
  5261. </if>
  5262. <if test="name != null and name != ''">
  5263. AND a.name like CONCAT('%',#{name},'%')
  5264. </if>
  5265. GROUP BY
  5266. a.beh_dept_id,
  5267. a.beh_dept_name
  5268. ) t2
  5269. WHERE
  5270. t1.behDeptId = t2.behDeptId
  5271. AND t1.behDeptName = t2.behDeptName
  5272. ORDER BY
  5273. t1.behDeptName,
  5274. t1.doctorName,
  5275. t1.patName,
  5276. <if test="radioCheck !=null and radioCheck == 1">
  5277. t1.caseName,
  5278. </if>
  5279. t1.behospitalCode
  5280. )tp
  5281. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5282. ON tp.behospitalCode = g.behospital_code
  5283. AND tp.hospitalId = g.hospital_id
  5284. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5285. ON tp.behospitalCode = h.behospital_code
  5286. AND tp.hospitalId = h.hospital_id
  5287. ) tu
  5288. WHERE tu.behospitalCode IS NOT NULL
  5289. <if test="checkStatus != null ">
  5290. and tu.check_status = #{checkStatus}
  5291. </if>
  5292. <if test="mrStatus != null ">
  5293. AND tu.mr_status = #{mrStatus}
  5294. </if>
  5295. <if test="chName != null and chName !=''">
  5296. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5297. </if>
  5298. <if test="mrName != null and mrName !=''">
  5299. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5300. </if>
  5301. <if test="chTimeStart != null">
  5302. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5303. </if>
  5304. <if test="chTimeEnd != null">
  5305. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5306. </if>
  5307. <if test="mrTimeStart != null">
  5308. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5309. </if>
  5310. <if test="mrTimeEnd != null">
  5311. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5312. </if>
  5313. </select>
  5314. <!-- 条目缺陷质控评分页(内页)-->
  5315. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5316. SELECT t.*
  5317. FROM
  5318. (SELECT DISTINCT
  5319. t1.hospital_id AS hospitalId,
  5320. t1.behospital_code AS behospitalCode,
  5321. t1.bed_code AS bedCode,
  5322. t1.LEVEL AS LEVEL,
  5323. t1.grade_type AS gradeType,
  5324. t1.score_res AS scoreRes,
  5325. t1.scoreBn,
  5326. t1.NAME AS NAME,
  5327. t1.sex AS sex,
  5328. t1.beh_dept_id AS behDeptId,
  5329. t1.beh_dept_name AS behDeptName,
  5330. t1.doctor_id AS doctorId,
  5331. t1.doctor_name AS doctorName,
  5332. t1.beh_doctor_id AS behDoctorId,
  5333. t1.beh_doctor_name AS behDoctorName,
  5334. t1.director_doctor_id AS directorDoctorId,
  5335. t1.director_doctor_name AS directorDoctorName,
  5336. t1.birthday AS birthday,
  5337. t1.behospital_date AS behospitalDate,
  5338. t1.leave_hospital_date AS leaveHospitalDate,
  5339. t1.placefile_date AS placefileDate,
  5340. t1.gmt_create AS gradeTime,
  5341. t1.diagnose,
  5342. t1.ward_name AS wardName,
  5343. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5344. t1.file_code AS fileCode,
  5345. t1.checkStatus,
  5346. t1.mrStatus,
  5347. t1.chName,
  5348. t1.mrName,
  5349. t1.chTime,
  5350. t1.mrTime
  5351. FROM
  5352. (
  5353. SELECT DISTINCT
  5354. tt1.*
  5355. FROM
  5356. (SELECT
  5357. be.*,
  5358. ifnull(mci.status,0) AS checkStatus,
  5359. ifnull(hm_mci.status,0) AS mrStatus,
  5360. mci.check_name as chName,
  5361. e.score_res as scoreBn,
  5362. hm_mci.check_name as mrName,
  5363. mci.gmt_create as chTime,
  5364. hm_mci.gmt_create as mrTime
  5365. FROM
  5366. (
  5367. SELECT DISTINCT
  5368. a.hospital_id,
  5369. a.behospital_code,
  5370. a.bed_code,
  5371. a.file_code,
  5372. b.LEVEL,
  5373. b.grade_type,
  5374. b.score_res,
  5375. a.NAME,
  5376. a.sex,
  5377. a.beh_dept_id,
  5378. a.beh_dept_name,
  5379. a.birthday,
  5380. a.behospital_date,
  5381. a.leave_hospital_date,
  5382. a.doctor_id,
  5383. a.doctor_name,
  5384. a.beh_doctor_id,
  5385. a.beh_doctor_name,
  5386. a.director_doctor_id,
  5387. a.director_doctor_name,
  5388. a.diagnose,
  5389. a.placefile_date,
  5390. a.ward_name,
  5391. b.gmt_create
  5392. FROM
  5393. med_behospital_info a,
  5394. med_qcresult_info b,
  5395. med_qcresult_detail c,
  5396. qc_cases_entry d
  5397. WHERE
  5398. a.is_deleted = 'N'
  5399. AND b.is_deleted = 'N'
  5400. AND c.is_deleted = 'N'
  5401. AND d.is_deleted = 'N'
  5402. AND a.hospital_id = b.hospital_id
  5403. AND a.hospital_id = c.hospital_id
  5404. AND a.behospital_code = b.behospital_code
  5405. AND a.behospital_code = c.behospital_code
  5406. AND c.cases_id = d.cases_id
  5407. AND c.cases_entry_id = d.id
  5408. AND a.qc_type_id != 0
  5409. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5410. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5411. </if>
  5412. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5413. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5414. </if>
  5415. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5416. <if test="qcResultShortPageVO.startDate != null ">
  5417. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5418. </if>
  5419. <if test="qcResultShortPageVO.endDate != null ">
  5420. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5421. </if>
  5422. </if>
  5423. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5424. <if test="qcResultShortPageVO.startDate != null ">
  5425. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5426. </if>
  5427. <if test="qcResultShortPageVO.endDate != null">
  5428. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5429. </if>
  5430. </if>
  5431. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5432. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5433. </if>
  5434. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5435. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5436. </if>
  5437. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5438. AND b.`level` = #{qcResultShortPageVO.level}
  5439. </if>
  5440. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5441. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5442. </if>
  5443. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5444. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5445. </if>
  5446. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5447. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5448. </if>
  5449. <if test="qcResultShortPageVO.casesEntryId != null ">
  5450. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5451. </if>
  5452. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5453. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5454. </if>
  5455. <if test="qcResultShortPageVO.casesId != null">
  5456. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5457. </if>
  5458. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5459. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5460. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5461. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5462. </if>
  5463. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5464. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5465. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5466. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5467. </if>
  5468. <if test="qcResultShortPageVO.isReject != null">
  5469. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5470. </if>
  5471. <if test="qcResultShortPageVO.ruleType != null">
  5472. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5473. </if>
  5474. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5475. AND TIMESTAMPDIFF(
  5476. DAY,
  5477. DATE( a.behospital_date ),
  5478. DATE( a.leave_hospital_date ))> 30
  5479. </if>
  5480. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5481. AND TIMESTAMPDIFF(
  5482. DAY,
  5483. DATE( a.behospital_date ),
  5484. DATE( a.leave_hospital_date ))> 31
  5485. </if>
  5486. )be
  5487. left join med_check_info mci
  5488. on mci.is_deleted = 'N'
  5489. and mci.check_type = 0
  5490. and be.hospital_id = mci.hospital_id
  5491. and be.behospital_code = mci.behospital_code
  5492. left join med_check_info hm_mci
  5493. on hm_mci.is_deleted = 'N'
  5494. and hm_mci.check_type = 1
  5495. and be.hospital_id = hm_mci.hospital_id
  5496. and be.behospital_code = hm_mci.behospital_code
  5497. LEFT JOIN med_qcresult_cases e
  5498. on be.behospital_code = e.behospital_code
  5499. and be.hospital_id = e.hospital_id
  5500. AND e.is_deleted = 'N'
  5501. and e.cases_id = 243
  5502. )tt1
  5503. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5504. ,med_medical_record tt2
  5505. WHERE
  5506. tt2.is_deleted = 'N'
  5507. AND tt1.hospital_id = tt2.hospital_id
  5508. AND tt1.behospital_code = tt2.behospital_code
  5509. AND tt2.mode_id = 30
  5510. </if>
  5511. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5512. ,med_crisis_info tt2
  5513. WHERE
  5514. tt2.is_deleted = 'N'
  5515. AND tt1.hospital_id = tt2.hospital_id
  5516. AND tt1.behospital_code = tt2.behospital_code
  5517. </if>
  5518. ) t1
  5519. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5520. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5521. AND t1.behospital_code = t2.behospital_code
  5522. AND t2.is_deleted = 'N'
  5523. </if>
  5524. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5525. , med_home_page t2
  5526. , med_home_operation_info t3
  5527. WHERE t1.hospital_id = t2.hospital_id
  5528. AND t1.behospital_code = t2.behospital_code
  5529. AND t2.home_page_id = t3.home_page_id
  5530. AND t2.is_deleted = 'N'
  5531. AND t3.is_deleted = 'N'
  5532. </if>
  5533. ) t
  5534. where 1=1
  5535. <if test="qcResultShortPageVO.checkStatus != null">
  5536. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5537. </if>
  5538. <if test="qcResultShortPageVO.mrStatus != null">
  5539. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5540. </if>
  5541. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5542. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5543. </if>
  5544. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5545. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5546. </if>
  5547. <if test="qcResultShortPageVO.chTimeStart != null ">
  5548. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5549. </if>
  5550. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5551. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5552. </if>
  5553. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5554. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5555. </if>
  5556. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5557. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5558. </if>
  5559. </select>
  5560. <!-- 条目缺陷质控评分页-科室(内页)-->
  5561. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5562. SELECT t.*
  5563. FROM
  5564. (SELECT DISTINCT
  5565. t1.hospital_id AS hospitalId,
  5566. t1.behospital_code AS behospitalCode,
  5567. t1.bed_code AS bedCode,
  5568. t1.LEVEL AS LEVEL,
  5569. t1.grade_type AS gradeType,
  5570. t1.score_res AS scoreRes,
  5571. t1.scoreBn,
  5572. t1.NAME AS NAME,
  5573. t1.sex AS sex,
  5574. t1.beh_dept_id AS behDeptId,
  5575. t1.beh_dept_name AS behDeptName,
  5576. t1.doctor_id AS doctorId,
  5577. t1.doctor_name AS doctorName,
  5578. t1.beh_doctor_id AS behDoctorId,
  5579. t1.beh_doctor_name AS behDoctorName,
  5580. t1.director_doctor_id AS directorDoctorId,
  5581. t1.director_doctor_name AS directorDoctorName,
  5582. t1.birthday AS birthday,
  5583. t1.behospital_date AS behospitalDate,
  5584. t1.leave_hospital_date AS leaveHospitalDate,
  5585. t1.placefile_date AS placefileDate,
  5586. t1.gmt_create AS gradeTime,
  5587. t1.diagnose,
  5588. t1.ward_name AS wardName,
  5589. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5590. t1.file_code AS fileCode,
  5591. t1.checkStatus,
  5592. t1.mrStatus,
  5593. t1.chName,
  5594. t1.mrName,
  5595. t1.chTime,
  5596. t1.mrTime
  5597. FROM
  5598. (
  5599. SELECT DISTINCT
  5600. tt1.*
  5601. FROM
  5602. (SELECT
  5603. be.*,
  5604. ifnull(mci.status,0) AS checkStatus,
  5605. ifnull(hm_mci.status,0) AS mrStatus,
  5606. mci.check_name as chName,
  5607. e.score_res as scoreBn,
  5608. hm_mci.check_name as mrName,
  5609. mci.gmt_create as chTime,
  5610. hm_mci.gmt_create as mrTime
  5611. FROM
  5612. (
  5613. SELECT DISTINCT
  5614. a.hospital_id,
  5615. a.behospital_code,
  5616. a.bed_code,
  5617. a.file_code,
  5618. b.LEVEL,
  5619. b.grade_type,
  5620. b.score_res,
  5621. a.NAME,
  5622. a.sex,
  5623. a.beh_dept_id,
  5624. a.beh_dept_name,
  5625. a.birthday,
  5626. a.behospital_date,
  5627. a.leave_hospital_date,
  5628. a.doctor_id,
  5629. a.doctor_name,
  5630. a.beh_doctor_id,
  5631. a.beh_doctor_name,
  5632. a.director_doctor_id,
  5633. a.director_doctor_name,
  5634. a.diagnose,
  5635. a.placefile_date,
  5636. a.ward_name,
  5637. b.gmt_create
  5638. FROM
  5639. med_behospital_info a,
  5640. med_qcresult_info b,
  5641. med_qcresult_detail c,
  5642. qc_cases_entry d,
  5643. sys_user_dept e
  5644. WHERE
  5645. a.is_deleted = 'N'
  5646. AND b.is_deleted = 'N'
  5647. AND c.is_deleted = 'N'
  5648. AND d.is_deleted = 'N'
  5649. AND e.is_deleted = 'N'
  5650. AND a.hospital_id = b.hospital_id
  5651. AND a.hospital_id = c.hospital_id
  5652. AND a.hospital_id = e.hospital_id
  5653. AND a.behospital_code = b.behospital_code
  5654. AND a.behospital_code = c.behospital_code
  5655. AND a.beh_dept_id = e.dept_id
  5656. AND c.cases_id = d.cases_id
  5657. AND c.cases_entry_id = d.id
  5658. AND a.qc_type_id != 0
  5659. <if test="qcResultShortPageVO.userId!=null">
  5660. AND e.user_id = #{qcResultShortPageVO.userId}
  5661. </if>
  5662. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5663. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5664. </if>
  5665. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5666. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5667. </if>
  5668. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5669. <if test="qcResultShortPageVO.startDate != null ">
  5670. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5671. </if>
  5672. <if test="qcResultShortPageVO.endDate != null ">
  5673. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5674. </if>
  5675. </if>
  5676. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5677. <if test="qcResultShortPageVO.startDate != null ">
  5678. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5679. </if>
  5680. <if test="qcResultShortPageVO.endDate != null">
  5681. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5682. </if>
  5683. </if>
  5684. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5685. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5686. </if>
  5687. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5688. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5689. </if>
  5690. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5691. AND b.`level` = #{qcResultShortPageVO.level}
  5692. </if>
  5693. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5694. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5695. </if>
  5696. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5697. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5698. </if>
  5699. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5700. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5701. </if>
  5702. <if test="qcResultShortPageVO.casesEntryId != null ">
  5703. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5704. </if>
  5705. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5706. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5707. </if>
  5708. <if test="qcResultShortPageVO.casesId != null">
  5709. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5710. </if>
  5711. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5712. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5713. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5714. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5715. </if>
  5716. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5717. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5718. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5719. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5720. </if>
  5721. <if test="qcResultShortPageVO.isReject != null">
  5722. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5723. </if>
  5724. <if test="qcResultShortPageVO.ruleType != null">
  5725. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5726. </if>
  5727. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5728. AND TIMESTAMPDIFF(
  5729. DAY,
  5730. DATE( a.behospital_date ),
  5731. DATE( a.leave_hospital_date ))> 30
  5732. </if>
  5733. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5734. AND TIMESTAMPDIFF(
  5735. DAY,
  5736. DATE( a.behospital_date ),
  5737. DATE( a.leave_hospital_date ))> 31
  5738. </if>
  5739. )be
  5740. left join med_check_info mci
  5741. on mci.is_deleted = 'N'
  5742. and mci.check_type = 0
  5743. and be.hospital_id = mci.hospital_id
  5744. and be.behospital_code = mci.behospital_code
  5745. left join med_check_info hm_mci
  5746. on hm_mci.is_deleted = 'N'
  5747. and hm_mci.check_type = 1
  5748. and be.hospital_id = hm_mci.hospital_id
  5749. and be.behospital_code = hm_mci.behospital_code
  5750. LEFT JOIN med_qcresult_cases e
  5751. on be.behospital_code = e.behospital_code
  5752. and be.hospital_id = e.hospital_id
  5753. AND e.is_deleted = 'N'
  5754. and e.cases_id = 243
  5755. )tt1
  5756. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5757. ,med_medical_record tt2
  5758. WHERE
  5759. tt2.is_deleted = 'N'
  5760. AND tt1.hospital_id = tt2.hospital_id
  5761. AND tt1.behospital_code = tt2.behospital_code
  5762. AND tt2.mode_id = 30
  5763. </if>
  5764. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5765. ,med_crisis_info tt2
  5766. WHERE
  5767. tt2.is_deleted = 'N'
  5768. AND tt1.hospital_id = tt2.hospital_id
  5769. AND tt1.behospital_code = tt2.behospital_code
  5770. </if>
  5771. ) t1
  5772. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5773. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5774. AND t1.behospital_code = t2.behospital_code
  5775. AND t2.is_deleted = 'N'
  5776. </if>
  5777. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5778. , med_home_page t2
  5779. , med_home_operation_info t3
  5780. WHERE t1.hospital_id = t2.hospital_id
  5781. AND t1.behospital_code = t2.behospital_code
  5782. AND t2.home_page_id = t3.home_page_id
  5783. AND t2.is_deleted = 'N'
  5784. AND t3.is_deleted = 'N'
  5785. </if>
  5786. ) t
  5787. where 1=1
  5788. <if test="qcResultShortPageVO.checkStatus != null">
  5789. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5790. </if>
  5791. <if test="qcResultShortPageVO.mrStatus != null">
  5792. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5793. </if>
  5794. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5795. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5796. </if>
  5797. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5798. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5799. </if>
  5800. <if test="qcResultShortPageVO.chTimeStart != null ">
  5801. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5802. </if>
  5803. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5804. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5805. </if>
  5806. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5807. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5808. </if>
  5809. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5810. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5811. </if>
  5812. </select>
  5813. <update id="updateBatchByKey">
  5814. <foreach collection="list" item="item" separator=";">
  5815. update med_behospital_info
  5816. <set>
  5817. <if test="item.name != null">
  5818. name = #{item.name},
  5819. </if>
  5820. <if test="item.sex != null">
  5821. sex = #{item.sex},
  5822. </if>
  5823. <if test="item.birthday != null">
  5824. birthday = #{item.birthday},
  5825. </if>
  5826. <if test="item.fileCode != null">
  5827. file_code = #{item.fileCode},
  5828. </if>
  5829. <if test="item.qcTypeId != null">
  5830. qc_type_id = #{item.qcTypeId},
  5831. </if>
  5832. <if test="item.wardCode != null">
  5833. ward_code = #{item.wardCode},
  5834. </if>
  5835. <if test="item.wardName != null">
  5836. ward_name = #{item.wardName},
  5837. </if>
  5838. <if test="item.behDeptId != null">
  5839. beh_dept_id = #{item.behDeptId},
  5840. </if>
  5841. <if test="item.behDeptName != null">
  5842. beh_dept_name = #{item.behDeptName},
  5843. </if>
  5844. <if test="item.bedCode != null">
  5845. bed_code = #{item.bedCode},
  5846. </if>
  5847. <if test="item.bedName != null">
  5848. bed_name = #{item.bedName},
  5849. </if>
  5850. <if test="item.insuranceName != null">
  5851. insurance_name = #{item.insuranceName},
  5852. </if>
  5853. <if test="item.jobType != null">
  5854. job_type = #{item.jobType},
  5855. </if>
  5856. <if test="item.behospitalDate != null">
  5857. behospital_date = #{item.behospitalDate},
  5858. </if>
  5859. <if test="item.leaveHospitalDate != null">
  5860. leave_hospital_date = #{item.leaveHospitalDate},
  5861. </if>
  5862. <if test="item.diagnoseIcd != null">
  5863. diagnose_icd = #{item.diagnoseIcd},
  5864. </if>
  5865. <if test="item.diagnose != null">
  5866. diagnose = #{item.diagnose},
  5867. </if>
  5868. <if test="item.behDoctorId != null">
  5869. beh_doctor_id = #{item.behDoctorId},
  5870. </if>
  5871. <if test="item.behDoctorName != null">
  5872. beh_doctor_name = #{item.behDoctorName},
  5873. </if>
  5874. <if test="item.doctorId != null">
  5875. doctor_id = #{item.doctorId},
  5876. </if>
  5877. <if test="item.doctorName != null">
  5878. doctor_name = #{item.doctorName},
  5879. </if>
  5880. <if test="item.directorDoctorId != null">
  5881. director_doctor_id = #{item.directorDoctorId},
  5882. </if>
  5883. <if test="item.directorDoctorName != null">
  5884. director_doctor_name = #{item.directorDoctorName},
  5885. </if>
  5886. <if test="item.placefileDate != null">
  5887. placefile_date = #{item.placefileDate},
  5888. </if>
  5889. <if test="item.isPlacefile != null">
  5890. is_placefile = #{item.isPlacefile},
  5891. </if>
  5892. <if test="item.gmtModified != null">
  5893. gmt_modified = #{item.gmtModified},
  5894. </if>
  5895. <if test="item.modifier != null">
  5896. modifier = #{item.modifier},
  5897. </if>
  5898. </set>
  5899. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  5900. </foreach>
  5901. </update>
  5902. <!-- 关键条目缺陷统计报表-->
  5903. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  5904. SELECT
  5905. deptId,
  5906. deptName,
  5907. consultationMRNum,
  5908. consultationNum,
  5909. 2511 AS consultationEntryId,
  5910. '普通会诊未在24小时内完成' AS consultationEntryName,
  5911. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  5912. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  5913. operationMRNum,
  5914. 2594 AS operationNameEntryId,
  5915. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  5916. operationNameNum,
  5917. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  5918. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  5919. 2973 AS operationTimeEntryId,
  5920. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  5921. operationTimeNum,
  5922. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  5923. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  5924. 2930 AS operation15MinuteEntryId,
  5925. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  5926. operation15MinuteNum,
  5927. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  5928. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  5929. 2419 AS crisisEntryId,
  5930. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  5931. crisisMRNum,
  5932. crisisNum,
  5933. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  5934. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  5935. 2495 AS stageSummaryEntryId,
  5936. '无阶段小结' AS stageSummaryEntryName,
  5937. stageSummaryMRNum,
  5938. stageSummaryNum,
  5939. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  5940. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  5941. beHosGT31DaysMRNum
  5942. FROM
  5943. (
  5944. SELECT
  5945. tt.deptId,
  5946. tt.deptName,
  5947. sum( tt.consultationNum ) AS consultationNum,
  5948. sum( tt.consultationMRNum ) AS consultationMRNum,
  5949. sum( tt.operationNameNum ) AS operationNameNum,
  5950. sum( tt.operationTimeNum ) AS operationTimeNum,
  5951. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  5952. sum( tt.operationMRNum ) AS operationMRNum,
  5953. sum( tt.crisisNum ) AS crisisNum,
  5954. sum( tt.crisisMRNum ) AS crisisMRNum,
  5955. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  5956. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  5957. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  5958. FROM
  5959. (
  5960. (
  5961. SELECT
  5962. c.beh_dept_id AS deptId,
  5963. c.beh_dept_name AS deptName,
  5964. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  5965. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  5966. 0 AS operationNameNum,
  5967. 0 AS operationTimeNum,
  5968. 0 AS operation15MinuteNum,
  5969. 0 AS operationMRNum,
  5970. 0 AS crisisNum,
  5971. 0 AS crisisMRNum,
  5972. 0 AS stageSummaryNum,
  5973. 0 AS stageSummaryMRNum,
  5974. 0 AS beHosGT31DaysMRNum
  5975. FROM
  5976. (
  5977. SELECT DISTINCT
  5978. a.hospital_id,
  5979. a.behospital_code,
  5980. a.beh_dept_name,
  5981. a.beh_dept_id
  5982. FROM
  5983. med_behospital_info a,
  5984. med_medical_record b
  5985. WHERE
  5986. a.is_deleted = 'N'
  5987. AND b.is_deleted = 'N'
  5988. AND a.hospital_id = b.hospital_id
  5989. AND a.behospital_code = b.behospital_code
  5990. AND b.mode_id = 30
  5991. <if test="isPlacefile != null and isPlacefile != ''">
  5992. and a.is_placefile = #{isPlacefile}
  5993. </if>
  5994. AND a.qc_type_id != 0
  5995. <if test="hospitalId != null and hospitalId != ''">
  5996. AND a.hospital_id = #{hospitalId}
  5997. </if>
  5998. <if test="isPlacefile != null and isPlacefile == 0">
  5999. <if test="startDate != null ">
  6000. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6001. </if>
  6002. <if test="endDate != null ">
  6003. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6004. </if>
  6005. </if>
  6006. <if test="isPlacefile != null and isPlacefile == 1">
  6007. <if test="startDate != null ">
  6008. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6009. </if>
  6010. <if test="endDate != null ">
  6011. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6012. </if>
  6013. </if>
  6014. <if test="deptName != null and deptName != ''">
  6015. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6016. </if>
  6017. ) c
  6018. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6019. AND c.hospital_id = d.hospital_id
  6020. AND c.behospital_code = d.behospital_code
  6021. GROUP BY
  6022. c.beh_dept_id,
  6023. c.beh_dept_name
  6024. ) UNION
  6025. (
  6026. SELECT
  6027. d.beh_dept_id AS deptId,
  6028. d.beh_dept_name AS deptName,
  6029. 0 AS consultationNum,
  6030. 0 AS consultationMRNum,
  6031. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6032. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6033. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6034. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6035. 0 AS crisisNum,
  6036. 0 AS crisisMRNum,
  6037. 0 AS stageSummaryNum,
  6038. 0 AS stageSummaryMRNum,
  6039. 0 AS beHosGT31DaysMRNum
  6040. FROM
  6041. (
  6042. SELECT DISTINCT
  6043. a.hospital_id,
  6044. a.behospital_code,
  6045. a.beh_dept_name,
  6046. a.beh_dept_id
  6047. FROM
  6048. med_behospital_info a,
  6049. med_home_page b,
  6050. med_home_operation_info c
  6051. WHERE
  6052. a.is_deleted = 'N'
  6053. AND b.is_deleted = 'N'
  6054. AND c.is_deleted = 'N'
  6055. AND a.hospital_id = b.hospital_id
  6056. AND a.hospital_id = c.hospital_id
  6057. AND a.behospital_code = b.behospital_code
  6058. AND b.home_page_id = c.home_page_id
  6059. <if test="isPlacefile != null and isPlacefile != ''">
  6060. and a.is_placefile = #{isPlacefile}
  6061. </if>
  6062. AND a.qc_type_id != 0
  6063. <if test="hospitalId != null and hospitalId != ''">
  6064. AND a.hospital_id = #{hospitalId}
  6065. </if>
  6066. <if test="isPlacefile != null and isPlacefile == 0">
  6067. <if test="startDate != null ">
  6068. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6069. </if>
  6070. <if test="endDate != null ">
  6071. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6072. </if>
  6073. </if>
  6074. <if test="isPlacefile != null and isPlacefile == 1">
  6075. <if test="startDate != null ">
  6076. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6077. </if>
  6078. <if test="endDate != null ">
  6079. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6080. </if>
  6081. </if>
  6082. <if test="deptName != null and deptName != ''">
  6083. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6084. </if>
  6085. ) d
  6086. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6087. AND d.hospital_id = e.hospital_id
  6088. AND d.behospital_code = e.behospital_code
  6089. GROUP BY
  6090. d.beh_dept_id,
  6091. d.beh_dept_name
  6092. ) UNION
  6093. (
  6094. SELECT
  6095. c.beh_dept_id AS deptId,
  6096. c.beh_dept_name AS deptName,
  6097. 0 AS consultationNum,
  6098. 0 AS consultationMRNum,
  6099. 0 AS operationNameNum,
  6100. 0 AS operationTimeNum,
  6101. 0 AS operation15MinuteNum,
  6102. 0 AS operationMRNum,
  6103. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6104. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6105. 0 AS stageSummaryNum,
  6106. 0 AS stageSummaryMRNum,
  6107. 0 AS beHosGT31DaysMRNum
  6108. FROM
  6109. (
  6110. SELECT DISTINCT
  6111. a.hospital_id,
  6112. a.behospital_code,
  6113. a.beh_dept_name,
  6114. a.beh_dept_id
  6115. FROM
  6116. med_behospital_info a,
  6117. med_crisis_info b
  6118. WHERE
  6119. a.is_deleted = 'N'
  6120. AND b.is_deleted = 'N'
  6121. AND a.hospital_id = b.hospital_id
  6122. AND a.behospital_code = b.behospital_code
  6123. <if test="isPlacefile != null and isPlacefile != ''">
  6124. and a.is_placefile = #{isPlacefile}
  6125. </if>
  6126. AND a.qc_type_id != 0
  6127. <if test="hospitalId != null and hospitalId != ''">
  6128. AND a.hospital_id = #{hospitalId}
  6129. </if>
  6130. <if test="isPlacefile != null and isPlacefile == 0">
  6131. <if test="startDate != null ">
  6132. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6133. </if>
  6134. <if test="endDate != null ">
  6135. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6136. </if>
  6137. </if>
  6138. <if test="isPlacefile != null and isPlacefile == 1">
  6139. <if test="startDate != null ">
  6140. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6141. </if>
  6142. <if test="endDate != null ">
  6143. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6144. </if>
  6145. </if>
  6146. <if test="deptName != null and deptName != ''">
  6147. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6148. </if>
  6149. ) c
  6150. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6151. AND c.hospital_id = d.hospital_id
  6152. AND c.behospital_code = d.behospital_code
  6153. GROUP BY
  6154. c.beh_dept_id,
  6155. c.beh_dept_name
  6156. ) UNION
  6157. (
  6158. SELECT
  6159. b.beh_dept_id AS deptId,
  6160. b.beh_dept_name AS deptName,
  6161. 0 AS consultationNum,
  6162. 0 AS consultationMRNum,
  6163. 0 AS operationNameNum,
  6164. 0 AS operationTimeNum,
  6165. 0 AS operation15MinuteNum,
  6166. 0 AS operationMRNum,
  6167. 0 AS crisisNum,
  6168. 0 AS crisisMRNum,
  6169. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6170. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6171. 0 AS beHosGT31DaysMRNum
  6172. FROM
  6173. (
  6174. SELECT DISTINCT
  6175. a.hospital_id,
  6176. a.behospital_code,
  6177. a.beh_dept_name,
  6178. a.beh_dept_id
  6179. FROM
  6180. med_behospital_info a
  6181. WHERE
  6182. a.is_deleted = 'N'
  6183. AND TIMESTAMPDIFF(
  6184. DAY,
  6185. DATE( behospital_date ),
  6186. DATE( leave_hospital_date ))> 30
  6187. <if test="isPlacefile != null and isPlacefile != ''">
  6188. and a.is_placefile = #{isPlacefile}
  6189. </if>
  6190. AND a.qc_type_id != 0
  6191. <if test="hospitalId != null and hospitalId != ''">
  6192. AND a.hospital_id = #{hospitalId}
  6193. </if>
  6194. <if test="isPlacefile != null and isPlacefile == 0">
  6195. <if test="startDate != null ">
  6196. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6197. </if>
  6198. <if test="endDate != null ">
  6199. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6200. </if>
  6201. </if>
  6202. <if test="isPlacefile != null and isPlacefile == 1">
  6203. <if test="startDate != null ">
  6204. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6205. </if>
  6206. <if test="endDate != null ">
  6207. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6208. </if>
  6209. </if>
  6210. <if test="deptName != null and deptName != ''">
  6211. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6212. </if>
  6213. ) b
  6214. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6215. AND b.hospital_id = c.hospital_id
  6216. AND b.behospital_code = c.behospital_code
  6217. GROUP BY
  6218. b.beh_dept_id,
  6219. b.beh_dept_name
  6220. ) UNION
  6221. (
  6222. SELECT
  6223. b.beh_dept_id AS deptId,
  6224. b.beh_dept_name AS deptName,
  6225. 0 AS consultationNum,
  6226. 0 AS consultationMRNum,
  6227. 0 AS operationNameNum,
  6228. 0 AS operationTimeNum,
  6229. 0 AS operation15MinuteNum,
  6230. 0 AS operationMRNum,
  6231. 0 AS crisisNum,
  6232. 0 AS crisisMRNum,
  6233. 0 AS stageSummaryNum,
  6234. 0 AS stageSummaryMRNum,
  6235. count(*) AS beHosGT31DaysMRNum
  6236. FROM
  6237. (
  6238. SELECT DISTINCT
  6239. a.hospital_id,
  6240. a.behospital_code,
  6241. a.beh_dept_name,
  6242. a.beh_dept_id
  6243. FROM
  6244. med_behospital_info a,
  6245. med_qcresult_info b,
  6246. med_qcresult_detail c,
  6247. qc_cases_entry d
  6248. WHERE
  6249. a.is_deleted = 'N'
  6250. AND b.is_deleted = 'N'
  6251. AND c.is_deleted = 'N'
  6252. AND d.is_deleted = 'N'
  6253. AND a.hospital_id = b.hospital_id
  6254. AND a.hospital_id = c.hospital_id
  6255. AND a.behospital_code = b.behospital_code
  6256. AND a.behospital_code = c.behospital_code
  6257. AND c.cases_id = d.cases_id
  6258. AND c.cases_entry_id = d.id
  6259. AND TIMESTAMPDIFF(
  6260. DAY,
  6261. DATE( behospital_date ),
  6262. DATE( leave_hospital_date ))> 31
  6263. <if test="isPlacefile != null and isPlacefile != ''">
  6264. and a.is_placefile = #{isPlacefile}
  6265. </if>
  6266. AND a.qc_type_id != 0
  6267. <if test="hospitalId != null and hospitalId != ''">
  6268. AND a.hospital_id = #{hospitalId}
  6269. </if>
  6270. <if test="isPlacefile != null and isPlacefile == 0">
  6271. <if test="startDate != null ">
  6272. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6273. </if>
  6274. <if test="endDate != null ">
  6275. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6276. </if>
  6277. </if>
  6278. <if test="isPlacefile != null and isPlacefile == 1">
  6279. <if test="startDate != null ">
  6280. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6281. </if>
  6282. <if test="endDate != null ">
  6283. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6284. </if>
  6285. </if>
  6286. <if test="deptName != null and deptName != ''">
  6287. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6288. </if>
  6289. ) b
  6290. GROUP BY
  6291. b.beh_dept_id,
  6292. b.beh_dept_name
  6293. )
  6294. ) tt
  6295. GROUP BY
  6296. tt.deptId,
  6297. tt.deptName
  6298. ) t
  6299. <if test="asc != null and asc !=''">
  6300. order by
  6301. <choose>
  6302. <when test='asc=="deptId"'>deptId asc</when>
  6303. <when test='asc=="deptName"'>deptName asc</when>
  6304. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6305. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6306. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6307. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6308. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6309. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6310. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6311. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6312. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6313. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6314. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6315. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6316. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6317. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6318. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6319. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6320. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6321. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6322. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6323. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6324. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6325. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6326. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6327. <otherwise>deptName asc</otherwise>
  6328. </choose>
  6329. </if>
  6330. <if test="desc != null and desc!=''">
  6331. order by
  6332. <choose>
  6333. <when test='desc=="deptId"'>deptId desc</when>
  6334. <when test='desc=="deptName"'>deptName desc</when>
  6335. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6336. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6337. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6338. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6339. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6340. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6341. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6342. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6343. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6344. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6345. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6346. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6347. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6348. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6349. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6350. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6351. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6352. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6353. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6354. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6355. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6356. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6357. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6358. <otherwise>deptName desc</otherwise>
  6359. </choose>
  6360. </if>
  6361. </select>
  6362. <!-- 关键条目缺陷统计报表-科室-->
  6363. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6364. SELECT
  6365. deptId,
  6366. deptName,
  6367. doctorName,
  6368. consultationMRNum,
  6369. consultationNum,
  6370. 2511 AS consultationEntryId,
  6371. '普通会诊未在24小时内完成' AS consultationEntryName,
  6372. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6373. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6374. operationMRNum,
  6375. 2594 AS operationNameEntryId,
  6376. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6377. operationNameNum,
  6378. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6379. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6380. 2973 AS operationTimeEntryId,
  6381. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6382. operationTimeNum,
  6383. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6384. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6385. 2930 AS operation15MinuteEntryId,
  6386. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6387. operation15MinuteNum,
  6388. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6389. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6390. 2419 AS crisisEntryId,
  6391. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6392. crisisMRNum,
  6393. crisisNum,
  6394. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6395. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6396. 2495 AS stageSummaryEntryId,
  6397. '无阶段小结' AS stageSummaryEntryName,
  6398. stageSummaryMRNum,
  6399. stageSummaryNum,
  6400. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6401. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6402. beHosGT31DaysMRNum
  6403. FROM
  6404. (
  6405. SELECT
  6406. tt.deptId,
  6407. tt.deptName,
  6408. tt.doctorId,
  6409. tt.doctorName,
  6410. sum( tt.consultationNum ) AS consultationNum,
  6411. sum( tt.consultationMRNum ) AS consultationMRNum,
  6412. sum( tt.operationNameNum ) AS operationNameNum,
  6413. sum( tt.operationTimeNum ) AS operationTimeNum,
  6414. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6415. sum( tt.operationMRNum ) AS operationMRNum,
  6416. sum( tt.crisisNum ) AS crisisNum,
  6417. sum( tt.crisisMRNum ) AS crisisMRNum,
  6418. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6419. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6420. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6421. FROM
  6422. (
  6423. (
  6424. SELECT
  6425. c.beh_dept_id AS deptId,
  6426. c.beh_dept_name AS deptName,
  6427. c.doctorId,
  6428. c.doctorName,
  6429. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6430. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6431. 0 AS operationNameNum,
  6432. 0 AS operationTimeNum,
  6433. 0 AS operation15MinuteNum,
  6434. 0 AS operationMRNum,
  6435. 0 AS crisisNum,
  6436. 0 AS crisisMRNum,
  6437. 0 AS stageSummaryNum,
  6438. 0 AS stageSummaryMRNum,
  6439. 0 AS beHosGT31DaysMRNum
  6440. FROM
  6441. (
  6442. SELECT DISTINCT
  6443. a.hospital_id,
  6444. a.behospital_code,
  6445. a.beh_dept_name,
  6446. a.beh_dept_id,
  6447. a.doctor_id as doctorId,
  6448. a.doctor_name as doctorName
  6449. FROM
  6450. med_behospital_info a,
  6451. med_medical_record b,
  6452. sys_user_dept c
  6453. WHERE
  6454. a.is_deleted = 'N'
  6455. AND b.is_deleted = 'N'
  6456. AND c.is_deleted = 'N'
  6457. AND a.hospital_id = b.hospital_id
  6458. AND a.hospital_id = c.hospital_id
  6459. AND a.behospital_code = b.behospital_code
  6460. AND a.beh_dept_id = c.dept_id
  6461. AND b.mode_id = 30
  6462. <if test="userId!=null">
  6463. AND c.user_id = #{userId}
  6464. </if>
  6465. <if test="isPlacefile != null and isPlacefile != ''">
  6466. and a.is_placefile = #{isPlacefile}
  6467. </if>
  6468. AND a.qc_type_id != 0
  6469. <if test="hospitalId != null and hospitalId != ''">
  6470. AND a.hospital_id = #{hospitalId}
  6471. </if>
  6472. <if test="isPlacefile != null and isPlacefile == 0">
  6473. <if test="startDate != null ">
  6474. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6475. </if>
  6476. <if test="endDate != null ">
  6477. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6478. </if>
  6479. </if>
  6480. <if test="isPlacefile != null and isPlacefile == 1">
  6481. <if test="startDate != null ">
  6482. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6483. </if>
  6484. <if test="endDate != null ">
  6485. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6486. </if>
  6487. </if>
  6488. <if test="doctorName != null and doctorName != ''">
  6489. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6490. </if>
  6491. <if test="deptName != null and deptName != ''">
  6492. AND a.beh_dept_name = #{deptName}
  6493. </if>
  6494. ) c
  6495. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6496. AND c.hospital_id = d.hospital_id
  6497. AND c.behospital_code = d.behospital_code
  6498. GROUP BY
  6499. c.doctorId,
  6500. c.doctorName
  6501. ) UNION
  6502. (
  6503. SELECT
  6504. d.beh_dept_id AS deptId,
  6505. d.beh_dept_name AS deptName,
  6506. d.doctor_id as doctorId,
  6507. d.doctor_name as doctorName,
  6508. 0 AS consultationNum,
  6509. 0 AS consultationMRNum,
  6510. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6511. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6512. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6513. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6514. 0 AS crisisNum,
  6515. 0 AS crisisMRNum,
  6516. 0 AS stageSummaryNum,
  6517. 0 AS stageSummaryMRNum,
  6518. 0 AS beHosGT31DaysMRNum
  6519. FROM
  6520. (
  6521. SELECT DISTINCT
  6522. a.hospital_id,
  6523. a.behospital_code,
  6524. a.beh_dept_name,
  6525. a.beh_dept_id,
  6526. a.doctor_id,
  6527. a.doctor_name
  6528. FROM
  6529. med_behospital_info a,
  6530. med_home_page b,
  6531. med_home_operation_info c,
  6532. sys_user_dept d
  6533. WHERE
  6534. a.is_deleted = 'N'
  6535. AND b.is_deleted = 'N'
  6536. AND c.is_deleted = 'N'
  6537. AND d.is_deleted = 'N'
  6538. AND a.hospital_id = b.hospital_id
  6539. AND a.hospital_id = c.hospital_id
  6540. AND a.hospital_id = d.hospital_id
  6541. AND a.behospital_code = b.behospital_code
  6542. AND b.home_page_id = c.home_page_id
  6543. AND a.beh_dept_id = d.dept_id
  6544. <if test="userId!=null">
  6545. AND d.user_id = #{userId}
  6546. </if>
  6547. <if test="isPlacefile != null and isPlacefile != ''">
  6548. and a.is_placefile = #{isPlacefile}
  6549. </if>
  6550. AND a.qc_type_id != 0
  6551. <if test="hospitalId != null and hospitalId != ''">
  6552. AND a.hospital_id = #{hospitalId}
  6553. </if>
  6554. <if test="isPlacefile != null and isPlacefile == 0">
  6555. <if test="startDate != null ">
  6556. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6557. </if>
  6558. <if test="endDate != null ">
  6559. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6560. </if>
  6561. </if>
  6562. <if test="isPlacefile != null and isPlacefile == 1">
  6563. <if test="startDate != null ">
  6564. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6565. </if>
  6566. <if test="endDate != null ">
  6567. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6568. </if>
  6569. </if>
  6570. <if test="doctorName != null and doctorName != ''">
  6571. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6572. </if>
  6573. <if test="deptName != null and deptName != ''">
  6574. AND a.beh_dept_name = #{deptName}
  6575. </if>
  6576. ) d
  6577. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6578. AND d.hospital_id = e.hospital_id
  6579. AND d.behospital_code = e.behospital_code
  6580. GROUP BY
  6581. d.doctor_id,
  6582. d.doctor_name
  6583. ) UNION
  6584. (
  6585. SELECT
  6586. c.beh_dept_id AS deptId,
  6587. c.beh_dept_name AS deptName,
  6588. c.doctor_id as doctorId,
  6589. c.doctor_name as doctorName,
  6590. 0 AS consultationNum,
  6591. 0 AS consultationMRNum,
  6592. 0 AS operationNameNum,
  6593. 0 AS operationTimeNum,
  6594. 0 AS operation15MinuteNum,
  6595. 0 AS operationMRNum,
  6596. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6597. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6598. 0 AS stageSummaryNum,
  6599. 0 AS stageSummaryMRNum,
  6600. 0 AS beHosGT31DaysMRNum
  6601. FROM
  6602. (
  6603. SELECT DISTINCT
  6604. a.hospital_id,
  6605. a.behospital_code,
  6606. a.beh_dept_name,
  6607. a.beh_dept_id,
  6608. a.doctor_id,
  6609. a.doctor_name
  6610. FROM
  6611. med_behospital_info a,
  6612. med_crisis_info b,
  6613. sys_user_dept c
  6614. WHERE
  6615. a.is_deleted = 'N'
  6616. AND b.is_deleted = 'N'
  6617. AND c.is_deleted = 'N'
  6618. AND a.hospital_id = b.hospital_id
  6619. AND a.hospital_id = c.hospital_id
  6620. AND a.behospital_code = b.behospital_code
  6621. AND a.beh_dept_id = c.dept_id
  6622. <if test="userId!=null">
  6623. AND c.user_id = #{userId}
  6624. </if>
  6625. <if test="isPlacefile != null and isPlacefile != ''">
  6626. and a.is_placefile = #{isPlacefile}
  6627. </if>
  6628. AND a.qc_type_id != 0
  6629. <if test="hospitalId != null and hospitalId != ''">
  6630. AND a.hospital_id = #{hospitalId}
  6631. </if>
  6632. <if test="isPlacefile != null and isPlacefile == 0">
  6633. <if test="startDate != null ">
  6634. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6635. </if>
  6636. <if test="endDate != null ">
  6637. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6638. </if>
  6639. </if>
  6640. <if test="isPlacefile != null and isPlacefile == 1">
  6641. <if test="startDate != null ">
  6642. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6643. </if>
  6644. <if test="endDate != null ">
  6645. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6646. </if>
  6647. </if>
  6648. <if test="doctorName != null and doctorName != ''">
  6649. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6650. </if>
  6651. <if test="deptName != null and deptName != ''">
  6652. AND a.beh_dept_name = #{deptName}
  6653. </if>
  6654. ) c
  6655. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6656. AND c.hospital_id = d.hospital_id
  6657. AND c.behospital_code = d.behospital_code
  6658. GROUP BY
  6659. c.doctor_id,
  6660. c.doctor_name
  6661. ) UNION
  6662. (
  6663. SELECT
  6664. b.beh_dept_id AS deptId,
  6665. b.beh_dept_name AS deptName,
  6666. b.doctor_id as doctorId,
  6667. b.doctor_name as doctorName,
  6668. 0 AS consultationNum,
  6669. 0 AS consultationMRNum,
  6670. 0 AS operationNameNum,
  6671. 0 AS operationTimeNum,
  6672. 0 AS operation15MinuteNum,
  6673. 0 AS operationMRNum,
  6674. 0 AS crisisNum,
  6675. 0 AS crisisMRNum,
  6676. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6677. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6678. 0 AS beHosGT31DaysMRNum
  6679. FROM
  6680. (
  6681. SELECT DISTINCT
  6682. a.hospital_id,
  6683. a.behospital_code,
  6684. a.beh_dept_name,
  6685. a.beh_dept_id,
  6686. a.doctor_id,
  6687. a.doctor_name
  6688. FROM
  6689. med_behospital_info a,
  6690. sys_user_dept b
  6691. WHERE
  6692. a.is_deleted = 'N'
  6693. AND b.is_deleted = 'N'
  6694. AND a.hospital_id = b.hospital_id
  6695. AND a.beh_dept_id = b.dept_id
  6696. AND TIMESTAMPDIFF(
  6697. DAY,
  6698. DATE( behospital_date ),
  6699. DATE( leave_hospital_date ))> 30
  6700. <if test="userId!=null">
  6701. AND b.user_id = #{userId}
  6702. </if>
  6703. <if test="isPlacefile != null and isPlacefile != ''">
  6704. and a.is_placefile = #{isPlacefile}
  6705. </if>
  6706. AND a.qc_type_id != 0
  6707. <if test="hospitalId != null and hospitalId != ''">
  6708. AND a.hospital_id = #{hospitalId}
  6709. </if>
  6710. <if test="isPlacefile != null and isPlacefile == 0">
  6711. <if test="startDate != null ">
  6712. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6713. </if>
  6714. <if test="endDate != null ">
  6715. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6716. </if>
  6717. </if>
  6718. <if test="isPlacefile != null and isPlacefile == 1">
  6719. <if test="startDate != null ">
  6720. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6721. </if>
  6722. <if test="endDate != null ">
  6723. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6724. </if>
  6725. </if>
  6726. <if test="doctorName != null and doctorName != ''">
  6727. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6728. </if>
  6729. <if test="deptName != null and deptName != ''">
  6730. AND a.beh_dept_name = #{deptName}
  6731. </if>
  6732. ) b
  6733. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6734. AND b.hospital_id = c.hospital_id
  6735. AND b.behospital_code = c.behospital_code
  6736. GROUP BY
  6737. b.doctor_id,
  6738. b.doctor_name
  6739. ) UNION
  6740. (
  6741. SELECT
  6742. b.beh_dept_id AS deptId,
  6743. b.beh_dept_name AS deptName,
  6744. b.doctor_id as doctorId,
  6745. b.doctor_name as doctorName,
  6746. 0 AS consultationNum,
  6747. 0 AS consultationMRNum,
  6748. 0 AS operationNameNum,
  6749. 0 AS operationTimeNum,
  6750. 0 AS operation15MinuteNum,
  6751. 0 AS operationMRNum,
  6752. 0 AS crisisNum,
  6753. 0 AS crisisMRNum,
  6754. 0 AS stageSummaryNum,
  6755. 0 AS stageSummaryMRNum,
  6756. count(*) AS beHosGT31DaysMRNum
  6757. FROM
  6758. (
  6759. SELECT DISTINCT
  6760. a.hospital_id,
  6761. a.behospital_code,
  6762. a.beh_dept_name,
  6763. a.beh_dept_id,
  6764. a.doctor_id,
  6765. a.doctor_name
  6766. FROM
  6767. med_behospital_info a,
  6768. med_qcresult_info b,
  6769. med_qcresult_detail c,
  6770. qc_cases_entry d,
  6771. sys_user_dept e
  6772. WHERE
  6773. a.is_deleted = 'N'
  6774. AND b.is_deleted = 'N'
  6775. AND c.is_deleted = 'N'
  6776. AND d.is_deleted = 'N'
  6777. AND e.is_deleted = 'N'
  6778. AND a.hospital_id = b.hospital_id
  6779. AND a.hospital_id = c.hospital_id
  6780. AND a.hospital_id = e.hospital_id
  6781. AND a.behospital_code = b.behospital_code
  6782. AND a.behospital_code = c.behospital_code
  6783. AND c.cases_id = d.cases_id
  6784. AND c.cases_entry_id = d.id
  6785. AND a.beh_dept_id = e.dept_id
  6786. AND TIMESTAMPDIFF(
  6787. DAY,
  6788. DATE( behospital_date ),
  6789. DATE( leave_hospital_date ))> 31
  6790. <if test="userId!=null">
  6791. AND e.user_id = #{userId}
  6792. </if>
  6793. <if test="isPlacefile != null and isPlacefile != ''">
  6794. and a.is_placefile = #{isPlacefile}
  6795. </if>
  6796. AND a.qc_type_id != 0
  6797. <if test="hospitalId != null and hospitalId != ''">
  6798. AND a.hospital_id = #{hospitalId}
  6799. </if>
  6800. <if test="isPlacefile != null and isPlacefile == 0">
  6801. <if test="startDate != null ">
  6802. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6803. </if>
  6804. <if test="endDate != null ">
  6805. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6806. </if>
  6807. </if>
  6808. <if test="isPlacefile != null and isPlacefile == 1">
  6809. <if test="startDate != null ">
  6810. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6811. </if>
  6812. <if test="endDate != null ">
  6813. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6814. </if>
  6815. </if>
  6816. <if test="doctorName != null and doctorName != ''">
  6817. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6818. </if>
  6819. <if test="deptName != null and deptName != ''">
  6820. AND a.beh_dept_name = #{deptName}
  6821. </if>
  6822. ) b
  6823. GROUP BY
  6824. b.doctor_id,
  6825. b.doctor_name
  6826. )
  6827. ) tt
  6828. GROUP BY
  6829. tt.doctorName
  6830. ) t
  6831. <if test="asc != null and asc !=''">
  6832. order by
  6833. <choose>
  6834. <when test='asc=="deptId"'>deptId asc</when>
  6835. <when test='asc=="deptName"'>deptName asc</when>
  6836. <when test='asc=="doctorName"'>doctorName asc</when>
  6837. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6838. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6839. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6840. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6841. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6842. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6843. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6844. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6845. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6846. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6847. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6848. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6849. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6850. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6851. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6852. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6853. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6854. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6855. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6856. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6857. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6858. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6859. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6860. <otherwise>doctorName asc</otherwise>
  6861. </choose>
  6862. </if>
  6863. <if test="desc != null and desc!=''">
  6864. order by
  6865. <choose>
  6866. <when test='desc=="deptId"'>deptId desc</when>
  6867. <when test='desc=="doctorName"'>doctorName desc</when>
  6868. <when test='desc=="deptName"'>deptName desc</when>
  6869. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6870. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6871. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6872. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6873. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6874. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6875. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6876. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6877. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6878. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6879. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6880. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6881. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6882. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6883. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6884. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6885. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6886. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6887. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6888. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6889. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6890. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6891. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6892. <otherwise>doctorName desc</otherwise>
  6893. </choose>
  6894. </if>
  6895. </select>
  6896. <!-- 非医嘱离院病人记录-->
  6897. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6898. SELECT
  6899. count(*)
  6900. FROM
  6901. med_behospital_info a,
  6902. med_home_page b
  6903. WHERE
  6904. a.is_deleted = 'N'
  6905. AND b.is_deleted = 'N'
  6906. AND a.hospital_id = b.hospital_id
  6907. AND a.behospital_code = b.behospital_code
  6908. AND b.leave_hospital_type = '非医嘱离院'
  6909. <if test="isPlacefile != null and isPlacefile != ''">
  6910. and a.is_placefile = #{isPlacefile}
  6911. </if>
  6912. AND a.qc_type_id != 0
  6913. <if test="hospitalId != null and hospitalId != ''">
  6914. AND a.hospital_id = #{hospitalId}
  6915. </if>
  6916. <if test="isPlacefile != null and isPlacefile == 0">
  6917. <if test="startDate != null and startDate != ''">
  6918. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6919. </if>
  6920. <if test="endDate != null and endDate != ''">
  6921. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6922. </if>
  6923. </if>
  6924. <if test="isPlacefile != null and isPlacefile == 1">
  6925. <if test="startDate != null and startDate != ''">
  6926. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6927. </if>
  6928. <if test="endDate != null and endDate != ''">
  6929. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6930. </if>
  6931. </if>
  6932. </select>
  6933. <!-- 31天内再入院记录-->
  6934. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6935. SELECT
  6936. count(*)
  6937. FROM
  6938. (
  6939. SELECT
  6940. r1.file_code,
  6941. r1.diagnose,
  6942. r1.behospital_code AS behospitalCode,
  6943. r1.behospital_date AS behospitalDate,
  6944. r1.leave_hospital_date AS leaveHospitalDate,
  6945. r2.behospital_code AS lastBehospitalCode,
  6946. r2.behospital_date AS lastBehospitalDate,
  6947. r2.leave_hospital_date AS lastLeaveHospitalDate,
  6948. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  6949. FROM
  6950. (
  6951. SELECT
  6952. ( @rownum := @rownum + 1 ) AS rownum,
  6953. t1.file_code,
  6954. t1.diagnose,
  6955. t1.behospital_code,
  6956. t1.behospital_date,
  6957. t1.leave_hospital_date
  6958. FROM
  6959. (
  6960. SELECT
  6961. tt1.file_code,
  6962. tt1.diagnose,
  6963. tt2.behospital_code,
  6964. tt2.behospital_date,
  6965. tt2.leave_hospital_date
  6966. FROM
  6967. (
  6968. SELECT
  6969. a.file_code,
  6970. a.diagnose
  6971. FROM
  6972. med_behospital_info a
  6973. WHERE
  6974. a.is_deleted = 'N'
  6975. <if test="isPlacefile != null and isPlacefile != ''">
  6976. and a.is_placefile = #{isPlacefile}
  6977. </if>
  6978. AND a.qc_type_id != 0
  6979. AND IFNULL( a.diagnose, '' )!= ''
  6980. AND IFNULL( a.file_code, '' )!= ''
  6981. <if test="hospitalId != null and hospitalId != ''">
  6982. AND a.hospital_id = #{hospitalId}
  6983. </if>
  6984. <if test="isPlacefile != null and isPlacefile == 0">
  6985. <if test="startDate != null and startDate != ''">
  6986. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6987. </if>
  6988. <if test="endDate != null and endDate != ''">
  6989. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6990. </if>
  6991. </if>
  6992. <if test="isPlacefile != null and isPlacefile == 1">
  6993. <if test="startDate != null and startDate != ''">
  6994. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6995. </if>
  6996. <if test="endDate != null and endDate != ''">
  6997. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6998. </if>
  6999. </if>
  7000. GROUP BY
  7001. a.file_code,
  7002. a.diagnose
  7003. HAVING
  7004. count(*)> 1
  7005. ) tt1,
  7006. med_behospital_info tt2
  7007. WHERE
  7008. tt2.is_deleted = 'N'
  7009. <if test="isPlacefile != null and isPlacefile != ''">
  7010. and tt2.is_placefile = #{isPlacefile}
  7011. </if>
  7012. AND tt2.qc_type_id != 0
  7013. AND tt1.file_code = tt2.file_code
  7014. AND tt1.diagnose = tt2.diagnose
  7015. <if test="hospitalId != null and hospitalId != ''">
  7016. AND tt2.hospital_id = #{hospitalId}
  7017. </if>
  7018. <if test="isPlacefile != null and isPlacefile == 0">
  7019. <if test="startDate != null and startDate != ''">
  7020. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7021. </if>
  7022. <if test="endDate != null and endDate != ''">
  7023. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7024. </if>
  7025. </if>
  7026. <if test="isPlacefile != null and isPlacefile == 1">
  7027. <if test="startDate != null and startDate != ''">
  7028. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7029. </if>
  7030. <if test="endDate != null and endDate != ''">
  7031. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7032. </if>
  7033. </if>
  7034. ORDER BY
  7035. tt1.file_code,
  7036. tt1.diagnose,
  7037. tt2.behospital_date DESC
  7038. ) t1,
  7039. ( SELECT @rownum := 0 ) r
  7040. ) r1
  7041. LEFT JOIN (
  7042. SELECT
  7043. ( @INDEX := @INDEX + 1 ) AS rownum,
  7044. t2.file_code,
  7045. t2.diagnose,
  7046. t2.behospital_code,
  7047. t2.behospital_date,
  7048. t2.leave_hospital_date
  7049. FROM
  7050. (
  7051. SELECT
  7052. tt1.file_code,
  7053. tt1.diagnose,
  7054. tt2.behospital_code,
  7055. tt2.behospital_date,
  7056. tt2.leave_hospital_date
  7057. FROM
  7058. (
  7059. SELECT
  7060. a.file_code,
  7061. a.diagnose
  7062. FROM
  7063. med_behospital_info a
  7064. WHERE
  7065. a.is_deleted = 'N'
  7066. <if test="isPlacefile != null and isPlacefile != ''">
  7067. and a.is_placefile = #{isPlacefile}
  7068. </if>
  7069. AND a.qc_type_id != 0
  7070. AND IFNULL( a.diagnose, '' )!= ''
  7071. AND IFNULL( a.file_code, '' )!= ''
  7072. <if test="hospitalId != null and hospitalId != ''">
  7073. AND a.hospital_id = #{hospitalId}
  7074. </if>
  7075. <if test="isPlacefile != null and isPlacefile == 0">
  7076. <if test="startDate != null and startDate != ''">
  7077. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7078. </if>
  7079. <if test="endDate != null and endDate != ''">
  7080. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7081. </if>
  7082. </if>
  7083. <if test="isPlacefile != null and isPlacefile == 1">
  7084. <if test="startDate != null and startDate != ''">
  7085. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7086. </if>
  7087. <if test="endDate != null and endDate != ''">
  7088. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7089. </if>
  7090. </if>
  7091. GROUP BY
  7092. a.file_code,
  7093. a.diagnose
  7094. HAVING
  7095. count(*)> 1
  7096. ) tt1,
  7097. med_behospital_info tt2
  7098. WHERE
  7099. tt2.is_deleted = 'N'
  7100. <if test="isPlacefile != null and isPlacefile != ''">
  7101. and tt2.is_placefile = #{isPlacefile}
  7102. </if>
  7103. AND tt2.qc_type_id != 0
  7104. AND tt1.file_code = tt2.file_code
  7105. AND tt1.diagnose = tt2.diagnose
  7106. <if test="hospitalId != null and hospitalId != ''">
  7107. AND tt2.hospital_id = #{hospitalId}
  7108. </if>
  7109. <if test="isPlacefile != null and isPlacefile == 0">
  7110. <if test="startDate != null and startDate != ''">
  7111. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7112. </if>
  7113. <if test="endDate != null and endDate != ''">
  7114. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7115. </if>
  7116. </if>
  7117. <if test="isPlacefile != null and isPlacefile == 1">
  7118. <if test="startDate != null and startDate != ''">
  7119. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7120. </if>
  7121. <if test="endDate != null and endDate != ''">
  7122. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7123. </if>
  7124. </if>
  7125. ORDER BY
  7126. tt1.file_code,
  7127. tt1.diagnose,
  7128. tt2.behospital_date DESC
  7129. ) t2,(
  7130. SELECT
  7131. @INDEX := 0
  7132. ) r
  7133. ) r2 ON r1.file_code = r2.file_code
  7134. AND r1.rownum = r2.rownum - 1
  7135. ) t
  7136. WHERE
  7137. t.diffDays IS NOT NULL
  7138. AND t.diffDays BETWEEN 0
  7139. AND 31
  7140. </select>
  7141. <!-- 病案首页质控病历数统计-全院(首页)-->
  7142. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  7143. SELECT
  7144. count( * ) AS mrNum,
  7145. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  7146. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  7147. SUM( c.`level` = '合格' ) AS firstLevelNum,
  7148. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  7149. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  7150. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  7151. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  7152. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  7153. FROM
  7154. med_behospital_info a,
  7155. med_qcresult_cases c
  7156. WHERE
  7157. a.is_deleted = 'N'
  7158. AND c.is_deleted = 'N'
  7159. AND a.hospital_id = c.hospital_id
  7160. AND a.behospital_code = c.behospital_code
  7161. AND c.cases_id = 243
  7162. <if test="isPlacefile != null and isPlacefile != ''">
  7163. and a.is_placefile = #{isPlacefile}
  7164. </if>
  7165. AND a.qc_type_id != 0
  7166. <if test="hospitalId != null and hospitalId != ''">
  7167. AND a.hospital_id = #{hospitalId}
  7168. </if>
  7169. <if test="isPlacefile != null and isPlacefile == 0">
  7170. <if test="startDate != null and startDate != ''">
  7171. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7172. </if>
  7173. <if test="endDate != null and endDate != ''">
  7174. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7175. </if>
  7176. </if>
  7177. <if test="isPlacefile != null and isPlacefile == 1">
  7178. <if test="startDate != null and startDate != ''">
  7179. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7180. </if>
  7181. <if test="endDate != null and endDate != ''">
  7182. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7183. </if>
  7184. </if>
  7185. </select>
  7186. <!-- 病案首页完整率统计-全院(首页)-->
  7187. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  7188. SELECT
  7189. h1.emptyNum,
  7190. h1.mrNum,
  7191. h2.entryNum,
  7192. h1.mrNum * h2.entryNum AS entryTotleNum,
  7193. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  7194. CONCAT(
  7195. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  7196. '%'
  7197. ) AS emptyPercentStr
  7198. FROM
  7199. (
  7200. SELECT
  7201. sum( d.rule_type = 1 ) AS emptyNum,
  7202. count( DISTINCT a.behospital_code ) AS mrNum
  7203. FROM
  7204. med_behospital_info a,
  7205. med_qcresult_cases b,
  7206. med_qcresult_detail c,
  7207. qc_cases_entry d
  7208. WHERE
  7209. a.is_deleted = 'N'
  7210. AND b.is_deleted = 'N'
  7211. AND c.is_deleted = 'N'
  7212. AND d.is_deleted = 'N'
  7213. AND a.hospital_id = b.hospital_id
  7214. AND a.hospital_id = c.hospital_id
  7215. AND a.behospital_code = b.behospital_code
  7216. AND a.behospital_code = c.behospital_code
  7217. AND b.cases_id = c.cases_id
  7218. AND c.cases_id = d.cases_id
  7219. AND c.cases_entry_id = d.id
  7220. <if test="isPlacefile != null and isPlacefile != ''">
  7221. and a.is_placefile = #{isPlacefile}
  7222. </if>
  7223. AND d.cases_id = 243
  7224. AND a.qc_type_id != 0
  7225. <if test="hospitalId != null and hospitalId != ''">
  7226. AND a.hospital_id = #{hospitalId}
  7227. </if>
  7228. <if test="isPlacefile != null and isPlacefile == 0">
  7229. <if test="startDate != null and startDate != ''">
  7230. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7231. </if>
  7232. <if test="endDate != null and endDate != ''">
  7233. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7234. </if>
  7235. </if>
  7236. <if test="isPlacefile != null and isPlacefile == 1">
  7237. <if test="startDate != null and startDate != ''">
  7238. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7239. </if>
  7240. <if test="endDate != null and endDate != ''">
  7241. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7242. </if>
  7243. </if>
  7244. ) h1,(
  7245. SELECT
  7246. count(*) AS entryNum
  7247. FROM
  7248. qc_cases_entry
  7249. WHERE
  7250. is_deleted = 'N'
  7251. AND cases_id = 243
  7252. ) h2
  7253. </select>
  7254. <!-- 离院病人评分详情页-->
  7255. <select id="getAge" resultType="java.util.Map">
  7256. SELECT
  7257. a.behospital_code as behospitalCode,
  7258. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  7259. FROM
  7260. med_home_page a
  7261. WHERE
  7262. a.is_deleted = 'N'
  7263. AND a.hospital_id = #{hospitalId}
  7264. AND a.behospital_code IN
  7265. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  7266. '${item}'
  7267. </foreach>
  7268. </select>
  7269. <!-- 离院病人评分详情页-->
  7270. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7271. SELECT
  7272. t.*
  7273. FROM
  7274. (SELECT DISTINCT
  7275. t1.hospital_id AS hospitalId,
  7276. t1.behospital_code AS behospitalCode,
  7277. t1.bed_code AS bedCode,
  7278. t1.LEVEL AS LEVEL,
  7279. t1.grade_type AS gradeType,
  7280. t1.score_res AS scoreRes,
  7281. t1.scoreBn,
  7282. t1.NAME AS NAME,
  7283. t1.sex AS sex,
  7284. t1.beh_dept_id AS behDeptId,
  7285. t1.beh_dept_name AS behDeptName,
  7286. t1.doctor_id AS doctorId,
  7287. t1.doctor_name AS doctorName,
  7288. t1.beh_doctor_id AS behDoctorId,
  7289. t1.beh_doctor_name AS behDoctorName,
  7290. t1.director_doctor_id AS directorDoctorId,
  7291. t1.director_doctor_name AS directorDoctorName,
  7292. t1.birthday AS birthday,
  7293. t1.behospital_date AS behospitalDate,
  7294. t1.leave_hospital_date AS leaveHospitalDate,
  7295. t1.placefile_date AS placefileDate,
  7296. t1.gmt_create AS gradeTime,
  7297. t1.diagnose,
  7298. t1.ward_name AS wardName,
  7299. t1.checkStatus,
  7300. t1.mrStatus,
  7301. t1.chName,
  7302. t1.mrName,
  7303. t1.chTime,
  7304. t1.mrTime,
  7305. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7306. t1.file_code AS fileCode
  7307. FROM
  7308. (
  7309. SELECT be.*,
  7310. ifnull(mci.status,0) AS checkStatus,
  7311. ifnull(hm_mci.status,0) AS mrStatus,
  7312. mci.check_name as chName,
  7313. e.score_res as scoreBn,
  7314. hm_mci.check_name as mrName,
  7315. mci.gmt_create as chTime,
  7316. hm_mci.gmt_create as mrTime
  7317. FROM
  7318. (
  7319. SELECT DISTINCT
  7320. tt1.*
  7321. FROM
  7322. (
  7323. SELECT
  7324. b.*,
  7325. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7326. c.grade_type,
  7327. c.score_res,
  7328. c.gmt_create
  7329. FROM
  7330. (
  7331. SELECT DISTINCT
  7332. a.hospital_id,
  7333. a.behospital_code,
  7334. a.bed_code,
  7335. a.NAME,
  7336. a.sex,
  7337. a.beh_dept_id,
  7338. a.beh_dept_name,
  7339. a.birthday,
  7340. a.behospital_date,
  7341. a.leave_hospital_date,
  7342. a.doctor_id,
  7343. a.doctor_name,
  7344. a.beh_doctor_id,
  7345. a.beh_doctor_name,
  7346. a.director_doctor_id,
  7347. a.director_doctor_name,
  7348. a.diagnose,
  7349. a.placefile_date,
  7350. a.ward_name,
  7351. a.file_code
  7352. FROM
  7353. med_behospital_info a
  7354. WHERE
  7355. a.is_deleted = 'N'
  7356. AND a.qc_type_id != 0
  7357. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7358. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7359. </if>
  7360. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7361. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7362. </if>
  7363. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7364. <if test="qcResultShortPageVO.startDate != null ">
  7365. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7366. </if>
  7367. <if test="qcResultShortPageVO.endDate != null ">
  7368. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7369. </if>
  7370. </if>
  7371. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7372. <if test="qcResultShortPageVO.startDate != null ">
  7373. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7374. </if>
  7375. <if test="qcResultShortPageVO.endDate != null">
  7376. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7377. </if>
  7378. </if>
  7379. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7380. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7381. </if>
  7382. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7383. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7384. </if>
  7385. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7386. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7387. </if>
  7388. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7389. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7390. </if>
  7391. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7392. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7393. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7394. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7395. </if>
  7396. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7397. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7398. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7399. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7400. </if>
  7401. ) b
  7402. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7403. AND b.hospital_id = c.hospital_id
  7404. AND b.behospital_code = c.behospital_code
  7405. ) tt1
  7406. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7407. ,med_medical_record tt2,
  7408. qc_mode tt3
  7409. WHERE
  7410. tt2.is_deleted = 'N'
  7411. AND tt3.is_deleted = 'N'
  7412. AND tt1.hospital_id = tt2.hospital_id
  7413. AND tt1.behospital_code = tt2.behospital_code
  7414. AND tt2.mode_id = tt3.id
  7415. AND tt3.`name` = '手术记录'
  7416. </if>
  7417. ) be
  7418. left join med_check_info mci
  7419. on mci.is_deleted = 'N'
  7420. and mci.check_type = 0
  7421. and be.hospital_id = mci.hospital_id
  7422. and be.behospital_code = mci.behospital_code
  7423. left join med_check_info hm_mci
  7424. on hm_mci.is_deleted = 'N'
  7425. and hm_mci.check_type = 1
  7426. and be.hospital_id = hm_mci.hospital_id
  7427. and be.behospital_code = hm_mci.behospital_code
  7428. LEFT JOIN med_qcresult_cases e
  7429. on be.behospital_code = e.behospital_code
  7430. and be.hospital_id = e.hospital_id
  7431. AND e.is_deleted = 'N'
  7432. and e.cases_id = 243
  7433. )t1
  7434. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7435. ,med_home_page t2
  7436. WHERE
  7437. t2.is_deleted = 'N'
  7438. AND t1.hospital_id = t2.hospital_id
  7439. AND t1.behospital_code = t2.behospital_code
  7440. AND (
  7441. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7442. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7443. )
  7444. </if>
  7445. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7446. , med_medical_record b,
  7447. med_medical_record_content c,
  7448. med_home_page t2
  7449. WHERE
  7450. b.is_deleted = 'N'
  7451. and c.is_deleted = 'N'
  7452. and t2.is_deleted = 'N'
  7453. and t1.hospital_id = b.hospital_id
  7454. and t1.hospital_id = c.hospital_id
  7455. and t1.hospital_id = t2.hospital_id
  7456. AND t1.behospital_code = b.behospital_code
  7457. AND t1.behospital_code = t2.behospital_code
  7458. AND b.rec_id = c.rec_id
  7459. and b.mode_id = '24'
  7460. </if>
  7461. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7462. ,med_home_page t2
  7463. WHERE
  7464. t2.is_deleted = 'N'
  7465. AND t1.hospital_id = t2.hospital_id
  7466. AND t1.behospital_code = t2.behospital_code
  7467. AND t2.leave_hospital_type = '非医嘱离院'
  7468. </if>
  7469. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7470. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7471. AND t1.hospital_id = t2.hospital_id
  7472. AND t1.behospital_code = t2.behospital_code
  7473. </if>
  7474. )t
  7475. where 1=1
  7476. <if test="qcResultShortPageVO.checkStatus != null">
  7477. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7478. </if>
  7479. <if test="qcResultShortPageVO.mrStatus != null">
  7480. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7481. </if>
  7482. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7483. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7484. </if>
  7485. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7486. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7487. </if>
  7488. <if test="qcResultShortPageVO.chTimeStart != null ">
  7489. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7490. </if>
  7491. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7492. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7493. </if>
  7494. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7495. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7496. </if>
  7497. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7498. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7499. </if>
  7500. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7501. AND t.`level` = #{qcResultShortPageVO.level}
  7502. </if>
  7503. </select>
  7504. <!-- 离院病人评分详情页-科室-->
  7505. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  7506. SELECT
  7507. t.*
  7508. FROM
  7509. (SELECT DISTINCT
  7510. t1.hospital_id AS hospitalId,
  7511. t1.behospital_code AS behospitalCode,
  7512. t1.bed_code AS bedCode,
  7513. t1.LEVEL AS LEVEL,
  7514. t1.grade_type AS gradeType,
  7515. t1.score_res AS scoreRes,
  7516. t1.scoreBn,
  7517. t1.NAME AS NAME,
  7518. t1.sex AS sex,
  7519. t1.beh_dept_id AS behDeptId,
  7520. t1.beh_dept_name AS behDeptName,
  7521. t1.doctor_id AS doctorId,
  7522. t1.doctor_name AS doctorName,
  7523. t1.beh_doctor_id AS behDoctorId,
  7524. t1.beh_doctor_name AS behDoctorName,
  7525. t1.director_doctor_id AS directorDoctorId,
  7526. t1.director_doctor_name AS directorDoctorName,
  7527. t1.birthday AS birthday,
  7528. t1.behospital_date AS behospitalDate,
  7529. t1.leave_hospital_date AS leaveHospitalDate,
  7530. t1.placefile_date AS placefileDate,
  7531. t1.gmt_create AS gradeTime,
  7532. t1.diagnose,
  7533. t1.ward_name AS wardName,
  7534. t1.checkStatus,
  7535. t1.mrStatus,
  7536. t1.chName,
  7537. t1.mrName,
  7538. t1.chTime,
  7539. t1.mrTime,
  7540. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7541. t1.file_code AS fileCode
  7542. FROM
  7543. (
  7544. SELECT be.*,
  7545. ifnull(mci.status,0) AS checkStatus,
  7546. ifnull(hm_mci.status,0) AS mrStatus,
  7547. mci.check_name as chName,
  7548. e.score_res as scoreBn,
  7549. hm_mci.check_name as mrName,
  7550. mci.gmt_create as chTime,
  7551. hm_mci.gmt_create as mrTime
  7552. FROM
  7553. (
  7554. SELECT DISTINCT
  7555. tt1.*
  7556. FROM
  7557. (
  7558. SELECT
  7559. b.*,
  7560. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7561. c.grade_type,
  7562. c.score_res,
  7563. c.gmt_create
  7564. FROM
  7565. (
  7566. SELECT DISTINCT
  7567. a.hospital_id,
  7568. a.behospital_code,
  7569. a.bed_code,
  7570. a.NAME,
  7571. a.sex,
  7572. a.beh_dept_id,
  7573. a.beh_dept_name,
  7574. a.birthday,
  7575. a.behospital_date,
  7576. a.leave_hospital_date,
  7577. a.doctor_id,
  7578. a.doctor_name,
  7579. a.beh_doctor_id,
  7580. a.beh_doctor_name,
  7581. a.director_doctor_id,
  7582. a.director_doctor_name,
  7583. a.diagnose,
  7584. a.placefile_date,
  7585. a.ward_name,
  7586. a.file_code
  7587. FROM
  7588. med_behospital_info a,
  7589. sys_user_dept b
  7590. WHERE
  7591. a.is_deleted = 'N'
  7592. AND b.is_deleted = 'N'
  7593. AND a.hospital_id = b.hospital_id
  7594. AND a.beh_dept_id = b.dept_id
  7595. AND a.qc_type_id != 0
  7596. <if test="qcResultShortPageVO.userId!=null">
  7597. AND b.user_id = #{qcResultShortPageVO.userId}
  7598. </if>
  7599. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7600. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7601. </if>
  7602. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7603. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7604. </if>
  7605. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7606. <if test="qcResultShortPageVO.startDate != null ">
  7607. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7608. </if>
  7609. <if test="qcResultShortPageVO.endDate != null ">
  7610. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7611. </if>
  7612. </if>
  7613. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7614. <if test="qcResultShortPageVO.startDate != null ">
  7615. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7616. </if>
  7617. <if test="qcResultShortPageVO.endDate != null">
  7618. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7619. </if>
  7620. </if>
  7621. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7622. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7623. </if>
  7624. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7625. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7626. </if>
  7627. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7628. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7629. </if>
  7630. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7631. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7632. </if>
  7633. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7634. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7635. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7636. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7637. </if>
  7638. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7639. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7640. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7641. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7642. </if>
  7643. ) b
  7644. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7645. AND b.hospital_id = c.hospital_id
  7646. AND b.behospital_code = c.behospital_code
  7647. ) tt1
  7648. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7649. ,med_medical_record tt2,
  7650. qc_mode tt3
  7651. WHERE
  7652. tt2.is_deleted = 'N'
  7653. AND tt3.is_deleted = 'N'
  7654. AND tt1.hospital_id = tt2.hospital_id
  7655. AND tt1.behospital_code = tt2.behospital_code
  7656. AND tt2.mode_id = tt3.id
  7657. AND tt3.`name` = '手术记录'
  7658. </if>
  7659. ) be
  7660. left join med_check_info mci
  7661. on mci.is_deleted = 'N'
  7662. and mci.check_type = 0
  7663. and be.hospital_id = mci.hospital_id
  7664. and be.behospital_code = mci.behospital_code
  7665. left join med_check_info hm_mci
  7666. on hm_mci.is_deleted = 'N'
  7667. and hm_mci.check_type = 1
  7668. and be.hospital_id = hm_mci.hospital_id
  7669. and be.behospital_code = hm_mci.behospital_code
  7670. LEFT JOIN med_qcresult_cases e
  7671. on be.behospital_code = e.behospital_code
  7672. and be.hospital_id = e.hospital_id
  7673. AND e.is_deleted = 'N'
  7674. and e.cases_id = 243
  7675. )t1
  7676. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7677. ,med_home_page t2
  7678. WHERE
  7679. t2.is_deleted = 'N'
  7680. AND t1.hospital_id = t2.hospital_id
  7681. AND t1.behospital_code = t2.behospital_code
  7682. AND (
  7683. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7684. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7685. )
  7686. </if>
  7687. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7688. , med_medical_record b,
  7689. med_medical_record_content c,
  7690. med_home_page t2
  7691. WHERE
  7692. b.is_deleted = 'N'
  7693. and c.is_deleted = 'N'
  7694. and t2.is_deleted = 'N'
  7695. and t1.hospital_id = b.hospital_id
  7696. and t1.hospital_id = c.hospital_id
  7697. and t1.hospital_id = t2.hospital_id
  7698. AND t1.behospital_code = b.behospital_code
  7699. AND t1.behospital_code = t2.behospital_code
  7700. AND b.rec_id = c.rec_id
  7701. and b.mode_id = '24'
  7702. </if>
  7703. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7704. ,med_home_page t2
  7705. WHERE
  7706. t2.is_deleted = 'N'
  7707. AND t1.hospital_id = t2.hospital_id
  7708. AND t1.behospital_code = t2.behospital_code
  7709. AND t2.leave_hospital_type = '非医嘱离院'
  7710. </if>
  7711. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7712. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7713. AND t1.hospital_id = t2.hospital_id
  7714. AND t1.behospital_code = t2.behospital_code
  7715. </if>
  7716. )t
  7717. where 1=1
  7718. <if test="qcResultShortPageVO.checkStatus != null">
  7719. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7720. </if>
  7721. <if test="qcResultShortPageVO.mrStatus != null">
  7722. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7723. </if>
  7724. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7725. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7726. </if>
  7727. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7728. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7729. </if>
  7730. <if test="qcResultShortPageVO.chTimeStart != null ">
  7731. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7732. </if>
  7733. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7734. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7735. </if>
  7736. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7737. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7738. </if>
  7739. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7740. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7741. </if>
  7742. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7743. AND t.`level` = #{qcResultShortPageVO.level}
  7744. </if>
  7745. </select>
  7746. <!-- 病案首页改善率统计(首页)-->
  7747. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7748. SELECT
  7749. t2.homePageMRNum,
  7750. t1.improveNum,
  7751. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  7752. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7753. t1.improveToPassNum,
  7754. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  7755. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7756. t1.improveToFullNum,
  7757. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  7758. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7759. FROM
  7760. (
  7761. SELECT
  7762. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7763. sum( d.score_res = 20 ) AS improveToFullNum,
  7764. count(*) AS improveNum
  7765. FROM
  7766. med_behospital_info a,
  7767. med_home_page b,
  7768. med_qcresult_info c,
  7769. med_qcresult_cases d,
  7770. (
  7771. SELECT
  7772. m4.*
  7773. FROM
  7774. med_behospital_info m1,
  7775. med_home_page m2,
  7776. med_qcresult_info m3,
  7777. med_qcresult_cases m4
  7778. WHERE
  7779. m1.is_deleted = 'N'
  7780. AND m2.is_deleted = 'N'
  7781. AND m3.is_deleted = 'Y'
  7782. AND m4.is_deleted = 'Y'
  7783. AND m1.hospital_id = m2.hospital_id
  7784. AND m1.hospital_id = m3.hospital_id
  7785. AND m1.hospital_id = m4.hospital_id
  7786. AND m1.behospital_code = m2.behospital_code
  7787. AND m1.behospital_code = m3.behospital_code
  7788. AND m1.behospital_code = m4.behospital_code
  7789. AND m3.gmt_create = m4.gmt_create
  7790. AND m3.have_home_page = 1
  7791. AND m4.cases_id = 243
  7792. <if test="isPlacefile != null and isPlacefile != ''">
  7793. and m1.is_placefile = #{isPlacefile}
  7794. </if>
  7795. AND m1.qc_type_id != 0
  7796. <if test="hospitalId != null and hospitalId != ''">
  7797. AND m1.hospital_id = #{hospitalId}
  7798. </if>
  7799. <if test="isPlacefile != null and isPlacefile == 0">
  7800. <if test="startDate != null and startDate != ''">
  7801. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7802. </if>
  7803. <if test="endDate != null and endDate != ''">
  7804. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7805. </if>
  7806. </if>
  7807. <if test="isPlacefile != null and isPlacefile == 1">
  7808. <if test="startDate != null and startDate != ''">
  7809. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7810. </if>
  7811. <if test="endDate != null and endDate != ''">
  7812. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7813. </if>
  7814. </if>
  7815. GROUP BY
  7816. m1.behospital_code
  7817. ORDER BY
  7818. m1.behospital_code,
  7819. m4.gmt_create
  7820. ) e
  7821. WHERE
  7822. a.is_deleted = 'N'
  7823. AND b.is_deleted = 'N'
  7824. AND c.is_deleted = 'N'
  7825. AND d.is_deleted = 'N'
  7826. AND a.hospital_id = b.hospital_id
  7827. AND a.hospital_id = c.hospital_id
  7828. AND a.hospital_id = d.hospital_id
  7829. AND a.hospital_id = e.hospital_id
  7830. AND a.behospital_code = b.behospital_code
  7831. AND a.behospital_code = c.behospital_code
  7832. AND a.behospital_code = d.behospital_code
  7833. AND a.behospital_code = e.behospital_code
  7834. AND d.cases_id = 243
  7835. AND d.score_res > e.score_res
  7836. <if test="isPlacefile != null and isPlacefile != ''">
  7837. and a.is_placefile = #{isPlacefile}
  7838. </if>
  7839. AND a.qc_type_id != 0
  7840. <if test="hospitalId != null and hospitalId != ''">
  7841. AND a.hospital_id = #{hospitalId}
  7842. </if>
  7843. <if test="isPlacefile != null and isPlacefile == 0">
  7844. <if test="startDate != null and startDate != ''">
  7845. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7846. </if>
  7847. <if test="endDate != null and endDate != ''">
  7848. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7849. </if>
  7850. </if>
  7851. <if test="isPlacefile != null and isPlacefile == 1">
  7852. <if test="startDate != null and startDate != ''">
  7853. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7854. </if>
  7855. <if test="endDate != null and endDate != ''">
  7856. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7857. </if>
  7858. </if>
  7859. ) t1,
  7860. (
  7861. SELECT
  7862. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7863. FROM
  7864. med_behospital_info a,
  7865. med_home_page b,
  7866. med_qcresult_info c
  7867. WHERE
  7868. a.is_deleted = 'N'
  7869. AND b.is_deleted = 'N'
  7870. AND a.hospital_id = b.hospital_id
  7871. AND a.hospital_id = c.hospital_id
  7872. AND a.behospital_code = b.behospital_code
  7873. AND a.behospital_code = c.behospital_code
  7874. AND a.qc_type_id != 0
  7875. <if test="isPlacefile != null and isPlacefile != ''">
  7876. and a.is_placefile = #{isPlacefile}
  7877. </if>
  7878. <if test="hospitalId != null and hospitalId != ''">
  7879. AND a.hospital_id = #{hospitalId}
  7880. </if>
  7881. <if test="isPlacefile != null and isPlacefile == 0">
  7882. <if test="startDate != null and startDate != ''">
  7883. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7884. </if>
  7885. <if test="endDate != null and endDate != ''">
  7886. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7887. </if>
  7888. </if>
  7889. <if test="isPlacefile != null and isPlacefile == 1">
  7890. <if test="startDate != null and startDate != ''">
  7891. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7892. </if>
  7893. <if test="endDate != null and endDate != ''">
  7894. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7895. </if>
  7896. </if>
  7897. ) t2
  7898. </select>
  7899. <!-- 质控核查统计(内页)-->
  7900. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7901. SELECT
  7902. t.*
  7903. FROM
  7904. (SELECT
  7905. mr.beh_dept_id AS deptId,
  7906. mr.beh_dept_name AS deptName,
  7907. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7908. ck.checkedNum AS checkedNum,
  7909. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7910. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7911. hmmr_t.homePageMRNum,
  7912. improve_t.improveNum,
  7913. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7914. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7915. improve_t.improveToPassNum,
  7916. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7917. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7918. improve_t.improveToFullNum,
  7919. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7920. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7921. FROM
  7922. (
  7923. SELECT
  7924. a.beh_dept_id,
  7925. a.beh_dept_name,
  7926. count(*) AS mrNum
  7927. FROM
  7928. med_behospital_info a,
  7929. med_qcresult_info b
  7930. WHERE
  7931. a.is_deleted = 'N'
  7932. AND b.is_deleted = 'N'
  7933. AND a.hospital_id = b.hospital_id
  7934. AND a.behospital_code = b.behospital_code
  7935. AND a.qc_type_id != 0
  7936. <if test="isPlacefile != null and isPlacefile != ''">
  7937. and a.is_placefile = #{isPlacefile}
  7938. </if>
  7939. <if test="hospitalId != null and hospitalId != ''">
  7940. AND a.hospital_id = #{hospitalId}
  7941. </if>
  7942. <if test="isPlacefile != null and isPlacefile == 0">
  7943. <if test="startDate != null and startDate != ''">
  7944. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7945. </if>
  7946. <if test="endDate != null and endDate != ''">
  7947. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7948. </if>
  7949. </if>
  7950. <if test="isPlacefile != null and isPlacefile == 1">
  7951. <if test="startDate != null and startDate != ''">
  7952. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7953. </if>
  7954. <if test="endDate != null and endDate != ''">
  7955. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7956. </if>
  7957. </if>
  7958. <if test="deptName != null and deptName != ''">
  7959. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7960. </if>
  7961. GROUP BY
  7962. a.beh_dept_id,
  7963. a.beh_dept_name
  7964. ) mr
  7965. LEFT JOIN (
  7966. SELECT
  7967. a.beh_dept_id,
  7968. a.beh_dept_name,
  7969. count(*) AS checkedNum
  7970. FROM
  7971. med_behospital_info a,
  7972. med_qcresult_info b,
  7973. med_check_info c
  7974. WHERE
  7975. a.is_deleted = 'N'
  7976. AND b.is_deleted = 'N'
  7977. AND c.is_deleted = 'N'
  7978. AND a.hospital_id = b.hospital_id
  7979. AND a.hospital_id = c.hospital_id
  7980. AND a.behospital_code = b.behospital_code
  7981. AND a.behospital_code = c.behospital_code
  7982. AND a.qc_type_id != 0
  7983. AND ifnull(c.`status`,0) = 1
  7984. AND c.check_type in (0,2)
  7985. <if test="isPlacefile != null and isPlacefile != ''">
  7986. and a.is_placefile = #{isPlacefile}
  7987. </if>
  7988. <if test="hospitalId != null and hospitalId != ''">
  7989. AND a.hospital_id = #{hospitalId}
  7990. </if>
  7991. <if test="isPlacefile != null and isPlacefile == 0">
  7992. <if test="startDate != null and startDate != ''">
  7993. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7994. </if>
  7995. <if test="endDate != null and endDate != ''">
  7996. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7997. </if>
  7998. </if>
  7999. <if test="isPlacefile != null and isPlacefile == 1">
  8000. <if test="startDate != null and startDate != ''">
  8001. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8002. </if>
  8003. <if test="endDate != null and endDate != ''">
  8004. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8005. </if>
  8006. </if>
  8007. <if test="deptName != null and deptName != ''">
  8008. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8009. </if>
  8010. GROUP BY
  8011. a.beh_dept_id,
  8012. a.beh_dept_name
  8013. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  8014. AND mr.beh_dept_name = ck.beh_dept_name
  8015. LEFT JOIN (
  8016. SELECT
  8017. a.beh_dept_id,
  8018. a.beh_dept_name,
  8019. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8020. FROM
  8021. med_behospital_info a,
  8022. med_home_page b,
  8023. med_qcresult_info c
  8024. WHERE
  8025. a.is_deleted = 'N'
  8026. AND b.is_deleted = 'N'
  8027. AND a.hospital_id = b.hospital_id
  8028. AND a.hospital_id = c.hospital_id
  8029. AND a.behospital_code = b.behospital_code
  8030. AND a.behospital_code = c.behospital_code
  8031. AND a.qc_type_id != 0
  8032. <if test="isPlacefile != null and isPlacefile != ''">
  8033. and a.is_placefile = #{isPlacefile}
  8034. </if>
  8035. <if test="hospitalId != null and hospitalId != ''">
  8036. AND a.hospital_id = #{hospitalId}
  8037. </if>
  8038. <if test="isPlacefile != null and isPlacefile == 0">
  8039. <if test="startDate != null and startDate != ''">
  8040. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8041. </if>
  8042. <if test="endDate != null and endDate != ''">
  8043. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8044. </if>
  8045. </if>
  8046. <if test="isPlacefile != null and isPlacefile == 1">
  8047. <if test="startDate != null and startDate != ''">
  8048. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8049. </if>
  8050. <if test="endDate != null and endDate != ''">
  8051. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8052. </if>
  8053. </if>
  8054. <if test="deptName != null and deptName != ''">
  8055. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8056. </if>
  8057. GROUP BY
  8058. a.beh_dept_id,
  8059. a.beh_dept_name
  8060. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  8061. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  8062. LEFT JOIN (
  8063. SELECT
  8064. a.beh_dept_id,
  8065. a.beh_dept_name,
  8066. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8067. sum( d.score_res = 20 ) AS improveToFullNum,
  8068. count(*) AS improveNum
  8069. FROM
  8070. med_behospital_info a,
  8071. med_home_page b,
  8072. med_qcresult_info c,
  8073. med_qcresult_cases d,
  8074. (
  8075. SELECT
  8076. m4.*
  8077. FROM
  8078. med_behospital_info m1,
  8079. med_home_page m2,
  8080. med_qcresult_info m3,
  8081. med_qcresult_cases m4
  8082. WHERE
  8083. m1.is_deleted = 'N'
  8084. AND m2.is_deleted = 'N'
  8085. AND m3.is_deleted = 'Y'
  8086. AND m4.is_deleted = 'Y'
  8087. AND m1.hospital_id = m2.hospital_id
  8088. AND m1.hospital_id = m3.hospital_id
  8089. AND m1.hospital_id = m4.hospital_id
  8090. AND m1.behospital_code = m2.behospital_code
  8091. AND m1.behospital_code = m3.behospital_code
  8092. AND m1.behospital_code = m4.behospital_code
  8093. AND m3.gmt_create = m4.gmt_create
  8094. AND m3.have_home_page = 1
  8095. AND m4.cases_id = 243
  8096. <if test="isPlacefile != null and isPlacefile != ''">
  8097. and m1.is_placefile = #{isPlacefile}
  8098. </if>
  8099. AND m1.qc_type_id != 0
  8100. <if test="hospitalId != null and hospitalId != ''">
  8101. AND m1.hospital_id = #{hospitalId}
  8102. </if>
  8103. <if test="isPlacefile != null and isPlacefile == 0">
  8104. <if test="startDate != null and startDate != ''">
  8105. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8106. </if>
  8107. <if test="endDate != null and endDate != ''">
  8108. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8109. </if>
  8110. </if>
  8111. <if test="isPlacefile != null and isPlacefile == 1">
  8112. <if test="startDate != null and startDate != ''">
  8113. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8114. </if>
  8115. <if test="endDate != null and endDate != ''">
  8116. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8117. </if>
  8118. </if>
  8119. <if test="deptName != null and deptName != ''">
  8120. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8121. </if>
  8122. GROUP BY
  8123. m1.behospital_code
  8124. ORDER BY
  8125. m1.behospital_code,
  8126. m4.gmt_create
  8127. ) e
  8128. WHERE
  8129. a.is_deleted = 'N'
  8130. AND b.is_deleted = 'N'
  8131. AND c.is_deleted = 'N'
  8132. AND d.is_deleted = 'N'
  8133. AND a.hospital_id = b.hospital_id
  8134. AND a.hospital_id = c.hospital_id
  8135. AND a.hospital_id = d.hospital_id
  8136. AND a.hospital_id = e.hospital_id
  8137. AND a.behospital_code = b.behospital_code
  8138. AND a.behospital_code = c.behospital_code
  8139. AND a.behospital_code = d.behospital_code
  8140. AND a.behospital_code = e.behospital_code
  8141. AND d.cases_id = 243
  8142. AND d.score_res > e.score_res
  8143. <if test="hospitalId != null and hospitalId != ''">
  8144. AND a.hospital_id = #{hospitalId}
  8145. </if>
  8146. <if test="isPlacefile != null and isPlacefile == 0">
  8147. <if test="startDate != null and startDate != ''">
  8148. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8149. </if>
  8150. <if test="endDate != null and endDate != ''">
  8151. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8152. </if>
  8153. </if>
  8154. <if test="isPlacefile != null and isPlacefile == 1">
  8155. <if test="startDate != null and startDate != ''">
  8156. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8157. </if>
  8158. <if test="endDate != null and endDate != ''">
  8159. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8160. </if>
  8161. </if>
  8162. <if test="deptName != null and deptName != ''">
  8163. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8164. </if>
  8165. GROUP BY
  8166. a.beh_dept_id,
  8167. a.beh_dept_name
  8168. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  8169. AND mr.beh_dept_name = improve_t.beh_dept_name
  8170. ) t
  8171. <if test="asc != null and asc !=''">
  8172. order by
  8173. <choose>
  8174. <when test='asc=="deptId"'>deptId asc</when>
  8175. <when test='asc=="deptName"'>deptName asc</when>
  8176. <when test='asc=="mrNum"'>mrNum asc</when>
  8177. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8178. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8179. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8180. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8181. <when test='asc=="improveNum"'>improveNum asc</when>
  8182. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8183. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8184. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8185. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8186. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8187. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8188. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8189. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8190. <otherwise>deptName asc</otherwise>
  8191. </choose>
  8192. </if>
  8193. <if test="desc != null and desc!=''">
  8194. order by
  8195. <choose>
  8196. <when test='desc=="deptId"'>deptId desc</when>
  8197. <when test='desc=="deptName"'>deptName desc</when>
  8198. <when test='desc=="mrNum"'>mrNum desc</when>
  8199. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8200. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8201. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8202. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8203. <when test='desc=="improveNum"'>improveNum desc</when>
  8204. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8205. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8206. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8207. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8208. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8209. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8210. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8211. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8212. <otherwise>deptName desc</otherwise>
  8213. </choose>
  8214. </if>
  8215. </select>
  8216. <!-- 质控核查统计-科室(内页)-->
  8217. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  8218. SELECT
  8219. t.*
  8220. FROM
  8221. (SELECT
  8222. mr.beh_dept_id AS deptId,
  8223. mr.beh_dept_name AS deptName,
  8224. mr.doctorId,
  8225. mr.doctorName,
  8226. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8227. ck.checkedNum AS checkedNum,
  8228. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8229. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8230. hmmr_t.homePageMRNum,
  8231. improve_t.improveNum,
  8232. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8233. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8234. improve_t.improveToPassNum,
  8235. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8236. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8237. improve_t.improveToFullNum,
  8238. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8239. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8240. FROM
  8241. (
  8242. SELECT
  8243. a.beh_dept_id,
  8244. a.beh_dept_name,
  8245. a.doctor_id as doctorId,
  8246. a.doctor_name as doctorName,
  8247. count(*) AS mrNum
  8248. FROM
  8249. med_behospital_info a,
  8250. med_qcresult_info b,
  8251. sys_user_dept c
  8252. WHERE
  8253. a.is_deleted = 'N'
  8254. AND b.is_deleted = 'N'
  8255. AND c.is_deleted = 'N'
  8256. AND a.hospital_id = b.hospital_id
  8257. AND a.hospital_id = c.hospital_id
  8258. AND a.beh_dept_id = c.dept_id
  8259. AND a.behospital_code = b.behospital_code
  8260. AND a.qc_type_id != 0
  8261. <if test="userId!=null">
  8262. AND c.user_id = #{userId}
  8263. </if>
  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 = #{deptName}
  8288. </if>
  8289. <if test="doctorName != null and doctorName != ''">
  8290. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8291. </if>
  8292. GROUP BY
  8293. a.doctor_id,
  8294. a.doctor_name
  8295. ) mr
  8296. LEFT JOIN (
  8297. SELECT
  8298. a.beh_dept_id,
  8299. a.beh_dept_name,
  8300. a.doctor_id as doctorId,
  8301. a.doctor_name as doctorName,
  8302. count(*) AS checkedNum
  8303. FROM
  8304. med_behospital_info a,
  8305. med_qcresult_info b,
  8306. med_check_info c,
  8307. sys_user_dept d
  8308. WHERE
  8309. a.is_deleted = 'N'
  8310. AND b.is_deleted = 'N'
  8311. AND c.is_deleted = 'N'
  8312. AND d.is_deleted = 'N'
  8313. AND a.hospital_id = b.hospital_id
  8314. AND a.hospital_id = c.hospital_id
  8315. AND a.hospital_id = d.hospital_id
  8316. AND a.behospital_code = b.behospital_code
  8317. AND a.behospital_code = c.behospital_code
  8318. AND a.beh_dept_id = d.dept_id
  8319. AND a.qc_type_id != 0
  8320. AND ifnull(c.`status`,0) = 1
  8321. AND c.check_type = 0
  8322. <if test="userId!=null">
  8323. AND d.user_id = #{userId}
  8324. </if>
  8325. <if test="isPlacefile != null and isPlacefile != ''">
  8326. and a.is_placefile = #{isPlacefile}
  8327. </if>
  8328. <if test="hospitalId != null and hospitalId != ''">
  8329. AND a.hospital_id = #{hospitalId}
  8330. </if>
  8331. <if test="isPlacefile != null and isPlacefile == 0">
  8332. <if test="startDate != null and startDate != ''">
  8333. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8334. </if>
  8335. <if test="endDate != null and endDate != ''">
  8336. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8337. </if>
  8338. </if>
  8339. <if test="isPlacefile != null and isPlacefile == 1">
  8340. <if test="startDate != null and startDate != ''">
  8341. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8342. </if>
  8343. <if test="endDate != null and endDate != ''">
  8344. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8345. </if>
  8346. </if>
  8347. <if test="deptName != null and deptName != ''">
  8348. and a.beh_dept_name = #{deptName}
  8349. </if>
  8350. <if test="doctorName != null and doctorName != ''">
  8351. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8352. </if>
  8353. GROUP BY
  8354. a.doctor_id,
  8355. a.doctor_name
  8356. ) ck ON mr.doctorId = ck.doctorId
  8357. AND mr.doctorName = ck.doctorName
  8358. LEFT JOIN (
  8359. SELECT
  8360. a.beh_dept_id,
  8361. a.beh_dept_name,
  8362. a.doctor_id as doctorId,
  8363. a.doctor_name as doctorName,
  8364. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8365. FROM
  8366. med_behospital_info a,
  8367. med_home_page b,
  8368. med_qcresult_info c,
  8369. sys_user_dept d
  8370. WHERE
  8371. a.is_deleted = 'N'
  8372. AND b.is_deleted = 'N'
  8373. AND c.is_deleted = 'N'
  8374. AND d.is_deleted = 'N'
  8375. AND a.hospital_id = b.hospital_id
  8376. AND a.hospital_id = c.hospital_id
  8377. AND a.hospital_id = d.hospital_id
  8378. AND a.behospital_code = b.behospital_code
  8379. AND a.behospital_code = c.behospital_code
  8380. AND a.beh_dept_id = d.dept_id
  8381. AND a.qc_type_id != 0
  8382. <if test="userId!=null">
  8383. AND d.user_id = #{userId}
  8384. </if>
  8385. <if test="isPlacefile != null and isPlacefile != ''">
  8386. and a.is_placefile = #{isPlacefile}
  8387. </if>
  8388. <if test="hospitalId != null and hospitalId != ''">
  8389. AND a.hospital_id = #{hospitalId}
  8390. </if>
  8391. <if test="isPlacefile != null and isPlacefile == 0">
  8392. <if test="startDate != null and startDate != ''">
  8393. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8394. </if>
  8395. <if test="endDate != null and endDate != ''">
  8396. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8397. </if>
  8398. </if>
  8399. <if test="isPlacefile != null and isPlacefile == 1">
  8400. <if test="startDate != null and startDate != ''">
  8401. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8402. </if>
  8403. <if test="endDate != null and endDate != ''">
  8404. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8405. </if>
  8406. </if>
  8407. <if test="deptName != null and deptName != ''">
  8408. and a.beh_dept_name = #{deptName}
  8409. </if>
  8410. <if test="doctorName != null and doctorName != ''">
  8411. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8412. </if>
  8413. GROUP BY
  8414. a.doctor_id,
  8415. a.doctor_name
  8416. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8417. AND mr.doctorName = hmmr_t.doctorName
  8418. LEFT JOIN (
  8419. SELECT
  8420. a.beh_dept_id,
  8421. a.beh_dept_name,
  8422. a.doctor_id as doctorId,
  8423. a.doctor_name as doctorName,
  8424. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8425. sum( d.score_res = 20 ) AS improveToFullNum,
  8426. count(*) AS improveNum
  8427. FROM
  8428. med_behospital_info a,
  8429. med_home_page b,
  8430. med_qcresult_info c,
  8431. med_qcresult_cases d,
  8432. sys_user_dept f,
  8433. (
  8434. SELECT
  8435. m4.*
  8436. FROM
  8437. med_behospital_info m1,
  8438. med_home_page m2,
  8439. med_qcresult_info m3,
  8440. med_qcresult_cases m4
  8441. WHERE
  8442. m1.is_deleted = 'N'
  8443. AND m2.is_deleted = 'N'
  8444. AND m3.is_deleted = 'Y'
  8445. AND m4.is_deleted = 'Y'
  8446. AND m1.hospital_id = m2.hospital_id
  8447. AND m1.hospital_id = m3.hospital_id
  8448. AND m1.hospital_id = m4.hospital_id
  8449. AND m1.behospital_code = m2.behospital_code
  8450. AND m1.behospital_code = m3.behospital_code
  8451. AND m1.behospital_code = m4.behospital_code
  8452. AND m3.gmt_create = m4.gmt_create
  8453. AND m3.have_home_page = 1
  8454. AND m4.cases_id = 243
  8455. <if test="isPlacefile != null and isPlacefile != ''">
  8456. and m1.is_placefile = #{isPlacefile}
  8457. </if>
  8458. AND m1.qc_type_id != 0
  8459. <if test="hospitalId != null and hospitalId != ''">
  8460. AND m1.hospital_id = #{hospitalId}
  8461. </if>
  8462. <if test="isPlacefile != null and isPlacefile == 0">
  8463. <if test="startDate != null and startDate != ''">
  8464. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8465. </if>
  8466. <if test="endDate != null and endDate != ''">
  8467. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8468. </if>
  8469. </if>
  8470. <if test="isPlacefile != null and isPlacefile == 1">
  8471. <if test="startDate != null and startDate != ''">
  8472. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8473. </if>
  8474. <if test="endDate != null and endDate != ''">
  8475. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8476. </if>
  8477. </if>
  8478. <if test="deptName != null and deptName != ''">
  8479. and m1.beh_dept_name = #{deptName}
  8480. </if>
  8481. GROUP BY
  8482. m1.behospital_code
  8483. ORDER BY
  8484. m1.behospital_code,
  8485. m4.gmt_create
  8486. ) e
  8487. WHERE
  8488. a.is_deleted = 'N'
  8489. AND b.is_deleted = 'N'
  8490. AND c.is_deleted = 'N'
  8491. AND d.is_deleted = 'N'
  8492. AND f.is_deleted = 'N'
  8493. AND a.hospital_id = b.hospital_id
  8494. AND a.hospital_id = c.hospital_id
  8495. AND a.hospital_id = d.hospital_id
  8496. AND a.hospital_id = e.hospital_id
  8497. AND a.hospital_id = f.hospital_id
  8498. AND a.behospital_code = b.behospital_code
  8499. AND a.behospital_code = c.behospital_code
  8500. AND a.behospital_code = d.behospital_code
  8501. AND a.behospital_code = e.behospital_code
  8502. AND a.beh_dept_id = f.dept_id
  8503. <if test="userId!=null">
  8504. AND f.user_id = #{userId}
  8505. </if>
  8506. AND d.cases_id = 243
  8507. AND d.score_res > e.score_res
  8508. <if test="hospitalId != null and hospitalId != ''">
  8509. AND a.hospital_id = #{hospitalId}
  8510. </if>
  8511. <if test="isPlacefile != null and isPlacefile == 0">
  8512. <if test="startDate != null and startDate != ''">
  8513. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8514. </if>
  8515. <if test="endDate != null and endDate != ''">
  8516. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8517. </if>
  8518. </if>
  8519. <if test="isPlacefile != null and isPlacefile == 1">
  8520. <if test="startDate != null and startDate != ''">
  8521. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8522. </if>
  8523. <if test="endDate != null and endDate != ''">
  8524. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8525. </if>
  8526. </if>
  8527. <if test="doctorName != null and doctorName != ''">
  8528. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8529. </if>
  8530. <if test="deptName != null and deptName != ''">
  8531. and a.beh_dept_name = #{deptName}
  8532. </if>
  8533. GROUP BY
  8534. a.doctor_id,
  8535. a.doctor_name
  8536. ) improve_t ON mr.doctorId = improve_t.doctorId
  8537. AND mr.doctorName = improve_t.doctorName
  8538. ) t
  8539. <if test="asc != null and asc !=''">
  8540. order by
  8541. <choose>
  8542. <when test='asc=="deptId"'>deptId asc</when>
  8543. <when test='asc=="deptName"'>deptName asc</when>
  8544. <when test='asc=="doctorName"'>doctorName asc</when>
  8545. <when test='asc=="mrNum"'>mrNum asc</when>
  8546. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8547. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8548. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8549. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8550. <when test='asc=="improveNum"'>improveNum asc</when>
  8551. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8552. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8553. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8554. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8555. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8556. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8557. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8558. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8559. <otherwise>doctorName asc</otherwise>
  8560. </choose>
  8561. </if>
  8562. <if test="desc != null and desc!=''">
  8563. order by
  8564. <choose>
  8565. <when test='desc=="deptId"'>deptId desc</when>
  8566. <when test='desc=="deptName"'>deptName desc</when>
  8567. <when test='desc=="doctorName"'>doctorName desc</when>
  8568. <when test='desc=="mrNum"'>mrNum desc</when>
  8569. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8570. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8571. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8572. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8573. <when test='desc=="improveNum"'>improveNum desc</when>
  8574. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8575. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8576. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8577. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8578. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8579. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8580. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8581. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8582. <otherwise>deptName desc</otherwise>
  8583. </choose>
  8584. </if>
  8585. </select>
  8586. <!-- 离院病人评分详情页导出-->
  8587. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  8588. SELECT
  8589. f1.behDeptId,
  8590. f1.behDeptName,
  8591. f1.doctorName,
  8592. f1.patName,
  8593. f1.behospitalCode,
  8594. f1.hospitalId,
  8595. f1.behospitalDate,
  8596. f1.leaveHospitalDate,
  8597. f1.score,
  8598. f2.avgScore,
  8599. f1.scoreBn,
  8600. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8601. f1.msg,
  8602. f1.caseName,
  8603. </if>
  8604. f1.checkStatus,
  8605. f1.mrStatus,
  8606. f1.chName,
  8607. f1.mrName,
  8608. f1.chTime,
  8609. f1.mrTime
  8610. FROM
  8611. (SELECT
  8612. t.doctorName,
  8613. t.`name` AS patName,
  8614. t.behospitalCode AS behospitalCode,
  8615. t.behospitalDate AS behospitalDate,
  8616. t.leaveHospitalDate AS leaveHospitalDate,
  8617. qi.score_res AS score,
  8618. t.scoreBn,
  8619. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8620. qd.msg AS msg,
  8621. qc.NAME AS caseName,
  8622. </if>
  8623. t.behDeptId,
  8624. t.behDeptName,
  8625. t.hospitalId,
  8626. t.checkStatus,
  8627. t.mrStatus,
  8628. t.chName,
  8629. t.mrName,
  8630. t.chTime,
  8631. t.mrTime
  8632. FROM
  8633. (SELECT DISTINCT
  8634. t1.hospital_id AS hospitalId,
  8635. t1.behospital_code AS behospitalCode,
  8636. t1.bed_code AS bedCode,
  8637. t1.LEVEL AS LEVEL,
  8638. t1.grade_type AS gradeType,
  8639. t1.score_res AS scoreRes,
  8640. t1.scoreBn,
  8641. t1.NAME AS NAME,
  8642. t1.sex AS sex,
  8643. t1.beh_dept_id AS behDeptId,
  8644. t1.beh_dept_name AS behDeptName,
  8645. t1.doctor_id AS doctorId,
  8646. t1.doctor_name AS doctorName,
  8647. t1.beh_doctor_id AS behDoctorId,
  8648. t1.beh_doctor_name AS behDoctorName,
  8649. t1.director_doctor_id AS directorDoctorId,
  8650. t1.director_doctor_name AS directorDoctorName,
  8651. t1.birthday AS birthday,
  8652. t1.behospital_date AS behospitalDate,
  8653. t1.leave_hospital_date AS leaveHospitalDate,
  8654. t1.placefile_date AS placefileDate,
  8655. t1.gmt_create AS gradeTime,
  8656. t1.diagnose,
  8657. t1.ward_name AS wardName,
  8658. t1.checkStatus,
  8659. t1.mrStatus,
  8660. t1.chName,
  8661. t1.mrName,
  8662. t1.chTime,
  8663. t1.mrTime,
  8664. t2.age,
  8665. t1.file_code AS fileCode
  8666. FROM
  8667. (
  8668. SELECT be.*,
  8669. ifnull(mci.status,0) AS checkStatus,
  8670. ifnull(hm_mci.status,0) AS mrStatus,
  8671. mci.check_name as chName,
  8672. e.score_res as scoreBn,
  8673. hm_mci.check_name as mrName,
  8674. mci.gmt_create as chTime,
  8675. hm_mci.gmt_create as mrTime
  8676. FROM
  8677. (
  8678. SELECT DISTINCT
  8679. tt1.*
  8680. FROM
  8681. (
  8682. SELECT
  8683. b.*,
  8684. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8685. c.grade_type,
  8686. c.score_res,
  8687. c.gmt_create
  8688. FROM
  8689. (
  8690. SELECT DISTINCT
  8691. a.hospital_id,
  8692. a.behospital_code,
  8693. a.bed_code,
  8694. a.NAME,
  8695. a.sex,
  8696. a.beh_dept_id,
  8697. a.beh_dept_name,
  8698. a.birthday,
  8699. a.behospital_date,
  8700. a.leave_hospital_date,
  8701. a.doctor_id,
  8702. a.doctor_name,
  8703. a.beh_doctor_id,
  8704. a.beh_doctor_name,
  8705. a.director_doctor_id,
  8706. a.director_doctor_name,
  8707. a.diagnose,
  8708. a.placefile_date,
  8709. a.ward_name,
  8710. a.file_code
  8711. FROM
  8712. med_behospital_info a
  8713. WHERE
  8714. a.is_deleted = 'N'
  8715. AND a.qc_type_id != 0
  8716. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8717. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8718. </if>
  8719. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8720. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8721. </if>
  8722. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8723. <if test="qcResultShortPageVO.startDate != null ">
  8724. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8725. </if>
  8726. <if test="qcResultShortPageVO.endDate != null ">
  8727. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8728. </if>
  8729. </if>
  8730. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8731. <if test="qcResultShortPageVO.startDate != null ">
  8732. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8733. </if>
  8734. <if test="qcResultShortPageVO.endDate != null">
  8735. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8736. </if>
  8737. </if>
  8738. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8739. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8740. </if>
  8741. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8742. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8743. </if>
  8744. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8745. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8746. </if>
  8747. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8748. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8749. </if>
  8750. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8751. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8752. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8753. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8754. </if>
  8755. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8756. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8757. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8758. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8759. </if>
  8760. ) b
  8761. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8762. AND b.hospital_id = c.hospital_id
  8763. AND b.behospital_code = c.behospital_code
  8764. ) tt1
  8765. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8766. ,med_medical_record tt2,
  8767. qc_mode tt3
  8768. WHERE
  8769. tt2.is_deleted = 'N'
  8770. AND tt3.is_deleted = 'N'
  8771. AND tt1.hospital_id = tt2.hospital_id
  8772. AND tt1.behospital_code = tt2.behospital_code
  8773. AND tt2.mode_id = tt3.id
  8774. AND tt3.`name` = '手术记录'
  8775. </if>
  8776. ) be
  8777. left join med_check_info mci
  8778. on mci.is_deleted = 'N'
  8779. and mci.check_type = 0
  8780. and be.hospital_id = mci.hospital_id
  8781. and be.behospital_code = mci.behospital_code
  8782. left join med_check_info hm_mci
  8783. on hm_mci.is_deleted = 'N'
  8784. and hm_mci.check_type = 1
  8785. and be.hospital_id = hm_mci.hospital_id
  8786. and be.behospital_code = hm_mci.behospital_code
  8787. LEFT JOIN med_qcresult_cases e
  8788. on be.behospital_code = e.behospital_code
  8789. and be.hospital_id = e.hospital_id
  8790. AND e.is_deleted = 'N'
  8791. and e.cases_id = 243
  8792. )t1
  8793. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8794. ,med_home_page t2
  8795. WHERE
  8796. t2.is_deleted = 'N'
  8797. AND t1.hospital_id = t2.hospital_id
  8798. AND t1.behospital_code = t2.behospital_code
  8799. AND (
  8800. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  8801. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8802. )
  8803. </if>
  8804. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8805. ,med_home_page t2
  8806. WHERE
  8807. t2.is_deleted = 'N'
  8808. AND t1.hospital_id = t2.hospital_id
  8809. AND t1.behospital_code = t2.behospital_code
  8810. AND t2.return_to_type = '死亡'
  8811. </if>
  8812. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8813. ,med_home_page t2
  8814. WHERE
  8815. t2.is_deleted = 'N'
  8816. AND t1.hospital_id = t2.hospital_id
  8817. AND t1.behospital_code = t2.behospital_code
  8818. AND t2.leave_hospital_type = '非医嘱离院'
  8819. </if>
  8820. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8821. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8822. AND t1.hospital_id = t2.hospital_id
  8823. AND t1.behospital_code = t2.behospital_code
  8824. </if>
  8825. )t
  8826. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8827. AND t.hospitalId = qi.hospital_id
  8828. AND t.behospitalCode = qi.behospital_code
  8829. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8830. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  8831. AND t.hospitalId = qd.hospital_id
  8832. AND t.behospitalCode = qd.behospital_code
  8833. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  8834. AND qd.cases_id = qc.id
  8835. </if>
  8836. where 1=1
  8837. <if test="qcResultShortPageVO.checkStatus != null">
  8838. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8839. </if>
  8840. <if test="qcResultShortPageVO.mrStatus != null">
  8841. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8842. </if>
  8843. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8844. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8845. </if>
  8846. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8847. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8848. </if>
  8849. <if test="qcResultShortPageVO.chTimeStart != null ">
  8850. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8851. </if>
  8852. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8853. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8854. </if>
  8855. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8856. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8857. </if>
  8858. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8859. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8860. </if>
  8861. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8862. AND t.`level` = #{qcResultShortPageVO.level}
  8863. </if>)f1,(SELECT
  8864. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8865. t.behDeptId,
  8866. t.behDeptName
  8867. FROM
  8868. (SELECT DISTINCT
  8869. t1.hospital_id AS hospitalId,
  8870. t1.behospital_code AS behospitalCode,
  8871. t1.bed_code AS bedCode,
  8872. t1.LEVEL AS LEVEL,
  8873. t1.grade_type AS gradeType,
  8874. t1.score_res AS scoreRes,
  8875. t1.NAME AS NAME,
  8876. t1.sex AS sex,
  8877. t1.beh_dept_id AS behDeptId,
  8878. t1.beh_dept_name AS behDeptName,
  8879. t1.doctor_id AS doctorId,
  8880. t1.doctor_name AS doctorName,
  8881. t1.beh_doctor_id AS behDoctorId,
  8882. t1.beh_doctor_name AS behDoctorName,
  8883. t1.director_doctor_id AS directorDoctorId,
  8884. t1.director_doctor_name AS directorDoctorName,
  8885. t1.birthday AS birthday,
  8886. t1.behospital_date AS behospitalDate,
  8887. t1.leave_hospital_date AS leaveHospitalDate,
  8888. t1.placefile_date AS placefileDate,
  8889. t1.gmt_create AS gradeTime,
  8890. t1.diagnose,
  8891. t1.ward_name AS wardName,
  8892. t1.checkStatus,
  8893. t1.mrStatus,
  8894. t1.chName,
  8895. t1.mrName,
  8896. t1.chTime,
  8897. t1.mrTime,
  8898. t2.age,
  8899. t1.file_code AS fileCode
  8900. FROM
  8901. (
  8902. SELECT be.*,
  8903. ifnull(mci.status,0) AS checkStatus,
  8904. ifnull(hm_mci.status,0) AS mrStatus,
  8905. mci.check_name as chName,
  8906. hm_mci.check_name as mrName,
  8907. mci.gmt_create as chTime,
  8908. hm_mci.gmt_create as mrTime
  8909. FROM
  8910. (
  8911. SELECT DISTINCT
  8912. tt1.*
  8913. FROM
  8914. (
  8915. SELECT
  8916. b.*,
  8917. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8918. c.grade_type,
  8919. c.score_res,
  8920. c.gmt_create
  8921. FROM
  8922. (
  8923. SELECT DISTINCT
  8924. a.hospital_id,
  8925. a.behospital_code,
  8926. a.bed_code,
  8927. a.NAME,
  8928. a.sex,
  8929. a.beh_dept_id,
  8930. a.beh_dept_name,
  8931. a.birthday,
  8932. a.behospital_date,
  8933. a.leave_hospital_date,
  8934. a.doctor_id,
  8935. a.doctor_name,
  8936. a.beh_doctor_id,
  8937. a.beh_doctor_name,
  8938. a.director_doctor_id,
  8939. a.director_doctor_name,
  8940. a.diagnose,
  8941. a.placefile_date,
  8942. a.ward_name,
  8943. a.file_code
  8944. FROM
  8945. med_behospital_info a
  8946. WHERE
  8947. a.is_deleted = 'N'
  8948. AND a.qc_type_id != 0
  8949. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8950. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8951. </if>
  8952. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8953. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8954. </if>
  8955. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8956. <if test="qcResultShortPageVO.startDate != null ">
  8957. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8958. </if>
  8959. <if test="qcResultShortPageVO.endDate != null ">
  8960. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8961. </if>
  8962. </if>
  8963. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8964. <if test="qcResultShortPageVO.startDate != null ">
  8965. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8966. </if>
  8967. <if test="qcResultShortPageVO.endDate != null">
  8968. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8969. </if>
  8970. </if>
  8971. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8972. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8973. </if>
  8974. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8975. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8976. </if>
  8977. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8978. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8979. </if>
  8980. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8981. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8982. </if>
  8983. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8984. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8985. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8986. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8987. </if>
  8988. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8989. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8990. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8991. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8992. </if>
  8993. ) b
  8994. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8995. AND b.hospital_id = c.hospital_id
  8996. AND b.behospital_code = c.behospital_code
  8997. ) tt1
  8998. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8999. ,med_medical_record tt2,
  9000. qc_mode tt3
  9001. WHERE
  9002. tt2.is_deleted = 'N'
  9003. AND tt3.is_deleted = 'N'
  9004. AND tt1.hospital_id = tt2.hospital_id
  9005. AND tt1.behospital_code = tt2.behospital_code
  9006. AND tt2.mode_id = tt3.id
  9007. AND tt3.`name` = '手术记录'
  9008. </if>
  9009. ) be
  9010. left join med_check_info mci
  9011. on mci.is_deleted = 'N'
  9012. and mci.check_type = 0
  9013. and be.hospital_id = mci.hospital_id
  9014. and be.behospital_code = mci.behospital_code
  9015. left join med_check_info hm_mci
  9016. on hm_mci.is_deleted = 'N'
  9017. and hm_mci.check_type = 1
  9018. and be.hospital_id = hm_mci.hospital_id
  9019. and be.behospital_code = hm_mci.behospital_code
  9020. )t1
  9021. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9022. ,med_home_page t2
  9023. WHERE
  9024. t2.is_deleted = 'N'
  9025. AND t1.hospital_id = t2.hospital_id
  9026. AND t1.behospital_code = t2.behospital_code
  9027. AND (
  9028. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  9029. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9030. )
  9031. </if>
  9032. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9033. ,med_home_page t2
  9034. WHERE
  9035. t2.is_deleted = 'N'
  9036. AND t1.hospital_id = t2.hospital_id
  9037. AND t1.behospital_code = t2.behospital_code
  9038. AND t2.return_to_type = '死亡'
  9039. </if>
  9040. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9041. ,med_home_page t2
  9042. WHERE
  9043. t2.is_deleted = 'N'
  9044. AND t1.hospital_id = t2.hospital_id
  9045. AND t1.behospital_code = t2.behospital_code
  9046. AND t2.leave_hospital_type = '非医嘱离院'
  9047. </if>
  9048. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9049. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9050. AND t1.hospital_id = t2.hospital_id
  9051. AND t1.behospital_code = t2.behospital_code
  9052. </if>
  9053. )t
  9054. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9055. AND t.hospitalId = qi.hospital_id
  9056. AND t.behospitalCode = qi.behospital_code
  9057. where 1=1
  9058. <if test="qcResultShortPageVO.checkStatus != null">
  9059. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9060. </if>
  9061. <if test="qcResultShortPageVO.mrStatus != null">
  9062. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9063. </if>
  9064. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9065. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9066. </if>
  9067. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9068. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9069. </if>
  9070. <if test="qcResultShortPageVO.chTimeStart != null ">
  9071. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9072. </if>
  9073. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9074. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9075. </if>
  9076. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9077. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9078. </if>
  9079. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9080. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9081. </if>
  9082. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9083. AND t.`level` = #{qcResultShortPageVO.level}
  9084. </if>
  9085. GROUP BY
  9086. t.behDeptId,
  9087. t.behDeptName
  9088. )f2
  9089. WHERE
  9090. f1.behDeptId = f2.behDeptId
  9091. AND f1.behDeptName = f2.behDeptName
  9092. </select>
  9093. <!-- 离院病人评分详情页导出-科室-->
  9094. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  9095. SELECT
  9096. f1.behDeptId,
  9097. f1.behDeptName,
  9098. f1.doctorName,
  9099. f1.patName,
  9100. f1.behospitalCode,
  9101. f1.hospitalId,
  9102. f1.behospitalDate,
  9103. f1.leaveHospitalDate,
  9104. f1.score,
  9105. f2.avgScore,
  9106. f1.scoreBn,
  9107. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9108. f1.msg,
  9109. f1.caseName,
  9110. </if>
  9111. f1.checkStatus,
  9112. f1.mrStatus,
  9113. f1.chName,
  9114. f1.mrName,
  9115. f1.chTime,
  9116. f1.mrTime
  9117. FROM
  9118. (SELECT
  9119. t.doctorName,
  9120. t.doctorId,
  9121. t.`name` AS patName,
  9122. t.behospitalCode AS behospitalCode,
  9123. t.behospitalDate AS behospitalDate,
  9124. t.leaveHospitalDate AS leaveHospitalDate,
  9125. qi.score_res AS score,
  9126. t.scoreBn,
  9127. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9128. qd.msg AS msg,
  9129. qc.NAME AS caseName,
  9130. </if>
  9131. t.behDeptId,
  9132. t.behDeptName,
  9133. t.hospitalId,
  9134. t.checkStatus,
  9135. t.mrStatus,
  9136. t.chName,
  9137. t.mrName,
  9138. t.chTime,
  9139. t.mrTime
  9140. FROM
  9141. (SELECT DISTINCT
  9142. t1.hospital_id AS hospitalId,
  9143. t1.behospital_code AS behospitalCode,
  9144. t1.bed_code AS bedCode,
  9145. t1.LEVEL AS LEVEL,
  9146. t1.grade_type AS gradeType,
  9147. t1.score_res AS scoreRes,
  9148. t1.scoreBn,
  9149. t1.NAME AS NAME,
  9150. t1.sex AS sex,
  9151. t1.beh_dept_id AS behDeptId,
  9152. t1.beh_dept_name AS behDeptName,
  9153. t1.doctor_id AS doctorId,
  9154. t1.doctor_name AS doctorName,
  9155. t1.beh_doctor_id AS behDoctorId,
  9156. t1.beh_doctor_name AS behDoctorName,
  9157. t1.director_doctor_id AS directorDoctorId,
  9158. t1.director_doctor_name AS directorDoctorName,
  9159. t1.birthday AS birthday,
  9160. t1.behospital_date AS behospitalDate,
  9161. t1.leave_hospital_date AS leaveHospitalDate,
  9162. t1.placefile_date AS placefileDate,
  9163. t1.gmt_create AS gradeTime,
  9164. t1.diagnose,
  9165. t1.ward_name AS wardName,
  9166. t1.checkStatus,
  9167. t1.mrStatus,
  9168. t1.chName,
  9169. t1.mrName,
  9170. t1.chTime,
  9171. t1.mrTime,
  9172. t2.age,
  9173. t1.file_code AS fileCode
  9174. FROM
  9175. (
  9176. SELECT be.*,
  9177. ifnull(mci.status,0) AS checkStatus,
  9178. ifnull(hm_mci.status,0) AS mrStatus,
  9179. mci.check_name as chName,
  9180. e.score_res as scoreBn,
  9181. hm_mci.check_name as mrName,
  9182. mci.gmt_create as chTime,
  9183. hm_mci.gmt_create as mrTime
  9184. FROM
  9185. (
  9186. SELECT DISTINCT
  9187. tt1.*
  9188. FROM
  9189. (
  9190. SELECT
  9191. b.*,
  9192. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9193. c.grade_type,
  9194. c.score_res,
  9195. c.gmt_create
  9196. FROM
  9197. (
  9198. SELECT DISTINCT
  9199. a.hospital_id,
  9200. a.behospital_code,
  9201. a.bed_code,
  9202. a.NAME,
  9203. a.sex,
  9204. a.beh_dept_id,
  9205. a.beh_dept_name,
  9206. a.birthday,
  9207. a.behospital_date,
  9208. a.leave_hospital_date,
  9209. a.doctor_id,
  9210. a.doctor_name,
  9211. a.beh_doctor_id,
  9212. a.beh_doctor_name,
  9213. a.director_doctor_id,
  9214. a.director_doctor_name,
  9215. a.diagnose,
  9216. a.placefile_date,
  9217. a.ward_name,
  9218. a.file_code
  9219. FROM
  9220. med_behospital_info a,
  9221. sys_user_dept b
  9222. WHERE
  9223. a.is_deleted = 'N'
  9224. AND b.is_deleted = 'N'
  9225. AND a.hospital_id = b.hospital_id
  9226. AND a.beh_dept_id = b.dept_id
  9227. AND a.qc_type_id != 0
  9228. <if test="qcResultShortPageVO.userId!=null">
  9229. AND b.user_id = #{qcResultShortPageVO.userId}
  9230. </if>
  9231. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9232. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9233. </if>
  9234. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9235. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9236. </if>
  9237. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9238. <if test="qcResultShortPageVO.startDate != null ">
  9239. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9240. </if>
  9241. <if test="qcResultShortPageVO.endDate != null ">
  9242. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9243. </if>
  9244. </if>
  9245. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9246. <if test="qcResultShortPageVO.startDate != null ">
  9247. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9248. </if>
  9249. <if test="qcResultShortPageVO.endDate != null">
  9250. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9251. </if>
  9252. </if>
  9253. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9254. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9255. </if>
  9256. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9257. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9258. </if>
  9259. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9260. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9261. </if>
  9262. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9263. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9264. </if>
  9265. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9266. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9267. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9268. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9269. </if>
  9270. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9271. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9272. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9273. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9274. </if>
  9275. ) b
  9276. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9277. AND b.hospital_id = c.hospital_id
  9278. AND b.behospital_code = c.behospital_code
  9279. ) tt1
  9280. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9281. ,med_medical_record tt2,
  9282. qc_mode tt3
  9283. WHERE
  9284. tt2.is_deleted = 'N'
  9285. AND tt3.is_deleted = 'N'
  9286. AND tt1.hospital_id = tt2.hospital_id
  9287. AND tt1.behospital_code = tt2.behospital_code
  9288. AND tt2.mode_id = tt3.id
  9289. AND tt3.`name` = '手术记录'
  9290. </if>
  9291. ) be
  9292. left join med_check_info mci
  9293. on mci.is_deleted = 'N'
  9294. and mci.check_type = 0
  9295. and be.hospital_id = mci.hospital_id
  9296. and be.behospital_code = mci.behospital_code
  9297. left join med_check_info hm_mci
  9298. on hm_mci.is_deleted = 'N'
  9299. and hm_mci.check_type = 1
  9300. and be.hospital_id = hm_mci.hospital_id
  9301. and be.behospital_code = hm_mci.behospital_code
  9302. LEFT JOIN med_qcresult_cases e
  9303. on be.behospital_code = e.behospital_code
  9304. and be.hospital_id = e.hospital_id
  9305. AND e.is_deleted = 'N'
  9306. and e.cases_id = 243
  9307. )t1
  9308. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9309. ,med_home_page t2
  9310. WHERE
  9311. t2.is_deleted = 'N'
  9312. AND t1.hospital_id = t2.hospital_id
  9313. AND t1.behospital_code = t2.behospital_code
  9314. AND (
  9315. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9316. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9317. )
  9318. </if>
  9319. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  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.return_to_type = '死亡'
  9326. </if>
  9327. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9328. ,med_home_page t2
  9329. WHERE
  9330. t2.is_deleted = 'N'
  9331. AND t1.hospital_id = t2.hospital_id
  9332. AND t1.behospital_code = t2.behospital_code
  9333. AND t2.leave_hospital_type = '非医嘱离院'
  9334. </if>
  9335. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9336. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9337. AND t1.hospital_id = t2.hospital_id
  9338. AND t1.behospital_code = t2.behospital_code
  9339. </if>
  9340. )t
  9341. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9342. AND t.hospitalId = qi.hospital_id
  9343. AND t.behospitalCode = qi.behospital_code
  9344. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9345. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9346. AND t.hospitalId = qd.hospital_id
  9347. AND t.behospitalCode = qd.behospital_code
  9348. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9349. AND qd.cases_id = qc.id
  9350. </if>
  9351. where 1=1
  9352. <if test="qcResultShortPageVO.checkStatus != null">
  9353. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9354. </if>
  9355. <if test="qcResultShortPageVO.mrStatus != null">
  9356. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9357. </if>
  9358. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9359. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9360. </if>
  9361. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9362. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9363. </if>
  9364. <if test="qcResultShortPageVO.chTimeStart != null ">
  9365. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9366. </if>
  9367. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9368. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9369. </if>
  9370. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9371. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9372. </if>
  9373. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9374. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9375. </if>
  9376. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9377. AND t.`level` = #{qcResultShortPageVO.level}
  9378. </if>)f1,(SELECT
  9379. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9380. t.behDeptId,
  9381. t.behDeptName,
  9382. t.doctorId,
  9383. t.doctorName
  9384. FROM
  9385. (SELECT DISTINCT
  9386. t1.hospital_id AS hospitalId,
  9387. t1.behospital_code AS behospitalCode,
  9388. t1.bed_code AS bedCode,
  9389. t1.LEVEL AS LEVEL,
  9390. t1.grade_type AS gradeType,
  9391. t1.score_res AS scoreRes,
  9392. t1.NAME AS NAME,
  9393. t1.sex AS sex,
  9394. t1.beh_dept_id AS behDeptId,
  9395. t1.beh_dept_name AS behDeptName,
  9396. t1.doctor_id AS doctorId,
  9397. t1.doctor_name AS doctorName,
  9398. t1.beh_doctor_id AS behDoctorId,
  9399. t1.beh_doctor_name AS behDoctorName,
  9400. t1.director_doctor_id AS directorDoctorId,
  9401. t1.director_doctor_name AS directorDoctorName,
  9402. t1.birthday AS birthday,
  9403. t1.behospital_date AS behospitalDate,
  9404. t1.leave_hospital_date AS leaveHospitalDate,
  9405. t1.placefile_date AS placefileDate,
  9406. t1.gmt_create AS gradeTime,
  9407. t1.diagnose,
  9408. t1.ward_name AS wardName,
  9409. t1.checkStatus,
  9410. t1.mrStatus,
  9411. t1.chName,
  9412. t1.mrName,
  9413. t1.chTime,
  9414. t1.mrTime,
  9415. t2.age,
  9416. t1.file_code AS fileCode
  9417. FROM
  9418. (
  9419. SELECT be.*,
  9420. ifnull(mci.status,0) AS checkStatus,
  9421. ifnull(hm_mci.status,0) AS mrStatus,
  9422. mci.check_name as chName,
  9423. hm_mci.check_name as mrName,
  9424. mci.gmt_create as chTime,
  9425. hm_mci.gmt_create as mrTime
  9426. FROM
  9427. (
  9428. SELECT DISTINCT
  9429. tt1.*
  9430. FROM
  9431. (
  9432. SELECT
  9433. b.*,
  9434. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9435. c.grade_type,
  9436. c.score_res,
  9437. c.gmt_create
  9438. FROM
  9439. (
  9440. SELECT DISTINCT
  9441. a.hospital_id,
  9442. a.behospital_code,
  9443. a.bed_code,
  9444. a.NAME,
  9445. a.sex,
  9446. a.beh_dept_id,
  9447. a.beh_dept_name,
  9448. a.birthday,
  9449. a.behospital_date,
  9450. a.leave_hospital_date,
  9451. a.doctor_id,
  9452. a.doctor_name,
  9453. a.beh_doctor_id,
  9454. a.beh_doctor_name,
  9455. a.director_doctor_id,
  9456. a.director_doctor_name,
  9457. a.diagnose,
  9458. a.placefile_date,
  9459. a.ward_name,
  9460. a.file_code
  9461. FROM
  9462. med_behospital_info a,
  9463. sys_user_dept b
  9464. WHERE
  9465. a.is_deleted = 'N'
  9466. AND b.is_deleted = 'N'
  9467. AND a.hospital_id = b.hospital_id
  9468. AND a.beh_dept_id = b.dept_id
  9469. AND a.qc_type_id != 0
  9470. <if test="qcResultShortPageVO.userId!=null">
  9471. AND b.user_id = #{qcResultShortPageVO.userId}
  9472. </if>
  9473. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9474. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9475. </if>
  9476. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9477. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9478. </if>
  9479. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9480. <if test="qcResultShortPageVO.startDate != null ">
  9481. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9482. </if>
  9483. <if test="qcResultShortPageVO.endDate != null ">
  9484. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9485. </if>
  9486. </if>
  9487. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9488. <if test="qcResultShortPageVO.startDate != null ">
  9489. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9490. </if>
  9491. <if test="qcResultShortPageVO.endDate != null">
  9492. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9493. </if>
  9494. </if>
  9495. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9496. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9497. </if>
  9498. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9499. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9500. </if>
  9501. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9502. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9503. </if>
  9504. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9505. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9506. </if>
  9507. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9508. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9509. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9510. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9511. </if>
  9512. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9513. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9514. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9515. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9516. </if>
  9517. ) b
  9518. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9519. AND b.hospital_id = c.hospital_id
  9520. AND b.behospital_code = c.behospital_code
  9521. ) tt1
  9522. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9523. ,med_medical_record tt2,
  9524. qc_mode tt3
  9525. WHERE
  9526. tt2.is_deleted = 'N'
  9527. AND tt3.is_deleted = 'N'
  9528. AND tt1.hospital_id = tt2.hospital_id
  9529. AND tt1.behospital_code = tt2.behospital_code
  9530. AND tt2.mode_id = tt3.id
  9531. AND tt3.`name` = '手术记录'
  9532. </if>
  9533. ) be
  9534. left join med_check_info mci
  9535. on mci.is_deleted = 'N'
  9536. and mci.check_type = 0
  9537. and be.hospital_id = mci.hospital_id
  9538. and be.behospital_code = mci.behospital_code
  9539. left join med_check_info hm_mci
  9540. on hm_mci.is_deleted = 'N'
  9541. and hm_mci.check_type = 1
  9542. and be.hospital_id = hm_mci.hospital_id
  9543. and be.behospital_code = hm_mci.behospital_code
  9544. )t1
  9545. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9546. ,med_home_page t2
  9547. WHERE
  9548. t2.is_deleted = 'N'
  9549. AND t1.hospital_id = t2.hospital_id
  9550. AND t1.behospital_code = t2.behospital_code
  9551. AND (
  9552. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9553. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9554. )
  9555. </if>
  9556. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9557. ,med_home_page t2
  9558. WHERE
  9559. t2.is_deleted = 'N'
  9560. AND t1.hospital_id = t2.hospital_id
  9561. AND t1.behospital_code = t2.behospital_code
  9562. AND t2.return_to_type = '死亡'
  9563. </if>
  9564. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9565. ,med_home_page t2
  9566. WHERE
  9567. t2.is_deleted = 'N'
  9568. AND t1.hospital_id = t2.hospital_id
  9569. AND t1.behospital_code = t2.behospital_code
  9570. AND t2.leave_hospital_type = '非医嘱离院'
  9571. </if>
  9572. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9573. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9574. AND t1.hospital_id = t2.hospital_id
  9575. AND t1.behospital_code = t2.behospital_code
  9576. </if>
  9577. )t
  9578. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9579. AND t.hospitalId = qi.hospital_id
  9580. AND t.behospitalCode = qi.behospital_code
  9581. where 1=1
  9582. <if test="qcResultShortPageVO.checkStatus != null">
  9583. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9584. </if>
  9585. <if test="qcResultShortPageVO.mrStatus != null">
  9586. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9587. </if>
  9588. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9589. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9590. </if>
  9591. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9592. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9593. </if>
  9594. <if test="qcResultShortPageVO.chTimeStart != null ">
  9595. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9596. </if>
  9597. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9598. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9599. </if>
  9600. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9601. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9602. </if>
  9603. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9604. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9605. </if>
  9606. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9607. AND t.`level` = #{qcResultShortPageVO.level}
  9608. </if>
  9609. GROUP BY
  9610. t.behDeptId,
  9611. t.behDeptName,
  9612. t.doctorId,
  9613. t.doctorName
  9614. )f2
  9615. WHERE
  9616. f1.doctorId = f2.doctorId
  9617. AND f1.doctorName = f2.doctorName
  9618. </select>
  9619. <!--缺陷详情质控评分页导出-科室-->
  9620. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  9621. SELECT * from(
  9622. SELECT
  9623. f1.*,
  9624. f2.avgScore
  9625. FROM
  9626. (SELECT
  9627. t.*,
  9628. qi.score_res AS score,
  9629. qd.msg AS msg,
  9630. qc.NAME AS caseName
  9631. FROM
  9632. (SELECT DISTINCT
  9633. t1.hospital_id AS hospitalId,
  9634. t1.behospital_code AS behospitalCode,
  9635. t1.bed_code AS bedCode,
  9636. t1.LEVEL AS LEVEL,
  9637. t1.grade_type AS gradeType,
  9638. t1.score_res AS scoreRes,
  9639. t1.scoreBn AS scoreBn,
  9640. t1.NAME AS patName,
  9641. t1.sex AS sex,
  9642. t1.beh_dept_id AS behDeptId,
  9643. t1.beh_dept_name AS behDeptName,
  9644. t1.doctor_id AS doctorId,
  9645. t1.doctor_name AS doctorName,
  9646. t1.beh_doctor_id AS behDoctorId,
  9647. t1.beh_doctor_name AS behDoctorName,
  9648. t1.director_doctor_id AS directorDoctorId,
  9649. t1.director_doctor_name AS directorDoctorName,
  9650. t1.birthday AS birthday,
  9651. t1.behospital_date AS behospitalDate,
  9652. t1.leave_hospital_date AS leaveHospitalDate,
  9653. t1.placefile_date AS placefileDate,
  9654. t1.gmt_create AS gradeTime,
  9655. t1.diagnose AS diagnose,
  9656. t1.ward_name AS wardName,
  9657. t1.file_code AS fileCode,
  9658. t1.checkStatus AS checkStatus,
  9659. t1.mrStatus AS mrStatus,
  9660. t1.chName AS chName,
  9661. t1.mrName AS mrName,
  9662. t1.chTime AS chTime,
  9663. t1.mrTime AS mrTime
  9664. FROM
  9665. (
  9666. SELECT DISTINCT
  9667. tt1.*
  9668. FROM
  9669. (SELECT
  9670. be.*,
  9671. ifnull(mci.status,0) AS checkStatus,
  9672. ifnull(hm_mci.status,0) AS mrStatus,
  9673. mci.check_name as chName,
  9674. hm_mci.check_name as mrName,
  9675. mci.gmt_create as chTime,
  9676. e.score_res as scoreBn,
  9677. hm_mci.gmt_create as mrTime
  9678. FROM
  9679. (
  9680. SELECT DISTINCT
  9681. a.hospital_id,
  9682. a.behospital_code,
  9683. a.bed_code,
  9684. a.file_code,
  9685. b.LEVEL,
  9686. b.grade_type,
  9687. b.score_res,
  9688. a.NAME,
  9689. a.sex,
  9690. a.beh_dept_id,
  9691. a.beh_dept_name,
  9692. a.birthday,
  9693. a.behospital_date,
  9694. a.leave_hospital_date,
  9695. a.doctor_id,
  9696. a.doctor_name,
  9697. a.beh_doctor_id,
  9698. a.beh_doctor_name,
  9699. a.director_doctor_id,
  9700. a.director_doctor_name,
  9701. a.diagnose,
  9702. a.placefile_date,
  9703. a.ward_name,
  9704. b.gmt_create
  9705. FROM
  9706. med_behospital_info a,
  9707. med_qcresult_info b,
  9708. med_qcresult_detail c,
  9709. qc_cases_entry d,
  9710. sys_user_dept e
  9711. WHERE
  9712. a.is_deleted = 'N'
  9713. AND b.is_deleted = 'N'
  9714. AND c.is_deleted = 'N'
  9715. AND d.is_deleted = 'N'
  9716. AND e.is_deleted = 'N'
  9717. AND a.hospital_id = b.hospital_id
  9718. AND a.hospital_id = c.hospital_id
  9719. AND a.hospital_id = e.hospital_id
  9720. AND a.behospital_code = b.behospital_code
  9721. AND a.behospital_code = c.behospital_code
  9722. AND a.beh_dept_id = e.dept_id
  9723. AND c.cases_id = d.cases_id
  9724. AND c.cases_entry_id = d.id
  9725. AND a.qc_type_id != 0
  9726. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9727. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9728. </if>
  9729. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  9730. AND e.user_id = #{qcResultShortPageVO.userId}
  9731. </if>
  9732. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9733. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9734. </if>
  9735. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9736. <if test="qcResultShortPageVO.startDate != null ">
  9737. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9738. </if>
  9739. <if test="qcResultShortPageVO.endDate != null ">
  9740. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9741. </if>
  9742. </if>
  9743. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9744. <if test="qcResultShortPageVO.startDate != null ">
  9745. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9746. </if>
  9747. <if test="qcResultShortPageVO.endDate != null">
  9748. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9749. </if>
  9750. </if>
  9751. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9752. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9753. </if>
  9754. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9755. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9756. </if>
  9757. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9758. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  9759. </if>
  9760. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9761. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9762. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9763. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9764. </if>
  9765. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9766. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9767. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9768. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9769. </if>
  9770. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9771. AND b.`level` = #{qcResultShortPageVO.level}
  9772. </if>
  9773. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9774. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9775. </if>
  9776. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9777. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9778. </if>
  9779. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9780. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  9781. </if>
  9782. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  9783. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9784. </if>
  9785. <if test="qcResultShortPageVO.isReject != null">
  9786. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9787. </if>
  9788. <if test="qcResultShortPageVO.ruleType != null">
  9789. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9790. </if>
  9791. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9792. AND TIMESTAMPDIFF(
  9793. DAY,
  9794. DATE( a.behospital_date ),
  9795. DATE( a.leave_hospital_date ))> 30
  9796. </if>
  9797. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9798. AND TIMESTAMPDIFF(
  9799. DAY,
  9800. DATE( a.behospital_date ),
  9801. DATE( a.leave_hospital_date ))> 31
  9802. </if>
  9803. )be
  9804. left join med_check_info mci
  9805. on mci.is_deleted = 'N'
  9806. and mci.check_type = 0
  9807. and be.hospital_id = mci.hospital_id
  9808. and be.behospital_code = mci.behospital_code
  9809. left join med_check_info hm_mci
  9810. on hm_mci.is_deleted = 'N'
  9811. and hm_mci.check_type = 1
  9812. and be.hospital_id = hm_mci.hospital_id
  9813. and be.behospital_code = hm_mci.behospital_code
  9814. LEFT JOIN med_qcresult_cases e
  9815. on be.behospital_code = e.behospital_code
  9816. and be.hospital_id = e.hospital_id
  9817. AND e.is_deleted = 'N'
  9818. and e.cases_id = 243
  9819. )tt1
  9820. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9821. ,med_medical_record tt2
  9822. WHERE
  9823. tt2.is_deleted = 'N'
  9824. AND tt1.hospital_id = tt2.hospital_id
  9825. AND tt1.behospital_code = tt2.behospital_code
  9826. AND tt2.mode_id = 30
  9827. </if>
  9828. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9829. ,med_crisis_info tt2
  9830. WHERE
  9831. tt2.is_deleted = 'N'
  9832. AND tt1.hospital_id = tt2.hospital_id
  9833. AND tt1.behospital_code = tt2.behospital_code
  9834. </if>
  9835. ) t1
  9836. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9837. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9838. AND t1.behospital_code = t2.behospital_code
  9839. AND t2.is_deleted = 'N'
  9840. </if>
  9841. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9842. , med_home_page t2
  9843. , med_home_operation_info t3
  9844. WHERE t1.hospital_id = t2.hospital_id
  9845. AND t1.behospital_code = t2.behospital_code
  9846. AND t2.home_page_id = t3.home_page_id
  9847. AND t2.is_deleted = 'N'
  9848. AND t3.is_deleted = 'N'
  9849. </if>
  9850. ) t
  9851. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9852. AND t.hospitalId = qi.hospital_id
  9853. AND t.behospitalCode = qi.behospital_code
  9854. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9855. AND t.hospitalId = qd.hospital_id
  9856. AND t.behospitalCode = qd.behospital_code
  9857. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9858. AND qd.cases_id = qc.id
  9859. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  9860. AND qd.cases_id = qce.cases_id
  9861. AND qd.cases_entry_id = qce.id
  9862. where 1=1
  9863. <if test="qcResultShortPageVO.checkStatus != null">
  9864. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9865. </if>
  9866. <if test="qcResultShortPageVO.mrStatus != null">
  9867. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9868. </if>
  9869. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9870. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9871. </if>
  9872. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9873. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9874. </if>
  9875. <if test="qcResultShortPageVO.chTimeStart != null ">
  9876. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9877. </if>
  9878. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9879. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9880. </if>
  9881. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9882. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9883. </if>
  9884. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9885. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9886. </if>
  9887. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9888. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  9889. </if>
  9890. <if test="qcResultShortPageVO.casesEntryId != null ">
  9891. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  9892. </if>
  9893. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9894. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  9895. </if>
  9896. <if test="qcResultShortPageVO.casesId != null">
  9897. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  9898. </if>
  9899. )f1,
  9900. (SELECT
  9901. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9902. t.behDeptId,
  9903. t.behDeptName,
  9904. t.doctorId,
  9905. t.doctorName
  9906. FROM
  9907. (SELECT DISTINCT
  9908. t1.hospital_id AS hospitalId,
  9909. t1.behospital_code AS behospitalCode,
  9910. t1.bed_code AS bedCode,
  9911. t1.LEVEL AS LEVEL,
  9912. t1.grade_type AS gradeType,
  9913. t1.score_res AS scoreRes,
  9914. t1.NAME AS NAME,
  9915. t1.sex AS sex,
  9916. t1.beh_dept_id AS behDeptId,
  9917. t1.beh_dept_name AS behDeptName,
  9918. t1.doctor_id AS doctorId,
  9919. t1.doctor_name AS doctorName,
  9920. t1.beh_doctor_id AS behDoctorId,
  9921. t1.beh_doctor_name AS behDoctorName,
  9922. t1.director_doctor_id AS directorDoctorId,
  9923. t1.director_doctor_name AS directorDoctorName,
  9924. t1.birthday AS birthday,
  9925. t1.behospital_date AS behospitalDate,
  9926. t1.leave_hospital_date AS leaveHospitalDate,
  9927. t1.placefile_date AS placefileDate,
  9928. t1.gmt_create AS gradeTime,
  9929. t1.diagnose,
  9930. t1.ward_name AS wardName,
  9931. t2.age,
  9932. t1.file_code AS fileCode,
  9933. t1.checkStatus,
  9934. t1.mrStatus,
  9935. t1.chName,
  9936. t1.mrName,
  9937. t1.chTime,
  9938. t1.mrTime
  9939. FROM
  9940. (
  9941. SELECT DISTINCT
  9942. tt1.*
  9943. FROM
  9944. (SELECT
  9945. be.*,
  9946. ifnull(mci.status,0) AS checkStatus,
  9947. ifnull(hm_mci.status,0) AS mrStatus,
  9948. mci.check_name as chName,
  9949. hm_mci.check_name as mrName,
  9950. mci.gmt_create as chTime,
  9951. hm_mci.gmt_create as mrTime
  9952. FROM
  9953. (
  9954. SELECT DISTINCT
  9955. a.hospital_id,
  9956. a.behospital_code,
  9957. a.bed_code,
  9958. a.file_code,
  9959. b.LEVEL,
  9960. b.grade_type,
  9961. b.score_res,
  9962. a.NAME,
  9963. a.sex,
  9964. a.beh_dept_id,
  9965. a.beh_dept_name,
  9966. a.birthday,
  9967. a.behospital_date,
  9968. a.leave_hospital_date,
  9969. a.doctor_id,
  9970. a.doctor_name,
  9971. a.beh_doctor_id,
  9972. a.beh_doctor_name,
  9973. a.director_doctor_id,
  9974. a.director_doctor_name,
  9975. a.diagnose,
  9976. a.placefile_date,
  9977. a.ward_name,
  9978. b.gmt_create
  9979. FROM
  9980. med_behospital_info a,
  9981. med_qcresult_info b,
  9982. med_qcresult_detail c,
  9983. qc_cases_entry d,
  9984. sys_user_dept e
  9985. WHERE
  9986. a.is_deleted = 'N'
  9987. AND b.is_deleted = 'N'
  9988. AND c.is_deleted = 'N'
  9989. AND d.is_deleted = 'N'
  9990. AND e.is_deleted = 'N'
  9991. AND a.hospital_id = b.hospital_id
  9992. AND a.hospital_id = c.hospital_id
  9993. AND a.hospital_id = e.hospital_id
  9994. AND a.behospital_code = b.behospital_code
  9995. AND a.behospital_code = c.behospital_code
  9996. AND a.beh_dept_id = e.dept_id
  9997. AND c.cases_id = d.cases_id
  9998. AND c.cases_entry_id = d.id
  9999. AND a.qc_type_id != 0
  10000. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10001. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10002. </if>
  10003. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10004. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10005. </if>
  10006. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10007. <if test="qcResultShortPageVO.startDate != null ">
  10008. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10009. </if>
  10010. <if test="qcResultShortPageVO.endDate != null ">
  10011. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10012. </if>
  10013. </if>
  10014. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10015. <if test="qcResultShortPageVO.startDate != null ">
  10016. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10017. </if>
  10018. <if test="qcResultShortPageVO.endDate != null">
  10019. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10020. </if>
  10021. </if>
  10022. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10023. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10024. </if>
  10025. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10026. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10027. </if>
  10028. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10029. AND b.`level` = #{qcResultShortPageVO.level}
  10030. </if>
  10031. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10032. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10033. </if>
  10034. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10035. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10036. </if>
  10037. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10038. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10039. </if>
  10040. <if test="qcResultShortPageVO.casesEntryId != null ">
  10041. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10042. </if>
  10043. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10044. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10045. </if>
  10046. <if test="qcResultShortPageVO.casesId != null">
  10047. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10048. </if>
  10049. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10050. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10051. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10052. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10053. </if>
  10054. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10055. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10056. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10057. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10058. </if>
  10059. <if test="qcResultShortPageVO.isReject != null">
  10060. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10061. </if>
  10062. <if test="qcResultShortPageVO.ruleType != null">
  10063. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10064. </if>
  10065. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10066. AND TIMESTAMPDIFF(
  10067. DAY,
  10068. DATE( a.behospital_date ),
  10069. DATE( a.leave_hospital_date ))> 30
  10070. </if>
  10071. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10072. AND TIMESTAMPDIFF(
  10073. DAY,
  10074. DATE( a.behospital_date ),
  10075. DATE( a.leave_hospital_date ))> 31
  10076. </if>
  10077. )be
  10078. left join med_check_info mci
  10079. on mci.is_deleted = 'N'
  10080. and mci.check_type = 0
  10081. and be.hospital_id = mci.hospital_id
  10082. and be.behospital_code = mci.behospital_code
  10083. left join med_check_info hm_mci
  10084. on hm_mci.is_deleted = 'N'
  10085. and hm_mci.check_type = 1
  10086. and be.hospital_id = hm_mci.hospital_id
  10087. and be.behospital_code = hm_mci.behospital_code
  10088. )tt1
  10089. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10090. ,med_medical_record tt2
  10091. WHERE
  10092. tt2.is_deleted = 'N'
  10093. AND tt1.hospital_id = tt2.hospital_id
  10094. AND tt1.behospital_code = tt2.behospital_code
  10095. AND tt2.mode_id = 30
  10096. </if>
  10097. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10098. ,med_crisis_info 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. </if>
  10104. ) t1
  10105. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10106. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10107. AND t1.behospital_code = t2.behospital_code
  10108. AND t2.is_deleted = 'N'
  10109. </if>
  10110. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10111. , med_home_page t2
  10112. , med_home_operation_info t3
  10113. WHERE t1.hospital_id = t2.hospital_id
  10114. AND t1.behospital_code = t2.behospital_code
  10115. AND t2.home_page_id = t3.home_page_id
  10116. AND t2.is_deleted = 'N'
  10117. AND t3.is_deleted = 'N'
  10118. </if>
  10119. ) t
  10120. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10121. AND t.hospitalId = qi.hospital_id
  10122. AND t.behospitalCode = qi.behospital_code
  10123. where 1=1
  10124. <if test="qcResultShortPageVO.checkStatus != null">
  10125. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10126. </if>
  10127. <if test="qcResultShortPageVO.mrStatus != null">
  10128. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10129. </if>
  10130. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10131. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10132. </if>
  10133. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10134. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10135. </if>
  10136. <if test="qcResultShortPageVO.chTimeStart != null ">
  10137. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10138. </if>
  10139. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10140. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10141. </if>
  10142. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10143. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10144. </if>
  10145. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10146. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10147. </if>
  10148. GROUP BY
  10149. t.behDeptId,
  10150. t.behDeptName,
  10151. t.doctorId,
  10152. t.doctorName
  10153. )f2
  10154. WHERE
  10155. f1.doctorId = f2.doctorId
  10156. AND f1.doctorName = f2.doctorName
  10157. )m
  10158. </select>
  10159. <!-- 条目缺陷评分详情页导出-->
  10160. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  10161. SELECT * from(
  10162. SELECT
  10163. f1.*,
  10164. f2.avgScore
  10165. FROM
  10166. (SELECT
  10167. t.*,
  10168. qi.score_res AS score,
  10169. qd.msg AS msg,
  10170. qc.NAME AS caseName
  10171. FROM
  10172. (SELECT DISTINCT
  10173. t1.hospital_id AS hospitalId,
  10174. t1.behospital_code AS behospitalCode,
  10175. t1.bed_code AS bedCode,
  10176. t1.LEVEL AS LEVEL,
  10177. t1.grade_type AS gradeType,
  10178. t1.score_res AS scoreRes,
  10179. t1.scoreBn AS scoreBn,
  10180. t1.NAME AS patName,
  10181. t1.sex AS sex,
  10182. t1.beh_dept_id AS behDeptId,
  10183. t1.beh_dept_name AS behDeptName,
  10184. t1.doctor_id AS doctorId,
  10185. t1.doctor_name AS doctorName,
  10186. t1.beh_doctor_id AS behDoctorId,
  10187. t1.beh_doctor_name AS behDoctorName,
  10188. t1.director_doctor_id AS directorDoctorId,
  10189. t1.director_doctor_name AS directorDoctorName,
  10190. t1.birthday AS birthday,
  10191. t1.behospital_date AS behospitalDate,
  10192. t1.leave_hospital_date AS leaveHospitalDate,
  10193. t1.placefile_date AS placefileDate,
  10194. t1.gmt_create AS gradeTime,
  10195. t1.diagnose AS diagnose,
  10196. t1.ward_name AS wardName,
  10197. t1.file_code AS fileCode,
  10198. t1.checkStatus AS checkStatus,
  10199. t1.mrStatus AS mrStatus,
  10200. t1.chName AS chName,
  10201. t1.mrName AS mrName,
  10202. t1.chTime AS chTime,
  10203. t1.mrTime AS mrTime
  10204. FROM
  10205. (
  10206. SELECT DISTINCT
  10207. tt1.*
  10208. FROM
  10209. (SELECT
  10210. be.*,
  10211. ifnull(mci.status,0) AS checkStatus,
  10212. ifnull(hm_mci.status,0) AS mrStatus,
  10213. mci.check_name as chName,
  10214. hm_mci.check_name as mrName,
  10215. mci.gmt_create as chTime,
  10216. e.score_res as scoreBn,
  10217. hm_mci.gmt_create as mrTime
  10218. FROM
  10219. (
  10220. SELECT DISTINCT
  10221. a.hospital_id,
  10222. a.behospital_code,
  10223. a.bed_code,
  10224. a.file_code,
  10225. b.LEVEL,
  10226. b.grade_type,
  10227. b.score_res,
  10228. a.NAME,
  10229. a.sex,
  10230. a.beh_dept_id,
  10231. a.beh_dept_name,
  10232. a.birthday,
  10233. a.behospital_date,
  10234. a.leave_hospital_date,
  10235. a.doctor_id,
  10236. a.doctor_name,
  10237. a.beh_doctor_id,
  10238. a.beh_doctor_name,
  10239. a.director_doctor_id,
  10240. a.director_doctor_name,
  10241. a.diagnose,
  10242. a.placefile_date,
  10243. a.ward_name,
  10244. b.gmt_create
  10245. FROM
  10246. med_behospital_info a,
  10247. med_qcresult_info b,
  10248. med_qcresult_detail c,
  10249. qc_cases_entry d
  10250. WHERE
  10251. a.is_deleted = 'N'
  10252. AND b.is_deleted = 'N'
  10253. AND c.is_deleted = 'N'
  10254. AND d.is_deleted = 'N'
  10255. AND a.hospital_id = b.hospital_id
  10256. AND a.hospital_id = c.hospital_id
  10257. AND a.behospital_code = b.behospital_code
  10258. AND a.behospital_code = c.behospital_code
  10259. AND c.cases_id = d.cases_id
  10260. AND c.cases_entry_id = d.id
  10261. AND a.qc_type_id != 0
  10262. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10263. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10264. </if>
  10265. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10266. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10267. </if>
  10268. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10269. <if test="qcResultShortPageVO.startDate != null ">
  10270. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10271. </if>
  10272. <if test="qcResultShortPageVO.endDate != null ">
  10273. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10274. </if>
  10275. </if>
  10276. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10277. <if test="qcResultShortPageVO.startDate != null ">
  10278. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10279. </if>
  10280. <if test="qcResultShortPageVO.endDate != null">
  10281. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10282. </if>
  10283. </if>
  10284. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10285. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10286. </if>
  10287. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10288. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10289. </if>
  10290. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10291. AND b.`level` = #{qcResultShortPageVO.level}
  10292. </if>
  10293. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10294. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10295. </if>
  10296. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10297. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10298. </if>
  10299. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10300. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10301. </if>
  10302. <if test="qcResultShortPageVO.casesEntryId != null ">
  10303. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10304. </if>
  10305. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10306. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10307. </if>
  10308. <if test="qcResultShortPageVO.casesId != null">
  10309. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10310. </if>
  10311. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10312. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10313. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10314. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10315. </if>
  10316. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10317. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10318. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10319. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10320. </if>
  10321. <if test="qcResultShortPageVO.isReject != null">
  10322. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10323. </if>
  10324. <if test="qcResultShortPageVO.ruleType != null">
  10325. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10326. </if>
  10327. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10328. AND TIMESTAMPDIFF(
  10329. DAY,
  10330. DATE( a.behospital_date ),
  10331. DATE( a.leave_hospital_date ))> 30
  10332. </if>
  10333. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10334. AND TIMESTAMPDIFF(
  10335. DAY,
  10336. DATE( a.behospital_date ),
  10337. DATE( a.leave_hospital_date ))> 31
  10338. </if>
  10339. )be
  10340. left join med_check_info mci
  10341. on mci.is_deleted = 'N'
  10342. and mci.check_type = 0
  10343. and be.hospital_id = mci.hospital_id
  10344. and be.behospital_code = mci.behospital_code
  10345. left join med_check_info hm_mci
  10346. on hm_mci.is_deleted = 'N'
  10347. and hm_mci.check_type = 1
  10348. and be.hospital_id = hm_mci.hospital_id
  10349. and be.behospital_code = hm_mci.behospital_code
  10350. LEFT JOIN med_qcresult_cases e
  10351. on be.behospital_code = e.behospital_code
  10352. and be.hospital_id = e.hospital_id
  10353. AND e.is_deleted = 'N'
  10354. and e.cases_id = 243
  10355. )tt1
  10356. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10357. ,med_medical_record tt2
  10358. WHERE
  10359. tt2.is_deleted = 'N'
  10360. AND tt1.hospital_id = tt2.hospital_id
  10361. AND tt1.behospital_code = tt2.behospital_code
  10362. AND tt2.mode_id = 30
  10363. </if>
  10364. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10365. ,med_crisis_info tt2
  10366. WHERE
  10367. tt2.is_deleted = 'N'
  10368. AND tt1.hospital_id = tt2.hospital_id
  10369. AND tt1.behospital_code = tt2.behospital_code
  10370. </if>
  10371. ) t1
  10372. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10373. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10374. AND t1.behospital_code = t2.behospital_code
  10375. AND t2.is_deleted = 'N'
  10376. </if>
  10377. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10378. , med_home_page t2
  10379. , med_home_operation_info t3
  10380. WHERE t1.hospital_id = t2.hospital_id
  10381. AND t1.behospital_code = t2.behospital_code
  10382. AND t2.home_page_id = t3.home_page_id
  10383. AND t2.is_deleted = 'N'
  10384. AND t3.is_deleted = 'N'
  10385. </if>
  10386. ) t
  10387. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10388. AND t.hospitalId = qi.hospital_id
  10389. AND t.behospitalCode = qi.behospital_code
  10390. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10391. AND t.hospitalId = qd.hospital_id
  10392. AND t.behospitalCode = qd.behospital_code
  10393. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10394. AND qd.cases_id = qc.id
  10395. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10396. AND qd.cases_id = qce.cases_id
  10397. AND qd.cases_entry_id = qce.id
  10398. where 1=1
  10399. <if test="qcResultShortPageVO.checkStatus != null">
  10400. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10401. </if>
  10402. <if test="qcResultShortPageVO.mrStatus != null">
  10403. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10404. </if>
  10405. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10406. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10407. </if>
  10408. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10409. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10410. </if>
  10411. <if test="qcResultShortPageVO.chTimeStart != null ">
  10412. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10413. </if>
  10414. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10415. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10416. </if>
  10417. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10418. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10419. </if>
  10420. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10421. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10422. </if>
  10423. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10424. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10425. </if>
  10426. <if test="qcResultShortPageVO.casesEntryId != null ">
  10427. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10428. </if>
  10429. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10430. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10431. </if>
  10432. <if test="qcResultShortPageVO.casesId != null">
  10433. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10434. </if>
  10435. )f1,
  10436. (SELECT
  10437. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10438. t.behDeptId,
  10439. t.behDeptName
  10440. FROM
  10441. (SELECT DISTINCT
  10442. t1.hospital_id AS hospitalId,
  10443. t1.behospital_code AS behospitalCode,
  10444. t1.bed_code AS bedCode,
  10445. t1.LEVEL AS LEVEL,
  10446. t1.grade_type AS gradeType,
  10447. t1.score_res AS scoreRes,
  10448. t1.NAME AS NAME,
  10449. t1.sex AS sex,
  10450. t1.beh_dept_id AS behDeptId,
  10451. t1.beh_dept_name AS behDeptName,
  10452. t1.doctor_id AS doctorId,
  10453. t1.doctor_name AS doctorName,
  10454. t1.beh_doctor_id AS behDoctorId,
  10455. t1.beh_doctor_name AS behDoctorName,
  10456. t1.director_doctor_id AS directorDoctorId,
  10457. t1.director_doctor_name AS directorDoctorName,
  10458. t1.birthday AS birthday,
  10459. t1.behospital_date AS behospitalDate,
  10460. t1.leave_hospital_date AS leaveHospitalDate,
  10461. t1.placefile_date AS placefileDate,
  10462. t1.gmt_create AS gradeTime,
  10463. t1.diagnose,
  10464. t1.ward_name AS wardName,
  10465. t2.age,
  10466. t1.file_code AS fileCode,
  10467. t1.checkStatus,
  10468. t1.mrStatus,
  10469. t1.chName,
  10470. t1.mrName,
  10471. t1.chTime,
  10472. t1.mrTime
  10473. FROM
  10474. (
  10475. SELECT DISTINCT
  10476. tt1.*
  10477. FROM
  10478. (SELECT
  10479. be.*,
  10480. ifnull(mci.status,0) AS checkStatus,
  10481. ifnull(hm_mci.status,0) AS mrStatus,
  10482. mci.check_name as chName,
  10483. hm_mci.check_name as mrName,
  10484. mci.gmt_create as chTime,
  10485. hm_mci.gmt_create as mrTime
  10486. FROM
  10487. (
  10488. SELECT DISTINCT
  10489. a.hospital_id,
  10490. a.behospital_code,
  10491. a.bed_code,
  10492. a.file_code,
  10493. b.LEVEL,
  10494. b.grade_type,
  10495. b.score_res,
  10496. a.NAME,
  10497. a.sex,
  10498. a.beh_dept_id,
  10499. a.beh_dept_name,
  10500. a.birthday,
  10501. a.behospital_date,
  10502. a.leave_hospital_date,
  10503. a.doctor_id,
  10504. a.doctor_name,
  10505. a.beh_doctor_id,
  10506. a.beh_doctor_name,
  10507. a.director_doctor_id,
  10508. a.director_doctor_name,
  10509. a.diagnose,
  10510. a.placefile_date,
  10511. a.ward_name,
  10512. b.gmt_create
  10513. FROM
  10514. med_behospital_info a,
  10515. med_qcresult_info b,
  10516. med_qcresult_detail c,
  10517. qc_cases_entry d
  10518. WHERE
  10519. a.is_deleted = 'N'
  10520. AND b.is_deleted = 'N'
  10521. AND c.is_deleted = 'N'
  10522. AND d.is_deleted = 'N'
  10523. AND a.hospital_id = b.hospital_id
  10524. AND a.hospital_id = c.hospital_id
  10525. AND a.behospital_code = b.behospital_code
  10526. AND a.behospital_code = c.behospital_code
  10527. AND c.cases_id = d.cases_id
  10528. AND c.cases_entry_id = d.id
  10529. AND a.qc_type_id != 0
  10530. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10531. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10532. </if>
  10533. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10534. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10535. </if>
  10536. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10537. <if test="qcResultShortPageVO.startDate != null ">
  10538. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10539. </if>
  10540. <if test="qcResultShortPageVO.endDate != null ">
  10541. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10542. </if>
  10543. </if>
  10544. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10545. <if test="qcResultShortPageVO.startDate != null ">
  10546. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10547. </if>
  10548. <if test="qcResultShortPageVO.endDate != null">
  10549. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10550. </if>
  10551. </if>
  10552. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10553. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10554. </if>
  10555. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10556. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10557. </if>
  10558. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10559. AND b.`level` = #{qcResultShortPageVO.level}
  10560. </if>
  10561. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10562. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10563. </if>
  10564. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10565. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10566. </if>
  10567. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10568. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10569. </if>
  10570. <if test="qcResultShortPageVO.casesEntryId != null ">
  10571. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10572. </if>
  10573. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10574. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10575. </if>
  10576. <if test="qcResultShortPageVO.casesId != null">
  10577. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10578. </if>
  10579. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10580. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10581. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10582. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10583. </if>
  10584. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10585. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10586. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10587. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10588. </if>
  10589. <if test="qcResultShortPageVO.isReject != null">
  10590. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10591. </if>
  10592. <if test="qcResultShortPageVO.ruleType != null">
  10593. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10594. </if>
  10595. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10596. AND TIMESTAMPDIFF(
  10597. DAY,
  10598. DATE( a.behospital_date ),
  10599. DATE( a.leave_hospital_date ))> 30
  10600. </if>
  10601. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10602. AND TIMESTAMPDIFF(
  10603. DAY,
  10604. DATE( a.behospital_date ),
  10605. DATE( a.leave_hospital_date ))> 31
  10606. </if>
  10607. )be
  10608. left join med_check_info mci
  10609. on mci.is_deleted = 'N'
  10610. and mci.check_type = 0
  10611. and be.hospital_id = mci.hospital_id
  10612. and be.behospital_code = mci.behospital_code
  10613. left join med_check_info hm_mci
  10614. on hm_mci.is_deleted = 'N'
  10615. and hm_mci.check_type = 1
  10616. and be.hospital_id = hm_mci.hospital_id
  10617. and be.behospital_code = hm_mci.behospital_code
  10618. )tt1
  10619. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10620. ,med_medical_record tt2
  10621. WHERE
  10622. tt2.is_deleted = 'N'
  10623. AND tt1.hospital_id = tt2.hospital_id
  10624. AND tt1.behospital_code = tt2.behospital_code
  10625. AND tt2.mode_id = 30
  10626. </if>
  10627. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10628. ,med_crisis_info tt2
  10629. WHERE
  10630. tt2.is_deleted = 'N'
  10631. AND tt1.hospital_id = tt2.hospital_id
  10632. AND tt1.behospital_code = tt2.behospital_code
  10633. </if>
  10634. ) t1
  10635. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10636. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10637. AND t1.behospital_code = t2.behospital_code
  10638. AND t2.is_deleted = 'N'
  10639. </if>
  10640. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10641. , med_home_page t2
  10642. , med_home_operation_info t3
  10643. WHERE t1.hospital_id = t2.hospital_id
  10644. AND t1.behospital_code = t2.behospital_code
  10645. AND t2.home_page_id = t3.home_page_id
  10646. AND t2.is_deleted = 'N'
  10647. AND t3.is_deleted = 'N'
  10648. </if>
  10649. ) t
  10650. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10651. AND t.hospitalId = qi.hospital_id
  10652. AND t.behospitalCode = qi.behospital_code
  10653. where 1=1
  10654. <if test="qcResultShortPageVO.checkStatus != null">
  10655. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10656. </if>
  10657. <if test="qcResultShortPageVO.mrStatus != null">
  10658. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10659. </if>
  10660. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10661. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10662. </if>
  10663. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10664. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10665. </if>
  10666. <if test="qcResultShortPageVO.chTimeStart != null ">
  10667. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10668. </if>
  10669. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10670. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10671. </if>
  10672. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10673. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10674. </if>
  10675. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10676. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10677. </if>
  10678. GROUP BY
  10679. t.behDeptId,
  10680. t.behDeptName
  10681. )f2
  10682. WHERE
  10683. f1.behDeptId = f2.behDeptId
  10684. AND f1.behDeptName = f2.behDeptName
  10685. )m
  10686. </select>
  10687. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  10688. <result column="deptName" property="deptName"/>
  10689. <result column="deptId" property="deptId"/>
  10690. <result column="doctorGroup" property="doctorGroup"/>
  10691. <result column="doctorName" property="doctorName"/>
  10692. <result column="entry_2658_num" property="entry_2658_num"/>
  10693. <result column="entry_2686_num" property="entry_2686_num"/>
  10694. <result column="entry_2657_num" property="entry_2657_num"/>
  10695. <result column="entry_3010_num" property="entry_3010_num"/>
  10696. <result column="entry_2655_num" property="entry_2655_num"/>
  10697. <result column="entry_2654_num" property="entry_2654_num"/>
  10698. <result column="entry_2852_num" property="entry_2852_num"/>
  10699. <result column="entry_2287_num" property="entry_2287_num"/>
  10700. <result column="entry_3025_num" property="entry_3025_num"/>
  10701. <result column="entry_2170_num" property="entry_2170_num"/>
  10702. <result column="entry_2930_num" property="entry_2930_num"/>
  10703. <result column="entry_2900_num" property="entry_2900_num"/>
  10704. <result column="entry_2229_num" property="entry_2229_num"/>
  10705. <result column="entry_2217_num" property="entry_2217_num"/>
  10706. <result column="entry_2218_num" property="entry_2218_num"/>
  10707. <result column="entry_2220_num" property="entry_2220_num"/>
  10708. <result column="entry_2486_num" property="entry_2486_num"/>
  10709. <result column="entry_3063_num" property="entry_3063_num"/>
  10710. <result column="entry_3062_num" property="entry_3062_num"/>
  10711. <result column="entry_2495_num" property="entry_2495_num"/>
  10712. </resultMap>
  10713. <!-- 病历稽查表-->
  10714. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  10715. SELECT
  10716. a.beh_dept_id AS deptId,
  10717. a.beh_dept_name AS deptName,
  10718. a.doctor_name as doctorGroup,
  10719. a.doctor_name as doctorName,
  10720. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10721. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10722. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10723. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10724. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10725. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10726. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10727. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10728. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10729. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10730. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10731. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10732. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10733. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10734. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10735. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10736. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10737. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10738. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10739. sum(c.cases_entry_id = 2495) as entry_2495_num
  10740. FROM
  10741. med_behospital_info a,
  10742. med_qcresult_info b,
  10743. med_qcresult_detail c,
  10744. qc_cases_entry d,
  10745. bas_doctor_info e
  10746. WHERE
  10747. a.is_deleted = 'N'
  10748. AND b.is_deleted = 'N'
  10749. AND c.is_deleted = 'N'
  10750. AND d.is_deleted = 'N'
  10751. AND e.is_deleted = 'N'
  10752. AND a.hospital_id = b.hospital_id
  10753. AND a.hospital_id = c.hospital_id
  10754. AND a.hospital_id = e.hospital_id
  10755. AND a.behospital_code = b.behospital_code
  10756. AND a.behospital_code = c.behospital_code
  10757. AND a.beh_dept_id = e.dept_id
  10758. AND c.cases_entry_id = d.id
  10759. and a.doctor_id=e.doctor_id
  10760. and e.group_id is not NULL
  10761. AND LENGTH(e.group_id)>0
  10762. AND a.qc_type_id != 0
  10763. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10764. and a.is_placefile = #{filterVO.isPlacefile}
  10765. </if>
  10766. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10767. AND a.hospital_id = #{filterVO.hospitalId}
  10768. </if>
  10769. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10770. <if test="filterVO.startDate != null ">
  10771. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10772. </if>
  10773. <if test="filterVO.endDate != null ">
  10774. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10775. </if>
  10776. </if>
  10777. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10778. <if test="filterVO.startDate != null ">
  10779. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10780. </if>
  10781. <if test="filterVO.endDate != null ">
  10782. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10783. </if>
  10784. </if>
  10785. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10786. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10787. </if>
  10788. GROUP BY
  10789. a.beh_dept_id,
  10790. e.group_id,
  10791. a.doctor_id
  10792. </select>
  10793. <!-- 病历稽查表-科室-->
  10794. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  10795. SELECT
  10796. a.beh_dept_id AS deptId,
  10797. a.beh_dept_name AS deptName,
  10798. a.doctor_name as doctorName,
  10799. a.doctor_name as doctorGroup,
  10800. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10801. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10802. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10803. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10804. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10805. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10806. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10807. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10808. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10809. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10810. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10811. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10812. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10813. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10814. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10815. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10816. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10817. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10818. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10819. sum(c.cases_entry_id = 2495) as entry_2495_num
  10820. FROM
  10821. med_behospital_info a,
  10822. med_qcresult_info b,
  10823. med_qcresult_detail c,
  10824. qc_cases_entry d,
  10825. bas_doctor_info e,
  10826. sys_user_dept f
  10827. WHERE
  10828. a.is_deleted = 'N'
  10829. AND b.is_deleted = 'N'
  10830. AND c.is_deleted = 'N'
  10831. AND d.is_deleted = 'N'
  10832. AND e.is_deleted = 'N'
  10833. AND f.is_deleted = 'N'
  10834. AND a.hospital_id = b.hospital_id
  10835. AND a.hospital_id = c.hospital_id
  10836. AND a.hospital_id = e.hospital_id
  10837. AND a.hospital_id = f.hospital_id
  10838. AND a.behospital_code = b.behospital_code
  10839. AND a.behospital_code = c.behospital_code
  10840. AND a.beh_dept_id = f.dept_id
  10841. AND c.cases_entry_id = d.id
  10842. and a.doctor_id=e.doctor_id
  10843. and e.group_id is not NULL
  10844. AND LENGTH(e.group_id)>0
  10845. AND a.qc_type_id != 0
  10846. <if test="filterVO.userId!=null">
  10847. AND f.user_id = #{filterVO.userId}
  10848. </if>
  10849. <if test="filterVO.name != null and filterVO.name != ''">
  10850. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  10851. </if>
  10852. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10853. and a.is_placefile = #{filterVO.isPlacefile}
  10854. </if>
  10855. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10856. AND a.hospital_id = #{filterVO.hospitalId}
  10857. </if>
  10858. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10859. <if test="filterVO.startDate != null ">
  10860. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10861. </if>
  10862. <if test="filterVO.endDate != null ">
  10863. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10864. </if>
  10865. </if>
  10866. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10867. <if test="filterVO.startDate != null ">
  10868. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10869. </if>
  10870. <if test="filterVO.endDate != null ">
  10871. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10872. </if>
  10873. </if>
  10874. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10875. AND a.beh_dept_name = #{filterVO.deptName}
  10876. </if>
  10877. GROUP BY
  10878. a.beh_dept_id,
  10879. e.group_id,
  10880. a.doctor_name
  10881. </select>
  10882. <!-- 病历稽查表最新sql、id&&name-->
  10883. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  10884. SELECT
  10885. d.id,
  10886. d.name
  10887. from
  10888. qc_cases_entry d
  10889. where
  10890. 1=1
  10891. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  10892. and d.id in
  10893. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  10894. '${item}'
  10895. </foreach>
  10896. </if>
  10897. </select>
  10898. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  10899. <result column="deptName" property="deptName"/>
  10900. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10901. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  10902. <result column="doctorName" property="doctorName"/>
  10903. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10904. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  10905. <result column="RYJLW_24" property="ryjlw_24"/>
  10906. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10907. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10908. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10909. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10910. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10911. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10912. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10913. <result column="SQTLXJW" property="sqtlxjw"/>
  10914. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10915. <result column="XHSCW_30M" property="xhscw_30m"/>
  10916. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10917. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10918. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10919. <result column="ZKJLW_24" property="zkjlw_24"/>
  10920. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10921. <result column="SXHWJL" property="sxhwjl"/>
  10922. <result column="SXPJW_24" property="sxpjw_24"/>
  10923. <result column="WJZWJL" property="wjzwjl"/>
  10924. <result column="WYWWCXJ" property="wywwcxj"/>
  10925. </collection>
  10926. </collection>
  10927. </resultMap>
  10928. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  10929. <result column="deptName" property="deptName"/>
  10930. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10931. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  10932. <result column="doctorGroup" property="doctorGroup"/>
  10933. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10934. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  10935. <result column="doctorName" property="doctorName"/>
  10936. <result column="RYJLW_24" property="ryjlw_24"/>
  10937. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10938. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10939. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10940. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10941. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10942. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10943. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10944. <result column="SQTLXJW" property="sqtlxjw"/>
  10945. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10946. <result column="XHSCW_30M" property="xhscw_30m"/>
  10947. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10948. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10949. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10950. <result column="ZKJLW_24" property="zkjlw_24"/>
  10951. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10952. <result column="SXHWJL" property="sxhwjl"/>
  10953. <result column="SXPJW_24" property="sxpjw_24"/>
  10954. <result column="WJZWJL" property="wjzwjl"/>
  10955. <result column="WYWWCXJ" property="wywwcxj"/>
  10956. </collection>
  10957. </collection>
  10958. </resultMap>
  10959. <!-- 病历稽查表最新导出-->
  10960. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  10961. SELECT
  10962. a.beh_dept_id AS deptId,
  10963. a.beh_dept_name AS deptName,
  10964. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  10965. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10966. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10967. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10968. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10969. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10970. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10971. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10972. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10973. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10974. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10975. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10976. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10977. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10978. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10979. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10980. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10981. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10982. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10983. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10984. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10985. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  10986. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  10987. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  10988. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  10989. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  10990. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  10991. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  10992. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  10993. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  10994. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  10995. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  10996. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  10997. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  10998. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  10999. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  11000. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  11001. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  11002. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  11003. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  11004. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  11005. FROM
  11006. med_behospital_info a,
  11007. med_qcresult_info b,
  11008. med_qcresult_detail c,
  11009. qc_cases_entry d,
  11010. bas_doctor_info e
  11011. WHERE
  11012. a.is_deleted = 'N'
  11013. AND b.is_deleted = 'N'
  11014. AND c.is_deleted = 'N'
  11015. AND d.is_deleted = 'N'
  11016. AND e.is_deleted = 'N'
  11017. AND a.hospital_id = b.hospital_id
  11018. AND a.hospital_id = c.hospital_id
  11019. AND a.hospital_id = e.hospital_id
  11020. AND a.behospital_code = b.behospital_code
  11021. AND a.behospital_code = c.behospital_code
  11022. AND a.beh_dept_id = e.dept_id
  11023. AND c.cases_entry_id = d.id
  11024. and a.doctor_id=e.doctor_id
  11025. and e.group_id is not NULL
  11026. AND LENGTH(e.group_id)>0
  11027. AND a.qc_type_id != 0
  11028. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11029. and a.is_placefile = #{filterVO.isPlacefile}
  11030. </if>
  11031. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11032. AND a.hospital_id = #{filterVO.hospitalId}
  11033. </if>
  11034. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11035. <if test="filterVO.startDate != null ">
  11036. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11037. </if>
  11038. <if test="filterVO.endDate != null ">
  11039. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11040. </if>
  11041. </if>
  11042. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11043. <if test="filterVO.startDate != null ">
  11044. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11045. </if>
  11046. <if test="filterVO.endDate != null ">
  11047. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11048. </if>
  11049. </if>
  11050. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11051. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  11052. </if>
  11053. GROUP BY
  11054. a.beh_dept_id,
  11055. e.group_id
  11056. </select>
  11057. <!-- 病历稽查表最新导出-->
  11058. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  11059. SELECT
  11060. a.beh_dept_id AS deptId,
  11061. a.beh_dept_name AS deptName,
  11062. a.doctor_name as doctorGroup,
  11063. a.doctor_name as doctorName,
  11064. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  11065. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  11066. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  11067. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  11068. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  11069. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  11070. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  11071. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  11072. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  11073. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  11074. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  11075. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  11076. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  11077. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  11078. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  11079. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  11080. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  11081. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  11082. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  11083. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  11084. FROM
  11085. med_behospital_info a,
  11086. med_qcresult_info b,
  11087. med_qcresult_detail c,
  11088. qc_cases_entry d,
  11089. bas_doctor_info e,
  11090. sys_user_dept f
  11091. WHERE
  11092. a.is_deleted = 'N'
  11093. AND b.is_deleted = 'N'
  11094. AND c.is_deleted = 'N'
  11095. AND d.is_deleted = 'N'
  11096. AND e.is_deleted = 'N'
  11097. AND f.is_deleted = 'N'
  11098. AND a.hospital_id = b.hospital_id
  11099. AND a.hospital_id = c.hospital_id
  11100. AND a.hospital_id = e.hospital_id
  11101. AND a.hospital_id = f.hospital_id
  11102. AND a.behospital_code = b.behospital_code
  11103. AND a.behospital_code = c.behospital_code
  11104. AND a.beh_dept_id = f.dept_id
  11105. AND c.cases_entry_id = d.id
  11106. and a.doctor_id=e.doctor_id
  11107. and e.group_id is not NULL
  11108. AND LENGTH(e.group_id)>0
  11109. AND a.qc_type_id != 0
  11110. <if test="filterVO.userId!=null">
  11111. AND f.user_id = #{filterVO.userId}
  11112. </if>
  11113. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11114. and a.is_placefile = #{filterVO.isPlacefile}
  11115. </if>
  11116. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11117. AND a.hospital_id = #{filterVO.hospitalId}
  11118. </if>
  11119. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11120. <if test="filterVO.startDate != null ">
  11121. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11122. </if>
  11123. <if test="filterVO.endDate != null ">
  11124. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11125. </if>
  11126. </if>
  11127. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11128. <if test="filterVO.startDate != null ">
  11129. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11130. </if>
  11131. <if test="filterVO.endDate != null ">
  11132. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11133. </if>
  11134. </if>
  11135. <if test="filterVO.name != null and filterVO.name != ''">
  11136. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11137. </if>
  11138. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11139. AND a.beh_dept_name = #{filterVO.deptName}
  11140. </if>
  11141. GROUP BY
  11142. a.beh_dept_id,
  11143. e.group_id,
  11144. a.doctor_name
  11145. </select>
  11146. <!-- 未整改病历统计-->
  11147. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11148. SELECT
  11149. a.beh_dept_id AS deptId,
  11150. a.beh_dept_name AS deptName,
  11151. d.id AS casesEntryId,
  11152. d.NAME AS casesEntryName,
  11153. count(*) AS casesEntryNum
  11154. FROM
  11155. med_behospital_info a,
  11156. med_qcresult_info b,
  11157. med_qcresult_detail c,
  11158. qc_cases_entry d
  11159. WHERE
  11160. a.is_deleted = 'N'
  11161. AND b.is_deleted = 'N'
  11162. AND c.is_deleted = 'N'
  11163. AND d.is_deleted = 'N'
  11164. AND a.hospital_id = b.hospital_id
  11165. AND a.hospital_id = c.hospital_id
  11166. AND a.behospital_code = b.behospital_code
  11167. AND a.behospital_code = c.behospital_code
  11168. AND c.cases_entry_id = d.id
  11169. AND a.qc_type_id != 0
  11170. <if test="isPlacefile != null and isPlacefile != ''">
  11171. and a.is_placefile = #{isPlacefile}
  11172. </if>
  11173. <if test="hospitalId != null and hospitalId != ''">
  11174. AND a.hospital_id = #{hospitalId}
  11175. </if>
  11176. <if test="isPlacefile != null and isPlacefile == 0">
  11177. <if test="startDate != null ">
  11178. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11179. </if>
  11180. <if test="endDate != null ">
  11181. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11182. </if>
  11183. </if>
  11184. <if test="isPlacefile != null and isPlacefile == 1">
  11185. <if test="startDate != null ">
  11186. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11187. </if>
  11188. <if test="endDate != null ">
  11189. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11190. </if>
  11191. </if>
  11192. <if test="deptName != null and deptName != ''">
  11193. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  11194. </if>
  11195. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11196. AND c.cases_entry_id IN
  11197. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11198. #{item}
  11199. </foreach>
  11200. </if>
  11201. GROUP BY
  11202. a.beh_dept_id,
  11203. a.beh_dept_name,
  11204. c.cases_entry_id,
  11205. d.NAME
  11206. </select>
  11207. <!-- 未整改病历统计-科室-->
  11208. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11209. SELECT
  11210. a.beh_dept_id AS deptId,
  11211. a.beh_dept_name AS deptName,
  11212. a.doctor_id as doctorId,
  11213. a.doctor_name as doctorName,
  11214. d.id AS casesEntryId,
  11215. d.NAME AS casesEntryName,
  11216. count(*) AS casesEntryNum
  11217. FROM
  11218. med_behospital_info a,
  11219. med_qcresult_info b,
  11220. med_qcresult_detail c,
  11221. qc_cases_entry d,
  11222. sys_user_dept f
  11223. WHERE
  11224. a.is_deleted = 'N'
  11225. AND b.is_deleted = 'N'
  11226. AND c.is_deleted = 'N'
  11227. AND d.is_deleted = 'N'
  11228. AND f.is_deleted = 'N'
  11229. AND a.hospital_id = b.hospital_id
  11230. AND a.hospital_id = c.hospital_id
  11231. AND a.hospital_id = f.hospital_id
  11232. AND a.behospital_code = b.behospital_code
  11233. AND a.behospital_code = c.behospital_code
  11234. AND a.beh_dept_id = f.dept_id
  11235. AND c.cases_entry_id = d.id
  11236. AND a.qc_type_id != 0
  11237. <if test="userId!=null">
  11238. AND f.user_id = #{userId}
  11239. </if>
  11240. <if test="isPlacefile != null and isPlacefile != ''">
  11241. and a.is_placefile = #{isPlacefile}
  11242. </if>
  11243. <if test="hospitalId != null and hospitalId != ''">
  11244. AND a.hospital_id = #{hospitalId}
  11245. </if>
  11246. <if test="isPlacefile != null and isPlacefile == 0">
  11247. <if test="startDate != null ">
  11248. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11249. </if>
  11250. <if test="endDate != null ">
  11251. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11252. </if>
  11253. </if>
  11254. <if test="isPlacefile != null and isPlacefile == 1">
  11255. <if test="startDate != null ">
  11256. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11257. </if>
  11258. <if test="endDate != null ">
  11259. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11260. </if>
  11261. </if>
  11262. <if test="deptName != null and deptName != ''">
  11263. AND a.beh_dept_name= #{deptName}
  11264. </if>
  11265. <if test="doctorName != null and doctorName != ''">
  11266. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11267. </if>
  11268. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11269. AND c.cases_entry_id IN
  11270. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11271. #{item}
  11272. </foreach>
  11273. </if>
  11274. GROUP BY
  11275. a.doctor_id,
  11276. a.doctor_name,
  11277. c.cases_entry_id,
  11278. d.NAME
  11279. </select>
  11280. <!-- 不合格/合格数病历号(内页)科室-->
  11281. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  11282. SELECT t.*
  11283. FROM
  11284. (SELECT DISTINCT
  11285. t1.hospital_id AS hospitalId,
  11286. t1.behospital_code AS behospitalCode,
  11287. t1.bed_code AS bedCode,
  11288. t1.LEVEL AS LEVEL,
  11289. t1.grade_type AS gradeType,
  11290. t1.score_res AS scoreRes,
  11291. t1.scoreBn,
  11292. t1.NAME AS NAME,
  11293. t1.sex AS sex,
  11294. t1.beh_dept_id AS behDeptId,
  11295. t1.beh_dept_name AS behDeptName,
  11296. t1.doctor_id AS doctorId,
  11297. t1.doctor_name AS doctorName,
  11298. t1.beh_doctor_id AS behDoctorId,
  11299. t1.beh_doctor_name AS behDoctorName,
  11300. t1.director_doctor_id AS directorDoctorId,
  11301. t1.director_doctor_name AS directorDoctorName,
  11302. t1.birthday AS birthday,
  11303. t1.behospital_date AS behospitalDate,
  11304. t1.leave_hospital_date AS leaveHospitalDate,
  11305. t1.placefile_date AS placefileDate,
  11306. t1.gmt_create AS gradeTime,
  11307. t1.diagnose,
  11308. t1.ward_name AS wardName,
  11309. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11310. t1.file_code AS fileCode,
  11311. t1.checkStatus,
  11312. t1.mrStatus,
  11313. t1.chName,
  11314. t1.mrName,
  11315. t1.chTime,
  11316. t1.mrTime
  11317. FROM
  11318. (SELECT
  11319. be.*,
  11320. b.LEVEL,
  11321. b.grade_type,
  11322. b.score_res,
  11323. b.gmt_create,
  11324. ifnull(mci.status,0) AS checkStatus,
  11325. ifnull(hm_mci.status,0) AS mrStatus,
  11326. mci.check_name as chName,
  11327. hm_mci.check_name as mrName,
  11328. mci.gmt_create as chTime,
  11329. hm_mci.gmt_create as mrTime
  11330. FROM
  11331. (
  11332. SELECT DISTINCT
  11333. a.hospital_id,
  11334. a.behospital_code,
  11335. a.bed_code,
  11336. a.file_code,
  11337. e.score_res as scoreBn,
  11338. a.NAME,
  11339. a.sex,
  11340. a.beh_dept_id,
  11341. a.beh_dept_name,
  11342. a.birthday,
  11343. a.behospital_date,
  11344. a.leave_hospital_date,
  11345. a.doctor_id,
  11346. a.doctor_name,
  11347. a.beh_doctor_id,
  11348. a.beh_doctor_name,
  11349. a.director_doctor_id,
  11350. a.director_doctor_name,
  11351. a.diagnose,
  11352. a.placefile_date,
  11353. a.ward_name
  11354. FROM
  11355. med_behospital_info a,
  11356. sys_user_dept c,
  11357. med_qcresult_cases e
  11358. WHERE
  11359. a.is_deleted = 'N'
  11360. AND c.is_deleted = 'N'
  11361. AND e.is_deleted = 'N'
  11362. AND a.hospital_id = c.hospital_id
  11363. AND a.hospital_id = e.hospital_id
  11364. AND a.beh_dept_id = c.dept_id
  11365. AND a.behospital_code = e.behospital_code
  11366. AND a.qc_type_id != 0
  11367. AND e.cases_id = 243
  11368. <if test="userId!=null">
  11369. AND c.user_id = #{userId}
  11370. </if>
  11371. <if test="deptName != null and deptName != ''">
  11372. and a.beh_dept_name = #{deptName}
  11373. </if>
  11374. <if test="deptClass != null and deptClass != ''">
  11375. and a.beh_dept_id = #{deptClass}
  11376. </if>
  11377. <if test="titleName != null and titleName != '' ">
  11378. <if test="titleName == '不合格数'">
  11379. AND e.`level`='不合格'
  11380. </if>
  11381. <if test="titleName == '合格数'">
  11382. AND e.`level`='合格'
  11383. </if>
  11384. </if>
  11385. <if test="isPlacefile != null and isPlacefile != ''">
  11386. and a.is_placefile = #{isPlacefile}
  11387. </if>
  11388. <if test="doctorName != null and doctorName != ''">
  11389. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11390. </if>
  11391. <if test="hospitalId != null and hospitalId != ''">
  11392. AND a.hospital_id = #{hospitalId}
  11393. </if>
  11394. <if test="isPlacefile != null and isPlacefile == 0">
  11395. <if test="startDate != null ">
  11396. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11397. </if>
  11398. <if test="endDate != null ">
  11399. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11400. </if>
  11401. </if>
  11402. <if test="isPlacefile != null and isPlacefile == 1">
  11403. <if test="startDate != null ">
  11404. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11405. </if>
  11406. <if test="endDate != null">
  11407. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11408. </if>
  11409. </if>
  11410. <if test="diagnose != null and diagnose != ''">
  11411. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11412. </if>
  11413. <if test="behospitalCode != null and behospitalCode != ''">
  11414. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11415. </if>
  11416. <if test="patName != null and patName != ''">
  11417. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11418. </if>
  11419. <if test="doctorId != null and doctorId != ''">
  11420. AND (a.doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  11421. OR a.beh_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  11422. OR a.director_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' ))
  11423. </if>
  11424. )be
  11425. left join med_check_info mci
  11426. on mci.is_deleted = 'N'
  11427. and mci.check_type = 0
  11428. and be.hospital_id = mci.hospital_id
  11429. and be.behospital_code = mci.behospital_code
  11430. left join med_check_info hm_mci
  11431. on hm_mci.is_deleted = 'N'
  11432. and hm_mci.check_type = 1
  11433. and be.hospital_id = hm_mci.hospital_id
  11434. and be.behospital_code = hm_mci.behospital_code
  11435. left join med_qcresult_info b
  11436. on b.is_deleted = 'N'
  11437. AND be.hospital_id = b.hospital_id
  11438. AND be.behospital_code = b.behospital_code
  11439. where
  11440. 1=1
  11441. <if test="level != null and level != ''">
  11442. AND b.`level` = #{level}
  11443. </if>
  11444. ) t1
  11445. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11446. AND t1.behospital_code = t2.behospital_code
  11447. AND t2.is_deleted = 'N'
  11448. ) t,
  11449. (
  11450. SELECT
  11451. a.doctor_id as doctorId,
  11452. a.doctor_name as doctorName
  11453. FROM
  11454. med_behospital_info a,
  11455. sys_user_dept b,
  11456. med_qcresult_cases c,
  11457. med_qcresult_detail d,
  11458. qc_cases_entry e
  11459. WHERE
  11460. a.is_deleted = 'N'
  11461. AND b.is_deleted = 'N'
  11462. AND c.is_deleted = 'N'
  11463. AND d.is_deleted = 'N'
  11464. AND e.is_deleted = 'N'
  11465. AND a.hospital_id = b.hospital_id
  11466. AND a.hospital_id = c.hospital_id
  11467. AND a.hospital_id = d.hospital_id
  11468. AND a.behospital_code = c.behospital_code
  11469. AND a.behospital_code = d.behospital_code
  11470. AND a.beh_dept_id = b.dept_id
  11471. AND c.cases_id = d.cases_id
  11472. AND d.cases_id = e.cases_id
  11473. AND d.cases_entry_id = e.id
  11474. AND d.cases_id = 243
  11475. AND a.qc_type_id != 0
  11476. <!-- <if test="titleName != null ">-->
  11477. <!-- <if test="titleName == '不合格数'">-->
  11478. <!-- AND c.`level`='不合格'-->
  11479. <!-- </if>-->
  11480. <!-- <if test="titleName == '合格数'">-->
  11481. <!-- AND c.`level`='合格'-->
  11482. <!-- </if>-->
  11483. <!-- </if>-->
  11484. <if test="userId!=null">
  11485. AND b.user_id = #{userId}
  11486. </if>
  11487. <if test="deptName != null and deptName != ''">
  11488. and a.beh_dept_name = #{deptName}
  11489. </if>
  11490. <if test="doctorName != null and doctorName != ''">
  11491. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11492. </if>
  11493. <if test="deptClass != null and deptClass != ''">
  11494. and a.beh_dept_id = #{deptClass}
  11495. </if>
  11496. <if test="isPlacefile != null and isPlacefile != ''">
  11497. and a.is_placefile = #{isPlacefile}
  11498. </if>
  11499. <if test="hospitalId != null and hospitalId != ''">
  11500. AND a.hospital_id = #{hospitalId}
  11501. </if>
  11502. <if test="isPlacefile != null and isPlacefile == 0">
  11503. <if test="startDate != null ">
  11504. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11505. </if>
  11506. <if test="endDate != null ">
  11507. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11508. </if>
  11509. </if>
  11510. <if test="isPlacefile != null and isPlacefile == 1">
  11511. <if test="startDate != null ">
  11512. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11513. </if>
  11514. <if test="endDate != null">
  11515. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11516. </if>
  11517. </if>
  11518. <if test="diagnose != null and diagnose != ''">
  11519. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11520. </if>
  11521. <if test="behospitalCode != null and behospitalCode != ''">
  11522. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11523. </if>
  11524. <if test="patName != null and patName != ''">
  11525. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11526. </if>
  11527. GROUP BY
  11528. a.doctor_id,
  11529. a.doctor_name
  11530. ) t2
  11531. where
  11532. t.doctorId = t2.doctorId
  11533. AND t.doctorName = t2.doctorName
  11534. <if test="checkStatus != null">
  11535. AND t.checkStatus = #{checkStatus}
  11536. </if>
  11537. <if test="mrStatus != null">
  11538. AND t.mrStatus = #{mrStatus}
  11539. </if>
  11540. <if test="chName != null and chName!=''">
  11541. AND t.chName like concat('%', #{chName}, '%')
  11542. </if>
  11543. <if test="mrName != null and mrName!=''">
  11544. AND t.mrName like concat('%', #{mrName}, '%')
  11545. </if>
  11546. <if test="chTimeStart != null ">
  11547. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  11548. </if>
  11549. <if test="chTimeEnd != null ">
  11550. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  11551. </if>
  11552. <if test="mrTimeStart != null ">
  11553. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  11554. </if>
  11555. <if test="mrTimeEnd != null ">
  11556. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  11557. </if>
  11558. </select>
  11559. <!-- 不合格/合格数病历号(内页)全院-->
  11560. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11561. SELECT t.*
  11562. FROM
  11563. (SELECT DISTINCT
  11564. t1.hospital_id AS hospitalId,
  11565. t1.behospital_code AS behospitalCode,
  11566. t1.bed_code AS bedCode,
  11567. t1.LEVEL AS LEVEL,
  11568. t1.grade_type AS gradeType,
  11569. t1.score_res AS scoreRes,
  11570. t1.scoreBn,
  11571. t1.NAME AS NAME,
  11572. t1.sex AS sex,
  11573. t1.beh_dept_id AS behDeptId,
  11574. t1.beh_dept_name AS behDeptName,
  11575. t1.doctor_id AS doctorId,
  11576. t1.doctor_name AS doctorName,
  11577. t1.beh_doctor_id AS behDoctorId,
  11578. t1.beh_doctor_name AS behDoctorName,
  11579. t1.director_doctor_id AS directorDoctorId,
  11580. t1.director_doctor_name AS directorDoctorName,
  11581. t1.birthday AS birthday,
  11582. t1.behospital_date AS behospitalDate,
  11583. t1.leave_hospital_date AS leaveHospitalDate,
  11584. t1.placefile_date AS placefileDate,
  11585. t1.gmt_create AS gradeTime,
  11586. t1.diagnose,
  11587. t1.ward_name AS wardName,
  11588. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11589. t1.file_code AS fileCode,
  11590. t1.checkStatus,
  11591. t1.mrStatus,
  11592. t1.chName,
  11593. t1.mrName,
  11594. t1.chTime,
  11595. t1.mrTime
  11596. FROM
  11597. (SELECT
  11598. be.*,
  11599. b.LEVEL,
  11600. b.grade_type,
  11601. b.score_res,
  11602. b.gmt_create,
  11603. ifnull(mci.status,0) AS checkStatus,
  11604. ifnull(hm_mci.status,0) AS mrStatus,
  11605. mci.check_name as chName,
  11606. hm_mci.check_name as mrName,
  11607. mci.gmt_create as chTime,
  11608. hm_mci.gmt_create as mrTime
  11609. FROM
  11610. (
  11611. SELECT DISTINCT
  11612. a.hospital_id,
  11613. a.behospital_code,
  11614. a.bed_code,
  11615. a.file_code,
  11616. e.score_res as scoreBn,
  11617. a.NAME,
  11618. a.sex,
  11619. a.beh_dept_id,
  11620. a.beh_dept_name,
  11621. a.birthday,
  11622. a.behospital_date,
  11623. a.leave_hospital_date,
  11624. a.doctor_id,
  11625. a.doctor_name,
  11626. a.beh_doctor_id,
  11627. a.beh_doctor_name,
  11628. a.director_doctor_id,
  11629. a.director_doctor_name,
  11630. a.diagnose,
  11631. a.placefile_date,
  11632. a.ward_name
  11633. FROM
  11634. med_behospital_info a,
  11635. med_qcresult_cases e
  11636. WHERE
  11637. a.is_deleted = 'N'
  11638. AND e.is_deleted = 'N'
  11639. AND a.hospital_id = e.hospital_id
  11640. AND a.behospital_code = e.behospital_code
  11641. AND a.qc_type_id != 0
  11642. AND e.cases_id = 243
  11643. <if test="qcResultPageVO.titleName != null ">
  11644. <if test="qcResultPageVO.titleName == '不合格数'">
  11645. AND e.`level`='不合格'
  11646. </if>
  11647. <if test="qcResultPageVO.titleName == '合格数'">
  11648. AND e.`level`='合格'
  11649. </if>
  11650. </if>
  11651. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11652. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11653. </if>
  11654. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11655. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11656. </if>
  11657. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11658. <if test="qcResultPageVO.startDate != null ">
  11659. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11660. </if>
  11661. <if test="qcResultPageVO.endDate != null ">
  11662. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11663. </if>
  11664. </if>
  11665. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11666. <if test="qcResultPageVO.startDate != null ">
  11667. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11668. </if>
  11669. <if test="qcResultPageVO.endDate != null">
  11670. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11671. </if>
  11672. </if>
  11673. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11674. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11675. </if>
  11676. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11677. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  11678. </if>
  11679. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11680. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11681. </if>
  11682. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11683. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11684. </if>
  11685. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11686. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11687. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11688. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11689. </if>
  11690. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11691. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11692. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11693. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11694. </if>
  11695. )be
  11696. left join med_check_info mci
  11697. on mci.is_deleted = 'N'
  11698. and mci.check_type = 0
  11699. and be.hospital_id = mci.hospital_id
  11700. and be.behospital_code = mci.behospital_code
  11701. left join med_check_info hm_mci
  11702. on hm_mci.is_deleted = 'N'
  11703. and hm_mci.check_type = 1
  11704. and be.hospital_id = hm_mci.hospital_id
  11705. and be.behospital_code = hm_mci.behospital_code
  11706. left join med_qcresult_info b
  11707. on b.is_deleted = 'N'
  11708. AND be.hospital_id = b.hospital_id
  11709. AND be.behospital_code = b.behospital_code
  11710. where
  11711. 1=1
  11712. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  11713. AND b.`level` = #{qcResultPageVO.level}
  11714. </if>
  11715. ) t1
  11716. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11717. AND t1.behospital_code = t2.behospital_code
  11718. AND t2.is_deleted = 'N'
  11719. ) t,
  11720. (
  11721. SELECT
  11722. a.beh_dept_id AS deptId,
  11723. a.beh_dept_name AS deptName
  11724. FROM
  11725. med_behospital_info a,
  11726. med_qcresult_cases c,
  11727. med_qcresult_detail d,
  11728. qc_cases_entry e
  11729. WHERE
  11730. a.is_deleted = 'N'
  11731. AND c.is_deleted = 'N'
  11732. AND d.is_deleted = 'N'
  11733. AND e.is_deleted = 'N'
  11734. AND a.hospital_id = c.hospital_id
  11735. AND a.hospital_id = d.hospital_id
  11736. AND a.behospital_code = c.behospital_code
  11737. AND a.behospital_code = d.behospital_code
  11738. AND c.cases_id = d.cases_id
  11739. AND d.cases_id = e.cases_id
  11740. AND d.cases_entry_id = e.id
  11741. AND d.cases_id = 243
  11742. AND a.qc_type_id != 0
  11743. <!-- <if test="qcResultPageVO.titleName != null ">-->
  11744. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  11745. <!-- AND c.`level`='不合格'-->
  11746. <!-- </if>-->
  11747. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  11748. <!-- AND c.`level`='合格'-->
  11749. <!-- </if>-->
  11750. <!-- </if>-->
  11751. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11752. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11753. </if>
  11754. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11755. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11756. </if>
  11757. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11758. <if test="qcResultPageVO.startDate != null ">
  11759. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11760. </if>
  11761. <if test="qcResultPageVO.endDate != null ">
  11762. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11763. </if>
  11764. </if>
  11765. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11766. <if test="qcResultPageVO.startDate != null ">
  11767. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11768. </if>
  11769. <if test="qcResultPageVO.endDate != null">
  11770. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11771. </if>
  11772. </if>
  11773. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11774. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11775. </if>
  11776. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11777. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  11778. </if>
  11779. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11780. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11781. </if>
  11782. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11783. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11784. </if>
  11785. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11786. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11787. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11788. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11789. </if>
  11790. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11791. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11792. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11793. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11794. </if>
  11795. GROUP BY
  11796. a.beh_dept_id,
  11797. a.beh_dept_name
  11798. ) t2
  11799. where
  11800. t.behDeptId = t2.deptId
  11801. AND t.behDeptName = t2.deptName
  11802. <if test="qcResultPageVO.checkStatus != null">
  11803. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  11804. </if>
  11805. <if test="qcResultPageVO.mrStatus != null">
  11806. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  11807. </if>
  11808. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  11809. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  11810. </if>
  11811. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  11812. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  11813. </if>
  11814. <if test="qcResultPageVO.chTimeStart != null ">
  11815. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  11816. </if>
  11817. <if test="qcResultPageVO.chTimeEnd != null ">
  11818. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  11819. </if>
  11820. <if test="qcResultPageVO.mrTimeStart != null ">
  11821. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  11822. </if>
  11823. <if test="qcResultPageVO.mrTimeEnd != null ">
  11824. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  11825. </if>
  11826. </select>
  11827. <!-- 未整改病历质控评分页(内页)-->
  11828. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11829. SELECT t.*
  11830. FROM
  11831. (SELECT DISTINCT
  11832. t1.hospital_id AS hospitalId,
  11833. t1.behospital_code AS behospitalCode,
  11834. t1.bed_code AS bedCode,
  11835. t1.LEVEL AS LEVEL,
  11836. t1.grade_type AS gradeType,
  11837. t1.score_res AS scoreRes,
  11838. t1.scoreBn,
  11839. t1.NAME AS NAME,
  11840. t1.sex AS sex,
  11841. t1.beh_dept_id AS behDeptId,
  11842. t1.beh_dept_name AS behDeptName,
  11843. t1.doctor_id AS doctorId,
  11844. t1.doctor_name AS doctorName,
  11845. t1.beh_doctor_id AS behDoctorId,
  11846. t1.beh_doctor_name AS behDoctorName,
  11847. t1.director_doctor_id AS directorDoctorId,
  11848. t1.director_doctor_name AS directorDoctorName,
  11849. t1.birthday AS birthday,
  11850. t1.behospital_date AS behospitalDate,
  11851. t1.leave_hospital_date AS leaveHospitalDate,
  11852. t1.placefile_date AS placefileDate,
  11853. t1.gmt_create AS gradeTime,
  11854. t1.diagnose,
  11855. t1.ward_name AS wardName,
  11856. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11857. t1.file_code AS fileCode,
  11858. t1.checkStatus,
  11859. t1.mrStatus,
  11860. t1.chName,
  11861. t1.mrName,
  11862. t1.chTime,
  11863. t1.mrTime
  11864. FROM
  11865. (SELECT
  11866. be.*,
  11867. ifnull(mci.status,0) AS checkStatus,
  11868. ifnull(hm_mci.status,0) AS mrStatus,
  11869. mci.check_name as chName,
  11870. e.score_res as scoreBn,
  11871. hm_mci.check_name as mrName,
  11872. mci.gmt_create as chTime,
  11873. hm_mci.gmt_create as mrTime
  11874. FROM
  11875. (
  11876. SELECT DISTINCT
  11877. a.hospital_id,
  11878. a.behospital_code,
  11879. a.bed_code,
  11880. a.file_code,
  11881. b.LEVEL,
  11882. b.grade_type,
  11883. b.score_res,
  11884. a.NAME,
  11885. a.sex,
  11886. a.beh_dept_id,
  11887. a.beh_dept_name,
  11888. a.birthday,
  11889. a.behospital_date,
  11890. a.leave_hospital_date,
  11891. a.doctor_id,
  11892. a.doctor_name,
  11893. a.beh_doctor_id,
  11894. a.beh_doctor_name,
  11895. a.director_doctor_id,
  11896. a.director_doctor_name,
  11897. a.diagnose,
  11898. a.placefile_date,
  11899. a.ward_name,
  11900. b.gmt_create
  11901. FROM
  11902. med_behospital_info a,
  11903. med_qcresult_info b,
  11904. med_qcresult_detail c,
  11905. qc_cases_entry d
  11906. WHERE
  11907. a.is_deleted = 'N'
  11908. AND b.is_deleted = 'N'
  11909. AND c.is_deleted = 'N'
  11910. AND d.is_deleted = 'N'
  11911. AND a.hospital_id = b.hospital_id
  11912. AND a.hospital_id = c.hospital_id
  11913. AND a.behospital_code = b.behospital_code
  11914. AND a.behospital_code = c.behospital_code
  11915. AND c.cases_id = d.cases_id
  11916. AND c.cases_entry_id = d.id
  11917. AND a.qc_type_id != 0
  11918. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11919. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11920. </if>
  11921. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11922. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11923. </if>
  11924. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11925. <if test="qcResultShortPageVO.startDate != null ">
  11926. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11927. </if>
  11928. <if test="qcResultShortPageVO.endDate != null ">
  11929. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11930. </if>
  11931. </if>
  11932. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11933. <if test="qcResultShortPageVO.startDate != null ">
  11934. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11935. </if>
  11936. <if test="qcResultShortPageVO.endDate != null">
  11937. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11938. </if>
  11939. </if>
  11940. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11941. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11942. </if>
  11943. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11944. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11945. </if>
  11946. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11947. AND b.`level` = #{qcResultShortPageVO.level}
  11948. </if>
  11949. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11950. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11951. </if>
  11952. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11953. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11954. </if>
  11955. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11956. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11957. </if>
  11958. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11959. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11960. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11961. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11962. </if>
  11963. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11964. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11965. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11966. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11967. </if>
  11968. <if test="qcResultShortPageVO.casesEntryId != null ">
  11969. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11970. </if>
  11971. <if test="qcResultShortPageVO.isReject != null">
  11972. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11973. </if>
  11974. <if test="qcResultShortPageVO.ruleType != null">
  11975. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11976. </if>
  11977. )be
  11978. left join med_check_info mci
  11979. on mci.is_deleted = 'N'
  11980. and mci.check_type = 0
  11981. and be.hospital_id = mci.hospital_id
  11982. and be.behospital_code = mci.behospital_code
  11983. left join med_check_info hm_mci
  11984. on hm_mci.is_deleted = 'N'
  11985. and hm_mci.check_type = 1
  11986. and be.hospital_id = hm_mci.hospital_id
  11987. and be.behospital_code = hm_mci.behospital_code
  11988. LEFT JOIN med_qcresult_cases e
  11989. on be.behospital_code = e.behospital_code
  11990. and be.hospital_id = e.hospital_id
  11991. AND e.is_deleted = 'N'
  11992. and e.cases_id = 243
  11993. ) t1
  11994. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11995. AND t1.behospital_code = t2.behospital_code
  11996. AND t2.is_deleted = 'N'
  11997. ) t
  11998. where 1=1
  11999. <if test="qcResultShortPageVO.checkStatus != null">
  12000. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12001. </if>
  12002. <if test="qcResultShortPageVO.mrStatus != null">
  12003. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12004. </if>
  12005. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12006. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12007. </if>
  12008. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12009. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12010. </if>
  12011. <if test="qcResultShortPageVO.chTimeStart != null ">
  12012. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12013. </if>
  12014. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12015. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12016. </if>
  12017. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12018. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12019. </if>
  12020. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12021. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12022. </if>
  12023. </select>
  12024. <!-- 未整改病历质控评分页-科室(内页)-->
  12025. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  12026. SELECT t.*
  12027. FROM
  12028. (SELECT DISTINCT
  12029. t1.hospital_id AS hospitalId,
  12030. t1.behospital_code AS behospitalCode,
  12031. t1.bed_code AS bedCode,
  12032. t1.LEVEL AS LEVEL,
  12033. t1.grade_type AS gradeType,
  12034. t1.score_res AS scoreRes,
  12035. t1.scoreBn,
  12036. t1.NAME AS NAME,
  12037. t1.sex AS sex,
  12038. t1.beh_dept_id AS behDeptId,
  12039. t1.beh_dept_name AS behDeptName,
  12040. t1.doctor_id AS doctorId,
  12041. t1.doctor_name AS doctorName,
  12042. t1.beh_doctor_id AS behDoctorId,
  12043. t1.beh_doctor_name AS behDoctorName,
  12044. t1.director_doctor_id AS directorDoctorId,
  12045. t1.director_doctor_name AS directorDoctorName,
  12046. t1.birthday AS birthday,
  12047. t1.behospital_date AS behospitalDate,
  12048. t1.leave_hospital_date AS leaveHospitalDate,
  12049. t1.placefile_date AS placefileDate,
  12050. t1.gmt_create AS gradeTime,
  12051. t1.diagnose,
  12052. t1.ward_name AS wardName,
  12053. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12054. t1.file_code AS fileCode,
  12055. t1.checkStatus,
  12056. t1.mrStatus,
  12057. t1.chName,
  12058. t1.mrName,
  12059. t1.chTime,
  12060. t1.mrTime
  12061. FROM
  12062. (SELECT
  12063. be.*,
  12064. ifnull(mci.status,0) AS checkStatus,
  12065. ifnull(hm_mci.status,0) AS mrStatus,
  12066. mci.check_name as chName,
  12067. e.score_res as scoreBn,
  12068. hm_mci.check_name as mrName,
  12069. mci.gmt_create as chTime,
  12070. hm_mci.gmt_create as mrTime
  12071. FROM
  12072. (
  12073. SELECT DISTINCT
  12074. a.hospital_id,
  12075. a.behospital_code,
  12076. a.bed_code,
  12077. a.file_code,
  12078. b.LEVEL,
  12079. b.grade_type,
  12080. b.score_res,
  12081. a.NAME,
  12082. a.sex,
  12083. a.beh_dept_id,
  12084. a.beh_dept_name,
  12085. a.birthday,
  12086. a.behospital_date,
  12087. a.leave_hospital_date,
  12088. a.doctor_id,
  12089. a.doctor_name,
  12090. a.beh_doctor_id,
  12091. a.beh_doctor_name,
  12092. a.director_doctor_id,
  12093. a.director_doctor_name,
  12094. a.diagnose,
  12095. a.placefile_date,
  12096. a.ward_name,
  12097. b.gmt_create
  12098. FROM
  12099. med_behospital_info a,
  12100. med_qcresult_info b,
  12101. med_qcresult_detail c,
  12102. qc_cases_entry d,
  12103. sys_user_dept f
  12104. WHERE
  12105. a.is_deleted = 'N'
  12106. AND b.is_deleted = 'N'
  12107. AND c.is_deleted = 'N'
  12108. AND d.is_deleted = 'N'
  12109. AND f.is_deleted = 'N'
  12110. AND a.hospital_id = b.hospital_id
  12111. AND a.hospital_id = c.hospital_id
  12112. AND a.hospital_id = f.hospital_id
  12113. AND a.behospital_code = b.behospital_code
  12114. AND a.behospital_code = c.behospital_code
  12115. AND c.cases_id = d.cases_id
  12116. AND a.beh_dept_id = f.dept_id
  12117. AND c.cases_entry_id = d.id
  12118. AND a.qc_type_id != 0
  12119. <if test="qcResultShortPageVO.userId!=null">
  12120. AND f.user_id = #{qcResultShortPageVO.userId}
  12121. </if>
  12122. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12123. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12124. </if>
  12125. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12126. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12127. </if>
  12128. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12129. <if test="qcResultShortPageVO.startDate != null ">
  12130. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12131. </if>
  12132. <if test="qcResultShortPageVO.endDate != null ">
  12133. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12134. </if>
  12135. </if>
  12136. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12137. <if test="qcResultShortPageVO.startDate != null ">
  12138. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12139. </if>
  12140. <if test="qcResultShortPageVO.endDate != null">
  12141. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12142. </if>
  12143. </if>
  12144. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12145. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12146. </if>
  12147. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12148. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12149. </if>
  12150. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12151. AND b.`level` = #{qcResultShortPageVO.level}
  12152. </if>
  12153. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12154. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12155. </if>
  12156. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12157. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12158. </if>
  12159. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12160. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12161. </if>
  12162. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12163. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12164. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12165. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12166. </if>
  12167. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12168. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12169. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12170. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12171. </if>
  12172. <if test="qcResultShortPageVO.casesEntryId != null ">
  12173. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12174. </if>
  12175. <if test="qcResultShortPageVO.isReject != null">
  12176. AND c.is_reject = #{qcResultShortPageVO.isReject}
  12177. </if>
  12178. <if test="qcResultShortPageVO.ruleType != null">
  12179. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12180. </if>
  12181. )be
  12182. left join med_check_info mci
  12183. on mci.is_deleted = 'N'
  12184. and mci.check_type = 0
  12185. and be.hospital_id = mci.hospital_id
  12186. and be.behospital_code = mci.behospital_code
  12187. left join med_check_info hm_mci
  12188. on hm_mci.is_deleted = 'N'
  12189. and hm_mci.check_type = 1
  12190. and be.hospital_id = hm_mci.hospital_id
  12191. and be.behospital_code = hm_mci.behospital_code
  12192. LEFT JOIN med_qcresult_cases e
  12193. on be.behospital_code = e.behospital_code
  12194. and be.hospital_id = e.hospital_id
  12195. AND e.is_deleted = 'N'
  12196. and e.cases_id = 243
  12197. ) t1
  12198. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12199. AND t1.behospital_code = t2.behospital_code
  12200. AND t2.is_deleted = 'N'
  12201. ) t
  12202. where 1=1
  12203. <if test="qcResultShortPageVO.checkStatus != null">
  12204. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12205. </if>
  12206. <if test="qcResultShortPageVO.mrStatus != null">
  12207. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12208. </if>
  12209. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12210. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12211. </if>
  12212. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12213. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12214. </if>
  12215. <if test="qcResultShortPageVO.chTimeStart != null ">
  12216. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12217. </if>
  12218. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12219. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12220. </if>
  12221. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12222. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12223. </if>
  12224. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12225. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12226. </if>
  12227. </select>
  12228. <!-- 病案首页不合格/合格数病历详情页导出-->
  12229. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  12230. SELECT
  12231. f1.behDeptId,
  12232. f1.behDeptName,
  12233. f1.doctorName,
  12234. f1.patName,
  12235. f1.behospitalCode,
  12236. f1.hospitalId,
  12237. f1.behospitalDate,
  12238. f1.leaveHospitalDate,
  12239. f1.score,
  12240. f1.scoreBn,
  12241. f2.avgScore,
  12242. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12243. f1.msg,
  12244. f1.caseName,
  12245. </if>
  12246. f1.checkStatus,
  12247. f1.mrStatus,
  12248. f1.chName,
  12249. f1.mrName,
  12250. f1.chTime,
  12251. f1.mrTime
  12252. FROM
  12253. (SELECT
  12254. t.doctorName,
  12255. t.`name` AS patName,
  12256. t.behospitalCode AS behospitalCode,
  12257. t.behospitalDate AS behospitalDate,
  12258. t.leaveHospitalDate AS leaveHospitalDate,
  12259. qi.score_res AS score,
  12260. t.scoreBn,
  12261. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12262. qd.msg AS msg,
  12263. qc.NAME AS caseName,
  12264. </if>
  12265. t.behDeptId,
  12266. t.behDeptName,
  12267. t.hospitalId,
  12268. t.checkStatus,
  12269. t.mrStatus,
  12270. t.chName,
  12271. t.mrName,
  12272. t.chTime,
  12273. t.mrTime
  12274. FROM
  12275. (SELECT DISTINCT
  12276. t1.hospital_id AS hospitalId,
  12277. t1.behospital_code AS behospitalCode,
  12278. t1.bed_code AS bedCode,
  12279. t1.LEVEL AS LEVEL,
  12280. t1.grade_type AS gradeType,
  12281. t1.score_res AS scoreRes,
  12282. t1.scoreBn,
  12283. t1.NAME AS NAME,
  12284. t1.sex AS sex,
  12285. t1.beh_dept_id AS behDeptId,
  12286. t1.beh_dept_name AS behDeptName,
  12287. t1.doctor_id AS doctorId,
  12288. t1.doctor_name AS doctorName,
  12289. t1.beh_doctor_id AS behDoctorId,
  12290. t1.beh_doctor_name AS behDoctorName,
  12291. t1.director_doctor_id AS directorDoctorId,
  12292. t1.director_doctor_name AS directorDoctorName,
  12293. t1.birthday AS birthday,
  12294. t1.behospital_date AS behospitalDate,
  12295. t1.leave_hospital_date AS leaveHospitalDate,
  12296. t1.placefile_date AS placefileDate,
  12297. t1.gmt_create AS gradeTime,
  12298. t1.diagnose,
  12299. t1.ward_name AS wardName,
  12300. t2.age,
  12301. t1.file_code AS fileCode,
  12302. t1.checkStatus,
  12303. t1.mrStatus,
  12304. t1.chName,
  12305. t1.mrName,
  12306. t1.chTime,
  12307. t1.mrTime
  12308. FROM
  12309. (SELECT
  12310. be.*,
  12311. b.LEVEL,
  12312. b.grade_type,
  12313. b.score_res,
  12314. b.gmt_create,
  12315. ifnull(mci.status,0) AS checkStatus,
  12316. ifnull(hm_mci.status,0) AS mrStatus,
  12317. mci.check_name as chName,
  12318. hm_mci.check_name as mrName,
  12319. mci.gmt_create as chTime,
  12320. hm_mci.gmt_create as mrTime
  12321. FROM
  12322. (
  12323. SELECT DISTINCT
  12324. a.hospital_id,
  12325. a.behospital_code,
  12326. a.bed_code,
  12327. a.file_code,
  12328. c.score_res as scoreBn,
  12329. c.cases_id,
  12330. a.NAME,
  12331. a.sex,
  12332. a.beh_dept_id,
  12333. a.beh_dept_name,
  12334. a.birthday,
  12335. a.behospital_date,
  12336. a.leave_hospital_date,
  12337. a.doctor_id,
  12338. a.doctor_name,
  12339. a.beh_doctor_id,
  12340. a.beh_doctor_name,
  12341. a.director_doctor_id,
  12342. a.director_doctor_name,
  12343. a.diagnose,
  12344. a.placefile_date,
  12345. a.ward_name
  12346. FROM
  12347. med_behospital_info a,
  12348. med_qcresult_cases c
  12349. WHERE
  12350. a.is_deleted = 'N'
  12351. AND c.is_deleted = 'N'
  12352. AND a.hospital_id = c.hospital_id
  12353. AND a.behospital_code = c.behospital_code
  12354. AND a.qc_type_id != 0
  12355. AND c.cases_id = 243
  12356. <if test="qcResultShortPageVO.titleName != null ">
  12357. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12358. AND c.`level`='不合格'
  12359. </if>
  12360. <if test="qcResultShortPageVO.titleName == '合格数'">
  12361. AND c.`level`='合格'
  12362. </if>
  12363. </if>
  12364. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12365. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12366. </if>
  12367. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12368. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12369. </if>
  12370. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12371. <if test="qcResultShortPageVO.startDate != null ">
  12372. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12373. </if>
  12374. <if test="qcResultShortPageVO.endDate != null ">
  12375. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12376. </if>
  12377. </if>
  12378. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12379. <if test="qcResultShortPageVO.startDate != null ">
  12380. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12381. </if>
  12382. <if test="qcResultShortPageVO.endDate != null">
  12383. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12384. </if>
  12385. </if>
  12386. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12387. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12388. </if>
  12389. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12390. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12391. </if>
  12392. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12393. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12394. </if>
  12395. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12396. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12397. </if>
  12398. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12399. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12400. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12401. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12402. </if>
  12403. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12404. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12405. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12406. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12407. </if>
  12408. )be
  12409. left join med_check_info mci
  12410. on mci.is_deleted = 'N'
  12411. and mci.check_type = 0
  12412. and be.hospital_id = mci.hospital_id
  12413. and be.behospital_code = mci.behospital_code
  12414. left join med_check_info hm_mci
  12415. on hm_mci.is_deleted = 'N'
  12416. and hm_mci.check_type = 1
  12417. and be.hospital_id = hm_mci.hospital_id
  12418. and be.behospital_code = hm_mci.behospital_code
  12419. left join med_qcresult_info b
  12420. on b.is_deleted = 'N'
  12421. AND be.hospital_id = b.hospital_id
  12422. AND be.behospital_code = b.behospital_code
  12423. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12424. AND b.`level` = #{qcResultPageVO.level}
  12425. </if>
  12426. left join qc_cases_entry d
  12427. on d.is_deleted = 'N'
  12428. AND be.cases_id = d.cases_id
  12429. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12430. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12431. </if>
  12432. <if test="qcResultShortPageVO.casesEntryId != null ">
  12433. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12434. </if>
  12435. <if test="qcResultShortPageVO.ruleType != null">
  12436. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12437. </if>
  12438. ) t1
  12439. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12440. AND t1.behospital_code = t2.behospital_code
  12441. AND t2.is_deleted = 'N'
  12442. ) t
  12443. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12444. AND t.hospitalId = qi.hospital_id
  12445. AND t.behospitalCode = qi.behospital_code
  12446. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12447. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12448. AND t.hospitalId = qd.hospital_id
  12449. AND t.behospitalCode = qd.behospital_code
  12450. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12451. AND qd.cases_id = qc.id
  12452. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12453. AND qd.cases_id = qce.cases_id
  12454. AND qd.cases_entry_id = qce.id
  12455. </if>
  12456. where 1=1
  12457. <if test="qcResultShortPageVO.checkStatus != null">
  12458. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12459. </if>
  12460. <if test="qcResultShortPageVO.mrStatus != null">
  12461. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12462. </if>
  12463. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12464. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12465. </if>
  12466. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12467. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12468. </if>
  12469. <if test="qcResultShortPageVO.chTimeStart != null ">
  12470. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12471. </if>
  12472. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12473. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12474. </if>
  12475. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12476. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12477. </if>
  12478. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12479. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12480. </if>
  12481. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12482. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12483. </if>
  12484. <if test="qcResultShortPageVO.casesEntryId != null ">
  12485. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12486. </if>
  12487. )f1,
  12488. (SELECT
  12489. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12490. t.behDeptId,
  12491. t.behDeptName
  12492. FROM
  12493. (SELECT DISTINCT
  12494. t1.hospital_id AS hospitalId,
  12495. t1.behospital_code AS behospitalCode,
  12496. t1.bed_code AS bedCode,
  12497. t1.LEVEL AS LEVEL,
  12498. t1.grade_type AS gradeType,
  12499. t1.score_res AS scoreRes,
  12500. t1.NAME AS NAME,
  12501. t1.sex AS sex,
  12502. t1.beh_dept_id AS behDeptId,
  12503. t1.beh_dept_name AS behDeptName,
  12504. t1.doctor_id AS doctorId,
  12505. t1.doctor_name AS doctorName,
  12506. t1.beh_doctor_id AS behDoctorId,
  12507. t1.beh_doctor_name AS behDoctorName,
  12508. t1.director_doctor_id AS directorDoctorId,
  12509. t1.director_doctor_name AS directorDoctorName,
  12510. t1.birthday AS birthday,
  12511. t1.behospital_date AS behospitalDate,
  12512. t1.leave_hospital_date AS leaveHospitalDate,
  12513. t1.placefile_date AS placefileDate,
  12514. t1.gmt_create AS gradeTime,
  12515. t1.diagnose,
  12516. t1.ward_name AS wardName,
  12517. t2.age,
  12518. t1.file_code AS fileCode,
  12519. t1.checkStatus,
  12520. t1.mrStatus,
  12521. t1.chName,
  12522. t1.mrName,
  12523. t1.chTime,
  12524. t1.mrTime
  12525. FROM
  12526. (SELECT
  12527. be.*,
  12528. b.grade_type,
  12529. b.score_res,
  12530. b.gmt_create,
  12531. b.LEVEL,
  12532. ifnull(mci.status,0) AS checkStatus,
  12533. ifnull(hm_mci.status,0) AS mrStatus,
  12534. mci.check_name as chName,
  12535. hm_mci.check_name as mrName,
  12536. mci.gmt_create as chTime,
  12537. hm_mci.gmt_create as mrTime
  12538. FROM
  12539. (
  12540. SELECT DISTINCT
  12541. a.hospital_id,
  12542. a.behospital_code,
  12543. a.bed_code,
  12544. a.file_code,
  12545. a.NAME,
  12546. a.sex,
  12547. a.beh_dept_id,
  12548. a.beh_dept_name,
  12549. a.birthday,
  12550. a.behospital_date,
  12551. a.leave_hospital_date,
  12552. a.doctor_id,
  12553. a.doctor_name,
  12554. a.beh_doctor_id,
  12555. a.beh_doctor_name,
  12556. a.director_doctor_id,
  12557. a.director_doctor_name,
  12558. a.diagnose,
  12559. a.placefile_date,
  12560. a.ward_name
  12561. FROM
  12562. med_behospital_info a,
  12563. med_qcresult_detail k,
  12564. med_qcresult_cases c,
  12565. qc_cases_entry d
  12566. WHERE
  12567. a.is_deleted = 'N'
  12568. AND c.is_deleted = 'N'
  12569. AND d.is_deleted = 'N'
  12570. AND a.hospital_id = c.hospital_id
  12571. AND a.behospital_code = c.behospital_code
  12572. AND c.cases_id = d.cases_id
  12573. AND a.hospital_id = k.hospital_id
  12574. AND a.behospital_code = k.behospital_code
  12575. AND c.cases_id = k.cases_id
  12576. AND k.cases_id = d.cases_id
  12577. AND k.cases_entry_id = d.id
  12578. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12579. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12580. <!-- AND c.`level`='不合格'-->
  12581. <!-- </if>-->
  12582. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12583. <!-- AND c.`level`='合格'-->
  12584. <!-- </if>-->
  12585. <!-- </if>-->
  12586. AND a.qc_type_id != 0
  12587. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12588. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12589. </if>
  12590. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12591. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12592. </if>
  12593. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12594. <if test="qcResultShortPageVO.startDate != null ">
  12595. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12596. </if>
  12597. <if test="qcResultShortPageVO.endDate != null ">
  12598. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12599. </if>
  12600. </if>
  12601. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12602. <if test="qcResultShortPageVO.startDate != null ">
  12603. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12604. </if>
  12605. <if test="qcResultShortPageVO.endDate != null">
  12606. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12607. </if>
  12608. </if>
  12609. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12610. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12611. </if>
  12612. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12613. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12614. </if>
  12615. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12616. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12617. </if>
  12618. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12619. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12620. </if>
  12621. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12622. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12623. </if>
  12624. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12625. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12626. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12627. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12628. </if>
  12629. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12630. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12631. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12632. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12633. </if>
  12634. <if test="qcResultShortPageVO.casesEntryId != null ">
  12635. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12636. </if>
  12637. <if test="qcResultShortPageVO.ruleType != null">
  12638. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12639. </if>
  12640. )be
  12641. left join med_check_info mci
  12642. on mci.is_deleted = 'N'
  12643. and mci.check_type = 0
  12644. and be.hospital_id = mci.hospital_id
  12645. and be.behospital_code = mci.behospital_code
  12646. left join med_check_info hm_mci
  12647. on hm_mci.is_deleted = 'N'
  12648. and hm_mci.check_type = 1
  12649. and be.hospital_id = hm_mci.hospital_id
  12650. and be.behospital_code = hm_mci.behospital_code
  12651. left join med_qcresult_info b
  12652. on b.is_deleted = 'N'
  12653. AND be.hospital_id = b.hospital_id
  12654. AND be.behospital_code = b.behospital_code
  12655. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12656. AND b.`level` = #{qcResultPageVO.level}
  12657. </if>
  12658. ) t1
  12659. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12660. AND t1.behospital_code = t2.behospital_code
  12661. AND t2.is_deleted = 'N'
  12662. ) t
  12663. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12664. AND t.hospitalId = qi.hospital_id
  12665. AND t.behospitalCode = qi.behospital_code
  12666. where 1=1
  12667. <if test="qcResultShortPageVO.checkStatus != null">
  12668. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12669. </if>
  12670. <if test="qcResultShortPageVO.mrStatus != null">
  12671. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12672. </if>
  12673. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12674. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12675. </if>
  12676. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12677. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12678. </if>
  12679. <if test="qcResultShortPageVO.chTimeStart != null ">
  12680. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12681. </if>
  12682. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12683. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12684. </if>
  12685. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12686. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12687. </if>
  12688. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12689. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12690. </if>
  12691. GROUP BY
  12692. t.behDeptId,
  12693. t.behDeptName
  12694. )f2
  12695. WHERE
  12696. f1.behDeptId = f2.behDeptId
  12697. AND f1.behDeptName = f2.behDeptName
  12698. </select>
  12699. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  12700. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  12701. SELECT
  12702. f1.behDeptId,
  12703. f1.behDeptName,
  12704. f1.doctorName,
  12705. f1.patName,
  12706. f1.behospitalCode,
  12707. f1.hospitalId,
  12708. f1.behospitalDate,
  12709. f1.leaveHospitalDate,
  12710. f1.score,
  12711. f1.scoreBn,
  12712. f2.avgScore,
  12713. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12714. f1.msg,
  12715. f1.caseName,
  12716. </if>
  12717. f1.checkStatus,
  12718. f1.mrStatus,
  12719. f1.chName,
  12720. f1.mrName,
  12721. f1.chTime,
  12722. f1.mrTime
  12723. FROM
  12724. (SELECT
  12725. t.doctorName AS doctorName,
  12726. t.doctorId,
  12727. t.`name` AS patName,
  12728. t.behospitalCode AS behospitalCode,
  12729. t.behospitalDate AS behospitalDate,
  12730. t.leaveHospitalDate AS leaveHospitalDate,
  12731. qi.score_res AS score,
  12732. t.scoreBn,
  12733. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12734. qd.msg AS msg,
  12735. qc.NAME AS caseName,
  12736. </if>
  12737. t.behDeptId,
  12738. t.behDeptName,
  12739. t.hospitalId,
  12740. t.checkStatus,
  12741. t.mrStatus,
  12742. t.chName,
  12743. t.mrName,
  12744. t.chTime,
  12745. t.mrTime
  12746. FROM
  12747. (SELECT DISTINCT
  12748. t1.hospital_id AS hospitalId,
  12749. t1.behospital_code AS behospitalCode,
  12750. t1.bed_code AS bedCode,
  12751. t1.LEVEL AS LEVEL,
  12752. t1.grade_type AS gradeType,
  12753. t1.score_res AS scoreRes,
  12754. t1.scoreBn,
  12755. t1.NAME AS NAME,
  12756. t1.sex AS sex,
  12757. t1.beh_dept_id AS behDeptId,
  12758. t1.beh_dept_name AS behDeptName,
  12759. t1.doctor_id AS doctorId,
  12760. t1.doctor_name AS doctorName,
  12761. t1.beh_doctor_id AS behDoctorId,
  12762. t1.beh_doctor_name AS behDoctorName,
  12763. t1.director_doctor_id AS directorDoctorId,
  12764. t1.director_doctor_name AS directorDoctorName,
  12765. t1.birthday AS birthday,
  12766. t1.behospital_date AS behospitalDate,
  12767. t1.leave_hospital_date AS leaveHospitalDate,
  12768. t1.placefile_date AS placefileDate,
  12769. t1.gmt_create AS gradeTime,
  12770. t1.diagnose,
  12771. t1.ward_name AS wardName,
  12772. t2.age,
  12773. t1.file_code AS fileCode,
  12774. t1.checkStatus,
  12775. t1.mrStatus,
  12776. t1.chName,
  12777. t1.mrName,
  12778. t1.chTime,
  12779. t1.mrTime
  12780. FROM
  12781. (SELECT
  12782. be.*,
  12783. b.LEVEL,
  12784. b.grade_type,
  12785. b.score_res,
  12786. b.gmt_create,
  12787. ifnull(mci.status,0) AS checkStatus,
  12788. ifnull(hm_mci.status,0) AS mrStatus,
  12789. mci.check_name as chName,
  12790. hm_mci.check_name as mrName,
  12791. mci.gmt_create as chTime,
  12792. hm_mci.gmt_create as mrTime
  12793. FROM
  12794. (
  12795. SELECT DISTINCT
  12796. a.hospital_id,
  12797. a.behospital_code,
  12798. a.bed_code,
  12799. a.file_code,
  12800. c.score_res as scoreBn,
  12801. c.cases_id,
  12802. a.NAME,
  12803. a.sex,
  12804. a.beh_dept_id,
  12805. a.beh_dept_name,
  12806. a.birthday,
  12807. a.behospital_date,
  12808. a.leave_hospital_date,
  12809. a.doctor_id,
  12810. a.doctor_name,
  12811. a.beh_doctor_id,
  12812. a.beh_doctor_name,
  12813. a.director_doctor_id,
  12814. a.director_doctor_name,
  12815. a.diagnose,
  12816. a.placefile_date,
  12817. a.ward_name
  12818. FROM
  12819. med_behospital_info a,
  12820. sys_user_dept b,
  12821. med_qcresult_cases c
  12822. WHERE
  12823. a.is_deleted = 'N'
  12824. AND b.is_deleted = 'N'
  12825. AND c.is_deleted = 'N'
  12826. AND a.hospital_id = b.hospital_id
  12827. AND a.beh_dept_id = b.dept_id
  12828. AND a.hospital_id = c.hospital_id
  12829. AND a.behospital_code = c.behospital_code
  12830. AND a.qc_type_id != 0
  12831. AND c.cases_id = 243
  12832. <if test="qcResultShortPageVO.userId!=null">
  12833. AND b.user_id = #{qcResultShortPageVO.userId}
  12834. </if>
  12835. <if test="qcResultShortPageVO.titleName != null ">
  12836. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12837. AND c.`level`='不合格'
  12838. </if>
  12839. <if test="qcResultShortPageVO.titleName == '合格数'">
  12840. AND c.`level`='合格'
  12841. </if>
  12842. </if>
  12843. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12844. AND a.doctor_name like CONCAT('%', #{qcResultShortPageVO.doctorName}, '%')
  12845. </if>
  12846. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12847. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12848. </if>
  12849. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12850. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12851. </if>
  12852. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12853. <if test="qcResultShortPageVO.startDate != null ">
  12854. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12855. </if>
  12856. <if test="qcResultShortPageVO.endDate != null ">
  12857. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12858. </if>
  12859. </if>
  12860. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12861. <if test="qcResultShortPageVO.startDate != null ">
  12862. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12863. </if>
  12864. <if test="qcResultShortPageVO.endDate != null">
  12865. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12866. </if>
  12867. </if>
  12868. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12869. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12870. </if>
  12871. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12872. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  12873. </if>
  12874. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12875. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12876. </if>
  12877. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12878. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12879. </if>
  12880. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12881. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12882. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12883. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12884. </if>
  12885. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12886. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12887. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12888. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12889. </if>
  12890. )be
  12891. left join med_check_info mci
  12892. on mci.is_deleted = 'N'
  12893. and mci.check_type = 0
  12894. and be.hospital_id = mci.hospital_id
  12895. and be.behospital_code = mci.behospital_code
  12896. left join med_check_info hm_mci
  12897. on hm_mci.is_deleted = 'N'
  12898. and hm_mci.check_type = 1
  12899. and be.hospital_id = hm_mci.hospital_id
  12900. and be.behospital_code = hm_mci.behospital_code
  12901. left join med_qcresult_info b
  12902. on b.is_deleted = 'N'
  12903. AND be.hospital_id = b.hospital_id
  12904. AND be.behospital_code = b.behospital_code
  12905. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12906. AND b.`level` = #{qcResultPageVO.level}
  12907. </if>
  12908. left join qc_cases_entry d
  12909. on d.is_deleted = 'N'
  12910. AND be.cases_id = d.cases_id
  12911. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12912. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12913. </if>
  12914. <if test="qcResultShortPageVO.casesEntryId != null ">
  12915. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12916. </if>
  12917. <if test="qcResultShortPageVO.ruleType != null">
  12918. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12919. </if>
  12920. ) t1
  12921. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12922. AND t1.behospital_code = t2.behospital_code
  12923. AND t2.is_deleted = 'N'
  12924. ) t
  12925. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12926. AND t.hospitalId = qi.hospital_id
  12927. AND t.behospitalCode = qi.behospital_code
  12928. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12929. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12930. AND t.hospitalId = qd.hospital_id
  12931. AND t.behospitalCode = qd.behospital_code
  12932. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12933. AND qd.cases_id = qc.id
  12934. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12935. AND qd.cases_id = qce.cases_id
  12936. AND qd.cases_entry_id = qce.id
  12937. </if>
  12938. where 1=1
  12939. <if test="qcResultShortPageVO.checkStatus != null">
  12940. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12941. </if>
  12942. <if test="qcResultShortPageVO.mrStatus != null">
  12943. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12944. </if>
  12945. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12946. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12947. </if>
  12948. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12949. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12950. </if>
  12951. <if test="qcResultShortPageVO.chTimeStart != null ">
  12952. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12953. </if>
  12954. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12955. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12956. </if>
  12957. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12958. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12959. </if>
  12960. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12961. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12962. </if>
  12963. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12964. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12965. </if>
  12966. <if test="qcResultShortPageVO.casesEntryId != null ">
  12967. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12968. </if>
  12969. )f1,
  12970. (SELECT
  12971. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12972. t.doctorId,
  12973. t.doctorName
  12974. FROM
  12975. (SELECT DISTINCT
  12976. t1.hospital_id AS hospitalId,
  12977. t1.behospital_code AS behospitalCode,
  12978. t1.bed_code AS bedCode,
  12979. t1.LEVEL AS LEVEL,
  12980. t1.grade_type AS gradeType,
  12981. t1.score_res AS scoreRes,
  12982. t1.NAME AS NAME,
  12983. t1.sex AS sex,
  12984. t1.beh_dept_id AS behDeptId,
  12985. t1.beh_dept_name AS behDeptName,
  12986. t1.doctor_id AS doctorId,
  12987. t1.doctor_name AS doctorName,
  12988. t1.beh_doctor_id AS behDoctorId,
  12989. t1.beh_doctor_name AS behDoctorName,
  12990. t1.director_doctor_id AS directorDoctorId,
  12991. t1.director_doctor_name AS directorDoctorName,
  12992. t1.birthday AS birthday,
  12993. t1.behospital_date AS behospitalDate,
  12994. t1.leave_hospital_date AS leaveHospitalDate,
  12995. t1.placefile_date AS placefileDate,
  12996. t1.gmt_create AS gradeTime,
  12997. t1.diagnose,
  12998. t1.ward_name AS wardName,
  12999. t2.age,
  13000. t1.file_code AS fileCode,
  13001. t1.checkStatus,
  13002. t1.mrStatus,
  13003. t1.chName,
  13004. t1.mrName,
  13005. t1.chTime,
  13006. t1.mrTime
  13007. FROM
  13008. (SELECT
  13009. be.*,
  13010. b.grade_type,
  13011. b.score_res,
  13012. b.gmt_create,
  13013. b.LEVEL,
  13014. ifnull(mci.status,0) AS checkStatus,
  13015. ifnull(hm_mci.status,0) AS mrStatus,
  13016. mci.check_name as chName,
  13017. hm_mci.check_name as mrName,
  13018. mci.gmt_create as chTime,
  13019. hm_mci.gmt_create as mrTime
  13020. FROM
  13021. (
  13022. SELECT DISTINCT
  13023. a.hospital_id,
  13024. a.behospital_code,
  13025. a.bed_code,
  13026. a.file_code,
  13027. a.NAME,
  13028. a.sex,
  13029. a.beh_dept_id,
  13030. a.beh_dept_name,
  13031. a.birthday,
  13032. a.behospital_date,
  13033. a.leave_hospital_date,
  13034. a.doctor_id,
  13035. a.doctor_name,
  13036. a.beh_doctor_id,
  13037. a.beh_doctor_name,
  13038. a.director_doctor_id,
  13039. a.director_doctor_name,
  13040. a.diagnose,
  13041. a.placefile_date,
  13042. a.ward_name
  13043. FROM
  13044. med_behospital_info a,
  13045. med_qcresult_detail k,
  13046. sys_user_dept b,
  13047. med_qcresult_cases c,
  13048. qc_cases_entry d
  13049. WHERE
  13050. a.is_deleted = 'N'
  13051. AND b.is_deleted = 'N'
  13052. AND c.is_deleted = 'N'
  13053. AND d.is_deleted = 'N'
  13054. AND a.hospital_id = b.hospital_id
  13055. AND a.hospital_id = c.hospital_id
  13056. AND a.behospital_code = c.behospital_code
  13057. AND a.beh_dept_id = b.dept_id
  13058. AND c.cases_id = d.cases_id
  13059. AND a.hospital_id = k.hospital_id
  13060. AND a.behospital_code = k.behospital_code
  13061. AND c.cases_id = k.cases_id
  13062. AND k.cases_id = d.cases_id
  13063. AND k.cases_entry_id = d.id
  13064. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  13065. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  13066. <!-- AND c.`level`='不合格'-->
  13067. <!-- </if>-->
  13068. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  13069. <!-- AND c.`level`='合格'-->
  13070. <!-- </if>-->
  13071. <!-- </if>-->
  13072. AND a.qc_type_id != 0
  13073. <if test="qcResultShortPageVO.userId!=null">
  13074. AND b.user_id = #{qcResultShortPageVO.userId}
  13075. </if>
  13076. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13077. and a.doctor_name = #{qcResultShortPageVO.doctorName}
  13078. </if>
  13079. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13080. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13081. </if>
  13082. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13083. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13084. </if>
  13085. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13086. <if test="qcResultShortPageVO.startDate != null ">
  13087. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13088. </if>
  13089. <if test="qcResultShortPageVO.endDate != null ">
  13090. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13091. </if>
  13092. </if>
  13093. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13094. <if test="qcResultShortPageVO.startDate != null ">
  13095. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13096. </if>
  13097. <if test="qcResultShortPageVO.endDate != null">
  13098. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13099. </if>
  13100. </if>
  13101. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13102. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13103. </if>
  13104. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13105. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  13106. </if>
  13107. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13108. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13109. </if>
  13110. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13111. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13112. </if>
  13113. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13114. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13115. </if>
  13116. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13117. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13118. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13119. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13120. </if>
  13121. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13122. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13123. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13124. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13125. </if>
  13126. <if test="qcResultShortPageVO.casesEntryId != null ">
  13127. AND d.id = #{qcResultShortPageVO.casesEntryId}
  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_info b
  13144. on b.is_deleted = 'N'
  13145. AND be.hospital_id = b.hospital_id
  13146. AND be.behospital_code = b.behospital_code
  13147. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13148. AND b.`level` = #{qcResultPageVO.level}
  13149. </if>
  13150. ) t1
  13151. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13152. AND t1.behospital_code = t2.behospital_code
  13153. AND t2.is_deleted = 'N'
  13154. ) t
  13155. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13156. AND t.hospitalId = qi.hospital_id
  13157. AND t.behospitalCode = qi.behospital_code
  13158. where 1=1
  13159. <if test="qcResultShortPageVO.checkStatus != null">
  13160. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13161. </if>
  13162. <if test="qcResultShortPageVO.mrStatus != null">
  13163. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13164. </if>
  13165. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13166. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13167. </if>
  13168. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13169. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13170. </if>
  13171. <if test="qcResultShortPageVO.chTimeStart != null ">
  13172. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13173. </if>
  13174. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13175. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13176. </if>
  13177. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13178. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13179. </if>
  13180. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13181. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13182. </if>
  13183. GROUP BY
  13184. t.behDeptId,
  13185. t.behDeptName,
  13186. t.doctorId,
  13187. t.doctorName
  13188. )f2
  13189. WHERE
  13190. f1.doctorId = f2.doctorId
  13191. AND f1.doctorName = f2.doctorName
  13192. </select>
  13193. <!-- 未整改病历缺陷评分详情页导出-->
  13194. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  13195. SELECT
  13196. f1.behDeptId,
  13197. f1.behDeptName,
  13198. f1.doctorName,
  13199. f1.patName,
  13200. f1.behospitalCode,
  13201. f1.hospitalId,
  13202. f1.behospitalDate,
  13203. f1.leaveHospitalDate,
  13204. f1.score,
  13205. f1.scoreBn,
  13206. f2.avgScore,
  13207. f1.msg,
  13208. f1.caseName,
  13209. f1.checkStatus,
  13210. f1.mrStatus,
  13211. f1.chName,
  13212. f1.mrName,
  13213. f1.chTime,
  13214. f1.mrTime
  13215. FROM
  13216. (SELECT
  13217. t.doctorName,
  13218. t.`name` AS patName,
  13219. t.behospitalCode AS behospitalCode,
  13220. t.behospitalDate AS behospitalDate,
  13221. t.leaveHospitalDate AS leaveHospitalDate,
  13222. qi.score_res AS score,
  13223. t.scoreBn,
  13224. qd.msg AS msg,
  13225. qc.NAME AS caseName,
  13226. t.behDeptId,
  13227. t.behDeptName,
  13228. t.hospitalId,
  13229. t.checkStatus,
  13230. t.mrStatus,
  13231. t.chName,
  13232. t.mrName,
  13233. t.chTime,
  13234. t.mrTime
  13235. FROM
  13236. (SELECT DISTINCT
  13237. t1.hospital_id AS hospitalId,
  13238. t1.behospital_code AS behospitalCode,
  13239. t1.bed_code AS bedCode,
  13240. t1.LEVEL AS LEVEL,
  13241. t1.grade_type AS gradeType,
  13242. t1.score_res AS scoreRes,
  13243. t1.scoreBn,
  13244. t1.NAME AS NAME,
  13245. t1.sex AS sex,
  13246. t1.beh_dept_id AS behDeptId,
  13247. t1.beh_dept_name AS behDeptName,
  13248. t1.doctor_id AS doctorId,
  13249. t1.doctor_name AS doctorName,
  13250. t1.beh_doctor_id AS behDoctorId,
  13251. t1.beh_doctor_name AS behDoctorName,
  13252. t1.director_doctor_id AS directorDoctorId,
  13253. t1.director_doctor_name AS directorDoctorName,
  13254. t1.birthday AS birthday,
  13255. t1.behospital_date AS behospitalDate,
  13256. t1.leave_hospital_date AS leaveHospitalDate,
  13257. t1.placefile_date AS placefileDate,
  13258. t1.gmt_create AS gradeTime,
  13259. t1.diagnose,
  13260. t1.ward_name AS wardName,
  13261. t2.age,
  13262. t1.file_code AS fileCode,
  13263. t1.checkStatus,
  13264. t1.mrStatus,
  13265. t1.chName,
  13266. t1.mrName,
  13267. t1.chTime,
  13268. t1.mrTime
  13269. FROM
  13270. (SELECT
  13271. be.*,
  13272. ifnull(mci.status,0) AS checkStatus,
  13273. ifnull(hm_mci.status,0) AS mrStatus,
  13274. mci.check_name as chName,
  13275. e.score_res as scoreBn,
  13276. hm_mci.check_name as mrName,
  13277. mci.gmt_create as chTime,
  13278. hm_mci.gmt_create as mrTime
  13279. FROM
  13280. (
  13281. SELECT DISTINCT
  13282. a.hospital_id,
  13283. a.behospital_code,
  13284. a.bed_code,
  13285. a.file_code,
  13286. b.LEVEL,
  13287. b.grade_type,
  13288. b.score_res,
  13289. a.NAME,
  13290. a.sex,
  13291. a.beh_dept_id,
  13292. a.beh_dept_name,
  13293. a.birthday,
  13294. a.behospital_date,
  13295. a.leave_hospital_date,
  13296. a.doctor_id,
  13297. a.doctor_name,
  13298. a.beh_doctor_id,
  13299. a.beh_doctor_name,
  13300. a.director_doctor_id,
  13301. a.director_doctor_name,
  13302. a.diagnose,
  13303. a.placefile_date,
  13304. a.ward_name,
  13305. b.gmt_create
  13306. FROM
  13307. med_behospital_info a,
  13308. med_qcresult_info b,
  13309. med_qcresult_detail c,
  13310. qc_cases_entry d
  13311. WHERE
  13312. a.is_deleted = 'N'
  13313. AND b.is_deleted = 'N'
  13314. AND c.is_deleted = 'N'
  13315. AND d.is_deleted = 'N'
  13316. AND a.hospital_id = b.hospital_id
  13317. AND a.hospital_id = c.hospital_id
  13318. AND a.behospital_code = b.behospital_code
  13319. AND a.behospital_code = c.behospital_code
  13320. AND c.cases_id = d.cases_id
  13321. AND c.cases_entry_id = d.id
  13322. AND a.qc_type_id != 0
  13323. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13324. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13325. </if>
  13326. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13327. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13328. </if>
  13329. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13330. <if test="qcResultShortPageVO.startDate != null ">
  13331. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13332. </if>
  13333. <if test="qcResultShortPageVO.endDate != null ">
  13334. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13335. </if>
  13336. </if>
  13337. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13338. <if test="qcResultShortPageVO.startDate != null ">
  13339. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13340. </if>
  13341. <if test="qcResultShortPageVO.endDate != null">
  13342. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13343. </if>
  13344. </if>
  13345. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13346. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13347. </if>
  13348. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13349. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13350. </if>
  13351. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13352. AND b.`level` = #{qcResultShortPageVO.level}
  13353. </if>
  13354. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13355. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13356. </if>
  13357. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13358. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13359. </if>
  13360. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13361. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13362. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13363. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13364. </if>
  13365. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13366. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13367. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13368. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13369. </if>
  13370. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13371. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13372. </if>
  13373. <if test="qcResultShortPageVO.casesEntryId != null ">
  13374. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13375. </if>
  13376. <if test="qcResultShortPageVO.isReject != null">
  13377. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13378. </if>
  13379. <if test="qcResultShortPageVO.ruleType != null">
  13380. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13381. </if>
  13382. )be
  13383. left join med_check_info mci
  13384. on mci.is_deleted = 'N'
  13385. and mci.check_type = 0
  13386. and be.hospital_id = mci.hospital_id
  13387. and be.behospital_code = mci.behospital_code
  13388. left join med_check_info hm_mci
  13389. on hm_mci.is_deleted = 'N'
  13390. and hm_mci.check_type = 1
  13391. and be.hospital_id = hm_mci.hospital_id
  13392. and be.behospital_code = hm_mci.behospital_code
  13393. LEFT JOIN med_qcresult_cases e
  13394. on be.behospital_code = e.behospital_code
  13395. and be.hospital_id = e.hospital_id
  13396. AND e.is_deleted = 'N'
  13397. and e.cases_id = 243
  13398. ) t1
  13399. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13400. AND t1.behospital_code = t2.behospital_code
  13401. AND t2.is_deleted = 'N'
  13402. ) t
  13403. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13404. AND t.hospitalId = qi.hospital_id
  13405. AND t.behospitalCode = qi.behospital_code
  13406. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13407. AND t.hospitalId = qd.hospital_id
  13408. AND t.behospitalCode = qd.behospital_code
  13409. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13410. AND qd.cases_id = qc.id
  13411. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13412. AND qd.cases_id = qce.cases_id
  13413. AND qd.cases_entry_id = qce.id
  13414. where 1=1
  13415. <if test="qcResultShortPageVO.checkStatus != null">
  13416. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13417. </if>
  13418. <if test="qcResultShortPageVO.mrStatus != null">
  13419. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13420. </if>
  13421. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13422. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13423. </if>
  13424. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13425. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13426. </if>
  13427. <if test="qcResultShortPageVO.chTimeStart != null ">
  13428. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13429. </if>
  13430. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13431. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13432. </if>
  13433. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13434. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13435. </if>
  13436. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13437. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13438. </if>
  13439. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13440. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13441. </if>
  13442. <if test="qcResultShortPageVO.casesEntryId != null ">
  13443. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13444. </if>
  13445. )f1,
  13446. (SELECT
  13447. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13448. t.behDeptId,
  13449. t.behDeptName
  13450. FROM
  13451. (SELECT DISTINCT
  13452. t1.hospital_id AS hospitalId,
  13453. t1.behospital_code AS behospitalCode,
  13454. t1.bed_code AS bedCode,
  13455. t1.LEVEL AS LEVEL,
  13456. t1.grade_type AS gradeType,
  13457. t1.score_res AS scoreRes,
  13458. t1.NAME AS NAME,
  13459. t1.sex AS sex,
  13460. t1.beh_dept_id AS behDeptId,
  13461. t1.beh_dept_name AS behDeptName,
  13462. t1.doctor_id AS doctorId,
  13463. t1.doctor_name AS doctorName,
  13464. t1.beh_doctor_id AS behDoctorId,
  13465. t1.beh_doctor_name AS behDoctorName,
  13466. t1.director_doctor_id AS directorDoctorId,
  13467. t1.director_doctor_name AS directorDoctorName,
  13468. t1.birthday AS birthday,
  13469. t1.behospital_date AS behospitalDate,
  13470. t1.leave_hospital_date AS leaveHospitalDate,
  13471. t1.placefile_date AS placefileDate,
  13472. t1.gmt_create AS gradeTime,
  13473. t1.diagnose,
  13474. t1.ward_name AS wardName,
  13475. t2.age,
  13476. t1.file_code AS fileCode,
  13477. t1.checkStatus,
  13478. t1.mrStatus,
  13479. t1.chName,
  13480. t1.mrName,
  13481. t1.chTime,
  13482. t1.mrTime
  13483. FROM
  13484. (SELECT
  13485. be.*,
  13486. ifnull(mci.status,0) AS checkStatus,
  13487. ifnull(hm_mci.status,0) AS mrStatus,
  13488. mci.check_name as chName,
  13489. hm_mci.check_name as mrName,
  13490. mci.gmt_create as chTime,
  13491. hm_mci.gmt_create as mrTime
  13492. FROM
  13493. (
  13494. SELECT DISTINCT
  13495. a.hospital_id,
  13496. a.behospital_code,
  13497. a.bed_code,
  13498. a.file_code,
  13499. b.LEVEL,
  13500. b.grade_type,
  13501. b.score_res,
  13502. a.NAME,
  13503. a.sex,
  13504. a.beh_dept_id,
  13505. a.beh_dept_name,
  13506. a.birthday,
  13507. a.behospital_date,
  13508. a.leave_hospital_date,
  13509. a.doctor_id,
  13510. a.doctor_name,
  13511. a.beh_doctor_id,
  13512. a.beh_doctor_name,
  13513. a.director_doctor_id,
  13514. a.director_doctor_name,
  13515. a.diagnose,
  13516. a.placefile_date,
  13517. a.ward_name,
  13518. b.gmt_create
  13519. FROM
  13520. med_behospital_info a,
  13521. med_qcresult_info b,
  13522. med_qcresult_detail c,
  13523. qc_cases_entry d
  13524. WHERE
  13525. a.is_deleted = 'N'
  13526. AND b.is_deleted = 'N'
  13527. AND c.is_deleted = 'N'
  13528. AND d.is_deleted = 'N'
  13529. AND a.hospital_id = b.hospital_id
  13530. AND a.hospital_id = c.hospital_id
  13531. AND a.behospital_code = b.behospital_code
  13532. AND a.behospital_code = c.behospital_code
  13533. AND c.cases_id = d.cases_id
  13534. AND c.cases_entry_id = d.id
  13535. AND a.qc_type_id != 0
  13536. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13537. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13538. </if>
  13539. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13540. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13541. </if>
  13542. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13543. <if test="qcResultShortPageVO.startDate != null ">
  13544. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13545. </if>
  13546. <if test="qcResultShortPageVO.endDate != null ">
  13547. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13548. </if>
  13549. </if>
  13550. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13551. <if test="qcResultShortPageVO.startDate != null ">
  13552. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13553. </if>
  13554. <if test="qcResultShortPageVO.endDate != null">
  13555. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13556. </if>
  13557. </if>
  13558. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13559. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13560. </if>
  13561. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13562. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13563. </if>
  13564. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13565. AND b.`level` = #{qcResultShortPageVO.level}
  13566. </if>
  13567. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13568. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13569. </if>
  13570. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13571. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13572. </if>
  13573. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13574. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13575. </if>
  13576. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13577. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13578. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13579. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13580. </if>
  13581. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13582. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13583. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13584. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13585. </if>
  13586. <if test="qcResultShortPageVO.casesEntryId != null ">
  13587. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13588. </if>
  13589. <if test="qcResultShortPageVO.isReject != null">
  13590. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13591. </if>
  13592. <if test="qcResultShortPageVO.ruleType != null">
  13593. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13594. </if>
  13595. )be
  13596. left join med_check_info mci
  13597. on mci.is_deleted = 'N'
  13598. and mci.check_type = 0
  13599. and be.hospital_id = mci.hospital_id
  13600. and be.behospital_code = mci.behospital_code
  13601. left join med_check_info hm_mci
  13602. on hm_mci.is_deleted = 'N'
  13603. and hm_mci.check_type = 1
  13604. and be.hospital_id = hm_mci.hospital_id
  13605. and be.behospital_code = hm_mci.behospital_code
  13606. ) t1
  13607. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13608. AND t1.behospital_code = t2.behospital_code
  13609. AND t2.is_deleted = 'N'
  13610. ) t
  13611. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13612. AND t.hospitalId = qi.hospital_id
  13613. AND t.behospitalCode = qi.behospital_code
  13614. where 1=1
  13615. <if test="qcResultShortPageVO.checkStatus != null">
  13616. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13617. </if>
  13618. <if test="qcResultShortPageVO.mrStatus != null">
  13619. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13620. </if>
  13621. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13622. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13623. </if>
  13624. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13625. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13626. </if>
  13627. <if test="qcResultShortPageVO.chTimeStart != null ">
  13628. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13629. </if>
  13630. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13631. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13632. </if>
  13633. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13634. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13635. </if>
  13636. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13637. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13638. </if>
  13639. GROUP BY
  13640. t.behDeptId,
  13641. t.behDeptName
  13642. )f2
  13643. WHERE
  13644. f1.behDeptId = f2.behDeptId
  13645. AND f1.behDeptName = f2.behDeptName
  13646. </select>
  13647. <!-- 未整改病历缺陷评分详情页导出-科室-->
  13648. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  13649. SELECT
  13650. f1.behDeptId,
  13651. f1.behDeptName,
  13652. f1.doctorName,
  13653. f1.patName,
  13654. f1.behospitalCode,
  13655. f1.hospitalId,
  13656. f1.behospitalDate,
  13657. f1.leaveHospitalDate,
  13658. f1.score,
  13659. f1.scoreBn,
  13660. f2.avgScore,
  13661. f1.msg,
  13662. f1.caseName,
  13663. f1.checkStatus,
  13664. f1.mrStatus,
  13665. f1.chName,
  13666. f1.mrName,
  13667. f1.chTime,
  13668. f1.mrTime
  13669. FROM
  13670. (SELECT
  13671. t.doctorName,
  13672. t.doctorId,
  13673. t.`name` AS patName,
  13674. t.behospitalCode AS behospitalCode,
  13675. t.behospitalDate AS behospitalDate,
  13676. t.leaveHospitalDate AS leaveHospitalDate,
  13677. qi.score_res AS score,
  13678. t.scoreBn,
  13679. qd.msg AS msg,
  13680. qc.NAME AS caseName,
  13681. t.behDeptId,
  13682. t.behDeptName,
  13683. t.hospitalId,
  13684. t.checkStatus,
  13685. t.mrStatus,
  13686. t.chName,
  13687. t.mrName,
  13688. t.chTime,
  13689. t.mrTime
  13690. FROM
  13691. (SELECT DISTINCT
  13692. t1.hospital_id AS hospitalId,
  13693. t1.behospital_code AS behospitalCode,
  13694. t1.bed_code AS bedCode,
  13695. t1.LEVEL AS LEVEL,
  13696. t1.grade_type AS gradeType,
  13697. t1.score_res AS scoreRes,
  13698. t1.scoreBn,
  13699. t1.NAME AS NAME,
  13700. t1.sex AS sex,
  13701. t1.beh_dept_id AS behDeptId,
  13702. t1.beh_dept_name AS behDeptName,
  13703. t1.doctor_id AS doctorId,
  13704. t1.doctor_name AS doctorName,
  13705. t1.beh_doctor_id AS behDoctorId,
  13706. t1.beh_doctor_name AS behDoctorName,
  13707. t1.director_doctor_id AS directorDoctorId,
  13708. t1.director_doctor_name AS directorDoctorName,
  13709. t1.birthday AS birthday,
  13710. t1.behospital_date AS behospitalDate,
  13711. t1.leave_hospital_date AS leaveHospitalDate,
  13712. t1.placefile_date AS placefileDate,
  13713. t1.gmt_create AS gradeTime,
  13714. t1.diagnose,
  13715. t1.ward_name AS wardName,
  13716. t2.age,
  13717. t1.file_code AS fileCode,
  13718. t1.checkStatus,
  13719. t1.mrStatus,
  13720. t1.chName,
  13721. t1.mrName,
  13722. t1.chTime,
  13723. t1.mrTime
  13724. FROM
  13725. (SELECT
  13726. be.*,
  13727. ifnull(mci.status,0) AS checkStatus,
  13728. ifnull(hm_mci.status,0) AS mrStatus,
  13729. mci.check_name as chName,
  13730. e.score_res as scoreBn,
  13731. hm_mci.check_name as mrName,
  13732. mci.gmt_create as chTime,
  13733. hm_mci.gmt_create as mrTime
  13734. FROM
  13735. (
  13736. SELECT DISTINCT
  13737. a.hospital_id,
  13738. a.behospital_code,
  13739. a.bed_code,
  13740. a.file_code,
  13741. b.LEVEL,
  13742. b.grade_type,
  13743. b.score_res,
  13744. a.NAME,
  13745. a.sex,
  13746. a.beh_dept_id,
  13747. a.beh_dept_name,
  13748. a.birthday,
  13749. a.behospital_date,
  13750. a.leave_hospital_date,
  13751. a.doctor_id,
  13752. a.doctor_name,
  13753. a.beh_doctor_id,
  13754. a.beh_doctor_name,
  13755. a.director_doctor_id,
  13756. a.director_doctor_name,
  13757. a.diagnose,
  13758. a.placefile_date,
  13759. a.ward_name,
  13760. b.gmt_create
  13761. FROM
  13762. med_behospital_info a,
  13763. med_qcresult_info b,
  13764. med_qcresult_detail c,
  13765. qc_cases_entry d,
  13766. sys_user_dept f
  13767. WHERE
  13768. a.is_deleted = 'N'
  13769. AND b.is_deleted = 'N'
  13770. AND c.is_deleted = 'N'
  13771. AND d.is_deleted = 'N'
  13772. AND f.is_deleted = 'N'
  13773. AND a.hospital_id = b.hospital_id
  13774. AND a.hospital_id = c.hospital_id
  13775. AND a.hospital_id = f.hospital_id
  13776. AND a.behospital_code = b.behospital_code
  13777. AND a.behospital_code = c.behospital_code
  13778. AND c.cases_id = d.cases_id
  13779. AND c.cases_entry_id = d.id
  13780. AND a.beh_dept_id = f.dept_id
  13781. AND a.qc_type_id != 0
  13782. <if test="qcResultShortPageVO.userId!=null">
  13783. AND f.user_id = #{qcResultShortPageVO.userId}
  13784. </if>
  13785. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13786. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13787. </if>
  13788. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13789. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13790. </if>
  13791. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13792. <if test="qcResultShortPageVO.startDate != null ">
  13793. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13794. </if>
  13795. <if test="qcResultShortPageVO.endDate != null ">
  13796. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13797. </if>
  13798. </if>
  13799. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13800. <if test="qcResultShortPageVO.startDate != null ">
  13801. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13802. </if>
  13803. <if test="qcResultShortPageVO.endDate != null">
  13804. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13805. </if>
  13806. </if>
  13807. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13808. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13809. </if>
  13810. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13811. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13812. </if>
  13813. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13814. AND b.`level` = #{qcResultShortPageVO.level}
  13815. </if>
  13816. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13817. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13818. </if>
  13819. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13820. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13821. </if>
  13822. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13823. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13824. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13825. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13826. </if>
  13827. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13828. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13829. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13830. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13831. </if>
  13832. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13833. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13834. </if>
  13835. <if test="qcResultShortPageVO.casesEntryId != null ">
  13836. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13837. </if>
  13838. <if test="qcResultShortPageVO.isReject != null">
  13839. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13840. </if>
  13841. <if test="qcResultShortPageVO.ruleType != null">
  13842. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13843. </if>
  13844. )be
  13845. left join med_check_info mci
  13846. on mci.is_deleted = 'N'
  13847. and mci.check_type = 0
  13848. and be.hospital_id = mci.hospital_id
  13849. and be.behospital_code = mci.behospital_code
  13850. left join med_check_info hm_mci
  13851. on hm_mci.is_deleted = 'N'
  13852. and hm_mci.check_type = 1
  13853. and be.hospital_id = hm_mci.hospital_id
  13854. and be.behospital_code = hm_mci.behospital_code
  13855. LEFT JOIN med_qcresult_cases e
  13856. on be.behospital_code = e.behospital_code
  13857. and be.hospital_id = e.hospital_id
  13858. AND e.is_deleted = 'N'
  13859. and e.cases_id = 243
  13860. ) t1
  13861. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13862. AND t1.behospital_code = t2.behospital_code
  13863. AND t2.is_deleted = 'N'
  13864. ) t
  13865. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13866. AND t.hospitalId = qi.hospital_id
  13867. AND t.behospitalCode = qi.behospital_code
  13868. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13869. AND t.hospitalId = qd.hospital_id
  13870. AND t.behospitalCode = qd.behospital_code
  13871. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13872. AND qd.cases_id = qc.id
  13873. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13874. AND qd.cases_id = qce.cases_id
  13875. AND qd.cases_entry_id = qce.id
  13876. where 1=1
  13877. <if test="qcResultShortPageVO.checkStatus != null">
  13878. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13879. </if>
  13880. <if test="qcResultShortPageVO.mrStatus != null">
  13881. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13882. </if>
  13883. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13884. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13885. </if>
  13886. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13887. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13888. </if>
  13889. <if test="qcResultShortPageVO.chTimeStart != null ">
  13890. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13891. </if>
  13892. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13893. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13894. </if>
  13895. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13896. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13897. </if>
  13898. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13899. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13900. </if>
  13901. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13902. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13903. </if>
  13904. <if test="qcResultShortPageVO.casesEntryId != null ">
  13905. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13906. </if>
  13907. )f1,
  13908. (SELECT
  13909. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13910. t.behDeptId,
  13911. t.behDeptName,
  13912. t.doctorId,
  13913. t.doctorName
  13914. FROM
  13915. (SELECT DISTINCT
  13916. t1.hospital_id AS hospitalId,
  13917. t1.behospital_code AS behospitalCode,
  13918. t1.bed_code AS bedCode,
  13919. t1.LEVEL AS LEVEL,
  13920. t1.grade_type AS gradeType,
  13921. t1.score_res AS scoreRes,
  13922. t1.NAME AS NAME,
  13923. t1.sex AS sex,
  13924. t1.beh_dept_id AS behDeptId,
  13925. t1.beh_dept_name AS behDeptName,
  13926. t1.doctor_id AS doctorId,
  13927. t1.doctor_name AS doctorName,
  13928. t1.beh_doctor_id AS behDoctorId,
  13929. t1.beh_doctor_name AS behDoctorName,
  13930. t1.director_doctor_id AS directorDoctorId,
  13931. t1.director_doctor_name AS directorDoctorName,
  13932. t1.birthday AS birthday,
  13933. t1.behospital_date AS behospitalDate,
  13934. t1.leave_hospital_date AS leaveHospitalDate,
  13935. t1.placefile_date AS placefileDate,
  13936. t1.gmt_create AS gradeTime,
  13937. t1.diagnose,
  13938. t1.ward_name AS wardName,
  13939. t2.age,
  13940. t1.file_code AS fileCode,
  13941. t1.checkStatus,
  13942. t1.mrStatus,
  13943. t1.chName,
  13944. t1.mrName,
  13945. t1.chTime,
  13946. t1.mrTime
  13947. FROM
  13948. (SELECT
  13949. be.*,
  13950. ifnull(mci.status,0) AS checkStatus,
  13951. ifnull(hm_mci.status,0) AS mrStatus,
  13952. mci.check_name as chName,
  13953. hm_mci.check_name as mrName,
  13954. mci.gmt_create as chTime,
  13955. hm_mci.gmt_create as mrTime
  13956. FROM
  13957. (
  13958. SELECT DISTINCT
  13959. a.hospital_id,
  13960. a.behospital_code,
  13961. a.bed_code,
  13962. a.file_code,
  13963. b.LEVEL,
  13964. b.grade_type,
  13965. b.score_res,
  13966. a.NAME,
  13967. a.sex,
  13968. a.beh_dept_id,
  13969. a.beh_dept_name,
  13970. a.birthday,
  13971. a.behospital_date,
  13972. a.leave_hospital_date,
  13973. a.doctor_id,
  13974. a.doctor_name,
  13975. a.beh_doctor_id,
  13976. a.beh_doctor_name,
  13977. a.director_doctor_id,
  13978. a.director_doctor_name,
  13979. a.diagnose,
  13980. a.placefile_date,
  13981. a.ward_name,
  13982. b.gmt_create
  13983. FROM
  13984. med_behospital_info a,
  13985. med_qcresult_info b,
  13986. med_qcresult_detail c,
  13987. qc_cases_entry d,
  13988. sys_user_dept f
  13989. WHERE
  13990. a.is_deleted = 'N'
  13991. AND b.is_deleted = 'N'
  13992. AND c.is_deleted = 'N'
  13993. AND d.is_deleted = 'N'
  13994. AND f.is_deleted = 'N'
  13995. AND a.hospital_id = b.hospital_id
  13996. AND a.hospital_id = c.hospital_id
  13997. AND a.hospital_id = f.hospital_id
  13998. AND a.behospital_code = b.behospital_code
  13999. AND a.behospital_code = c.behospital_code
  14000. AND c.cases_id = d.cases_id
  14001. AND c.cases_entry_id = d.id
  14002. AND a.beh_dept_id = f.dept_id
  14003. AND a.qc_type_id != 0
  14004. <if test="qcResultShortPageVO.userId!=null">
  14005. AND f.user_id = #{qcResultShortPageVO.userId}
  14006. </if>
  14007. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14008. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14009. </if>
  14010. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14011. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14012. </if>
  14013. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14014. <if test="qcResultShortPageVO.startDate != null ">
  14015. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14016. </if>
  14017. <if test="qcResultShortPageVO.endDate != null ">
  14018. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14019. </if>
  14020. </if>
  14021. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14022. <if test="qcResultShortPageVO.startDate != null ">
  14023. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14024. </if>
  14025. <if test="qcResultShortPageVO.endDate != null">
  14026. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14027. </if>
  14028. </if>
  14029. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14030. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14031. </if>
  14032. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14033. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14034. </if>
  14035. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14036. AND b.`level` = #{qcResultShortPageVO.level}
  14037. </if>
  14038. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14039. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14040. </if>
  14041. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14042. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14043. </if>
  14044. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14045. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14046. </if>
  14047. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14048. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14049. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14050. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14051. </if>
  14052. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14053. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14054. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14055. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14056. </if>
  14057. <if test="qcResultShortPageVO.casesEntryId != null ">
  14058. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14059. </if>
  14060. <if test="qcResultShortPageVO.isReject != null">
  14061. AND c.is_reject = #{qcResultShortPageVO.isReject}
  14062. </if>
  14063. <if test="qcResultShortPageVO.ruleType != null">
  14064. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14065. </if>
  14066. )be
  14067. left join med_check_info mci
  14068. on mci.is_deleted = 'N'
  14069. and mci.check_type = 0
  14070. and be.hospital_id = mci.hospital_id
  14071. and be.behospital_code = mci.behospital_code
  14072. left join med_check_info hm_mci
  14073. on hm_mci.is_deleted = 'N'
  14074. and hm_mci.check_type = 1
  14075. and be.hospital_id = hm_mci.hospital_id
  14076. and be.behospital_code = hm_mci.behospital_code
  14077. ) t1
  14078. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14079. AND t1.behospital_code = t2.behospital_code
  14080. AND t2.is_deleted = 'N'
  14081. ) t
  14082. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14083. AND t.hospitalId = qi.hospital_id
  14084. AND t.behospitalCode = qi.behospital_code
  14085. where 1=1
  14086. <if test="qcResultShortPageVO.checkStatus != null">
  14087. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14088. </if>
  14089. <if test="qcResultShortPageVO.mrStatus != null">
  14090. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14091. </if>
  14092. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14093. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14094. </if>
  14095. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14096. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14097. </if>
  14098. <if test="qcResultShortPageVO.chTimeStart != null ">
  14099. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14100. </if>
  14101. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14102. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14103. </if>
  14104. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14105. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14106. </if>
  14107. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14108. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14109. </if>
  14110. GROUP BY
  14111. t.doctorId,
  14112. t.doctorName
  14113. )f2
  14114. WHERE
  14115. f1.doctorId = f2.doctorId
  14116. AND f1.doctorName = f2.doctorName
  14117. </select>
  14118. <!-- 31天再入院详情页-->
  14119. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14120. SELECT
  14121. t.fileCode,
  14122. t.diagnose,
  14123. t.diagnoseName,
  14124. t.NAME,
  14125. t.sex,
  14126. t.hospitalId,
  14127. t.behDeptId,
  14128. t.behDeptName,
  14129. t.behospitalCode,
  14130. t.behospitalDate,
  14131. t.lastDiagnose,
  14132. t.lastDiagnoseName,
  14133. t.leaveHospitalDate,
  14134. t.lastBehDeptId,
  14135. t.lastBehDeptName,
  14136. t.lastBehospitalCode,
  14137. t.lastBehospitalDate,
  14138. t.lastLeaveHospitalDate,
  14139. t.diffDays,
  14140. mqi.score_res AS scoreRes,
  14141. mqi.LEVEL AS LEVEL,
  14142. mqi_last.score_res AS lastScoreRes,
  14143. mqi_last.LEVEL AS lastLevel,
  14144. mhp.total_fee AS totleFee,
  14145. mhp.behospital_day_num AS behospitalDayNum,
  14146. mhp.again_behospital_plan AS againBehospitalPlan,
  14147. IF(mhp.age is null, null,CONCAT( ifnull(mhp.age,'') ,ifnull(mhp.age_unit,'') ))as age,
  14148. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  14149. IF(mhp_last.age is null, null,CONCAT( ifnull(mhp_last.age,'') ,ifnull(mhp_last.age_unit,'') ))as lastAge,
  14150. mhp_last.total_fee AS lastTotleFee,
  14151. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14152. FROM
  14153. (
  14154. SELECT
  14155. be.fileCode,
  14156. be.diagnose,
  14157. be.diagnoseName,
  14158. be.NAME,
  14159. be.sex,
  14160. be.hospitalId,
  14161. be.behDeptId,
  14162. be.behDeptName,
  14163. be.behospitalCode,
  14164. be.behospitalDate,
  14165. be.leaveHospitalDate,
  14166. be.lastDiagnose,
  14167. be.lastDiagnoseName,
  14168. be.lastBehDeptId,
  14169. be.lastBehDeptName,
  14170. be.lastBehospitalCode,
  14171. be.lastBehospitalDate,
  14172. be.lastLeaveHospitalDate,
  14173. be.diffDays
  14174. FROM
  14175. (
  14176. SELECT
  14177. r1.file_code AS fileCode,
  14178. r1.diagnose,
  14179. r1.diagnose_name AS diagnoseName,
  14180. r1.NAME,
  14181. r1.sex,
  14182. r1.hospital_id AS hospitalId,
  14183. r1.beh_dept_id AS behDeptId,
  14184. r1.beh_dept_name AS behDeptName,
  14185. r1.behospital_code AS behospitalCode,
  14186. r1.behospital_date AS behospitalDate,
  14187. r1.leave_hospital_date AS leaveHospitalDate,
  14188. r2.diagnose AS lastDiagnose,
  14189. r2.diagnose_name AS lastDiagnoseName,
  14190. r2.beh_dept_id AS lastBehDeptId,
  14191. r2.beh_dept_name AS lastBehDeptName,
  14192. r2.behospital_code AS lastBehospitalCode,
  14193. r2.behospital_date AS lastBehospitalDate,
  14194. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14195. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14196. FROM
  14197. (
  14198. SELECT
  14199. ( @rownum := @rownum + 1 ) AS rownum,
  14200. t1.file_code,
  14201. t1.behospital_code,
  14202. t1.diagnose,
  14203. t1.diagnose_name,
  14204. t1.NAME,
  14205. t1.sex,
  14206. t1.hospital_id,
  14207. t1.beh_dept_id,
  14208. t1.beh_dept_name,
  14209. t1.behospital_date,
  14210. t1.leave_hospital_date
  14211. FROM(
  14212. select
  14213. tt3.file_code,
  14214. tt3.behospital_code,
  14215. tt3.diagnose,
  14216. tt3.NAME,
  14217. tt3.sex,
  14218. tt3.hospital_id,
  14219. tt3.beh_dept_id,
  14220. tt3.beh_dept_name,
  14221. tt3.behospital_date,
  14222. tt3.leave_hospital_date,
  14223. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14224. FROM(
  14225. SELECT
  14226. tt2.file_code,
  14227. tt2.diagnose,
  14228. tt2.NAME,
  14229. tt2.sex,
  14230. tt2.hospital_id,
  14231. tt2.beh_dept_id,
  14232. tt2.beh_dept_name,
  14233. tt2.behospital_code,
  14234. tt2.behospital_date,
  14235. tt2.leave_hospital_date
  14236. FROM
  14237. (
  14238. SELECT
  14239. a.file_code
  14240. FROM
  14241. med_behospital_info a
  14242. WHERE
  14243. a.is_deleted = 'N'
  14244. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14245. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14246. </if>
  14247. AND a.qc_type_id != 0
  14248. AND IFNULL( a.diagnose, '' )!= ''
  14249. AND IFNULL( a.file_code, '' )!= ''
  14250. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14251. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14252. </if>
  14253. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14254. <if test="reBeHosPageVO.startDate != null ">
  14255. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14256. </if>
  14257. <if test="reBeHosPageVO.endDate != null ">
  14258. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14259. </if>
  14260. </if>
  14261. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14262. <if test="reBeHosPageVO.startDate != null ">
  14263. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14264. </if>
  14265. <if test="reBeHosPageVO.endDate != null">
  14266. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14267. </if>
  14268. </if>
  14269. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14270. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14271. </if>
  14272. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14273. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14274. </if>
  14275. GROUP BY
  14276. a.file_code
  14277. HAVING
  14278. count(*)> 1
  14279. ) tt1,
  14280. med_behospital_info tt2
  14281. WHERE
  14282. tt2.is_deleted = 'N'
  14283. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14284. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14285. </if>
  14286. AND tt2.qc_type_id != 0
  14287. AND tt1.file_code = tt2.file_code
  14288. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14289. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14290. </if>
  14291. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14292. <if test="reBeHosPageVO.startDate != null ">
  14293. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14294. </if>
  14295. <if test="reBeHosPageVO.endDate != null ">
  14296. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14297. </if>
  14298. </if>
  14299. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14300. <if test="reBeHosPageVO.startDate != null ">
  14301. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14302. </if>
  14303. <if test="reBeHosPageVO.endDate != null">
  14304. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14305. </if>
  14306. </if>
  14307. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14308. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14309. </if>
  14310. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14311. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14312. </if>
  14313. ORDER BY
  14314. tt1.file_code,
  14315. tt2.behospital_date DESC)tt3
  14316. left join med_home_page tt4 on tt4.is_deleted = 'N'
  14317. AND tt3.hospital_id = tt4.hospital_id
  14318. AND tt3.behospital_code = tt4.behospital_code
  14319. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  14320. AND tt4.hospital_id = tt5.hospital_id
  14321. AND tt4.home_page_id = tt5.home_page_id
  14322. GROUP by tt3.behospital_code
  14323. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  14324. ) t1,
  14325. ( SELECT @rownum := 0 ) r
  14326. ) r1
  14327. LEFT JOIN (
  14328. SELECT
  14329. ( @INDEX := @INDEX + 1 ) AS rownum,
  14330. t1.file_code,
  14331. t1.behospital_code,
  14332. t1.diagnose,
  14333. t1.diagnose_name,
  14334. t1.NAME,
  14335. t1.sex,
  14336. t1.hospital_id,
  14337. t1.beh_dept_id,
  14338. t1.beh_dept_name,
  14339. t1.behospital_date,
  14340. t1.leave_hospital_date
  14341. FROM(
  14342. select
  14343. tt3.file_code,
  14344. tt3.behospital_code,
  14345. tt3.diagnose,
  14346. tt3.NAME,
  14347. tt3.sex,
  14348. tt3.hospital_id,
  14349. tt3.beh_dept_id,
  14350. tt3.beh_dept_name,
  14351. tt3.behospital_date,
  14352. tt3.leave_hospital_date,
  14353. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14354. FROM(
  14355. SELECT
  14356. tt2.file_code,
  14357. tt2.diagnose,
  14358. tt2.NAME,
  14359. tt2.sex,
  14360. tt2.hospital_id,
  14361. tt2.beh_dept_id,
  14362. tt2.beh_dept_name,
  14363. tt2.behospital_code,
  14364. tt2.behospital_date,
  14365. tt2.leave_hospital_date
  14366. FROM
  14367. (
  14368. SELECT
  14369. a.file_code
  14370. FROM
  14371. med_behospital_info a
  14372. WHERE
  14373. a.is_deleted = 'N'
  14374. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14375. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14376. </if>
  14377. AND a.qc_type_id != 0
  14378. AND IFNULL( a.diagnose, '' )!= ''
  14379. AND IFNULL( a.file_code, '' )!= ''
  14380. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14381. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14382. </if>
  14383. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14384. <if test="reBeHosPageVO.startDate != null ">
  14385. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14386. </if>
  14387. <if test="reBeHosPageVO.endDate != null ">
  14388. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14389. </if>
  14390. </if>
  14391. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14392. <if test="reBeHosPageVO.startDate != null ">
  14393. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14394. </if>
  14395. <if test="reBeHosPageVO.endDate != null">
  14396. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14397. </if>
  14398. </if>
  14399. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14400. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14401. </if>
  14402. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14403. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14404. </if>
  14405. GROUP BY
  14406. a.file_code
  14407. HAVING
  14408. count(*)> 1
  14409. ) tt1,
  14410. med_behospital_info tt2
  14411. WHERE
  14412. tt2.is_deleted = 'N'
  14413. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14414. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14415. </if>
  14416. AND tt2.qc_type_id != 0
  14417. AND tt1.file_code = tt2.file_code
  14418. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14419. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14420. </if>
  14421. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14422. <if test="reBeHosPageVO.startDate != null ">
  14423. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14424. </if>
  14425. <if test="reBeHosPageVO.endDate != null ">
  14426. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14427. </if>
  14428. </if>
  14429. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14430. <if test="reBeHosPageVO.startDate != null ">
  14431. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14432. </if>
  14433. <if test="reBeHosPageVO.endDate != null">
  14434. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14435. </if>
  14436. </if>
  14437. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14438. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14439. </if>
  14440. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14441. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14442. </if>
  14443. ORDER BY
  14444. tt1.file_code,
  14445. tt2.behospital_date DESC)tt3
  14446. left join med_home_page tt4 on tt4.is_deleted = 'N'
  14447. AND tt3.hospital_id = tt4.hospital_id
  14448. AND tt3.behospital_code = tt4.behospital_code
  14449. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  14450. AND tt4.hospital_id = tt5.hospital_id
  14451. AND tt4.home_page_id = tt5.home_page_id
  14452. GROUP by tt3.behospital_code
  14453. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  14454. ) t1,
  14455. ( SELECT @INDEX := 0 ) r
  14456. ) r2 ON r1.file_code = r2.file_code
  14457. AND r1.rownum = r2.rownum - 1
  14458. ) be
  14459. WHERE
  14460. be.diffDays IS NOT NULL
  14461. AND be.diffDays BETWEEN 0
  14462. AND 31
  14463. ) t
  14464. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14465. AND t.hospitalId = mqi.hospital_id
  14466. AND t.behospitalCode = mqi.behospital_code
  14467. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14468. AND t.hospitalId = mqi_last.hospital_id
  14469. AND t.lastBehospitalCode = mqi_last.behospital_code
  14470. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14471. AND t.hospitalId = mhp.hospital_id
  14472. AND t.behospitalCode = mhp.behospital_code
  14473. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14474. AND t.hospitalId = mhp_last.hospital_id
  14475. AND t.lastBehospitalCode = mhp_last.behospital_code
  14476. </select>
  14477. <!-- 31天再入院详情页-科室-->
  14478. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14479. SELECT
  14480. t.fileCode,
  14481. t.diagnose,
  14482. t.diagnoseName,
  14483. t.NAME,
  14484. t.sex,
  14485. t.hospitalId,
  14486. t.behDeptId,
  14487. t.behDeptName,
  14488. t.doctorId,
  14489. t.doctorName,
  14490. t.behospitalCode,
  14491. t.behospitalDate,
  14492. t.leaveHospitalDate,
  14493. t.lastDiagnose,
  14494. t.lastDiagnoseName,
  14495. t.lastBehDeptId,
  14496. t.lastBehDeptName,
  14497. t.lastDoctorName,
  14498. t.lastBehospitalCode,
  14499. t.lastBehospitalDate,
  14500. t.lastLeaveHospitalDate,
  14501. t.diffDays,
  14502. mqi.score_res AS scoreRes,
  14503. mqi.LEVEL AS LEVEL,
  14504. mqi_last.score_res AS lastScoreRes,
  14505. mqi_last.LEVEL AS lastLevel,
  14506. mhp.again_behospital_plan AS againBehospitalPlan,
  14507. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  14508. mhp.total_fee AS totleFee,
  14509. mhp.behospital_day_num AS behospitalDayNum,
  14510. mhp_last.total_fee AS lastTotleFee,
  14511. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14512. FROM
  14513. (
  14514. SELECT
  14515. be.fileCode,
  14516. be.diagnose,
  14517. be.diagnoseName,
  14518. be.NAME,
  14519. be.sex,
  14520. be.hospitalId,
  14521. be.behDeptId,
  14522. be.behDeptName,
  14523. be.doctorId,
  14524. be.doctorName,
  14525. be.behospitalCode,
  14526. be.behospitalDate,
  14527. be.leaveHospitalDate,
  14528. be.lastDiagnose,
  14529. be.lastDiagnoseName,
  14530. be.lastBehDeptId,
  14531. be.lastBehDeptName,
  14532. be.lastDoctorId,
  14533. be.lastDoctorName,
  14534. be.lastBehospitalCode,
  14535. be.lastBehospitalDate,
  14536. be.lastLeaveHospitalDate,
  14537. be.diffDays
  14538. FROM
  14539. (
  14540. SELECT
  14541. r1.file_code AS fileCode,
  14542. r1.diagnose,
  14543. r1.diagnose_name AS diagnoseName,
  14544. r1.NAME,
  14545. r1.sex,
  14546. r1.hospital_id AS hospitalId,
  14547. r1.beh_dept_id AS behDeptId,
  14548. r1.beh_dept_name AS behDeptName,
  14549. r1.doctor_id as doctorId,
  14550. r1.doctor_name as doctorName,
  14551. r1.behospital_code AS behospitalCode,
  14552. r1.behospital_date AS behospitalDate,
  14553. r1.leave_hospital_date AS leaveHospitalDate,
  14554. r2.diagnose AS lastDiagnose,
  14555. r2.diagnose_name AS lastDiagnoseName,
  14556. r2.beh_dept_id AS lastBehDeptId,
  14557. r2.beh_dept_name AS lastBehDeptName,
  14558. r2.behospital_code AS lastBehospitalCode,
  14559. r2.behospital_date AS lastBehospitalDate,
  14560. r2.doctor_id as lastDoctorId,
  14561. r2.doctor_name as lastDoctorName,
  14562. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14563. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14564. FROM
  14565. (
  14566. SELECT
  14567. ( @rownum := @rownum + 1 ) AS rownum,
  14568. t1.file_code,
  14569. t1.NAME,
  14570. t1.sex,
  14571. t1.diagnose,
  14572. t1.diagnose_name,
  14573. t1.doctor_id,
  14574. t1.doctor_name,
  14575. t1.hospital_id,
  14576. t1.beh_dept_id,
  14577. t1.beh_dept_name,
  14578. t1.behospital_code,
  14579. t1.behospital_date,
  14580. t1.leave_hospital_date
  14581. FROM
  14582. (
  14583. select
  14584. tt3.file_code,
  14585. tt3.behospital_code,
  14586. tt3.diagnose,
  14587. tt3.NAME,
  14588. tt3.sex,
  14589. tt3.hospital_id,
  14590. tt3.beh_dept_id,
  14591. tt3.beh_dept_name,
  14592. tt3.doctor_id,
  14593. tt3.doctor_name,
  14594. tt3.behospital_date,
  14595. tt3.leave_hospital_date,
  14596. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14597. FROM(
  14598. SELECT
  14599. tt1.file_code,
  14600. tt2.diagnose,
  14601. tt2.doctor_id,
  14602. tt2.doctor_name,
  14603. tt2.NAME,
  14604. tt2.sex,
  14605. tt2.hospital_id,
  14606. tt2.beh_dept_id,
  14607. tt2.beh_dept_name,
  14608. tt2.behospital_code,
  14609. tt2.behospital_date,
  14610. tt2.leave_hospital_date
  14611. FROM
  14612. (
  14613. SELECT
  14614. a.file_code
  14615. FROM
  14616. med_behospital_info a,
  14617. sys_user_dept c
  14618. WHERE
  14619. a.is_deleted = 'N'
  14620. AND c.is_deleted = 'N'
  14621. AND a.hospital_id = c.hospital_id
  14622. AND a.beh_dept_id = c.dept_id
  14623. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14624. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14625. </if>
  14626. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14627. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14628. </if>
  14629. <if test="reBeHosPageVO.userId!=null">
  14630. AND c.user_id = #{reBeHosPageVO.userId}
  14631. </if>
  14632. AND a.qc_type_id != 0
  14633. AND IFNULL( a.diagnose, '' )!= ''
  14634. AND IFNULL( a.file_code, '' )!= ''
  14635. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14636. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14637. </if>
  14638. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14639. <if test="reBeHosPageVO.startDate != null ">
  14640. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14641. </if>
  14642. <if test="reBeHosPageVO.endDate != null ">
  14643. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14644. </if>
  14645. </if>
  14646. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14647. <if test="reBeHosPageVO.startDate != null ">
  14648. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14649. </if>
  14650. <if test="reBeHosPageVO.endDate != null">
  14651. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14652. </if>
  14653. </if>
  14654. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14655. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14656. </if>
  14657. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14658. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14659. </if>
  14660. GROUP BY
  14661. a.file_code
  14662. HAVING
  14663. count(*)> 1
  14664. ) tt1,
  14665. med_behospital_info tt2
  14666. WHERE
  14667. tt2.is_deleted = 'N'
  14668. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14669. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14670. </if>
  14671. AND tt2.qc_type_id != 0
  14672. AND tt1.file_code = tt2.file_code
  14673. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14674. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14675. </if>
  14676. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14677. <if test="reBeHosPageVO.startDate != null ">
  14678. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14679. </if>
  14680. <if test="reBeHosPageVO.endDate != null ">
  14681. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14682. </if>
  14683. </if>
  14684. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14685. <if test="reBeHosPageVO.startDate != null ">
  14686. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14687. </if>
  14688. <if test="reBeHosPageVO.endDate != null">
  14689. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14690. </if>
  14691. </if>
  14692. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14693. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14694. </if>
  14695. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14696. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14697. </if>
  14698. ORDER BY
  14699. tt1.file_code,
  14700. tt2.behospital_date DESC)tt3
  14701. left join med_home_page tt4 on tt4.is_deleted = 'N'
  14702. AND tt3.hospital_id = tt4.hospital_id
  14703. AND tt3.behospital_code = tt4.behospital_code
  14704. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  14705. AND tt4.hospital_id = tt5.hospital_id
  14706. AND tt4.home_page_id = tt5.home_page_id
  14707. GROUP by tt3.behospital_code
  14708. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  14709. ) t1,
  14710. ( SELECT @rownum := 0 ) r
  14711. ) r1
  14712. LEFT JOIN (
  14713. SELECT
  14714. ( @INDEX := @INDEX + 1 ) AS rownum,
  14715. t1.file_code,
  14716. t1.NAME,
  14717. t1.sex,
  14718. t1.diagnose,
  14719. t1.diagnose_name,
  14720. t1.doctor_id,
  14721. t1.doctor_name,
  14722. t1.hospital_id,
  14723. t1.beh_dept_id,
  14724. t1.beh_dept_name,
  14725. t1.behospital_code,
  14726. t1.behospital_date,
  14727. t1.leave_hospital_date
  14728. FROM
  14729. (
  14730. select
  14731. tt3.file_code,
  14732. tt3.behospital_code,
  14733. tt3.diagnose,
  14734. tt3.NAME,
  14735. tt3.sex,
  14736. tt3.hospital_id,
  14737. tt3.beh_dept_id,
  14738. tt3.beh_dept_name,
  14739. tt3.doctor_id,
  14740. tt3.doctor_name,
  14741. tt3.behospital_date,
  14742. tt3.leave_hospital_date,
  14743. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14744. FROM(
  14745. SELECT
  14746. tt1.file_code,
  14747. tt2.diagnose,
  14748. tt2.doctor_id,
  14749. tt2.doctor_name,
  14750. tt2.NAME,
  14751. tt2.sex,
  14752. tt2.hospital_id,
  14753. tt2.beh_dept_id,
  14754. tt2.beh_dept_name,
  14755. tt2.behospital_code,
  14756. tt2.behospital_date,
  14757. tt2.leave_hospital_date
  14758. FROM
  14759. (
  14760. SELECT
  14761. a.file_code
  14762. FROM
  14763. med_behospital_info a,
  14764. sys_user_dept c
  14765. WHERE
  14766. a.is_deleted = 'N'
  14767. AND c.is_deleted = 'N'
  14768. AND a.hospital_id = c.hospital_id
  14769. AND a.beh_dept_id = c.dept_id
  14770. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14771. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14772. </if>
  14773. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14774. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14775. </if>
  14776. <if test="reBeHosPageVO.userId!=null">
  14777. AND c.user_id = #{reBeHosPageVO.userId}
  14778. </if>
  14779. AND a.qc_type_id != 0
  14780. AND IFNULL( a.diagnose, '' )!= ''
  14781. AND IFNULL( a.file_code, '' )!= ''
  14782. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14783. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14784. </if>
  14785. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14786. <if test="reBeHosPageVO.startDate != null ">
  14787. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14788. </if>
  14789. <if test="reBeHosPageVO.endDate != null ">
  14790. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14791. </if>
  14792. </if>
  14793. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14794. <if test="reBeHosPageVO.startDate != null ">
  14795. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14796. </if>
  14797. <if test="reBeHosPageVO.endDate != null">
  14798. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14799. </if>
  14800. </if>
  14801. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14802. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14803. </if>
  14804. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14805. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14806. </if>
  14807. GROUP BY
  14808. a.file_code
  14809. HAVING
  14810. count(*)> 1
  14811. ) tt1,
  14812. med_behospital_info tt2
  14813. WHERE
  14814. tt2.is_deleted = 'N'
  14815. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14816. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14817. </if>
  14818. AND tt2.qc_type_id != 0
  14819. AND tt1.file_code = tt2.file_code
  14820. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14821. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14822. </if>
  14823. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14824. <if test="reBeHosPageVO.startDate != null ">
  14825. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14826. </if>
  14827. <if test="reBeHosPageVO.endDate != null ">
  14828. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14829. </if>
  14830. </if>
  14831. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14832. <if test="reBeHosPageVO.startDate != null ">
  14833. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14834. </if>
  14835. <if test="reBeHosPageVO.endDate != null">
  14836. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14837. </if>
  14838. </if>
  14839. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14840. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14841. </if>
  14842. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14843. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14844. </if>
  14845. ORDER BY
  14846. tt1.file_code,
  14847. tt2.behospital_date DESC)tt3
  14848. left join med_home_page tt4 on tt4.is_deleted = 'N'
  14849. AND tt3.hospital_id = tt4.hospital_id
  14850. AND tt3.behospital_code = tt4.behospital_code
  14851. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  14852. AND tt4.hospital_id = tt5.hospital_id
  14853. AND tt4.home_page_id = tt5.home_page_id
  14854. GROUP by tt3.behospital_code
  14855. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  14856. ) t1,
  14857. ( SELECT @INDEX := 0 ) r
  14858. ) r2 ON r1.file_code = r2.file_code
  14859. AND r1.rownum = r2.rownum - 1
  14860. ) be
  14861. WHERE
  14862. be.diffDays IS NOT NULL
  14863. AND be.diffDays BETWEEN 0
  14864. AND 31
  14865. ) t
  14866. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14867. AND t.hospitalId = mqi.hospital_id
  14868. AND t.behospitalCode = mqi.behospital_code
  14869. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14870. AND t.hospitalId = mqi_last.hospital_id
  14871. AND t.lastBehospitalCode = mqi_last.behospital_code
  14872. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14873. AND t.hospitalId = mhp.hospital_id
  14874. AND t.behospitalCode = mhp.behospital_code
  14875. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14876. AND t.hospitalId = mhp_last.hospital_id
  14877. AND t.lastBehospitalCode = mhp_last.behospital_code
  14878. </select>
  14879. <!-- 单条条目缺陷统计-->
  14880. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  14881. SELECT
  14882. a.beh_dept_id AS id,
  14883. a.beh_dept_name AS NAME,
  14884. count(*) AS num
  14885. FROM
  14886. med_behospital_info a,
  14887. med_qcresult_detail b
  14888. WHERE
  14889. a.is_deleted = 'N'
  14890. AND b.is_deleted = 'N'
  14891. AND a.hospital_id = b.hospital_id
  14892. AND a.behospital_code = b.behospital_code
  14893. AND a.qc_type_id != 0
  14894. and b.cases_entry_id=2658
  14895. <if test="isPlacefile != null and isPlacefile != ''">
  14896. and a.is_placefile = #{isPlacefile}
  14897. </if>
  14898. <if test="hospitalId != null and hospitalId != ''">
  14899. AND a.hospital_id = #{hospitalId}
  14900. </if>
  14901. <if test="isPlacefile != null and isPlacefile == 0">
  14902. <if test="startDate != null and startDate != ''">
  14903. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14904. </if>
  14905. <if test="endDate != null and endDate != ''">
  14906. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14907. </if>
  14908. </if>
  14909. <if test="isPlacefile != null and isPlacefile == 1">
  14910. <if test="startDate != null and startDate != ''">
  14911. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14912. </if>
  14913. <if test="endDate != null and endDate != ''">
  14914. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14915. </if>
  14916. </if>
  14917. GROUP BY
  14918. a.beh_dept_id,
  14919. a.beh_dept_name
  14920. </select>
  14921. <!-- 单条条目缺陷统计-->
  14922. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  14923. SELECT
  14924. a.beh_dept_id AS deptId,
  14925. a.beh_dept_name AS deptName,
  14926. a.doctor_id as doctorId,
  14927. a.doctor_name as doctorName,
  14928. count(*) AS num
  14929. FROM
  14930. med_behospital_info a,
  14931. med_qcresult_detail b,
  14932. sys_user_dept c
  14933. WHERE
  14934. a.is_deleted = 'N'
  14935. AND b.is_deleted = 'N'
  14936. AND c.is_deleted = 'N'
  14937. AND a.hospital_id = b.hospital_id
  14938. AND a.hospital_id = c.hospital_id
  14939. AND a.behospital_code = b.behospital_code
  14940. AND a.beh_dept_id = c.dept_id
  14941. AND a.qc_type_id != 0
  14942. and b.cases_entry_id=2658
  14943. <if test="isPlacefile != null and isPlacefile != ''">
  14944. and a.is_placefile = #{isPlacefile}
  14945. </if>
  14946. <if test="hospitalId != null and hospitalId != ''">
  14947. AND a.hospital_id = #{hospitalId}
  14948. </if>
  14949. <if test="userId!=null">
  14950. AND c.user_id = #{userId}
  14951. </if>
  14952. <if test="isPlacefile != null and isPlacefile == 0">
  14953. <if test="startDate != null and startDate != ''">
  14954. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14955. </if>
  14956. <if test="endDate != null and endDate != ''">
  14957. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14958. </if>
  14959. </if>
  14960. <if test="isPlacefile != null and isPlacefile == 1">
  14961. <if test="startDate != null and startDate != ''">
  14962. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14963. </if>
  14964. <if test="endDate != null and endDate != ''">
  14965. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14966. </if>
  14967. </if>
  14968. GROUP BY
  14969. a.beh_dept_id,
  14970. a.beh_dept_name,
  14971. a.doctor_id,
  14972. a.doctor_name
  14973. </select>
  14974. <!-- 病案首页改善率质控评分页(内页)-->
  14975. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  14976. SELECT
  14977. t.*
  14978. FROM
  14979. (
  14980. SELECT DISTINCT
  14981. t1.hospital_id AS hospitalId,
  14982. t1.behospital_code AS behospitalCode,
  14983. t1.bed_code AS bedCode,
  14984. t1.LEVEL AS LEVEL,
  14985. t1.grade_type AS gradeType,
  14986. t1.score_res AS scoreRes,
  14987. t1.scoreBn,
  14988. t1.NAME AS NAME,
  14989. t1.sex AS sex,
  14990. t1.beh_dept_id AS behDeptId,
  14991. t1.beh_dept_name AS behDeptName,
  14992. t1.doctor_id AS doctorId,
  14993. t1.doctor_name AS doctorName,
  14994. t1.beh_doctor_id AS behDoctorId,
  14995. t1.beh_doctor_name AS behDoctorName,
  14996. t1.director_doctor_id AS directorDoctorId,
  14997. t1.director_doctor_name AS directorDoctorName,
  14998. t1.birthday AS birthday,
  14999. t1.behospital_date AS behospitalDate,
  15000. t1.leave_hospital_date AS leaveHospitalDate,
  15001. t1.placefile_date AS placefileDate,
  15002. t1.gmt_create AS gradeTime,
  15003. t1.diagnose,
  15004. t1.ward_name AS wardName,
  15005. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15006. t1.file_code AS fileCode,
  15007. t1.checkStatus,
  15008. t1.chName,
  15009. t1.chTime
  15010. FROM
  15011. (
  15012. SELECT
  15013. be.*,
  15014. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15015. mci.check_name AS chName,
  15016. mci.gmt_create AS chTime
  15017. FROM
  15018. (
  15019. SELECT DISTINCT
  15020. a.hospital_id,
  15021. a.behospital_code,
  15022. a.bed_code,
  15023. a.file_code,
  15024. c.LEVEL,
  15025. c.grade_type,
  15026. c.score_res,
  15027. a.NAME,
  15028. a.sex,
  15029. a.beh_dept_id,
  15030. a.beh_dept_name,
  15031. a.birthday,
  15032. a.behospital_date,
  15033. a.leave_hospital_date,
  15034. a.doctor_id,
  15035. a.doctor_name,
  15036. a.beh_doctor_id,
  15037. a.beh_doctor_name,
  15038. a.director_doctor_id,
  15039. a.director_doctor_name,
  15040. a.diagnose,
  15041. a.placefile_date,
  15042. a.ward_name,
  15043. c.gmt_create,
  15044. d.score_res as scoreBn
  15045. FROM
  15046. med_behospital_info a,
  15047. med_home_page b,
  15048. med_qcresult_info c,
  15049. med_qcresult_cases d,
  15050. (
  15051. SELECT
  15052. m4.*
  15053. FROM
  15054. med_behospital_info m1,
  15055. med_home_page m2,
  15056. med_qcresult_info m3,
  15057. med_qcresult_cases m4
  15058. WHERE
  15059. m1.is_deleted = 'N'
  15060. AND m2.is_deleted = 'N'
  15061. AND m3.is_deleted = 'Y'
  15062. AND m4.is_deleted = 'Y'
  15063. AND m1.hospital_id = m2.hospital_id
  15064. AND m1.hospital_id = m3.hospital_id
  15065. AND m1.hospital_id = m4.hospital_id
  15066. AND m1.behospital_code = m2.behospital_code
  15067. AND m1.behospital_code = m3.behospital_code
  15068. AND m1.behospital_code = m4.behospital_code
  15069. AND m3.gmt_create = m4.gmt_create
  15070. AND m3.have_home_page = 1
  15071. AND m4.cases_id = 243
  15072. AND m1.qc_type_id != 0
  15073. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15074. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15075. </if>
  15076. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15077. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15078. </if>
  15079. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15080. <if test="qcResultShortPageVO.startDate != null ">
  15081. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15082. </if>
  15083. <if test="qcResultShortPageVO.endDate != null ">
  15084. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15085. </if>
  15086. </if>
  15087. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15088. <if test="qcResultShortPageVO.startDate != null">
  15089. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15090. </if>
  15091. <if test="qcResultShortPageVO.endDate != null ">
  15092. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15093. </if>
  15094. </if>
  15095. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15096. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15097. </if>
  15098. GROUP BY
  15099. m1.behospital_code
  15100. ORDER BY
  15101. m1.behospital_code,
  15102. m4.gmt_create
  15103. ) e
  15104. WHERE
  15105. a.is_deleted = 'N'
  15106. AND b.is_deleted = 'N'
  15107. AND c.is_deleted = 'N'
  15108. AND d.is_deleted = 'N'
  15109. AND a.hospital_id = b.hospital_id
  15110. AND a.hospital_id = c.hospital_id
  15111. AND a.hospital_id = d.hospital_id
  15112. AND a.hospital_id = e.hospital_id
  15113. AND a.behospital_code = b.behospital_code
  15114. AND a.behospital_code = c.behospital_code
  15115. AND a.behospital_code = d.behospital_code
  15116. AND a.behospital_code = e.behospital_code
  15117. AND d.cases_id = 243
  15118. AND d.score_res > e.score_res
  15119. AND a.qc_type_id != 0
  15120. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15121. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15122. </if>
  15123. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15124. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15125. </if>
  15126. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15127. <if test="qcResultShortPageVO.startDate != null ">
  15128. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15129. </if>
  15130. <if test="qcResultShortPageVO.endDate != null ">
  15131. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15132. </if>
  15133. </if>
  15134. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15135. <if test="qcResultShortPageVO.startDate != null ">
  15136. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15137. </if>
  15138. <if test="qcResultShortPageVO.endDate != null">
  15139. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15140. </if>
  15141. </if>
  15142. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15143. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15144. </if>
  15145. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15146. AND c.`level` = #{qcResultShortPageVO.level}
  15147. </if>
  15148. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15149. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15150. </if>
  15151. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15152. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15153. </if>
  15154. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15155. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15156. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15157. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15158. </if>
  15159. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15160. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15161. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15162. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15163. </if>
  15164. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15165. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15166. </if>
  15167. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15168. AND d.score_res = 20
  15169. </if>
  15170. ) be
  15171. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15172. AND mci.check_type in(0,2)
  15173. AND be.hospital_id = mci.hospital_id
  15174. AND be.behospital_code = mci.behospital_code
  15175. ) t1
  15176. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15177. AND t1.behospital_code = t2.behospital_code
  15178. AND t2.is_deleted = 'N'
  15179. ) t
  15180. WHERE
  15181. 1 = 1
  15182. <if test="qcResultShortPageVO.checkStatus != null">
  15183. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15184. </if>
  15185. <if test="qcResultShortPageVO.mrStatus != null">
  15186. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15187. </if>
  15188. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15189. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15190. </if>
  15191. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15192. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15193. </if>
  15194. <if test="qcResultShortPageVO.chTimeStart != null ">
  15195. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15196. </if>
  15197. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15198. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15199. </if>
  15200. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15201. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15202. </if>
  15203. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15204. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15205. </if>
  15206. </select>
  15207. <!-- 病案首页改善率质控评分页(内页)-科室-->
  15208. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  15209. SELECT
  15210. t.*
  15211. FROM
  15212. (
  15213. SELECT DISTINCT
  15214. t1.hospital_id AS hospitalId,
  15215. t1.behospital_code AS behospitalCode,
  15216. t1.bed_code AS bedCode,
  15217. t1.LEVEL AS LEVEL,
  15218. t1.grade_type AS gradeType,
  15219. t1.score_res AS scoreRes,
  15220. t1.NAME AS NAME,
  15221. t1.scoreBn,
  15222. t1.sex AS sex,
  15223. t1.beh_dept_id AS behDeptId,
  15224. t1.beh_dept_name AS behDeptName,
  15225. t1.doctor_id AS doctorId,
  15226. t1.doctor_name AS doctorName,
  15227. t1.beh_doctor_id AS behDoctorId,
  15228. t1.beh_doctor_name AS behDoctorName,
  15229. t1.director_doctor_id AS directorDoctorId,
  15230. t1.director_doctor_name AS directorDoctorName,
  15231. t1.birthday AS birthday,
  15232. t1.behospital_date AS behospitalDate,
  15233. t1.leave_hospital_date AS leaveHospitalDate,
  15234. t1.placefile_date AS placefileDate,
  15235. t1.gmt_create AS gradeTime,
  15236. t1.diagnose,
  15237. t1.ward_name AS wardName,
  15238. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15239. t1.file_code AS fileCode,
  15240. t1.checkStatus,
  15241. t1.mrStatus,
  15242. t1.chName,
  15243. t1.mrName,
  15244. t1.chTime,
  15245. t1.mrTime
  15246. FROM
  15247. (
  15248. SELECT
  15249. be.*,
  15250. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15251. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15252. mci.check_name AS chName,
  15253. hm_mci.check_name AS mrName,
  15254. e.score_res as scoreBn,
  15255. mci.gmt_create AS chTime,
  15256. hm_mci.gmt_create AS mrTime
  15257. FROM
  15258. (
  15259. SELECT DISTINCT
  15260. a.hospital_id,
  15261. a.behospital_code,
  15262. a.bed_code,
  15263. a.file_code,
  15264. c.LEVEL,
  15265. c.grade_type,
  15266. c.score_res,
  15267. a.NAME,
  15268. a.sex,
  15269. a.beh_dept_id,
  15270. a.beh_dept_name,
  15271. a.birthday,
  15272. a.behospital_date,
  15273. a.leave_hospital_date,
  15274. a.doctor_id,
  15275. a.doctor_name,
  15276. a.beh_doctor_id,
  15277. a.beh_doctor_name,
  15278. a.director_doctor_id,
  15279. a.director_doctor_name,
  15280. a.diagnose,
  15281. a.placefile_date,
  15282. a.ward_name,
  15283. c.gmt_create
  15284. FROM
  15285. med_behospital_info a,
  15286. med_home_page b,
  15287. med_qcresult_info c,
  15288. med_qcresult_cases d,
  15289. sys_user_dept f,
  15290. (
  15291. SELECT
  15292. m4.*
  15293. FROM
  15294. med_behospital_info m1,
  15295. med_home_page m2,
  15296. med_qcresult_info m3,
  15297. med_qcresult_cases m4
  15298. WHERE
  15299. m1.is_deleted = 'N'
  15300. AND m2.is_deleted = 'N'
  15301. AND m3.is_deleted = 'Y'
  15302. AND m4.is_deleted = 'Y'
  15303. AND m1.hospital_id = m2.hospital_id
  15304. AND m1.hospital_id = m3.hospital_id
  15305. AND m1.hospital_id = m4.hospital_id
  15306. AND m1.behospital_code = m2.behospital_code
  15307. AND m1.behospital_code = m3.behospital_code
  15308. AND m1.behospital_code = m4.behospital_code
  15309. AND m3.gmt_create = m4.gmt_create
  15310. AND m3.have_home_page = 1
  15311. AND m4.cases_id = 243
  15312. AND m1.qc_type_id != 0
  15313. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15314. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15315. </if>
  15316. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15317. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15318. </if>
  15319. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15320. <if test="qcResultShortPageVO.startDate != null ">
  15321. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15322. </if>
  15323. <if test="qcResultShortPageVO.endDate != null ">
  15324. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15325. </if>
  15326. </if>
  15327. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15328. <if test="qcResultShortPageVO.startDate != null">
  15329. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15330. </if>
  15331. <if test="qcResultShortPageVO.endDate != null ">
  15332. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15333. </if>
  15334. </if>
  15335. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15336. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  15337. </if>
  15338. GROUP BY
  15339. m1.behospital_code
  15340. ORDER BY
  15341. m1.behospital_code,
  15342. m4.gmt_create
  15343. ) e
  15344. WHERE
  15345. a.is_deleted = 'N'
  15346. AND b.is_deleted = 'N'
  15347. AND c.is_deleted = 'N'
  15348. AND d.is_deleted = 'N'
  15349. AND f.is_deleted = 'N'
  15350. AND a.hospital_id = b.hospital_id
  15351. AND a.hospital_id = c.hospital_id
  15352. AND a.hospital_id = d.hospital_id
  15353. AND a.hospital_id = f.hospital_id
  15354. AND a.hospital_id = e.hospital_id
  15355. AND a.behospital_code = b.behospital_code
  15356. AND a.behospital_code = c.behospital_code
  15357. AND a.behospital_code = d.behospital_code
  15358. AND a.beh_dept_id = f.dept_id
  15359. AND a.behospital_code = e.behospital_code
  15360. AND d.cases_id = 243
  15361. AND d.score_res > e.score_res
  15362. AND a.qc_type_id != 0
  15363. <if test="qcResultShortPageVO.userId!=null">
  15364. AND f.user_id = #{qcResultShortPageVO.userId}
  15365. </if>
  15366. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15367. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15368. </if>
  15369. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15370. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15371. </if>
  15372. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15373. <if test="qcResultShortPageVO.startDate != null ">
  15374. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15375. </if>
  15376. <if test="qcResultShortPageVO.endDate != null ">
  15377. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15378. </if>
  15379. </if>
  15380. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15381. <if test="qcResultShortPageVO.startDate != null ">
  15382. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15383. </if>
  15384. <if test="qcResultShortPageVO.endDate != null">
  15385. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15386. </if>
  15387. </if>
  15388. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15389. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15390. </if>
  15391. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15392. AND c.`level` = #{qcResultShortPageVO.level}
  15393. </if>
  15394. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15395. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15396. </if>
  15397. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15398. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15399. </if>
  15400. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15401. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15402. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15403. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15404. </if>
  15405. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15406. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15407. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15408. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15409. </if>
  15410. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15411. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15412. </if>
  15413. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15414. AND d.score_res = 20
  15415. </if>
  15416. ) be
  15417. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15418. AND mci.check_type = 0
  15419. AND be.hospital_id = mci.hospital_id
  15420. AND be.behospital_code = mci.behospital_code
  15421. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15422. AND hm_mci.check_type = 1
  15423. AND be.hospital_id = hm_mci.hospital_id
  15424. AND be.behospital_code = hm_mci.behospital_code
  15425. LEFT JOIN med_qcresult_cases e
  15426. on be.behospital_code = e.behospital_code
  15427. and be.hospital_id = e.hospital_id
  15428. AND e.is_deleted = 'N'
  15429. and e.cases_id = 243
  15430. ) t1
  15431. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15432. AND t1.behospital_code = t2.behospital_code
  15433. AND t2.is_deleted = 'N'
  15434. ) t
  15435. WHERE
  15436. 1 = 1
  15437. <if test="qcResultShortPageVO.checkStatus != null">
  15438. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15439. </if>
  15440. <if test="qcResultShortPageVO.mrStatus != null">
  15441. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15442. </if>
  15443. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15444. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15445. </if>
  15446. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15447. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15448. </if>
  15449. <if test="qcResultShortPageVO.chTimeStart != null ">
  15450. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15451. </if>
  15452. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15453. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15454. </if>
  15455. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15456. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15457. </if>
  15458. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15459. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15460. </if>
  15461. </select>
  15462. <!-- 质控核查质控评分页(内页)-->
  15463. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  15464. SELECT
  15465. t.*
  15466. FROM
  15467. (
  15468. SELECT DISTINCT
  15469. t1.hospital_id AS hospitalId,
  15470. t1.behospital_code AS behospitalCode,
  15471. t1.bed_code AS bedCode,
  15472. t1.LEVEL AS LEVEL,
  15473. t1.grade_type AS gradeType,
  15474. t1.score_res AS scoreRes,
  15475. t1.scoreBn,
  15476. t1.NAME AS NAME,
  15477. t1.sex AS sex,
  15478. t1.beh_dept_id AS behDeptId,
  15479. t1.beh_dept_name AS behDeptName,
  15480. t1.doctor_id AS doctorId,
  15481. t1.doctor_name AS doctorName,
  15482. t1.beh_doctor_id AS behDoctorId,
  15483. t1.beh_doctor_name AS behDoctorName,
  15484. t1.director_doctor_id AS directorDoctorId,
  15485. t1.director_doctor_name AS directorDoctorName,
  15486. t1.birthday AS birthday,
  15487. t1.behospital_date AS behospitalDate,
  15488. t1.leave_hospital_date AS leaveHospitalDate,
  15489. t1.placefile_date AS placefileDate,
  15490. t1.gmt_create AS gradeTime,
  15491. t1.diagnose,
  15492. t1.ward_name AS wardName,
  15493. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15494. t1.file_code AS fileCode,
  15495. t1.checkStatus,
  15496. t1.chName,
  15497. t1.chTime
  15498. FROM
  15499. (
  15500. SELECT
  15501. be.*,
  15502. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15503. mci.check_name AS chName,
  15504. e.score_res as scoreBn,
  15505. mci.gmt_create AS chTime
  15506. FROM
  15507. (
  15508. SELECT DISTINCT
  15509. a.hospital_id,
  15510. a.behospital_code,
  15511. a.bed_code,
  15512. a.file_code,
  15513. b.LEVEL,
  15514. b.grade_type,
  15515. b.score_res,
  15516. a.NAME,
  15517. a.sex,
  15518. a.beh_dept_id,
  15519. a.beh_dept_name,
  15520. a.birthday,
  15521. a.behospital_date,
  15522. a.leave_hospital_date,
  15523. a.doctor_id,
  15524. a.doctor_name,
  15525. a.beh_doctor_id,
  15526. a.beh_doctor_name,
  15527. a.director_doctor_id,
  15528. a.director_doctor_name,
  15529. a.diagnose,
  15530. a.placefile_date,
  15531. a.ward_name,
  15532. b.gmt_create
  15533. FROM
  15534. med_behospital_info a,
  15535. med_qcresult_info b
  15536. WHERE
  15537. a.is_deleted = 'N'
  15538. AND b.is_deleted = 'N'
  15539. AND a.hospital_id = b.hospital_id
  15540. AND a.behospital_code = b.behospital_code
  15541. AND a.qc_type_id != 0
  15542. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15543. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15544. </if>
  15545. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15546. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15547. </if>
  15548. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15549. <if test="qcResultShortPageVO.startDate != null ">
  15550. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15551. </if>
  15552. <if test="qcResultShortPageVO.endDate != null ">
  15553. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15554. </if>
  15555. </if>
  15556. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15557. <if test="qcResultShortPageVO.startDate != null ">
  15558. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15559. </if>
  15560. <if test="qcResultShortPageVO.endDate != null">
  15561. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15562. </if>
  15563. </if>
  15564. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15565. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15566. </if>
  15567. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15568. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15569. </if>
  15570. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15571. AND b.`level` = #{qcResultShortPageVO.level}
  15572. </if>
  15573. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15574. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15575. </if>
  15576. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15577. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15578. </if>
  15579. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15580. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15581. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15582. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15583. </if>
  15584. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15585. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15586. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15587. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15588. </if>
  15589. ) be
  15590. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15591. AND mci.check_type in(0,2)
  15592. AND be.hospital_id = mci.hospital_id
  15593. AND be.behospital_code = mci.behospital_code
  15594. LEFT JOIN med_qcresult_cases e
  15595. on be.behospital_code = e.behospital_code
  15596. and be.hospital_id = e.hospital_id
  15597. AND e.is_deleted = 'N'
  15598. and e.cases_id = 243
  15599. ) t1
  15600. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15601. AND t1.behospital_code = t2.behospital_code
  15602. AND t2.is_deleted = 'N'
  15603. ) t
  15604. WHERE
  15605. 1 = 1
  15606. <if test="qcResultShortPageVO.checkStatus != null">
  15607. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15608. </if>
  15609. <if test="qcResultShortPageVO.mrStatus != null">
  15610. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15611. </if>
  15612. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15613. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15614. </if>
  15615. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15616. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15617. </if>
  15618. <if test="qcResultShortPageVO.chTimeStart != null ">
  15619. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15620. </if>
  15621. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15622. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15623. </if>
  15624. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15625. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15626. </if>
  15627. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15628. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15629. </if>
  15630. </select>
  15631. <!-- 质控核查质控评分页-科室(内页)-->
  15632. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  15633. SELECT
  15634. t.*
  15635. FROM
  15636. (
  15637. SELECT DISTINCT
  15638. t1.hospital_id AS hospitalId,
  15639. t1.behospital_code AS behospitalCode,
  15640. t1.bed_code AS bedCode,
  15641. t1.LEVEL AS LEVEL,
  15642. t1.grade_type AS gradeType,
  15643. t1.score_res AS scoreRes,
  15644. t1.scoreBn,
  15645. t1.NAME AS NAME,
  15646. t1.sex AS sex,
  15647. t1.beh_dept_id AS behDeptId,
  15648. t1.beh_dept_name AS behDeptName,
  15649. t1.doctor_id AS doctorId,
  15650. t1.doctor_name AS doctorName,
  15651. t1.beh_doctor_id AS behDoctorId,
  15652. t1.beh_doctor_name AS behDoctorName,
  15653. t1.director_doctor_id AS directorDoctorId,
  15654. t1.director_doctor_name AS directorDoctorName,
  15655. t1.birthday AS birthday,
  15656. t1.behospital_date AS behospitalDate,
  15657. t1.leave_hospital_date AS leaveHospitalDate,
  15658. t1.placefile_date AS placefileDate,
  15659. t1.gmt_create AS gradeTime,
  15660. t1.diagnose,
  15661. t1.ward_name AS wardName,
  15662. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15663. t1.file_code AS fileCode,
  15664. t1.checkStatus,
  15665. t1.mrStatus,
  15666. t1.chName,
  15667. t1.mrName,
  15668. t1.chTime,
  15669. t1.mrTime
  15670. FROM
  15671. (
  15672. SELECT
  15673. be.*,
  15674. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15675. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15676. mci.check_name AS chName,
  15677. e.score_res as scoreBn,
  15678. hm_mci.check_name AS mrName,
  15679. mci.gmt_create AS chTime,
  15680. hm_mci.gmt_create AS mrTime
  15681. FROM
  15682. (
  15683. SELECT DISTINCT
  15684. a.hospital_id,
  15685. a.behospital_code,
  15686. a.bed_code,
  15687. a.file_code,
  15688. b.LEVEL,
  15689. b.grade_type,
  15690. b.score_res,
  15691. a.NAME,
  15692. a.sex,
  15693. a.beh_dept_id,
  15694. a.beh_dept_name,
  15695. a.birthday,
  15696. a.behospital_date,
  15697. a.leave_hospital_date,
  15698. a.doctor_id,
  15699. a.doctor_name,
  15700. a.beh_doctor_id,
  15701. a.beh_doctor_name,
  15702. a.director_doctor_id,
  15703. a.director_doctor_name,
  15704. a.diagnose,
  15705. a.placefile_date,
  15706. a.ward_name,
  15707. b.gmt_create
  15708. FROM
  15709. med_behospital_info a,
  15710. med_qcresult_info b,
  15711. sys_user_dept c
  15712. WHERE
  15713. a.is_deleted = 'N'
  15714. AND b.is_deleted = 'N'
  15715. AND c.is_deleted = 'N'
  15716. AND a.hospital_id = b.hospital_id
  15717. AND a.hospital_id = c.hospital_id
  15718. AND a.beh_dept_id = c.dept_id
  15719. AND a.behospital_code = b.behospital_code
  15720. AND a.qc_type_id != 0
  15721. <if test="qcResultShortPageVO.userId!=null">
  15722. AND c.user_id = #{qcResultShortPageVO.userId}
  15723. </if>
  15724. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15725. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15726. </if>
  15727. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15728. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15729. </if>
  15730. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15731. <if test="qcResultShortPageVO.startDate != null ">
  15732. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15733. </if>
  15734. <if test="qcResultShortPageVO.endDate != null ">
  15735. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15736. </if>
  15737. </if>
  15738. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15739. <if test="qcResultShortPageVO.startDate != null ">
  15740. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15741. </if>
  15742. <if test="qcResultShortPageVO.endDate != null">
  15743. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15744. </if>
  15745. </if>
  15746. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15747. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15748. </if>
  15749. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15750. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15751. </if>
  15752. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15753. AND b.`level` = #{qcResultShortPageVO.level}
  15754. </if>
  15755. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15756. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15757. </if>
  15758. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15759. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15760. </if>
  15761. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15762. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15763. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15764. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15765. </if>
  15766. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15767. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15768. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15769. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15770. </if>
  15771. ) be
  15772. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15773. AND mci.check_type = 0
  15774. AND be.hospital_id = mci.hospital_id
  15775. AND be.behospital_code = mci.behospital_code
  15776. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15777. AND hm_mci.check_type = 1
  15778. AND be.hospital_id = hm_mci.hospital_id
  15779. AND be.behospital_code = hm_mci.behospital_code
  15780. LEFT JOIN med_qcresult_cases e
  15781. on be.behospital_code = e.behospital_code
  15782. and be.hospital_id = e.hospital_id
  15783. AND e.is_deleted = 'N'
  15784. and e.cases_id = 243
  15785. ) t1
  15786. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15787. AND t1.behospital_code = t2.behospital_code
  15788. AND t2.is_deleted = 'N'
  15789. ) t
  15790. WHERE
  15791. 1 = 1
  15792. <if test="qcResultShortPageVO.checkStatus != null">
  15793. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15794. </if>
  15795. <if test="qcResultShortPageVO.mrStatus != null">
  15796. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15797. </if>
  15798. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15799. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15800. </if>
  15801. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15802. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15803. </if>
  15804. <if test="qcResultShortPageVO.chTimeStart != null ">
  15805. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15806. </if>
  15807. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15808. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15809. </if>
  15810. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15811. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15812. </if>
  15813. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15814. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15815. </if>
  15816. </select>
  15817. <!-- 病案首页改善率质控评分页导出-->
  15818. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  15819. SELECT
  15820. f1.behDeptId,
  15821. f1.behDeptName,
  15822. f1.patName,
  15823. f1.behospitalCode,
  15824. f1.hospitalId,
  15825. f1.behospitalDate,
  15826. f1.leaveHospitalDate,
  15827. f1.score,
  15828. f1.scoreBn,
  15829. f2.avgScore,
  15830. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15831. f1.msg,
  15832. f1.caseName,
  15833. </if>
  15834. f1.checkStatus,
  15835. f1.chName,
  15836. f1.chTime
  15837. FROM
  15838. (SELECT
  15839. t.doctorName AS behDoctorName,
  15840. t.`name` AS patName,
  15841. t.behospitalCode AS behospitalCode,
  15842. t.behospitalDate AS behospitalDate,
  15843. t.leaveHospitalDate AS leaveHospitalDate,
  15844. qi.score_res AS score,
  15845. t.scoreBn,
  15846. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15847. qd.msg AS msg,
  15848. qc.NAME AS caseName,
  15849. </if>
  15850. t.behDeptId,
  15851. t.behDeptName,
  15852. t.hospitalId,
  15853. t.checkStatus,
  15854. t.chName,
  15855. t.chTime
  15856. FROM
  15857. (
  15858. SELECT DISTINCT
  15859. t1.hospital_id AS hospitalId,
  15860. t1.behospital_code AS behospitalCode,
  15861. t1.bed_code AS bedCode,
  15862. t1.LEVEL AS LEVEL,
  15863. t1.grade_type AS gradeType,
  15864. t1.score_res AS scoreRes,
  15865. t1.scoreBn,
  15866. t1.NAME AS NAME,
  15867. t1.sex AS sex,
  15868. t1.beh_dept_id AS behDeptId,
  15869. t1.beh_dept_name AS behDeptName,
  15870. t1.doctor_id AS doctorId,
  15871. t1.doctor_name AS doctorName,
  15872. t1.beh_doctor_id AS behDoctorId,
  15873. t1.beh_doctor_name AS behDoctorName,
  15874. t1.director_doctor_id AS directorDoctorId,
  15875. t1.director_doctor_name AS directorDoctorName,
  15876. t1.birthday AS birthday,
  15877. t1.behospital_date AS behospitalDate,
  15878. t1.leave_hospital_date AS leaveHospitalDate,
  15879. t1.placefile_date AS placefileDate,
  15880. t1.gmt_create AS gradeTime,
  15881. t1.diagnose,
  15882. t1.ward_name AS wardName,
  15883. t2.age,
  15884. t1.file_code AS fileCode,
  15885. t1.checkStatus,
  15886. t1.chName,
  15887. t1.chTime
  15888. FROM
  15889. (
  15890. SELECT
  15891. be.*,
  15892. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15893. mci.check_name AS chName,
  15894. mci.gmt_create AS chTime
  15895. FROM
  15896. (
  15897. SELECT DISTINCT
  15898. a.hospital_id,
  15899. a.behospital_code,
  15900. a.bed_code,
  15901. a.file_code,
  15902. c.LEVEL,
  15903. c.grade_type,
  15904. c.score_res,
  15905. a.NAME,
  15906. a.sex,
  15907. a.beh_dept_id,
  15908. a.beh_dept_name,
  15909. a.birthday,
  15910. a.behospital_date,
  15911. a.leave_hospital_date,
  15912. a.doctor_id,
  15913. a.doctor_name,
  15914. a.beh_doctor_id,
  15915. a.beh_doctor_name,
  15916. a.director_doctor_id,
  15917. a.director_doctor_name,
  15918. a.diagnose,
  15919. a.placefile_date,
  15920. a.ward_name,
  15921. c.gmt_create,
  15922. d.score_res as scoreBn
  15923. FROM
  15924. med_behospital_info a,
  15925. med_home_page b,
  15926. med_qcresult_info c,
  15927. med_qcresult_cases d,
  15928. (
  15929. SELECT
  15930. m4.*
  15931. FROM
  15932. med_behospital_info m1,
  15933. med_home_page m2,
  15934. med_qcresult_info m3,
  15935. med_qcresult_cases m4
  15936. WHERE
  15937. m1.is_deleted = 'N'
  15938. AND m2.is_deleted = 'N'
  15939. AND m3.is_deleted = 'Y'
  15940. AND m4.is_deleted = 'Y'
  15941. AND m1.hospital_id = m2.hospital_id
  15942. AND m1.hospital_id = m3.hospital_id
  15943. AND m1.hospital_id = m4.hospital_id
  15944. AND m1.behospital_code = m2.behospital_code
  15945. AND m1.behospital_code = m3.behospital_code
  15946. AND m1.behospital_code = m4.behospital_code
  15947. AND m3.gmt_create = m4.gmt_create
  15948. AND m3.have_home_page = 1
  15949. AND m4.cases_id = 243
  15950. AND m1.qc_type_id != 0
  15951. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15952. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15953. </if>
  15954. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15955. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15956. </if>
  15957. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15958. <if test="qcResultShortPageVO.startDate != null ">
  15959. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15960. </if>
  15961. <if test="qcResultShortPageVO.endDate != null ">
  15962. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15963. </if>
  15964. </if>
  15965. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15966. <if test="qcResultShortPageVO.startDate != null">
  15967. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15968. </if>
  15969. <if test="qcResultShortPageVO.endDate != null ">
  15970. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15971. </if>
  15972. </if>
  15973. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15974. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15975. </if>
  15976. GROUP BY
  15977. m1.behospital_code
  15978. ORDER BY
  15979. m1.behospital_code,
  15980. m4.gmt_create
  15981. ) e
  15982. WHERE
  15983. a.is_deleted = 'N'
  15984. AND b.is_deleted = 'N'
  15985. AND c.is_deleted = 'N'
  15986. AND d.is_deleted = 'N'
  15987. AND a.hospital_id = b.hospital_id
  15988. AND a.hospital_id = c.hospital_id
  15989. AND a.hospital_id = d.hospital_id
  15990. AND a.hospital_id = e.hospital_id
  15991. AND a.behospital_code = b.behospital_code
  15992. AND a.behospital_code = c.behospital_code
  15993. AND a.behospital_code = d.behospital_code
  15994. AND a.behospital_code = e.behospital_code
  15995. AND d.cases_id = 243
  15996. AND d.score_res > e.score_res
  15997. AND a.qc_type_id != 0
  15998. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15999. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16000. </if>
  16001. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16002. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16003. </if>
  16004. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16005. <if test="qcResultShortPageVO.startDate != null ">
  16006. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16007. </if>
  16008. <if test="qcResultShortPageVO.endDate != null ">
  16009. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16010. </if>
  16011. </if>
  16012. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16013. <if test="qcResultShortPageVO.startDate != null ">
  16014. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16015. </if>
  16016. <if test="qcResultShortPageVO.endDate != null">
  16017. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16018. </if>
  16019. </if>
  16020. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16021. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16022. </if>
  16023. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16024. AND c.`level` = #{qcResultShortPageVO.level}
  16025. </if>
  16026. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16027. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16028. </if>
  16029. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16030. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16031. </if>
  16032. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16033. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16034. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16035. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16036. </if>
  16037. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16038. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16039. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16040. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16041. </if>
  16042. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16043. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16044. </if>
  16045. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16046. AND d.score_res = 20
  16047. </if>
  16048. ) be
  16049. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16050. AND mci.check_type in(0,2)
  16051. AND be.hospital_id = mci.hospital_id
  16052. AND be.behospital_code = mci.behospital_code
  16053. ) t1
  16054. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16055. AND t1.behospital_code = t2.behospital_code
  16056. AND t2.is_deleted = 'N'
  16057. ) t
  16058. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16059. AND t.hospitalId = qi.hospital_id
  16060. AND t.behospitalCode = qi.behospital_code
  16061. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16062. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16063. AND t.hospitalId = qd.hospital_id
  16064. AND t.behospitalCode = qd.behospital_code
  16065. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16066. AND qd.cases_id = qc.id
  16067. </if>
  16068. where 1=1
  16069. <if test="qcResultShortPageVO.checkStatus != null">
  16070. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16071. </if>
  16072. <if test="qcResultShortPageVO.mrStatus != null">
  16073. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16074. </if>
  16075. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16076. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16077. </if>
  16078. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16079. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16080. </if>
  16081. <if test="qcResultShortPageVO.chTimeStart != null ">
  16082. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16083. </if>
  16084. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16085. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16086. </if>
  16087. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16088. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16089. </if>
  16090. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16091. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16092. </if>
  16093. )f1,
  16094. (SELECT
  16095. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16096. t.behDeptId,
  16097. t.behDeptName
  16098. FROM
  16099. (
  16100. SELECT DISTINCT
  16101. t1.hospital_id AS hospitalId,
  16102. t1.behospital_code AS behospitalCode,
  16103. t1.bed_code AS bedCode,
  16104. t1.LEVEL AS LEVEL,
  16105. t1.grade_type AS gradeType,
  16106. t1.score_res AS scoreRes,
  16107. t1.NAME AS NAME,
  16108. t1.sex AS sex,
  16109. t1.beh_dept_id AS behDeptId,
  16110. t1.beh_dept_name AS behDeptName,
  16111. t1.doctor_id AS doctorId,
  16112. t1.doctor_name AS doctorName,
  16113. t1.beh_doctor_id AS behDoctorId,
  16114. t1.beh_doctor_name AS behDoctorName,
  16115. t1.director_doctor_id AS directorDoctorId,
  16116. t1.director_doctor_name AS directorDoctorName,
  16117. t1.birthday AS birthday,
  16118. t1.behospital_date AS behospitalDate,
  16119. t1.leave_hospital_date AS leaveHospitalDate,
  16120. t1.placefile_date AS placefileDate,
  16121. t1.gmt_create AS gradeTime,
  16122. t1.diagnose,
  16123. t1.ward_name AS wardName,
  16124. t2.age,
  16125. t1.file_code AS fileCode,
  16126. t1.checkStatus,
  16127. t1.chName,
  16128. t1.chTime
  16129. FROM
  16130. (
  16131. SELECT
  16132. be.*,
  16133. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16134. mci.check_name AS chName,
  16135. mci.gmt_create AS chTime
  16136. FROM
  16137. (
  16138. SELECT DISTINCT
  16139. a.hospital_id,
  16140. a.behospital_code,
  16141. a.bed_code,
  16142. a.file_code,
  16143. c.LEVEL,
  16144. c.grade_type,
  16145. c.score_res,
  16146. a.NAME,
  16147. a.sex,
  16148. a.beh_dept_id,
  16149. a.beh_dept_name,
  16150. a.birthday,
  16151. a.behospital_date,
  16152. a.leave_hospital_date,
  16153. a.doctor_id,
  16154. a.doctor_name,
  16155. a.beh_doctor_id,
  16156. a.beh_doctor_name,
  16157. a.director_doctor_id,
  16158. a.director_doctor_name,
  16159. a.diagnose,
  16160. a.placefile_date,
  16161. a.ward_name,
  16162. c.gmt_create
  16163. FROM
  16164. med_behospital_info a,
  16165. med_home_page b,
  16166. med_qcresult_info c,
  16167. med_qcresult_cases d,
  16168. (
  16169. SELECT
  16170. m4.*
  16171. FROM
  16172. med_behospital_info m1,
  16173. med_home_page m2,
  16174. med_qcresult_info m3,
  16175. med_qcresult_cases m4
  16176. WHERE
  16177. m1.is_deleted = 'N'
  16178. AND m2.is_deleted = 'N'
  16179. AND m3.is_deleted = 'Y'
  16180. AND m4.is_deleted = 'Y'
  16181. AND m1.hospital_id = m2.hospital_id
  16182. AND m1.hospital_id = m3.hospital_id
  16183. AND m1.hospital_id = m4.hospital_id
  16184. AND m1.behospital_code = m2.behospital_code
  16185. AND m1.behospital_code = m3.behospital_code
  16186. AND m1.behospital_code = m4.behospital_code
  16187. AND m3.gmt_create = m4.gmt_create
  16188. AND m3.have_home_page = 1
  16189. AND m4.cases_id = 243
  16190. AND m1.qc_type_id != 0
  16191. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16192. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16193. </if>
  16194. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16195. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16196. </if>
  16197. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16198. <if test="qcResultShortPageVO.startDate != null ">
  16199. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16200. </if>
  16201. <if test="qcResultShortPageVO.endDate != null ">
  16202. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16203. </if>
  16204. </if>
  16205. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16206. <if test="qcResultShortPageVO.startDate != null">
  16207. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16208. </if>
  16209. <if test="qcResultShortPageVO.endDate != null ">
  16210. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16211. </if>
  16212. </if>
  16213. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16214. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16215. </if>
  16216. GROUP BY
  16217. m1.behospital_code
  16218. ORDER BY
  16219. m1.behospital_code,
  16220. m4.gmt_create
  16221. ) e
  16222. WHERE
  16223. a.is_deleted = 'N'
  16224. AND b.is_deleted = 'N'
  16225. AND c.is_deleted = 'N'
  16226. AND d.is_deleted = 'N'
  16227. AND a.hospital_id = b.hospital_id
  16228. AND a.hospital_id = c.hospital_id
  16229. AND a.hospital_id = d.hospital_id
  16230. AND a.hospital_id = e.hospital_id
  16231. AND a.behospital_code = b.behospital_code
  16232. AND a.behospital_code = c.behospital_code
  16233. AND a.behospital_code = d.behospital_code
  16234. AND a.behospital_code = e.behospital_code
  16235. AND d.cases_id = 243
  16236. AND d.score_res > e.score_res
  16237. AND a.qc_type_id != 0
  16238. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16239. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16240. </if>
  16241. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16242. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16243. </if>
  16244. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16245. <if test="qcResultShortPageVO.startDate != null ">
  16246. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16247. </if>
  16248. <if test="qcResultShortPageVO.endDate != null ">
  16249. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16250. </if>
  16251. </if>
  16252. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16253. <if test="qcResultShortPageVO.startDate != null ">
  16254. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16255. </if>
  16256. <if test="qcResultShortPageVO.endDate != null">
  16257. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16258. </if>
  16259. </if>
  16260. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16261. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16262. </if>
  16263. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16264. AND c.`level` = #{qcResultShortPageVO.level}
  16265. </if>
  16266. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16267. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16268. </if>
  16269. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16270. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16271. </if>
  16272. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16273. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16274. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16275. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16276. </if>
  16277. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16278. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16279. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16280. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16281. </if>
  16282. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16283. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16284. </if>
  16285. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16286. AND d.score_res = 20
  16287. </if>
  16288. ) be
  16289. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16290. AND mci.check_type in(0,2)
  16291. AND be.hospital_id = mci.hospital_id
  16292. AND be.behospital_code = mci.behospital_code
  16293. ) t1
  16294. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16295. AND t1.behospital_code = t2.behospital_code
  16296. AND t2.is_deleted = 'N'
  16297. ) t
  16298. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16299. AND t.hospitalId = qi.hospital_id
  16300. AND t.behospitalCode = qi.behospital_code
  16301. where 1=1
  16302. <if test="qcResultShortPageVO.checkStatus != null">
  16303. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16304. </if>
  16305. <if test="qcResultShortPageVO.mrStatus != null">
  16306. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16307. </if>
  16308. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16309. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16310. </if>
  16311. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16312. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16313. </if>
  16314. <if test="qcResultShortPageVO.chTimeStart != null ">
  16315. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16316. </if>
  16317. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16318. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16319. </if>
  16320. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16321. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16322. </if>
  16323. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16324. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16325. </if>
  16326. GROUP BY
  16327. t.behDeptId,
  16328. t.behDeptName
  16329. )f2
  16330. WHERE
  16331. f1.behDeptId = f2.behDeptId
  16332. AND f1.behDeptName = f2.behDeptName
  16333. </select>
  16334. <!-- 病案首页改善率质控评分页导出-->
  16335. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  16336. SELECT
  16337. f1.behDeptId,
  16338. f1.behDeptName,
  16339. f1.doctorId,
  16340. f1.doctorName,
  16341. f1.patName,
  16342. f1.behospitalCode,
  16343. f1.hospitalId,
  16344. f1.scoreBn,
  16345. f1.behospitalDate,
  16346. f1.leaveHospitalDate,
  16347. f1.score,
  16348. f2.avgScore,
  16349. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16350. f1.msg,
  16351. f1.caseName,
  16352. </if>
  16353. f1.checkStatus,
  16354. f1.mrStatus,
  16355. f1.chName,
  16356. f1.mrName,
  16357. f1.chTime,
  16358. f1.mrTime
  16359. FROM
  16360. (SELECT
  16361. t.doctorId,
  16362. t.doctorName,
  16363. t.`name` AS patName,
  16364. t.behospitalCode AS behospitalCode,
  16365. t.behospitalDate AS behospitalDate,
  16366. t.leaveHospitalDate AS leaveHospitalDate,
  16367. qi.score_res AS score,
  16368. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16369. qd.msg AS msg,
  16370. qc.NAME AS caseName,
  16371. </if>
  16372. t.behDeptId,
  16373. t.behDeptName,
  16374. t.hospitalId,
  16375. t.checkStatus,
  16376. t.mrStatus,
  16377. t.chName,
  16378. t.mrName,
  16379. t.chTime,
  16380. t.mrTime
  16381. FROM
  16382. (
  16383. SELECT DISTINCT
  16384. t1.hospital_id AS hospitalId,
  16385. t1.behospital_code AS behospitalCode,
  16386. t1.bed_code AS bedCode,
  16387. t1.LEVEL AS LEVEL,
  16388. t1.grade_type AS gradeType,
  16389. t1.score_res AS scoreRes,
  16390. t1.NAME AS NAME,
  16391. t1.sex AS sex,
  16392. t1.beh_dept_id AS behDeptId,
  16393. t1.beh_dept_name AS behDeptName,
  16394. t1.doctor_id AS doctorId,
  16395. t1.doctor_name AS doctorName,
  16396. t1.beh_doctor_id AS behDoctorId,
  16397. t1.beh_doctor_name AS behDoctorName,
  16398. t1.director_doctor_id AS directorDoctorId,
  16399. t1.director_doctor_name AS directorDoctorName,
  16400. t1.birthday AS birthday,
  16401. t1.behospital_date AS behospitalDate,
  16402. t1.leave_hospital_date AS leaveHospitalDate,
  16403. t1.placefile_date AS placefileDate,
  16404. t1.gmt_create AS gradeTime,
  16405. t1.diagnose,
  16406. t1.ward_name AS wardName,
  16407. t1.scoreBn,
  16408. t1.file_code AS fileCode,
  16409. t1.checkStatus,
  16410. t1.mrStatus,
  16411. t1.chName,
  16412. t1.mrName,
  16413. t1.chTime,
  16414. t1.mrTime
  16415. FROM
  16416. (
  16417. SELECT
  16418. be.*,
  16419. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16420. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16421. mci.check_name AS chName,
  16422. e.score_res as scoreBn,
  16423. hm_mci.check_name AS mrName,
  16424. mci.gmt_create AS chTime,
  16425. hm_mci.gmt_create AS mrTime
  16426. FROM
  16427. (
  16428. SELECT DISTINCT
  16429. a.hospital_id,
  16430. a.behospital_code,
  16431. a.bed_code,
  16432. a.file_code,
  16433. c.LEVEL,
  16434. c.grade_type,
  16435. c.score_res,
  16436. a.NAME,
  16437. a.sex,
  16438. a.beh_dept_id,
  16439. a.beh_dept_name,
  16440. a.birthday,
  16441. a.behospital_date,
  16442. a.leave_hospital_date,
  16443. a.doctor_id,
  16444. a.doctor_name,
  16445. a.beh_doctor_id,
  16446. a.beh_doctor_name,
  16447. a.director_doctor_id,
  16448. a.director_doctor_name,
  16449. a.diagnose,
  16450. a.placefile_date,
  16451. a.ward_name,
  16452. c.gmt_create
  16453. FROM
  16454. med_behospital_info a,
  16455. med_home_page b,
  16456. med_qcresult_info c,
  16457. med_qcresult_cases d,
  16458. sys_user_dept f,
  16459. (
  16460. SELECT
  16461. m4.*
  16462. FROM
  16463. med_behospital_info m1,
  16464. med_home_page m2,
  16465. med_qcresult_info m3,
  16466. med_qcresult_cases m4
  16467. WHERE
  16468. m1.is_deleted = 'N'
  16469. AND m2.is_deleted = 'N'
  16470. AND m3.is_deleted = 'Y'
  16471. AND m4.is_deleted = 'Y'
  16472. AND m1.hospital_id = m2.hospital_id
  16473. AND m1.hospital_id = m3.hospital_id
  16474. AND m1.hospital_id = m4.hospital_id
  16475. AND m1.behospital_code = m2.behospital_code
  16476. AND m1.behospital_code = m3.behospital_code
  16477. AND m1.behospital_code = m4.behospital_code
  16478. AND m3.gmt_create = m4.gmt_create
  16479. AND m3.have_home_page = 1
  16480. AND m4.cases_id = 243
  16481. AND m1.qc_type_id != 0
  16482. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16483. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16484. </if>
  16485. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16486. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16487. </if>
  16488. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16489. <if test="qcResultShortPageVO.startDate != null ">
  16490. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16491. </if>
  16492. <if test="qcResultShortPageVO.endDate != null ">
  16493. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16494. </if>
  16495. </if>
  16496. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16497. <if test="qcResultShortPageVO.startDate != null">
  16498. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16499. </if>
  16500. <if test="qcResultShortPageVO.endDate != null ">
  16501. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16502. </if>
  16503. </if>
  16504. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16505. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16506. </if>
  16507. GROUP BY
  16508. m1.behospital_code
  16509. ORDER BY
  16510. m1.behospital_code,
  16511. m4.gmt_create
  16512. ) e
  16513. WHERE
  16514. a.is_deleted = 'N'
  16515. AND b.is_deleted = 'N'
  16516. AND c.is_deleted = 'N'
  16517. AND d.is_deleted = 'N'
  16518. AND f.is_deleted = 'N'
  16519. AND a.hospital_id = b.hospital_id
  16520. AND a.hospital_id = c.hospital_id
  16521. AND a.hospital_id = d.hospital_id
  16522. AND a.hospital_id = e.hospital_id
  16523. AND a.hospital_id = f.hospital_id
  16524. AND a.behospital_code = b.behospital_code
  16525. AND a.behospital_code = c.behospital_code
  16526. AND a.behospital_code = d.behospital_code
  16527. AND a.behospital_code = e.behospital_code
  16528. AND a.beh_dept_id = f.dept_id
  16529. AND d.cases_id = 243
  16530. AND d.score_res > e.score_res
  16531. AND a.qc_type_id != 0
  16532. <if test="qcResultShortPageVO.userId!=null">
  16533. AND f.user_id = #{qcResultShortPageVO.userId}
  16534. </if>
  16535. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16536. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16537. </if>
  16538. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16539. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16540. </if>
  16541. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16542. <if test="qcResultShortPageVO.startDate != null ">
  16543. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16544. </if>
  16545. <if test="qcResultShortPageVO.endDate != null ">
  16546. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16547. </if>
  16548. </if>
  16549. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16550. <if test="qcResultShortPageVO.startDate != null ">
  16551. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16552. </if>
  16553. <if test="qcResultShortPageVO.endDate != null">
  16554. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16555. </if>
  16556. </if>
  16557. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16558. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16559. </if>
  16560. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16561. AND c.`level` = #{qcResultShortPageVO.level}
  16562. </if>
  16563. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16564. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16565. </if>
  16566. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16567. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16568. </if>
  16569. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16570. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16571. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16572. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16573. </if>
  16574. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16575. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16576. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16577. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16578. </if>
  16579. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16580. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16581. </if>
  16582. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16583. AND d.score_res = 20
  16584. </if>
  16585. ) be
  16586. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16587. AND mci.check_type = 0
  16588. AND be.hospital_id = mci.hospital_id
  16589. AND be.behospital_code = mci.behospital_code
  16590. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16591. AND hm_mci.check_type = 1
  16592. AND be.hospital_id = hm_mci.hospital_id
  16593. AND be.behospital_code = hm_mci.behospital_code
  16594. LEFT JOIN med_qcresult_cases e
  16595. on be.behospital_code = e.behospital_code
  16596. and be.hospital_id = e.hospital_id
  16597. AND e.is_deleted = 'N'
  16598. and e.cases_id = 243
  16599. ) t1
  16600. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16601. AND t1.behospital_code = t2.behospital_code
  16602. AND t2.is_deleted = 'N'
  16603. ) t
  16604. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16605. AND t.hospitalId = qi.hospital_id
  16606. AND t.behospitalCode = qi.behospital_code
  16607. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16608. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16609. AND t.hospitalId = qd.hospital_id
  16610. AND t.behospitalCode = qd.behospital_code
  16611. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16612. AND qd.cases_id = qc.id
  16613. </if>
  16614. where 1=1
  16615. <if test="qcResultShortPageVO.checkStatus != null">
  16616. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16617. </if>
  16618. <if test="qcResultShortPageVO.mrStatus != null">
  16619. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16620. </if>
  16621. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16622. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16623. </if>
  16624. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16625. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16626. </if>
  16627. <if test="qcResultShortPageVO.chTimeStart != null ">
  16628. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16629. </if>
  16630. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16631. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16632. </if>
  16633. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16634. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16635. </if>
  16636. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16637. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16638. </if>
  16639. )f1,
  16640. (SELECT
  16641. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16642. t.behDeptId,
  16643. t.behDeptName,
  16644. t.doctorId,
  16645. t.doctorName
  16646. FROM
  16647. (
  16648. SELECT DISTINCT
  16649. t1.hospital_id AS hospitalId,
  16650. t1.behospital_code AS behospitalCode,
  16651. t1.bed_code AS bedCode,
  16652. t1.LEVEL AS LEVEL,
  16653. t1.grade_type AS gradeType,
  16654. t1.score_res AS scoreRes,
  16655. t1.NAME AS NAME,
  16656. t1.sex AS sex,
  16657. t1.beh_dept_id AS behDeptId,
  16658. t1.beh_dept_name AS behDeptName,
  16659. t1.doctor_id AS doctorId,
  16660. t1.doctor_name AS doctorName,
  16661. t1.beh_doctor_id AS behDoctorId,
  16662. t1.beh_doctor_name AS behDoctorName,
  16663. t1.director_doctor_id AS directorDoctorId,
  16664. t1.director_doctor_name AS directorDoctorName,
  16665. t1.birthday AS birthday,
  16666. t1.behospital_date AS behospitalDate,
  16667. t1.leave_hospital_date AS leaveHospitalDate,
  16668. t1.placefile_date AS placefileDate,
  16669. t1.gmt_create AS gradeTime,
  16670. t1.diagnose,
  16671. t1.ward_name AS wardName,
  16672. t2.age,
  16673. t1.file_code AS fileCode,
  16674. t1.checkStatus,
  16675. t1.mrStatus,
  16676. t1.chName,
  16677. t1.mrName,
  16678. t1.chTime,
  16679. t1.mrTime
  16680. FROM
  16681. (
  16682. SELECT
  16683. be.*,
  16684. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16685. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16686. mci.check_name AS chName,
  16687. hm_mci.check_name AS mrName,
  16688. mci.gmt_create AS chTime,
  16689. hm_mci.gmt_create AS mrTime
  16690. FROM
  16691. (
  16692. SELECT DISTINCT
  16693. a.hospital_id,
  16694. a.behospital_code,
  16695. a.bed_code,
  16696. a.file_code,
  16697. c.LEVEL,
  16698. c.grade_type,
  16699. c.score_res,
  16700. a.NAME,
  16701. a.sex,
  16702. a.beh_dept_id,
  16703. a.beh_dept_name,
  16704. a.birthday,
  16705. a.behospital_date,
  16706. a.leave_hospital_date,
  16707. a.doctor_id,
  16708. a.doctor_name,
  16709. a.beh_doctor_id,
  16710. a.beh_doctor_name,
  16711. a.director_doctor_id,
  16712. a.director_doctor_name,
  16713. a.diagnose,
  16714. a.placefile_date,
  16715. a.ward_name,
  16716. c.gmt_create
  16717. FROM
  16718. med_behospital_info a,
  16719. med_home_page b,
  16720. med_qcresult_info c,
  16721. med_qcresult_cases d,
  16722. sys_user_dept f,
  16723. (
  16724. SELECT
  16725. m4.*
  16726. FROM
  16727. med_behospital_info m1,
  16728. med_home_page m2,
  16729. med_qcresult_info m3,
  16730. med_qcresult_cases m4
  16731. WHERE
  16732. m1.is_deleted = 'N'
  16733. AND m2.is_deleted = 'N'
  16734. AND m3.is_deleted = 'Y'
  16735. AND m4.is_deleted = 'Y'
  16736. AND m1.hospital_id = m2.hospital_id
  16737. AND m1.hospital_id = m3.hospital_id
  16738. AND m1.hospital_id = m4.hospital_id
  16739. AND m1.behospital_code = m2.behospital_code
  16740. AND m1.behospital_code = m3.behospital_code
  16741. AND m1.behospital_code = m4.behospital_code
  16742. AND m3.gmt_create = m4.gmt_create
  16743. AND m3.have_home_page = 1
  16744. AND m4.cases_id = 243
  16745. AND m1.qc_type_id != 0
  16746. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16747. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16748. </if>
  16749. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16750. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16751. </if>
  16752. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16753. <if test="qcResultShortPageVO.startDate != null ">
  16754. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16755. </if>
  16756. <if test="qcResultShortPageVO.endDate != null ">
  16757. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16758. </if>
  16759. </if>
  16760. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16761. <if test="qcResultShortPageVO.startDate != null">
  16762. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16763. </if>
  16764. <if test="qcResultShortPageVO.endDate != null ">
  16765. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16766. </if>
  16767. </if>
  16768. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16769. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16770. </if>
  16771. GROUP BY
  16772. m1.behospital_code
  16773. ORDER BY
  16774. m1.behospital_code,
  16775. m4.gmt_create
  16776. ) e
  16777. WHERE
  16778. a.is_deleted = 'N'
  16779. AND b.is_deleted = 'N'
  16780. AND c.is_deleted = 'N'
  16781. AND d.is_deleted = 'N'
  16782. AND f.is_deleted = 'N'
  16783. AND a.hospital_id = b.hospital_id
  16784. AND a.hospital_id = c.hospital_id
  16785. AND a.hospital_id = d.hospital_id
  16786. AND a.hospital_id = e.hospital_id
  16787. AND a.hospital_id = f.hospital_id
  16788. AND a.behospital_code = b.behospital_code
  16789. AND a.behospital_code = c.behospital_code
  16790. AND a.behospital_code = d.behospital_code
  16791. AND a.behospital_code = e.behospital_code
  16792. AND a.beh_dept_id = f.dept_id
  16793. AND d.cases_id = 243
  16794. AND d.score_res > e.score_res
  16795. AND a.qc_type_id != 0
  16796. <if test="qcResultShortPageVO.userId!=null">
  16797. AND f.user_id = #{qcResultShortPageVO.userId}
  16798. </if>
  16799. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16800. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16801. </if>
  16802. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16803. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16804. </if>
  16805. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16806. <if test="qcResultShortPageVO.startDate != null ">
  16807. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16808. </if>
  16809. <if test="qcResultShortPageVO.endDate != null ">
  16810. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16811. </if>
  16812. </if>
  16813. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16814. <if test="qcResultShortPageVO.startDate != null ">
  16815. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16816. </if>
  16817. <if test="qcResultShortPageVO.endDate != null">
  16818. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16819. </if>
  16820. </if>
  16821. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16822. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16823. </if>
  16824. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16825. AND c.`level` = #{qcResultShortPageVO.level}
  16826. </if>
  16827. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16828. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16829. </if>
  16830. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16831. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16832. </if>
  16833. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16834. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16835. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16836. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16837. </if>
  16838. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16839. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16840. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16841. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16842. </if>
  16843. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16844. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16845. </if>
  16846. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16847. AND d.score_res = 20
  16848. </if>
  16849. ) be
  16850. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16851. AND mci.check_type = 0
  16852. AND be.hospital_id = mci.hospital_id
  16853. AND be.behospital_code = mci.behospital_code
  16854. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16855. AND hm_mci.check_type = 1
  16856. AND be.hospital_id = hm_mci.hospital_id
  16857. AND be.behospital_code = hm_mci.behospital_code
  16858. ) t1
  16859. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16860. AND t1.behospital_code = t2.behospital_code
  16861. AND t2.is_deleted = 'N'
  16862. ) t
  16863. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16864. AND t.hospitalId = qi.hospital_id
  16865. AND t.behospitalCode = qi.behospital_code
  16866. where 1=1
  16867. <if test="qcResultShortPageVO.checkStatus != null">
  16868. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16869. </if>
  16870. <if test="qcResultShortPageVO.mrStatus != null">
  16871. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16872. </if>
  16873. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16874. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16875. </if>
  16876. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16877. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16878. </if>
  16879. <if test="qcResultShortPageVO.chTimeStart != null ">
  16880. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16881. </if>
  16882. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16883. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16884. </if>
  16885. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16886. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16887. </if>
  16888. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16889. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16890. </if>
  16891. GROUP BY
  16892. t.doctorId,
  16893. t.doctorName
  16894. )f2
  16895. WHERE
  16896. f1.doctorId = f2.doctorId
  16897. AND f1.doctorName = f2.doctorName
  16898. </select>
  16899. <!-- 质控核查质控评分页导出-->
  16900. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  16901. SELECT
  16902. f1.behDeptId,
  16903. f1.behDeptName,
  16904. f1.doctorName,
  16905. f1.patName,
  16906. f1.behospitalCode,
  16907. f1.hospitalId,
  16908. f1.behospitalDate,
  16909. f1.leaveHospitalDate,
  16910. f1.score,
  16911. f1.scoreBn,
  16912. f2.avgScore,
  16913. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16914. f1.msg,
  16915. f1.caseName,
  16916. </if>
  16917. f1.checkStatus,
  16918. f1.chName,
  16919. f1.chTime
  16920. FROM
  16921. (SELECT
  16922. t.doctorName,
  16923. t.`name` AS patName,
  16924. t.behospitalCode AS behospitalCode,
  16925. t.behospitalDate AS behospitalDate,
  16926. t.leaveHospitalDate AS leaveHospitalDate,
  16927. qi.score_res AS score,
  16928. t.scoreBn,
  16929. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16930. qd.msg AS msg,
  16931. qc.NAME AS caseName,
  16932. </if>
  16933. t.behDeptId,
  16934. t.behDeptName,
  16935. t.hospitalId,
  16936. t.checkStatus,
  16937. t.chName,
  16938. t.chTime
  16939. FROM
  16940. (
  16941. SELECT DISTINCT
  16942. t1.hospital_id AS hospitalId,
  16943. t1.behospital_code AS behospitalCode,
  16944. t1.bed_code AS bedCode,
  16945. t1.LEVEL AS LEVEL,
  16946. t1.grade_type AS gradeType,
  16947. t1.score_res AS scoreRes,
  16948. t1.scoreBn,
  16949. t1.NAME AS NAME,
  16950. t1.sex AS sex,
  16951. t1.beh_dept_id AS behDeptId,
  16952. t1.beh_dept_name AS behDeptName,
  16953. t1.doctor_id AS doctorId,
  16954. t1.doctor_name AS doctorName,
  16955. t1.beh_doctor_id AS behDoctorId,
  16956. t1.beh_doctor_name AS behDoctorName,
  16957. t1.director_doctor_id AS directorDoctorId,
  16958. t1.director_doctor_name AS directorDoctorName,
  16959. t1.birthday AS birthday,
  16960. t1.behospital_date AS behospitalDate,
  16961. t1.leave_hospital_date AS leaveHospitalDate,
  16962. t1.placefile_date AS placefileDate,
  16963. t1.gmt_create AS gradeTime,
  16964. t1.diagnose,
  16965. t1.ward_name AS wardName,
  16966. t2.age,
  16967. t1.file_code AS fileCode,
  16968. t1.checkStatus,
  16969. t1.chName,
  16970. t1.chTime
  16971. FROM
  16972. (
  16973. SELECT
  16974. be.*,
  16975. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16976. mci.check_name AS chName,
  16977. e.score_res as scoreBn,
  16978. mci.gmt_create AS chTime
  16979. FROM
  16980. (
  16981. SELECT DISTINCT
  16982. a.hospital_id,
  16983. a.behospital_code,
  16984. a.bed_code,
  16985. a.file_code,
  16986. b.LEVEL,
  16987. b.grade_type,
  16988. b.score_res,
  16989. a.NAME,
  16990. a.sex,
  16991. a.beh_dept_id,
  16992. a.beh_dept_name,
  16993. a.birthday,
  16994. a.behospital_date,
  16995. a.leave_hospital_date,
  16996. a.doctor_id,
  16997. a.doctor_name,
  16998. a.beh_doctor_id,
  16999. a.beh_doctor_name,
  17000. a.director_doctor_id,
  17001. a.director_doctor_name,
  17002. a.diagnose,
  17003. a.placefile_date,
  17004. a.ward_name,
  17005. b.gmt_create
  17006. FROM
  17007. med_behospital_info a,
  17008. med_qcresult_info b
  17009. WHERE
  17010. a.is_deleted = 'N'
  17011. AND b.is_deleted = 'N'
  17012. AND a.hospital_id = b.hospital_id
  17013. AND a.behospital_code = b.behospital_code
  17014. AND a.qc_type_id != 0
  17015. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17016. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17017. </if>
  17018. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17019. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17020. </if>
  17021. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17022. <if test="qcResultShortPageVO.startDate != null ">
  17023. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17024. </if>
  17025. <if test="qcResultShortPageVO.endDate != null ">
  17026. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17027. </if>
  17028. </if>
  17029. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17030. <if test="qcResultShortPageVO.startDate != null ">
  17031. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17032. </if>
  17033. <if test="qcResultShortPageVO.endDate != null">
  17034. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17035. </if>
  17036. </if>
  17037. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17038. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17039. </if>
  17040. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17041. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17042. </if>
  17043. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17044. AND c.`level` = #{qcResultShortPageVO.level}
  17045. </if>
  17046. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17047. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17048. </if>
  17049. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17050. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17051. </if>
  17052. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17053. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17054. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17055. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17056. </if>
  17057. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17058. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17059. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17060. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17061. </if>
  17062. ) be
  17063. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17064. AND mci.check_type in(0,2)
  17065. AND be.hospital_id = mci.hospital_id
  17066. AND be.behospital_code = mci.behospital_code
  17067. LEFT JOIN med_qcresult_cases e
  17068. on be.behospital_code = e.behospital_code
  17069. and be.hospital_id = e.hospital_id
  17070. AND e.is_deleted = 'N'
  17071. and e.cases_id = 243
  17072. ) t1
  17073. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17074. AND t1.behospital_code = t2.behospital_code
  17075. AND t2.is_deleted = 'N'
  17076. ) t
  17077. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17078. AND t.hospitalId = qi.hospital_id
  17079. AND t.behospitalCode = qi.behospital_code
  17080. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17081. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17082. AND t.hospitalId = qd.hospital_id
  17083. AND t.behospitalCode = qd.behospital_code
  17084. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17085. AND qd.cases_id = qc.id
  17086. </if>
  17087. where 1=1
  17088. <if test="qcResultShortPageVO.checkStatus != null">
  17089. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17090. </if>
  17091. <if test="qcResultShortPageVO.mrStatus != null">
  17092. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17093. </if>
  17094. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17095. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17096. </if>
  17097. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17098. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17099. </if>
  17100. <if test="qcResultShortPageVO.chTimeStart != null ">
  17101. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17102. </if>
  17103. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17104. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17105. </if>
  17106. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17107. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17108. </if>
  17109. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17110. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17111. </if>
  17112. )f1,
  17113. (SELECT
  17114. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17115. t.behDeptId,
  17116. t.behDeptName
  17117. FROM
  17118. (
  17119. SELECT DISTINCT
  17120. t1.hospital_id AS hospitalId,
  17121. t1.behospital_code AS behospitalCode,
  17122. t1.bed_code AS bedCode,
  17123. t1.LEVEL AS LEVEL,
  17124. t1.grade_type AS gradeType,
  17125. t1.score_res AS scoreRes,
  17126. t1.NAME AS NAME,
  17127. t1.sex AS sex,
  17128. t1.beh_dept_id AS behDeptId,
  17129. t1.beh_dept_name AS behDeptName,
  17130. t1.doctor_id AS doctorId,
  17131. t1.doctor_name AS doctorName,
  17132. t1.beh_doctor_id AS behDoctorId,
  17133. t1.beh_doctor_name AS behDoctorName,
  17134. t1.director_doctor_id AS directorDoctorId,
  17135. t1.director_doctor_name AS directorDoctorName,
  17136. t1.birthday AS birthday,
  17137. t1.behospital_date AS behospitalDate,
  17138. t1.leave_hospital_date AS leaveHospitalDate,
  17139. t1.placefile_date AS placefileDate,
  17140. t1.gmt_create AS gradeTime,
  17141. t1.diagnose,
  17142. t1.ward_name AS wardName,
  17143. t2.age,
  17144. t1.file_code AS fileCode,
  17145. t1.checkStatus,
  17146. t1.chName,
  17147. t1.chTime
  17148. FROM
  17149. (
  17150. SELECT
  17151. be.*,
  17152. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17153. mci.check_name AS chName,
  17154. mci.gmt_create AS chTime
  17155. FROM
  17156. (
  17157. SELECT DISTINCT
  17158. a.hospital_id,
  17159. a.behospital_code,
  17160. a.bed_code,
  17161. a.file_code,
  17162. b.LEVEL,
  17163. b.grade_type,
  17164. b.score_res,
  17165. a.NAME,
  17166. a.sex,
  17167. a.beh_dept_id,
  17168. a.beh_dept_name,
  17169. a.birthday,
  17170. a.behospital_date,
  17171. a.leave_hospital_date,
  17172. a.doctor_id,
  17173. a.doctor_name,
  17174. a.beh_doctor_id,
  17175. a.beh_doctor_name,
  17176. a.director_doctor_id,
  17177. a.director_doctor_name,
  17178. a.diagnose,
  17179. a.placefile_date,
  17180. a.ward_name,
  17181. b.gmt_create
  17182. FROM
  17183. med_behospital_info a,
  17184. med_qcresult_info b
  17185. WHERE
  17186. a.is_deleted = 'N'
  17187. AND b.is_deleted = 'N'
  17188. AND a.hospital_id = b.hospital_id
  17189. AND a.behospital_code = b.behospital_code
  17190. AND a.qc_type_id != 0
  17191. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17192. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17193. </if>
  17194. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17195. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17196. </if>
  17197. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17198. <if test="qcResultShortPageVO.startDate != null ">
  17199. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17200. </if>
  17201. <if test="qcResultShortPageVO.endDate != null ">
  17202. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17203. </if>
  17204. </if>
  17205. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17206. <if test="qcResultShortPageVO.startDate != null ">
  17207. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17208. </if>
  17209. <if test="qcResultShortPageVO.endDate != null">
  17210. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17211. </if>
  17212. </if>
  17213. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17214. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17215. </if>
  17216. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17217. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17218. </if>
  17219. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17220. AND c.`level` = #{qcResultShortPageVO.level}
  17221. </if>
  17222. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17223. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17224. </if>
  17225. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17226. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17227. </if>
  17228. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17229. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17230. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17231. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17232. </if>
  17233. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17234. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17235. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17236. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17237. </if>
  17238. ) be
  17239. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17240. AND mci.check_type in(0,2)
  17241. AND be.hospital_id = mci.hospital_id
  17242. AND be.behospital_code = mci.behospital_code
  17243. ) t1
  17244. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17245. AND t1.behospital_code = t2.behospital_code
  17246. AND t2.is_deleted = 'N'
  17247. ) t
  17248. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17249. AND t.hospitalId = qi.hospital_id
  17250. AND t.behospitalCode = qi.behospital_code
  17251. where 1=1
  17252. <if test="qcResultShortPageVO.checkStatus != null">
  17253. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17254. </if>
  17255. <if test="qcResultShortPageVO.mrStatus != null">
  17256. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17257. </if>
  17258. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17259. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17260. </if>
  17261. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17262. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17263. </if>
  17264. <if test="qcResultShortPageVO.chTimeStart != null ">
  17265. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17266. </if>
  17267. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17268. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17269. </if>
  17270. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17271. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17272. </if>
  17273. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17274. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17275. </if>
  17276. GROUP BY
  17277. t.behDeptId,
  17278. t.behDeptName
  17279. )f2
  17280. WHERE
  17281. f1.behDeptId = f2.behDeptId
  17282. AND f1.behDeptName = f2.behDeptName
  17283. </select>
  17284. <!-- 质控核查质控评分页导出 -科室-->
  17285. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  17286. SELECT
  17287. f1.behDeptId,
  17288. f1.behDeptName,
  17289. f1.doctorName,
  17290. f1.doctorId,
  17291. f1.patName,
  17292. f1.behospitalCode,
  17293. f1.hospitalId,
  17294. f1.behospitalDate,
  17295. f1.leaveHospitalDate,
  17296. f1.score,
  17297. f1.scoreBn,
  17298. f2.avgScore,
  17299. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17300. f1.msg,
  17301. f1.caseName,
  17302. </if>
  17303. f1.checkStatus,
  17304. f1.mrStatus,
  17305. f1.chName,
  17306. f1.mrName,
  17307. f1.chTime,
  17308. f1.mrTime
  17309. FROM
  17310. (SELECT
  17311. t.doctorName,
  17312. t.doctorId,
  17313. t.`name` AS patName,
  17314. t.behospitalCode AS behospitalCode,
  17315. t.behospitalDate AS behospitalDate,
  17316. t.leaveHospitalDate AS leaveHospitalDate,
  17317. qi.score_res AS score,
  17318. t.scoreBn,
  17319. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17320. qd.msg AS msg,
  17321. qc.NAME AS caseName,
  17322. </if>
  17323. t.behDeptId,
  17324. t.behDeptName,
  17325. t.hospitalId,
  17326. t.checkStatus,
  17327. t.mrStatus,
  17328. t.chName,
  17329. t.mrName,
  17330. t.chTime,
  17331. t.mrTime
  17332. FROM
  17333. (
  17334. SELECT DISTINCT
  17335. t1.hospital_id AS hospitalId,
  17336. t1.behospital_code AS behospitalCode,
  17337. t1.bed_code AS bedCode,
  17338. t1.LEVEL AS LEVEL,
  17339. t1.grade_type AS gradeType,
  17340. t1.score_res AS scoreRes,
  17341. t1.scoreBn,
  17342. t1.NAME AS NAME,
  17343. t1.sex AS sex,
  17344. t1.beh_dept_id AS behDeptId,
  17345. t1.beh_dept_name AS behDeptName,
  17346. t1.doctor_id AS doctorId,
  17347. t1.doctor_name AS doctorName,
  17348. t1.beh_doctor_id AS behDoctorId,
  17349. t1.beh_doctor_name AS behDoctorName,
  17350. t1.director_doctor_id AS directorDoctorId,
  17351. t1.director_doctor_name AS directorDoctorName,
  17352. t1.birthday AS birthday,
  17353. t1.behospital_date AS behospitalDate,
  17354. t1.leave_hospital_date AS leaveHospitalDate,
  17355. t1.placefile_date AS placefileDate,
  17356. t1.gmt_create AS gradeTime,
  17357. t1.diagnose,
  17358. t1.ward_name AS wardName,
  17359. t2.age,
  17360. t1.file_code AS fileCode,
  17361. t1.checkStatus,
  17362. t1.mrStatus,
  17363. t1.chName,
  17364. t1.mrName,
  17365. t1.chTime,
  17366. t1.mrTime
  17367. FROM
  17368. (
  17369. SELECT
  17370. be.*,
  17371. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17372. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17373. mci.check_name AS chName,
  17374. e.score_res as scoreBn,
  17375. hm_mci.check_name AS mrName,
  17376. mci.gmt_create AS chTime,
  17377. hm_mci.gmt_create AS mrTime
  17378. FROM
  17379. (
  17380. SELECT DISTINCT
  17381. a.hospital_id,
  17382. a.behospital_code,
  17383. a.bed_code,
  17384. a.file_code,
  17385. b.LEVEL,
  17386. b.grade_type,
  17387. b.score_res,
  17388. a.NAME,
  17389. a.sex,
  17390. a.beh_dept_id,
  17391. a.beh_dept_name,
  17392. a.birthday,
  17393. a.behospital_date,
  17394. a.leave_hospital_date,
  17395. a.doctor_id,
  17396. a.doctor_name,
  17397. a.beh_doctor_id,
  17398. a.beh_doctor_name,
  17399. a.director_doctor_id,
  17400. a.director_doctor_name,
  17401. a.diagnose,
  17402. a.placefile_date,
  17403. a.ward_name,
  17404. b.gmt_create
  17405. FROM
  17406. med_behospital_info a,
  17407. med_qcresult_info b,
  17408. sys_user_dept c
  17409. WHERE
  17410. a.is_deleted = 'N'
  17411. AND b.is_deleted = 'N'
  17412. AND c.is_deleted = 'N'
  17413. AND a.hospital_id = b.hospital_id
  17414. AND a.hospital_id = c.hospital_id
  17415. AND a.behospital_code = b.behospital_code
  17416. AND a.beh_dept_id = c.dept_id
  17417. AND a.qc_type_id != 0
  17418. <if test="qcResultShortPageVO.userId!=null">
  17419. AND c.user_id = #{qcResultShortPageVO.userId}
  17420. </if>
  17421. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17422. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17423. </if>
  17424. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17425. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17426. </if>
  17427. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17428. <if test="qcResultShortPageVO.startDate != null ">
  17429. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17430. </if>
  17431. <if test="qcResultShortPageVO.endDate != null ">
  17432. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17433. </if>
  17434. </if>
  17435. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17436. <if test="qcResultShortPageVO.startDate != null ">
  17437. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17438. </if>
  17439. <if test="qcResultShortPageVO.endDate != null">
  17440. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17441. </if>
  17442. </if>
  17443. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17444. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17445. </if>
  17446. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17447. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17448. </if>
  17449. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17450. AND c.`level` = #{qcResultShortPageVO.level}
  17451. </if>
  17452. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17453. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17454. </if>
  17455. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17456. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17457. </if>
  17458. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17459. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17460. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17461. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17462. </if>
  17463. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17464. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17465. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17466. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17467. </if>
  17468. ) be
  17469. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17470. AND mci.check_type = 0
  17471. AND be.hospital_id = mci.hospital_id
  17472. AND be.behospital_code = mci.behospital_code
  17473. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17474. AND hm_mci.check_type = 1
  17475. AND be.hospital_id = hm_mci.hospital_id
  17476. AND be.behospital_code = hm_mci.behospital_code
  17477. LEFT JOIN med_qcresult_cases e
  17478. on be.behospital_code = e.behospital_code
  17479. and be.hospital_id = e.hospital_id
  17480. AND e.is_deleted = 'N'
  17481. and e.cases_id = 243
  17482. ) t1
  17483. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17484. AND t1.behospital_code = t2.behospital_code
  17485. AND t2.is_deleted = 'N'
  17486. ) t
  17487. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17488. AND t.hospitalId = qi.hospital_id
  17489. AND t.behospitalCode = qi.behospital_code
  17490. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17491. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17492. AND t.hospitalId = qd.hospital_id
  17493. AND t.behospitalCode = qd.behospital_code
  17494. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17495. AND qd.cases_id = qc.id
  17496. </if>
  17497. where 1=1
  17498. <if test="qcResultShortPageVO.checkStatus != null">
  17499. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17500. </if>
  17501. <if test="qcResultShortPageVO.mrStatus != null">
  17502. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17503. </if>
  17504. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17505. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17506. </if>
  17507. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17508. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17509. </if>
  17510. <if test="qcResultShortPageVO.chTimeStart != null ">
  17511. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17512. </if>
  17513. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17514. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17515. </if>
  17516. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17517. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17518. </if>
  17519. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17520. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17521. </if>
  17522. )f1,
  17523. (SELECT
  17524. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17525. t.behDeptId,
  17526. t.behDeptName,
  17527. t.doctorId,
  17528. t.doctorName
  17529. FROM
  17530. (
  17531. SELECT DISTINCT
  17532. t1.hospital_id AS hospitalId,
  17533. t1.behospital_code AS behospitalCode,
  17534. t1.bed_code AS bedCode,
  17535. t1.LEVEL AS LEVEL,
  17536. t1.grade_type AS gradeType,
  17537. t1.score_res AS scoreRes,
  17538. t1.NAME AS NAME,
  17539. t1.sex AS sex,
  17540. t1.beh_dept_id AS behDeptId,
  17541. t1.beh_dept_name AS behDeptName,
  17542. t1.doctor_id AS doctorId,
  17543. t1.doctor_name AS doctorName,
  17544. t1.beh_doctor_id AS behDoctorId,
  17545. t1.beh_doctor_name AS behDoctorName,
  17546. t1.director_doctor_id AS directorDoctorId,
  17547. t1.director_doctor_name AS directorDoctorName,
  17548. t1.birthday AS birthday,
  17549. t1.behospital_date AS behospitalDate,
  17550. t1.leave_hospital_date AS leaveHospitalDate,
  17551. t1.placefile_date AS placefileDate,
  17552. t1.gmt_create AS gradeTime,
  17553. t1.diagnose,
  17554. t1.ward_name AS wardName,
  17555. t2.age,
  17556. t1.file_code AS fileCode,
  17557. t1.checkStatus,
  17558. t1.mrStatus,
  17559. t1.chName,
  17560. t1.mrName,
  17561. t1.chTime,
  17562. t1.mrTime
  17563. FROM
  17564. (
  17565. SELECT
  17566. be.*,
  17567. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17568. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17569. mci.check_name AS chName,
  17570. hm_mci.check_name AS mrName,
  17571. mci.gmt_create AS chTime,
  17572. hm_mci.gmt_create AS mrTime
  17573. FROM
  17574. (
  17575. SELECT DISTINCT
  17576. a.hospital_id,
  17577. a.behospital_code,
  17578. a.bed_code,
  17579. a.file_code,
  17580. b.LEVEL,
  17581. b.grade_type,
  17582. b.score_res,
  17583. a.NAME,
  17584. a.sex,
  17585. a.beh_dept_id,
  17586. a.beh_dept_name,
  17587. a.birthday,
  17588. a.behospital_date,
  17589. a.leave_hospital_date,
  17590. a.doctor_id,
  17591. a.doctor_name,
  17592. a.beh_doctor_id,
  17593. a.beh_doctor_name,
  17594. a.director_doctor_id,
  17595. a.director_doctor_name,
  17596. a.diagnose,
  17597. a.placefile_date,
  17598. a.ward_name,
  17599. b.gmt_create
  17600. FROM
  17601. med_behospital_info a,
  17602. med_qcresult_info b,
  17603. sys_user_dept c
  17604. WHERE
  17605. a.is_deleted = 'N'
  17606. AND b.is_deleted = 'N'
  17607. AND c.is_deleted = 'N'
  17608. AND a.hospital_id = b.hospital_id
  17609. AND a.hospital_id = c.hospital_id
  17610. AND a.behospital_code = b.behospital_code
  17611. AND a.beh_dept_id = c.dept_id
  17612. AND a.qc_type_id != 0
  17613. <if test="qcResultShortPageVO.userId!=null">
  17614. AND c.user_id = #{qcResultShortPageVO.userId}
  17615. </if>
  17616. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17617. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17618. </if>
  17619. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17620. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17621. </if>
  17622. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17623. <if test="qcResultShortPageVO.startDate != null ">
  17624. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17625. </if>
  17626. <if test="qcResultShortPageVO.endDate != null ">
  17627. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17628. </if>
  17629. </if>
  17630. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17631. <if test="qcResultShortPageVO.startDate != null ">
  17632. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17633. </if>
  17634. <if test="qcResultShortPageVO.endDate != null">
  17635. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17636. </if>
  17637. </if>
  17638. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17639. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17640. </if>
  17641. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17642. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17643. </if>
  17644. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17645. AND c.`level` = #{qcResultShortPageVO.level}
  17646. </if>
  17647. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17648. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17649. </if>
  17650. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17651. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17652. </if>
  17653. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17654. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17655. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17656. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17657. </if>
  17658. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17659. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17660. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17661. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17662. </if>
  17663. ) be
  17664. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17665. AND mci.check_type = 0
  17666. AND be.hospital_id = mci.hospital_id
  17667. AND be.behospital_code = mci.behospital_code
  17668. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17669. AND hm_mci.check_type = 1
  17670. AND be.hospital_id = hm_mci.hospital_id
  17671. AND be.behospital_code = hm_mci.behospital_code
  17672. ) t1
  17673. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17674. AND t1.behospital_code = t2.behospital_code
  17675. AND t2.is_deleted = 'N'
  17676. ) t
  17677. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17678. AND t.hospitalId = qi.hospital_id
  17679. AND t.behospitalCode = qi.behospital_code
  17680. where 1=1
  17681. <if test="qcResultShortPageVO.checkStatus != null">
  17682. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17683. </if>
  17684. <if test="qcResultShortPageVO.mrStatus != null">
  17685. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17686. </if>
  17687. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17688. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17689. </if>
  17690. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17691. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17692. </if>
  17693. <if test="qcResultShortPageVO.chTimeStart != null ">
  17694. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17695. </if>
  17696. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17697. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17698. </if>
  17699. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17700. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17701. </if>
  17702. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17703. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17704. </if>
  17705. GROUP BY
  17706. t.doctorId,
  17707. t.doctorName
  17708. )f2
  17709. WHERE
  17710. f1.doctorId = f2.doctorId
  17711. AND f1.doctorName = f2.doctorName
  17712. </select>
  17713. <!-- 入院,手术,出院病案情况-->
  17714. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17715. SELECT
  17716. count(
  17717. DISTINCT
  17718. CASE
  17719. WHEN q.type=5 THEN
  17720. a.behospital_code
  17721. ELSE
  17722. NULL
  17723. END
  17724. ) AS 'operationNote',
  17725. count(
  17726. DISTINCT
  17727. CASE
  17728. WHEN q.type = 4 THEN
  17729. a.behospital_code
  17730. ELSE
  17731. NULL
  17732. END
  17733. ) AS 'residentAdmitNote',
  17734. count(
  17735. DISTINCT
  17736. CASE
  17737. WHEN q.type = 6 THEN
  17738. a.behospital_code
  17739. ELSE
  17740. NULL
  17741. END
  17742. ) AS 'dischargeRecord',
  17743. count(
  17744. DISTINCT
  17745. CASE
  17746. WHEN q.type = 7 THEN
  17747. a.behospital_code
  17748. ELSE
  17749. NULL
  17750. END
  17751. ) AS 'medicalRecord'
  17752. FROM
  17753. (
  17754. SELECT
  17755. a.behospital_code,
  17756. a.cases_entry_id,
  17757. a.hospital_id
  17758. FROM
  17759. (
  17760. SELECT
  17761. a.behospital_code,
  17762. c.cases_entry_id,
  17763. a.hospital_id
  17764. FROM
  17765. (
  17766. SELECT
  17767. a.behospital_code,
  17768. a.hospital_id
  17769. FROM
  17770. med_behospital_info a,
  17771. med_qcresult_info c
  17772. WHERE
  17773. a.is_deleted = 'N'
  17774. AND c.is_deleted = 'N'
  17775. AND a.is_placefile = #{filterVO.isPlacefile}
  17776. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17777. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17778. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17779. </if>
  17780. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17781. AND a.behospital_code = c.behospital_code
  17782. AND a.hospital_id = #{filterVO.hospitalId}
  17783. AND a.hospital_id = c.hospital_id
  17784. ) a
  17785. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  17786. AND a.behospital_code = c.behospital_code
  17787. AND a.hospital_id = c.hospital_id
  17788. ) a
  17789. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  17790. AND d.is_deleted = 'N'
  17791. ) a
  17792. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  17793. AND a.hospital_id = q.hospital_id
  17794. </select>
  17795. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  17796. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17797. select
  17798. d.behospital_code behospitalCode,
  17799. b.operation_fee operationFee,
  17800. b.pathology_fee pathologyFee,
  17801. b.antibiosis_fee antibiosisFee
  17802. FROM
  17803. (
  17804. SELECT
  17805. a.behospital_code,
  17806. a.hospital_id,
  17807. a.behospital_date,
  17808. a.leave_hospital_date
  17809. FROM
  17810. med_behospital_info a,
  17811. med_qcresult_info c
  17812. WHERE
  17813. a.is_deleted = 'N'
  17814. AND c.is_deleted = 'N'
  17815. AND a.is_placefile = #{filterVO.isPlacefile}
  17816. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17817. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17818. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17819. </if>
  17820. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17821. AND a.hospital_id = c.hospital_id
  17822. AND a.hospital_id = #{filterVO.hospitalId}
  17823. and a.behospital_code = c.behospital_code
  17824. ) d
  17825. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  17826. AND d.hospital_id = b.hospital_id
  17827. AND b.is_deleted = 'N'
  17828. </select>
  17829. <!-- 关于触发规则不符合人数-->
  17830. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17831. SELECT
  17832. count(
  17833. DISTINCT
  17834. CASE
  17835. WHEN a.type=5 THEN
  17836. a.behospital_code
  17837. ELSE
  17838. NULL
  17839. END
  17840. ) AS 'operationNote',
  17841. count(
  17842. DISTINCT
  17843. CASE
  17844. WHEN a.type = 4 THEN
  17845. a.behospital_code
  17846. ELSE
  17847. NULL
  17848. END
  17849. ) AS 'residentAdmitNote',
  17850. count(
  17851. DISTINCT
  17852. CASE
  17853. WHEN a.type = 6 THEN
  17854. a.behospital_code
  17855. ELSE
  17856. NULL
  17857. END
  17858. ) AS 'dischargeRecord',
  17859. count(
  17860. DISTINCT
  17861. CASE
  17862. WHEN a.type = 7 THEN
  17863. a.behospital_code
  17864. ELSE
  17865. NULL
  17866. END
  17867. ) AS 'medicalRecord',
  17868. count(
  17869. DISTINCT
  17870. CASE
  17871. WHEN a.type=8 THEN
  17872. a.behospital_code
  17873. ELSE
  17874. NULL
  17875. END
  17876. ) AS 'CT',
  17877. count(
  17878. DISTINCT
  17879. CASE
  17880. WHEN a.type = 9 THEN
  17881. a.behospital_code
  17882. ELSE
  17883. NULL
  17884. END
  17885. ) AS 'MR',
  17886. count(
  17887. DISTINCT
  17888. CASE
  17889. WHEN a.type = 10 THEN
  17890. a.behospital_code
  17891. ELSE
  17892. NULL
  17893. END
  17894. ) AS 'operationPathologyFee',
  17895. count(
  17896. DISTINCT
  17897. CASE
  17898. WHEN a.type = 11 THEN
  17899. a.behospital_code
  17900. ELSE
  17901. NULL
  17902. END
  17903. ) AS 'bacterialCulture',
  17904. count(
  17905. DISTINCT
  17906. CASE
  17907. WHEN a.type = 12 THEN
  17908. a.behospital_code
  17909. ELSE
  17910. NULL
  17911. END
  17912. ) AS 'antibiosis',
  17913. count(
  17914. DISTINCT
  17915. CASE
  17916. WHEN a.type = 13 THEN
  17917. a.behospital_code
  17918. ELSE
  17919. NULL
  17920. END
  17921. ) AS 'chemotherapyMalignantTumors',
  17922. count(
  17923. DISTINCT
  17924. CASE
  17925. WHEN a.type = 15 THEN
  17926. a.behospital_code
  17927. ELSE
  17928. NULL
  17929. END
  17930. ) AS 'operationRecordNum',
  17931. count(
  17932. DISTINCT
  17933. CASE
  17934. WHEN a.type = 17 THEN
  17935. a.behospital_code
  17936. ELSE
  17937. NULL
  17938. END
  17939. ) AS 'bloodNum',
  17940. count(
  17941. DISTINCT
  17942. CASE
  17943. WHEN a.type = 18 THEN
  17944. a.behospital_code
  17945. ELSE
  17946. NULL
  17947. END
  17948. ) AS 'WardRoundNum',
  17949. count(
  17950. DISTINCT
  17951. CASE
  17952. WHEN a.type = 19 THEN
  17953. a.behospital_code
  17954. ELSE
  17955. NULL
  17956. END
  17957. ) AS 'rescueNum',
  17958. count(
  17959. DISTINCT
  17960. CASE
  17961. WHEN a.type = 22 THEN
  17962. a.behospital_code
  17963. ELSE
  17964. NULL
  17965. END
  17966. ) AS 'unreasonedCopyNum',
  17967. count(
  17968. DISTINCT
  17969. CASE
  17970. WHEN a.type = 14 THEN
  17971. a.behospital_code
  17972. ELSE
  17973. NULL
  17974. END
  17975. ) AS 'tumorRadiationNum',
  17976. count(
  17977. DISTINCT
  17978. CASE
  17979. WHEN a.type = 16 THEN
  17980. a.behospital_code
  17981. ELSE
  17982. NULL
  17983. END
  17984. ) AS 'implantsNum',
  17985. count(
  17986. DISTINCT
  17987. CASE
  17988. WHEN a.type = 23 THEN
  17989. a.behospital_code
  17990. ELSE
  17991. NULL
  17992. END
  17993. ) AS 'InformedNum'
  17994. FROM
  17995. (
  17996. SELECT
  17997. a.behospital_code,
  17998. a.hospital_id,
  17999. q.type
  18000. FROM
  18001. (
  18002. SELECT
  18003. a.behospital_code,
  18004. a.cases_entry_id,
  18005. a.hospital_id
  18006. FROM
  18007. (
  18008. SELECT
  18009. a.behospital_code,
  18010. c.cases_entry_id,
  18011. a.hospital_id
  18012. FROM
  18013. (
  18014. SELECT
  18015. a.behospital_code,
  18016. a.hospital_id
  18017. FROM
  18018. med_behospital_info a,
  18019. med_qcresult_info c
  18020. WHERE
  18021. a.is_deleted = 'N'
  18022. AND c.is_deleted = 'N'
  18023. AND a.is_placefile = #{filterVO.isPlacefile}
  18024. <if test="filterVO.startDate != null and filterVO.endDate != null">
  18025. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  18026. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18027. </if>
  18028. AND a.behospital_code = c.behospital_code
  18029. AND a.hospital_id = #{filterVO.hospitalId}
  18030. AND a.hospital_id = c.hospital_id
  18031. ) a
  18032. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  18033. AND a.behospital_code = c.behospital_code
  18034. AND a.hospital_id = c.hospital_id
  18035. ) a
  18036. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  18037. AND d.is_deleted = 'N'
  18038. ) a
  18039. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  18040. AND a.hospital_id = q.hospital_id
  18041. ) a
  18042. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  18043. AND r.relevance_type = a.type
  18044. AND r.is_deleted = 'N'
  18045. AND a.hospital_id = r.hospital_id
  18046. </select>
  18047. <!-- 跟病案首页关联的出院病历-->
  18048. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18049. SELECT
  18050. d.behospital_code,
  18051. d.behospital_date,
  18052. d.leave_hospital_date,
  18053. b.behospital_code AS b_code,
  18054. b.operation_fee,
  18055. b.antibiosis_fee,
  18056. b.pathology_fee
  18057. FROM
  18058. (
  18059. SELECT
  18060. a.behospital_code,
  18061. a.hospital_id,
  18062. a.behospital_date,
  18063. a.leave_hospital_date
  18064. FROM
  18065. med_behospital_info a,
  18066. med_qcresult_info c
  18067. WHERE
  18068. a.behospital_code = c.behospital_code
  18069. AND a.hospital_id = #{filterVO.hospitalId}
  18070. AND a.is_placefile = #{filterVO.isPlacefile}
  18071. AND a.hospital_id = c.hospital_id
  18072. AND a.is_deleted = 'N'
  18073. AND c.is_deleted = 'N'
  18074. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18075. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  18076. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  18077. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18078. </if>
  18079. ) d
  18080. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18081. AND d.hospital_id = b.hospital_id
  18082. AND b.is_deleted = 'N'
  18083. where ISNULL(b.behospital_code)
  18084. </select>
  18085. <!-- 首页恶性肿瘤-->
  18086. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18087. select
  18088. a.behospital_code,
  18089. a.hospital_id,
  18090. d.diagnose_name,
  18091. d.diagnose_type,
  18092. d.icd_code
  18093. from(
  18094. SELECT
  18095. d.behospital_code,
  18096. d.hospital_id,
  18097. b.home_page_id
  18098. FROM
  18099. (
  18100. SELECT
  18101. a.behospital_code,
  18102. a.hospital_id,
  18103. a.behospital_date,
  18104. a.leave_hospital_date
  18105. FROM
  18106. med_behospital_info a,
  18107. med_qcresult_info c
  18108. WHERE
  18109. a.behospital_code = c.behospital_code
  18110. AND a.hospital_id = #{filterVO.hospitalId}
  18111. AND a.is_placefile = #{filterVO.isPlacefile}
  18112. AND a.hospital_id = c.hospital_id
  18113. AND a.is_deleted = 'N'
  18114. AND c.is_deleted = 'N'
  18115. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18116. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  18117. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  18118. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18119. </if>
  18120. ) d
  18121. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18122. AND d.hospital_id = b.hospital_id
  18123. AND b.is_deleted = 'N'
  18124. )a join
  18125. med_home_diagnose_info d on a.hospital_id=d.hospital_id
  18126. where a.home_page_id =d.home_page_id
  18127. and d.is_deleted ='N'
  18128. and d.diagnose_name like '%恶性肿瘤%'
  18129. and d.icd_code like 'C%'
  18130. </select>
  18131. <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
  18132. <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
  18133. SELECT
  18134. mbi.behospital_code behospitalCode,
  18135. mhp.age,
  18136. TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
  18137. TIMESTAMPDIFF(day,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageDay
  18138. FROM
  18139. med_behospital_info mbi
  18140. LEFT JOIN med_home_page mhp
  18141. ON mbi.behospital_code=mhp.behospital_code
  18142. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  18143. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
  18144. <if test="behospitalCodes !=null and behospitalCodes.size > 0">
  18145. and mbi.behospital_code in
  18146. <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
  18147. #{item}
  18148. </foreach>
  18149. </if>
  18150. </select>
  18151. </mapper>