BehospitalInfoMapper.xml 746 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  7. <id column="behospital_code" property="behospitalCode"/>
  8. <result column="hospital_id" property="hospitalId"/>
  9. <result column="name" property="name"/>
  10. <result column="sex" property="sex"/>
  11. <result column="birthday" property="birthday"/>
  12. <result column="file_code" property="fileCode"/>
  13. <result column="qc_type_id" property="qcTypeId"/>
  14. <result column="ward_code" property="wardCode"/>
  15. <result column="ward_name" property="wardName"/>
  16. <result column="beh_dept_id" property="behDeptId"/>
  17. <result column="beh_dept_name" property="behDeptName"/>
  18. <result column="bed_code" property="bedCode"/>
  19. <result column="bed_name" property="bedName"/>
  20. <result column="insurance_name" property="insuranceName"/>
  21. <result column="job_type" property="jobType"/>
  22. <result column="behospital_date" property="behospitalDate"/>
  23. <result column="leave_hospital_date" property="leaveHospitalDate"/>
  24. <result column="diagnose_icd" property="diagnoseIcd"/>
  25. <result column="diagnose" property="diagnose"/>
  26. <result column="beh_doctor_id" property="behDoctorId"/>
  27. <result column="beh_doctor_name" property="behDoctorName"/>
  28. <result column="doctor_id" property="doctorId"/>
  29. <result column="doctor_name" property="doctorName"/>
  30. <result column="director_doctor_id" property="directorDoctorId"/>
  31. <result column="director_doctor_name" property="directorDoctorName"/>
  32. <result column="is_placefile" property="isPlacefile"/>
  33. <result column="placefile_date" property="placefileDate"/>
  34. <result column="is_deleted" property="isDeleted"/>
  35. <result column="gmt_create" property="gmtCreate"/>
  36. <result column="gmt_modified" property="gmtModified"/>
  37. <result column="creator" property="creator"/>
  38. <result column="modifier" property="modifier"/>
  39. <result column="linkman" property="linkman"/>
  40. </resultMap>
  41. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  42. SELECT * FROM (
  43. select t.*,
  44. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  45. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  46. g.check_type AS ch_type,
  47. h.check_type AS mr_type,
  48. g.check_name AS ch_name,
  49. h.check_name AS mr_name,
  50. g.check_time AS ch_time,
  51. h.check_time AS mr_time
  52. from (
  53. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  54. grade_time,IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,e.score_res as score_bn from med_behospital_info a
  55. LEFT JOIN med_qcresult_info b
  56. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  57. left join med_home_page c
  58. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  59. LEFT JOIN med_qcresult_cases e
  60. on a.behospital_code = e.behospital_code
  61. AND e.is_deleted = 'N'
  62. and e.cases_id = 243
  63. ) t
  64. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  65. ON t.behospital_code = g.behospital_code
  66. AND t.hospital_id = g.hospital_id
  67. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  68. ON t.behospital_code = h.behospital_code
  69. AND t.hospital_id = h.hospital_id
  70. where t.is_deleted = 'N'
  71. <if test="diagnose != null and diagnose != ''">
  72. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  73. </if>
  74. <if test="deptName != null and deptName != ''">
  75. and t.beh_dept_name= #{deptName}
  76. </if>
  77. <if test="doctorName != null and doctorName != ''">
  78. and CONCAT(
  79. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  80. like CONCAT('%',#{doctorName},'%')
  81. </if>
  82. <if test="name != null and name != ''">
  83. and t.name like CONCAT('%',#{name},'%')
  84. </if>
  85. <if test="doctorCode != null and doctorCode != ''">
  86. and (t.doctor_id = #{doctorCode}
  87. or t.beh_doctor_id = #{doctorCode}
  88. or t.director_doctor_id = #{doctorCode})
  89. </if>
  90. <if test="fileCode != null and fileCode != ''">
  91. and t.file_code like CONCAT('%',#{fileCode},'%')
  92. </if>
  93. <if test="hospitalId != null">
  94. and t.hospital_id = #{hospitalId}
  95. </if>
  96. <if test="behospitalCode != null and behospitalCode != ''">
  97. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  98. </if>
  99. <if test="behosDateStart != null">
  100. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  101. </if>
  102. <if test="behosDateEnd != null">
  103. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  104. </if>
  105. <if test="leaveHosDateStart != null">
  106. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  107. </if>
  108. <if test="leaveHosDateEnd != null">
  109. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  110. </if>
  111. <if test="level != null and level != ''">
  112. and t.level = #{level}
  113. </if>
  114. <if test="isPlacefile != null and isPlacefile != ''">
  115. and t.is_placefile = #{isPlacefile}
  116. </if>
  117. and t.qc_type_id != 0) p
  118. where p.is_deleted="N"
  119. <if test="checkStatus != null ">
  120. and p.check_status = #{checkStatus}
  121. </if>
  122. <if test="mrStatus != null ">
  123. AND p.mr_status = #{mrStatus}
  124. </if>
  125. <if test="chName != null and chName !=''">
  126. AND p.ch_name like CONCAT('%',#{chName},'%')
  127. </if>
  128. <if test="mrName != null and mrName !=''">
  129. AND p.mr_name like CONCAT('%',#{mrName},'%')
  130. </if>
  131. <if test="chTimeStart != null">
  132. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  133. </if>
  134. <if test="chTimeEnd != null">
  135. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  136. </if>
  137. <if test="mrTimeStart != null">
  138. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  139. </if>
  140. <if test="mrTimeEnd != null">
  141. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  142. </if>
  143. </select>
  144. <select id="getQualityCaseSorce" resultType="com.diagbot.dto.CaseScoreDTO">
  145. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  146. FROM med_qcresult_detail c,med_behospital_info e
  147. where c.is_deleted = 'N'AND e.is_deleted = 'N'
  148. AND c.behospital_code = e.behospital_code
  149. AND c.hospital_id = e.hospital_id
  150. and c.hospital_id = #{hospitalId}
  151. <if test="deptName != null and deptName != ''">
  152. and e.beh_dept_name= #{deptName}
  153. </if>
  154. <if test="behospitalCode != null and behospitalCode != ''">
  155. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  156. </if>
  157. <if test="isPlacefile != null and isPlacefile != ''">
  158. and e.is_placefile = #{isPlacefile}
  159. </if>
  160. <if test="behosDateStart != null">
  161. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  162. </if>
  163. <if test="behosDateEnd != null">
  164. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  165. </if>
  166. <if test="leaveHosDateStart != null">
  167. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  168. </if>
  169. <if test="leaveHosDateEnd != null">
  170. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  171. </if>
  172. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  173. order by c.behospital_code
  174. </select>
  175. <select id="getQualityCaseSorceByDept" resultType="com.diagbot.dto.CaseScoreDTO">
  176. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  177. FROM med_qcresult_detail c,sys_user_dept d,med_behospital_info e
  178. where c.is_deleted = 'N' AND d.is_deleted = 'N' AND e.is_deleted = 'N'
  179. AND c.behospital_code = e.behospital_code
  180. ON d.hospital_id = e.hospital_id
  181. AND e.beh_dept_id = d.dept_id
  182. AND c.hospital_id = e.hospital_id
  183. and c.hospital_id = #{hospitalId}
  184. <if test="deptName != null and deptName != ''">
  185. and e.beh_dept_name= #{deptName}
  186. </if>
  187. <if test="userId != null and userId != ''">
  188. and d.user_id = #{userId}
  189. </if>
  190. <if test="behospitalCode != null and behospitalCode != ''">
  191. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  192. </if>
  193. <if test="isPlacefile != null and isPlacefile != ''">
  194. and e.is_placefile = #{isPlacefile}
  195. </if>
  196. <if test="behosDateStart != null">
  197. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  198. </if>
  199. <if test="behosDateEnd != null">
  200. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  201. </if>
  202. <if test="leaveHosDateStart != null">
  203. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  204. </if>
  205. <if test="leaveHosDateEnd != null">
  206. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  207. </if>
  208. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  209. order by c.behospital_code
  210. </select>
  211. <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  212. SELECT * FROM (
  213. select
  214. distinct
  215. t.name AS NAME,
  216. t.behospital_code AS behospitalCode,
  217. t.doctor_name AS doctorName,
  218. t.beh_dept_name AS deptName,
  219. t.beh_dept_id AS deptId,
  220. t.leave_hospital_date AS leaveHospitalDate,
  221. t.level,
  222. t.age,
  223. t.score_res as totalScore,
  224. t.is_deleted,
  225. g.check_name AS chName,
  226. h.check_name AS mrName
  227. from (
  228. select a.*,
  229. ifnull(b.level,'未评分') as level,
  230. b.grade_type,
  231. IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,
  232. b.score_res
  233. from med_behospital_info a
  234. LEFT JOIN med_qcresult_info b
  235. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  236. left join med_home_page c
  237. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  238. ) t
  239. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  240. ON t.behospital_code = g.behospital_code
  241. AND t.hospital_id = g.hospital_id
  242. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  243. ON t.behospital_code = h.behospital_code
  244. AND t.hospital_id = h.hospital_id
  245. where t.is_deleted = 'N'
  246. <if test="diagnose != null and diagnose != ''">
  247. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  248. </if>
  249. <if test="deptName != null and deptName != ''">
  250. and t.beh_dept_name= #{deptName}
  251. </if>
  252. <if test="doctorName != null and doctorName != ''">
  253. and CONCAT(
  254. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  255. like CONCAT('%',#{doctorName},'%')
  256. </if>
  257. <if test="name != null and name != ''">
  258. and t.name like CONCAT('%',#{name},'%')
  259. </if>
  260. <if test="doctorCode != null and doctorCode != ''">
  261. and (t.doctor_id = #{doctorCode}
  262. or t.beh_doctor_id = #{doctorCode}
  263. or t.director_doctor_id = #{doctorCode})
  264. </if>
  265. <if test="fileCode != null and fileCode != ''">
  266. and t.file_code like CONCAT('%',#{fileCode},'%')
  267. </if>
  268. <if test="hospitalId != null">
  269. and t.hospital_id = #{hospitalId}
  270. </if>
  271. <if test="behospitalCode != null and behospitalCode != ''">
  272. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  273. </if>
  274. <if test="behosDateStart != null">
  275. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  276. </if>
  277. <if test="behosDateEnd != null">
  278. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  279. </if>
  280. <if test="leaveHosDateStart != null">
  281. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  282. </if>
  283. <if test="leaveHosDateEnd != null">
  284. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  285. </if>
  286. <if test="level != null and level != ''">
  287. and t.level = #{level}
  288. </if>
  289. <if test="isPlacefile != null and isPlacefile != ''">
  290. and t.is_placefile = #{isPlacefile}
  291. </if>
  292. and t.qc_type_id != 0) p
  293. where p.is_deleted="N"
  294. <if test="chName != null and chName !=''">
  295. AND p.chName like CONCAT('%',#{chName},'%')
  296. </if>
  297. <if test="mrName != null and mrName !=''">
  298. AND p.mrName like CONCAT('%',#{mrName},'%')
  299. </if>
  300. </select>
  301. <select id="qualityControlByDept" resultType="com.diagbot.dto.QualityControlDeptDTO">
  302. SELECT * FROM (
  303. select
  304. distinct
  305. t.name AS NAME,
  306. t.behospital_code AS behospitalCode,
  307. t.doctor_name AS doctorName,
  308. t.beh_dept_name AS deptName,
  309. t.beh_dept_id AS deptId,
  310. t.leave_hospital_date AS leaveHospitalDate,
  311. t.level,
  312. t.age,
  313. t.score_res as totalScore,
  314. t.is_deleted,
  315. g.check_name AS chName,
  316. h.check_name AS mrName
  317. from (
  318. select a.*, ifnull(b.level,'未评分') as level, IF(c.age is null, null,CONCAT( ifnull(c.age,''),ifnull(c.age_unit,'') ))as age, b.grade_type,d.user_id, b.score_res, b.gmt_create as
  319. grade_time from med_behospital_info a
  320. LEFT JOIN med_qcresult_info b
  321. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  322. left join med_home_page c
  323. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  324. LEFT JOIN sys_user_dept d
  325. ON a.hospital_id = d.hospital_id
  326. AND a.beh_dept_id = d.dept_id
  327. ) t
  328. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  329. ON t.behospital_code = g.behospital_code
  330. AND t.hospital_id = g.hospital_id
  331. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  332. ON t.behospital_code = h.behospital_code
  333. AND t.hospital_id = h.hospital_id
  334. where t.is_deleted = 'N'
  335. AND t.user_id = #{userId}
  336. <if test="diagnose != null and diagnose != ''">
  337. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  338. </if>
  339. <if test="deptName != null and deptName != ''">
  340. and t.beh_dept_name= #{deptName}
  341. </if>
  342. <if test="doctorName != null and doctorName != ''">
  343. and CONCAT(
  344. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  345. like CONCAT('%',#{doctorName},'%')
  346. </if>
  347. <if test="name != null and name != ''">
  348. and t.name like CONCAT('%',#{name},'%')
  349. </if>
  350. <if test="doctorCode != null and doctorCode != ''">
  351. and (t.doctor_id = #{doctorCode}
  352. or t.beh_doctor_id = #{doctorCode}
  353. or t.director_doctor_id = #{doctorCode})
  354. </if>
  355. <if test="fileCode != null and fileCode != ''">
  356. and t.file_code like CONCAT('%',#{fileCode},'%')
  357. </if>
  358. <if test="hospitalId != null">
  359. and t.hospital_id = #{hospitalId}
  360. </if>
  361. <if test="behospitalCode != null and behospitalCode != ''">
  362. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  363. </if>
  364. <if test="behosDateStart != null">
  365. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  366. </if>
  367. <if test="behosDateEnd != null">
  368. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  369. </if>
  370. <if test="leaveHosDateStart != null">
  371. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  372. </if>
  373. <if test="leaveHosDateEnd != null">
  374. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  375. </if>
  376. <if test="level != null and level != ''">
  377. and t.level = #{level}
  378. </if>
  379. <if test="isPlacefile != null and isPlacefile != ''">
  380. and t.is_placefile = #{isPlacefile}
  381. </if>
  382. and t.qc_type_id != 0) p
  383. where p.is_deleted="N"
  384. <if test="chName != null and chName !=''">
  385. AND p.chName like CONCAT('%',#{chName},'%')
  386. </if>
  387. <if test="mrName != null and mrName !=''">
  388. AND p.mrName like CONCAT('%',#{mrName},'%')
  389. </if>
  390. </select>
  391. <!-- <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  392. SELECT m.* FROM(
  393. SELECT
  394. a.name AS NAME,
  395. a.behospital_code AS behospitalCode,
  396. a.doctor_name AS doctorName,
  397. a.beh_dept_name AS deptName,
  398. a.beh_dept_id AS deptId,
  399. a.leave_hospital_date AS leaveHospitalDate,
  400. c.behospital_code,
  401. c.hospital_id,
  402. c.admissionNote,
  403. c.firstCourseNote,
  404. c.medHomePage,
  405. c.docAdviceNote,
  406. c.courseRecord,
  407. c.operationInfo,
  408. c.dischargeNote,
  409. c.admissionNoteScore,
  410. c.firstCourseNoteScore,
  411. c. medHomePageScore,
  412. c.docAdviceNoteScore,
  413. c.courseRecordScore,
  414. c.operationInfoScore,
  415. c.dischargeNoteScore,
  416. c.otherCase,
  417. (100.0-c.score_res) AS otherCaseScore,
  418. IFNULL(b.level,'未评分') AS `level`,
  419. g.check_name AS ch_name,
  420. h.check_name AS mr_name
  421. FROM
  422. med_behospital_info a LEFT JOIN med_qcresult_info b
  423. ON a.behospital_code = b.behospital_code AND b.is_deleted = 'N'
  424. LEFT JOIN (
  425. SELECT
  426. t.behospital_code,
  427. t.hospital_id,
  428. t.admissionNote,
  429. t.firstCourseNote,
  430. t.medHomePage,
  431. t.docAdviceNote,
  432. t.courseRecord,
  433. t.operationInfo,
  434. t.dischargeNote,
  435. t.otherCase,
  436. t.score_res,
  437. if(t.admissionNoteScoreOn >= t.admissionNoteTolScore, (t.admissionNoteTolScore + t.admissionNoteScoreTh),(t.admissionNoteScoreOn + t.admissionNoteScoreTh)) AS admissionNoteScore,
  438. if(t.firstCourseNoteScoreOn >= t.firstCourseNoteTolScore, (t.firstCourseNoteTolScore + t.firstCourseNoteScoreTh),(t.firstCourseNoteScoreOn + t.firstCourseNoteScoreTh)) AS firstCourseNoteScore,
  439. if(t.medHomePageScoreOn >= t.medHomePageTolScore, (t.medHomePageTolScore + t.medHomePageScoreTh),(t.medHomePageScoreOn + t.medHomePageScoreTh)) AS medHomePageScore,
  440. if(t.docAdviceNoteScoreOn >= t.docAdviceNoteTolScore, (t.docAdviceNoteTolScore + t.docAdviceNoteScoreTh),(t.docAdviceNoteScoreOn + t.docAdviceNoteScoreTh)) AS docAdviceNoteScore,
  441. if(t.courseRecordScoreOn >= t.courseRecordTolScore, (t.courseRecordTolScore + t.courseRecordScoreTh),(t.courseRecordScoreOn + t.courseRecordScoreTh)) AS courseRecordScore,
  442. if(t.operationInfoScoreOn >= t.operationInfoTolScore, (t.operationInfoTolScore + t.operationInfoScoreTh),(t.operationInfoScoreOn + t.operationInfoScoreTh)) AS operationInfoScore,
  443. if(t.dischargeNoteScoreOn >= t.dischargeNoteTolScore, (t.dischargeNoteTolScore + t.dischargeNoteScoreTh),(t.dischargeNoteScoreOn + t.dischargeNoteScoreTh)) AS dischargeNoteScore
  444. from(
  445. select
  446. t1.*,
  447. t2.admissionNoteTolScore,
  448. t2.firstCourseNoteTolScore,
  449. t2.medHomePageTolScore,
  450. t2.docAdviceNoteTolScore,
  451. t2.courseRecordTolScore,
  452. t2.operationInfoTolScore,
  453. t2.dischargeNoteTolScore,
  454. t2.score_res FROM (
  455. SELECT
  456. t1.behospital_code,
  457. t1.hospital_id,
  458. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  459. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  460. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  461. (SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS admissionNoteScoreTh,
  462. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  463. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  464. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  465. (SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) -SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS firstCourseNoteScoreTh,
  466. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  467. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  468. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  469. (SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS medHomePageScoreTh,
  470. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  471. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  472. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  473. (SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS docAdviceNoteScoreTh,
  474. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  475. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  476. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  477. (SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS courseRecordScoreTh,
  478. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  479. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  480. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  481. (SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS operationInfoScoreTh,
  482. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  483. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  484. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  485. (SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END)-GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' )) AS dischargeNoteScoreTh,
  486. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id != 1 AND t1.mode_id != 2 AND t1.mode_id != 6 AND t1.mode_id != 8 AND t1.mode_id != 156 AND t1.mode_id != 17 AND t1.mode_id != 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS otherCase
  487. FROM (
  488. SELECT
  489. c.behospital_code,
  490. c.hospital_id,
  491. a.mode_id,
  492. c.cases_score,
  493. c.score,
  494. c.msg,
  495. c.is_reject,
  496. c.cases_id
  497. FROM
  498. `qc_cases_entry` a,
  499. qc_mode b,
  500. med_qcresult_detail c,
  501. qc_cases_hospital d,
  502. med_behospital_info e
  503. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  504. AND a.id = c.cases_entry_id
  505. AND a.mode_id = b.id
  506. AND c.cases_id = d.cases_id
  507. AND c.hospital_id = d.hospital_id
  508. AND c.behospital_code = e.behospital_code
  509. AND c.hospital_id = e.hospital_id
  510. <if test="hospitalId != null">
  511. and c.hospital_id = #{hospitalId}
  512. </if>
  513. <if test="deptName != null and deptName != ''">
  514. and e.beh_dept_name= #{deptName}
  515. </if>
  516. <if test="behospitalCode != null and behospitalCode != ''">
  517. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  518. </if>
  519. <if test="isPlacefile != null and isPlacefile != ''">
  520. and e.is_placefile = #{isPlacefile}
  521. </if>
  522. <if test="behosDateStart != null">
  523. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  524. </if>
  525. <if test="behosDateEnd != null">
  526. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  527. </if>
  528. <if test="leaveHosDateStart != null">
  529. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  530. </if>
  531. <if test="leaveHosDateEnd != null">
  532. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  533. </if>
  534. <if test="level != null and level != ''">
  535. and e.level = #{level}
  536. </if>
  537. <if test="level != null and level != ''">
  538. and e.level = #{level}
  539. </if>
  540. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  541. )t1 GROUP BY behospital_code)t1
  542. LEFT JOIN (
  543. SELECT m1.*, m2.score_res FROM(
  544. SELECT
  545. m1.hospital_id,
  546. m1.behospital_code,
  547. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  548. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  549. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  550. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  551. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  552. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  553. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  554. FROM (
  555. SELECT
  556. c.behospital_code,
  557. a.mode_id,
  558. c.cases_score,
  559. c.cases_id,
  560. c.hospital_id
  561. FROM
  562. `qc_cases_entry` a,
  563. qc_mode b,
  564. med_qcresult_detail c,
  565. qc_cases_hospital d,
  566. med_behospital_info e
  567. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  568. AND a.id = c.cases_entry_id
  569. AND a.mode_id = b.id
  570. AND c.cases_id = d.cases_id
  571. AND c.hospital_id = d.hospital_id
  572. AND c.behospital_code = e.behospital_code
  573. AND c.hospital_id = e.hospital_id
  574. <if test="hospitalId != null">
  575. and c.hospital_id = #{hospitalId}
  576. </if>
  577. <if test="deptName != null and deptName != ''">
  578. and e.beh_dept_name= #{deptName}
  579. </if>
  580. <if test="behospitalCode != null and behospitalCode != ''">
  581. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  582. </if>
  583. <if test="isPlacefile != null and isPlacefile != ''">
  584. and e.is_placefile = #{isPlacefile}
  585. </if>
  586. <if test="behosDateStart != null">
  587. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  588. </if>
  589. <if test="behosDateEnd != null">
  590. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  591. </if>
  592. <if test="leaveHosDateStart != null">
  593. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  594. </if>
  595. <if test="leaveHosDateEnd != null">
  596. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  597. </if>
  598. <if test="level != null and level != ''">
  599. and e.level = #{level}
  600. </if>
  601. <if test="level != null and level != ''">
  602. and e.level = #{level}
  603. </if>
  604. GROUP BY mode_id
  605. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  606. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  607. ON m2.is_deleted = 'N'
  608. AND m1.hospital_id = m2.hospital_id
  609. AND m1.behospital_code = m2.behospital_code
  610. )t2
  611. ON t1.hospital_id = t2.hospital_id
  612. AND t1.behospital_code = t2.behospital_code)t)c
  613. ON a.behospital_code = c.behospital_code
  614. AND a.hospital_id = c.hospital_id
  615. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  616. ON a.behospital_code = g.behospital_code
  617. AND a.hospital_id = g.hospital_id
  618. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  619. ON a.behospital_code = h.behospital_code
  620. AND a.hospital_id = h.hospital_id
  621. where
  622. a.is_deleted = 'N'
  623. <if test="deptName != null and deptName != ''">
  624. and a.beh_dept_name= #{deptName}
  625. </if>
  626. <if test="doctorName != null and doctorName != ''">
  627. and CONCAT(
  628. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  629. like CONCAT('%',#{doctorName},'%')
  630. </if>
  631. <if test="name != null and name != ''">
  632. and a.name like CONCAT('%',#{name},'%')
  633. </if>
  634. <if test="doctorCode != null and doctorCode != ''">
  635. and (a.doctor_id = #{doctorCode}
  636. or a.beh_doctor_id = #{doctorCode}
  637. or a.director_doctor_id = #{doctorCode})
  638. </if>
  639. <if test="fileCode != null and fileCode != ''">
  640. and a.file_code like CONCAT('%',#{fileCode},'%')
  641. </if>
  642. <if test="hospitalId != null">
  643. and a.hospital_id = #{hospitalId}
  644. </if>
  645. <if test="behospitalCode != null and behospitalCode != ''">
  646. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  647. </if>
  648. <if test="behosDateStart != null">
  649. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  650. </if>
  651. <if test="behosDateEnd != null">
  652. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  653. </if>
  654. <if test="leaveHosDateStart != null">
  655. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  656. </if>
  657. <if test="leaveHosDateEnd != null">
  658. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  659. </if>
  660. <if test="level != null and level != ''">
  661. and a.level = #{level}
  662. </if>
  663. <if test="isPlacefile != null and isPlacefile != ''">
  664. and a.is_placefile = #{isPlacefile}
  665. </if>
  666. and a.qc_type_id != 0
  667. <if test="chName != null and chName !=''">
  668. AND g.ch_name like CONCAT('%',#{chName},'%')
  669. </if>
  670. <if test="mrName != null and mrName !=''">
  671. AND h.mr_name like CONCAT('%',#{mrName},'%')
  672. </if>)m
  673. </select>-->
  674. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  675. SELECT a.*, u.linkman
  676. FROM
  677. (
  678. SELECT DISTINCT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info, a.cases_id cases_id, d.score cases_score,
  679. b.id model_id, a.name standard_msg, c.opt_type, c.grade_type,
  680. c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,c.explain_info as explainInfo,
  681. a.type, a.drgs
  682. FROM
  683. `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  684. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  685. and a.id = c.cases_entry_id and a.mode_id = b.id
  686. AND c.cases_id = d.cases_id and c.hospital_id = d.hospital_id
  687. and c.hospital_id = #{hospitalId}
  688. <if test="qcresultInfoId != null">
  689. AND c.qcresult_info_id = #{qcresultInfoId}
  690. </if>
  691. and c.behospital_code = #{behospitalCode}
  692. order by b.order_no, c.grade_type desc, a.order_no) a
  693. LEFT JOIN sys_user u on u.id = a.modifier and u.is_deleted = 'N'
  694. </select>
  695. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  696. SELECT b.id model_id,b.`name` model_name,
  697. d.score,d.msg,d.cases_entry_id,d.is_reject,
  698. a.cases_id cases_id, a.name standard_msg,a.code
  699. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  700. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  701. and a.mode_id = b.id
  702. and a.id = d.cases_entry_id
  703. and d.is_used = 1
  704. and d.hospital_id = #{hospitalId}
  705. and a.code in
  706. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  707. #{item}
  708. </foreach>
  709. <if test="modeId != null">
  710. and a.mode_id = #{modeId}
  711. </if>
  712. order by b.order_no, a.order_no;
  713. </select>
  714. <!--病案管理指标基础sql明细-->
  715. <select id="getBaseIndex" parameterType="com.diagbot.vo.MedIndexFilterVO" resultType="java.util.Map">
  716. select
  717. f1.firWorkNum,
  718. f2.secWorkNum,
  719. f3.thrWorkNum,
  720. f3.forWorkNum,
  721. f3.sixWorkNum
  722. from (
  723. SELECT count(DISTINCT a.behospital_code) as firWorkNum
  724. FROM
  725. med_behospital_info a
  726. WHERE
  727. a.is_deleted = 'N'
  728. AND a.is_placefile = 1
  729. <if test="hospitalId != null and hospitalId != ''">
  730. AND a.hospital_id = #{hospitalId}
  731. </if>
  732. <![CDATA[AND a.qc_type_id <>0 ]]>
  733. <if test="startDate != null and startDate != ''">
  734. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  735. </if>
  736. <if test="endDate != null and endDate != ''">
  737. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  738. </if>)f1,
  739. ( SELECT count(DISTINCT a.behospital_code) AS secWorkNum
  740. FROM
  741. med_outpatient_info a
  742. WHERE
  743. a.is_deleted = 'N'
  744. <if test="startDate != null and startDate != ''">
  745. <![CDATA[ AND a.visit_date >= #{lastStartDate}]]>
  746. </if>
  747. <if test="endDate != null and endDate != ''">
  748. <![CDATA[ AND a.visit_date <= #{lastEndDate}]]>
  749. </if>
  750. <if test="hospitalId != null and hospitalId != ''">
  751. AND a.hospital_id = #{hospitalId}
  752. </if>)f2,(
  753. select
  754. count(DISTINCT case when <![CDATA[m.behospital_date >= #{startDate}]]> and <![CDATA[m.behospital_date <= #{endDate}]]>
  755. and m.is_placefile = 0 then m.behospital_code else null end) as thrWorkNum,
  756. 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,
  757. 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
  758. from(
  759. SELECT DISTINCT a.*,b.level
  760. FROM
  761. med_behospital_info a,
  762. med_qcresult_info b
  763. WHERE
  764. a.is_deleted = 'N'
  765. AND b.is_deleted = 'N'
  766. AND a.hospital_id = b.hospital_id
  767. AND a.behospital_code = b.behospital_code
  768. <![CDATA[AND a.qc_type_id <>0 ]]>
  769. <if test="hospitalId != null and hospitalId != ''">
  770. AND a.hospital_id = #{hospitalId}
  771. </if>)m
  772. )f3
  773. </select>
  774. <!-- 病案管理规则质控缺陷病历总数查询-->
  775. <select id="getMedManageParams" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.MedManageParamsDTO">
  776. SELECT
  777. f1.behospitalCode,
  778. <if test="flagStr != null and flagStr == 1 ">
  779. f2.rep_name as repName,
  780. </if>
  781. <if test="flagStr != null and flagStr == 2">
  782. f3.da_item_name as daItemName,
  783. f3.da_status AS daStatus,
  784. f3.doctor_advice_type as doctorAdviceType,
  785. </if>
  786. <if test="flagStr != null and flagStr == 4 ">
  787. f5.content as content,
  788. f5.rec_title as recTitle,
  789. </if>
  790. f1.hospitalId
  791. from(
  792. SELECT DISTINCT
  793. a.hospital_id as hospitalId,
  794. a.behospital_code as behospitalCode
  795. FROM
  796. med_behospital_info a,
  797. med_qcresult_info b
  798. WHERE
  799. a.is_deleted = 'N'
  800. AND b.is_deleted = 'N'
  801. AND a.hospital_id = b.hospital_id
  802. AND a.behospital_code = b.behospital_code
  803. AND <![CDATA[a.leave_hospital_date >= #{startDate}]]>
  804. AND <![CDATA[a.leave_hospital_date <= #{endDate}]]>
  805. AND a.is_placefile = 1
  806. <![CDATA[AND a.qc_type_id <>0 ]]>
  807. <if test="hospitalId != null and hospitalId != ''">
  808. AND a.hospital_id = #{hospitalId}
  809. </if>)f1
  810. <if test="flagStr != null and flagStr == 1 ">
  811. join med_lis_info f2
  812. on f2.is_deleted = 'N'
  813. AND f1.hospitalId = f2.hospital_id
  814. AND f1.behospitalCode = f2.behospital_code
  815. </if>
  816. <if test="flagStr != null and flagStr == 2">
  817. join med_doctor_advice f3
  818. on f3.is_deleted = 'N'
  819. AND f1.hospitalId = f3.hospital_id
  820. AND f1.behospitalCode = f3.behospital_code
  821. </if>
  822. <if test="flagStr != null and flagStr == 3">
  823. join med_qcresult_detail f4
  824. on f4.is_deleted = 'N'
  825. AND f1.hospitalId = f4.hospital_id
  826. AND f1.behospitalCode = f4.behospital_code
  827. AND f4.is_reject = 1
  828. </if>
  829. <if test="flagStr != null and flagStr == 4">
  830. join str_informed_consent f5
  831. on f5.is_deleted = 'N'
  832. AND f1.hospitalId = f5.hospital_id
  833. AND f1.behospitalCode = f5.behospital_code
  834. </if>
  835. </select>
  836. <!-- 各科室缺陷占比-全院-首页 -->
  837. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  838. resultType="com.diagbot.dto.NumDTO">
  839. SELECT
  840. a.beh_dept_id as id,
  841. a.beh_dept_name as name,
  842. count(*) AS num
  843. FROM
  844. med_behospital_info a,
  845. med_qcresult_info c,
  846. med_qcresult_detail d
  847. WHERE
  848. a.behospital_code = c.behospital_code
  849. AND a.hospital_id = c.hospital_id
  850. AND a.behospital_code = d.behospital_code
  851. AND a.hospital_id = d.hospital_id
  852. AND a.is_deleted = 'N'
  853. AND c.is_deleted = 'N'
  854. AND d.is_deleted = 'N'
  855. <if test="isPlacefile != null and isPlacefile != ''">
  856. and a.is_placefile = #{isPlacefile}
  857. </if>
  858. <![CDATA[AND a.qc_type_id <>0 ]]>
  859. <if test="hospitalId != null and hospitalId != ''">
  860. AND a.hospital_id = #{hospitalId}
  861. </if>
  862. <if test="isPlacefile != null and isPlacefile == 0">
  863. <if test="startDate != null and startDate != ''">
  864. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  865. </if>
  866. <if test="endDate != null and endDate != ''">
  867. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  868. </if>
  869. </if>
  870. <if test="isPlacefile != null and isPlacefile == 1">
  871. <if test="startDate != null and startDate != ''">
  872. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  873. </if>
  874. <if test="endDate != null and endDate != ''">
  875. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  876. </if>
  877. </if>
  878. GROUP BY
  879. a.beh_dept_id,
  880. a.beh_dept_name
  881. ORDER BY
  882. count(*) DESC
  883. </select>
  884. <!-- 质控结果缺陷总数查询-->
  885. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  886. SELECT
  887. count(*) AS totle
  888. FROM
  889. med_behospital_info a,
  890. med_qcresult_info c,
  891. med_qcresult_detail d
  892. WHERE
  893. a.behospital_code = c.behospital_code
  894. AND a.hospital_id = c.hospital_id
  895. AND a.behospital_code = d.behospital_code
  896. AND a.hospital_id = d.hospital_id
  897. AND a.is_deleted = 'N'
  898. AND c.is_deleted = 'N'
  899. AND d.is_deleted = 'N'
  900. <if test="isPlacefile != null and isPlacefile != ''">
  901. and a.is_placefile = #{isPlacefile}
  902. </if>
  903. <![CDATA[AND a.qc_type_id <>0 ]]>
  904. <if test="hospitalId != null and hospitalId != ''">
  905. AND a.hospital_id = #{hospitalId}
  906. </if>
  907. <if test="isPlacefile != null and isPlacefile == 0">
  908. <if test="startDate != null and startDate != ''">
  909. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  910. </if>
  911. <if test="endDate != null and endDate != ''">
  912. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  913. </if>
  914. </if>
  915. <if test="isPlacefile != null and isPlacefile == 1">
  916. <if test="startDate != null and startDate != ''">
  917. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  918. </if>
  919. <if test="endDate != null and endDate != ''">
  920. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  921. </if>
  922. </if>
  923. </select>
  924. <!--获取病历-->
  925. <select id="getNoGrade" resultMap="BaseResultMap">
  926. select * from med_behospital_info a
  927. where a.is_deleted = 'N'
  928. and a.qc_type_id != 0
  929. <if test="isPlacefile != null and isPlacefile != ''">
  930. and a.is_placefile = #{isPlacefile}
  931. </if>
  932. <if test="filterFlag != null and filterFlag == 0">
  933. and
  934. not EXISTS (
  935. SELECT
  936. 1
  937. FROM
  938. med_qcresult_info b
  939. WHERE
  940. b.is_deleted = 'N'
  941. AND a.hospital_id = b.hospital_id
  942. AND a.behospital_code = b.behospital_code
  943. )
  944. </if>
  945. <if test="leaveDate != null">
  946. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  947. </if>
  948. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  949. and a.hospital_id in
  950. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  951. #{item}
  952. </foreach>
  953. </if>
  954. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  955. and a.behospital_code in
  956. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  957. #{item}
  958. </foreach>
  959. </if>
  960. <if test="individuation != null and individuation.contains(1)">
  961. union
  962. select * from med_behospital_info b
  963. where b.is_deleted = 'N'
  964. and b.qc_type_id != 0
  965. <if test="isPlacefile != null and isPlacefile != ''">
  966. and b.is_placefile = #{isPlacefile}
  967. </if>
  968. <if test="startLeaveDate != null">
  969. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  970. </if>
  971. <if test="endLeaveDate != null">
  972. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  973. </if>
  974. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  975. and b.hospital_id in
  976. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  977. #{item}
  978. </foreach>
  979. </if>
  980. </if>
  981. </select>
  982. <!--质控评分(科室)分页-->
  983. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDeptDTO">
  984. SELECT * from (
  985. SELECT
  986. t.*,
  987. t3.name as medoup_name,
  988. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  989. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  990. g.check_type as ch_type,
  991. h.check_type AS mr_type,
  992. g.check_name as ch_name,
  993. h.check_name as mr_name,
  994. g.check_time as ch_time,
  995. h.check_time AS mr_time
  996. FROM
  997. ( SELECT
  998. a.*,
  999. IFNULL(b.level, '未评分') AS `level`,
  1000. b.grade_type,
  1001. b.score_res,
  1002. e.score_res as score_bn,
  1003. b.gmt_create AS grade_time,
  1004. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1005. FROM
  1006. med_behospital_info a
  1007. JOIN sys_user_dept d
  1008. ON a.hospital_id = d.hospital_id
  1009. AND a.beh_dept_id = d.dept_id
  1010. LEFT JOIN med_qcresult_info b
  1011. ON a.behospital_code = b.behospital_code
  1012. AND b.is_deleted = 'N'
  1013. LEFT JOIN med_qcresult_cases e
  1014. on a.behospital_code = e.behospital_code
  1015. AND e.is_deleted = 'N'
  1016. and e.cases_id = 243
  1017. LEFT JOIN med_home_page c
  1018. ON a.behospital_code = c.behospital_code
  1019. AND c.is_deleted = 'N'
  1020. WHERE d.is_deleted = 'N'
  1021. AND d.user_id = #{userId}
  1022. ) t
  1023. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1024. ON t.behospital_code = g.behospital_code
  1025. AND t.hospital_id = g.hospital_id
  1026. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1027. ON t.behospital_code = h.behospital_code
  1028. AND t.hospital_id = h.hospital_id
  1029. LEFT JOIN bas_doctor_info t2 ON t.doctor_id = t2.doctor_id
  1030. AND t.hospital_id = t2.hospital_id
  1031. AND t2.is_deleted = 'N'
  1032. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  1033. AND t3.is_deleted = 'N'
  1034. where t.is_deleted = 'N'
  1035. <if test="medoupName != null and medoupName != ''">
  1036. AND t3.name = #{medoupName}
  1037. </if>
  1038. <if test="wardName != null and wardName != ''">
  1039. AND t.ward_name = #{wardName}
  1040. </if>
  1041. <if test="diagnose != null and diagnose != ''">
  1042. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1043. </if>
  1044. <if test="deptName != null and deptName != ''">
  1045. and t.beh_dept_name = #{deptName}
  1046. </if>
  1047. <if test="deptId != null and deptId != ''">
  1048. and t.beh_dept_Id = #{deptId}
  1049. </if>
  1050. <if test="doctorName != null and doctorName != ''">
  1051. and CONCAT(
  1052. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  1053. like CONCAT('%',#{doctorName},'%')
  1054. </if>
  1055. <if test="doctorCode != null and doctorCode != ''">
  1056. and t.doctor_id = #{doctorCode}
  1057. </if>
  1058. <if test="doctorId != null and doctorId != ''">
  1059. and t.doctor_id = #{doctorId}
  1060. </if>
  1061. <if test="name != null and name != ''">
  1062. and t.name like CONCAT('%',#{name},'%')
  1063. </if>
  1064. <if test="fileCode != null and fileCode != ''">
  1065. and t.file_code like CONCAT('%',#{fileCode},'%')
  1066. </if>
  1067. <if test="hospitalId != null">
  1068. and t.hospital_id = #{hospitalId}
  1069. </if>
  1070. <if test="behospitalCode != null and behospitalCode != ''">
  1071. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1072. </if>
  1073. <if test="behosDateStart != null">
  1074. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1075. </if>
  1076. <if test="behosDateEnd != null">
  1077. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1078. </if>
  1079. <if test="leaveHosDateStart != null">
  1080. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1081. </if>
  1082. <if test="leaveHosDateEnd != null">
  1083. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1084. </if>
  1085. <if test="level != null and level != ''">
  1086. and t.level = #{level}
  1087. </if>
  1088. <if test="isPlacefile != null and isPlacefile != ''">
  1089. and t.is_placefile = #{isPlacefile}
  1090. </if>
  1091. and t.qc_type_id != 0) p
  1092. where p.is_deleted="N"
  1093. <if test="checkStatus != null ">
  1094. and p.check_status = #{checkStatus}
  1095. </if>
  1096. <if test="mrStatus != null ">
  1097. AND p.mr_status = #{mrStatus}
  1098. </if>
  1099. <if test="chName != null and chName !=''">
  1100. AND p.ch_name like CONCAT('%',#{chName},'%')
  1101. </if>
  1102. <if test="mrName != null and mrName !=''">
  1103. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1104. </if>
  1105. <if test="chTimeStart != null">
  1106. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1107. </if>
  1108. <if test="chTimeEnd != null">
  1109. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1110. </if>
  1111. <if test="mrTimeStart != null">
  1112. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1113. </if>
  1114. <if test="mrTimeEnd != null">
  1115. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1116. </if>
  1117. </select>
  1118. <!--各科室缺陷占比病历列表-->
  1119. <select id="levelStatisticsByDeptPage" resultType="com.diagbot.dto.BehospitalInfoDeptDTO">
  1120. SELECT * from (
  1121. SELECT
  1122. t.*,
  1123. t3.name as medoup_name,
  1124. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1125. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1126. g.check_type as ch_type,
  1127. h.check_type AS mr_type,
  1128. g.check_name as ch_name,
  1129. h.check_name as mr_name,
  1130. g.check_time as ch_time,
  1131. h.check_time AS mr_time
  1132. FROM
  1133. ( SELECT
  1134. a.*,
  1135. IFNULL(b.level, '未评分') AS `level`,
  1136. b.grade_type,
  1137. b.score_res,
  1138. e.score_res as score_bn,
  1139. b.gmt_create AS grade_time,
  1140. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1141. FROM
  1142. med_behospital_info a
  1143. JOIN sys_user_dept d
  1144. ON a.hospital_id = d.hospital_id
  1145. AND a.beh_dept_id = d.dept_id
  1146. LEFT JOIN med_qcresult_info b
  1147. ON a.behospital_code = b.behospital_code
  1148. AND b.is_deleted = 'N'
  1149. LEFT JOIN med_qcresult_cases e
  1150. on a.behospital_code = e.behospital_code
  1151. AND e.is_deleted = 'N'
  1152. and e.cases_id = 243
  1153. LEFT JOIN med_home_page c
  1154. ON a.behospital_code = c.behospital_code
  1155. AND c.is_deleted = 'N'
  1156. WHERE d.is_deleted = 'N'
  1157. AND d.user_id = #{userId}
  1158. ) t
  1159. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1160. ON t.behospital_code = g.behospital_code
  1161. AND t.hospital_id = g.hospital_id
  1162. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1163. ON t.behospital_code = h.behospital_code
  1164. AND t.hospital_id = h.hospital_id
  1165. LEFT JOIN bas_doctor_info t2 ON t.doctor_id = t2.doctor_id
  1166. AND t.hospital_id = t2.hospital_id
  1167. AND t2.is_deleted = 'N'
  1168. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  1169. AND t3.is_deleted = 'N'
  1170. where t.is_deleted = 'N'
  1171. <if test="medoupName != null and medoupName != ''">
  1172. AND t3.name = #{medoupName}
  1173. </if>
  1174. <if test="wardName != null and wardName != ''">
  1175. AND t.ward_name = #{wardName}
  1176. </if>
  1177. <if test="diagnose != null and diagnose != ''">
  1178. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1179. </if>
  1180. <if test="deptName != null and deptName != ''">
  1181. and t.beh_dept_name = #{deptName}
  1182. </if>
  1183. <if test="deptId != null and deptId != ''">
  1184. and t.beh_dept_Id = #{deptId}
  1185. </if>
  1186. <if test="doctorName != null and doctorName != ''">
  1187. and t.doctor_name = #{doctorName}
  1188. </if>
  1189. <if test="doctorCode != null and doctorCode != ''">
  1190. and t.doctor_id = #{doctorCode}
  1191. </if>
  1192. <if test="doctorId != null and doctorId != ''">
  1193. and t.doctor_id = #{doctorId}
  1194. </if>
  1195. <if test="name != null and name != ''">
  1196. and t.name like CONCAT('%',#{name},'%')
  1197. </if>
  1198. <if test="fileCode != null and fileCode != ''">
  1199. and t.file_code like CONCAT('%',#{fileCode},'%')
  1200. </if>
  1201. <if test="hospitalId != null">
  1202. and t.hospital_id = #{hospitalId}
  1203. </if>
  1204. <if test="behospitalCode != null and behospitalCode != ''">
  1205. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1206. </if>
  1207. <if test="behosDateStart != null">
  1208. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1209. </if>
  1210. <if test="behosDateEnd != null">
  1211. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1212. </if>
  1213. <if test="leaveHosDateStart != null">
  1214. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1215. </if>
  1216. <if test="leaveHosDateEnd != null">
  1217. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1218. </if>
  1219. <if test="level != null and level != ''">
  1220. and t.level = #{level}
  1221. </if>
  1222. <if test="isPlacefile != null and isPlacefile != ''">
  1223. and t.is_placefile = #{isPlacefile}
  1224. </if>
  1225. and t.qc_type_id != 0) p
  1226. where p.is_deleted="N"
  1227. <if test="checkStatus != null ">
  1228. and p.check_status = #{checkStatus}
  1229. </if>
  1230. <if test="mrStatus != null ">
  1231. AND p.mr_status = #{mrStatus}
  1232. </if>
  1233. <if test="chName != null and chName !=''">
  1234. AND p.ch_name like CONCAT('%',#{chName},'%')
  1235. </if>
  1236. <if test="mrName != null and mrName !=''">
  1237. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1238. </if>
  1239. <if test="chTimeStart != null">
  1240. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1241. </if>
  1242. <if test="chTimeEnd != null">
  1243. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1244. </if>
  1245. <if test="mrTimeStart != null">
  1246. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1247. </if>
  1248. <if test="mrTimeEnd != null">
  1249. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1250. </if>
  1251. </select>
  1252. <!--质控评分(个人)分页-->
  1253. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1254. Select * from (
  1255. select t.*,
  1256. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1257. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1258. g.check_type as ch_type,
  1259. h.check_type AS mr_type,
  1260. g.check_name as ch_name,
  1261. h.check_name as mr_name,
  1262. g.check_time as ch_time,
  1263. h.check_time AS mr_time
  1264. from (SELECT
  1265. a.*,
  1266. IFNULL(b.level, '未评分') AS `level`,
  1267. b.grade_type,
  1268. b.score_res,
  1269. e.score_res as score_bn,
  1270. b.gmt_create AS grade_time,
  1271. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1272. FROM
  1273. med_behospital_info a
  1274. JOIN
  1275. (SELECT
  1276. u.id,
  1277. u.linkman AS linkman,
  1278. uh.hospital_id
  1279. FROM
  1280. sys_user u
  1281. JOIN sys_user_hospital uh
  1282. ON u.id = uh.user_id
  1283. WHERE u.is_deleted = "N"
  1284. AND u.id = #{userId}
  1285. AND uh.hospital_id = #{hospitalId}) u1
  1286. ON a.hospital_id = u1.hospital_id
  1287. LEFT JOIN med_qcresult_info b
  1288. ON a.behospital_code = b.behospital_code
  1289. AND b.is_deleted = 'N'
  1290. LEFT JOIN med_qcresult_cases e
  1291. on a.behospital_code = e.behospital_code
  1292. AND e.is_deleted = 'N'
  1293. and e.cases_id = 243
  1294. LEFT JOIN med_home_page c
  1295. ON a.behospital_code = c.behospital_code
  1296. AND c.is_deleted = 'N'
  1297. WHERE
  1298. a.is_deleted = 'N'
  1299. and a.doctor_name = u1.linkman
  1300. or a.beh_doctor_name = u1.linkman
  1301. or a.director_doctor_name = u1.linkman
  1302. ) t
  1303. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1304. ON t.behospital_code = g.behospital_code
  1305. AND t.hospital_id = g.hospital_id
  1306. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1307. ON t.behospital_code = h.behospital_code
  1308. AND t.hospital_id = h.hospital_id
  1309. WHERE t.is_deleted = 'N'
  1310. <if test="diagnose != null and diagnose != ''">
  1311. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1312. </if>
  1313. <if test="deptName != null and deptName != ''">
  1314. and t.beh_dept_name = #{deptName}
  1315. </if>
  1316. <if test="deptId != null and deptId != ''">
  1317. and t.beh_dept_id= #{deptId}
  1318. </if>
  1319. <if test="name != null and name != ''">
  1320. and t.name like CONCAT('%',#{name},'%')
  1321. </if>
  1322. <if test="fileCode != null and fileCode != ''">
  1323. and t.file_code like CONCAT('%',#{fileCode},'%')
  1324. </if>
  1325. <if test="behospitalCode != null and behospitalCode != ''">
  1326. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1327. </if>
  1328. <if test="behosDateStart != null">
  1329. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1330. </if>
  1331. <if test="behosDateEnd != null">
  1332. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1333. </if>
  1334. <if test="leaveHosDateStart != null">
  1335. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1336. </if>
  1337. <if test="leaveHosDateEnd != null">
  1338. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1339. </if>
  1340. <if test="level != null and level != ''">
  1341. and t.level = #{level}
  1342. </if>
  1343. <if test="isPlacefile != null and isPlacefile != ''">
  1344. and t.is_placefile = #{isPlacefile}
  1345. </if>
  1346. and t.qc_type_id != 0) p
  1347. where p.is_deleted="N"
  1348. <if test="checkStatus != null ">
  1349. and p.check_status = #{checkStatus}
  1350. </if>
  1351. <if test="mrStatus != null ">
  1352. AND p.mr_status = #{mrStatus}
  1353. </if>
  1354. <if test="chName != null and chName !=''">
  1355. AND p.ch_name like CONCAT('%',#{chName},'%')
  1356. </if>
  1357. <if test="mrName != null and mrName !=''">
  1358. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1359. </if>
  1360. <if test="chTimeStart != null">
  1361. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1362. </if>
  1363. <if test="chTimeEnd != null">
  1364. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1365. </if>
  1366. <if test="mrTimeStart != null">
  1367. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1368. </if>
  1369. <if test="mrTimeEnd != null">
  1370. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1371. </if>
  1372. </select>
  1373. <!--质控评分(医疗组)分页-->
  1374. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1375. select * from (
  1376. select t.*,
  1377. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1378. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1379. g.check_type as ch_type,
  1380. h.check_type AS mr_type,
  1381. g.check_name as ch_name,
  1382. h.check_name as mr_name,
  1383. g.check_time as ch_time,
  1384. h.check_time AS mr_time
  1385. from (
  1386. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  1387. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  1388. LEFT JOIN med_qcresult_info b
  1389. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  1390. LEFT JOIN med_qcresult_cases e
  1391. on a.behospital_code = e.behospital_code
  1392. AND e.is_deleted = 'N'
  1393. and e.cases_id = 243
  1394. left join med_home_page c
  1395. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  1396. ) t
  1397. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1398. ON t.behospital_code = g.behospital_code
  1399. AND t.hospital_id = g.hospital_id
  1400. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1401. ON t.behospital_code = h.behospital_code
  1402. AND t.hospital_id = h.hospital_id
  1403. WHERE t.is_deleted = 'N'
  1404. and
  1405. t.doctor_id in (
  1406. SELECT doctor_id FROM `bas_doctor_info`
  1407. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  1408. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  1409. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  1410. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  1411. and c1.username = c3.doctor_id
  1412. and c2.hospital_id = #{hospitalId}
  1413. and c1.id = #{userId}
  1414. )
  1415. )
  1416. <if test="diagnose != null and diagnose != ''">
  1417. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1418. </if>
  1419. <if test="doctorName != null and doctorName != ''">
  1420. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  1421. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  1422. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  1423. </if>
  1424. <if test="name != null and name != ''">
  1425. and t.name like CONCAT('%',#{name},'%')
  1426. </if>
  1427. <if test="doctorCode != null and doctorCode != ''">
  1428. and (t.doctor_id = #{doctorCode}
  1429. or t.beh_doctor_id = #{doctorCode}
  1430. or t.director_doctor_id = #{doctorCode})
  1431. </if>
  1432. <if test="fileCode != null and fileCode != ''">
  1433. and t.file_code like CONCAT('%',#{fileCode},'%')
  1434. </if>
  1435. <if test="hospitalId != null">
  1436. and t.hospital_id = #{hospitalId}
  1437. </if>
  1438. <if test="behospitalCode != null and behospitalCode != ''">
  1439. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1440. </if>
  1441. <if test="behosDateStart != null">
  1442. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1443. </if>
  1444. <if test="behosDateEnd != null">
  1445. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1446. </if>
  1447. <if test="leaveHosDateStart != null">
  1448. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1449. </if>
  1450. <if test="leaveHosDateEnd != null">
  1451. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1452. </if>
  1453. <if test="level != null and level != ''">
  1454. and t.level = #{level}
  1455. </if>
  1456. <if test="isPlacefile != null and isPlacefile != ''">
  1457. and t.is_placefile = #{isPlacefile}
  1458. </if>
  1459. and t.qc_type_id != 0) p
  1460. where p.is_deleted="N"
  1461. <if test="checkStatus != null ">
  1462. and p.check_status = #{checkStatus}
  1463. </if>
  1464. <if test="mrStatus != null ">
  1465. AND p.mr_status = #{mrStatus}
  1466. </if>
  1467. <if test="chName != null and chName !=''">
  1468. AND p.ch_name like CONCAT('%',#{chName},'%')
  1469. </if>
  1470. <if test="mrName != null and mrName !=''">
  1471. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1472. </if>
  1473. <if test="chTimeStart != null">
  1474. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1475. </if>
  1476. <if test="chTimeEnd != null">
  1477. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1478. </if>
  1479. <if test="mrTimeStart != null">
  1480. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1481. </if>
  1482. <if test="mrTimeEnd != null">
  1483. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1484. </if>
  1485. </select>
  1486. <!-- 出院总人数统计-全院-首页 -->
  1487. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1488. SELECT
  1489. COUNT(*)
  1490. FROM
  1491. med_behospital_info a
  1492. WHERE
  1493. a.is_deleted = 'N'
  1494. and a.qc_type_id != 0
  1495. <if test="isPlacefile != null and isPlacefile != ''">
  1496. and a.is_placefile = #{isPlacefile}
  1497. </if>
  1498. <if test="hospitalId != null and hospitalId != ''">
  1499. AND a.hospital_id = #{hospitalId}
  1500. </if>
  1501. <if test="isPlacefile != null and isPlacefile == 0">
  1502. <if test="startDate != null and startDate != ''">
  1503. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1504. </if>
  1505. <if test="endDate != null and endDate != ''">
  1506. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1507. </if>
  1508. </if>
  1509. <if test="isPlacefile != null and isPlacefile == 1">
  1510. <if test="startDate != null and startDate != ''">
  1511. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1512. </if>
  1513. <if test="endDate != null and endDate != ''">
  1514. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1515. </if>
  1516. </if>
  1517. </select>
  1518. <!-- 新生儿出院人数统计-全院-首页 -->
  1519. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1520. SELECT
  1521. COUNT(*)
  1522. FROM
  1523. med_behospital_info a,
  1524. med_home_page b
  1525. WHERE
  1526. a.is_deleted = 'N'
  1527. AND b.is_deleted = 'N'
  1528. AND a.hospital_id = b.hospital_id
  1529. AND a.behospital_code = b.behospital_code
  1530. <if test="isPlacefile != null and isPlacefile != ''">
  1531. and a.is_placefile = #{isPlacefile}
  1532. </if>
  1533. AND (
  1534. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  1535. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1536. )
  1537. <![CDATA[AND a.qc_type_id <>0 ]]>
  1538. <if test="hospitalId != null and hospitalId != ''">
  1539. AND a.hospital_id = #{hospitalId}
  1540. </if>
  1541. <if test="isPlacefile != null and isPlacefile == 0">
  1542. <if test="startDate != null and startDate != ''">
  1543. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1544. </if>
  1545. <if test="endDate != null and endDate != ''">
  1546. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1547. </if>
  1548. </if>
  1549. <if test="isPlacefile != null and isPlacefile == 1">
  1550. <if test="startDate != null and startDate != ''">
  1551. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1552. </if>
  1553. <if test="endDate != null and endDate != ''">
  1554. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1555. </if>
  1556. </if>
  1557. </select>
  1558. <!-- 死亡人数统计-全院-首页 -->
  1559. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1560. select COUNT(*) from(
  1561. SELECT distinct a.*
  1562. FROM
  1563. med_behospital_info a,
  1564. med_medical_record b,
  1565. med_medical_record_content c
  1566. WHERE
  1567. a.is_deleted = 'N'
  1568. AND b.is_deleted = 'N'
  1569. AND c.is_deleted = 'N'
  1570. AND a.hospital_id = b.hospital_id
  1571. AND a.hospital_id = c.hospital_id
  1572. AND a.behospital_code = b.behospital_code
  1573. AND b.rec_id = c.rec_id
  1574. and b.mode_id = '24'
  1575. <if test="isPlacefile != null and isPlacefile != ''">
  1576. and a.is_placefile = #{isPlacefile}
  1577. </if>
  1578. <![CDATA[AND a.qc_type_id <>0 ]]>
  1579. <if test="hospitalId != null and hospitalId != ''">
  1580. AND a.hospital_id = #{hospitalId}
  1581. </if>
  1582. <if test="isPlacefile != null and isPlacefile == 0">
  1583. <if test="startDate != null and startDate != ''">
  1584. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1585. </if>
  1586. <if test="endDate != null and endDate != ''">
  1587. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1588. </if>
  1589. </if>
  1590. <if test="isPlacefile != null and isPlacefile == 1">
  1591. <if test="startDate != null and startDate != ''">
  1592. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1593. </if>
  1594. <if test="endDate != null and endDate != ''">
  1595. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1596. </if>
  1597. </if>)m
  1598. </select>
  1599. <!-- 手术人数统计-全院-首页 -->
  1600. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1601. SELECT
  1602. COUNT( DISTINCT a.behospital_code )
  1603. FROM
  1604. med_behospital_info a,
  1605. med_medical_record c,
  1606. qc_mode d
  1607. WHERE
  1608. a.is_deleted = 'N'
  1609. AND c.is_deleted = 'N'
  1610. AND d.is_deleted = 'N'
  1611. AND a.hospital_id = c.hospital_id
  1612. AND a.behospital_code = c.behospital_code
  1613. AND c.mode_id = d.id
  1614. <if test="isPlacefile != null and isPlacefile != ''">
  1615. and a.is_placefile = #{isPlacefile}
  1616. </if>
  1617. AND d.`name` = '手术记录'
  1618. <![CDATA[AND a.qc_type_id <>0 ]]>
  1619. <if test="hospitalId != null and hospitalId != ''">
  1620. AND a.hospital_id = #{hospitalId}
  1621. </if>
  1622. <if test="isPlacefile != null and isPlacefile == 0">
  1623. <if test="startDate != null and startDate != ''">
  1624. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1625. </if>
  1626. <if test="endDate != null and endDate != ''">
  1627. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1628. </if>
  1629. </if>
  1630. <if test="isPlacefile != null and isPlacefile == 1">
  1631. <if test="startDate != null and startDate != ''">
  1632. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1633. </if>
  1634. <if test="endDate != null and endDate != ''">
  1635. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1636. </if>
  1637. </if>
  1638. </select>
  1639. <!-- 入院人数统计-首页 -->
  1640. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  1641. resultType="com.diagbot.dto.NumDTO">
  1642. SELECT
  1643. a.beh_dept_id AS id,
  1644. a.beh_dept_name AS NAME,
  1645. COUNT(*) AS num
  1646. FROM
  1647. med_behospital_info a
  1648. WHERE
  1649. a.is_deleted = 'N'
  1650. and a.qc_type_id != 0
  1651. <if test="isPlacefile != null and isPlacefile != ''">
  1652. and a.is_placefile = #{isPlacefile}
  1653. </if>
  1654. <if test="hospitalId != null and hospitalId != ''">
  1655. AND a.hospital_id = #{hospitalId}
  1656. </if>
  1657. <if test="isPlacefile != null and isPlacefile == 0">
  1658. <if test="startDate != null and startDate != ''">
  1659. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1660. </if>
  1661. <if test="endDate != null and endDate != ''">
  1662. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1663. </if>
  1664. </if>
  1665. <if test="isPlacefile != null and isPlacefile == 1">
  1666. <if test="startDate != null and startDate != ''">
  1667. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1668. </if>
  1669. <if test="endDate != null and endDate != ''">
  1670. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1671. </if>
  1672. </if>
  1673. GROUP BY
  1674. a.beh_dept_id,
  1675. a.beh_dept_name
  1676. </select>
  1677. <!-- 出院总人数统计-科室-首页 -->
  1678. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1679. resultType="com.diagbot.dto.NumDTO">
  1680. SELECT
  1681. a.beh_dept_id AS id,
  1682. a.beh_dept_name AS NAME,
  1683. COUNT(*) AS num
  1684. FROM
  1685. med_behospital_info a,
  1686. sys_user_dept c
  1687. WHERE
  1688. a.is_deleted = 'N'
  1689. AND c.is_deleted = 'N'
  1690. and a.qc_type_id != 0
  1691. AND a.hospital_id = c.hospital_id
  1692. AND a.beh_dept_id = c.dept_id
  1693. <if test="isPlacefile != null and isPlacefile != ''">
  1694. and a.is_placefile = #{isPlacefile}
  1695. </if>
  1696. <if test="userId!=null">
  1697. AND c.user_id = #{userId}
  1698. </if>
  1699. <if test="hospitalId != null and hospitalId != ''">
  1700. AND a.hospital_id = #{hospitalId}
  1701. </if>
  1702. <if test="isPlacefile != null and isPlacefile == 0">
  1703. <if test="startDate != null and startDate != ''">
  1704. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1705. </if>
  1706. <if test="endDate != null and endDate != ''">
  1707. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1708. </if>
  1709. </if>
  1710. <if test="isPlacefile != null and isPlacefile == 1">
  1711. <if test="startDate != null and startDate != ''">
  1712. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1713. </if>
  1714. <if test="endDate != null and endDate != ''">
  1715. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1716. </if>
  1717. </if>
  1718. GROUP BY
  1719. a.beh_dept_id,
  1720. a.beh_dept_name
  1721. </select>
  1722. <!-- 入院总人数统计-科室-首页 -->
  1723. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1724. resultType="com.diagbot.dto.AdmissionCountDTO">
  1725. SELECT
  1726. a.beh_dept_id as deptId,
  1727. a.beh_dept_name as deptName,
  1728. a.doctor_id as doctorId,
  1729. a.doctor_name as doctorName,
  1730. COUNT(*) AS num
  1731. FROM
  1732. med_behospital_info a,
  1733. sys_user_dept c
  1734. WHERE
  1735. a.is_deleted = 'N'
  1736. AND c.is_deleted = 'N'
  1737. and a.qc_type_id != 0
  1738. AND a.hospital_id = c.hospital_id
  1739. AND a.beh_dept_id = c.dept_id
  1740. <if test="isPlacefile != null and isPlacefile != ''">
  1741. and a.is_placefile = #{isPlacefile}
  1742. </if>
  1743. <if test="userId!=null">
  1744. AND c.user_id = #{userId}
  1745. </if>
  1746. <if test="hospitalId != null and hospitalId != ''">
  1747. AND a.hospital_id = #{hospitalId}
  1748. </if>
  1749. <if test="isPlacefile != null and isPlacefile == 0">
  1750. <if test="startDate != null and startDate != ''">
  1751. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1752. </if>
  1753. <if test="endDate != null and endDate != ''">
  1754. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1755. </if>
  1756. </if>
  1757. <if test="isPlacefile != null and isPlacefile == 1">
  1758. <if test="startDate != null and startDate != ''">
  1759. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1760. </if>
  1761. <if test="endDate != null and endDate != ''">
  1762. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1763. </if>
  1764. </if>
  1765. GROUP BY
  1766. a.beh_dept_id,
  1767. a.beh_dept_name,
  1768. a.doctor_id,
  1769. a.doctor_name
  1770. </select>
  1771. <!-- 新生儿出院人数统计-科室-首页 -->
  1772. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1773. resultType="com.diagbot.dto.NumDTO">
  1774. SELECT
  1775. a.beh_dept_id AS id,
  1776. a.beh_dept_name AS NAME,
  1777. COUNT(*) AS num
  1778. FROM
  1779. med_behospital_info a,
  1780. med_home_page b,
  1781. sys_user_dept c
  1782. WHERE
  1783. a.is_deleted = 'N'
  1784. AND b.is_deleted = 'N'
  1785. AND c.is_deleted = 'N'
  1786. AND a.hospital_id = b.hospital_id
  1787. AND a.hospital_id = c.hospital_id
  1788. AND a.behospital_code = b.behospital_code
  1789. AND a.beh_dept_id = c.dept_id
  1790. AND (
  1791. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  1792. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1793. )
  1794. <if test="isPlacefile != null and isPlacefile != ''">
  1795. and a.is_placefile = #{isPlacefile}
  1796. </if>
  1797. <![CDATA[AND a.qc_type_id <>0 ]]>
  1798. <if test="userId!=null">
  1799. AND c.user_id = #{userId}
  1800. </if>
  1801. <if test="hospitalId != null and hospitalId != ''">
  1802. AND a.hospital_id = #{hospitalId}
  1803. </if>
  1804. <if test="isPlacefile != null and isPlacefile == 0">
  1805. <if test="startDate != null and startDate != ''">
  1806. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1807. </if>
  1808. <if test="endDate != null and endDate != ''">
  1809. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1810. </if>
  1811. </if>
  1812. <if test="isPlacefile != null and isPlacefile == 1">
  1813. <if test="startDate != null and startDate != ''">
  1814. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1815. </if>
  1816. <if test="endDate != null and endDate != ''">
  1817. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1818. </if>
  1819. </if>
  1820. GROUP BY
  1821. a.beh_dept_id,
  1822. a.beh_dept_name
  1823. </select>
  1824. <!-- 死亡人数统计-科室-首页 -->
  1825. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1826. resultType="com.diagbot.dto.NumDTO">
  1827. SELECT
  1828. a.beh_dept_id AS id,
  1829. a.beh_dept_name AS NAME,
  1830. COUNT(*) AS num
  1831. FROM
  1832. med_behospital_info a,
  1833. sys_user_dept c,
  1834. med_medical_record d,
  1835. med_medical_record_content e
  1836. WHERE
  1837. a.is_deleted = 'N'
  1838. AND c.is_deleted = 'N'
  1839. AND d.is_deleted = 'N'
  1840. AND e.is_deleted = 'N'
  1841. AND a.hospital_id = c.hospital_id
  1842. AND a.hospital_id = d.hospital_id
  1843. AND a.hospital_id = e.hospital_id
  1844. AND a.behospital_code = d.behospital_code
  1845. AND a.beh_dept_id = c.dept_id
  1846. AND d.rec_id = e.rec_id
  1847. AND d.mode_id = '24'
  1848. <if test="isPlacefile != null and isPlacefile != ''">
  1849. and a.is_placefile = #{isPlacefile}
  1850. </if>
  1851. <![CDATA[AND a.qc_type_id <>0 ]]>
  1852. <if test="userId!=null">
  1853. AND c.user_id = #{userId}
  1854. </if>
  1855. <if test="hospitalId != null and hospitalId != ''">
  1856. AND a.hospital_id = #{hospitalId}
  1857. </if>
  1858. <if test="isPlacefile != null and isPlacefile == 0">
  1859. <if test="startDate != null and startDate != ''">
  1860. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1861. </if>
  1862. <if test="endDate != null and endDate != ''">
  1863. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1864. </if>
  1865. </if>
  1866. <if test="isPlacefile != null and isPlacefile == 1">
  1867. <if test="startDate != null and startDate != ''">
  1868. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1869. </if>
  1870. <if test="endDate != null and endDate != ''">
  1871. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1872. </if>
  1873. </if>
  1874. GROUP BY
  1875. a.beh_dept_id,
  1876. a.beh_dept_name
  1877. </select>
  1878. <!-- 手术人数统计-科室-首页 -->
  1879. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1880. resultType="com.diagbot.dto.NumDTO">
  1881. SELECT
  1882. a.beh_dept_id AS id,
  1883. a.beh_dept_name AS NAME,
  1884. COUNT( DISTINCT a.behospital_code ) AS num
  1885. FROM
  1886. med_behospital_info a,
  1887. sys_user_dept c,
  1888. med_medical_record d,
  1889. qc_mode e
  1890. WHERE
  1891. a.is_deleted = 'N'
  1892. AND c.is_deleted = 'N'
  1893. AND d.is_deleted = 'N'
  1894. AND e.is_deleted = 'N'
  1895. AND a.hospital_id = c.hospital_id
  1896. AND a.hospital_id = d.hospital_id
  1897. AND a.behospital_code = d.behospital_code
  1898. AND a.beh_dept_id = c.dept_id
  1899. AND d.mode_id = e.id
  1900. AND e.`name` = '手术记录'
  1901. <if test="isPlacefile != null and isPlacefile != ''">
  1902. and a.is_placefile = #{isPlacefile}
  1903. </if>
  1904. <![CDATA[AND a.qc_type_id <>0 ]]>
  1905. <if test="userId!=null">
  1906. AND c.user_id = #{userId}
  1907. </if>
  1908. <if test="hospitalId != null and hospitalId != ''">
  1909. AND a.hospital_id = #{hospitalId}
  1910. </if>
  1911. <if test="isPlacefile != null and isPlacefile == 0">
  1912. <if test="startDate != null and startDate != ''">
  1913. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1914. </if>
  1915. <if test="endDate != null and endDate != ''">
  1916. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1917. </if>
  1918. </if>
  1919. <if test="isPlacefile != null and isPlacefile == 1">
  1920. <if test="startDate != null and startDate != ''">
  1921. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1922. </if>
  1923. <if test="endDate != null and endDate != ''">
  1924. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1925. </if>
  1926. </if>
  1927. GROUP BY
  1928. a.beh_dept_id,
  1929. a.beh_dept_name
  1930. </select>
  1931. <!-- 各科室缺陷占比排行(分页) -->
  1932. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1933. SELECT t.*
  1934. FROM
  1935. (SELECT
  1936. t1.beh_dept_name AS NAME,
  1937. t1.num AS num,
  1938. t2.totle AS totleNum,
  1939. round( t1.num / t2.totle, 4 ) AS percent,
  1940. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1941. FROM
  1942. (
  1943. SELECT
  1944. a.beh_dept_id,
  1945. a.beh_dept_name,
  1946. count(*) AS num
  1947. FROM
  1948. med_behospital_info a,
  1949. med_qcresult_info c,
  1950. med_qcresult_detail d
  1951. WHERE
  1952. a.behospital_code = c.behospital_code
  1953. AND a.hospital_id = c.hospital_id
  1954. AND a.behospital_code = d.behospital_code
  1955. AND a.hospital_id = d.hospital_id
  1956. AND a.is_deleted = 'N'
  1957. AND c.is_deleted = 'N'
  1958. AND d.is_deleted = 'N'
  1959. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1960. and a.is_placefile = #{filterPageVO.isPlacefile}
  1961. </if>
  1962. <![CDATA[AND a.qc_type_id <>0 ]]>
  1963. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1964. AND a.hospital_id = #{filterPageVO.hospitalId}
  1965. </if>
  1966. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1967. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1968. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1969. </if>
  1970. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1971. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1972. </if>
  1973. </if>
  1974. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1975. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1976. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1977. </if>
  1978. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1979. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1980. </if>
  1981. </if>
  1982. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1983. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1984. </if>
  1985. GROUP BY
  1986. a.beh_dept_id,
  1987. a.beh_dept_name
  1988. ORDER BY
  1989. count(*) DESC
  1990. ) t1,
  1991. (
  1992. SELECT
  1993. count(*) AS totle
  1994. FROM
  1995. med_behospital_info a,
  1996. med_qcresult_info c,
  1997. med_qcresult_detail d
  1998. WHERE
  1999. a.behospital_code = c.behospital_code
  2000. AND a.hospital_id = c.hospital_id
  2001. AND a.behospital_code = d.behospital_code
  2002. AND a.hospital_id = d.hospital_id
  2003. AND a.is_deleted = 'N'
  2004. AND c.is_deleted = 'N'
  2005. AND d.is_deleted = 'N'
  2006. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  2007. and a.is_placefile = #{filterPageVO.isPlacefile}
  2008. </if>
  2009. <![CDATA[AND a.qc_type_id <>0 ]]>
  2010. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  2011. AND a.hospital_id = #{filterPageVO.hospitalId}
  2012. </if>
  2013. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  2014. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  2015. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  2016. </if>
  2017. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  2018. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  2019. </if>
  2020. </if>
  2021. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  2022. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  2023. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  2024. </if>
  2025. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  2026. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  2027. </if>
  2028. </if>
  2029. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  2030. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  2031. </if>
  2032. ) t2
  2033. )t
  2034. </select>
  2035. <!-- 科室缺陷占比(主任医生) -->
  2036. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  2037. SELECT
  2038. t.*
  2039. FROM
  2040. (
  2041. SELECT
  2042. t1.NAME,
  2043. t1.num AS num,
  2044. t2.totle AS totleNum,
  2045. round( t1.num / t2.totle, 4 ) AS percent,
  2046. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  2047. FROM
  2048. (
  2049. SELECT
  2050. d.msg as name,
  2051. count(*) AS num
  2052. FROM
  2053. med_behospital_info a,
  2054. med_qcresult_info c,
  2055. med_qcresult_detail d,
  2056. sys_user_dept e
  2057. WHERE
  2058. a.behospital_code = c.behospital_code
  2059. AND a.hospital_id = c.hospital_id
  2060. AND a.behospital_code = d.behospital_code
  2061. AND a.hospital_id = d.hospital_id
  2062. AND a.is_deleted = 'N'
  2063. AND c.is_deleted = 'N'
  2064. AND d.is_deleted = 'N'
  2065. AND e.is_deleted = 'N'
  2066. AND a.beh_dept_id = e.dept_id
  2067. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  2068. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  2069. </if>
  2070. <![CDATA[AND a.qc_type_id <>0 ]]>
  2071. <if test="filterPageByDeptVO.userId!=null">
  2072. AND e.user_id = #{filterPageByDeptVO.userId}
  2073. </if>
  2074. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  2075. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  2076. </if>
  2077. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  2078. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2079. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  2080. </if>
  2081. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2082. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  2083. </if>
  2084. </if>
  2085. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  2086. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2087. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  2088. </if>
  2089. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2090. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  2091. </if>
  2092. </if>
  2093. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  2094. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  2095. </if>
  2096. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  2097. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  2098. </if>
  2099. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  2100. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  2101. </if>
  2102. GROUP BY
  2103. d.msg
  2104. ORDER BY
  2105. count(*) DESC
  2106. ) t1,
  2107. (
  2108. SELECT
  2109. count(*) AS totle
  2110. FROM
  2111. med_behospital_info a,
  2112. med_qcresult_info c,
  2113. med_qcresult_detail d,
  2114. sys_user_dept e
  2115. WHERE
  2116. a.behospital_code = c.behospital_code
  2117. AND a.hospital_id = c.hospital_id
  2118. AND a.behospital_code = d.behospital_code
  2119. AND a.hospital_id = d.hospital_id
  2120. AND a.is_deleted = 'N'
  2121. AND c.is_deleted = 'N'
  2122. AND d.is_deleted = 'N'
  2123. AND e.is_deleted = 'N'
  2124. AND a.beh_dept_id = e.dept_id
  2125. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  2126. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  2127. </if>
  2128. <![CDATA[AND a.qc_type_id <>0 ]]>
  2129. <if test="filterPageByDeptVO.userId!=null">
  2130. AND e.user_id = #{filterPageByDeptVO.userId}
  2131. </if>
  2132. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  2133. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  2134. </if>
  2135. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  2136. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2137. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  2138. </if>
  2139. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2140. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  2141. </if>
  2142. </if>
  2143. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  2144. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  2145. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  2146. </if>
  2147. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  2148. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  2149. </if>
  2150. </if>
  2151. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  2152. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  2153. </if>
  2154. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  2155. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  2156. </if>
  2157. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  2158. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  2159. </if>
  2160. ) t2
  2161. )t
  2162. </select>
  2163. <!-- 各科室缺陷占比(组合)-全院 -->
  2164. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2165. resultType="com.diagbot.dto.LevelStatisticsDTO">
  2166. SELECT
  2167. m1.deptId,
  2168. m1.deptName,
  2169. m1.entryNum,
  2170. m2.sameNum,
  2171. m1.mrNum,
  2172. m2.sameMrNum,
  2173. m1.totleValue,
  2174. m2.sameTotleValue,
  2175. m1.averageValue,
  2176. m2.sameAvgValue,
  2177. m1.firstLevelNum,
  2178. m2.sameFirstLevelNum,
  2179. m1.secondLevelNum,
  2180. m2.sameSecondLevelNum,
  2181. m1.thirdLevelNum,
  2182. m2.sameThirdLevelNum,
  2183. m1.firstLevelPercent,
  2184. m2.sameFirstLevelPercent,
  2185. m1.secondLevelPercent,
  2186. m2.sameSecondLevelPercent,
  2187. m1.thirdLevelPercent,
  2188. m2.sameThirdLevelPercent,
  2189. m1.firstLevelPercentStr,
  2190. m2.sameFirstLevelPercentStr,
  2191. m1.secondLevelPercentStr,
  2192. m2.sameSecondLevelPercentStr,
  2193. m1.thirdLevelPercentStr,
  2194. m2.sameThirdLevelPercentStr
  2195. FROM
  2196. (
  2197. SELECT
  2198. t1.deptId,
  2199. t1.deptName,
  2200. t2.entryNum,
  2201. t1.mrNum,
  2202. t1.totleValue,
  2203. t1.averageValue,
  2204. t1.firstLevelNum,
  2205. t1.secondLevelNum,
  2206. t1.thirdLevelNum,
  2207. t1.firstLevelPercent,
  2208. t1.secondLevelPercent,
  2209. t1.thirdLevelPercent,
  2210. t1.firstLevelPercentStr,
  2211. t1.secondLevelPercentStr,
  2212. t1.thirdLevelPercentStr
  2213. FROM
  2214. (
  2215. SELECT
  2216. a.beh_dept_id AS deptId,
  2217. a.beh_dept_name AS deptName,
  2218. count(*) AS mrNum,
  2219. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2220. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2221. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2222. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2223. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2224. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2225. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2226. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2227. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2228. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2229. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2230. FROM
  2231. med_behospital_info a,
  2232. med_qcresult_info c
  2233. WHERE
  2234. a.is_deleted = 'N'
  2235. AND c.is_deleted = 'N'
  2236. AND a.hospital_id = c.hospital_id
  2237. AND a.behospital_code = c.behospital_code
  2238. <if test="isPlacefile != null and isPlacefile != ''">
  2239. and a.is_placefile = #{isPlacefile}
  2240. </if>
  2241. AND a.qc_type_id != 0
  2242. <if test="hospitalId != null and hospitalId != ''">
  2243. AND a.hospital_id = #{hospitalId}
  2244. </if>
  2245. <if test="isPlacefile != null and isPlacefile == 0">
  2246. <if test="startDate != null and startDate != ''">
  2247. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2248. </if>
  2249. <if test="endDate != null and endDate != ''">
  2250. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2251. </if>
  2252. </if>
  2253. <if test="isPlacefile != null and isPlacefile == 1">
  2254. <if test="startDate != null and startDate != ''">
  2255. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2256. </if>
  2257. <if test="endDate != null and endDate != ''">
  2258. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2259. </if>
  2260. </if>
  2261. <if test="level != null and level != ''">
  2262. and c.level = #{level}
  2263. </if>
  2264. <if test="deptName != null and deptName != ''">
  2265. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2266. </if>
  2267. GROUP BY
  2268. a.beh_dept_id,
  2269. a.beh_dept_name
  2270. ) t1,
  2271. (
  2272. SELECT
  2273. a.beh_dept_id AS deptId,
  2274. a.beh_dept_name AS deptName,
  2275. count( * ) AS entryNum
  2276. FROM
  2277. med_behospital_info a,
  2278. med_qcresult_info c,
  2279. med_qcresult_detail d,
  2280. qc_cases_entry e
  2281. WHERE
  2282. a.is_deleted = 'N'
  2283. AND c.is_deleted = 'N'
  2284. AND d.is_deleted = 'N'
  2285. AND e.is_deleted = 'N'
  2286. AND a.hospital_id = c.hospital_id
  2287. AND a.hospital_id = d.hospital_id
  2288. AND a.behospital_code = c.behospital_code
  2289. AND a.behospital_code = d.behospital_code
  2290. AND d.cases_id = e.cases_id
  2291. AND d.cases_entry_id = e.id
  2292. <if test="isPlacefile != null and isPlacefile != ''">
  2293. and a.is_placefile = #{isPlacefile}
  2294. </if>
  2295. AND a.qc_type_id != 0
  2296. <if test="hospitalId != null and hospitalId != ''">
  2297. AND a.hospital_id = #{hospitalId}
  2298. </if>
  2299. <if test="isPlacefile != null and isPlacefile == 0">
  2300. <if test="startDate != null and startDate != ''">
  2301. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2302. </if>
  2303. <if test="endDate != null and endDate != ''">
  2304. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2305. </if>
  2306. </if>
  2307. <if test="isPlacefile != null and isPlacefile == 1">
  2308. <if test="startDate != null and startDate != ''">
  2309. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2310. </if>
  2311. <if test="endDate != null and endDate != ''">
  2312. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2313. </if>
  2314. </if>
  2315. <if test="level != null and level != ''">
  2316. and c.level = #{level}
  2317. </if>
  2318. <if test="deptName != null and deptName != ''">
  2319. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2320. </if>
  2321. GROUP BY
  2322. a.beh_dept_id,
  2323. a.beh_dept_name
  2324. ) t2
  2325. WHERE
  2326. t1.deptId = t2.deptId
  2327. AND t1.deptName = t2.deptName)m1 left join
  2328. ( SELECT
  2329. t1.deptId,
  2330. t1.deptName,
  2331. t2.entryNum as sameNum,
  2332. t1.mrNum as sameMrNum,
  2333. t1.totleValue as sameTotleValue,
  2334. t1.averageValue as sameAvgValue,
  2335. t1.firstLevelNum as sameFirstLevelNum,
  2336. t1.secondLevelNum as sameSecondLevelNum,
  2337. t1.thirdLevelNum as sameThirdLevelNum,
  2338. t1.firstLevelPercent as sameFirstLevelPercent,
  2339. t1.secondLevelPercent as sameSecondLevelPercent,
  2340. t1.thirdLevelPercent as sameThirdLevelPercent,
  2341. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2342. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2343. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2344. FROM
  2345. (
  2346. SELECT
  2347. a.beh_dept_id AS deptId,
  2348. a.beh_dept_name AS deptName,
  2349. count(*) AS mrNum,
  2350. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2351. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2352. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2353. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2354. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2355. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2356. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2357. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2358. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2359. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2360. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2361. FROM
  2362. med_behospital_info a,
  2363. med_qcresult_info c
  2364. WHERE
  2365. a.is_deleted = 'N'
  2366. AND c.is_deleted = 'N'
  2367. AND a.hospital_id = c.hospital_id
  2368. AND a.behospital_code = c.behospital_code
  2369. <if test="isPlacefile != null and isPlacefile != ''">
  2370. and a.is_placefile = #{isPlacefile}
  2371. </if>
  2372. AND a.qc_type_id != 0
  2373. <if test="hospitalId != null and hospitalId != ''">
  2374. AND a.hospital_id = #{hospitalId}
  2375. </if>
  2376. <if test="isPlacefile != null and isPlacefile == 0">
  2377. <if test="lastStartDate != null and lastStartDate != ''">
  2378. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2379. </if>
  2380. <if test="lastEndDate != null and lastEndDate != ''">
  2381. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2382. </if>
  2383. </if>
  2384. <if test="isPlacefile != null and isPlacefile == 1">
  2385. <if test="lastStartDate != null and lastStartDate != ''">
  2386. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2387. </if>
  2388. <if test="lastEndDate != null and lastEndDate != ''">
  2389. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2390. </if>
  2391. </if>
  2392. <if test="level != null and level != ''">
  2393. and c.level = #{level}
  2394. </if>
  2395. <if test="deptName != null and deptName != ''">
  2396. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2397. </if>
  2398. GROUP BY
  2399. a.beh_dept_id,
  2400. a.beh_dept_name
  2401. ) t1,
  2402. (
  2403. SELECT
  2404. a.beh_dept_id AS deptId,
  2405. a.beh_dept_name AS deptName,
  2406. count( * ) AS entryNum
  2407. FROM
  2408. med_behospital_info a,
  2409. med_qcresult_info c,
  2410. med_qcresult_detail d,
  2411. qc_cases_entry e
  2412. WHERE
  2413. a.is_deleted = 'N'
  2414. AND c.is_deleted = 'N'
  2415. AND d.is_deleted = 'N'
  2416. AND e.is_deleted = 'N'
  2417. AND a.hospital_id = c.hospital_id
  2418. AND a.hospital_id = d.hospital_id
  2419. AND a.behospital_code = c.behospital_code
  2420. AND a.behospital_code = d.behospital_code
  2421. AND d.cases_id = e.cases_id
  2422. AND d.cases_entry_id = e.id
  2423. <if test="isPlacefile != null and isPlacefile != ''">
  2424. and a.is_placefile = #{isPlacefile}
  2425. </if>
  2426. AND a.qc_type_id != 0
  2427. <if test="hospitalId != null and hospitalId != ''">
  2428. AND a.hospital_id = #{hospitalId}
  2429. </if>
  2430. <if test="isPlacefile != null and isPlacefile == 0">
  2431. <if test="lastStartDate != null and lastStartDate != ''">
  2432. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2433. </if>
  2434. <if test="lastEndDate != null and lastEndDate != ''">
  2435. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2436. </if>
  2437. </if>
  2438. <if test="isPlacefile != null and isPlacefile == 1">
  2439. <if test="lastStartDate != null and lastStartDate != ''">
  2440. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2441. </if>
  2442. <if test="lastEndDate != null and lastEndDate != ''">
  2443. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2444. </if>
  2445. </if>
  2446. <if test="level != null and level != ''">
  2447. and c.level = #{level}
  2448. </if>
  2449. <if test="deptName != null and deptName != ''">
  2450. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2451. </if>
  2452. GROUP BY
  2453. a.beh_dept_id,
  2454. a.beh_dept_name
  2455. ) t2
  2456. WHERE
  2457. t1.deptId = t2.deptId
  2458. AND t1.deptName = t2.deptName)m2
  2459. on
  2460. m1.deptId = m2.deptId
  2461. AND m1.deptName = m2.deptName
  2462. <if test="asc != null and asc !=''">
  2463. order by
  2464. <choose>
  2465. <when test='asc=="deptId"'>m1.deptId asc</when>
  2466. <when test='asc=="deptName"'>m1.deptName asc</when>
  2467. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2468. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2469. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2470. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2471. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2472. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2473. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2474. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2475. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2476. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2477. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2478. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2479. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2480. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2481. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2482. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2483. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2484. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2485. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2486. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2487. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2488. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2489. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2490. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2491. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2492. <otherwise>deptName asc</otherwise>
  2493. </choose>
  2494. </if>
  2495. <if test="desc != null and desc!=''">
  2496. order by
  2497. <choose>
  2498. <when test='desc=="deptId"'>m1.deptId desc</when>
  2499. <when test='desc=="deptName"'>m1.deptName desc</when>
  2500. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2501. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2502. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2503. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2504. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2505. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2506. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2507. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2508. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2509. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2510. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2511. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2512. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2513. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2514. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2515. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2516. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2517. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2518. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2519. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2520. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2521. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2522. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2523. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2524. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2525. <otherwise>deptName desc</otherwise>
  2526. </choose>
  2527. </if>
  2528. </select>
  2529. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  2530. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  2531. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2532. SELECT
  2533. t1.deptId,
  2534. t1.deptName,
  2535. t1.deptClassId,
  2536. t1.deptClass,
  2537. t2.entryNum,
  2538. t1.mrNum,
  2539. t1.totleValue,
  2540. t1.averageValue,
  2541. t1.firstLevelNum,
  2542. t1.secondLevelNum,
  2543. t1.thirdLevelNum,
  2544. t1.firstLevelPercent,
  2545. t1.secondLevelPercent,
  2546. t1.thirdLevelPercent,
  2547. t1.firstLevelPercentStr,
  2548. t1.secondLevelPercentStr,
  2549. t1.thirdLevelPercentStr
  2550. FROM
  2551. (
  2552. SELECT
  2553. a.beh_dept_id AS deptId,
  2554. a.beh_dept_name AS deptName,
  2555. e.dept_id AS deptClassId,
  2556. e.dept_name AS deptClass,
  2557. count( DISTINCT c.id ) AS mrNum,
  2558. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2559. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  2560. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  2561. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  2562. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  2563. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  2564. ) AS firstLevelPercent,
  2565. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2566. ) AS secondLevelPercent,
  2567. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2568. ) AS thirdLevelPercent,
  2569. concat(
  2570. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  2571. 100, 2 ),
  2572. '%'
  2573. ) AS firstLevelPercentStr,
  2574. concat(
  2575. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  2576. 100, 2 ),
  2577. '%'
  2578. ) AS secondLevelPercentStr,
  2579. concat(
  2580. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  2581. 100, 2 ),
  2582. '%'
  2583. ) AS thirdLevelPercentStr
  2584. FROM
  2585. med_behospital_info a,
  2586. med_qcresult_info c,
  2587. bas_dept_info d,
  2588. bas_dept_info e
  2589. WHERE
  2590. a.is_deleted = 'N'
  2591. AND c.is_deleted = 'N'
  2592. AND d.is_deleted = 'N'
  2593. AND e.is_deleted = 'N'
  2594. AND a.hospital_id = c.hospital_id
  2595. AND a.hospital_id = d.hospital_id
  2596. AND a.hospital_id = e.hospital_id
  2597. AND a.behospital_code = c.behospital_code
  2598. AND a.beh_dept_id = d.dept_id
  2599. AND d.parent_dept_id = e.dept_id
  2600. <if test="isPlacefile != null and isPlacefile != ''">
  2601. and a.is_placefile = #{isPlacefile}
  2602. </if>
  2603. <![CDATA[AND a.qc_type_id <>0 ]]>
  2604. <if test="hospitalId != null and hospitalId != ''">
  2605. AND a.hospital_id = #{hospitalId}
  2606. </if>
  2607. <if test="isPlacefile != null and isPlacefile == 0">
  2608. <if test="startDate != null and startDate != ''">
  2609. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2610. </if>
  2611. <if test="endDate != null and endDate != ''">
  2612. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2613. </if>
  2614. </if>
  2615. <if test="isPlacefile != null and isPlacefile == 1">
  2616. <if test="startDate != null and startDate != ''">
  2617. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2618. </if>
  2619. <if test="endDate != null and endDate != ''">
  2620. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2621. </if>
  2622. </if>
  2623. <if test="level != null and level != ''">
  2624. and c.level = #{level}
  2625. </if>
  2626. <if test="deptName != null and deptName != ''">
  2627. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2628. </if>
  2629. <if test="deptClass != null and deptClass != ''">
  2630. and e.dept_name = #{deptClass}
  2631. </if>
  2632. GROUP BY
  2633. a.beh_dept_id,
  2634. a.beh_dept_name,
  2635. e.dept_id,
  2636. e.dept_name
  2637. ) t1,
  2638. (
  2639. SELECT
  2640. a.beh_dept_id AS deptId,
  2641. a.beh_dept_name AS deptName,
  2642. g.dept_id AS deptClassId,
  2643. g.dept_name AS deptClass,
  2644. count( * ) AS entryNum
  2645. FROM
  2646. med_behospital_info a,
  2647. med_qcresult_info c,
  2648. med_qcresult_detail d,
  2649. qc_cases_entry e,
  2650. bas_dept_info f,
  2651. bas_dept_info g
  2652. WHERE
  2653. a.is_deleted = 'N'
  2654. AND c.is_deleted = 'N'
  2655. AND d.is_deleted = 'N'
  2656. AND e.is_deleted = 'N'
  2657. AND f.is_deleted = 'N'
  2658. AND g.is_deleted = 'N'
  2659. AND a.hospital_id = c.hospital_id
  2660. AND a.hospital_id = d.hospital_id
  2661. AND a.hospital_id = f.hospital_id
  2662. AND a.hospital_id = g.hospital_id
  2663. AND a.behospital_code = c.behospital_code
  2664. AND a.behospital_code = d.behospital_code
  2665. AND d.cases_id = e.cases_id
  2666. AND d.cases_entry_id = e.id
  2667. AND a.beh_dept_id = f.dept_id
  2668. AND f.parent_dept_id = g.dept_id
  2669. <if test="isPlacefile != null and isPlacefile != ''">
  2670. and a.is_placefile = #{isPlacefile}
  2671. </if>
  2672. <![CDATA[AND a.qc_type_id <>0 ]]>
  2673. <if test="hospitalId != null and hospitalId != ''">
  2674. AND a.hospital_id = #{hospitalId}
  2675. </if>
  2676. <if test="isPlacefile != null and isPlacefile == 0">
  2677. <if test="startDate != null and startDate != ''">
  2678. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2679. </if>
  2680. <if test="endDate != null and endDate != ''">
  2681. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2682. </if>
  2683. </if>
  2684. <if test="isPlacefile != null and isPlacefile == 1">
  2685. <if test="startDate != null and startDate != ''">
  2686. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2687. </if>
  2688. <if test="endDate != null and endDate != ''">
  2689. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2690. </if>
  2691. </if>
  2692. <if test="level != null and level != ''">
  2693. and c.level = #{level}
  2694. </if>
  2695. <if test="deptName != null and deptName != ''">
  2696. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2697. </if>
  2698. <if test="deptClass != null and deptClass != ''">
  2699. and g.dept_name = #{deptClass}
  2700. </if>
  2701. GROUP BY
  2702. a.beh_dept_id,
  2703. a.beh_dept_name,
  2704. g.dept_id,
  2705. g.dept_name
  2706. ) t2
  2707. WHERE
  2708. t1.deptId = t2.deptId
  2709. AND t1.deptName = t2.deptName
  2710. AND t1.deptClassId = t2.deptClassId
  2711. AND t1.deptClass = t2.deptClass
  2712. <if test="asc != null and asc !=''">
  2713. order by
  2714. <choose>
  2715. <when test='asc=="deptId"'>deptId asc</when>
  2716. <when test='asc=="deptName"'>deptName asc</when>
  2717. <when test='asc=="deptClassId"'>deptClassId asc</when>
  2718. <when test='asc=="deptClass"'>deptClass asc</when>
  2719. <when test='asc=="entryNum"'>entryNum asc</when>
  2720. <when test='asc=="mrNum"'>mrNum asc</when>
  2721. <when test='asc=="totleValue"'>totleValue asc</when>
  2722. <when test='asc=="averageValue"'>averageValue asc</when>
  2723. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2724. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2725. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2726. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2727. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2728. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2729. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2730. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2731. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2732. <otherwise>deptName asc</otherwise>
  2733. </choose>
  2734. </if>
  2735. <if test="desc != null and desc!=''">
  2736. order by
  2737. <choose>
  2738. <when test='desc=="deptId"'>deptId desc</when>
  2739. <when test='desc=="deptName"'>deptName desc</when>
  2740. <when test='desc=="deptClassId"'>deptClassId desc</when>
  2741. <when test='desc=="deptClass"'>deptClass desc</when>
  2742. <when test='desc=="entryNum"'>entryNum desc</when>
  2743. <when test='desc=="mrNum"'>mrNum desc</when>
  2744. <when test='desc=="totleValue"'>totleValue desc</when>
  2745. <when test='desc=="averageValue"'>averageValue desc</when>
  2746. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2747. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2748. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2749. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2750. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2751. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2752. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2753. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2754. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2755. <otherwise>deptName desc</otherwise>
  2756. </choose>
  2757. </if>
  2758. </select>
  2759. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  2760. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2761. select
  2762. m1.deptId,
  2763. m1.deptName,
  2764. m1.deptClassId,
  2765. m1.deptClass,
  2766. m1.entryNum,
  2767. m2.sameNum,
  2768. m1.mrNum,
  2769. m2.sameMrNum,
  2770. m1.totleValue,
  2771. m2.sameTotleValue,
  2772. m1.averageValue,
  2773. m2.sameAvgValue,
  2774. m1.firstLevelNum,
  2775. m2.sameFirstLevelNum,
  2776. m1.secondLevelNum,
  2777. m2.sameSecondLevelNum,
  2778. m1.thirdLevelNum,
  2779. m2.sameThirdLevelNum,
  2780. m1.firstLevelPercent,
  2781. m2.sameFirstLevelPercent,
  2782. m1.secondLevelPercent,
  2783. m2.sameSecondLevelPercent,
  2784. m1.thirdLevelPercent,
  2785. m2.sameThirdLevelPercent,
  2786. m1.firstLevelPercentStr,
  2787. m2.sameFirstLevelPercentStr,
  2788. m1.secondLevelPercentStr,
  2789. m2.sameSecondLevelPercentStr,
  2790. m1.thirdLevelPercentStr,
  2791. m2.sameThirdLevelPercentStr
  2792. from (
  2793. SELECT
  2794. t1.deptId,
  2795. t1.deptName,
  2796. t1.deptClassId,
  2797. t1.deptClass,
  2798. t2.entryNum,
  2799. t1.mrNum,
  2800. t1.totleValue,
  2801. t1.averageValue,
  2802. t1.firstLevelNum,
  2803. t1.secondLevelNum,
  2804. t1.thirdLevelNum,
  2805. t1.firstLevelPercent,
  2806. t1.secondLevelPercent,
  2807. t1.thirdLevelPercent,
  2808. t1.firstLevelPercentStr,
  2809. t1.secondLevelPercentStr,
  2810. t1.thirdLevelPercentStr
  2811. FROM
  2812. (
  2813. SELECT
  2814. tt1.deptId,
  2815. tt1.deptName,
  2816. e.dept_id AS deptClassId,
  2817. e.dept_name AS deptClass,
  2818. count(*) AS mrNum,
  2819. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2820. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2821. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2822. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2823. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2824. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2825. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2826. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2827. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2828. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2829. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2830. FROM
  2831. (
  2832. SELECT
  2833. a.beh_dept_id AS deptId,
  2834. a.beh_dept_name AS deptName,
  2835. d.parent_dept_id AS parentDeptId,
  2836. a.hospital_id AS hospitalId,
  2837. a.behospital_code AS behospitalCode,
  2838. c.score_res AS score,
  2839. c.LEVEL
  2840. FROM
  2841. med_behospital_info a,
  2842. med_qcresult_info c,
  2843. bas_dept_info d
  2844. WHERE
  2845. a.is_deleted = 'N'
  2846. AND c.is_deleted = 'N'
  2847. AND d.is_deleted = 'N'
  2848. AND a.hospital_id = c.hospital_id
  2849. AND a.hospital_id = d.hospital_id
  2850. AND a.behospital_code = c.behospital_code
  2851. AND a.beh_dept_id = d.dept_id
  2852. <if test="isPlacefile != null and isPlacefile != ''">
  2853. and a.is_placefile = #{isPlacefile}
  2854. </if>
  2855. AND a.qc_type_id != 0
  2856. <if test="hospitalId != null and hospitalId != ''">
  2857. AND a.hospital_id = #{hospitalId}
  2858. </if>
  2859. <if test="isPlacefile != null and isPlacefile == 0">
  2860. <if test="startDate != null and startDate != ''">
  2861. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2862. </if>
  2863. <if test="endDate != null and endDate != ''">
  2864. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2865. </if>
  2866. </if>
  2867. <if test="isPlacefile != null and isPlacefile == 1">
  2868. <if test="startDate != null and startDate != ''">
  2869. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2870. </if>
  2871. <if test="endDate != null and endDate != ''">
  2872. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2873. </if>
  2874. </if>
  2875. <if test="level != null and level != ''">
  2876. and c.level = #{level}
  2877. </if>
  2878. <if test="deptName != null and deptName != ''">
  2879. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2880. </if>
  2881. ) tt1
  2882. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2883. AND e.is_deleted = 'N'
  2884. AND tt1.hospitalId = e.hospital_id
  2885. <if test="deptClass != null and deptClass != ''">
  2886. WHERE e.dept_name = #{deptClass}
  2887. </if>
  2888. GROUP BY
  2889. tt1.deptId,
  2890. tt1.deptName,
  2891. e.dept_id,
  2892. e.dept_name
  2893. ) t1,
  2894. (
  2895. SELECT
  2896. tt2.deptId,
  2897. tt2.deptName,
  2898. g.dept_id AS deptClassId,
  2899. g.dept_name AS deptClass,
  2900. count( * ) AS entryNum
  2901. FROM
  2902. (
  2903. SELECT
  2904. a.beh_dept_id AS deptId,
  2905. a.beh_dept_name AS deptName,
  2906. f.parent_dept_id AS parentDeptId,
  2907. a.hospital_id AS hospitalId,
  2908. a.behospital_code AS behospitalCode
  2909. FROM
  2910. med_behospital_info a,
  2911. med_qcresult_info c,
  2912. med_qcresult_detail d,
  2913. qc_cases_entry e,
  2914. bas_dept_info f
  2915. WHERE
  2916. a.is_deleted = 'N'
  2917. AND c.is_deleted = 'N'
  2918. AND d.is_deleted = 'N'
  2919. AND e.is_deleted = 'N'
  2920. AND f.is_deleted = 'N'
  2921. AND a.hospital_id = c.hospital_id
  2922. AND a.hospital_id = d.hospital_id
  2923. AND a.hospital_id = f.hospital_id
  2924. AND a.behospital_code = c.behospital_code
  2925. AND a.behospital_code = d.behospital_code
  2926. AND d.cases_id = e.cases_id
  2927. AND d.cases_entry_id = e.id
  2928. AND a.beh_dept_id = f.dept_id
  2929. <if test="isPlacefile != null and isPlacefile != ''">
  2930. and a.is_placefile = #{isPlacefile}
  2931. </if>
  2932. AND a.qc_type_id != 0
  2933. <if test="hospitalId != null and hospitalId != ''">
  2934. AND a.hospital_id = #{hospitalId}
  2935. </if>
  2936. <if test="isPlacefile != null and isPlacefile == 0">
  2937. <if test="startDate != null and startDate != ''">
  2938. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2939. </if>
  2940. <if test="endDate != null and endDate != ''">
  2941. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2942. </if>
  2943. </if>
  2944. <if test="isPlacefile != null and isPlacefile == 1">
  2945. <if test="startDate != null and startDate != ''">
  2946. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2947. </if>
  2948. <if test="endDate != null and endDate != ''">
  2949. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2950. </if>
  2951. </if>
  2952. <if test="level != null and level != ''">
  2953. and c.level = #{level}
  2954. </if>
  2955. <if test="deptName != null and deptName != ''">
  2956. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2957. </if>
  2958. ) tt2
  2959. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2960. AND g.is_deleted = 'N'
  2961. AND tt2.hospitalId = g.hospital_id
  2962. <if test="deptClass != null and deptClass != ''">
  2963. WHERE g.dept_name = #{deptClass}
  2964. </if>
  2965. GROUP BY
  2966. tt2.deptId,
  2967. tt2.deptName,
  2968. g.dept_id,
  2969. g.dept_name
  2970. ) t2
  2971. WHERE
  2972. t1.deptId = t2.deptId
  2973. AND t1.deptName = t2.deptName)m1 left join
  2974. ( SELECT
  2975. t1.deptId,
  2976. t1.deptName,
  2977. t1.deptClassId,
  2978. t1.deptClass,
  2979. t2.entryNum as sameNum,
  2980. t1.mrNum as sameMrNum,
  2981. t1.totleValue as sameTotleValue,
  2982. t1.averageValue as sameAvgValue,
  2983. t1.firstLevelNum as sameFirstLevelNum,
  2984. t1.secondLevelNum as sameSecondLevelNum,
  2985. t1.thirdLevelNum as sameThirdLevelNum,
  2986. t1.firstLevelPercent as sameFirstLevelPercent,
  2987. t1.secondLevelPercent as sameSecondLevelPercent,
  2988. t1.thirdLevelPercent as sameThirdLevelPercent,
  2989. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2990. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2991. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2992. FROM
  2993. (
  2994. SELECT
  2995. tt1.deptId,
  2996. tt1.deptName,
  2997. e.dept_id AS deptClassId,
  2998. e.dept_name AS deptClass,
  2999. count(*) AS mrNum,
  3000. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3001. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3002. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  3003. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  3004. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  3005. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  3006. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  3007. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  3008. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3009. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3010. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3011. FROM
  3012. (
  3013. SELECT
  3014. a.beh_dept_id AS deptId,
  3015. a.beh_dept_name AS deptName,
  3016. d.parent_dept_id AS parentDeptId,
  3017. a.hospital_id AS hospitalId,
  3018. a.behospital_code AS behospitalCode,
  3019. c.score_res AS score,
  3020. c.LEVEL
  3021. FROM
  3022. med_behospital_info a,
  3023. med_qcresult_info c,
  3024. bas_dept_info d
  3025. WHERE
  3026. a.is_deleted = 'N'
  3027. AND c.is_deleted = 'N'
  3028. AND d.is_deleted = 'N'
  3029. AND a.hospital_id = c.hospital_id
  3030. AND a.hospital_id = d.hospital_id
  3031. AND a.behospital_code = c.behospital_code
  3032. AND a.beh_dept_id = d.dept_id
  3033. <if test="isPlacefile != null and isPlacefile != ''">
  3034. and a.is_placefile = #{isPlacefile}
  3035. </if>
  3036. AND a.qc_type_id != 0
  3037. <if test="hospitalId != null and hospitalId != ''">
  3038. AND a.hospital_id = #{hospitalId}
  3039. </if>
  3040. <if test="isPlacefile != null and isPlacefile == 0">
  3041. <if test="lastStartDate != null and lastStartDate != ''">
  3042. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3043. </if>
  3044. <if test="lastEndDate != null and lastEndDate != ''">
  3045. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3046. </if>
  3047. </if>
  3048. <if test="isPlacefile != null and isPlacefile == 1">
  3049. <if test="lastStartDate != null and lastStartDate != ''">
  3050. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3051. </if>
  3052. <if test="lastEndDate != null and lastEndDate != ''">
  3053. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3054. </if>
  3055. </if>
  3056. <if test="level != null and level != ''">
  3057. and c.level = #{level}
  3058. </if>
  3059. <if test="deptName != null and deptName != ''">
  3060. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3061. </if>
  3062. ) tt1
  3063. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  3064. AND e.is_deleted = 'N'
  3065. AND tt1.hospitalId = e.hospital_id
  3066. <if test="deptClass != null and deptClass != ''">
  3067. WHERE e.dept_name = #{deptClass}
  3068. </if>
  3069. GROUP BY
  3070. tt1.deptId,
  3071. tt1.deptName,
  3072. e.dept_id,
  3073. e.dept_name
  3074. ) t1,
  3075. (
  3076. SELECT
  3077. tt2.deptId,
  3078. tt2.deptName,
  3079. g.dept_id AS deptClassId,
  3080. g.dept_name AS deptClass,
  3081. count( * ) AS entryNum
  3082. FROM
  3083. (
  3084. SELECT
  3085. a.beh_dept_id AS deptId,
  3086. a.beh_dept_name AS deptName,
  3087. f.parent_dept_id AS parentDeptId,
  3088. a.hospital_id AS hospitalId,
  3089. a.behospital_code AS behospitalCode
  3090. FROM
  3091. med_behospital_info a,
  3092. med_qcresult_info c,
  3093. med_qcresult_detail d,
  3094. qc_cases_entry e,
  3095. bas_dept_info f
  3096. WHERE
  3097. a.is_deleted = 'N'
  3098. AND c.is_deleted = 'N'
  3099. AND d.is_deleted = 'N'
  3100. AND e.is_deleted = 'N'
  3101. AND f.is_deleted = 'N'
  3102. AND a.hospital_id = c.hospital_id
  3103. AND a.hospital_id = d.hospital_id
  3104. AND a.hospital_id = f.hospital_id
  3105. AND a.behospital_code = c.behospital_code
  3106. AND a.behospital_code = d.behospital_code
  3107. AND d.cases_id = e.cases_id
  3108. AND d.cases_entry_id = e.id
  3109. AND a.beh_dept_id = f.dept_id
  3110. <if test="isPlacefile != null and isPlacefile != ''">
  3111. and a.is_placefile = #{isPlacefile}
  3112. </if>
  3113. AND a.qc_type_id != 0
  3114. <if test="hospitalId != null and hospitalId != ''">
  3115. AND a.hospital_id = #{hospitalId}
  3116. </if>
  3117. <if test="isPlacefile != null and isPlacefile == 0">
  3118. <if test="lastStartDate != null and lastStartDate != ''">
  3119. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3120. </if>
  3121. <if test="lastEndDate != null and lastEndDate != ''">
  3122. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3123. </if>
  3124. </if>
  3125. <if test="isPlacefile != null and isPlacefile == 1">
  3126. <if test="lastStartDate != null and lastStartDate != ''">
  3127. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3128. </if>
  3129. <if test="lastEndDate != null and lastEndDate != ''">
  3130. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3131. </if>
  3132. </if>
  3133. <if test="level != null and level != ''">
  3134. and c.level = #{level}
  3135. </if>
  3136. <if test="deptName != null and deptName != ''">
  3137. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  3138. </if>
  3139. ) tt2
  3140. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  3141. AND g.is_deleted = 'N'
  3142. AND tt2.hospitalId = g.hospital_id
  3143. <if test="deptClass != null and deptClass != ''">
  3144. WHERE g.dept_name = #{deptClass}
  3145. </if>
  3146. GROUP BY
  3147. tt2.deptId,
  3148. tt2.deptName,
  3149. g.dept_id,
  3150. g.dept_name
  3151. ) t2
  3152. WHERE
  3153. t1.deptId = t2.deptId
  3154. AND t1.deptName = t2.deptName)m2
  3155. on
  3156. m1.deptId = m2.deptId
  3157. and m1.deptName = m2.deptName
  3158. <if test="asc != null and asc !=''">
  3159. order by
  3160. <choose>
  3161. <when test='asc=="deptId"'>m1.deptId asc</when>
  3162. <when test='asc=="deptName"'>m1.deptName asc</when>
  3163. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  3164. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  3165. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3166. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3167. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3168. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3169. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3170. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3171. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3172. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3173. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3174. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3175. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3176. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3177. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3178. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3179. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3180. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3181. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3182. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3183. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3184. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3185. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3186. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3187. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3188. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3189. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3190. <otherwise>deptName asc</otherwise>
  3191. </choose>
  3192. </if>
  3193. <if test="desc != null and desc!=''">
  3194. order by
  3195. <choose>
  3196. <when test='desc=="deptId"'>m1.deptId desc</when>
  3197. <when test='desc=="deptName"'>m1.deptName desc</when>
  3198. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  3199. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  3200. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3201. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3202. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3203. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3204. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3205. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3206. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3207. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3208. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3209. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3210. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3211. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3212. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3213. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3214. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3215. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3216. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3217. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3218. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3219. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3220. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3221. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3222. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3223. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3224. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3225. <otherwise>deptName desc</otherwise>
  3226. </choose>
  3227. </if>
  3228. </select>
  3229. <!-- 病案首页合格率占比 -全院-->
  3230. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  3231. resultType="com.diagbot.dto.HomePageNumDTO">
  3232. SELECT
  3233. t1.deptId,
  3234. t1.deptName,
  3235. t2.entryNum,
  3236. t1.mrNum,
  3237. t1.totleValue,
  3238. t1.averageValue,
  3239. t1.firstLevelNum,
  3240. t1.secondLevelNum,
  3241. t1.firstLevelPercent,
  3242. t1.secondLevelPercent,
  3243. t1.firstLevelPercentStr,
  3244. t1.secondLevelPercentStr,
  3245. t3.emptyNum,
  3246. t3.errorNum,
  3247. t3.entryTotleNum,
  3248. t3.emptyPercent,
  3249. t3.errorPercent,
  3250. t3.emptyPercentStr,
  3251. t3.errorPercentStr
  3252. FROM
  3253. (
  3254. SELECT
  3255. a.beh_dept_id AS deptId,
  3256. a.beh_dept_name AS deptName,
  3257. count( * ) AS mrNum,
  3258. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3259. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3260. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3261. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3262. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3263. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3264. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3265. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3266. FROM
  3267. med_behospital_info a,
  3268. med_qcresult_cases c
  3269. WHERE
  3270. a.is_deleted = 'N'
  3271. AND c.is_deleted = 'N'
  3272. AND a.hospital_id = c.hospital_id
  3273. AND a.behospital_code = c.behospital_code
  3274. AND c.cases_id = 243
  3275. <if test="isPlacefile != null and isPlacefile != ''">
  3276. and a.is_placefile = #{isPlacefile}
  3277. </if>
  3278. AND a.qc_type_id != 0
  3279. <if test="hospitalId != null and hospitalId != ''">
  3280. AND a.hospital_id = #{hospitalId}
  3281. </if>
  3282. <if test="isPlacefile != null and isPlacefile == 0">
  3283. <if test="startDate != null and startDate != ''">
  3284. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3285. </if>
  3286. <if test="endDate != null and endDate != ''">
  3287. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3288. </if>
  3289. </if>
  3290. <if test="isPlacefile != null and isPlacefile == 1">
  3291. <if test="startDate != null and startDate != ''">
  3292. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3293. </if>
  3294. <if test="endDate != null and endDate != ''">
  3295. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3296. </if>
  3297. </if>
  3298. <if test="level != null and level != ''">
  3299. and c.level = #{level}
  3300. </if>
  3301. <if test="deptName != null and deptName != ''">
  3302. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3303. </if>
  3304. GROUP BY
  3305. a.beh_dept_id,
  3306. a.beh_dept_name
  3307. ) t1,
  3308. (
  3309. SELECT
  3310. a.beh_dept_id AS deptId,
  3311. a.beh_dept_name AS deptName,
  3312. count( * ) AS entryNum
  3313. FROM
  3314. med_behospital_info a,
  3315. med_qcresult_cases c,
  3316. med_qcresult_detail d,
  3317. qc_cases_entry e
  3318. WHERE
  3319. a.is_deleted = 'N'
  3320. AND c.is_deleted = 'N'
  3321. AND d.is_deleted = 'N'
  3322. AND e.is_deleted = 'N'
  3323. AND a.hospital_id = c.hospital_id
  3324. AND a.hospital_id = d.hospital_id
  3325. AND a.behospital_code = c.behospital_code
  3326. AND a.behospital_code = d.behospital_code
  3327. AND c.cases_id = d.cases_id
  3328. AND d.cases_id = e.cases_id
  3329. AND d.cases_entry_id = e.id
  3330. AND d.cases_id = 243
  3331. <if test="isPlacefile != null and isPlacefile != ''">
  3332. and a.is_placefile = #{isPlacefile}
  3333. </if>
  3334. AND a.qc_type_id != 0
  3335. <if test="hospitalId != null and hospitalId != ''">
  3336. AND a.hospital_id = #{hospitalId}
  3337. </if>
  3338. <if test="isPlacefile != null and isPlacefile == 0">
  3339. <if test="startDate != null and startDate != ''">
  3340. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3341. </if>
  3342. <if test="endDate != null and endDate != ''">
  3343. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3344. </if>
  3345. </if>
  3346. <if test="isPlacefile != null and isPlacefile == 1">
  3347. <if test="startDate != null and startDate != ''">
  3348. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3349. </if>
  3350. <if test="endDate != null and endDate != ''">
  3351. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3352. </if>
  3353. </if>
  3354. <if test="level != null and level != ''">
  3355. and c.level = #{level}
  3356. </if>
  3357. <if test="deptName != null and deptName != ''">
  3358. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3359. </if>
  3360. GROUP BY
  3361. a.beh_dept_id,
  3362. a.beh_dept_name
  3363. ) t2,(
  3364. SELECT
  3365. h1.deptId,
  3366. h1.deptName,
  3367. h1.emptyNum,
  3368. h1.errorNum,
  3369. h1.mrNum,
  3370. h2.entryNum,
  3371. h1.mrNum * h2.entryNum AS entryTotleNum,
  3372. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3373. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3374. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3375. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3376. FROM
  3377. (
  3378. SELECT
  3379. a.beh_dept_id AS deptId,
  3380. a.beh_dept_name AS deptName,
  3381. sum( d.rule_type = 1 ) AS emptyNum,
  3382. sum( d.rule_type = 2 ) AS errorNum,
  3383. count( DISTINCT a.behospital_code ) AS mrNum
  3384. FROM
  3385. med_behospital_info a,
  3386. med_qcresult_cases b,
  3387. med_qcresult_detail c,
  3388. qc_cases_entry d
  3389. WHERE
  3390. a.is_deleted = 'N'
  3391. AND b.is_deleted = 'N'
  3392. AND c.is_deleted = 'N'
  3393. AND d.is_deleted = 'N'
  3394. AND a.hospital_id = b.hospital_id
  3395. AND a.hospital_id = c.hospital_id
  3396. AND a.behospital_code = b.behospital_code
  3397. AND a.behospital_code = c.behospital_code
  3398. AND b.cases_id = c.cases_id
  3399. AND c.cases_id = d.cases_id
  3400. AND c.cases_entry_id = d.id
  3401. <if test="isPlacefile != null and isPlacefile != ''">
  3402. and a.is_placefile = #{isPlacefile}
  3403. </if>
  3404. AND d.cases_id = 243
  3405. AND a.qc_type_id != 0
  3406. <if test="hospitalId != null and hospitalId != ''">
  3407. AND a.hospital_id = #{hospitalId}
  3408. </if>
  3409. <if test="isPlacefile != null and isPlacefile == 0">
  3410. <if test="startDate != null and startDate != ''">
  3411. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3412. </if>
  3413. <if test="endDate != null and endDate != ''">
  3414. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3415. </if>
  3416. </if>
  3417. <if test="isPlacefile != null and isPlacefile == 1">
  3418. <if test="startDate != null and startDate != ''">
  3419. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3420. </if>
  3421. <if test="endDate != null and endDate != ''">
  3422. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3423. </if>
  3424. </if>
  3425. <if test="level != null and level != ''">
  3426. and b.level = #{level}
  3427. </if>
  3428. <if test="deptName != null and deptName != ''">
  3429. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3430. </if>
  3431. GROUP BY
  3432. a.beh_dept_id,
  3433. a.beh_dept_name
  3434. ) h1,(
  3435. SELECT
  3436. count(*) AS entryNum
  3437. FROM
  3438. qc_cases_entry
  3439. WHERE
  3440. is_deleted = 'N'
  3441. AND cases_id = 243
  3442. ) h2
  3443. ) t3
  3444. WHERE
  3445. t1.deptId = t2.deptId
  3446. AND t1.deptId = t3.deptId
  3447. AND t1.deptName = t2.deptName
  3448. AND t1.deptName = t3.deptName
  3449. <if test="asc != null and asc !=''">
  3450. order by
  3451. <choose>
  3452. <when test='asc=="deptId"'>deptId asc</when>
  3453. <when test='asc=="deptName"'>deptName asc</when>
  3454. <when test='asc=="entryNum"'>entryNum asc</when>
  3455. <when test='asc=="mrNum"'>mrNum asc</when>
  3456. <when test='asc=="totleValue"'>totleValue asc</when>
  3457. <when test='asc=="averageValue"'>averageValue asc</when>
  3458. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3459. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3460. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3461. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3462. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3463. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3464. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3465. <when test='asc=="errorNum"'>errorNum asc</when>
  3466. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3467. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3468. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3469. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3470. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3471. <otherwise>deptName asc</otherwise>
  3472. </choose>
  3473. </if>
  3474. <if test="desc != null and desc!=''">
  3475. order by
  3476. <choose>
  3477. <when test='desc=="deptId"'>deptId desc</when>
  3478. <when test='desc=="deptName"'>deptName desc</when>
  3479. <when test='desc=="entryNum"'>entryNum desc</when>
  3480. <when test='desc=="mrNum"'>mrNum desc</when>
  3481. <when test='desc=="totleValue"'>totleValue desc</when>
  3482. <when test='desc=="averageValue"'>averageValue desc</when>
  3483. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3484. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3485. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3486. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3487. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3488. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3489. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3490. <when test='desc=="errorNum"'>errorNum desc</when>
  3491. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3492. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3493. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3494. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3495. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3496. <otherwise>deptName desc</otherwise>
  3497. </choose>
  3498. </if>
  3499. </select>
  3500. <!-- 各科室缺陷占比-科室 -->
  3501. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3502. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3503. SELECT
  3504. m1.doctorId,
  3505. m1.doctorName,
  3506. m1.entryNum,
  3507. m2.sameNum,
  3508. m1.mrNum,
  3509. m2.sameMrNum,
  3510. m1.totleValue,
  3511. m2.sameTotleValue,
  3512. m1.averageValue,
  3513. m2.sameAvgValue,
  3514. m1.firstLevelNum,
  3515. m2.sameFirstLevelNum,
  3516. m1.secondLevelNum,
  3517. m2.sameSecondLevelNum,
  3518. m1.thirdLevelNum,
  3519. m2.sameThirdLevelNum,
  3520. m1.firstLevelPercent,
  3521. m2.sameFirstLevelPercent,
  3522. m1.secondLevelPercent,
  3523. m2.sameSecondLevelPercent,
  3524. m1.thirdLevelPercent,
  3525. m2.sameThirdLevelPercent,
  3526. m1.firstLevelPercentStr,
  3527. m2.sameFirstLevelPercentStr,
  3528. m1.secondLevelPercentStr,
  3529. m2.sameSecondLevelPercentStr,
  3530. m1.thirdLevelPercentStr,
  3531. m2.sameThirdLevelPercentStr
  3532. FROM
  3533. (
  3534. SELECT
  3535. t1.doctorId,
  3536. t1.doctorName,
  3537. t2.entryNum,
  3538. t1.mrNum,
  3539. t1.totleValue,
  3540. t1.averageValue,
  3541. t1.firstLevelNum,
  3542. t1.secondLevelNum,
  3543. t1.thirdLevelNum,
  3544. t1.firstLevelPercent,
  3545. t1.secondLevelPercent,
  3546. t1.thirdLevelPercent,
  3547. t1.firstLevelPercentStr,
  3548. t1.secondLevelPercentStr,
  3549. t1.thirdLevelPercentStr
  3550. FROM
  3551. (
  3552. SELECT
  3553. a.doctor_id AS doctorId,
  3554. a.doctor_name AS doctorName,
  3555. count(*) AS mrNum,
  3556. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3557. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3558. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3559. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3560. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3561. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3562. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3563. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3564. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3565. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3566. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3567. FROM
  3568. med_behospital_info a,
  3569. med_qcresult_info c,
  3570. sys_user_dept e
  3571. WHERE
  3572. a.is_deleted = 'N'
  3573. AND c.is_deleted = 'N'
  3574. AND e.is_deleted = 'N'
  3575. AND a.hospital_id = c.hospital_id
  3576. AND a.behospital_code = c.behospital_code
  3577. AND a.beh_dept_id = e.dept_id
  3578. <if test="isPlacefile != null and isPlacefile != ''">
  3579. and a.is_placefile = #{isPlacefile}
  3580. </if>
  3581. AND a.qc_type_id != 0
  3582. <if test="hospitalId != null and hospitalId != ''">
  3583. AND a.hospital_id = #{hospitalId}
  3584. </if>
  3585. <if test="isPlacefile != null and isPlacefile == 0">
  3586. <if test="startDate != null and startDate != ''">
  3587. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3588. </if>
  3589. <if test="endDate != null and endDate != ''">
  3590. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3591. </if>
  3592. </if>
  3593. <if test="isPlacefile != null and isPlacefile == 1">
  3594. <if test="startDate != null and startDate != ''">
  3595. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3596. </if>
  3597. <if test="endDate != null and endDate != ''">
  3598. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3599. </if>
  3600. </if>
  3601. <if test="level != null and level != ''">
  3602. and c.level = #{level}
  3603. </if>
  3604. <if test="doctorName != null and doctorName != ''">
  3605. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3606. </if>
  3607. <if test="userId!=null and userId !=''">
  3608. AND e.user_id = #{userId}
  3609. </if>
  3610. <if test="deptName != null and deptName != ''">
  3611. and a.beh_dept_name = #{deptName}
  3612. </if>
  3613. GROUP BY
  3614. a.doctor_id,
  3615. a.doctor_name
  3616. ) t1,
  3617. (
  3618. SELECT
  3619. a.doctor_id AS doctorId,
  3620. a.doctor_name AS doctorName,
  3621. count( * ) AS entryNum
  3622. FROM
  3623. med_behospital_info a,
  3624. med_qcresult_info c,
  3625. med_qcresult_detail d,
  3626. qc_cases_entry e,
  3627. sys_user_dept f
  3628. WHERE
  3629. a.is_deleted = 'N'
  3630. AND c.is_deleted = 'N'
  3631. AND d.is_deleted = 'N'
  3632. AND e.is_deleted = 'N'
  3633. AND f.is_deleted = 'N'
  3634. AND a.hospital_id = c.hospital_id
  3635. AND a.hospital_id = d.hospital_id
  3636. AND a.behospital_code = c.behospital_code
  3637. AND a.behospital_code = d.behospital_code
  3638. AND d.cases_id = e.cases_id
  3639. AND d.cases_entry_id = e.id
  3640. AND a.beh_dept_id = f.dept_id
  3641. <if test="isPlacefile != null and isPlacefile != ''">
  3642. and a.is_placefile = #{isPlacefile}
  3643. </if>
  3644. AND a.qc_type_id != 0
  3645. <if test="hospitalId != null and hospitalId != ''">
  3646. AND a.hospital_id = #{hospitalId}
  3647. </if>
  3648. <if test="isPlacefile != null and isPlacefile == 0">
  3649. <if test="startDate != null and startDate != ''">
  3650. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3651. </if>
  3652. <if test="endDate != null and endDate != ''">
  3653. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3654. </if>
  3655. </if>
  3656. <if test="isPlacefile != null and isPlacefile == 1">
  3657. <if test="startDate != null and startDate != ''">
  3658. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3659. </if>
  3660. <if test="endDate != null and endDate != ''">
  3661. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3662. </if>
  3663. </if>
  3664. <if test="level != null and level != ''">
  3665. and c.level = #{level}
  3666. </if>
  3667. <if test="doctorName != null and doctorName != ''">
  3668. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3669. </if>
  3670. <if test="userId!=null and userId !=''">
  3671. AND f.user_id = #{userId}
  3672. </if>
  3673. <if test="deptName != null and deptName != ''">
  3674. and a.beh_dept_name = #{deptName}
  3675. </if>
  3676. GROUP BY
  3677. a.doctor_id,
  3678. a.doctor_name
  3679. ) t2
  3680. WHERE
  3681. t1.doctorId = t2.doctorId
  3682. AND t1.doctorName = t2.doctorName
  3683. )m1 left join
  3684. ( SELECT
  3685. t1.doctorId,
  3686. t1.doctorName,
  3687. t2.entryNum as sameNum,
  3688. t1.mrNum as sameMrNum,
  3689. t1.totleValue as sameTotleValue,
  3690. t1.averageValue as sameAvgValue,
  3691. t1.firstLevelNum as sameFirstLevelNum,
  3692. t1.secondLevelNum as sameSecondLevelNum,
  3693. t1.thirdLevelNum as sameThirdLevelNum,
  3694. t1.firstLevelPercent as sameFirstLevelPercent,
  3695. t1.secondLevelPercent as sameSecondLevelPercent,
  3696. t1.thirdLevelPercent as sameThirdLevelPercent,
  3697. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3698. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3699. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3700. FROM
  3701. (
  3702. SELECT
  3703. a.doctor_id AS doctorId,
  3704. a.doctor_name AS doctorName,
  3705. count(*) AS mrNum,
  3706. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3707. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3708. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3709. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3710. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3711. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3712. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3713. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3714. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3715. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3716. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3717. FROM
  3718. med_behospital_info a,
  3719. med_qcresult_info c,
  3720. sys_user_dept e
  3721. WHERE
  3722. a.is_deleted = 'N'
  3723. AND c.is_deleted = 'N'
  3724. AND e.is_deleted = 'N'
  3725. AND a.hospital_id = c.hospital_id
  3726. AND a.behospital_code = c.behospital_code
  3727. AND a.beh_dept_id = e.dept_id
  3728. <if test="isPlacefile != null and isPlacefile != ''">
  3729. and a.is_placefile = #{isPlacefile}
  3730. </if>
  3731. AND a.qc_type_id != 0
  3732. <if test="hospitalId != null and hospitalId != ''">
  3733. AND a.hospital_id = #{hospitalId}
  3734. </if>
  3735. <if test="isPlacefile != null and isPlacefile == 0">
  3736. <if test="lastStartDate != null and lastStartDate != ''">
  3737. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3738. </if>
  3739. <if test="lastEndDate != null and lastEndDate != ''">
  3740. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3741. </if>
  3742. </if>
  3743. <if test="isPlacefile != null and isPlacefile == 1">
  3744. <if test="lastStartDate != null and lastStartDate != ''">
  3745. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3746. </if>
  3747. <if test="lastEndDate != null and lastEndDate != ''">
  3748. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3749. </if>
  3750. </if>
  3751. <if test="level != null and level != ''">
  3752. and c.level = #{level}
  3753. </if>
  3754. <if test="doctorName != null and doctorName != ''">
  3755. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3756. </if>
  3757. <if test="userId!=null and userId !=''">
  3758. AND e.user_id = #{userId}
  3759. </if>
  3760. <if test="deptName != null and deptName != ''">
  3761. and a.beh_dept_name = #{deptName}
  3762. </if>
  3763. GROUP BY
  3764. a.doctor_id,
  3765. a.doctor_name
  3766. ) t1,
  3767. (
  3768. SELECT
  3769. a.doctor_id AS doctorId,
  3770. a.doctor_name AS doctorName,
  3771. count( * ) AS entryNum
  3772. FROM
  3773. med_behospital_info a,
  3774. med_qcresult_info c,
  3775. med_qcresult_detail d,
  3776. qc_cases_entry e,
  3777. sys_user_dept f
  3778. WHERE
  3779. a.is_deleted = 'N'
  3780. AND c.is_deleted = 'N'
  3781. AND d.is_deleted = 'N'
  3782. AND e.is_deleted = 'N'
  3783. AND f.is_deleted = 'N'
  3784. AND a.hospital_id = c.hospital_id
  3785. AND a.hospital_id = d.hospital_id
  3786. AND a.behospital_code = c.behospital_code
  3787. AND a.behospital_code = d.behospital_code
  3788. AND d.cases_id = e.cases_id
  3789. AND d.cases_entry_id = e.id
  3790. AND a.beh_dept_id = f.dept_id
  3791. <if test="isPlacefile != null and isPlacefile != ''">
  3792. and a.is_placefile = #{isPlacefile}
  3793. </if>
  3794. AND a.qc_type_id != 0
  3795. <if test="hospitalId != null and hospitalId != ''">
  3796. AND a.hospital_id = #{hospitalId}
  3797. </if>
  3798. <if test="isPlacefile != null and isPlacefile == 0">
  3799. <if test="lastStartDate != null and lastStartDate != ''">
  3800. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3801. </if>
  3802. <if test="lastEndDate != null and lastEndDate != ''">
  3803. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3804. </if>
  3805. </if>
  3806. <if test="isPlacefile != null and isPlacefile == 1">
  3807. <if test="lastStartDate != null and lastStartDate != ''">
  3808. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3809. </if>
  3810. <if test="lastEndDate != null and lastEndDate != ''">
  3811. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3812. </if>
  3813. </if>
  3814. <if test="level != null and level != ''">
  3815. and c.level = #{level}
  3816. </if>
  3817. <if test="doctorName != null and doctorName != ''">
  3818. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3819. </if>
  3820. <if test="userId!=null and userId !=''">
  3821. AND f.user_id = #{userId}
  3822. </if>
  3823. <if test="deptName != null and deptName != ''">
  3824. and a.beh_dept_name = #{deptName}
  3825. </if>
  3826. GROUP BY
  3827. a.doctor_id,
  3828. a.doctor_name
  3829. ) t2
  3830. WHERE
  3831. t1.doctorId = t2.doctorId
  3832. AND t1.doctorName = t2.doctorName
  3833. )m2
  3834. on
  3835. m1.doctorId = m2.doctorId
  3836. AND m1.doctorName = m2.doctorName
  3837. <if test="asc != null and asc !=''">
  3838. order by
  3839. <choose>
  3840. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3841. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3842. <when test='asc=="name"'>m1.doctorName asc</when>
  3843. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3844. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3845. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3846. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3847. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3848. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3849. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3850. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3851. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3852. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3853. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3854. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3855. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3856. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3857. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3858. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3859. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3860. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3861. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3862. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3863. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3864. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3865. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3866. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3867. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3868. <otherwise>doctorName asc</otherwise>
  3869. </choose>
  3870. </if>
  3871. <if test="desc != null and desc!=''">
  3872. order by
  3873. <choose>
  3874. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3875. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3876. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3877. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3878. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3879. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3880. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3881. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3882. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3883. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3884. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3885. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3886. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3887. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3888. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3889. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3890. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3891. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3892. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3893. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3894. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3895. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3896. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3897. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3898. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3899. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3900. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3901. <otherwise>doctorName desc</otherwise>
  3902. </choose>
  3903. </if>
  3904. </select>
  3905. <!-- 病案首页合格率占比-科室 -->
  3906. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3907. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3908. SELECT
  3909. t1.doctorId,
  3910. t1.doctorName,
  3911. t2.entryNum,
  3912. t1.mrNum,
  3913. t1.totleValue,
  3914. t1.averageValue,
  3915. t1.firstLevelNum,
  3916. t1.secondLevelNum,
  3917. t1.firstLevelPercent,
  3918. t1.secondLevelPercent,
  3919. t1.firstLevelPercentStr,
  3920. t1.secondLevelPercentStr,
  3921. t3.emptyNum,
  3922. t3.errorNum,
  3923. t3.entryTotleNum,
  3924. t3.emptyPercent,
  3925. t3.errorPercent,
  3926. t3.emptyPercentStr,
  3927. t3.errorPercentStr
  3928. FROM
  3929. (
  3930. SELECT
  3931. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3932. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3933. count( * ) AS mrNum,
  3934. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3935. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3936. sum( c.`level` = '合格' ) AS firstLevelNum,
  3937. sum( c.`level` = '不合格' ) AS secondLevelNum,
  3938. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  3939. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3940. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3941. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3942. FROM
  3943. med_behospital_info a,
  3944. med_qcresult_cases c,
  3945. sys_user_dept f
  3946. WHERE
  3947. a.is_deleted = 'N'
  3948. AND c.is_deleted = 'N'
  3949. AND f.is_deleted = 'N'
  3950. AND a.hospital_id = c.hospital_id
  3951. AND a.behospital_code = c.behospital_code
  3952. AND a.beh_dept_id = f.dept_id
  3953. AND c.cases_id = 243
  3954. <if test="isPlacefile != null and isPlacefile != ''">
  3955. and a.is_placefile = #{isPlacefile}
  3956. </if>
  3957. <![CDATA[AND a.qc_type_id <>0 ]]>
  3958. <if test="hospitalId != null and hospitalId != ''">
  3959. AND a.hospital_id = #{hospitalId}
  3960. </if>
  3961. <if test="isPlacefile != null and isPlacefile == 0">
  3962. <if test="startDate != null and startDate != ''">
  3963. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3964. </if>
  3965. <if test="endDate != null and endDate != ''">
  3966. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3967. </if>
  3968. </if>
  3969. <if test="isPlacefile != null and isPlacefile == 1">
  3970. <if test="startDate != null and startDate != ''">
  3971. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3972. </if>
  3973. <if test="endDate != null and endDate != ''">
  3974. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3975. </if>
  3976. </if>
  3977. <if test="level != null and level != ''">
  3978. and c.level = #{level}
  3979. </if>
  3980. <if test="name != null and name != ''">
  3981. <if test="name == '未知'">
  3982. and (a.doctor_name is null or a.doctor_name='')
  3983. </if>
  3984. <if test="name != '未知'">
  3985. and a.doctor_name like CONCAT('%',#{name},'%')
  3986. </if>
  3987. </if>
  3988. <if test="userId!=null and userId !=''">
  3989. AND f.user_id = #{userId}
  3990. </if>
  3991. <if test="deptName!=null and deptName !=''">
  3992. AND a.beh_dept_name = #{deptName}
  3993. </if>
  3994. <if test="name != null and name != ''">
  3995. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3996. </if>
  3997. GROUP BY
  3998. a.doctor_id,
  3999. a.doctor_name
  4000. ) t1,
  4001. (
  4002. SELECT
  4003. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4004. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4005. count( * ) AS entryNum
  4006. FROM
  4007. med_behospital_info a,
  4008. med_qcresult_cases c,
  4009. med_qcresult_detail d,
  4010. qc_cases_entry e,
  4011. sys_user_dept f
  4012. WHERE
  4013. a.is_deleted = 'N'
  4014. AND c.is_deleted = 'N'
  4015. AND d.is_deleted = 'N'
  4016. AND e.is_deleted = 'N'
  4017. AND f.is_deleted = 'N'
  4018. AND a.hospital_id = c.hospital_id
  4019. AND a.hospital_id = d.hospital_id
  4020. AND a.behospital_code = c.behospital_code
  4021. AND a.behospital_code = d.behospital_code
  4022. AND a.beh_dept_id = f.dept_id
  4023. AND c.cases_id = d.cases_id
  4024. AND d.cases_id = e.cases_id
  4025. AND d.cases_entry_id = e.id
  4026. AND c.cases_id = 243
  4027. <if test="isPlacefile != null and isPlacefile != ''">
  4028. and a.is_placefile = #{isPlacefile}
  4029. </if>
  4030. <![CDATA[AND a.qc_type_id <>0 ]]>
  4031. <if test="hospitalId != null and hospitalId != ''">
  4032. AND a.hospital_id = #{hospitalId}
  4033. </if>
  4034. <if test="isPlacefile != null and isPlacefile == 0">
  4035. <if test="startDate != null and startDate != ''">
  4036. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4037. </if>
  4038. <if test="endDate != null and endDate != ''">
  4039. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4040. </if>
  4041. </if>
  4042. <if test="isPlacefile != null and isPlacefile == 1">
  4043. <if test="startDate != null and startDate != ''">
  4044. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4045. </if>
  4046. <if test="endDate != null and endDate != ''">
  4047. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4048. </if>
  4049. </if>
  4050. <if test="level != null and level != ''">
  4051. and c.level = #{level}
  4052. </if>
  4053. <if test="name != null and name != ''">
  4054. <if test="name == '未知'">
  4055. and (a.doctor_name is null or a.doctor_name='')
  4056. </if>
  4057. <if test="name != '未知'">
  4058. and a.doctor_name like CONCAT('%',#{name},'%')
  4059. </if>
  4060. </if>
  4061. <if test="userId!=null and userId !=''">
  4062. AND f.user_id = #{userId}
  4063. </if>
  4064. <if test="deptName!=null and deptName !=''">
  4065. AND a.beh_dept_name = #{deptName}
  4066. </if>
  4067. <if test="name != null and name != ''">
  4068. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4069. </if>
  4070. GROUP BY
  4071. a.doctor_id,
  4072. a.doctor_name
  4073. ) t2,(
  4074. SELECT
  4075. h1.doctorId,
  4076. h1.doctorName,
  4077. h1.emptyNum,
  4078. h1.errorNum,
  4079. h1.mrNum,
  4080. h2.entryNum,
  4081. h1.mrNum * h2.entryNum AS entryTotleNum,
  4082. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  4083. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  4084. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  4085. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  4086. FROM
  4087. (
  4088. SELECT
  4089. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  4090. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  4091. sum( d.rule_type = 1 ) AS emptyNum,
  4092. sum( d.rule_type = 2 ) AS errorNum,
  4093. count( DISTINCT a.behospital_code ) AS mrNum
  4094. FROM
  4095. med_behospital_info a,
  4096. med_qcresult_cases b,
  4097. med_qcresult_detail c,
  4098. qc_cases_entry d,
  4099. sys_user_dept e
  4100. WHERE
  4101. a.is_deleted = 'N'
  4102. AND b.is_deleted = 'N'
  4103. AND c.is_deleted = 'N'
  4104. AND d.is_deleted = 'N'
  4105. AND e.is_deleted = 'N'
  4106. AND a.hospital_id = b.hospital_id
  4107. AND a.hospital_id = c.hospital_id
  4108. AND a.hospital_id = e.hospital_id
  4109. AND a.behospital_code = b.behospital_code
  4110. AND a.behospital_code = c.behospital_code
  4111. AND b.cases_id = c.cases_id
  4112. AND c.cases_id = d.cases_id
  4113. AND c.cases_entry_id = d.id
  4114. AND a.beh_dept_id = e.dept_id
  4115. <if test="isPlacefile != null and isPlacefile != ''">
  4116. and a.is_placefile = #{isPlacefile}
  4117. </if>
  4118. AND d.cases_id = 243
  4119. <![CDATA[AND a.qc_type_id <>0 ]]>
  4120. <if test="hospitalId != null and hospitalId != ''">
  4121. AND a.hospital_id = #{hospitalId}
  4122. </if>
  4123. <if test="isPlacefile != null and isPlacefile == 0">
  4124. <if test="startDate != null and startDate != ''">
  4125. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4126. </if>
  4127. <if test="endDate != null and endDate != ''">
  4128. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4129. </if>
  4130. </if>
  4131. <if test="isPlacefile != null and isPlacefile == 1">
  4132. <if test="startDate != null and startDate != ''">
  4133. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4134. </if>
  4135. <if test="endDate != null and endDate != ''">
  4136. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4137. </if>
  4138. </if>
  4139. <if test="level != null and level != ''">
  4140. and b.level = #{level}
  4141. </if>
  4142. <if test="name != null and name != ''">
  4143. <if test="name == '未知'">
  4144. and (a.doctor_name is null or a.doctor_name='')
  4145. </if>
  4146. <if test="name != '未知'">
  4147. and a.doctor_name like CONCAT('%',#{name},'%')
  4148. </if>
  4149. </if>
  4150. <if test="userId!=null and userId !=''">
  4151. AND e.user_id = #{userId}
  4152. </if>
  4153. <if test="deptName!=null and deptName !=''">
  4154. AND a.beh_dept_name = #{deptName}
  4155. </if>
  4156. <if test="name != null and name != ''">
  4157. AND a.doctor_name like CONCAT('%', #{name}, '%')
  4158. </if>
  4159. GROUP BY
  4160. a.doctor_id,
  4161. a.doctor_name
  4162. ) h1,(
  4163. SELECT
  4164. count(*) AS entryNum
  4165. FROM
  4166. qc_cases_entry
  4167. WHERE
  4168. is_deleted = 'N'
  4169. AND cases_id = 243
  4170. ) h2
  4171. ) t3
  4172. WHERE
  4173. t1.doctorId = t2.doctorId
  4174. AND t1.doctorId = t3.doctorId
  4175. AND t1.doctorName = t2.doctorName
  4176. AND t1.doctorName = t3.doctorName
  4177. <if test="asc != null and asc !=''">
  4178. order by
  4179. <choose>
  4180. <when test='asc=="doctorId"'>doctorId asc</when>
  4181. <when test='asc=="doctorName"'>doctorName asc</when>
  4182. <when test='asc=="entryNum"'>entryNum asc</when>
  4183. <when test='asc=="mrNum"'>mrNum asc</when>
  4184. <when test='asc=="totleValue"'>totleValue asc</when>
  4185. <when test='asc=="averageValue"'>averageValue asc</when>
  4186. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4187. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4188. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4189. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4190. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4191. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4192. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4193. <when test='asc=="errorNum"'>errorNum asc</when>
  4194. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4195. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4196. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4197. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4198. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4199. <otherwise>doctorName asc</otherwise>
  4200. </choose>
  4201. </if>
  4202. <if test="desc != null and desc!=''">
  4203. order by
  4204. <choose>
  4205. <when test='desc=="doctorId"'>doctorId desc</when>
  4206. <when test='desc=="doctorName"'>doctorName desc</when>
  4207. <when test='desc=="entryNum"'>entryNum desc</when>
  4208. <when test='desc=="mrNum"'>mrNum desc</when>
  4209. <when test='desc=="totleValue"'>totleValue desc</when>
  4210. <when test='desc=="averageValue"'>averageValue desc</when>
  4211. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4212. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4213. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4214. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4215. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4216. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4217. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4218. <when test='desc=="errorNum"'>errorNum desc</when>
  4219. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4220. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4221. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4222. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4223. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4224. <otherwise>doctorName desc</otherwise>
  4225. </choose>
  4226. </if>
  4227. </select>
  4228. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4229. <result column="behDeptName" property="behDeptName"/>
  4230. <result column="wardName" property="wardName"/>
  4231. <result column="medoup_name" property="medoupName"/>
  4232. <result column="medoupName" property="medoupName"/>
  4233. <result column="doctorName" property="doctorName"/>
  4234. <result column="avgScore" property="avgScore"/>
  4235. <collection property="excelBehospitalDTOS"
  4236. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  4237. <result column="patName" property="patName"/>
  4238. <result column="behospitalCode" property="behospitalCode"/>
  4239. <result column="fileCode" property="fileCode"/>
  4240. <result column="behospitalDate" property="behospitalDate"/>
  4241. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4242. <result column="score" property="score"/>
  4243. <result column="scoreBn" property="scoreBn"/>
  4244. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4245. <result column="caseName" property="caseName"/>
  4246. <collection property="exportExcelMsgDTOS"
  4247. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4248. <result column="msg" property="msg"/>
  4249. </collection>
  4250. </collection>
  4251. </collection>
  4252. </resultMap>
  4253. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  4254. <result column="behDeptName" property="behDeptName"/>
  4255. <result column="avgScore" property="avgScore"/>
  4256. <collection property="excelBehospitalDTOS"
  4257. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  4258. <result column="doctorName" property="doctorName"/>
  4259. <result column="patName" property="patName"/>
  4260. <result column="behospitalCode" property="behospitalCode"/>
  4261. <result column="fileCode" property="fileCode"/>
  4262. <result column="behospitalDate" property="behospitalDate"/>
  4263. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4264. <result column="score" property="score"/>
  4265. <result column="scoreBn" property="scoreBn"/>
  4266. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4267. <result column="caseName" property="caseName"/>
  4268. <collection property="exportExcelMsgDTOS"
  4269. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4270. <result column="msg" property="msg"/>
  4271. </collection>
  4272. </collection>
  4273. </collection>
  4274. </resultMap>
  4275. <select id="exportExcel" resultMap="ExportExcelMap">
  4276. SELECT DISTINCT
  4277. t1.beh_dept_name AS behDeptName,
  4278. t1.beh_doctor_name AS doctorName,
  4279. t1.`name` AS patName,
  4280. t1.behospital_code AS behospitalCode,
  4281. t1.behospital_date AS behospitalDate,
  4282. t1.leave_hospital_date AS leaveHospitalDate,
  4283. t2.score_res AS score,
  4284. "1" AS avgScore,
  4285. t4.`name` AS caseName,
  4286. t3.msg AS msg
  4287. FROM
  4288. med_behospital_info t1,
  4289. med_qcresult_info t2,
  4290. med_qcresult_detail t3,
  4291. qc_cases t4
  4292. WHERE
  4293. t1.is_deleted = 'N'
  4294. AND t2.is_deleted = 'N'
  4295. AND t3.is_deleted = 'N'
  4296. AND t4.is_deleted = 'N'
  4297. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4298. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4299. AND t1.hospital_id = t2.hospital_id
  4300. AND t1.behospital_code = t2.behospital_code
  4301. AND t1.hospital_id = t3.hospital_id
  4302. AND t1.behospital_code = t3.behospital_code
  4303. AND t3.cases_id = t4.id
  4304. ORDER BY
  4305. t1.beh_dept_id ASC,
  4306. t1.leave_hospital_date DESC,
  4307. t1.behospital_code ASC,
  4308. t4.`name` ASC
  4309. </select>
  4310. <!-- 质控评分导出到excel-->
  4311. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4312. SELECT * FROM (
  4313. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4314. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4315. g.check_type AS ch_type,
  4316. h.check_type AS mr_type,
  4317. g.check_name AS ch_name,
  4318. h.check_name AS mr_name,
  4319. g.check_time AS ch_time,
  4320. h.check_time AS mr_time
  4321. FROM (
  4322. SELECT
  4323. t1.behDeptId,
  4324. t1.behDeptName,
  4325. t1.doctorName,
  4326. t1.patName,
  4327. t1.fileCode,
  4328. t1.behospitalCode,
  4329. t1.hospitalId,
  4330. t1.behospitalDate,
  4331. t1.leaveHospitalDate,
  4332. t1.score,
  4333. <if test="radioCheck !=null and radioCheck == 1">
  4334. t1.msg,
  4335. t1.caseName,
  4336. </if>
  4337. t1.scoreBn,
  4338. t2.avgScore
  4339. FROM
  4340. (
  4341. SELECT
  4342. a.doctor_name AS doctorName,
  4343. a.`name` AS patName,
  4344. a.`file_code` AS fileCode,
  4345. a.behospital_code AS behospitalCode,
  4346. a.behospital_date AS behospitalDate,
  4347. a.leave_hospital_date AS leaveHospitalDate,
  4348. b.score_res AS score,
  4349. e.score_res as scoreBn,
  4350. <if test="radioCheck !=null and radioCheck == 1">
  4351. c.msg AS msg,
  4352. d.NAME AS caseName,
  4353. </if>
  4354. a.beh_dept_id AS behDeptId,
  4355. a.beh_dept_name AS behDeptName,
  4356. a.hospital_id AS hospitalId
  4357. FROM
  4358. med_behospital_info a
  4359. RIGHT JOIN
  4360. med_qcresult_info b
  4361. ON a.hospital_id = b.hospital_id
  4362. AND a.is_deleted = 'N'
  4363. AND b.is_deleted = 'N'
  4364. AND a.behospital_code = b.behospital_code
  4365. <if test="radioCheck !=null and radioCheck == 1">
  4366. LEFT JOIN
  4367. med_qcresult_detail c
  4368. ON c.is_deleted = 'N'
  4369. AND b.behospital_code = c.behospital_code
  4370. AND b.hospital_id = c.hospital_id
  4371. LEFT JOIN
  4372. qc_cases d
  4373. on d.is_deleted = 'N'
  4374. AND c.cases_id = d.id
  4375. </if>
  4376. LEFT JOIN med_qcresult_cases e
  4377. on b.behospital_code = e.behospital_code
  4378. and b.hospital_id = e.hospital_id
  4379. AND e.is_deleted = 'N'
  4380. and e.cases_id = 243
  4381. WHERE
  4382. 1=1
  4383. <if test="isPlacefile != null and isPlacefile != ''">
  4384. and a.is_placefile = #{isPlacefile}
  4385. </if>
  4386. <![CDATA[AND a.qc_type_id <>0 ]]>
  4387. <if test="hospitalId != null and hospitalId != ''">
  4388. AND a.hospital_id = #{hospitalId}
  4389. </if>
  4390. <if test="diagnose != null and diagnose != ''">
  4391. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4392. </if>
  4393. <if test="behosDateStart != null">
  4394. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4395. </if>
  4396. <if test="behosDateEnd != null">
  4397. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4398. </if>
  4399. <if test="leaveHosDateStart != null ">
  4400. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4401. </if>
  4402. <if test="leaveHosDateEnd != null ">
  4403. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4404. </if>
  4405. <if test="behospitalCode != null and behospitalCode != ''">
  4406. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4407. </if>
  4408. <if test="level != null and level != ''">
  4409. AND b.level = #{level}
  4410. </if>
  4411. <if test="doctorName != null and doctorName != ''">
  4412. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4413. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4414. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4415. </if>
  4416. <if test="doctorCode != null and doctorCode != ''">
  4417. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4418. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4419. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4420. </if>
  4421. <if test="deptName != null and deptName != ''">
  4422. and a.beh_dept_name = #{deptName}
  4423. </if>
  4424. <if test="name != null and name != ''">
  4425. AND a.name like CONCAT('%',#{name},'%')
  4426. </if>
  4427. ) t1,
  4428. (
  4429. SELECT
  4430. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4431. a.beh_dept_id AS behDeptId,
  4432. a.beh_dept_name AS behDeptName
  4433. FROM
  4434. med_behospital_info a,
  4435. med_qcresult_info b
  4436. WHERE
  4437. a.is_deleted = 'N'
  4438. AND b.is_deleted = 'N'
  4439. AND a.hospital_id = b.hospital_id
  4440. AND a.behospital_code = b.behospital_code
  4441. <if test="isPlacefile != null and isPlacefile != ''">
  4442. and a.is_placefile = #{isPlacefile}
  4443. </if>
  4444. <![CDATA[AND a.qc_type_id <>0 ]]>
  4445. <if test="hospitalId != null and hospitalId != ''">
  4446. AND a.hospital_id = #{hospitalId}
  4447. </if>
  4448. <if test="diagnose != null and diagnose != ''">
  4449. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4450. </if>
  4451. <if test="behosDateStart != null">
  4452. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4453. </if>
  4454. <if test="behosDateEnd != null">
  4455. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4456. </if>
  4457. <if test="leaveHosDateStart != null ">
  4458. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4459. </if>
  4460. <if test="leaveHosDateEnd != null ">
  4461. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4462. </if>
  4463. <if test="behospitalCode != null and behospitalCode != ''">
  4464. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4465. </if>
  4466. <if test="level != null and level != ''">
  4467. AND b.level = #{level}
  4468. </if>
  4469. <if test="doctorName != null and doctorName != ''">
  4470. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4471. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4472. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4473. </if>
  4474. <if test="doctorCode != null and doctorCode != ''">
  4475. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4476. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4477. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4478. </if>
  4479. <if test="deptName != null and deptName != ''">
  4480. and a.beh_dept_name = #{deptName}
  4481. </if>
  4482. <if test="name != null and name != ''">
  4483. AND a.name like CONCAT('%',#{name},'%')
  4484. </if>
  4485. GROUP BY
  4486. a.beh_dept_id,
  4487. a.beh_dept_name
  4488. ) t2
  4489. WHERE
  4490. t1.behDeptId = t2.behDeptId
  4491. AND t1.behDeptName = t2.behDeptName
  4492. ORDER BY
  4493. t1.behDeptName,
  4494. t1.doctorName,
  4495. t1.patName,
  4496. <if test="radioCheck !=null and radioCheck == 1">
  4497. t1.caseName,
  4498. </if>
  4499. t1.behospitalCode
  4500. )tp
  4501. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  4502. ON tp.behospitalCode = g.behospital_code
  4503. AND tp.hospitalId = g.hospital_id
  4504. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4505. ON tp.behospitalCode = h.behospital_code
  4506. AND tp.hospitalId = h.hospital_id
  4507. ) tu
  4508. WHERE tu.behospitalCode IS NOT NULL
  4509. <if test="checkStatus != null ">
  4510. and tu.check_status = #{checkStatus}
  4511. </if>
  4512. <if test="mrStatus != null ">
  4513. AND tu.mr_status = #{mrStatus}
  4514. </if>
  4515. <if test="chName != null and chName !=''">
  4516. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4517. </if>
  4518. <if test="mrName != null and mrName !=''">
  4519. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4520. </if>
  4521. <if test="chTimeStart != null">
  4522. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4523. </if>
  4524. <if test="chTimeEnd != null">
  4525. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4526. </if>
  4527. <if test="mrTimeStart != null">
  4528. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4529. </if>
  4530. <if test="mrTimeEnd != null">
  4531. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4532. </if>
  4533. </select>
  4534. <!-- 科室质控评分导出到excel-->
  4535. <select id="exportQcresultByDept" resultMap="ExportExcelMapByDept" parameterType="com.diagbot.vo.ExportQcresultVO">
  4536. SELECT * FROM (
  4537. SELECT tp.*,t3.name as medoup_name,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4538. g.check_type AS ch_type,
  4539. g.check_name AS ch_name,
  4540. g.check_time AS ch_time
  4541. FROM (
  4542. SELECT
  4543. t1.behDeptId,
  4544. t1.behDeptName,
  4545. t1.doctorName,
  4546. t1.doctor_id as doctorId,
  4547. t1.patName,
  4548. t1.wardName,
  4549. t1.behospitalCode,
  4550. t1.fileCode,
  4551. t1.hospitalId,
  4552. t1.behospitalDate,
  4553. t1.leaveHospitalDate,
  4554. t1.score,
  4555. t2.avgScore,
  4556. <if test="radioCheck !=null and radioCheck == 1">
  4557. c.msg AS msg,
  4558. t1.caseName,
  4559. </if>
  4560. e.score_res as scoreBn
  4561. FROM
  4562. (
  4563. SELECT
  4564. a.doctor_name AS doctorName,
  4565. a.doctor_id,
  4566. a.`name` AS patName,
  4567. a.ward_name as wardName,
  4568. a.file_code as fileCode,
  4569. a.behospital_code AS behospitalCode,
  4570. a.hospital_id AS hospital_id,
  4571. d.id,
  4572. a.behospital_date AS behospitalDate,
  4573. a.leave_hospital_date AS leaveHospitalDate,
  4574. b.score_res AS score,
  4575. <if test="radioCheck !=null and radioCheck == 1">
  4576. d.NAME AS caseName,
  4577. </if>
  4578. a.beh_dept_id AS behDeptId,
  4579. a.beh_dept_name AS behDeptName,
  4580. a.hospital_id AS hospitalId
  4581. FROM
  4582. med_behospital_info a,
  4583. med_qcresult_info b,
  4584. qc_cases d,
  4585. sys_user_dept e
  4586. WHERE
  4587. a.is_deleted = 'N'
  4588. AND b.is_deleted = 'N'
  4589. AND d.is_deleted = 'N'
  4590. AND e.is_deleted = 'N'
  4591. AND a.hospital_id = b.hospital_id
  4592. AND a.hospital_id = e.hospital_id
  4593. AND a.behospital_code = b.behospital_code
  4594. AND a.beh_dept_id = e.dept_id
  4595. <if test="diagnose != null and diagnose != ''">
  4596. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4597. </if>
  4598. <if test="isPlacefile != null and isPlacefile != ''">
  4599. and a.is_placefile = #{isPlacefile}
  4600. </if>
  4601. <if test="wardName != null and wardName != ''">
  4602. AND a.ward_name = #{wardName}
  4603. </if>
  4604. <![CDATA[AND a.qc_type_id <>0 ]]>
  4605. <if test="hospitalId != null and hospitalId != ''">
  4606. AND a.hospital_id = #{hospitalId}
  4607. </if>
  4608. <if test="userId != null ">
  4609. AND e.user_id = #{userId}
  4610. </if>
  4611. <if test="behosDateStart != null">
  4612. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4613. </if>
  4614. <if test="behosDateEnd != null">
  4615. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4616. </if>
  4617. <if test="leaveHosDateStart != null ">
  4618. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4619. </if>
  4620. <if test="leaveHosDateEnd != null ">
  4621. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4622. </if>
  4623. <if test="behospitalCode != null and behospitalCode != ''">
  4624. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4625. </if>
  4626. <if test="level != null and level != ''">
  4627. AND b.level = #{level}
  4628. </if>
  4629. <if test="doctorName != null and doctorName != ''">
  4630. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4631. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4632. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4633. </if>
  4634. <if test="doctorCode != null and doctorCode != ''">
  4635. AND a.doctor_id = #{doctorCode}
  4636. </if>
  4637. <if test="deptName != null and deptName != ''">
  4638. and a.beh_dept_name = #{deptName}
  4639. </if>
  4640. <if test="deptId != null and deptId != ''">
  4641. and a.beh_dept_id = #{deptId}
  4642. </if>
  4643. <if test="name != null and name != ''">
  4644. AND a.name like CONCAT('%',#{name},'%')
  4645. </if>
  4646. ) t1
  4647. LEFT JOIN med_qcresult_cases e
  4648. on t1.behospitalCode = e.behospital_code
  4649. and t1.hospital_id = e.hospital_id
  4650. AND e.is_deleted = 'N'
  4651. and e.cases_id = 243
  4652. LEFT JOIN med_qcresult_detail c
  4653. on t1.behospitalCode = c.behospital_code
  4654. and t1.hospital_id = c.hospital_id
  4655. AND c.cases_id = t1.id
  4656. AND c.is_deleted = 'N',
  4657. (
  4658. SELECT
  4659. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4660. a.beh_dept_id AS behDeptId,
  4661. a.beh_dept_name AS behDeptName,
  4662. a.doctor_id AS doctorId,
  4663. a.doctor_name AS doctorName
  4664. FROM
  4665. med_behospital_info a,
  4666. med_qcresult_info b,
  4667. sys_user_dept c
  4668. WHERE
  4669. a.is_deleted = 'N'
  4670. AND b.is_deleted = 'N'
  4671. AND c.is_deleted = 'N'
  4672. AND a.hospital_id = b.hospital_id
  4673. AND a.hospital_id = c.hospital_id
  4674. AND a.behospital_code = b.behospital_code
  4675. AND a.beh_dept_id = c.dept_id
  4676. <if test="diagnose != null and diagnose != ''">
  4677. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4678. </if>
  4679. <if test="wardName != null and wardName != ''">
  4680. AND a.ward_name = #{wardName}
  4681. </if>
  4682. <if test="isPlacefile != null and isPlacefile != ''">
  4683. and a.is_placefile = #{isPlacefile}
  4684. </if>
  4685. <![CDATA[AND a.qc_type_id <>0 ]]>
  4686. <if test="hospitalId != null and hospitalId != ''">
  4687. AND a.hospital_id = #{hospitalId}
  4688. </if>
  4689. <if test="userId != null ">
  4690. AND c.user_id = #{userId}
  4691. </if>
  4692. <if test="behosDateStart != null">
  4693. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4694. </if>
  4695. <if test="behosDateEnd != null">
  4696. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4697. </if>
  4698. <if test="leaveHosDateStart != null ">
  4699. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4700. </if>
  4701. <if test="leaveHosDateEnd != null ">
  4702. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4703. </if>
  4704. <if test="behospitalCode != null and behospitalCode != ''">
  4705. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4706. </if>
  4707. <if test="level != null and level != ''">
  4708. AND b.level = #{level}
  4709. </if>
  4710. <if test="doctorName != null and doctorName != ''">
  4711. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4712. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4713. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4714. </if>
  4715. <if test="doctorCode != null and doctorCode != ''">
  4716. and a.doctor_id = #{doctorCode}
  4717. </if>
  4718. <if test="deptName != null and deptName != ''">
  4719. and a.beh_dept_name = #{deptName}
  4720. </if>
  4721. <if test="deptId != null and deptId != ''">
  4722. and a.beh_dept_id = #{deptId}
  4723. </if>
  4724. <if test="name != null and name != ''">
  4725. AND a.name like CONCAT('%',#{name},'%')
  4726. </if>
  4727. GROUP BY
  4728. a.beh_dept_id,
  4729. a.beh_dept_name,
  4730. a.doctor_id,
  4731. a.doctor_name
  4732. ) t2
  4733. WHERE
  4734. t1.behDeptId = t2.behDeptId
  4735. AND t1.behDeptName = t2.behDeptName
  4736. AND t1.doctor_id = t2.doctorId
  4737. AND t1.doctorName = t2.doctorName
  4738. ORDER BY
  4739. t1.behDeptName,
  4740. t1.doctorName,
  4741. t1.patName,
  4742. <if test="radioCheck !=null and radioCheck == 1">
  4743. t1.caseName,
  4744. </if>
  4745. t1.behospitalCode
  4746. )tp
  4747. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  4748. ON tp.behospitalCode = g.behospital_code
  4749. AND tp.hospitalId = g.hospital_id
  4750. LEFT JOIN bas_doctor_info t2 ON tp.doctorId = t2.doctor_id
  4751. AND tp.hospitalId = t2.hospital_id
  4752. AND t2.is_deleted = 'N'
  4753. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  4754. AND t3.is_deleted = 'N'
  4755. where 1=1
  4756. <if test="medoupName != null and medoupName != ''">
  4757. AND t3.name = #{medoupName}
  4758. </if>
  4759. ) tu
  4760. WHERE tu.behospitalCode IS NOT NULL
  4761. <if test="checkStatus != null ">
  4762. and tu.check_status = #{checkStatus}
  4763. </if>
  4764. <if test="mrStatus != null ">
  4765. AND tu.mr_status = #{mrStatus}
  4766. </if>
  4767. <if test="chName != null and chName !=''">
  4768. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4769. </if>
  4770. <if test="mrName != null and mrName !=''">
  4771. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4772. </if>
  4773. <if test="chTimeStart != null">
  4774. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4775. </if>
  4776. <if test="chTimeEnd != null">
  4777. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4778. </if>
  4779. <if test="mrTimeStart != null">
  4780. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4781. </if>
  4782. <if test="mrTimeEnd != null">
  4783. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4784. </if>
  4785. </select>
  4786. <!-- 各科室缺陷占比科室导出-->
  4787. <select id="levelStatisticsExportByDept" resultMap="ExportExcelMapByDept" parameterType="com.diagbot.vo.ExportQcresultVO">
  4788. SELECT * FROM (
  4789. SELECT tp.*,t3.name as medoup_name,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4790. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4791. g.check_type AS ch_type,
  4792. h.check_type AS mr_type,
  4793. g.check_name AS ch_name,
  4794. h.check_name AS mr_name,
  4795. g.check_time AS ch_time,
  4796. h.check_time AS mr_time
  4797. FROM (
  4798. SELECT
  4799. t1.behDeptId,
  4800. t1.behDeptName,
  4801. t1.doctorName,
  4802. t1.doctor_id as doctorId,
  4803. t1.patName,
  4804. t1.wardName,
  4805. t1.behospitalCode,
  4806. t1.fileCode,
  4807. t1.hospitalId,
  4808. t1.behospitalDate,
  4809. t1.leaveHospitalDate,
  4810. t1.score,
  4811. t2.avgScore,
  4812. <if test="radioCheck !=null and radioCheck == 1">
  4813. c.msg AS msg,
  4814. t1.caseName,
  4815. </if>
  4816. e.score_res as scoreBn
  4817. FROM
  4818. (
  4819. SELECT
  4820. a.doctor_name AS doctorName,
  4821. a.doctor_id,
  4822. a.`name` AS patName,
  4823. a.ward_name as wardName,
  4824. a.file_code as fileCode,
  4825. a.behospital_code AS behospitalCode,
  4826. a.hospital_id AS hospital_id,
  4827. d.id,
  4828. a.behospital_date AS behospitalDate,
  4829. a.leave_hospital_date AS leaveHospitalDate,
  4830. b.score_res AS score,
  4831. <if test="radioCheck !=null and radioCheck == 1">
  4832. d.NAME AS caseName,
  4833. </if>
  4834. a.beh_dept_id AS behDeptId,
  4835. a.beh_dept_name AS behDeptName,
  4836. a.hospital_id AS hospitalId
  4837. FROM
  4838. med_behospital_info a,
  4839. med_qcresult_info b,
  4840. qc_cases d,
  4841. sys_user_dept e
  4842. WHERE
  4843. a.is_deleted = 'N'
  4844. AND b.is_deleted = 'N'
  4845. AND d.is_deleted = 'N'
  4846. AND e.is_deleted = 'N'
  4847. AND a.hospital_id = b.hospital_id
  4848. AND a.hospital_id = e.hospital_id
  4849. AND a.behospital_code = b.behospital_code
  4850. AND a.beh_dept_id = e.dept_id
  4851. <if test="diagnose != null and diagnose != ''">
  4852. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4853. </if>
  4854. <if test="isPlacefile != null and isPlacefile != ''">
  4855. and a.is_placefile = #{isPlacefile}
  4856. </if>
  4857. <if test="wardName != null and wardName != ''">
  4858. AND a.ward_name = #{wardName}
  4859. </if>
  4860. <![CDATA[AND a.qc_type_id <>0 ]]>
  4861. <if test="hospitalId != null and hospitalId != ''">
  4862. AND a.hospital_id = #{hospitalId}
  4863. </if>
  4864. <if test="userId != null ">
  4865. AND e.user_id = #{userId}
  4866. </if>
  4867. <if test="behosDateStart != null">
  4868. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4869. </if>
  4870. <if test="behosDateEnd != null">
  4871. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4872. </if>
  4873. <if test="leaveHosDateStart != null ">
  4874. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4875. </if>
  4876. <if test="leaveHosDateEnd != null ">
  4877. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4878. </if>
  4879. <if test="behospitalCode != null and behospitalCode != ''">
  4880. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4881. </if>
  4882. <if test="level != null and level != ''">
  4883. AND b.level = #{level}
  4884. </if>
  4885. <if test="doctorName != null and doctorName != ''">
  4886. AND a.doctor_name = #{doctorName}
  4887. </if>
  4888. <if test="doctorCode != null and doctorCode != ''">
  4889. AND a.doctor_id = #{doctorCode}
  4890. </if>
  4891. <if test="deptName != null and deptName != ''">
  4892. and a.beh_dept_name = #{deptName}
  4893. </if>
  4894. <if test="deptId != null and deptId != ''">
  4895. and a.beh_dept_id = #{deptId}
  4896. </if>
  4897. <if test="name != null and name != ''">
  4898. AND a.name like CONCAT('%',#{name},'%')
  4899. </if>
  4900. ) t1
  4901. LEFT JOIN med_qcresult_cases e
  4902. on t1.behospitalCode = e.behospital_code
  4903. and t1.hospital_id = e.hospital_id
  4904. AND e.is_deleted = 'N'
  4905. and e.cases_id = 243
  4906. LEFT JOIN med_qcresult_detail c
  4907. on t1.behospitalCode = c.behospital_code
  4908. and t1.hospital_id = c.hospital_id
  4909. AND c.cases_id = t1.id
  4910. AND c.is_deleted = 'N',
  4911. (
  4912. SELECT
  4913. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4914. a.beh_dept_id AS behDeptId,
  4915. a.beh_dept_name AS behDeptName,
  4916. a.doctor_id AS doctorId,
  4917. a.doctor_name AS doctorName
  4918. FROM
  4919. med_behospital_info a,
  4920. med_qcresult_info b,
  4921. sys_user_dept c
  4922. WHERE
  4923. a.is_deleted = 'N'
  4924. AND b.is_deleted = 'N'
  4925. AND c.is_deleted = 'N'
  4926. AND a.hospital_id = b.hospital_id
  4927. AND a.hospital_id = c.hospital_id
  4928. AND a.behospital_code = b.behospital_code
  4929. AND a.beh_dept_id = c.dept_id
  4930. <if test="diagnose != null and diagnose != ''">
  4931. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4932. </if>
  4933. <if test="wardName != null and wardName != ''">
  4934. AND a.ward_name = #{wardName}
  4935. </if>
  4936. <if test="isPlacefile != null and isPlacefile != ''">
  4937. and a.is_placefile = #{isPlacefile}
  4938. </if>
  4939. <![CDATA[AND a.qc_type_id <>0 ]]>
  4940. <if test="hospitalId != null and hospitalId != ''">
  4941. AND a.hospital_id = #{hospitalId}
  4942. </if>
  4943. <if test="userId != null ">
  4944. AND c.user_id = #{userId}
  4945. </if>
  4946. <if test="behosDateStart != null">
  4947. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4948. </if>
  4949. <if test="behosDateEnd != null">
  4950. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4951. </if>
  4952. <if test="leaveHosDateStart != null ">
  4953. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4954. </if>
  4955. <if test="leaveHosDateEnd != null ">
  4956. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4957. </if>
  4958. <if test="behospitalCode != null and behospitalCode != ''">
  4959. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4960. </if>
  4961. <if test="level != null and level != ''">
  4962. AND b.level = #{level}
  4963. </if>
  4964. <if test="doctorName != null and doctorName != ''">
  4965. AND a.doctor_name = #{doctorName}
  4966. </if>
  4967. <if test="doctorCode != null and doctorCode != ''">
  4968. and a.doctor_id = #{doctorCode}
  4969. </if>
  4970. <if test="deptName != null and deptName != ''">
  4971. and a.beh_dept_name = #{deptName}
  4972. </if>
  4973. <if test="deptId != null and deptId != ''">
  4974. and a.beh_dept_id = #{deptId}
  4975. </if>
  4976. <if test="name != null and name != ''">
  4977. AND a.name like CONCAT('%',#{name},'%')
  4978. </if>
  4979. GROUP BY
  4980. a.beh_dept_id,
  4981. a.beh_dept_name,
  4982. a.doctor_id,
  4983. a.doctor_name
  4984. ) t2
  4985. WHERE
  4986. t1.behDeptId = t2.behDeptId
  4987. AND t1.behDeptName = t2.behDeptName
  4988. AND t1.doctor_id = t2.doctorId
  4989. AND t1.doctorName = t2.doctorName
  4990. ORDER BY
  4991. t1.behDeptName,
  4992. t1.doctorName,
  4993. t1.patName,
  4994. <if test="radioCheck !=null and radioCheck == 1">
  4995. t1.caseName,
  4996. </if>
  4997. t1.behospitalCode
  4998. )tp
  4999. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5000. ON tp.behospitalCode = g.behospital_code
  5001. AND tp.hospitalId = g.hospital_id
  5002. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5003. ON tp.behospitalCode = h.behospital_code
  5004. AND tp.hospitalId = h.hospital_id
  5005. LEFT JOIN bas_doctor_info t2 ON tp.doctorId = t2.doctor_id
  5006. AND tp.hospitalId = t2.hospital_id
  5007. AND t2.is_deleted = 'N'
  5008. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  5009. AND t3.is_deleted = 'N'
  5010. where 1=1
  5011. <if test="medoupName != null and medoupName != ''">
  5012. AND t3.name = #{medoupName}
  5013. </if>
  5014. ) tu
  5015. WHERE tu.behospitalCode IS NOT NULL
  5016. <if test="checkStatus != null ">
  5017. and tu.check_status = #{checkStatus}
  5018. </if>
  5019. <if test="mrStatus != null ">
  5020. AND tu.mr_status = #{mrStatus}
  5021. </if>
  5022. <if test="chName != null and chName !=''">
  5023. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5024. </if>
  5025. <if test="mrName != null and mrName !=''">
  5026. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5027. </if>
  5028. <if test="chTimeStart != null">
  5029. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5030. </if>
  5031. <if test="chTimeEnd != null">
  5032. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5033. </if>
  5034. <if test="mrTimeStart != null">
  5035. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5036. </if>
  5037. <if test="mrTimeEnd != null">
  5038. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5039. </if>
  5040. </select>
  5041. <!-- 个人质控评分导出到excel-->
  5042. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  5043. SELECT * FROM (
  5044. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  5045. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  5046. g.check_type AS ch_type,
  5047. h.check_type AS mr_type,
  5048. g.check_name AS ch_name,
  5049. h.check_name AS mr_name,
  5050. g.check_time AS ch_time,
  5051. h.check_time AS mr_time
  5052. FROM (
  5053. SELECT
  5054. t1.behDeptId,
  5055. t1.behDeptName,
  5056. t1.doctorName,
  5057. t1.fileCode,
  5058. t1.patName,
  5059. t1.behospitalCode,
  5060. t1.hospitalId,
  5061. t1.behospitalDate,
  5062. t1.leaveHospitalDate,
  5063. t1.score,
  5064. t2.avgScore,
  5065. <if test="radioCheck !=null and radioCheck == 1">
  5066. t1.msg,
  5067. t1.caseName,
  5068. </if>
  5069. e.score_res as scoreBn
  5070. FROM
  5071. (
  5072. SELECT
  5073. a.doctor_name AS doctorName,
  5074. a.beh_doctor_name,
  5075. a.file_code as fileCode,
  5076. a.director_doctor_name,
  5077. a.`name` AS patName,
  5078. a.behospital_code AS behospitalCode,
  5079. a.behospital_date AS behospitalDate,
  5080. a.leave_hospital_date AS leaveHospitalDate,
  5081. b.score_res AS score,
  5082. <if test="radioCheck !=null and radioCheck == 1">
  5083. c.msg AS msg,
  5084. d.NAME AS caseName,
  5085. </if>
  5086. a.beh_dept_id AS behDeptId,
  5087. a.beh_dept_name AS behDeptName,
  5088. a.hospital_id AS hospitalId
  5089. FROM
  5090. med_behospital_info a,
  5091. med_qcresult_info b,
  5092. med_qcresult_detail c,
  5093. qc_cases d,
  5094. sys_user u,
  5095. sys_user_hospital uh
  5096. WHERE
  5097. a.is_deleted = 'N'
  5098. AND b.is_deleted = 'N'
  5099. AND c.is_deleted = 'N'
  5100. AND d.is_deleted = 'N'
  5101. AND u.is_deleted = 'N'
  5102. AND uh.is_deleted = 'N'
  5103. AND a.hospital_id = b.hospital_id
  5104. AND a.hospital_id = c.hospital_id
  5105. AND a.behospital_code = b.behospital_code
  5106. AND a.behospital_code = c.behospital_code
  5107. AND u.id = uh.user_id
  5108. AND a.hospital_id = uh.hospital_id
  5109. <if test="userId != null and userId != ''">
  5110. AND u.id = #{userId}
  5111. </if>
  5112. <if test="isPlacefile != null and isPlacefile != ''">
  5113. and a.is_placefile = #{isPlacefile}
  5114. </if>
  5115. <![CDATA[AND a.qc_type_id <>0 ]]>
  5116. <if test="hospitalId != null and hospitalId != ''">
  5117. AND a.hospital_id = #{hospitalId}
  5118. </if>
  5119. <if test="diagnose != null and diagnose != ''">
  5120. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5121. </if>
  5122. <if test="behosDateStart != null">
  5123. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5124. </if>
  5125. <if test="behosDateEnd != null">
  5126. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5127. </if>
  5128. <if test="leaveHosDateStart != null ">
  5129. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  5130. </if>
  5131. <if test="leaveHosDateEnd != null ">
  5132. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  5133. </if>
  5134. <if test="behospitalCode != null and behospitalCode != ''">
  5135. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5136. </if>
  5137. <if test="level != null and level != ''">
  5138. AND b.level = #{level}
  5139. </if>
  5140. <if test="doctorName != null and doctorName != ''">
  5141. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5142. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5143. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5144. </if>
  5145. <if test="doctorCode != null and doctorCode != ''">
  5146. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5147. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5148. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5149. </if>
  5150. <if test="deptId != null and deptId != ''">
  5151. AND a.beh_dept_id = #{deptId}
  5152. </if>
  5153. <if test="deptName != null and deptName != ''">
  5154. and a.beh_dept_name = #{deptName}
  5155. </if>
  5156. <if test="name != null and name != ''">
  5157. AND a.name like CONCAT('%',#{name},'%')
  5158. </if>
  5159. ) t1 LEFT JOIN med_qcresult_cases e
  5160. on t1.behospitalCode = e.behospital_code
  5161. and t1.hospitalId = e.hospital_id
  5162. AND e.is_deleted = 'N'
  5163. and e.cases_id = 243,
  5164. (
  5165. SELECT
  5166. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5167. a.beh_dept_id AS behDeptId,
  5168. a.beh_dept_name AS behDeptName
  5169. FROM
  5170. med_behospital_info a,
  5171. med_qcresult_info b,
  5172. sys_user u,
  5173. sys_user_hospital uh
  5174. WHERE
  5175. a.is_deleted = 'N'
  5176. AND b.is_deleted = 'N'
  5177. AND u.is_deleted = 'N'
  5178. AND uh.is_deleted = 'N'
  5179. AND a.hospital_id = b.hospital_id
  5180. AND a.behospital_code = b.behospital_code
  5181. AND u.id = uh.user_id
  5182. AND a.hospital_id = uh.hospital_id
  5183. and (a.doctor_name = u.linkman
  5184. or a.beh_doctor_name = u.linkman
  5185. or a.director_doctor_name = u.linkman)
  5186. <if test="userId != null and userId != ''">
  5187. AND u.id = #{userId}
  5188. </if>
  5189. <if test="diagnose != null and diagnose != ''">
  5190. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5191. </if>
  5192. <if test="isPlacefile != null and isPlacefile != ''">
  5193. and a.is_placefile = #{isPlacefile}
  5194. </if>
  5195. <![CDATA[AND a.qc_type_id <>0 ]]>
  5196. <if test="hospitalId != null and hospitalId != ''">
  5197. AND a.hospital_id = #{hospitalId}
  5198. </if>
  5199. <if test="behosDateStart != null">
  5200. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5201. </if>
  5202. <if test="behosDateEnd != null">
  5203. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5204. </if>
  5205. <if test="leaveHosDateStart != null ">
  5206. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  5207. </if>
  5208. <if test="leaveHosDateEnd != null ">
  5209. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  5210. </if>
  5211. <if test="behospitalCode != null and behospitalCode != ''">
  5212. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5213. </if>
  5214. <if test="level != null and level != ''">
  5215. AND b.level = #{level}
  5216. </if>
  5217. <if test="doctorName != null and doctorName != ''">
  5218. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5219. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5220. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5221. </if>
  5222. <if test="doctorCode != null and doctorCode != ''">
  5223. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5224. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5225. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5226. </if>
  5227. <if test="deptId != null and deptId != ''">
  5228. AND a.beh_dept_id = #{deptId}
  5229. </if>
  5230. <if test="deptName != null and deptName != ''">
  5231. and a.beh_dept_name = #{deptName}
  5232. </if>
  5233. <if test="name != null and name != ''">
  5234. AND a.name like CONCAT('%',#{name},'%')
  5235. </if>
  5236. GROUP BY a.beh_dept_id,
  5237. a.beh_dept_name
  5238. ) t2
  5239. WHERE
  5240. t1.behDeptId = t2.behDeptId
  5241. AND t1.behDeptName = t2.behDeptName
  5242. ORDER BY
  5243. t1.behDeptName,
  5244. t1.doctorName,
  5245. t1.patName,
  5246. <if test="radioCheck !=null and radioCheck == 1">
  5247. t1.caseName,
  5248. </if>
  5249. t1.behospitalCode
  5250. )tp
  5251. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  5252. ON tp.behospitalCode = g.behospital_code
  5253. AND tp.hospitalId = g.hospital_id
  5254. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5255. ON tp.behospitalCode = h.behospital_code
  5256. AND tp.hospitalId = h.hospital_id
  5257. ) tu
  5258. WHERE tu.behospitalCode IS NOT NULL
  5259. <if test="checkStatus != null ">
  5260. and tu.check_status = #{checkStatus}
  5261. </if>
  5262. <if test="mrStatus != null ">
  5263. AND tu.mr_status = #{mrStatus}
  5264. </if>
  5265. <if test="chName != null and chName !=''">
  5266. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5267. </if>
  5268. <if test="mrName != null and mrName !=''">
  5269. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5270. </if>
  5271. <if test="chTimeStart != null">
  5272. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5273. </if>
  5274. <if test="chTimeEnd != null">
  5275. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5276. </if>
  5277. <if test="mrTimeStart != null">
  5278. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5279. </if>
  5280. <if test="mrTimeEnd != null">
  5281. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5282. </if>
  5283. </select>
  5284. <!-- 医疗组质控评分导出到excel-->
  5285. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  5286. SELECT * FROM (
  5287. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  5288. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  5289. g.check_type AS ch_type,
  5290. h.check_type AS mr_type,
  5291. g.check_name AS ch_name,
  5292. h.check_name AS mr_name,
  5293. g.check_time AS ch_time,
  5294. h.check_time AS mr_time
  5295. FROM (
  5296. SELECT
  5297. t1.behDeptId,
  5298. t1.behDeptName,
  5299. t1.doctorName,
  5300. t1.patName,
  5301. t1.fileCode,
  5302. t1.behospitalCode,
  5303. t1.hospitalId,
  5304. t1.behospitalDate,
  5305. t1.leaveHospitalDate,
  5306. t1.score,
  5307. t2.avgScore,
  5308. <if test="radioCheck !=null and radioCheck == 1">
  5309. t1.msg,
  5310. t1.caseName,
  5311. </if>
  5312. e.score_res as scoreBn
  5313. FROM
  5314. (
  5315. SELECT
  5316. a.doctor_name AS doctorName,
  5317. a.`name` AS patName,
  5318. a.file_code as fileCode,
  5319. a.behospital_code AS behospitalCode,
  5320. a.behospital_date AS behospitalDate,
  5321. a.leave_hospital_date AS leaveHospitalDate,
  5322. b.score_res AS score,
  5323. <if test="radioCheck !=null and radioCheck == 1">
  5324. c.msg AS msg,
  5325. d.NAME AS caseName,
  5326. </if>
  5327. a.beh_dept_id AS behDeptId,
  5328. a.beh_dept_name AS behDeptName,
  5329. a.hospital_id AS hospitalId
  5330. FROM
  5331. med_behospital_info a,
  5332. med_qcresult_info b,
  5333. med_qcresult_detail c,
  5334. qc_cases d
  5335. WHERE
  5336. a.is_deleted = 'N'
  5337. AND b.is_deleted = 'N'
  5338. AND c.is_deleted = 'N'
  5339. AND d.is_deleted = 'N'
  5340. AND a.hospital_id = b.hospital_id
  5341. AND a.hospital_id = c.hospital_id
  5342. AND a.behospital_code = b.behospital_code
  5343. AND a.behospital_code = c.behospital_code
  5344. AND c.cases_id = d.id
  5345. <if test="isPlacefile != null and isPlacefile != ''">
  5346. and a.is_placefile = #{isPlacefile}
  5347. </if>
  5348. AND a.doctor_id in
  5349. (SELECT doctor_id FROM `bas_doctor_info`
  5350. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5351. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5352. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5353. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5354. and c1.username = c3.doctor_id
  5355. and c2.hospital_id = #{hospitalId}
  5356. and c1.id = #{userId}
  5357. ))
  5358. <![CDATA[AND a.qc_type_id <>0 ]]>
  5359. <if test="hospitalId != null and hospitalId != ''">
  5360. AND a.hospital_id = #{hospitalId}
  5361. </if>
  5362. <if test="diagnose != null and diagnose != ''">
  5363. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5364. </if>
  5365. <if test="behosDateStart != null">
  5366. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5367. </if>
  5368. <if test="behosDateEnd != null">
  5369. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5370. </if>
  5371. <if test="leaveHosDateStart != null ">
  5372. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5373. </if>
  5374. <if test="leaveHosDateEnd != null ">
  5375. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5376. </if>
  5377. <if test="behospitalCode != null and behospitalCode != ''">
  5378. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5379. </if>
  5380. <if test="level != null and level != ''">
  5381. AND b.level = #{level}
  5382. </if>
  5383. <if test="doctorName != null and doctorName != ''">
  5384. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5385. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5386. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5387. </if>
  5388. <if test="doctorCode != null and doctorCode != ''">
  5389. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5390. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5391. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5392. </if>
  5393. <if test="deptId != null and deptId != ''">
  5394. AND a.beh_dept_id = #{deptId}
  5395. </if>
  5396. <if test="name != null and name != ''">
  5397. AND a.name like CONCAT('%',#{name},'%')
  5398. </if>
  5399. ) t1 LEFT JOIN med_qcresult_cases e
  5400. on t1.behospitalCode = e.behospital_code
  5401. and t1.hospitalId = e.hospital_id
  5402. AND e.is_deleted = 'N'
  5403. and e.cases_id = 243,
  5404. (
  5405. SELECT
  5406. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  5407. a.beh_dept_id AS behDeptId,
  5408. a.beh_dept_name AS behDeptName
  5409. FROM
  5410. med_behospital_info a,
  5411. med_qcresult_info b
  5412. WHERE
  5413. a.is_deleted = 'N'
  5414. AND a.doctor_id in
  5415. (SELECT doctor_id FROM `bas_doctor_info`
  5416. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  5417. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  5418. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  5419. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  5420. and c1.username = c3.doctor_id
  5421. and c2.hospital_id = #{hospitalId}
  5422. and c1.id = #{userId}
  5423. ))
  5424. AND b.is_deleted = 'N'
  5425. AND a.hospital_id = b.hospital_id
  5426. AND a.behospital_code = b.behospital_code
  5427. <if test="diagnose != null and diagnose != ''">
  5428. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  5429. </if>
  5430. <if test="isPlacefile != null and isPlacefile != ''">
  5431. and a.is_placefile = #{isPlacefile}
  5432. </if>
  5433. <![CDATA[AND a.qc_type_id <>0 ]]>
  5434. <if test="hospitalId != null and hospitalId != ''">
  5435. AND a.hospital_id = #{hospitalId}
  5436. </if>
  5437. <if test="behosDateStart != null">
  5438. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  5439. </if>
  5440. <if test="behosDateEnd != null">
  5441. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  5442. </if>
  5443. <if test="leaveHosDateStart != null ">
  5444. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  5445. </if>
  5446. <if test="leaveHosDateEnd != null ">
  5447. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  5448. </if>
  5449. <if test="behospitalCode != null and behospitalCode != ''">
  5450. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5451. </if>
  5452. <if test="level != null and level != ''">
  5453. AND b.level = #{level}
  5454. </if>
  5455. <if test="doctorName != null and doctorName != ''">
  5456. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5457. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5458. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5459. </if>
  5460. <if test="doctorCode != null and doctorCode != ''">
  5461. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5462. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5463. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5464. </if>
  5465. <if test="deptId != null and deptId != ''">
  5466. AND a.beh_dept_id = #{deptId}
  5467. </if>
  5468. <if test="name != null and name != ''">
  5469. AND a.name like CONCAT('%',#{name},'%')
  5470. </if>
  5471. GROUP BY
  5472. a.beh_dept_id,
  5473. a.beh_dept_name
  5474. ) t2
  5475. WHERE
  5476. t1.behDeptId = t2.behDeptId
  5477. AND t1.behDeptName = t2.behDeptName
  5478. ORDER BY
  5479. t1.behDeptName,
  5480. t1.doctorName,
  5481. t1.patName,
  5482. <if test="radioCheck !=null and radioCheck == 1">
  5483. t1.caseName,
  5484. </if>
  5485. t1.behospitalCode
  5486. )tp
  5487. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  5488. ON tp.behospitalCode = g.behospital_code
  5489. AND tp.hospitalId = g.hospital_id
  5490. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5491. ON tp.behospitalCode = h.behospital_code
  5492. AND tp.hospitalId = h.hospital_id
  5493. ) tu
  5494. WHERE tu.behospitalCode IS NOT NULL
  5495. <if test="checkStatus != null ">
  5496. and tu.check_status = #{checkStatus}
  5497. </if>
  5498. <if test="mrStatus != null ">
  5499. AND tu.mr_status = #{mrStatus}
  5500. </if>
  5501. <if test="chName != null and chName !=''">
  5502. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5503. </if>
  5504. <if test="mrName != null and mrName !=''">
  5505. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5506. </if>
  5507. <if test="chTimeStart != null">
  5508. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5509. </if>
  5510. <if test="chTimeEnd != null">
  5511. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5512. </if>
  5513. <if test="mrTimeStart != null">
  5514. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5515. </if>
  5516. <if test="mrTimeEnd != null">
  5517. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5518. </if>
  5519. </select>
  5520. <!-- 条目缺陷质控评分页(内页)-->
  5521. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5522. SELECT t.*
  5523. FROM
  5524. (SELECT DISTINCT
  5525. t1.hospital_id AS hospitalId,
  5526. t1.behospital_code AS behospitalCode,
  5527. t1.bed_code AS bedCode,
  5528. t1.LEVEL AS LEVEL,
  5529. t1.grade_type AS gradeType,
  5530. t1.score_res AS scoreRes,
  5531. t1.scoreBn,
  5532. t1.NAME AS NAME,
  5533. t1.sex AS sex,
  5534. t1.beh_dept_id AS behDeptId,
  5535. t1.beh_dept_name AS behDeptName,
  5536. t1.doctor_id AS doctorId,
  5537. t1.doctor_name AS doctorName,
  5538. t1.beh_doctor_id AS behDoctorId,
  5539. t1.beh_doctor_name AS behDoctorName,
  5540. t1.director_doctor_id AS directorDoctorId,
  5541. t1.director_doctor_name AS directorDoctorName,
  5542. t1.birthday AS birthday,
  5543. t1.behospital_date AS behospitalDate,
  5544. t1.leave_hospital_date AS leaveHospitalDate,
  5545. t1.placefile_date AS placefileDate,
  5546. t1.gmt_create AS gradeTime,
  5547. t1.diagnose,
  5548. t1.ward_name AS wardName,
  5549. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5550. t1.file_code AS fileCode,
  5551. t1.checkStatus,
  5552. t1.mrStatus,
  5553. t1.chName,
  5554. t1.mrName,
  5555. t1.chTime,
  5556. t1.mrTime
  5557. FROM
  5558. (
  5559. SELECT DISTINCT
  5560. tt1.*
  5561. FROM
  5562. (SELECT
  5563. be.*,
  5564. ifnull(mci.status,0) AS checkStatus,
  5565. ifnull(hm_mci.status,0) AS mrStatus,
  5566. mci.check_name as chName,
  5567. e.score_res as scoreBn,
  5568. hm_mci.check_name as mrName,
  5569. mci.gmt_create as chTime,
  5570. hm_mci.gmt_create as mrTime
  5571. FROM
  5572. (
  5573. SELECT DISTINCT
  5574. a.hospital_id,
  5575. a.behospital_code,
  5576. a.bed_code,
  5577. a.file_code,
  5578. b.LEVEL,
  5579. b.grade_type,
  5580. b.score_res,
  5581. a.NAME,
  5582. a.sex,
  5583. a.beh_dept_id,
  5584. a.beh_dept_name,
  5585. a.birthday,
  5586. a.behospital_date,
  5587. a.leave_hospital_date,
  5588. a.doctor_id,
  5589. a.doctor_name,
  5590. a.beh_doctor_id,
  5591. a.beh_doctor_name,
  5592. a.director_doctor_id,
  5593. a.director_doctor_name,
  5594. a.diagnose,
  5595. a.placefile_date,
  5596. a.ward_name,
  5597. b.gmt_create
  5598. FROM
  5599. med_behospital_info a,
  5600. med_qcresult_info b,
  5601. med_qcresult_detail c,
  5602. qc_cases_entry d
  5603. WHERE
  5604. a.is_deleted = 'N'
  5605. AND b.is_deleted = 'N'
  5606. AND c.is_deleted = 'N'
  5607. AND d.is_deleted = 'N'
  5608. AND a.hospital_id = b.hospital_id
  5609. AND a.hospital_id = c.hospital_id
  5610. AND a.behospital_code = b.behospital_code
  5611. AND a.behospital_code = c.behospital_code
  5612. AND c.cases_id = d.cases_id
  5613. AND c.cases_entry_id = d.id
  5614. AND a.qc_type_id != 0
  5615. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5616. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5617. </if>
  5618. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5619. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5620. </if>
  5621. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5622. <if test="qcResultShortPageVO.startDate != null ">
  5623. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5624. </if>
  5625. <if test="qcResultShortPageVO.endDate != null ">
  5626. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5627. </if>
  5628. </if>
  5629. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5630. <if test="qcResultShortPageVO.startDate != null ">
  5631. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5632. </if>
  5633. <if test="qcResultShortPageVO.endDate != null">
  5634. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5635. </if>
  5636. </if>
  5637. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5638. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5639. </if>
  5640. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5641. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5642. </if>
  5643. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5644. AND b.`level` = #{qcResultShortPageVO.level}
  5645. </if>
  5646. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5647. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5648. </if>
  5649. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5650. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5651. </if>
  5652. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5653. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5654. </if>
  5655. <if test="qcResultShortPageVO.casesEntryId != null ">
  5656. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5657. </if>
  5658. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5659. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5660. </if>
  5661. <if test="qcResultShortPageVO.casesId != null">
  5662. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5663. </if>
  5664. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5665. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5666. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5667. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5668. </if>
  5669. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5670. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5671. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5672. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5673. </if>
  5674. <if test="qcResultShortPageVO.isReject != null">
  5675. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5676. </if>
  5677. <if test="qcResultShortPageVO.ruleType != null">
  5678. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5679. </if>
  5680. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5681. AND TIMESTAMPDIFF(
  5682. DAY,
  5683. DATE( a.behospital_date ),
  5684. DATE( a.leave_hospital_date ))> 30
  5685. </if>
  5686. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5687. AND TIMESTAMPDIFF(
  5688. DAY,
  5689. DATE( a.behospital_date ),
  5690. DATE( a.leave_hospital_date ))> 31
  5691. </if>
  5692. )be
  5693. left join med_check_info mci
  5694. on mci.is_deleted = 'N'
  5695. and mci.check_type = 0
  5696. and be.hospital_id = mci.hospital_id
  5697. and be.behospital_code = mci.behospital_code
  5698. left join med_check_info hm_mci
  5699. on hm_mci.is_deleted = 'N'
  5700. and hm_mci.check_type = 1
  5701. and be.hospital_id = hm_mci.hospital_id
  5702. and be.behospital_code = hm_mci.behospital_code
  5703. LEFT JOIN med_qcresult_cases e
  5704. on be.behospital_code = e.behospital_code
  5705. and be.hospital_id = e.hospital_id
  5706. AND e.is_deleted = 'N'
  5707. and e.cases_id = 243
  5708. )tt1
  5709. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5710. ,med_medical_record tt2
  5711. WHERE
  5712. tt2.is_deleted = 'N'
  5713. AND tt1.hospital_id = tt2.hospital_id
  5714. AND tt1.behospital_code = tt2.behospital_code
  5715. AND tt2.mode_id = 30
  5716. </if>
  5717. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5718. ,med_crisis_info tt2
  5719. WHERE
  5720. tt2.is_deleted = 'N'
  5721. AND tt1.hospital_id = tt2.hospital_id
  5722. AND tt1.behospital_code = tt2.behospital_code
  5723. </if>
  5724. ) t1
  5725. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5726. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5727. AND t1.behospital_code = t2.behospital_code
  5728. AND t2.is_deleted = 'N'
  5729. </if>
  5730. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5731. , med_home_page t2
  5732. , med_home_operation_info t3
  5733. WHERE t1.hospital_id = t2.hospital_id
  5734. AND t1.behospital_code = t2.behospital_code
  5735. AND t2.home_page_id = t3.home_page_id
  5736. AND t2.is_deleted = 'N'
  5737. AND t3.is_deleted = 'N'
  5738. </if>
  5739. ) t
  5740. where 1=1
  5741. <if test="qcResultShortPageVO.checkStatus != null">
  5742. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5743. </if>
  5744. <if test="qcResultShortPageVO.mrStatus != null">
  5745. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5746. </if>
  5747. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5748. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5749. </if>
  5750. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5751. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5752. </if>
  5753. <if test="qcResultShortPageVO.chTimeStart != null ">
  5754. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5755. </if>
  5756. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5757. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5758. </if>
  5759. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5760. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5761. </if>
  5762. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5763. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5764. </if>
  5765. </select>
  5766. <!-- 条目缺陷质控评分页-科室(内页)-->
  5767. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  5768. SELECT t.*
  5769. FROM
  5770. (SELECT DISTINCT
  5771. t1.hospital_id AS hospitalId,
  5772. t1.behospital_code AS behospitalCode,
  5773. t1.bed_code AS bedCode,
  5774. t1.LEVEL AS LEVEL,
  5775. t1.grade_type AS gradeType,
  5776. t1.score_res AS scoreRes,
  5777. t1.scoreBn,
  5778. t1.medoupName,
  5779. t1.NAME AS NAME,
  5780. t1.sex AS sex,
  5781. t1.beh_dept_id AS behDeptId,
  5782. t1.beh_dept_name AS behDeptName,
  5783. t1.doctor_id AS doctorId,
  5784. t1.doctor_name AS doctorName,
  5785. t1.beh_doctor_id AS behDoctorId,
  5786. t1.beh_doctor_name AS behDoctorName,
  5787. t1.director_doctor_id AS directorDoctorId,
  5788. t1.director_doctor_name AS directorDoctorName,
  5789. t1.birthday AS birthday,
  5790. t1.behospital_date AS behospitalDate,
  5791. t1.leave_hospital_date AS leaveHospitalDate,
  5792. t1.placefile_date AS placefileDate,
  5793. t1.gmt_create AS gradeTime,
  5794. t1.diagnose,
  5795. t1.ward_name AS wardName,
  5796. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5797. t1.file_code AS fileCode,
  5798. t1.checkStatus,
  5799. t1.mrStatus,
  5800. t1.chName,
  5801. t1.mrName,
  5802. t1.chTime,
  5803. t1.mrTime
  5804. FROM
  5805. (
  5806. SELECT DISTINCT
  5807. tt1.*
  5808. FROM
  5809. (SELECT
  5810. be.*,
  5811. t3.name as medoupName,
  5812. ifnull(mci.status,0) AS checkStatus,
  5813. ifnull(hm_mci.status,0) AS mrStatus,
  5814. mci.check_name as chName,
  5815. e.score_res as scoreBn,
  5816. hm_mci.check_name as mrName,
  5817. mci.gmt_create as chTime,
  5818. hm_mci.gmt_create as mrTime
  5819. FROM
  5820. (
  5821. SELECT DISTINCT
  5822. a.hospital_id,
  5823. a.behospital_code,
  5824. a.bed_code,
  5825. a.file_code,
  5826. b.LEVEL,
  5827. b.grade_type,
  5828. b.score_res,
  5829. a.NAME,
  5830. a.sex,
  5831. a.beh_dept_id,
  5832. a.beh_dept_name,
  5833. a.birthday,
  5834. a.behospital_date,
  5835. a.leave_hospital_date,
  5836. a.doctor_id,
  5837. a.doctor_name,
  5838. a.beh_doctor_id,
  5839. a.beh_doctor_name,
  5840. a.director_doctor_id,
  5841. a.director_doctor_name,
  5842. a.diagnose,
  5843. a.placefile_date,
  5844. a.ward_name,
  5845. b.gmt_create
  5846. FROM
  5847. med_behospital_info a,
  5848. med_qcresult_info b,
  5849. med_qcresult_detail c,
  5850. qc_cases_entry d,
  5851. sys_user_dept e
  5852. WHERE
  5853. a.is_deleted = 'N'
  5854. AND b.is_deleted = 'N'
  5855. AND c.is_deleted = 'N'
  5856. AND d.is_deleted = 'N'
  5857. AND e.is_deleted = 'N'
  5858. AND a.hospital_id = b.hospital_id
  5859. AND a.hospital_id = c.hospital_id
  5860. AND a.hospital_id = e.hospital_id
  5861. AND a.behospital_code = b.behospital_code
  5862. AND a.behospital_code = c.behospital_code
  5863. AND a.beh_dept_id = e.dept_id
  5864. AND c.cases_id = d.cases_id
  5865. AND c.cases_entry_id = d.id
  5866. AND a.qc_type_id != 0
  5867. <if test="qcResultShortPageVO.userId!=null">
  5868. AND e.user_id = #{qcResultShortPageVO.userId}
  5869. </if>
  5870. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5871. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5872. </if>
  5873. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5874. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5875. </if>
  5876. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5877. <if test="qcResultShortPageVO.startDate != null ">
  5878. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5879. </if>
  5880. <if test="qcResultShortPageVO.endDate != null ">
  5881. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5882. </if>
  5883. </if>
  5884. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5885. <if test="qcResultShortPageVO.startDate != null ">
  5886. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5887. </if>
  5888. <if test="qcResultShortPageVO.endDate != null">
  5889. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5890. </if>
  5891. </if>
  5892. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5893. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5894. </if>
  5895. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  5896. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  5897. </if>
  5898. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5899. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5900. </if>
  5901. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  5902. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  5903. </if>
  5904. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5905. AND b.`level` = #{qcResultShortPageVO.level}
  5906. </if>
  5907. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5908. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5909. </if>
  5910. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5911. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5912. </if>
  5913. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5914. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5915. </if>
  5916. <if test="qcResultShortPageVO.casesEntryId != null ">
  5917. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5918. </if>
  5919. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5920. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5921. </if>
  5922. <if test="qcResultShortPageVO.casesId != null">
  5923. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5924. </if>
  5925. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5926. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  5927. </if>
  5928. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5929. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  5930. </if>
  5931. <if test="qcResultShortPageVO.isReject != null">
  5932. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5933. </if>
  5934. <if test="qcResultShortPageVO.ruleType != null">
  5935. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5936. </if>
  5937. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5938. AND TIMESTAMPDIFF(
  5939. DAY,
  5940. DATE( a.behospital_date ),
  5941. DATE( a.leave_hospital_date ))> 30
  5942. </if>
  5943. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5944. AND TIMESTAMPDIFF(
  5945. DAY,
  5946. DATE( a.behospital_date ),
  5947. DATE( a.leave_hospital_date ))> 31
  5948. </if>
  5949. )be
  5950. left join med_check_info mci
  5951. on mci.is_deleted = 'N'
  5952. and mci.check_type = 0
  5953. and be.hospital_id = mci.hospital_id
  5954. and be.behospital_code = mci.behospital_code
  5955. left join med_check_info hm_mci
  5956. on hm_mci.is_deleted = 'N'
  5957. and hm_mci.check_type = 1
  5958. and be.hospital_id = hm_mci.hospital_id
  5959. and be.behospital_code = hm_mci.behospital_code
  5960. LEFT JOIN med_qcresult_cases e
  5961. on be.behospital_code = e.behospital_code
  5962. and be.hospital_id = e.hospital_id
  5963. AND e.is_deleted = 'N'
  5964. and e.cases_id = 243
  5965. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  5966. and be.hospital_id = t2.hospital_id
  5967. AND t2.is_deleted = 'N'
  5968. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  5969. AND t3.is_deleted = 'N'
  5970. )tt1
  5971. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5972. ,med_medical_record tt2
  5973. WHERE
  5974. tt2.is_deleted = 'N'
  5975. AND tt1.hospital_id = tt2.hospital_id
  5976. AND tt1.behospital_code = tt2.behospital_code
  5977. AND tt2.mode_id = 30
  5978. </if>
  5979. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5980. ,med_crisis_info tt2
  5981. WHERE
  5982. tt2.is_deleted = 'N'
  5983. AND tt1.hospital_id = tt2.hospital_id
  5984. AND tt1.behospital_code = tt2.behospital_code
  5985. </if>
  5986. ) t1
  5987. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5988. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5989. AND t1.behospital_code = t2.behospital_code
  5990. AND t2.is_deleted = 'N'
  5991. </if>
  5992. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5993. , med_home_page t2
  5994. , med_home_operation_info t3
  5995. WHERE t1.hospital_id = t2.hospital_id
  5996. AND t1.behospital_code = t2.behospital_code
  5997. AND t2.home_page_id = t3.home_page_id
  5998. AND t2.is_deleted = 'N'
  5999. AND t3.is_deleted = 'N'
  6000. </if>
  6001. ) t
  6002. where
  6003. 1=1
  6004. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  6005. and t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  6006. </if>
  6007. <if test="qcResultShortPageVO.checkStatus != null">
  6008. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6009. </if>
  6010. <if test="qcResultShortPageVO.mrStatus != null">
  6011. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6012. </if>
  6013. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6014. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6015. </if>
  6016. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6017. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6018. </if>
  6019. <if test="qcResultShortPageVO.chTimeStart != null ">
  6020. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6021. </if>
  6022. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6023. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6024. </if>
  6025. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6026. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6027. </if>
  6028. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6029. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6030. </if>
  6031. </select>
  6032. <update id="updateBatchByKey">
  6033. <foreach collection="list" item="item" separator=";">
  6034. update med_behospital_info
  6035. <set>
  6036. <if test="item.name != null">
  6037. name = #{item.name},
  6038. </if>
  6039. <if test="item.sex != null">
  6040. sex = #{item.sex},
  6041. </if>
  6042. <if test="item.birthday != null">
  6043. birthday = #{item.birthday},
  6044. </if>
  6045. <if test="item.fileCode != null">
  6046. file_code = #{item.fileCode},
  6047. </if>
  6048. <if test="item.qcTypeId != null">
  6049. qc_type_id = #{item.qcTypeId},
  6050. </if>
  6051. <if test="item.wardCode != null">
  6052. ward_code = #{item.wardCode},
  6053. </if>
  6054. <if test="item.wardName != null">
  6055. ward_name = #{item.wardName},
  6056. </if>
  6057. <if test="item.behDeptId != null">
  6058. beh_dept_id = #{item.behDeptId},
  6059. </if>
  6060. <if test="item.behDeptName != null">
  6061. beh_dept_name = #{item.behDeptName},
  6062. </if>
  6063. <if test="item.bedCode != null">
  6064. bed_code = #{item.bedCode},
  6065. </if>
  6066. <if test="item.bedName != null">
  6067. bed_name = #{item.bedName},
  6068. </if>
  6069. <if test="item.insuranceName != null">
  6070. insurance_name = #{item.insuranceName},
  6071. </if>
  6072. <if test="item.jobType != null">
  6073. job_type = #{item.jobType},
  6074. </if>
  6075. <if test="item.behospitalDate != null">
  6076. behospital_date = #{item.behospitalDate},
  6077. </if>
  6078. <if test="item.leaveHospitalDate != null">
  6079. leave_hospital_date = #{item.leaveHospitalDate},
  6080. </if>
  6081. <if test="item.diagnoseIcd != null">
  6082. diagnose_icd = #{item.diagnoseIcd},
  6083. </if>
  6084. <if test="item.diagnose != null">
  6085. diagnose = #{item.diagnose},
  6086. </if>
  6087. <if test="item.behDoctorId != null">
  6088. beh_doctor_id = #{item.behDoctorId},
  6089. </if>
  6090. <if test="item.behDoctorName != null">
  6091. beh_doctor_name = #{item.behDoctorName},
  6092. </if>
  6093. <if test="item.doctorId != null">
  6094. doctor_id = #{item.doctorId},
  6095. </if>
  6096. <if test="item.doctorName != null">
  6097. doctor_name = #{item.doctorName},
  6098. </if>
  6099. <if test="item.directorDoctorId != null">
  6100. director_doctor_id = #{item.directorDoctorId},
  6101. </if>
  6102. <if test="item.directorDoctorName != null">
  6103. director_doctor_name = #{item.directorDoctorName},
  6104. </if>
  6105. <if test="item.placefileDate != null">
  6106. placefile_date = #{item.placefileDate},
  6107. </if>
  6108. <if test="item.isPlacefile != null">
  6109. is_placefile = #{item.isPlacefile},
  6110. </if>
  6111. <if test="item.gmtModified != null">
  6112. gmt_modified = #{item.gmtModified},
  6113. </if>
  6114. <if test="item.modifier != null">
  6115. modifier = #{item.modifier},
  6116. </if>
  6117. </set>
  6118. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  6119. </foreach>
  6120. </update>
  6121. <!-- 关键条目缺陷统计报表-->
  6122. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  6123. SELECT
  6124. deptId,
  6125. deptName,
  6126. consultationMRNum,
  6127. consultationNum,
  6128. 2511 AS consultationEntryId,
  6129. '普通会诊未在24小时内完成' AS consultationEntryName,
  6130. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6131. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6132. operationMRNum,
  6133. 2594 AS operationNameEntryId,
  6134. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6135. operationNameNum,
  6136. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6137. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6138. 2973 AS operationTimeEntryId,
  6139. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6140. operationTimeNum,
  6141. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6142. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6143. 2930 AS operation15MinuteEntryId,
  6144. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6145. operation15MinuteNum,
  6146. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6147. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6148. 2419 AS crisisEntryId,
  6149. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6150. crisisMRNum,
  6151. crisisNum,
  6152. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6153. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6154. 2495 AS stageSummaryEntryId,
  6155. '无阶段小结' AS stageSummaryEntryName,
  6156. stageSummaryMRNum,
  6157. stageSummaryNum,
  6158. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6159. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6160. beHosGT31DaysMRNum
  6161. FROM
  6162. (
  6163. SELECT
  6164. tt.deptId,
  6165. tt.deptName,
  6166. sum( tt.consultationNum ) AS consultationNum,
  6167. sum( tt.consultationMRNum ) AS consultationMRNum,
  6168. sum( tt.operationNameNum ) AS operationNameNum,
  6169. sum( tt.operationTimeNum ) AS operationTimeNum,
  6170. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6171. sum( tt.operationMRNum ) AS operationMRNum,
  6172. sum( tt.crisisNum ) AS crisisNum,
  6173. sum( tt.crisisMRNum ) AS crisisMRNum,
  6174. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6175. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6176. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6177. FROM
  6178. (
  6179. (
  6180. SELECT
  6181. c.beh_dept_id AS deptId,
  6182. c.beh_dept_name AS deptName,
  6183. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6184. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6185. 0 AS operationNameNum,
  6186. 0 AS operationTimeNum,
  6187. 0 AS operation15MinuteNum,
  6188. 0 AS operationMRNum,
  6189. 0 AS crisisNum,
  6190. 0 AS crisisMRNum,
  6191. 0 AS stageSummaryNum,
  6192. 0 AS stageSummaryMRNum,
  6193. 0 AS beHosGT31DaysMRNum
  6194. FROM
  6195. (
  6196. SELECT DISTINCT
  6197. a.hospital_id,
  6198. a.behospital_code,
  6199. a.beh_dept_name,
  6200. a.beh_dept_id
  6201. FROM
  6202. med_behospital_info a,
  6203. med_medical_record b
  6204. WHERE
  6205. a.is_deleted = 'N'
  6206. AND b.is_deleted = 'N'
  6207. AND a.hospital_id = b.hospital_id
  6208. AND a.behospital_code = b.behospital_code
  6209. AND b.mode_id = 30
  6210. <if test="isPlacefile != null and isPlacefile != ''">
  6211. and a.is_placefile = #{isPlacefile}
  6212. </if>
  6213. AND a.qc_type_id != 0
  6214. <if test="hospitalId != null and hospitalId != ''">
  6215. AND a.hospital_id = #{hospitalId}
  6216. </if>
  6217. <if test="isPlacefile != null and isPlacefile == 0">
  6218. <if test="startDate != null ">
  6219. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6220. </if>
  6221. <if test="endDate != null ">
  6222. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6223. </if>
  6224. </if>
  6225. <if test="isPlacefile != null and isPlacefile == 1">
  6226. <if test="startDate != null ">
  6227. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6228. </if>
  6229. <if test="endDate != null ">
  6230. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6231. </if>
  6232. </if>
  6233. <if test="deptName != null and deptName != ''">
  6234. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6235. </if>
  6236. ) c
  6237. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6238. AND c.hospital_id = d.hospital_id
  6239. AND c.behospital_code = d.behospital_code
  6240. GROUP BY
  6241. c.beh_dept_id,
  6242. c.beh_dept_name
  6243. ) UNION
  6244. (
  6245. SELECT
  6246. d.beh_dept_id AS deptId,
  6247. d.beh_dept_name AS deptName,
  6248. 0 AS consultationNum,
  6249. 0 AS consultationMRNum,
  6250. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6251. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6252. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6253. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6254. 0 AS crisisNum,
  6255. 0 AS crisisMRNum,
  6256. 0 AS stageSummaryNum,
  6257. 0 AS stageSummaryMRNum,
  6258. 0 AS beHosGT31DaysMRNum
  6259. FROM
  6260. (
  6261. SELECT DISTINCT
  6262. a.hospital_id,
  6263. a.behospital_code,
  6264. a.beh_dept_name,
  6265. a.beh_dept_id
  6266. FROM
  6267. med_behospital_info a,
  6268. med_home_page b,
  6269. med_home_operation_info c
  6270. WHERE
  6271. a.is_deleted = 'N'
  6272. AND b.is_deleted = 'N'
  6273. AND c.is_deleted = 'N'
  6274. AND a.hospital_id = b.hospital_id
  6275. AND a.hospital_id = c.hospital_id
  6276. AND a.behospital_code = b.behospital_code
  6277. AND b.home_page_id = c.home_page_id
  6278. <if test="isPlacefile != null and isPlacefile != ''">
  6279. and a.is_placefile = #{isPlacefile}
  6280. </if>
  6281. AND a.qc_type_id != 0
  6282. <if test="hospitalId != null and hospitalId != ''">
  6283. AND a.hospital_id = #{hospitalId}
  6284. </if>
  6285. <if test="isPlacefile != null and isPlacefile == 0">
  6286. <if test="startDate != null ">
  6287. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6288. </if>
  6289. <if test="endDate != null ">
  6290. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6291. </if>
  6292. </if>
  6293. <if test="isPlacefile != null and isPlacefile == 1">
  6294. <if test="startDate != null ">
  6295. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6296. </if>
  6297. <if test="endDate != null ">
  6298. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6299. </if>
  6300. </if>
  6301. <if test="deptName != null and deptName != ''">
  6302. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6303. </if>
  6304. ) d
  6305. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6306. AND d.hospital_id = e.hospital_id
  6307. AND d.behospital_code = e.behospital_code
  6308. GROUP BY
  6309. d.beh_dept_id,
  6310. d.beh_dept_name
  6311. ) UNION
  6312. (
  6313. SELECT
  6314. c.beh_dept_id AS deptId,
  6315. c.beh_dept_name AS deptName,
  6316. 0 AS consultationNum,
  6317. 0 AS consultationMRNum,
  6318. 0 AS operationNameNum,
  6319. 0 AS operationTimeNum,
  6320. 0 AS operation15MinuteNum,
  6321. 0 AS operationMRNum,
  6322. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6323. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6324. 0 AS stageSummaryNum,
  6325. 0 AS stageSummaryMRNum,
  6326. 0 AS beHosGT31DaysMRNum
  6327. FROM
  6328. (
  6329. SELECT DISTINCT
  6330. a.hospital_id,
  6331. a.behospital_code,
  6332. a.beh_dept_name,
  6333. a.beh_dept_id
  6334. FROM
  6335. med_behospital_info a,
  6336. med_crisis_info b
  6337. WHERE
  6338. a.is_deleted = 'N'
  6339. AND b.is_deleted = 'N'
  6340. AND a.hospital_id = b.hospital_id
  6341. AND a.behospital_code = b.behospital_code
  6342. <if test="isPlacefile != null and isPlacefile != ''">
  6343. and a.is_placefile = #{isPlacefile}
  6344. </if>
  6345. AND a.qc_type_id != 0
  6346. <if test="hospitalId != null and hospitalId != ''">
  6347. AND a.hospital_id = #{hospitalId}
  6348. </if>
  6349. <if test="isPlacefile != null and isPlacefile == 0">
  6350. <if test="startDate != null ">
  6351. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6352. </if>
  6353. <if test="endDate != null ">
  6354. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6355. </if>
  6356. </if>
  6357. <if test="isPlacefile != null and isPlacefile == 1">
  6358. <if test="startDate != null ">
  6359. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6360. </if>
  6361. <if test="endDate != null ">
  6362. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6363. </if>
  6364. </if>
  6365. <if test="deptName != null and deptName != ''">
  6366. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6367. </if>
  6368. ) c
  6369. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6370. AND c.hospital_id = d.hospital_id
  6371. AND c.behospital_code = d.behospital_code
  6372. GROUP BY
  6373. c.beh_dept_id,
  6374. c.beh_dept_name
  6375. ) UNION
  6376. (
  6377. SELECT
  6378. b.beh_dept_id AS deptId,
  6379. b.beh_dept_name AS deptName,
  6380. 0 AS consultationNum,
  6381. 0 AS consultationMRNum,
  6382. 0 AS operationNameNum,
  6383. 0 AS operationTimeNum,
  6384. 0 AS operation15MinuteNum,
  6385. 0 AS operationMRNum,
  6386. 0 AS crisisNum,
  6387. 0 AS crisisMRNum,
  6388. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6389. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6390. 0 AS beHosGT31DaysMRNum
  6391. FROM
  6392. (
  6393. SELECT DISTINCT
  6394. a.hospital_id,
  6395. a.behospital_code,
  6396. a.beh_dept_name,
  6397. a.beh_dept_id
  6398. FROM
  6399. med_behospital_info a
  6400. WHERE
  6401. a.is_deleted = 'N'
  6402. AND TIMESTAMPDIFF(
  6403. DAY,
  6404. DATE( behospital_date ),
  6405. DATE( leave_hospital_date ))> 30
  6406. <if test="isPlacefile != null and isPlacefile != ''">
  6407. and a.is_placefile = #{isPlacefile}
  6408. </if>
  6409. AND a.qc_type_id != 0
  6410. <if test="hospitalId != null and hospitalId != ''">
  6411. AND a.hospital_id = #{hospitalId}
  6412. </if>
  6413. <if test="isPlacefile != null and isPlacefile == 0">
  6414. <if test="startDate != null ">
  6415. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6416. </if>
  6417. <if test="endDate != null ">
  6418. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6419. </if>
  6420. </if>
  6421. <if test="isPlacefile != null and isPlacefile == 1">
  6422. <if test="startDate != null ">
  6423. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6424. </if>
  6425. <if test="endDate != null ">
  6426. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6427. </if>
  6428. </if>
  6429. <if test="deptName != null and deptName != ''">
  6430. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6431. </if>
  6432. ) b
  6433. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6434. AND b.hospital_id = c.hospital_id
  6435. AND b.behospital_code = c.behospital_code
  6436. GROUP BY
  6437. b.beh_dept_id,
  6438. b.beh_dept_name
  6439. ) UNION
  6440. (
  6441. SELECT
  6442. b.beh_dept_id AS deptId,
  6443. b.beh_dept_name AS deptName,
  6444. 0 AS consultationNum,
  6445. 0 AS consultationMRNum,
  6446. 0 AS operationNameNum,
  6447. 0 AS operationTimeNum,
  6448. 0 AS operation15MinuteNum,
  6449. 0 AS operationMRNum,
  6450. 0 AS crisisNum,
  6451. 0 AS crisisMRNum,
  6452. 0 AS stageSummaryNum,
  6453. 0 AS stageSummaryMRNum,
  6454. count(*) AS beHosGT31DaysMRNum
  6455. FROM
  6456. (
  6457. SELECT DISTINCT
  6458. a.hospital_id,
  6459. a.behospital_code,
  6460. a.beh_dept_name,
  6461. a.beh_dept_id
  6462. FROM
  6463. med_behospital_info a,
  6464. med_qcresult_info b,
  6465. med_qcresult_detail c,
  6466. qc_cases_entry d
  6467. WHERE
  6468. a.is_deleted = 'N'
  6469. AND b.is_deleted = 'N'
  6470. AND c.is_deleted = 'N'
  6471. AND d.is_deleted = 'N'
  6472. AND a.hospital_id = b.hospital_id
  6473. AND a.hospital_id = c.hospital_id
  6474. AND a.behospital_code = b.behospital_code
  6475. AND a.behospital_code = c.behospital_code
  6476. AND c.cases_id = d.cases_id
  6477. AND c.cases_entry_id = d.id
  6478. AND TIMESTAMPDIFF(
  6479. DAY,
  6480. DATE( behospital_date ),
  6481. DATE( leave_hospital_date ))> 31
  6482. <if test="isPlacefile != null and isPlacefile != ''">
  6483. and a.is_placefile = #{isPlacefile}
  6484. </if>
  6485. AND a.qc_type_id != 0
  6486. <if test="hospitalId != null and hospitalId != ''">
  6487. AND a.hospital_id = #{hospitalId}
  6488. </if>
  6489. <if test="isPlacefile != null and isPlacefile == 0">
  6490. <if test="startDate != null ">
  6491. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6492. </if>
  6493. <if test="endDate != null ">
  6494. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6495. </if>
  6496. </if>
  6497. <if test="isPlacefile != null and isPlacefile == 1">
  6498. <if test="startDate != null ">
  6499. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6500. </if>
  6501. <if test="endDate != null ">
  6502. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6503. </if>
  6504. </if>
  6505. <if test="deptName != null and deptName != ''">
  6506. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6507. </if>
  6508. ) b
  6509. GROUP BY
  6510. b.beh_dept_id,
  6511. b.beh_dept_name
  6512. )
  6513. ) tt
  6514. GROUP BY
  6515. tt.deptId,
  6516. tt.deptName
  6517. ) t
  6518. <if test="asc != null and asc !=''">
  6519. order by
  6520. <choose>
  6521. <when test='asc=="deptId"'>deptId asc</when>
  6522. <when test='asc=="deptName"'>deptName asc</when>
  6523. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6524. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6525. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6526. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6527. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6528. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6529. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6530. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6531. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6532. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6533. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6534. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6535. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6536. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6537. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6538. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6539. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6540. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6541. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6542. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6543. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6544. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6545. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6546. <otherwise>deptName asc</otherwise>
  6547. </choose>
  6548. </if>
  6549. <if test="desc != null and desc!=''">
  6550. order by
  6551. <choose>
  6552. <when test='desc=="deptId"'>deptId desc</when>
  6553. <when test='desc=="deptName"'>deptName desc</when>
  6554. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6555. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6556. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6557. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6558. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6559. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6560. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6561. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6562. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6563. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6564. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6565. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6566. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6567. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6568. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6569. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6570. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6571. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6572. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6573. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6574. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6575. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6576. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6577. <otherwise>deptName desc</otherwise>
  6578. </choose>
  6579. </if>
  6580. </select>
  6581. <!-- 关键条目缺陷统计报表-科室-->
  6582. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6583. SELECT
  6584. deptId,
  6585. deptName,
  6586. doctorName,
  6587. doctorId,
  6588. consultationMRNum,
  6589. consultationNum,
  6590. 2511 AS consultationEntryId,
  6591. '普通会诊未在24小时内完成' AS consultationEntryName,
  6592. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6593. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6594. operationMRNum,
  6595. 2594 AS operationNameEntryId,
  6596. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6597. operationNameNum,
  6598. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6599. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6600. 2973 AS operationTimeEntryId,
  6601. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6602. operationTimeNum,
  6603. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6604. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6605. 2930 AS operation15MinuteEntryId,
  6606. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6607. operation15MinuteNum,
  6608. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6609. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6610. 2419 AS crisisEntryId,
  6611. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6612. crisisMRNum,
  6613. crisisNum,
  6614. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6615. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6616. 2495 AS stageSummaryEntryId,
  6617. '无阶段小结' AS stageSummaryEntryName,
  6618. stageSummaryMRNum,
  6619. stageSummaryNum,
  6620. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6621. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6622. beHosGT31DaysMRNum
  6623. FROM
  6624. (
  6625. SELECT
  6626. tt.deptId,
  6627. tt.deptName,
  6628. tt.doctorId,
  6629. tt.doctorName,
  6630. sum( tt.consultationNum ) AS consultationNum,
  6631. sum( tt.consultationMRNum ) AS consultationMRNum,
  6632. sum( tt.operationNameNum ) AS operationNameNum,
  6633. sum( tt.operationTimeNum ) AS operationTimeNum,
  6634. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6635. sum( tt.operationMRNum ) AS operationMRNum,
  6636. sum( tt.crisisNum ) AS crisisNum,
  6637. sum( tt.crisisMRNum ) AS crisisMRNum,
  6638. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6639. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6640. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6641. FROM
  6642. (
  6643. (
  6644. SELECT
  6645. c.beh_dept_id AS deptId,
  6646. c.beh_dept_name AS deptName,
  6647. c.doctorId,
  6648. c.doctorName,
  6649. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6650. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6651. 0 AS operationNameNum,
  6652. 0 AS operationTimeNum,
  6653. 0 AS operation15MinuteNum,
  6654. 0 AS operationMRNum,
  6655. 0 AS crisisNum,
  6656. 0 AS crisisMRNum,
  6657. 0 AS stageSummaryNum,
  6658. 0 AS stageSummaryMRNum,
  6659. 0 AS beHosGT31DaysMRNum
  6660. FROM
  6661. (
  6662. SELECT DISTINCT
  6663. a.hospital_id,
  6664. a.behospital_code,
  6665. a.beh_dept_name,
  6666. a.beh_dept_id,
  6667. a.doctor_id as doctorId,
  6668. a.doctor_name as doctorName
  6669. FROM
  6670. med_behospital_info a,
  6671. med_medical_record b,
  6672. sys_user_dept c
  6673. WHERE
  6674. a.is_deleted = 'N'
  6675. AND b.is_deleted = 'N'
  6676. AND c.is_deleted = 'N'
  6677. AND a.hospital_id = b.hospital_id
  6678. AND a.hospital_id = c.hospital_id
  6679. AND a.behospital_code = b.behospital_code
  6680. AND a.beh_dept_id = c.dept_id
  6681. AND b.mode_id = 30
  6682. <if test="userId!=null">
  6683. AND c.user_id = #{userId}
  6684. </if>
  6685. <if test="isPlacefile != null and isPlacefile != ''">
  6686. and a.is_placefile = #{isPlacefile}
  6687. </if>
  6688. AND a.qc_type_id != 0
  6689. <if test="hospitalId != null and hospitalId != ''">
  6690. AND a.hospital_id = #{hospitalId}
  6691. </if>
  6692. <if test="isPlacefile != null and isPlacefile == 0">
  6693. <if test="startDate != null ">
  6694. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6695. </if>
  6696. <if test="endDate != null ">
  6697. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6698. </if>
  6699. </if>
  6700. <if test="isPlacefile != null and isPlacefile == 1">
  6701. <if test="startDate != null ">
  6702. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6703. </if>
  6704. <if test="endDate != null ">
  6705. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6706. </if>
  6707. </if>
  6708. <if test="doctorName != null and doctorName != ''">
  6709. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6710. </if>
  6711. <if test="deptName != null and deptName != ''">
  6712. AND a.beh_dept_name = #{deptName}
  6713. </if>
  6714. ) c
  6715. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6716. AND c.hospital_id = d.hospital_id
  6717. AND c.behospital_code = d.behospital_code
  6718. GROUP BY
  6719. c.doctorId,
  6720. c.doctorName
  6721. having
  6722. sum( d.cases_entry_id = 2511 ) is not null and sum( d.cases_entry_id = 2511 ) != 0
  6723. ) UNION
  6724. (
  6725. SELECT
  6726. d.beh_dept_id AS deptId,
  6727. d.beh_dept_name AS deptName,
  6728. d.doctor_id as doctorId,
  6729. d.doctor_name as doctorName,
  6730. 0 AS consultationNum,
  6731. 0 AS consultationMRNum,
  6732. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6733. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6734. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6735. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6736. 0 AS crisisNum,
  6737. 0 AS crisisMRNum,
  6738. 0 AS stageSummaryNum,
  6739. 0 AS stageSummaryMRNum,
  6740. 0 AS beHosGT31DaysMRNum
  6741. FROM
  6742. (
  6743. SELECT DISTINCT
  6744. a.hospital_id,
  6745. a.behospital_code,
  6746. a.beh_dept_name,
  6747. a.beh_dept_id,
  6748. a.doctor_id,
  6749. a.doctor_name
  6750. FROM
  6751. med_behospital_info a,
  6752. med_home_page b,
  6753. med_home_operation_info c,
  6754. sys_user_dept d
  6755. WHERE
  6756. a.is_deleted = 'N'
  6757. AND b.is_deleted = 'N'
  6758. AND c.is_deleted = 'N'
  6759. AND d.is_deleted = 'N'
  6760. AND a.hospital_id = b.hospital_id
  6761. AND a.hospital_id = c.hospital_id
  6762. AND a.hospital_id = d.hospital_id
  6763. AND a.behospital_code = b.behospital_code
  6764. AND b.home_page_id = c.home_page_id
  6765. AND a.beh_dept_id = d.dept_id
  6766. <if test="userId!=null">
  6767. AND d.user_id = #{userId}
  6768. </if>
  6769. <if test="isPlacefile != null and isPlacefile != ''">
  6770. and a.is_placefile = #{isPlacefile}
  6771. </if>
  6772. AND a.qc_type_id != 0
  6773. <if test="hospitalId != null and hospitalId != ''">
  6774. AND a.hospital_id = #{hospitalId}
  6775. </if>
  6776. <if test="isPlacefile != null and isPlacefile == 0">
  6777. <if test="startDate != null ">
  6778. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6779. </if>
  6780. <if test="endDate != null ">
  6781. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6782. </if>
  6783. </if>
  6784. <if test="isPlacefile != null and isPlacefile == 1">
  6785. <if test="startDate != null ">
  6786. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6787. </if>
  6788. <if test="endDate != null ">
  6789. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6790. </if>
  6791. </if>
  6792. <if test="doctorName != null and doctorName != ''">
  6793. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6794. </if>
  6795. <if test="deptName != null and deptName != ''">
  6796. AND a.beh_dept_name = #{deptName}
  6797. </if>
  6798. ) d
  6799. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6800. AND d.hospital_id = e.hospital_id
  6801. AND d.behospital_code = e.behospital_code
  6802. GROUP BY
  6803. d.doctor_id,
  6804. d.doctor_name
  6805. having sum( e.cases_entry_id = 2594 ) is not null and sum( e.cases_entry_id = 2594 ) != 0
  6806. and sum( e.cases_entry_id = 2973 ) is not null and sum( e.cases_entry_id = 2973 ) != 0
  6807. and sum( e.cases_entry_id = 2930 )is not null and sum( e.cases_entry_id = 2930 ) != 0
  6808. ) UNION
  6809. (
  6810. SELECT
  6811. c.beh_dept_id AS deptId,
  6812. c.beh_dept_name AS deptName,
  6813. c.doctor_id as doctorId,
  6814. c.doctor_name as doctorName,
  6815. 0 AS consultationNum,
  6816. 0 AS consultationMRNum,
  6817. 0 AS operationNameNum,
  6818. 0 AS operationTimeNum,
  6819. 0 AS operation15MinuteNum,
  6820. 0 AS operationMRNum,
  6821. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6822. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6823. 0 AS stageSummaryNum,
  6824. 0 AS stageSummaryMRNum,
  6825. 0 AS beHosGT31DaysMRNum
  6826. FROM
  6827. (
  6828. SELECT DISTINCT
  6829. a.hospital_id,
  6830. a.behospital_code,
  6831. a.beh_dept_name,
  6832. a.beh_dept_id,
  6833. a.doctor_id,
  6834. a.doctor_name
  6835. FROM
  6836. med_behospital_info a,
  6837. med_crisis_info b,
  6838. sys_user_dept c
  6839. WHERE
  6840. a.is_deleted = 'N'
  6841. AND b.is_deleted = 'N'
  6842. AND c.is_deleted = 'N'
  6843. AND a.hospital_id = b.hospital_id
  6844. AND a.hospital_id = c.hospital_id
  6845. AND a.behospital_code = b.behospital_code
  6846. AND a.beh_dept_id = c.dept_id
  6847. <if test="userId!=null">
  6848. AND c.user_id = #{userId}
  6849. </if>
  6850. <if test="isPlacefile != null and isPlacefile != ''">
  6851. and a.is_placefile = #{isPlacefile}
  6852. </if>
  6853. AND a.qc_type_id != 0
  6854. <if test="hospitalId != null and hospitalId != ''">
  6855. AND a.hospital_id = #{hospitalId}
  6856. </if>
  6857. <if test="isPlacefile != null and isPlacefile == 0">
  6858. <if test="startDate != null ">
  6859. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6860. </if>
  6861. <if test="endDate != null ">
  6862. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6863. </if>
  6864. </if>
  6865. <if test="isPlacefile != null and isPlacefile == 1">
  6866. <if test="startDate != null ">
  6867. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6868. </if>
  6869. <if test="endDate != null ">
  6870. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6871. </if>
  6872. </if>
  6873. <if test="doctorName != null and doctorName != ''">
  6874. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6875. </if>
  6876. <if test="deptName != null and deptName != ''">
  6877. AND a.beh_dept_name = #{deptName}
  6878. </if>
  6879. ) c
  6880. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6881. AND c.hospital_id = d.hospital_id
  6882. AND c.behospital_code = d.behospital_code
  6883. GROUP BY
  6884. c.doctor_id,
  6885. c.doctor_name
  6886. having sum( d.cases_entry_id = 2419 ) is not null and sum( d.cases_entry_id = 2419 ) != 0
  6887. ) UNION
  6888. (
  6889. SELECT
  6890. b.beh_dept_id AS deptId,
  6891. b.beh_dept_name AS deptName,
  6892. b.doctor_id as doctorId,
  6893. b.doctor_name as doctorName,
  6894. 0 AS consultationNum,
  6895. 0 AS consultationMRNum,
  6896. 0 AS operationNameNum,
  6897. 0 AS operationTimeNum,
  6898. 0 AS operation15MinuteNum,
  6899. 0 AS operationMRNum,
  6900. 0 AS crisisNum,
  6901. 0 AS crisisMRNum,
  6902. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6903. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6904. 0 AS beHosGT31DaysMRNum
  6905. FROM
  6906. (
  6907. SELECT DISTINCT
  6908. a.hospital_id,
  6909. a.behospital_code,
  6910. a.beh_dept_name,
  6911. a.beh_dept_id,
  6912. a.doctor_id,
  6913. a.doctor_name
  6914. FROM
  6915. med_behospital_info a,
  6916. sys_user_dept b
  6917. WHERE
  6918. a.is_deleted = 'N'
  6919. AND b.is_deleted = 'N'
  6920. AND a.hospital_id = b.hospital_id
  6921. AND a.beh_dept_id = b.dept_id
  6922. AND TIMESTAMPDIFF(
  6923. DAY,
  6924. DATE( behospital_date ),
  6925. DATE( leave_hospital_date ))> 30
  6926. <if test="userId!=null">
  6927. AND b.user_id = #{userId}
  6928. </if>
  6929. <if test="isPlacefile != null and isPlacefile != ''">
  6930. and a.is_placefile = #{isPlacefile}
  6931. </if>
  6932. AND a.qc_type_id != 0
  6933. <if test="hospitalId != null and hospitalId != ''">
  6934. AND a.hospital_id = #{hospitalId}
  6935. </if>
  6936. <if test="isPlacefile != null and isPlacefile == 0">
  6937. <if test="startDate != null ">
  6938. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6939. </if>
  6940. <if test="endDate != null ">
  6941. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6942. </if>
  6943. </if>
  6944. <if test="isPlacefile != null and isPlacefile == 1">
  6945. <if test="startDate != null ">
  6946. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6947. </if>
  6948. <if test="endDate != null ">
  6949. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6950. </if>
  6951. </if>
  6952. <if test="doctorName != null and doctorName != ''">
  6953. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6954. </if>
  6955. <if test="deptName != null and deptName != ''">
  6956. AND a.beh_dept_name = #{deptName}
  6957. </if>
  6958. ) b
  6959. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6960. AND b.hospital_id = c.hospital_id
  6961. AND b.behospital_code = c.behospital_code
  6962. GROUP BY
  6963. b.doctor_id,
  6964. b.doctor_name
  6965. having sum(c.cases_entry_id = 2495) is not null and sum(c.cases_entry_id = 2495) != 0
  6966. ) UNION
  6967. (
  6968. SELECT
  6969. b.beh_dept_id AS deptId,
  6970. b.beh_dept_name AS deptName,
  6971. b.doctor_id as doctorId,
  6972. b.doctor_name as doctorName,
  6973. 0 AS consultationNum,
  6974. 0 AS consultationMRNum,
  6975. 0 AS operationNameNum,
  6976. 0 AS operationTimeNum,
  6977. 0 AS operation15MinuteNum,
  6978. 0 AS operationMRNum,
  6979. 0 AS crisisNum,
  6980. 0 AS crisisMRNum,
  6981. 0 AS stageSummaryNum,
  6982. 0 AS stageSummaryMRNum,
  6983. count(*) AS beHosGT31DaysMRNum
  6984. FROM
  6985. (
  6986. SELECT DISTINCT
  6987. a.hospital_id,
  6988. a.behospital_code,
  6989. a.beh_dept_name,
  6990. a.beh_dept_id,
  6991. a.doctor_id,
  6992. a.doctor_name
  6993. FROM
  6994. med_behospital_info a,
  6995. med_qcresult_info b,
  6996. med_qcresult_detail c,
  6997. qc_cases_entry d,
  6998. sys_user_dept e
  6999. WHERE
  7000. a.is_deleted = 'N'
  7001. AND b.is_deleted = 'N'
  7002. AND c.is_deleted = 'N'
  7003. AND d.is_deleted = 'N'
  7004. AND e.is_deleted = 'N'
  7005. AND a.hospital_id = b.hospital_id
  7006. AND a.hospital_id = c.hospital_id
  7007. AND a.hospital_id = e.hospital_id
  7008. AND a.behospital_code = b.behospital_code
  7009. AND a.behospital_code = c.behospital_code
  7010. AND c.cases_id = d.cases_id
  7011. AND c.cases_entry_id = d.id
  7012. AND a.beh_dept_id = e.dept_id
  7013. AND TIMESTAMPDIFF(
  7014. DAY,
  7015. DATE( behospital_date ),
  7016. DATE( leave_hospital_date ))> 31
  7017. <if test="userId!=null">
  7018. AND e.user_id = #{userId}
  7019. </if>
  7020. <if test="isPlacefile != null and isPlacefile != ''">
  7021. and a.is_placefile = #{isPlacefile}
  7022. </if>
  7023. AND a.qc_type_id != 0
  7024. <if test="hospitalId != null and hospitalId != ''">
  7025. AND a.hospital_id = #{hospitalId}
  7026. </if>
  7027. <if test="isPlacefile != null and isPlacefile == 0">
  7028. <if test="startDate != null ">
  7029. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7030. </if>
  7031. <if test="endDate != null ">
  7032. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7033. </if>
  7034. </if>
  7035. <if test="isPlacefile != null and isPlacefile == 1">
  7036. <if test="startDate != null ">
  7037. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7038. </if>
  7039. <if test="endDate != null ">
  7040. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7041. </if>
  7042. </if>
  7043. <if test="doctorName != null and doctorName != ''">
  7044. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  7045. </if>
  7046. <if test="deptName != null and deptName != ''">
  7047. AND a.beh_dept_name = #{deptName}
  7048. </if>
  7049. ) b
  7050. GROUP BY
  7051. b.doctor_id,
  7052. b.doctor_name
  7053. )
  7054. ) tt
  7055. GROUP BY
  7056. tt.doctorName
  7057. ) t
  7058. <if test="asc != null and asc !=''">
  7059. order by
  7060. <choose>
  7061. <when test='asc=="deptId"'>deptId asc</when>
  7062. <when test='asc=="deptName"'>deptName asc</when>
  7063. <when test='asc=="doctorName"'>doctorName asc</when>
  7064. <when test='asc=="consultationNum"'>consultationNum asc</when>
  7065. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  7066. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  7067. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  7068. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  7069. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  7070. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  7071. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  7072. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  7073. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  7074. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  7075. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  7076. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  7077. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  7078. <when test='asc=="crisisNum"'>crisisNum asc</when>
  7079. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  7080. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  7081. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  7082. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  7083. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  7084. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  7085. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  7086. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  7087. <otherwise>doctorName asc</otherwise>
  7088. </choose>
  7089. </if>
  7090. <if test="desc != null and desc!=''">
  7091. order by
  7092. <choose>
  7093. <when test='desc=="deptId"'>deptId desc</when>
  7094. <when test='desc=="doctorName"'>doctorName desc</when>
  7095. <when test='desc=="deptName"'>deptName desc</when>
  7096. <when test='desc=="consultationNum"'>consultationNum desc</when>
  7097. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  7098. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  7099. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  7100. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  7101. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  7102. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  7103. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  7104. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  7105. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  7106. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  7107. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  7108. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  7109. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  7110. <when test='desc=="crisisNum"'>crisisNum desc</when>
  7111. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  7112. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  7113. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  7114. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  7115. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  7116. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  7117. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  7118. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  7119. <otherwise>doctorName desc</otherwise>
  7120. </choose>
  7121. </if>
  7122. </select>
  7123. <!-- 非医嘱离院病人记录-->
  7124. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  7125. SELECT
  7126. count(*)
  7127. FROM
  7128. med_behospital_info a,
  7129. med_home_page b
  7130. WHERE
  7131. a.is_deleted = 'N'
  7132. AND b.is_deleted = 'N'
  7133. AND a.hospital_id = b.hospital_id
  7134. AND a.behospital_code = b.behospital_code
  7135. AND b.leave_hospital_type = '非医嘱离院'
  7136. <if test="isPlacefile != null and isPlacefile != ''">
  7137. and a.is_placefile = #{isPlacefile}
  7138. </if>
  7139. AND a.qc_type_id != 0
  7140. <if test="hospitalId != null and hospitalId != ''">
  7141. AND a.hospital_id = #{hospitalId}
  7142. </if>
  7143. <if test="isPlacefile != null and isPlacefile == 0">
  7144. <if test="startDate != null and startDate != ''">
  7145. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7146. </if>
  7147. <if test="endDate != null and endDate != ''">
  7148. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7149. </if>
  7150. </if>
  7151. <if test="isPlacefile != null and isPlacefile == 1">
  7152. <if test="startDate != null and startDate != ''">
  7153. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7154. </if>
  7155. <if test="endDate != null and endDate != ''">
  7156. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7157. </if>
  7158. </if>
  7159. </select>
  7160. <!-- 31天内再入院记录-->
  7161. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  7162. SELECT
  7163. count(*)
  7164. FROM
  7165. (
  7166. SELECT
  7167. r1.file_code,
  7168. r1.diagnose,
  7169. r1.behospital_code AS behospitalCode,
  7170. r1.behospital_date AS behospitalDate,
  7171. r1.leave_hospital_date AS leaveHospitalDate,
  7172. r2.behospital_code AS lastBehospitalCode,
  7173. r2.behospital_date AS lastBehospitalDate,
  7174. r2.leave_hospital_date AS lastLeaveHospitalDate,
  7175. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  7176. FROM
  7177. (
  7178. SELECT
  7179. ( @rownum := @rownum + 1 ) AS rownum,
  7180. t1.file_code,
  7181. t1.diagnose,
  7182. t1.behospital_code,
  7183. t1.behospital_date,
  7184. t1.leave_hospital_date
  7185. FROM
  7186. (
  7187. SELECT
  7188. tt1.file_code,
  7189. tt1.diagnose,
  7190. tt2.behospital_code,
  7191. tt2.behospital_date,
  7192. tt2.leave_hospital_date
  7193. FROM
  7194. (
  7195. SELECT
  7196. a.file_code,
  7197. a.diagnose
  7198. FROM
  7199. med_behospital_info a
  7200. WHERE
  7201. a.is_deleted = 'N'
  7202. <if test="isPlacefile != null and isPlacefile != ''">
  7203. and a.is_placefile = #{isPlacefile}
  7204. </if>
  7205. AND a.qc_type_id != 0
  7206. AND IFNULL( a.diagnose, '' )!= ''
  7207. AND IFNULL( a.file_code, '' )!= ''
  7208. <if test="hospitalId != null and hospitalId != ''">
  7209. AND a.hospital_id = #{hospitalId}
  7210. </if>
  7211. <if test="isPlacefile != null and isPlacefile == 0">
  7212. <if test="startDate != null and startDate != ''">
  7213. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7214. </if>
  7215. <if test="endDate != null and endDate != ''">
  7216. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7217. </if>
  7218. </if>
  7219. <if test="isPlacefile != null and isPlacefile == 1">
  7220. <if test="startDate != null and startDate != ''">
  7221. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7222. </if>
  7223. <if test="endDate != null and endDate != ''">
  7224. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7225. </if>
  7226. </if>
  7227. GROUP BY
  7228. a.file_code,
  7229. a.diagnose
  7230. HAVING
  7231. count(*)> 1
  7232. ) tt1,
  7233. med_behospital_info tt2
  7234. WHERE
  7235. tt2.is_deleted = 'N'
  7236. <if test="isPlacefile != null and isPlacefile != ''">
  7237. and tt2.is_placefile = #{isPlacefile}
  7238. </if>
  7239. AND tt2.qc_type_id != 0
  7240. AND tt1.file_code = tt2.file_code
  7241. AND tt1.diagnose = tt2.diagnose
  7242. <if test="hospitalId != null and hospitalId != ''">
  7243. AND tt2.hospital_id = #{hospitalId}
  7244. </if>
  7245. <if test="isPlacefile != null and isPlacefile == 0">
  7246. <if test="startDate != null and startDate != ''">
  7247. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7248. </if>
  7249. <if test="endDate != null and endDate != ''">
  7250. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7251. </if>
  7252. </if>
  7253. <if test="isPlacefile != null and isPlacefile == 1">
  7254. <if test="startDate != null and startDate != ''">
  7255. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7256. </if>
  7257. <if test="endDate != null and endDate != ''">
  7258. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7259. </if>
  7260. </if>
  7261. ORDER BY
  7262. tt1.file_code,
  7263. tt1.diagnose,
  7264. tt2.behospital_date DESC
  7265. ) t1,
  7266. ( SELECT @rownum := 0 ) r
  7267. ) r1
  7268. LEFT JOIN (
  7269. SELECT
  7270. ( @INDEX := @INDEX + 1 ) AS rownum,
  7271. t2.file_code,
  7272. t2.diagnose,
  7273. t2.behospital_code,
  7274. t2.behospital_date,
  7275. t2.leave_hospital_date
  7276. FROM
  7277. (
  7278. SELECT
  7279. tt1.file_code,
  7280. tt1.diagnose,
  7281. tt2.behospital_code,
  7282. tt2.behospital_date,
  7283. tt2.leave_hospital_date
  7284. FROM
  7285. (
  7286. SELECT
  7287. a.file_code,
  7288. a.diagnose
  7289. FROM
  7290. med_behospital_info a
  7291. WHERE
  7292. a.is_deleted = 'N'
  7293. <if test="isPlacefile != null and isPlacefile != ''">
  7294. and a.is_placefile = #{isPlacefile}
  7295. </if>
  7296. AND a.qc_type_id != 0
  7297. AND IFNULL( a.diagnose, '' )!= ''
  7298. AND IFNULL( a.file_code, '' )!= ''
  7299. <if test="hospitalId != null and hospitalId != ''">
  7300. AND a.hospital_id = #{hospitalId}
  7301. </if>
  7302. <if test="isPlacefile != null and isPlacefile == 0">
  7303. <if test="startDate != null and startDate != ''">
  7304. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7305. </if>
  7306. <if test="endDate != null and endDate != ''">
  7307. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7308. </if>
  7309. </if>
  7310. <if test="isPlacefile != null and isPlacefile == 1">
  7311. <if test="startDate != null and startDate != ''">
  7312. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7313. </if>
  7314. <if test="endDate != null and endDate != ''">
  7315. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7316. </if>
  7317. </if>
  7318. GROUP BY
  7319. a.file_code,
  7320. a.diagnose
  7321. HAVING
  7322. count(*)> 1
  7323. ) tt1,
  7324. med_behospital_info tt2
  7325. WHERE
  7326. tt2.is_deleted = 'N'
  7327. <if test="isPlacefile != null and isPlacefile != ''">
  7328. and tt2.is_placefile = #{isPlacefile}
  7329. </if>
  7330. AND tt2.qc_type_id != 0
  7331. AND tt1.file_code = tt2.file_code
  7332. AND tt1.diagnose = tt2.diagnose
  7333. <if test="hospitalId != null and hospitalId != ''">
  7334. AND tt2.hospital_id = #{hospitalId}
  7335. </if>
  7336. <if test="isPlacefile != null and isPlacefile == 0">
  7337. <if test="startDate != null and startDate != ''">
  7338. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  7339. </if>
  7340. <if test="endDate != null and endDate != ''">
  7341. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  7342. </if>
  7343. </if>
  7344. <if test="isPlacefile != null and isPlacefile == 1">
  7345. <if test="startDate != null and startDate != ''">
  7346. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  7347. </if>
  7348. <if test="endDate != null and endDate != ''">
  7349. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  7350. </if>
  7351. </if>
  7352. ORDER BY
  7353. tt1.file_code,
  7354. tt1.diagnose,
  7355. tt2.behospital_date DESC
  7356. ) t2,(
  7357. SELECT
  7358. @INDEX := 0
  7359. ) r
  7360. ) r2 ON r1.file_code = r2.file_code
  7361. AND r1.rownum = r2.rownum - 1
  7362. ) t
  7363. WHERE
  7364. t.diffDays IS NOT NULL
  7365. AND t.diffDays BETWEEN 0
  7366. AND 31
  7367. </select>
  7368. <!-- 病案首页质控病历数统计-全院(首页)-->
  7369. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  7370. SELECT
  7371. count( * ) AS mrNum,
  7372. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  7373. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  7374. SUM( c.`level` = '合格' ) AS firstLevelNum,
  7375. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  7376. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  7377. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  7378. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  7379. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  7380. FROM
  7381. med_behospital_info a,
  7382. med_qcresult_cases c
  7383. WHERE
  7384. a.is_deleted = 'N'
  7385. AND c.is_deleted = 'N'
  7386. AND a.hospital_id = c.hospital_id
  7387. AND a.behospital_code = c.behospital_code
  7388. AND c.cases_id = 243
  7389. <if test="isPlacefile != null and isPlacefile != ''">
  7390. and a.is_placefile = #{isPlacefile}
  7391. </if>
  7392. AND a.qc_type_id != 0
  7393. <if test="hospitalId != null and hospitalId != ''">
  7394. AND a.hospital_id = #{hospitalId}
  7395. </if>
  7396. <if test="isPlacefile != null and isPlacefile == 0">
  7397. <if test="startDate != null and startDate != ''">
  7398. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7399. </if>
  7400. <if test="endDate != null and endDate != ''">
  7401. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7402. </if>
  7403. </if>
  7404. <if test="isPlacefile != null and isPlacefile == 1">
  7405. <if test="startDate != null and startDate != ''">
  7406. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7407. </if>
  7408. <if test="endDate != null and endDate != ''">
  7409. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7410. </if>
  7411. </if>
  7412. </select>
  7413. <!-- 病案首页完整率统计-全院(首页)-->
  7414. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  7415. SELECT
  7416. h1.emptyNum,
  7417. h1.mrNum,
  7418. h2.entryNum,
  7419. h1.mrNum * h2.entryNum AS entryTotleNum,
  7420. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  7421. CONCAT(
  7422. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  7423. '%'
  7424. ) AS emptyPercentStr
  7425. FROM
  7426. (
  7427. SELECT
  7428. sum( d.rule_type = 1 ) AS emptyNum,
  7429. count( DISTINCT a.behospital_code ) AS mrNum
  7430. FROM
  7431. med_behospital_info a,
  7432. med_qcresult_cases b,
  7433. med_qcresult_detail c,
  7434. qc_cases_entry d
  7435. WHERE
  7436. a.is_deleted = 'N'
  7437. AND b.is_deleted = 'N'
  7438. AND c.is_deleted = 'N'
  7439. AND d.is_deleted = 'N'
  7440. AND a.hospital_id = b.hospital_id
  7441. AND a.hospital_id = c.hospital_id
  7442. AND a.behospital_code = b.behospital_code
  7443. AND a.behospital_code = c.behospital_code
  7444. AND b.cases_id = c.cases_id
  7445. AND c.cases_id = d.cases_id
  7446. AND c.cases_entry_id = d.id
  7447. <if test="isPlacefile != null and isPlacefile != ''">
  7448. and a.is_placefile = #{isPlacefile}
  7449. </if>
  7450. AND d.cases_id = 243
  7451. AND a.qc_type_id != 0
  7452. <if test="hospitalId != null and hospitalId != ''">
  7453. AND a.hospital_id = #{hospitalId}
  7454. </if>
  7455. <if test="isPlacefile != null and isPlacefile == 0">
  7456. <if test="startDate != null and startDate != ''">
  7457. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7458. </if>
  7459. <if test="endDate != null and endDate != ''">
  7460. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7461. </if>
  7462. </if>
  7463. <if test="isPlacefile != null and isPlacefile == 1">
  7464. <if test="startDate != null and startDate != ''">
  7465. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7466. </if>
  7467. <if test="endDate != null and endDate != ''">
  7468. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7469. </if>
  7470. </if>
  7471. ) h1,(
  7472. SELECT
  7473. count(*) AS entryNum
  7474. FROM
  7475. qc_cases_entry
  7476. WHERE
  7477. is_deleted = 'N'
  7478. AND cases_id = 243
  7479. ) h2
  7480. </select>
  7481. <!-- 离院病人评分详情页-->
  7482. <select id="getAge" resultType="java.util.Map">
  7483. SELECT
  7484. a.behospital_code as behospitalCode,
  7485. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  7486. FROM
  7487. med_home_page a
  7488. WHERE
  7489. a.is_deleted = 'N'
  7490. AND a.hospital_id = #{hospitalId}
  7491. AND a.behospital_code IN
  7492. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  7493. '${item}'
  7494. </foreach>
  7495. </select>
  7496. <!-- 离院病人评分详情页-->
  7497. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7498. SELECT
  7499. t.*
  7500. FROM
  7501. (SELECT DISTINCT
  7502. t1.hospital_id AS hospitalId,
  7503. t1.behospital_code AS behospitalCode,
  7504. t1.bed_code AS bedCode,
  7505. t1.LEVEL AS LEVEL,
  7506. t1.grade_type AS gradeType,
  7507. t1.score_res AS scoreRes,
  7508. t1.scoreBn,
  7509. t1.NAME AS NAME,
  7510. t1.sex AS sex,
  7511. t1.beh_dept_id AS behDeptId,
  7512. t1.beh_dept_name AS behDeptName,
  7513. t1.doctor_id AS doctorId,
  7514. t1.doctor_name AS doctorName,
  7515. t1.beh_doctor_id AS behDoctorId,
  7516. t1.beh_doctor_name AS behDoctorName,
  7517. t1.director_doctor_id AS directorDoctorId,
  7518. t1.director_doctor_name AS directorDoctorName,
  7519. t1.birthday AS birthday,
  7520. t1.behospital_date AS behospitalDate,
  7521. t1.leave_hospital_date AS leaveHospitalDate,
  7522. t1.placefile_date AS placefileDate,
  7523. t1.gmt_create AS gradeTime,
  7524. t1.diagnose,
  7525. t1.ward_name AS wardName,
  7526. t1.checkStatus,
  7527. t1.mrStatus,
  7528. t1.chName,
  7529. t1.mrName,
  7530. t1.chTime,
  7531. t1.mrTime,
  7532. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7533. t1.file_code AS fileCode
  7534. FROM
  7535. (
  7536. SELECT be.*,
  7537. ifnull(mci.status,0) AS checkStatus,
  7538. ifnull(hm_mci.status,0) AS mrStatus,
  7539. mci.check_name as chName,
  7540. e.score_res as scoreBn,
  7541. hm_mci.check_name as mrName,
  7542. mci.gmt_create as chTime,
  7543. hm_mci.gmt_create as mrTime
  7544. FROM
  7545. (
  7546. SELECT DISTINCT
  7547. tt1.*
  7548. FROM
  7549. (
  7550. SELECT
  7551. b.*,
  7552. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7553. c.grade_type,
  7554. c.score_res,
  7555. c.gmt_create
  7556. FROM
  7557. (
  7558. SELECT DISTINCT
  7559. a.hospital_id,
  7560. a.behospital_code,
  7561. a.bed_code,
  7562. a.NAME,
  7563. a.sex,
  7564. a.beh_dept_id,
  7565. a.beh_dept_name,
  7566. a.birthday,
  7567. a.behospital_date,
  7568. a.leave_hospital_date,
  7569. a.doctor_id,
  7570. a.doctor_name,
  7571. a.beh_doctor_id,
  7572. a.beh_doctor_name,
  7573. a.director_doctor_id,
  7574. a.director_doctor_name,
  7575. a.diagnose,
  7576. a.placefile_date,
  7577. a.ward_name,
  7578. a.file_code
  7579. FROM
  7580. med_behospital_info a
  7581. WHERE
  7582. a.is_deleted = 'N'
  7583. AND a.qc_type_id != 0
  7584. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7585. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7586. </if>
  7587. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7588. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7589. </if>
  7590. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7591. <if test="qcResultShortPageVO.startDate != null ">
  7592. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7593. </if>
  7594. <if test="qcResultShortPageVO.endDate != null ">
  7595. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7596. </if>
  7597. </if>
  7598. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7599. <if test="qcResultShortPageVO.startDate != null ">
  7600. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7601. </if>
  7602. <if test="qcResultShortPageVO.endDate != null">
  7603. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7604. </if>
  7605. </if>
  7606. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7607. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7608. </if>
  7609. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7610. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7611. </if>
  7612. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7613. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7614. </if>
  7615. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7616. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7617. </if>
  7618. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7619. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7620. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7621. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7622. </if>
  7623. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7624. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7625. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7626. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7627. </if>
  7628. ) b
  7629. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7630. AND b.hospital_id = c.hospital_id
  7631. AND b.behospital_code = c.behospital_code
  7632. ) tt1
  7633. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7634. ,med_medical_record tt2,
  7635. qc_mode tt3
  7636. WHERE
  7637. tt2.is_deleted = 'N'
  7638. AND tt3.is_deleted = 'N'
  7639. AND tt1.hospital_id = tt2.hospital_id
  7640. AND tt1.behospital_code = tt2.behospital_code
  7641. AND tt2.mode_id = tt3.id
  7642. AND tt3.`name` = '手术记录'
  7643. </if>
  7644. ) be
  7645. left join med_check_info mci
  7646. on mci.is_deleted = 'N'
  7647. and mci.check_type = 0
  7648. and be.hospital_id = mci.hospital_id
  7649. and be.behospital_code = mci.behospital_code
  7650. left join med_check_info hm_mci
  7651. on hm_mci.is_deleted = 'N'
  7652. and hm_mci.check_type = 1
  7653. and be.hospital_id = hm_mci.hospital_id
  7654. and be.behospital_code = hm_mci.behospital_code
  7655. LEFT JOIN med_qcresult_cases e
  7656. on be.behospital_code = e.behospital_code
  7657. and be.hospital_id = e.hospital_id
  7658. AND e.is_deleted = 'N'
  7659. and e.cases_id = 243
  7660. )t1
  7661. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7662. ,med_home_page t2
  7663. WHERE
  7664. t2.is_deleted = 'N'
  7665. AND t1.hospital_id = t2.hospital_id
  7666. AND t1.behospital_code = t2.behospital_code
  7667. AND (
  7668. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7669. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7670. )
  7671. </if>
  7672. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7673. , med_medical_record b,
  7674. med_medical_record_content c,
  7675. med_home_page t2
  7676. WHERE
  7677. b.is_deleted = 'N'
  7678. and c.is_deleted = 'N'
  7679. and t2.is_deleted = 'N'
  7680. and t1.hospital_id = b.hospital_id
  7681. and t1.hospital_id = c.hospital_id
  7682. and t1.hospital_id = t2.hospital_id
  7683. AND t1.behospital_code = b.behospital_code
  7684. AND t1.behospital_code = t2.behospital_code
  7685. AND b.rec_id = c.rec_id
  7686. and b.mode_id = '24'
  7687. </if>
  7688. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7689. ,med_home_page t2
  7690. WHERE
  7691. t2.is_deleted = 'N'
  7692. AND t1.hospital_id = t2.hospital_id
  7693. AND t1.behospital_code = t2.behospital_code
  7694. AND t2.leave_hospital_type = '非医嘱离院'
  7695. </if>
  7696. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7697. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7698. AND t1.hospital_id = t2.hospital_id
  7699. AND t1.behospital_code = t2.behospital_code
  7700. </if>
  7701. )t
  7702. where 1=1
  7703. <if test="qcResultShortPageVO.checkStatus != null">
  7704. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7705. </if>
  7706. <if test="qcResultShortPageVO.mrStatus != null">
  7707. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7708. </if>
  7709. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7710. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7711. </if>
  7712. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7713. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7714. </if>
  7715. <if test="qcResultShortPageVO.chTimeStart != null ">
  7716. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7717. </if>
  7718. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7719. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7720. </if>
  7721. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7722. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7723. </if>
  7724. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7725. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7726. </if>
  7727. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7728. AND t.`level` = #{qcResultShortPageVO.level}
  7729. </if>
  7730. </select>
  7731. <!-- 离院病人评分详情页-科室-->
  7732. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  7733. SELECT
  7734. t.*
  7735. FROM
  7736. (SELECT DISTINCT
  7737. t1.hospital_id AS hospitalId,
  7738. t1.behospital_code AS behospitalCode,
  7739. t1.bed_code AS bedCode,
  7740. t1.LEVEL AS LEVEL,
  7741. t1.grade_type AS gradeType,
  7742. t1.score_res AS scoreRes,
  7743. t1.scoreBn,
  7744. t1.NAME AS NAME,
  7745. t1.sex AS sex,
  7746. t1.beh_dept_id AS behDeptId,
  7747. t1.beh_dept_name AS behDeptName,
  7748. t1.doctor_id AS doctorId,
  7749. t1.doctor_name AS doctorName,
  7750. t1.beh_doctor_id AS behDoctorId,
  7751. t1.beh_doctor_name AS behDoctorName,
  7752. t1.director_doctor_id AS directorDoctorId,
  7753. t1.director_doctor_name AS directorDoctorName,
  7754. t1.birthday AS birthday,
  7755. t1.behospital_date AS behospitalDate,
  7756. t1.leave_hospital_date AS leaveHospitalDate,
  7757. t1.placefile_date AS placefileDate,
  7758. t1.gmt_create AS gradeTime,
  7759. t1.diagnose,
  7760. t1.medoupName,
  7761. t1.ward_name AS wardName,
  7762. t1.checkStatus,
  7763. t1.mrStatus,
  7764. t1.chName,
  7765. t1.mrName,
  7766. t1.chTime,
  7767. t1.mrTime,
  7768. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7769. t1.file_code AS fileCode
  7770. FROM
  7771. (
  7772. SELECT be.*,
  7773. t3.name as medoupName,
  7774. ifnull(mci.status,0) AS checkStatus,
  7775. ifnull(hm_mci.status,0) AS mrStatus,
  7776. mci.check_name as chName,
  7777. e.score_res as scoreBn,
  7778. hm_mci.check_name as mrName,
  7779. mci.gmt_create as chTime,
  7780. hm_mci.gmt_create as mrTime
  7781. FROM
  7782. (
  7783. SELECT DISTINCT
  7784. tt1.*
  7785. FROM
  7786. (
  7787. SELECT
  7788. b.*,
  7789. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7790. c.grade_type,
  7791. c.score_res,
  7792. c.gmt_create
  7793. FROM
  7794. (
  7795. SELECT DISTINCT
  7796. a.hospital_id,
  7797. a.behospital_code,
  7798. a.bed_code,
  7799. a.NAME,
  7800. a.sex,
  7801. a.beh_dept_id,
  7802. a.beh_dept_name,
  7803. a.birthday,
  7804. a.behospital_date,
  7805. a.leave_hospital_date,
  7806. a.doctor_id,
  7807. a.doctor_name,
  7808. a.beh_doctor_id,
  7809. a.beh_doctor_name,
  7810. a.director_doctor_id,
  7811. a.director_doctor_name,
  7812. a.diagnose,
  7813. a.placefile_date,
  7814. a.ward_name,
  7815. a.file_code
  7816. FROM
  7817. med_behospital_info a,
  7818. sys_user_dept b
  7819. WHERE
  7820. a.is_deleted = 'N'
  7821. AND b.is_deleted = 'N'
  7822. AND a.hospital_id = b.hospital_id
  7823. AND a.beh_dept_id = b.dept_id
  7824. AND a.qc_type_id != 0
  7825. <if test="qcResultShortPageVO.userId!=null">
  7826. AND b.user_id = #{qcResultShortPageVO.userId}
  7827. </if>
  7828. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7829. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7830. </if>
  7831. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7832. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7833. </if>
  7834. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7835. <if test="qcResultShortPageVO.startDate != null ">
  7836. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7837. </if>
  7838. <if test="qcResultShortPageVO.endDate != null ">
  7839. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7840. </if>
  7841. </if>
  7842. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7843. <if test="qcResultShortPageVO.startDate != null ">
  7844. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7845. </if>
  7846. <if test="qcResultShortPageVO.endDate != null">
  7847. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7848. </if>
  7849. </if>
  7850. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7851. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7852. </if>
  7853. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  7854. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  7855. </if>
  7856. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7857. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7858. </if>
  7859. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  7860. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  7861. </if>
  7862. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7863. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7864. </if>
  7865. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7866. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7867. </if>
  7868. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7869. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  7870. </if>
  7871. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7872. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  7873. </if>
  7874. ) b
  7875. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7876. AND b.hospital_id = c.hospital_id
  7877. AND b.behospital_code = c.behospital_code
  7878. ) tt1
  7879. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7880. ,med_medical_record tt2,
  7881. qc_mode tt3
  7882. WHERE
  7883. tt2.is_deleted = 'N'
  7884. AND tt3.is_deleted = 'N'
  7885. AND tt1.hospital_id = tt2.hospital_id
  7886. AND tt1.behospital_code = tt2.behospital_code
  7887. AND tt2.mode_id = tt3.id
  7888. AND tt3.`name` = '手术记录'
  7889. </if>
  7890. ) be
  7891. left join med_check_info mci
  7892. on mci.is_deleted = 'N'
  7893. and mci.check_type = 0
  7894. and be.hospital_id = mci.hospital_id
  7895. and be.behospital_code = mci.behospital_code
  7896. left join med_check_info hm_mci
  7897. on hm_mci.is_deleted = 'N'
  7898. and hm_mci.check_type = 1
  7899. and be.hospital_id = hm_mci.hospital_id
  7900. and be.behospital_code = hm_mci.behospital_code
  7901. LEFT JOIN med_qcresult_cases e
  7902. on be.behospital_code = e.behospital_code
  7903. and be.hospital_id = e.hospital_id
  7904. AND e.is_deleted = 'N'
  7905. and e.cases_id = 243
  7906. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  7907. and be.hospital_id = t2.hospital_id
  7908. AND t2.is_deleted = 'N'
  7909. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  7910. AND t3.is_deleted = 'N'
  7911. )t1
  7912. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7913. ,med_home_page t2
  7914. WHERE
  7915. t2.is_deleted = 'N'
  7916. AND t1.hospital_id = t2.hospital_id
  7917. AND t1.behospital_code = t2.behospital_code
  7918. AND (
  7919. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7920. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7921. )
  7922. </if>
  7923. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7924. , med_medical_record b,
  7925. med_medical_record_content c,
  7926. med_home_page t2
  7927. WHERE
  7928. b.is_deleted = 'N'
  7929. and c.is_deleted = 'N'
  7930. and t2.is_deleted = 'N'
  7931. and t1.hospital_id = b.hospital_id
  7932. and t1.hospital_id = c.hospital_id
  7933. and t1.hospital_id = t2.hospital_id
  7934. AND t1.behospital_code = b.behospital_code
  7935. AND t1.behospital_code = t2.behospital_code
  7936. AND b.rec_id = c.rec_id
  7937. and b.mode_id = '24'
  7938. </if>
  7939. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7940. ,med_home_page t2
  7941. WHERE
  7942. t2.is_deleted = 'N'
  7943. AND t1.hospital_id = t2.hospital_id
  7944. AND t1.behospital_code = t2.behospital_code
  7945. AND t2.leave_hospital_type = '非医嘱离院'
  7946. </if>
  7947. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7948. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7949. AND t1.hospital_id = t2.hospital_id
  7950. AND t1.behospital_code = t2.behospital_code
  7951. </if>
  7952. )t
  7953. where 1=1
  7954. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  7955. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  7956. </if>
  7957. <if test="qcResultShortPageVO.checkStatus != null">
  7958. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7959. </if>
  7960. <if test="qcResultShortPageVO.mrStatus != null">
  7961. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7962. </if>
  7963. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7964. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7965. </if>
  7966. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7967. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7968. </if>
  7969. <if test="qcResultShortPageVO.chTimeStart != null ">
  7970. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7971. </if>
  7972. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7973. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7974. </if>
  7975. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7976. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7977. </if>
  7978. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7979. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7980. </if>
  7981. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7982. AND t.`level` = #{qcResultShortPageVO.level}
  7983. </if>
  7984. </select>
  7985. <!-- 病案首页改善率统计(首页)-->
  7986. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7987. SELECT
  7988. t2.homePageMRNum,
  7989. t1.improveNum,
  7990. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  7991. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7992. t1.improveToPassNum,
  7993. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  7994. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7995. t1.improveToFullNum,
  7996. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  7997. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7998. FROM
  7999. (
  8000. SELECT
  8001. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8002. sum( d.score_res = 20 ) AS improveToFullNum,
  8003. count(*) AS improveNum
  8004. FROM
  8005. med_behospital_info a,
  8006. med_home_page b,
  8007. med_qcresult_info c,
  8008. med_qcresult_cases d,
  8009. (
  8010. SELECT
  8011. m4.*
  8012. FROM
  8013. med_behospital_info m1,
  8014. med_home_page m2,
  8015. med_qcresult_info m3,
  8016. med_qcresult_cases m4
  8017. WHERE
  8018. m1.is_deleted = 'N'
  8019. AND m2.is_deleted = 'N'
  8020. AND m3.is_deleted = 'Y'
  8021. AND m4.is_deleted = 'Y'
  8022. AND m1.hospital_id = m2.hospital_id
  8023. AND m1.hospital_id = m3.hospital_id
  8024. AND m1.hospital_id = m4.hospital_id
  8025. AND m1.behospital_code = m2.behospital_code
  8026. AND m1.behospital_code = m3.behospital_code
  8027. AND m1.behospital_code = m4.behospital_code
  8028. AND m3.gmt_create = m4.gmt_create
  8029. AND m3.have_home_page = 1
  8030. AND m4.cases_id = 243
  8031. <if test="isPlacefile != null and isPlacefile != ''">
  8032. and m1.is_placefile = #{isPlacefile}
  8033. </if>
  8034. AND m1.qc_type_id != 0
  8035. <if test="hospitalId != null and hospitalId != ''">
  8036. AND m1.hospital_id = #{hospitalId}
  8037. </if>
  8038. <if test="isPlacefile != null and isPlacefile == 0">
  8039. <if test="startDate != null and startDate != ''">
  8040. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8041. </if>
  8042. <if test="endDate != null and endDate != ''">
  8043. <![CDATA[ AND m1.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 m1.leave_hospital_date >= #{startDate}]]>
  8049. </if>
  8050. <if test="endDate != null and endDate != ''">
  8051. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8052. </if>
  8053. </if>
  8054. GROUP BY
  8055. m1.behospital_code
  8056. ORDER BY
  8057. m1.behospital_code,
  8058. m4.gmt_create
  8059. ) e
  8060. WHERE
  8061. a.is_deleted = 'N'
  8062. AND b.is_deleted = 'N'
  8063. AND c.is_deleted = 'N'
  8064. AND d.is_deleted = 'N'
  8065. AND a.hospital_id = b.hospital_id
  8066. AND a.hospital_id = c.hospital_id
  8067. AND a.hospital_id = d.hospital_id
  8068. AND a.hospital_id = e.hospital_id
  8069. AND a.behospital_code = b.behospital_code
  8070. AND a.behospital_code = c.behospital_code
  8071. AND a.behospital_code = d.behospital_code
  8072. AND a.behospital_code = e.behospital_code
  8073. AND d.cases_id = 243
  8074. AND d.score_res > e.score_res
  8075. <if test="isPlacefile != null and isPlacefile != ''">
  8076. and a.is_placefile = #{isPlacefile}
  8077. </if>
  8078. AND a.qc_type_id != 0
  8079. <if test="hospitalId != null and hospitalId != ''">
  8080. AND a.hospital_id = #{hospitalId}
  8081. </if>
  8082. <if test="isPlacefile != null and isPlacefile == 0">
  8083. <if test="startDate != null and startDate != ''">
  8084. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8085. </if>
  8086. <if test="endDate != null and endDate != ''">
  8087. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8088. </if>
  8089. </if>
  8090. <if test="isPlacefile != null and isPlacefile == 1">
  8091. <if test="startDate != null and startDate != ''">
  8092. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8093. </if>
  8094. <if test="endDate != null and endDate != ''">
  8095. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8096. </if>
  8097. </if>
  8098. ) t1,
  8099. (
  8100. SELECT
  8101. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8102. FROM
  8103. med_behospital_info a,
  8104. med_home_page b,
  8105. med_qcresult_info c
  8106. WHERE
  8107. a.is_deleted = 'N'
  8108. AND b.is_deleted = 'N'
  8109. AND a.hospital_id = b.hospital_id
  8110. AND a.hospital_id = c.hospital_id
  8111. AND a.behospital_code = b.behospital_code
  8112. AND a.behospital_code = c.behospital_code
  8113. AND a.qc_type_id != 0
  8114. <if test="isPlacefile != null and isPlacefile != ''">
  8115. and a.is_placefile = #{isPlacefile}
  8116. </if>
  8117. <if test="hospitalId != null and hospitalId != ''">
  8118. AND a.hospital_id = #{hospitalId}
  8119. </if>
  8120. <if test="isPlacefile != null and isPlacefile == 0">
  8121. <if test="startDate != null and startDate != ''">
  8122. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8123. </if>
  8124. <if test="endDate != null and endDate != ''">
  8125. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8126. </if>
  8127. </if>
  8128. <if test="isPlacefile != null and isPlacefile == 1">
  8129. <if test="startDate != null and startDate != ''">
  8130. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8131. </if>
  8132. <if test="endDate != null and endDate != ''">
  8133. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8134. </if>
  8135. </if>
  8136. ) t2
  8137. </select>
  8138. <!-- 质控核查统计(内页)-->
  8139. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  8140. SELECT
  8141. t.*
  8142. FROM
  8143. (SELECT
  8144. mr.beh_dept_id AS deptId,
  8145. mr.beh_dept_name AS deptName,
  8146. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8147. ck.checkedNum AS checkedNum,
  8148. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8149. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8150. hmmr_t.homePageMRNum,
  8151. improve_t.improveNum,
  8152. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8153. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8154. improve_t.improveToPassNum,
  8155. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8156. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8157. improve_t.improveToFullNum,
  8158. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8159. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8160. FROM
  8161. (
  8162. SELECT
  8163. a.beh_dept_id,
  8164. a.beh_dept_name,
  8165. count(*) AS mrNum
  8166. FROM
  8167. med_behospital_info a,
  8168. med_qcresult_info b
  8169. WHERE
  8170. a.is_deleted = 'N'
  8171. AND b.is_deleted = 'N'
  8172. AND a.hospital_id = b.hospital_id
  8173. AND a.behospital_code = b.behospital_code
  8174. AND a.qc_type_id != 0
  8175. <if test="isPlacefile != null and isPlacefile != ''">
  8176. and a.is_placefile = #{isPlacefile}
  8177. </if>
  8178. <if test="hospitalId != null and hospitalId != ''">
  8179. AND a.hospital_id = #{hospitalId}
  8180. </if>
  8181. <if test="isPlacefile != null and isPlacefile == 0">
  8182. <if test="startDate != null and startDate != ''">
  8183. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8184. </if>
  8185. <if test="endDate != null and endDate != ''">
  8186. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8187. </if>
  8188. </if>
  8189. <if test="isPlacefile != null and isPlacefile == 1">
  8190. <if test="startDate != null and startDate != ''">
  8191. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8192. </if>
  8193. <if test="endDate != null and endDate != ''">
  8194. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8195. </if>
  8196. </if>
  8197. <if test="deptName != null and deptName != ''">
  8198. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8199. </if>
  8200. GROUP BY
  8201. a.beh_dept_id,
  8202. a.beh_dept_name
  8203. ) mr
  8204. LEFT JOIN (
  8205. SELECT
  8206. a.beh_dept_id,
  8207. a.beh_dept_name,
  8208. count(*) AS checkedNum
  8209. FROM
  8210. med_behospital_info a,
  8211. med_qcresult_info b,
  8212. med_check_info c
  8213. WHERE
  8214. a.is_deleted = 'N'
  8215. AND b.is_deleted = 'N'
  8216. AND c.is_deleted = 'N'
  8217. AND a.hospital_id = b.hospital_id
  8218. AND a.hospital_id = c.hospital_id
  8219. AND a.behospital_code = b.behospital_code
  8220. AND a.behospital_code = c.behospital_code
  8221. AND a.qc_type_id != 0
  8222. AND ifnull(c.`status`,0) = 1
  8223. AND c.check_type in (0,2)
  8224. <if test="isPlacefile != null and isPlacefile != ''">
  8225. and a.is_placefile = #{isPlacefile}
  8226. </if>
  8227. <if test="hospitalId != null and hospitalId != ''">
  8228. AND a.hospital_id = #{hospitalId}
  8229. </if>
  8230. <if test="isPlacefile != null and isPlacefile == 0">
  8231. <if test="startDate != null and startDate != ''">
  8232. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8233. </if>
  8234. <if test="endDate != null and endDate != ''">
  8235. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8236. </if>
  8237. </if>
  8238. <if test="isPlacefile != null and isPlacefile == 1">
  8239. <if test="startDate != null and startDate != ''">
  8240. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8241. </if>
  8242. <if test="endDate != null and endDate != ''">
  8243. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8244. </if>
  8245. </if>
  8246. <if test="deptName != null and deptName != ''">
  8247. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8248. </if>
  8249. GROUP BY
  8250. a.beh_dept_id,
  8251. a.beh_dept_name
  8252. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  8253. AND mr.beh_dept_name = ck.beh_dept_name
  8254. LEFT JOIN (
  8255. SELECT
  8256. a.beh_dept_id,
  8257. a.beh_dept_name,
  8258. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8259. FROM
  8260. med_behospital_info a,
  8261. med_home_page b,
  8262. med_qcresult_info c
  8263. WHERE
  8264. a.is_deleted = 'N'
  8265. AND b.is_deleted = 'N'
  8266. AND a.hospital_id = b.hospital_id
  8267. AND a.hospital_id = c.hospital_id
  8268. AND a.behospital_code = b.behospital_code
  8269. AND a.behospital_code = c.behospital_code
  8270. AND a.qc_type_id != 0
  8271. <if test="isPlacefile != null and isPlacefile != ''">
  8272. and a.is_placefile = #{isPlacefile}
  8273. </if>
  8274. <if test="hospitalId != null and hospitalId != ''">
  8275. AND a.hospital_id = #{hospitalId}
  8276. </if>
  8277. <if test="isPlacefile != null and isPlacefile == 0">
  8278. <if test="startDate != null and startDate != ''">
  8279. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8280. </if>
  8281. <if test="endDate != null and endDate != ''">
  8282. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8283. </if>
  8284. </if>
  8285. <if test="isPlacefile != null and isPlacefile == 1">
  8286. <if test="startDate != null and startDate != ''">
  8287. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8288. </if>
  8289. <if test="endDate != null and endDate != ''">
  8290. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8291. </if>
  8292. </if>
  8293. <if test="deptName != null and deptName != ''">
  8294. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8295. </if>
  8296. GROUP BY
  8297. a.beh_dept_id,
  8298. a.beh_dept_name
  8299. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  8300. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  8301. LEFT JOIN (
  8302. SELECT
  8303. a.beh_dept_id,
  8304. a.beh_dept_name,
  8305. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8306. sum( d.score_res = 20 ) AS improveToFullNum,
  8307. count(*) AS improveNum
  8308. FROM
  8309. med_behospital_info a,
  8310. med_home_page b,
  8311. med_qcresult_info c,
  8312. med_qcresult_cases d,
  8313. (
  8314. SELECT
  8315. m4.*
  8316. FROM
  8317. med_behospital_info m1,
  8318. med_home_page m2,
  8319. med_qcresult_info m3,
  8320. med_qcresult_cases m4
  8321. WHERE
  8322. m1.is_deleted = 'N'
  8323. AND m2.is_deleted = 'N'
  8324. AND m3.is_deleted = 'Y'
  8325. AND m4.is_deleted = 'Y'
  8326. AND m1.hospital_id = m2.hospital_id
  8327. AND m1.hospital_id = m3.hospital_id
  8328. AND m1.hospital_id = m4.hospital_id
  8329. AND m1.behospital_code = m2.behospital_code
  8330. AND m1.behospital_code = m3.behospital_code
  8331. AND m1.behospital_code = m4.behospital_code
  8332. AND m3.gmt_create = m4.gmt_create
  8333. AND m3.have_home_page = 1
  8334. AND m4.cases_id = 243
  8335. <if test="isPlacefile != null and isPlacefile != ''">
  8336. and m1.is_placefile = #{isPlacefile}
  8337. </if>
  8338. AND m1.qc_type_id != 0
  8339. <if test="hospitalId != null and hospitalId != ''">
  8340. AND m1.hospital_id = #{hospitalId}
  8341. </if>
  8342. <if test="isPlacefile != null and isPlacefile == 0">
  8343. <if test="startDate != null and startDate != ''">
  8344. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8345. </if>
  8346. <if test="endDate != null and endDate != ''">
  8347. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8348. </if>
  8349. </if>
  8350. <if test="isPlacefile != null and isPlacefile == 1">
  8351. <if test="startDate != null and startDate != ''">
  8352. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8353. </if>
  8354. <if test="endDate != null and endDate != ''">
  8355. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8356. </if>
  8357. </if>
  8358. <if test="deptName != null and deptName != ''">
  8359. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8360. </if>
  8361. GROUP BY
  8362. m1.behospital_code
  8363. ORDER BY
  8364. m1.behospital_code,
  8365. m4.gmt_create
  8366. ) e
  8367. WHERE
  8368. a.is_deleted = 'N'
  8369. AND b.is_deleted = 'N'
  8370. AND c.is_deleted = 'N'
  8371. AND d.is_deleted = 'N'
  8372. AND a.hospital_id = b.hospital_id
  8373. AND a.hospital_id = c.hospital_id
  8374. AND a.hospital_id = d.hospital_id
  8375. AND a.hospital_id = e.hospital_id
  8376. AND a.behospital_code = b.behospital_code
  8377. AND a.behospital_code = c.behospital_code
  8378. AND a.behospital_code = d.behospital_code
  8379. AND a.behospital_code = e.behospital_code
  8380. AND d.cases_id = 243
  8381. AND d.score_res > e.score_res
  8382. <if test="hospitalId != null and hospitalId != ''">
  8383. AND a.hospital_id = #{hospitalId}
  8384. </if>
  8385. <if test="isPlacefile != null and isPlacefile == 0">
  8386. <if test="startDate != null and startDate != ''">
  8387. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8388. </if>
  8389. <if test="endDate != null and endDate != ''">
  8390. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8391. </if>
  8392. </if>
  8393. <if test="isPlacefile != null and isPlacefile == 1">
  8394. <if test="startDate != null and startDate != ''">
  8395. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8396. </if>
  8397. <if test="endDate != null and endDate != ''">
  8398. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8399. </if>
  8400. </if>
  8401. <if test="deptName != null and deptName != ''">
  8402. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  8403. </if>
  8404. GROUP BY
  8405. a.beh_dept_id,
  8406. a.beh_dept_name
  8407. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  8408. AND mr.beh_dept_name = improve_t.beh_dept_name
  8409. ) t
  8410. <if test="asc != null and asc !=''">
  8411. order by
  8412. <choose>
  8413. <when test='asc=="deptId"'>deptId asc</when>
  8414. <when test='asc=="deptName"'>deptName asc</when>
  8415. <when test='asc=="mrNum"'>mrNum asc</when>
  8416. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8417. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8418. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8419. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8420. <when test='asc=="improveNum"'>improveNum asc</when>
  8421. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8422. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8423. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8424. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8425. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8426. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8427. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8428. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8429. <otherwise>deptName asc</otherwise>
  8430. </choose>
  8431. </if>
  8432. <if test="desc != null and desc!=''">
  8433. order by
  8434. <choose>
  8435. <when test='desc=="deptId"'>deptId desc</when>
  8436. <when test='desc=="deptName"'>deptName desc</when>
  8437. <when test='desc=="mrNum"'>mrNum desc</when>
  8438. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8439. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8440. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8441. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8442. <when test='desc=="improveNum"'>improveNum desc</when>
  8443. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8444. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8445. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8446. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8447. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8448. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8449. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8450. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8451. <otherwise>deptName desc</otherwise>
  8452. </choose>
  8453. </if>
  8454. </select>
  8455. <!-- 质控核查统计-科室(内页)-->
  8456. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  8457. SELECT
  8458. t.*
  8459. FROM
  8460. (SELECT
  8461. mr.beh_dept_id AS deptId,
  8462. mr.beh_dept_name AS deptName,
  8463. mr.doctorId,
  8464. mr.doctorName,
  8465. IFNULL( mr.mrNum, 0 ) AS mrNum,
  8466. ck.checkedNum AS checkedNum,
  8467. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  8468. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  8469. hmmr_t.homePageMRNum,
  8470. improve_t.improveNum,
  8471. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  8472. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  8473. improve_t.improveToPassNum,
  8474. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  8475. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  8476. improve_t.improveToFullNum,
  8477. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  8478. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  8479. FROM
  8480. (
  8481. SELECT
  8482. a.beh_dept_id,
  8483. a.beh_dept_name,
  8484. a.doctor_id as doctorId,
  8485. a.doctor_name as doctorName,
  8486. count(*) AS mrNum
  8487. FROM
  8488. med_behospital_info a,
  8489. med_qcresult_info b,
  8490. sys_user_dept c
  8491. WHERE
  8492. a.is_deleted = 'N'
  8493. AND b.is_deleted = 'N'
  8494. AND c.is_deleted = 'N'
  8495. AND a.hospital_id = b.hospital_id
  8496. AND a.hospital_id = c.hospital_id
  8497. AND a.beh_dept_id = c.dept_id
  8498. AND a.behospital_code = b.behospital_code
  8499. AND a.qc_type_id != 0
  8500. <if test="userId!=null">
  8501. AND c.user_id = #{userId}
  8502. </if>
  8503. <if test="isPlacefile != null and isPlacefile != ''">
  8504. and a.is_placefile = #{isPlacefile}
  8505. </if>
  8506. <if test="hospitalId != null and hospitalId != ''">
  8507. AND a.hospital_id = #{hospitalId}
  8508. </if>
  8509. <if test="isPlacefile != null and isPlacefile == 0">
  8510. <if test="startDate != null and startDate != ''">
  8511. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8512. </if>
  8513. <if test="endDate != null and endDate != ''">
  8514. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8515. </if>
  8516. </if>
  8517. <if test="isPlacefile != null and isPlacefile == 1">
  8518. <if test="startDate != null and startDate != ''">
  8519. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8520. </if>
  8521. <if test="endDate != null and endDate != ''">
  8522. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8523. </if>
  8524. </if>
  8525. <if test="deptName != null and deptName != ''">
  8526. and a.beh_dept_name = #{deptName}
  8527. </if>
  8528. <if test="doctorName != null and doctorName != ''">
  8529. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8530. </if>
  8531. GROUP BY
  8532. a.doctor_id,
  8533. a.doctor_name
  8534. ) mr
  8535. LEFT JOIN (
  8536. SELECT
  8537. a.beh_dept_id,
  8538. a.beh_dept_name,
  8539. a.doctor_id as doctorId,
  8540. a.doctor_name as doctorName,
  8541. count(*) AS checkedNum
  8542. FROM
  8543. med_behospital_info a,
  8544. med_qcresult_info b,
  8545. med_check_info c,
  8546. sys_user_dept d
  8547. WHERE
  8548. a.is_deleted = 'N'
  8549. AND b.is_deleted = 'N'
  8550. AND c.is_deleted = 'N'
  8551. AND d.is_deleted = 'N'
  8552. AND a.hospital_id = b.hospital_id
  8553. AND a.hospital_id = c.hospital_id
  8554. AND a.hospital_id = d.hospital_id
  8555. AND a.behospital_code = b.behospital_code
  8556. AND a.behospital_code = c.behospital_code
  8557. AND a.beh_dept_id = d.dept_id
  8558. AND a.qc_type_id != 0
  8559. AND ifnull(c.`status`,0) = 1
  8560. AND c.check_type = 0
  8561. <if test="userId!=null">
  8562. AND d.user_id = #{userId}
  8563. </if>
  8564. <if test="isPlacefile != null and isPlacefile != ''">
  8565. and a.is_placefile = #{isPlacefile}
  8566. </if>
  8567. <if test="hospitalId != null and hospitalId != ''">
  8568. AND a.hospital_id = #{hospitalId}
  8569. </if>
  8570. <if test="isPlacefile != null and isPlacefile == 0">
  8571. <if test="startDate != null and startDate != ''">
  8572. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8573. </if>
  8574. <if test="endDate != null and endDate != ''">
  8575. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8576. </if>
  8577. </if>
  8578. <if test="isPlacefile != null and isPlacefile == 1">
  8579. <if test="startDate != null and startDate != ''">
  8580. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8581. </if>
  8582. <if test="endDate != null and endDate != ''">
  8583. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8584. </if>
  8585. </if>
  8586. <if test="deptName != null and deptName != ''">
  8587. and a.beh_dept_name = #{deptName}
  8588. </if>
  8589. <if test="doctorName != null and doctorName != ''">
  8590. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8591. </if>
  8592. GROUP BY
  8593. a.doctor_id,
  8594. a.doctor_name
  8595. ) ck ON mr.doctorId = ck.doctorId
  8596. AND mr.doctorName = ck.doctorName
  8597. LEFT JOIN (
  8598. SELECT
  8599. a.beh_dept_id,
  8600. a.beh_dept_name,
  8601. a.doctor_id as doctorId,
  8602. a.doctor_name as doctorName,
  8603. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8604. FROM
  8605. med_behospital_info a,
  8606. med_home_page b,
  8607. med_qcresult_info c,
  8608. sys_user_dept d
  8609. WHERE
  8610. a.is_deleted = 'N'
  8611. AND b.is_deleted = 'N'
  8612. AND c.is_deleted = 'N'
  8613. AND d.is_deleted = 'N'
  8614. AND a.hospital_id = b.hospital_id
  8615. AND a.hospital_id = c.hospital_id
  8616. AND a.hospital_id = d.hospital_id
  8617. AND a.behospital_code = b.behospital_code
  8618. AND a.behospital_code = c.behospital_code
  8619. AND a.beh_dept_id = d.dept_id
  8620. AND a.qc_type_id != 0
  8621. <if test="userId!=null">
  8622. AND d.user_id = #{userId}
  8623. </if>
  8624. <if test="isPlacefile != null and isPlacefile != ''">
  8625. and a.is_placefile = #{isPlacefile}
  8626. </if>
  8627. <if test="hospitalId != null and hospitalId != ''">
  8628. AND a.hospital_id = #{hospitalId}
  8629. </if>
  8630. <if test="isPlacefile != null and isPlacefile == 0">
  8631. <if test="startDate != null and startDate != ''">
  8632. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8633. </if>
  8634. <if test="endDate != null and endDate != ''">
  8635. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8636. </if>
  8637. </if>
  8638. <if test="isPlacefile != null and isPlacefile == 1">
  8639. <if test="startDate != null and startDate != ''">
  8640. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8641. </if>
  8642. <if test="endDate != null and endDate != ''">
  8643. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8644. </if>
  8645. </if>
  8646. <if test="deptName != null and deptName != ''">
  8647. and a.beh_dept_name = #{deptName}
  8648. </if>
  8649. <if test="doctorName != null and doctorName != ''">
  8650. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8651. </if>
  8652. GROUP BY
  8653. a.doctor_id,
  8654. a.doctor_name
  8655. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8656. AND mr.doctorName = hmmr_t.doctorName
  8657. LEFT JOIN (
  8658. SELECT
  8659. a.beh_dept_id,
  8660. a.beh_dept_name,
  8661. a.doctor_id as doctorId,
  8662. a.doctor_name as doctorName,
  8663. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8664. sum( d.score_res = 20 ) AS improveToFullNum,
  8665. count(*) AS improveNum
  8666. FROM
  8667. med_behospital_info a,
  8668. med_home_page b,
  8669. med_qcresult_info c,
  8670. med_qcresult_cases d,
  8671. sys_user_dept f,
  8672. (
  8673. SELECT
  8674. m4.*
  8675. FROM
  8676. med_behospital_info m1,
  8677. med_home_page m2,
  8678. med_qcresult_info m3,
  8679. med_qcresult_cases m4
  8680. WHERE
  8681. m1.is_deleted = 'N'
  8682. AND m2.is_deleted = 'N'
  8683. AND m3.is_deleted = 'Y'
  8684. AND m4.is_deleted = 'Y'
  8685. AND m1.hospital_id = m2.hospital_id
  8686. AND m1.hospital_id = m3.hospital_id
  8687. AND m1.hospital_id = m4.hospital_id
  8688. AND m1.behospital_code = m2.behospital_code
  8689. AND m1.behospital_code = m3.behospital_code
  8690. AND m1.behospital_code = m4.behospital_code
  8691. AND m3.gmt_create = m4.gmt_create
  8692. AND m3.have_home_page = 1
  8693. AND m4.cases_id = 243
  8694. <if test="isPlacefile != null and isPlacefile != ''">
  8695. and m1.is_placefile = #{isPlacefile}
  8696. </if>
  8697. AND m1.qc_type_id != 0
  8698. <if test="hospitalId != null and hospitalId != ''">
  8699. AND m1.hospital_id = #{hospitalId}
  8700. </if>
  8701. <if test="isPlacefile != null and isPlacefile == 0">
  8702. <if test="startDate != null and startDate != ''">
  8703. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8704. </if>
  8705. <if test="endDate != null and endDate != ''">
  8706. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8707. </if>
  8708. </if>
  8709. <if test="isPlacefile != null and isPlacefile == 1">
  8710. <if test="startDate != null and startDate != ''">
  8711. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8712. </if>
  8713. <if test="endDate != null and endDate != ''">
  8714. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8715. </if>
  8716. </if>
  8717. <if test="deptName != null and deptName != ''">
  8718. and m1.beh_dept_name = #{deptName}
  8719. </if>
  8720. GROUP BY
  8721. m1.behospital_code
  8722. ORDER BY
  8723. m1.behospital_code,
  8724. m4.gmt_create
  8725. ) e
  8726. WHERE
  8727. a.is_deleted = 'N'
  8728. AND b.is_deleted = 'N'
  8729. AND c.is_deleted = 'N'
  8730. AND d.is_deleted = 'N'
  8731. AND f.is_deleted = 'N'
  8732. AND a.hospital_id = b.hospital_id
  8733. AND a.hospital_id = c.hospital_id
  8734. AND a.hospital_id = d.hospital_id
  8735. AND a.hospital_id = e.hospital_id
  8736. AND a.hospital_id = f.hospital_id
  8737. AND a.behospital_code = b.behospital_code
  8738. AND a.behospital_code = c.behospital_code
  8739. AND a.behospital_code = d.behospital_code
  8740. AND a.behospital_code = e.behospital_code
  8741. AND a.beh_dept_id = f.dept_id
  8742. <if test="userId!=null">
  8743. AND f.user_id = #{userId}
  8744. </if>
  8745. AND d.cases_id = 243
  8746. AND d.score_res > e.score_res
  8747. <if test="hospitalId != null and hospitalId != ''">
  8748. AND a.hospital_id = #{hospitalId}
  8749. </if>
  8750. <if test="isPlacefile != null and isPlacefile == 0">
  8751. <if test="startDate != null and startDate != ''">
  8752. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8753. </if>
  8754. <if test="endDate != null and endDate != ''">
  8755. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8756. </if>
  8757. </if>
  8758. <if test="isPlacefile != null and isPlacefile == 1">
  8759. <if test="startDate != null and startDate != ''">
  8760. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8761. </if>
  8762. <if test="endDate != null and endDate != ''">
  8763. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8764. </if>
  8765. </if>
  8766. <if test="doctorName != null and doctorName != ''">
  8767. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8768. </if>
  8769. <if test="deptName != null and deptName != ''">
  8770. and a.beh_dept_name = #{deptName}
  8771. </if>
  8772. GROUP BY
  8773. a.doctor_id,
  8774. a.doctor_name
  8775. ) improve_t ON mr.doctorId = improve_t.doctorId
  8776. AND mr.doctorName = improve_t.doctorName
  8777. ) t
  8778. <if test="asc != null and asc !=''">
  8779. order by
  8780. <choose>
  8781. <when test='asc=="deptId"'>deptId asc</when>
  8782. <when test='asc=="deptName"'>deptName asc</when>
  8783. <when test='asc=="doctorName"'>doctorName asc</when>
  8784. <when test='asc=="mrNum"'>mrNum asc</when>
  8785. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8786. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8787. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8788. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8789. <when test='asc=="improveNum"'>improveNum asc</when>
  8790. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8791. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8792. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8793. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8794. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8795. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8796. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8797. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8798. <otherwise>doctorName asc</otherwise>
  8799. </choose>
  8800. </if>
  8801. <if test="desc != null and desc!=''">
  8802. order by
  8803. <choose>
  8804. <when test='desc=="deptId"'>deptId desc</when>
  8805. <when test='desc=="deptName"'>deptName desc</when>
  8806. <when test='desc=="doctorName"'>doctorName desc</when>
  8807. <when test='desc=="mrNum"'>mrNum desc</when>
  8808. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8809. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8810. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8811. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8812. <when test='desc=="improveNum"'>improveNum desc</when>
  8813. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8814. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8815. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8816. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8817. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8818. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8819. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8820. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8821. <otherwise>deptName desc</otherwise>
  8822. </choose>
  8823. </if>
  8824. </select>
  8825. <!-- 离院病人评分详情页导出-->
  8826. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  8827. SELECT
  8828. f1.behDeptId,
  8829. f1.behDeptName,
  8830. f1.doctorName,
  8831. f1.patName,
  8832. f1.behospitalCode,
  8833. f1.hospitalId,
  8834. f1.behospitalDate,
  8835. f1.leaveHospitalDate,
  8836. f1.score,
  8837. f2.avgScore,
  8838. f1.scoreBn,
  8839. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8840. f1.msg,
  8841. f1.caseName,
  8842. </if>
  8843. f1.checkStatus,
  8844. f1.mrStatus,
  8845. f1.chName,
  8846. f1.mrName,
  8847. f1.chTime,
  8848. f1.mrTime
  8849. FROM
  8850. (SELECT
  8851. t.doctorName,
  8852. t.`name` AS patName,
  8853. t.behospitalCode AS behospitalCode,
  8854. t.behospitalDate AS behospitalDate,
  8855. t.leaveHospitalDate AS leaveHospitalDate,
  8856. qi.score_res AS score,
  8857. t.scoreBn,
  8858. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8859. qd.msg AS msg,
  8860. qc.NAME AS caseName,
  8861. </if>
  8862. t.behDeptId,
  8863. t.behDeptName,
  8864. t.hospitalId,
  8865. t.checkStatus,
  8866. t.mrStatus,
  8867. t.chName,
  8868. t.mrName,
  8869. t.chTime,
  8870. t.mrTime
  8871. FROM
  8872. (SELECT DISTINCT
  8873. t1.hospital_id AS hospitalId,
  8874. t1.behospital_code AS behospitalCode,
  8875. t1.bed_code AS bedCode,
  8876. t1.LEVEL AS LEVEL,
  8877. t1.grade_type AS gradeType,
  8878. t1.score_res AS scoreRes,
  8879. t1.scoreBn,
  8880. t1.NAME AS NAME,
  8881. t1.sex AS sex,
  8882. t1.beh_dept_id AS behDeptId,
  8883. t1.beh_dept_name AS behDeptName,
  8884. t1.doctor_id AS doctorId,
  8885. t1.doctor_name AS doctorName,
  8886. t1.beh_doctor_id AS behDoctorId,
  8887. t1.beh_doctor_name AS behDoctorName,
  8888. t1.director_doctor_id AS directorDoctorId,
  8889. t1.director_doctor_name AS directorDoctorName,
  8890. t1.birthday AS birthday,
  8891. t1.behospital_date AS behospitalDate,
  8892. t1.leave_hospital_date AS leaveHospitalDate,
  8893. t1.placefile_date AS placefileDate,
  8894. t1.gmt_create AS gradeTime,
  8895. t1.diagnose,
  8896. t1.ward_name AS wardName,
  8897. t1.checkStatus,
  8898. t1.mrStatus,
  8899. t1.chName,
  8900. t1.mrName,
  8901. t1.chTime,
  8902. t1.mrTime,
  8903. t2.age,
  8904. t1.file_code AS fileCode
  8905. FROM
  8906. (
  8907. SELECT be.*,
  8908. ifnull(mci.status,0) AS checkStatus,
  8909. ifnull(hm_mci.status,0) AS mrStatus,
  8910. mci.check_name as chName,
  8911. e.score_res as scoreBn,
  8912. hm_mci.check_name as mrName,
  8913. mci.gmt_create as chTime,
  8914. hm_mci.gmt_create as mrTime
  8915. FROM
  8916. (
  8917. SELECT DISTINCT
  8918. tt1.*
  8919. FROM
  8920. (
  8921. SELECT
  8922. b.*,
  8923. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8924. c.grade_type,
  8925. c.score_res,
  8926. c.gmt_create
  8927. FROM
  8928. (
  8929. SELECT DISTINCT
  8930. a.hospital_id,
  8931. a.behospital_code,
  8932. a.bed_code,
  8933. a.NAME,
  8934. a.sex,
  8935. a.beh_dept_id,
  8936. a.beh_dept_name,
  8937. a.birthday,
  8938. a.behospital_date,
  8939. a.leave_hospital_date,
  8940. a.doctor_id,
  8941. a.doctor_name,
  8942. a.beh_doctor_id,
  8943. a.beh_doctor_name,
  8944. a.director_doctor_id,
  8945. a.director_doctor_name,
  8946. a.diagnose,
  8947. a.placefile_date,
  8948. a.ward_name,
  8949. a.file_code
  8950. FROM
  8951. med_behospital_info a
  8952. WHERE
  8953. a.is_deleted = 'N'
  8954. AND a.qc_type_id != 0
  8955. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8956. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8957. </if>
  8958. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8959. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8960. </if>
  8961. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8962. <if test="qcResultShortPageVO.startDate != null ">
  8963. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8964. </if>
  8965. <if test="qcResultShortPageVO.endDate != null ">
  8966. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8967. </if>
  8968. </if>
  8969. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8970. <if test="qcResultShortPageVO.startDate != null ">
  8971. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8972. </if>
  8973. <if test="qcResultShortPageVO.endDate != null">
  8974. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8975. </if>
  8976. </if>
  8977. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8978. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8979. </if>
  8980. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8981. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8982. </if>
  8983. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8984. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8985. </if>
  8986. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8987. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8988. </if>
  8989. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8990. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8991. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8992. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8993. </if>
  8994. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8995. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8996. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8997. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8998. </if>
  8999. ) b
  9000. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9001. AND b.hospital_id = c.hospital_id
  9002. AND b.behospital_code = c.behospital_code
  9003. ) tt1
  9004. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9005. ,med_medical_record tt2,
  9006. qc_mode tt3
  9007. WHERE
  9008. tt2.is_deleted = 'N'
  9009. AND tt3.is_deleted = 'N'
  9010. AND tt1.hospital_id = tt2.hospital_id
  9011. AND tt1.behospital_code = tt2.behospital_code
  9012. AND tt2.mode_id = tt3.id
  9013. AND tt3.`name` = '手术记录'
  9014. </if>
  9015. ) be
  9016. left join med_check_info mci
  9017. on mci.is_deleted = 'N'
  9018. and mci.check_type = 0
  9019. and be.hospital_id = mci.hospital_id
  9020. and be.behospital_code = mci.behospital_code
  9021. left join med_check_info hm_mci
  9022. on hm_mci.is_deleted = 'N'
  9023. and hm_mci.check_type = 1
  9024. and be.hospital_id = hm_mci.hospital_id
  9025. and be.behospital_code = hm_mci.behospital_code
  9026. LEFT JOIN med_qcresult_cases e
  9027. on be.behospital_code = e.behospital_code
  9028. and be.hospital_id = e.hospital_id
  9029. AND e.is_deleted = 'N'
  9030. and e.cases_id = 243
  9031. )t1
  9032. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  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 (
  9039. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9040. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9041. )
  9042. </if>
  9043. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9044. ,med_home_page t2
  9045. WHERE
  9046. t2.is_deleted = 'N'
  9047. AND t1.hospital_id = t2.hospital_id
  9048. AND t1.behospital_code = t2.behospital_code
  9049. AND t2.return_to_type = '死亡'
  9050. </if>
  9051. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9052. ,med_home_page t2
  9053. WHERE
  9054. t2.is_deleted = 'N'
  9055. AND t1.hospital_id = t2.hospital_id
  9056. AND t1.behospital_code = t2.behospital_code
  9057. AND t2.leave_hospital_type = '非医嘱离院'
  9058. </if>
  9059. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9060. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9061. AND t1.hospital_id = t2.hospital_id
  9062. AND t1.behospital_code = t2.behospital_code
  9063. </if>
  9064. )t
  9065. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9066. AND t.hospitalId = qi.hospital_id
  9067. AND t.behospitalCode = qi.behospital_code
  9068. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9069. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9070. AND t.hospitalId = qd.hospital_id
  9071. AND t.behospitalCode = qd.behospital_code
  9072. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9073. AND qd.cases_id = qc.id
  9074. </if>
  9075. where 1=1
  9076. <if test="qcResultShortPageVO.checkStatus != null">
  9077. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9078. </if>
  9079. <if test="qcResultShortPageVO.mrStatus != null">
  9080. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9081. </if>
  9082. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9083. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9084. </if>
  9085. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9086. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9087. </if>
  9088. <if test="qcResultShortPageVO.chTimeStart != null ">
  9089. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9090. </if>
  9091. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9092. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9093. </if>
  9094. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9095. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9096. </if>
  9097. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9098. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9099. </if>
  9100. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9101. AND t.`level` = #{qcResultShortPageVO.level}
  9102. </if>)f1,(SELECT
  9103. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9104. t.behDeptId,
  9105. t.behDeptName
  9106. FROM
  9107. (SELECT DISTINCT
  9108. t1.hospital_id AS hospitalId,
  9109. t1.behospital_code AS behospitalCode,
  9110. t1.bed_code AS bedCode,
  9111. t1.LEVEL AS LEVEL,
  9112. t1.grade_type AS gradeType,
  9113. t1.score_res AS scoreRes,
  9114. t1.NAME AS NAME,
  9115. t1.sex AS sex,
  9116. t1.beh_dept_id AS behDeptId,
  9117. t1.beh_dept_name AS behDeptName,
  9118. t1.doctor_id AS doctorId,
  9119. t1.doctor_name AS doctorName,
  9120. t1.beh_doctor_id AS behDoctorId,
  9121. t1.beh_doctor_name AS behDoctorName,
  9122. t1.director_doctor_id AS directorDoctorId,
  9123. t1.director_doctor_name AS directorDoctorName,
  9124. t1.birthday AS birthday,
  9125. t1.behospital_date AS behospitalDate,
  9126. t1.leave_hospital_date AS leaveHospitalDate,
  9127. t1.placefile_date AS placefileDate,
  9128. t1.gmt_create AS gradeTime,
  9129. t1.diagnose,
  9130. t1.ward_name AS wardName,
  9131. t1.checkStatus,
  9132. t1.mrStatus,
  9133. t1.chName,
  9134. t1.mrName,
  9135. t1.chTime,
  9136. t1.mrTime,
  9137. t2.age,
  9138. t1.file_code AS fileCode
  9139. FROM
  9140. (
  9141. SELECT be.*,
  9142. ifnull(mci.status,0) AS checkStatus,
  9143. ifnull(hm_mci.status,0) AS mrStatus,
  9144. mci.check_name as chName,
  9145. hm_mci.check_name as mrName,
  9146. mci.gmt_create as chTime,
  9147. hm_mci.gmt_create as mrTime
  9148. FROM
  9149. (
  9150. SELECT DISTINCT
  9151. tt1.*
  9152. FROM
  9153. (
  9154. SELECT
  9155. b.*,
  9156. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9157. c.grade_type,
  9158. c.score_res,
  9159. c.gmt_create
  9160. FROM
  9161. (
  9162. SELECT DISTINCT
  9163. a.hospital_id,
  9164. a.behospital_code,
  9165. a.bed_code,
  9166. a.NAME,
  9167. a.sex,
  9168. a.beh_dept_id,
  9169. a.beh_dept_name,
  9170. a.birthday,
  9171. a.behospital_date,
  9172. a.leave_hospital_date,
  9173. a.doctor_id,
  9174. a.doctor_name,
  9175. a.beh_doctor_id,
  9176. a.beh_doctor_name,
  9177. a.director_doctor_id,
  9178. a.director_doctor_name,
  9179. a.diagnose,
  9180. a.placefile_date,
  9181. a.ward_name,
  9182. a.file_code
  9183. FROM
  9184. med_behospital_info a
  9185. WHERE
  9186. a.is_deleted = 'N'
  9187. AND a.qc_type_id != 0
  9188. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9189. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9190. </if>
  9191. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9192. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9193. </if>
  9194. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9195. <if test="qcResultShortPageVO.startDate != null ">
  9196. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9197. </if>
  9198. <if test="qcResultShortPageVO.endDate != null ">
  9199. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9200. </if>
  9201. </if>
  9202. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9203. <if test="qcResultShortPageVO.startDate != null ">
  9204. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9205. </if>
  9206. <if test="qcResultShortPageVO.endDate != null">
  9207. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9208. </if>
  9209. </if>
  9210. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9211. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9212. </if>
  9213. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9214. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9215. </if>
  9216. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9217. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9218. </if>
  9219. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9220. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9221. </if>
  9222. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9223. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9224. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9225. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9226. </if>
  9227. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9228. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9229. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9230. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9231. </if>
  9232. ) b
  9233. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9234. AND b.hospital_id = c.hospital_id
  9235. AND b.behospital_code = c.behospital_code
  9236. ) tt1
  9237. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9238. ,med_medical_record tt2,
  9239. qc_mode tt3
  9240. WHERE
  9241. tt2.is_deleted = 'N'
  9242. AND tt3.is_deleted = 'N'
  9243. AND tt1.hospital_id = tt2.hospital_id
  9244. AND tt1.behospital_code = tt2.behospital_code
  9245. AND tt2.mode_id = tt3.id
  9246. AND tt3.`name` = '手术记录'
  9247. </if>
  9248. ) be
  9249. left join med_check_info mci
  9250. on mci.is_deleted = 'N'
  9251. and mci.check_type = 0
  9252. and be.hospital_id = mci.hospital_id
  9253. and be.behospital_code = mci.behospital_code
  9254. left join med_check_info hm_mci
  9255. on hm_mci.is_deleted = 'N'
  9256. and hm_mci.check_type = 1
  9257. and be.hospital_id = hm_mci.hospital_id
  9258. and be.behospital_code = hm_mci.behospital_code
  9259. )t1
  9260. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9261. ,med_home_page t2
  9262. WHERE
  9263. t2.is_deleted = 'N'
  9264. AND t1.hospital_id = t2.hospital_id
  9265. AND t1.behospital_code = t2.behospital_code
  9266. AND (
  9267. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  9268. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9269. )
  9270. </if>
  9271. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9272. ,med_home_page t2
  9273. WHERE
  9274. t2.is_deleted = 'N'
  9275. AND t1.hospital_id = t2.hospital_id
  9276. AND t1.behospital_code = t2.behospital_code
  9277. AND t2.return_to_type = '死亡'
  9278. </if>
  9279. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9280. ,med_home_page t2
  9281. WHERE
  9282. t2.is_deleted = 'N'
  9283. AND t1.hospital_id = t2.hospital_id
  9284. AND t1.behospital_code = t2.behospital_code
  9285. AND t2.leave_hospital_type = '非医嘱离院'
  9286. </if>
  9287. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9288. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9289. AND t1.hospital_id = t2.hospital_id
  9290. AND t1.behospital_code = t2.behospital_code
  9291. </if>
  9292. )t
  9293. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9294. AND t.hospitalId = qi.hospital_id
  9295. AND t.behospitalCode = qi.behospital_code
  9296. where 1=1
  9297. <if test="qcResultShortPageVO.checkStatus != null">
  9298. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9299. </if>
  9300. <if test="qcResultShortPageVO.mrStatus != null">
  9301. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9302. </if>
  9303. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9304. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9305. </if>
  9306. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9307. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9308. </if>
  9309. <if test="qcResultShortPageVO.chTimeStart != null ">
  9310. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9311. </if>
  9312. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9313. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9314. </if>
  9315. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9316. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9317. </if>
  9318. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9319. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9320. </if>
  9321. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9322. AND t.`level` = #{qcResultShortPageVO.level}
  9323. </if>
  9324. GROUP BY
  9325. t.behDeptId,
  9326. t.behDeptName
  9327. )f2
  9328. WHERE
  9329. f1.behDeptId = f2.behDeptId
  9330. AND f1.behDeptName = f2.behDeptName
  9331. </select>
  9332. <!-- 离院病人评分详情页导出-科室-->
  9333. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  9334. SELECT
  9335. f1.behDeptId,
  9336. f1.behDeptName,
  9337. f1.doctorName,
  9338. f1.patName,
  9339. f1.behospitalCode,
  9340. f1.hospitalId,
  9341. f1.behospitalDate,
  9342. f1.leaveHospitalDate,
  9343. f1.score,
  9344. f1.medoupName,
  9345. f1.wardName,
  9346. f2.avgScore,
  9347. f1.scoreBn,
  9348. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9349. f1.msg,
  9350. f1.caseName,
  9351. </if>
  9352. f1.checkStatus,
  9353. f1.mrStatus,
  9354. f1.chName,
  9355. f1.mrName,
  9356. f1.chTime,
  9357. f1.mrTime
  9358. FROM
  9359. (SELECT
  9360. t.doctorName,
  9361. t.doctorId,
  9362. t.`name` AS patName,
  9363. t3.name as medoupName,
  9364. t.behospitalCode AS behospitalCode,
  9365. t.behospitalDate AS behospitalDate,
  9366. t.leaveHospitalDate AS leaveHospitalDate,
  9367. qi.score_res AS score,
  9368. t.scoreBn,
  9369. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9370. qd.msg AS msg,
  9371. qc.NAME AS caseName,
  9372. </if>
  9373. t.behDeptId,
  9374. t.behDeptName,
  9375. t.wardName,
  9376. t.hospitalId,
  9377. t.checkStatus,
  9378. t.mrStatus,
  9379. t.chName,
  9380. t.mrName,
  9381. t.chTime,
  9382. t.mrTime
  9383. FROM
  9384. (SELECT DISTINCT
  9385. t1.hospital_id AS hospitalId,
  9386. t1.behospital_code AS behospitalCode,
  9387. t1.bed_code AS bedCode,
  9388. t1.LEVEL AS LEVEL,
  9389. t1.grade_type AS gradeType,
  9390. t1.score_res AS scoreRes,
  9391. t1.scoreBn,
  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. e.score_res as scoreBn,
  9424. hm_mci.check_name as mrName,
  9425. mci.gmt_create as chTime,
  9426. hm_mci.gmt_create as mrTime
  9427. FROM
  9428. (
  9429. SELECT DISTINCT
  9430. tt1.*
  9431. FROM
  9432. (
  9433. SELECT
  9434. b.*,
  9435. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9436. c.grade_type,
  9437. c.score_res,
  9438. c.gmt_create
  9439. FROM
  9440. (
  9441. SELECT DISTINCT
  9442. a.hospital_id,
  9443. a.behospital_code,
  9444. a.bed_code,
  9445. a.NAME,
  9446. a.sex,
  9447. a.beh_dept_id,
  9448. a.beh_dept_name,
  9449. a.birthday,
  9450. a.behospital_date,
  9451. a.leave_hospital_date,
  9452. a.doctor_id,
  9453. a.doctor_name,
  9454. a.beh_doctor_id,
  9455. a.beh_doctor_name,
  9456. a.director_doctor_id,
  9457. a.director_doctor_name,
  9458. a.diagnose,
  9459. a.placefile_date,
  9460. a.ward_name,
  9461. a.file_code
  9462. FROM
  9463. med_behospital_info a,
  9464. sys_user_dept b
  9465. WHERE
  9466. a.is_deleted = 'N'
  9467. AND b.is_deleted = 'N'
  9468. AND a.hospital_id = b.hospital_id
  9469. AND a.beh_dept_id = b.dept_id
  9470. AND a.qc_type_id != 0
  9471. <if test="qcResultShortPageVO.userId!=null">
  9472. AND b.user_id = #{qcResultShortPageVO.userId}
  9473. </if>
  9474. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9475. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9476. </if>
  9477. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9478. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9479. </if>
  9480. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9481. <if test="qcResultShortPageVO.startDate != null ">
  9482. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9483. </if>
  9484. <if test="qcResultShortPageVO.endDate != null ">
  9485. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9486. </if>
  9487. </if>
  9488. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9489. <if test="qcResultShortPageVO.startDate != null ">
  9490. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9491. </if>
  9492. <if test="qcResultShortPageVO.endDate != null">
  9493. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9494. </if>
  9495. </if>
  9496. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9497. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9498. </if>
  9499. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9500. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  9501. </if>
  9502. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9503. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9504. </if>
  9505. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  9506. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9507. </if>
  9508. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9509. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9510. </if>
  9511. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9512. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9513. </if>
  9514. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9515. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9516. </if>
  9517. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9518. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  9519. </if>
  9520. ) b
  9521. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9522. AND b.hospital_id = c.hospital_id
  9523. AND b.behospital_code = c.behospital_code
  9524. ) tt1
  9525. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9526. ,med_medical_record tt2,
  9527. qc_mode tt3
  9528. WHERE
  9529. tt2.is_deleted = 'N'
  9530. AND tt3.is_deleted = 'N'
  9531. AND tt1.hospital_id = tt2.hospital_id
  9532. AND tt1.behospital_code = tt2.behospital_code
  9533. AND tt2.mode_id = tt3.id
  9534. AND tt3.`name` = '手术记录'
  9535. </if>
  9536. ) be
  9537. left join med_check_info mci
  9538. on mci.is_deleted = 'N'
  9539. and mci.check_type = 0
  9540. and be.hospital_id = mci.hospital_id
  9541. and be.behospital_code = mci.behospital_code
  9542. left join med_check_info hm_mci
  9543. on hm_mci.is_deleted = 'N'
  9544. and hm_mci.check_type = 1
  9545. and be.hospital_id = hm_mci.hospital_id
  9546. and be.behospital_code = hm_mci.behospital_code
  9547. LEFT JOIN med_qcresult_cases e
  9548. on be.behospital_code = e.behospital_code
  9549. and be.hospital_id = e.hospital_id
  9550. AND e.is_deleted = 'N'
  9551. and e.cases_id = 243
  9552. )t1
  9553. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9554. ,med_home_page t2
  9555. WHERE
  9556. t2.is_deleted = 'N'
  9557. AND t1.hospital_id = t2.hospital_id
  9558. AND t1.behospital_code = t2.behospital_code
  9559. AND (
  9560. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9561. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9562. )
  9563. </if>
  9564. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  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.return_to_type = '死亡'
  9571. </if>
  9572. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9573. ,med_home_page t2
  9574. WHERE
  9575. t2.is_deleted = 'N'
  9576. AND t1.hospital_id = t2.hospital_id
  9577. AND t1.behospital_code = t2.behospital_code
  9578. AND t2.leave_hospital_type = '非医嘱离院'
  9579. </if>
  9580. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9581. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9582. AND t1.hospital_id = t2.hospital_id
  9583. AND t1.behospital_code = t2.behospital_code
  9584. </if>
  9585. )t
  9586. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9587. AND t.hospitalId = qi.hospital_id
  9588. AND t.behospitalCode = qi.behospital_code
  9589. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  9590. AND t.hospitalId = t2.hospital_id
  9591. AND t2.is_deleted = 'N'
  9592. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9593. AND t3.is_deleted = 'N'
  9594. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9595. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9596. AND t.hospitalId = qd.hospital_id
  9597. AND t.behospitalCode = qd.behospital_code
  9598. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9599. AND qd.cases_id = qc.id
  9600. </if>
  9601. where 1=1
  9602. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  9603. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  9604. </if>
  9605. <if test="qcResultShortPageVO.checkStatus != null">
  9606. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9607. </if>
  9608. <if test="qcResultShortPageVO.mrStatus != null">
  9609. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9610. </if>
  9611. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9612. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9613. </if>
  9614. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9615. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9616. </if>
  9617. <if test="qcResultShortPageVO.chTimeStart != null ">
  9618. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9619. </if>
  9620. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9621. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9622. </if>
  9623. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9624. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9625. </if>
  9626. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9627. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9628. </if>
  9629. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9630. AND t.`level` = #{qcResultShortPageVO.level}
  9631. </if>)f1,(SELECT
  9632. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9633. t.behDeptId,
  9634. t.behDeptName,
  9635. t.doctorId,
  9636. t.doctorName
  9637. FROM
  9638. (SELECT DISTINCT
  9639. t1.hospital_id AS hospitalId,
  9640. t1.behospital_code AS behospitalCode,
  9641. t1.bed_code AS bedCode,
  9642. t1.LEVEL AS LEVEL,
  9643. t1.grade_type AS gradeType,
  9644. t1.score_res AS scoreRes,
  9645. t1.NAME AS NAME,
  9646. t1.sex AS sex,
  9647. t1.beh_dept_id AS behDeptId,
  9648. t1.beh_dept_name AS behDeptName,
  9649. t1.doctor_id AS doctorId,
  9650. t1.doctor_name AS doctorName,
  9651. t1.beh_doctor_id AS behDoctorId,
  9652. t1.beh_doctor_name AS behDoctorName,
  9653. t1.director_doctor_id AS directorDoctorId,
  9654. t1.director_doctor_name AS directorDoctorName,
  9655. t1.birthday AS birthday,
  9656. t1.behospital_date AS behospitalDate,
  9657. t1.leave_hospital_date AS leaveHospitalDate,
  9658. t1.placefile_date AS placefileDate,
  9659. t1.gmt_create AS gradeTime,
  9660. t1.diagnose,
  9661. t1.ward_name AS wardName,
  9662. t1.checkStatus,
  9663. t1.mrStatus,
  9664. t1.chName,
  9665. t1.mrName,
  9666. t1.chTime,
  9667. t1.mrTime,
  9668. t2.age,
  9669. t1.file_code AS fileCode
  9670. FROM
  9671. (
  9672. SELECT be.*,
  9673. ifnull(mci.status,0) AS checkStatus,
  9674. ifnull(hm_mci.status,0) AS mrStatus,
  9675. mci.check_name as chName,
  9676. hm_mci.check_name as mrName,
  9677. mci.gmt_create as chTime,
  9678. hm_mci.gmt_create as mrTime
  9679. FROM
  9680. (
  9681. SELECT DISTINCT
  9682. tt1.*
  9683. FROM
  9684. (
  9685. SELECT
  9686. b.*,
  9687. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9688. c.grade_type,
  9689. c.score_res,
  9690. c.gmt_create
  9691. FROM
  9692. (
  9693. SELECT DISTINCT
  9694. a.hospital_id,
  9695. a.behospital_code,
  9696. a.bed_code,
  9697. a.NAME,
  9698. a.sex,
  9699. a.beh_dept_id,
  9700. a.beh_dept_name,
  9701. a.birthday,
  9702. a.behospital_date,
  9703. a.leave_hospital_date,
  9704. a.doctor_id,
  9705. a.doctor_name,
  9706. a.beh_doctor_id,
  9707. a.beh_doctor_name,
  9708. a.director_doctor_id,
  9709. a.director_doctor_name,
  9710. a.diagnose,
  9711. a.placefile_date,
  9712. a.ward_name,
  9713. a.file_code
  9714. FROM
  9715. med_behospital_info a,
  9716. sys_user_dept b
  9717. WHERE
  9718. a.is_deleted = 'N'
  9719. AND b.is_deleted = 'N'
  9720. AND a.hospital_id = b.hospital_id
  9721. AND a.beh_dept_id = b.dept_id
  9722. AND a.qc_type_id != 0
  9723. <if test="qcResultShortPageVO.userId!=null">
  9724. AND b.user_id = #{qcResultShortPageVO.userId}
  9725. </if>
  9726. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9727. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9728. </if>
  9729. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9730. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9731. </if>
  9732. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9733. <if test="qcResultShortPageVO.startDate != null ">
  9734. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9735. </if>
  9736. <if test="qcResultShortPageVO.endDate != null ">
  9737. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9738. </if>
  9739. </if>
  9740. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9741. <if test="qcResultShortPageVO.startDate != null ">
  9742. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9743. </if>
  9744. <if test="qcResultShortPageVO.endDate != null">
  9745. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9746. </if>
  9747. </if>
  9748. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9749. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9750. </if>
  9751. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9752. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  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.deptId != null and qcResultShortPageVO.deptId != ''">
  9758. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9759. </if>
  9760. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9761. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9762. </if>
  9763. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9764. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9765. </if>
  9766. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9767. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9768. </if>
  9769. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9770. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  9771. </if>
  9772. ) b
  9773. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9774. AND b.hospital_id = c.hospital_id
  9775. AND b.behospital_code = c.behospital_code
  9776. ) tt1
  9777. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9778. ,med_medical_record tt2,
  9779. qc_mode tt3
  9780. WHERE
  9781. tt2.is_deleted = 'N'
  9782. AND tt3.is_deleted = 'N'
  9783. AND tt1.hospital_id = tt2.hospital_id
  9784. AND tt1.behospital_code = tt2.behospital_code
  9785. AND tt2.mode_id = tt3.id
  9786. AND tt3.`name` = '手术记录'
  9787. </if>
  9788. ) be
  9789. left join med_check_info mci
  9790. on mci.is_deleted = 'N'
  9791. and mci.check_type = 0
  9792. and be.hospital_id = mci.hospital_id
  9793. and be.behospital_code = mci.behospital_code
  9794. left join med_check_info hm_mci
  9795. on hm_mci.is_deleted = 'N'
  9796. and hm_mci.check_type = 1
  9797. and be.hospital_id = hm_mci.hospital_id
  9798. and be.behospital_code = hm_mci.behospital_code
  9799. )t1
  9800. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9801. ,med_home_page t2
  9802. WHERE
  9803. t2.is_deleted = 'N'
  9804. AND t1.hospital_id = t2.hospital_id
  9805. AND t1.behospital_code = t2.behospital_code
  9806. AND (
  9807. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9808. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9809. )
  9810. </if>
  9811. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9812. ,med_home_page t2
  9813. WHERE
  9814. t2.is_deleted = 'N'
  9815. AND t1.hospital_id = t2.hospital_id
  9816. AND t1.behospital_code = t2.behospital_code
  9817. AND t2.return_to_type = '死亡'
  9818. </if>
  9819. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9820. ,med_home_page t2
  9821. WHERE
  9822. t2.is_deleted = 'N'
  9823. AND t1.hospital_id = t2.hospital_id
  9824. AND t1.behospital_code = t2.behospital_code
  9825. AND t2.leave_hospital_type = '非医嘱离院'
  9826. </if>
  9827. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9828. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9829. AND t1.hospital_id = t2.hospital_id
  9830. AND t1.behospital_code = t2.behospital_code
  9831. </if>
  9832. )t
  9833. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9834. AND t.hospitalId = qi.hospital_id
  9835. AND t.behospitalCode = qi.behospital_code
  9836. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  9837. AND t.hospitalId = t2.hospital_id
  9838. AND t2.is_deleted = 'N'
  9839. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9840. AND t3.is_deleted = 'N'
  9841. where 1=1
  9842. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  9843. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  9844. </if>
  9845. <if test="qcResultShortPageVO.checkStatus != null">
  9846. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9847. </if>
  9848. <if test="qcResultShortPageVO.mrStatus != null">
  9849. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9850. </if>
  9851. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9852. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9853. </if>
  9854. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9855. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9856. </if>
  9857. <if test="qcResultShortPageVO.chTimeStart != null ">
  9858. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9859. </if>
  9860. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9861. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9862. </if>
  9863. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9864. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9865. </if>
  9866. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9867. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9868. </if>
  9869. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9870. AND t.`level` = #{qcResultShortPageVO.level}
  9871. </if>
  9872. GROUP BY
  9873. t.behDeptId,
  9874. t.behDeptName,
  9875. t.doctorId,
  9876. t.doctorName
  9877. )f2
  9878. WHERE
  9879. f1.doctorId = f2.doctorId
  9880. AND f1.doctorName = f2.doctorName
  9881. </select>
  9882. <!--缺陷详情质控评分页导出-科室-->
  9883. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  9884. SELECT
  9885. f1.*,
  9886. f2.avgScore
  9887. FROM
  9888. (SELECT
  9889. t.*,
  9890. qi.score_res AS score,
  9891. qd.msg AS msg,
  9892. qc.NAME AS caseName
  9893. FROM
  9894. (SELECT DISTINCT
  9895. t1.hospital_id AS hospitalId,
  9896. t1.behospital_code AS behospitalCode,
  9897. t1.bed_code AS bedCode,
  9898. t1.LEVEL AS LEVEL,
  9899. t1.grade_type AS gradeType,
  9900. t1.score_res AS scoreRes,
  9901. t1.scoreBn AS scoreBn,
  9902. t1.NAME AS patName,
  9903. t1.medoupName,
  9904. t1.sex AS sex,
  9905. t1.beh_dept_id AS behDeptId,
  9906. t1.beh_dept_name AS behDeptName,
  9907. t1.doctor_id AS doctorId,
  9908. t1.doctor_name AS doctorName,
  9909. t1.beh_doctor_id AS behDoctorId,
  9910. t1.beh_doctor_name AS behDoctorName,
  9911. t1.director_doctor_id AS directorDoctorId,
  9912. t1.director_doctor_name AS directorDoctorName,
  9913. t1.birthday AS birthday,
  9914. t1.behospital_date AS behospitalDate,
  9915. t1.leave_hospital_date AS leaveHospitalDate,
  9916. t1.placefile_date AS placefileDate,
  9917. t1.gmt_create AS gradeTime,
  9918. t1.diagnose AS diagnose,
  9919. t1.ward_name AS wardName,
  9920. t1.file_code AS fileCode,
  9921. t1.checkStatus AS checkStatus,
  9922. t1.mrStatus AS mrStatus,
  9923. t1.chName AS chName,
  9924. t1.mrName AS mrName,
  9925. t1.chTime AS chTime,
  9926. t1.mrTime AS mrTime
  9927. FROM
  9928. (
  9929. SELECT DISTINCT
  9930. tt1.*
  9931. FROM
  9932. (SELECT
  9933. be.*,
  9934. t3.name as medoupName,
  9935. ifnull(mci.status,0) AS checkStatus,
  9936. ifnull(hm_mci.status,0) AS mrStatus,
  9937. mci.check_name as chName,
  9938. hm_mci.check_name as mrName,
  9939. mci.gmt_create as chTime,
  9940. e.score_res as scoreBn,
  9941. hm_mci.gmt_create as mrTime
  9942. FROM
  9943. (
  9944. SELECT DISTINCT
  9945. a.hospital_id,
  9946. a.behospital_code,
  9947. a.bed_code,
  9948. a.file_code,
  9949. b.LEVEL,
  9950. b.grade_type,
  9951. b.score_res,
  9952. a.NAME,
  9953. a.sex,
  9954. a.beh_dept_id,
  9955. a.beh_dept_name,
  9956. a.birthday,
  9957. a.behospital_date,
  9958. a.leave_hospital_date,
  9959. a.doctor_id,
  9960. a.doctor_name,
  9961. a.beh_doctor_id,
  9962. a.beh_doctor_name,
  9963. a.director_doctor_id,
  9964. a.director_doctor_name,
  9965. a.diagnose,
  9966. a.placefile_date,
  9967. a.ward_name,
  9968. b.gmt_create
  9969. FROM
  9970. med_behospital_info a,
  9971. med_qcresult_info b,
  9972. med_qcresult_detail c,
  9973. qc_cases_entry d,
  9974. sys_user_dept e
  9975. WHERE
  9976. a.is_deleted = 'N'
  9977. AND b.is_deleted = 'N'
  9978. AND c.is_deleted = 'N'
  9979. AND d.is_deleted = 'N'
  9980. AND e.is_deleted = 'N'
  9981. AND a.hospital_id = b.hospital_id
  9982. AND a.hospital_id = c.hospital_id
  9983. AND a.hospital_id = e.hospital_id
  9984. AND a.behospital_code = b.behospital_code
  9985. AND a.behospital_code = c.behospital_code
  9986. AND a.beh_dept_id = e.dept_id
  9987. AND c.cases_id = d.cases_id
  9988. AND c.cases_entry_id = d.id
  9989. AND a.qc_type_id != 0
  9990. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9991. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9992. </if>
  9993. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  9994. AND e.user_id = #{qcResultShortPageVO.userId}
  9995. </if>
  9996. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9997. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9998. </if>
  9999. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10000. <if test="qcResultShortPageVO.startDate != null ">
  10001. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10002. </if>
  10003. <if test="qcResultShortPageVO.endDate != null ">
  10004. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10005. </if>
  10006. </if>
  10007. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10008. <if test="qcResultShortPageVO.startDate != null ">
  10009. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10010. </if>
  10011. <if test="qcResultShortPageVO.endDate != null">
  10012. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10013. </if>
  10014. </if>
  10015. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10016. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10017. </if>
  10018. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  10019. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  10020. </if>
  10021. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10022. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10023. </if>
  10024. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10025. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10026. </if>
  10027. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10028. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10029. </if>
  10030. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10031. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  10032. </if>
  10033. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10034. AND b.`level` = #{qcResultShortPageVO.level}
  10035. </if>
  10036. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10037. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10038. </if>
  10039. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10040. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10041. </if>
  10042. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10043. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  10044. </if>
  10045. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  10046. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10047. </if>
  10048. <if test="qcResultShortPageVO.isReject != null">
  10049. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10050. </if>
  10051. <if test="qcResultShortPageVO.ruleType != null">
  10052. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10053. </if>
  10054. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10055. AND TIMESTAMPDIFF(
  10056. DAY,
  10057. DATE( a.behospital_date ),
  10058. DATE( a.leave_hospital_date ))> 30
  10059. </if>
  10060. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10061. AND TIMESTAMPDIFF(
  10062. DAY,
  10063. DATE( a.behospital_date ),
  10064. DATE( a.leave_hospital_date ))> 31
  10065. </if>
  10066. )be
  10067. left join med_check_info mci
  10068. on mci.is_deleted = 'N'
  10069. and mci.check_type = 0
  10070. and be.hospital_id = mci.hospital_id
  10071. and be.behospital_code = mci.behospital_code
  10072. left join med_check_info hm_mci
  10073. on hm_mci.is_deleted = 'N'
  10074. and hm_mci.check_type = 1
  10075. and be.hospital_id = hm_mci.hospital_id
  10076. and be.behospital_code = hm_mci.behospital_code
  10077. LEFT JOIN med_qcresult_cases e
  10078. on be.behospital_code = e.behospital_code
  10079. and be.hospital_id = e.hospital_id
  10080. AND e.is_deleted = 'N'
  10081. and e.cases_id = 243
  10082. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  10083. and be.hospital_id = t2.hospital_id
  10084. AND t2.is_deleted = 'N'
  10085. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  10086. AND t3.is_deleted = 'N'
  10087. )tt1
  10088. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10089. ,med_medical_record tt2
  10090. WHERE
  10091. tt2.is_deleted = 'N'
  10092. AND tt1.hospital_id = tt2.hospital_id
  10093. AND tt1.behospital_code = tt2.behospital_code
  10094. AND tt2.mode_id = 30
  10095. </if>
  10096. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10097. ,med_crisis_info tt2
  10098. WHERE
  10099. tt2.is_deleted = 'N'
  10100. AND tt1.hospital_id = tt2.hospital_id
  10101. AND tt1.behospital_code = tt2.behospital_code
  10102. </if>
  10103. ) t1
  10104. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10105. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10106. AND t1.behospital_code = t2.behospital_code
  10107. AND t2.is_deleted = 'N'
  10108. </if>
  10109. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10110. , med_home_page t2
  10111. , med_home_operation_info t3
  10112. WHERE t1.hospital_id = t2.hospital_id
  10113. AND t1.behospital_code = t2.behospital_code
  10114. AND t2.home_page_id = t3.home_page_id
  10115. AND t2.is_deleted = 'N'
  10116. AND t3.is_deleted = 'N'
  10117. </if>
  10118. ) t
  10119. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10120. AND t.hospitalId = qi.hospital_id
  10121. AND t.behospitalCode = qi.behospital_code
  10122. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10123. AND t.hospitalId = qd.hospital_id
  10124. AND t.behospitalCode = qd.behospital_code
  10125. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10126. AND qd.cases_id = qc.id
  10127. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10128. AND qd.cases_id = qce.cases_id
  10129. AND qd.cases_entry_id = qce.id
  10130. where 1=1
  10131. <if test="qcResultShortPageVO.checkStatus != null">
  10132. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10133. </if>
  10134. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  10135. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  10136. </if>
  10137. <if test="qcResultShortPageVO.mrStatus != null">
  10138. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10139. </if>
  10140. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10141. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10142. </if>
  10143. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10144. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10145. </if>
  10146. <if test="qcResultShortPageVO.chTimeStart != null ">
  10147. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10148. </if>
  10149. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10150. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10151. </if>
  10152. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10153. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10154. </if>
  10155. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10156. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10157. </if>
  10158. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10159. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10160. </if>
  10161. <if test="qcResultShortPageVO.casesEntryId != null ">
  10162. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10163. </if>
  10164. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10165. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10166. </if>
  10167. <if test="qcResultShortPageVO.casesId != null">
  10168. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10169. </if>
  10170. )f1,
  10171. (SELECT
  10172. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10173. t.behDeptId,
  10174. t.behDeptName,
  10175. t.doctorId,
  10176. t.doctorName
  10177. FROM
  10178. (SELECT DISTINCT
  10179. t1.hospital_id AS hospitalId,
  10180. t1.behospital_code AS behospitalCode,
  10181. t1.bed_code AS bedCode,
  10182. t1.LEVEL AS LEVEL,
  10183. t1.grade_type AS gradeType,
  10184. t1.score_res AS scoreRes,
  10185. t1.NAME AS NAME,
  10186. t1.medoupName,
  10187. t1.sex AS sex,
  10188. t1.beh_dept_id AS behDeptId,
  10189. t1.beh_dept_name AS behDeptName,
  10190. t1.doctor_id AS doctorId,
  10191. t1.doctor_name AS doctorName,
  10192. t1.beh_doctor_id AS behDoctorId,
  10193. t1.beh_doctor_name AS behDoctorName,
  10194. t1.director_doctor_id AS directorDoctorId,
  10195. t1.director_doctor_name AS directorDoctorName,
  10196. t1.birthday AS birthday,
  10197. t1.behospital_date AS behospitalDate,
  10198. t1.leave_hospital_date AS leaveHospitalDate,
  10199. t1.placefile_date AS placefileDate,
  10200. t1.gmt_create AS gradeTime,
  10201. t1.diagnose,
  10202. t1.ward_name AS wardName,
  10203. t2.age,
  10204. t1.file_code AS fileCode,
  10205. t1.checkStatus,
  10206. t1.mrStatus,
  10207. t1.chName,
  10208. t1.mrName,
  10209. t1.chTime,
  10210. t1.mrTime
  10211. FROM
  10212. (
  10213. SELECT DISTINCT
  10214. tt1.*
  10215. FROM
  10216. (SELECT
  10217. be.*,
  10218. t3.name as medoupName,
  10219. ifnull(mci.status,0) AS checkStatus,
  10220. ifnull(hm_mci.status,0) AS mrStatus,
  10221. mci.check_name as chName,
  10222. hm_mci.check_name as mrName,
  10223. mci.gmt_create as chTime,
  10224. hm_mci.gmt_create as mrTime
  10225. FROM
  10226. (
  10227. SELECT DISTINCT
  10228. a.hospital_id,
  10229. a.behospital_code,
  10230. a.bed_code,
  10231. a.file_code,
  10232. b.LEVEL,
  10233. b.grade_type,
  10234. b.score_res,
  10235. a.NAME,
  10236. a.sex,
  10237. a.beh_dept_id,
  10238. a.beh_dept_name,
  10239. a.birthday,
  10240. a.behospital_date,
  10241. a.leave_hospital_date,
  10242. a.doctor_id,
  10243. a.doctor_name,
  10244. a.beh_doctor_id,
  10245. a.beh_doctor_name,
  10246. a.director_doctor_id,
  10247. a.director_doctor_name,
  10248. a.diagnose,
  10249. a.placefile_date,
  10250. a.ward_name,
  10251. b.gmt_create
  10252. FROM
  10253. med_behospital_info a,
  10254. med_qcresult_info b,
  10255. med_qcresult_detail c,
  10256. qc_cases_entry d,
  10257. sys_user_dept e
  10258. WHERE
  10259. a.is_deleted = 'N'
  10260. AND b.is_deleted = 'N'
  10261. AND c.is_deleted = 'N'
  10262. AND d.is_deleted = 'N'
  10263. AND e.is_deleted = 'N'
  10264. AND a.hospital_id = b.hospital_id
  10265. AND a.hospital_id = c.hospital_id
  10266. AND a.hospital_id = e.hospital_id
  10267. AND a.behospital_code = b.behospital_code
  10268. AND a.behospital_code = c.behospital_code
  10269. AND a.beh_dept_id = e.dept_id
  10270. AND c.cases_id = d.cases_id
  10271. AND c.cases_entry_id = d.id
  10272. AND a.qc_type_id != 0
  10273. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10274. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10275. </if>
  10276. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10277. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10278. </if>
  10279. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10280. <if test="qcResultShortPageVO.startDate != null ">
  10281. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10282. </if>
  10283. <if test="qcResultShortPageVO.endDate != null ">
  10284. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10285. </if>
  10286. </if>
  10287. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10288. <if test="qcResultShortPageVO.startDate != null ">
  10289. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10290. </if>
  10291. <if test="qcResultShortPageVO.endDate != null">
  10292. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10293. </if>
  10294. </if>
  10295. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10296. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10297. </if>
  10298. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  10299. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  10300. </if>
  10301. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10302. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10303. </if>
  10304. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10305. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10306. </if>
  10307. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10308. AND b.`level` = #{qcResultShortPageVO.level}
  10309. </if>
  10310. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10311. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10312. </if>
  10313. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10314. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10315. </if>
  10316. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10317. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10318. </if>
  10319. <if test="qcResultShortPageVO.casesEntryId != null ">
  10320. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10321. </if>
  10322. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10323. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10324. </if>
  10325. <if test="qcResultShortPageVO.casesId != null">
  10326. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10327. </if>
  10328. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10329. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10330. </if>
  10331. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10332. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  10333. </if>
  10334. <if test="qcResultShortPageVO.isReject != null">
  10335. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10336. </if>
  10337. <if test="qcResultShortPageVO.ruleType != null">
  10338. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10339. </if>
  10340. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10341. AND TIMESTAMPDIFF(
  10342. DAY,
  10343. DATE( a.behospital_date ),
  10344. DATE( a.leave_hospital_date ))> 30
  10345. </if>
  10346. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10347. AND TIMESTAMPDIFF(
  10348. DAY,
  10349. DATE( a.behospital_date ),
  10350. DATE( a.leave_hospital_date ))> 31
  10351. </if>
  10352. )be
  10353. left join med_check_info mci
  10354. on mci.is_deleted = 'N'
  10355. and mci.check_type = 0
  10356. and be.hospital_id = mci.hospital_id
  10357. and be.behospital_code = mci.behospital_code
  10358. left join med_check_info hm_mci
  10359. on hm_mci.is_deleted = 'N'
  10360. and hm_mci.check_type = 1
  10361. and be.hospital_id = hm_mci.hospital_id
  10362. and be.behospital_code = hm_mci.behospital_code
  10363. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  10364. and be.hospital_id = t2.hospital_id
  10365. AND t2.is_deleted = 'N'
  10366. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  10367. AND t3.is_deleted = 'N'
  10368. )tt1
  10369. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10370. ,med_medical_record tt2
  10371. WHERE
  10372. tt2.is_deleted = 'N'
  10373. AND tt1.hospital_id = tt2.hospital_id
  10374. AND tt1.behospital_code = tt2.behospital_code
  10375. AND tt2.mode_id = 30
  10376. </if>
  10377. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10378. ,med_crisis_info tt2
  10379. WHERE
  10380. tt2.is_deleted = 'N'
  10381. AND tt1.hospital_id = tt2.hospital_id
  10382. AND tt1.behospital_code = tt2.behospital_code
  10383. </if>
  10384. ) t1
  10385. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10386. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10387. AND t1.behospital_code = t2.behospital_code
  10388. AND t2.is_deleted = 'N'
  10389. </if>
  10390. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10391. , med_home_page t2
  10392. , med_home_operation_info t3
  10393. WHERE t1.hospital_id = t2.hospital_id
  10394. AND t1.behospital_code = t2.behospital_code
  10395. AND t2.home_page_id = t3.home_page_id
  10396. AND t2.is_deleted = 'N'
  10397. AND t3.is_deleted = 'N'
  10398. </if>
  10399. ) t
  10400. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10401. AND t.hospitalId = qi.hospital_id
  10402. AND t.behospitalCode = qi.behospital_code
  10403. where 1=1
  10404. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  10405. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  10406. </if>
  10407. <if test="qcResultShortPageVO.checkStatus != null">
  10408. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10409. </if>
  10410. <if test="qcResultShortPageVO.mrStatus != null">
  10411. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10412. </if>
  10413. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10414. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10415. </if>
  10416. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10417. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10418. </if>
  10419. <if test="qcResultShortPageVO.chTimeStart != null ">
  10420. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10421. </if>
  10422. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10423. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10424. </if>
  10425. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10426. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10427. </if>
  10428. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10429. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10430. </if>
  10431. GROUP BY
  10432. t.behDeptId,
  10433. t.behDeptName,
  10434. t.doctorId,
  10435. t.doctorName
  10436. )f2
  10437. WHERE
  10438. f1.doctorId = f2.doctorId
  10439. AND f1.doctorName = f2.doctorName
  10440. AND f1.doctorName = f2.doctorName
  10441. </select>
  10442. <!-- 条目缺陷评分详情页导出-->
  10443. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  10444. SELECT * from(
  10445. SELECT
  10446. f1.*,
  10447. f2.avgScore
  10448. FROM
  10449. (SELECT
  10450. t.*,
  10451. qi.score_res AS score,
  10452. qd.msg AS msg,
  10453. qc.NAME AS caseName
  10454. FROM
  10455. (SELECT DISTINCT
  10456. t1.hospital_id AS hospitalId,
  10457. t1.behospital_code AS behospitalCode,
  10458. t1.bed_code AS bedCode,
  10459. t1.LEVEL AS LEVEL,
  10460. t1.grade_type AS gradeType,
  10461. t1.score_res AS scoreRes,
  10462. t1.scoreBn AS scoreBn,
  10463. t1.NAME AS patName,
  10464. t1.sex AS sex,
  10465. t1.beh_dept_id AS behDeptId,
  10466. t1.beh_dept_name AS behDeptName,
  10467. t1.doctor_id AS doctorId,
  10468. t1.doctor_name AS doctorName,
  10469. t1.beh_doctor_id AS behDoctorId,
  10470. t1.beh_doctor_name AS behDoctorName,
  10471. t1.director_doctor_id AS directorDoctorId,
  10472. t1.director_doctor_name AS directorDoctorName,
  10473. t1.birthday AS birthday,
  10474. t1.behospital_date AS behospitalDate,
  10475. t1.leave_hospital_date AS leaveHospitalDate,
  10476. t1.placefile_date AS placefileDate,
  10477. t1.gmt_create AS gradeTime,
  10478. t1.diagnose AS diagnose,
  10479. t1.ward_name AS wardName,
  10480. t1.file_code AS fileCode,
  10481. t1.checkStatus AS checkStatus,
  10482. t1.mrStatus AS mrStatus,
  10483. t1.chName AS chName,
  10484. t1.mrName AS mrName,
  10485. t1.chTime AS chTime,
  10486. t1.mrTime AS mrTime
  10487. FROM
  10488. (
  10489. SELECT DISTINCT
  10490. tt1.*
  10491. FROM
  10492. (SELECT
  10493. be.*,
  10494. ifnull(mci.status,0) AS checkStatus,
  10495. ifnull(hm_mci.status,0) AS mrStatus,
  10496. mci.check_name as chName,
  10497. hm_mci.check_name as mrName,
  10498. mci.gmt_create as chTime,
  10499. e.score_res as scoreBn,
  10500. hm_mci.gmt_create as mrTime
  10501. FROM
  10502. (
  10503. SELECT DISTINCT
  10504. a.hospital_id,
  10505. a.behospital_code,
  10506. a.bed_code,
  10507. a.file_code,
  10508. b.LEVEL,
  10509. b.grade_type,
  10510. b.score_res,
  10511. a.NAME,
  10512. a.sex,
  10513. a.beh_dept_id,
  10514. a.beh_dept_name,
  10515. a.birthday,
  10516. a.behospital_date,
  10517. a.leave_hospital_date,
  10518. a.doctor_id,
  10519. a.doctor_name,
  10520. a.beh_doctor_id,
  10521. a.beh_doctor_name,
  10522. a.director_doctor_id,
  10523. a.director_doctor_name,
  10524. a.diagnose,
  10525. a.placefile_date,
  10526. a.ward_name,
  10527. b.gmt_create
  10528. FROM
  10529. med_behospital_info a,
  10530. med_qcresult_info b,
  10531. med_qcresult_detail c,
  10532. qc_cases_entry d
  10533. WHERE
  10534. a.is_deleted = 'N'
  10535. AND b.is_deleted = 'N'
  10536. AND c.is_deleted = 'N'
  10537. AND d.is_deleted = 'N'
  10538. AND a.hospital_id = b.hospital_id
  10539. AND a.hospital_id = c.hospital_id
  10540. AND a.behospital_code = b.behospital_code
  10541. AND a.behospital_code = c.behospital_code
  10542. AND c.cases_id = d.cases_id
  10543. AND c.cases_entry_id = d.id
  10544. AND a.qc_type_id != 0
  10545. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10546. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10547. </if>
  10548. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10549. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10550. </if>
  10551. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10552. <if test="qcResultShortPageVO.startDate != null ">
  10553. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10554. </if>
  10555. <if test="qcResultShortPageVO.endDate != null ">
  10556. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10557. </if>
  10558. </if>
  10559. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10560. <if test="qcResultShortPageVO.startDate != null ">
  10561. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10562. </if>
  10563. <if test="qcResultShortPageVO.endDate != null">
  10564. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10565. </if>
  10566. </if>
  10567. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10568. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10569. </if>
  10570. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10571. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10572. </if>
  10573. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10574. AND b.`level` = #{qcResultShortPageVO.level}
  10575. </if>
  10576. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10577. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10578. </if>
  10579. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10580. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10581. </if>
  10582. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10583. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10584. </if>
  10585. <if test="qcResultShortPageVO.casesEntryId != null ">
  10586. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10587. </if>
  10588. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10589. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10590. </if>
  10591. <if test="qcResultShortPageVO.casesId != null">
  10592. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10593. </if>
  10594. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10595. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10596. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10597. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10598. </if>
  10599. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10600. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10601. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10602. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10603. </if>
  10604. <if test="qcResultShortPageVO.isReject != null">
  10605. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10606. </if>
  10607. <if test="qcResultShortPageVO.ruleType != null">
  10608. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10609. </if>
  10610. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10611. AND TIMESTAMPDIFF(
  10612. DAY,
  10613. DATE( a.behospital_date ),
  10614. DATE( a.leave_hospital_date ))> 30
  10615. </if>
  10616. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10617. AND TIMESTAMPDIFF(
  10618. DAY,
  10619. DATE( a.behospital_date ),
  10620. DATE( a.leave_hospital_date ))> 31
  10621. </if>
  10622. )be
  10623. left join med_check_info mci
  10624. on mci.is_deleted = 'N'
  10625. and mci.check_type = 0
  10626. and be.hospital_id = mci.hospital_id
  10627. and be.behospital_code = mci.behospital_code
  10628. left join med_check_info hm_mci
  10629. on hm_mci.is_deleted = 'N'
  10630. and hm_mci.check_type = 1
  10631. and be.hospital_id = hm_mci.hospital_id
  10632. and be.behospital_code = hm_mci.behospital_code
  10633. LEFT JOIN med_qcresult_cases e
  10634. on be.behospital_code = e.behospital_code
  10635. and be.hospital_id = e.hospital_id
  10636. AND e.is_deleted = 'N'
  10637. and e.cases_id = 243
  10638. )tt1
  10639. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10640. ,med_medical_record tt2
  10641. WHERE
  10642. tt2.is_deleted = 'N'
  10643. AND tt1.hospital_id = tt2.hospital_id
  10644. AND tt1.behospital_code = tt2.behospital_code
  10645. AND tt2.mode_id = 30
  10646. </if>
  10647. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10648. ,med_crisis_info tt2
  10649. WHERE
  10650. tt2.is_deleted = 'N'
  10651. AND tt1.hospital_id = tt2.hospital_id
  10652. AND tt1.behospital_code = tt2.behospital_code
  10653. </if>
  10654. ) t1
  10655. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10656. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10657. AND t1.behospital_code = t2.behospital_code
  10658. AND t2.is_deleted = 'N'
  10659. </if>
  10660. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10661. , med_home_page t2
  10662. , med_home_operation_info t3
  10663. WHERE t1.hospital_id = t2.hospital_id
  10664. AND t1.behospital_code = t2.behospital_code
  10665. AND t2.home_page_id = t3.home_page_id
  10666. AND t2.is_deleted = 'N'
  10667. AND t3.is_deleted = 'N'
  10668. </if>
  10669. ) t
  10670. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10671. AND t.hospitalId = qi.hospital_id
  10672. AND t.behospitalCode = qi.behospital_code
  10673. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10674. AND t.hospitalId = qd.hospital_id
  10675. AND t.behospitalCode = qd.behospital_code
  10676. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10677. AND qd.cases_id = qc.id
  10678. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10679. AND qd.cases_id = qce.cases_id
  10680. AND qd.cases_entry_id = qce.id
  10681. where 1=1
  10682. <if test="qcResultShortPageVO.checkStatus != null">
  10683. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10684. </if>
  10685. <if test="qcResultShortPageVO.mrStatus != null">
  10686. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10687. </if>
  10688. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10689. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10690. </if>
  10691. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10692. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10693. </if>
  10694. <if test="qcResultShortPageVO.chTimeStart != null ">
  10695. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10696. </if>
  10697. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10698. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10699. </if>
  10700. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10701. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10702. </if>
  10703. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10704. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10705. </if>
  10706. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10707. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10708. </if>
  10709. <if test="qcResultShortPageVO.casesEntryId != null ">
  10710. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10711. </if>
  10712. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10713. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10714. </if>
  10715. <if test="qcResultShortPageVO.casesId != null">
  10716. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10717. </if>
  10718. )f1,
  10719. (SELECT
  10720. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10721. t.behDeptId,
  10722. t.behDeptName
  10723. FROM
  10724. (SELECT DISTINCT
  10725. t1.hospital_id AS hospitalId,
  10726. t1.behospital_code AS behospitalCode,
  10727. t1.bed_code AS bedCode,
  10728. t1.LEVEL AS LEVEL,
  10729. t1.grade_type AS gradeType,
  10730. t1.score_res AS scoreRes,
  10731. t1.NAME AS NAME,
  10732. t1.sex AS sex,
  10733. t1.beh_dept_id AS behDeptId,
  10734. t1.beh_dept_name AS behDeptName,
  10735. t1.doctor_id AS doctorId,
  10736. t1.doctor_name AS doctorName,
  10737. t1.beh_doctor_id AS behDoctorId,
  10738. t1.beh_doctor_name AS behDoctorName,
  10739. t1.director_doctor_id AS directorDoctorId,
  10740. t1.director_doctor_name AS directorDoctorName,
  10741. t1.birthday AS birthday,
  10742. t1.behospital_date AS behospitalDate,
  10743. t1.leave_hospital_date AS leaveHospitalDate,
  10744. t1.placefile_date AS placefileDate,
  10745. t1.gmt_create AS gradeTime,
  10746. t1.diagnose,
  10747. t1.ward_name AS wardName,
  10748. t2.age,
  10749. t1.file_code AS fileCode,
  10750. t1.checkStatus,
  10751. t1.mrStatus,
  10752. t1.chName,
  10753. t1.mrName,
  10754. t1.chTime,
  10755. t1.mrTime
  10756. FROM
  10757. (
  10758. SELECT DISTINCT
  10759. tt1.*
  10760. FROM
  10761. (SELECT
  10762. be.*,
  10763. ifnull(mci.status,0) AS checkStatus,
  10764. ifnull(hm_mci.status,0) AS mrStatus,
  10765. mci.check_name as chName,
  10766. hm_mci.check_name as mrName,
  10767. mci.gmt_create as chTime,
  10768. hm_mci.gmt_create as mrTime
  10769. FROM
  10770. (
  10771. SELECT DISTINCT
  10772. a.hospital_id,
  10773. a.behospital_code,
  10774. a.bed_code,
  10775. a.file_code,
  10776. b.LEVEL,
  10777. b.grade_type,
  10778. b.score_res,
  10779. a.NAME,
  10780. a.sex,
  10781. a.beh_dept_id,
  10782. a.beh_dept_name,
  10783. a.birthday,
  10784. a.behospital_date,
  10785. a.leave_hospital_date,
  10786. a.doctor_id,
  10787. a.doctor_name,
  10788. a.beh_doctor_id,
  10789. a.beh_doctor_name,
  10790. a.director_doctor_id,
  10791. a.director_doctor_name,
  10792. a.diagnose,
  10793. a.placefile_date,
  10794. a.ward_name,
  10795. b.gmt_create
  10796. FROM
  10797. med_behospital_info a,
  10798. med_qcresult_info b,
  10799. med_qcresult_detail c,
  10800. qc_cases_entry d
  10801. WHERE
  10802. a.is_deleted = 'N'
  10803. AND b.is_deleted = 'N'
  10804. AND c.is_deleted = 'N'
  10805. AND d.is_deleted = 'N'
  10806. AND a.hospital_id = b.hospital_id
  10807. AND a.hospital_id = c.hospital_id
  10808. AND a.behospital_code = b.behospital_code
  10809. AND a.behospital_code = c.behospital_code
  10810. AND c.cases_id = d.cases_id
  10811. AND c.cases_entry_id = d.id
  10812. AND a.qc_type_id != 0
  10813. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10814. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10815. </if>
  10816. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10817. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10818. </if>
  10819. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10820. <if test="qcResultShortPageVO.startDate != null ">
  10821. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10822. </if>
  10823. <if test="qcResultShortPageVO.endDate != null ">
  10824. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10825. </if>
  10826. </if>
  10827. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10828. <if test="qcResultShortPageVO.startDate != null ">
  10829. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10830. </if>
  10831. <if test="qcResultShortPageVO.endDate != null">
  10832. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10833. </if>
  10834. </if>
  10835. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10836. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10837. </if>
  10838. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10839. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10840. </if>
  10841. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10842. AND b.`level` = #{qcResultShortPageVO.level}
  10843. </if>
  10844. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10845. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10846. </if>
  10847. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10848. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10849. </if>
  10850. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10851. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10852. </if>
  10853. <if test="qcResultShortPageVO.casesEntryId != null ">
  10854. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10855. </if>
  10856. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10857. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10858. </if>
  10859. <if test="qcResultShortPageVO.casesId != null">
  10860. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10861. </if>
  10862. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10863. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10864. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10865. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10866. </if>
  10867. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10868. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10869. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10870. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10871. </if>
  10872. <if test="qcResultShortPageVO.isReject != null">
  10873. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10874. </if>
  10875. <if test="qcResultShortPageVO.ruleType != null">
  10876. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10877. </if>
  10878. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10879. AND TIMESTAMPDIFF(
  10880. DAY,
  10881. DATE( a.behospital_date ),
  10882. DATE( a.leave_hospital_date ))> 30
  10883. </if>
  10884. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10885. AND TIMESTAMPDIFF(
  10886. DAY,
  10887. DATE( a.behospital_date ),
  10888. DATE( a.leave_hospital_date ))> 31
  10889. </if>
  10890. )be
  10891. left join med_check_info mci
  10892. on mci.is_deleted = 'N'
  10893. and mci.check_type = 0
  10894. and be.hospital_id = mci.hospital_id
  10895. and be.behospital_code = mci.behospital_code
  10896. left join med_check_info hm_mci
  10897. on hm_mci.is_deleted = 'N'
  10898. and hm_mci.check_type = 1
  10899. and be.hospital_id = hm_mci.hospital_id
  10900. and be.behospital_code = hm_mci.behospital_code
  10901. )tt1
  10902. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10903. ,med_medical_record tt2
  10904. WHERE
  10905. tt2.is_deleted = 'N'
  10906. AND tt1.hospital_id = tt2.hospital_id
  10907. AND tt1.behospital_code = tt2.behospital_code
  10908. AND tt2.mode_id = 30
  10909. </if>
  10910. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10911. ,med_crisis_info tt2
  10912. WHERE
  10913. tt2.is_deleted = 'N'
  10914. AND tt1.hospital_id = tt2.hospital_id
  10915. AND tt1.behospital_code = tt2.behospital_code
  10916. </if>
  10917. ) t1
  10918. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10919. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10920. AND t1.behospital_code = t2.behospital_code
  10921. AND t2.is_deleted = 'N'
  10922. </if>
  10923. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10924. , med_home_page t2
  10925. , med_home_operation_info t3
  10926. WHERE t1.hospital_id = t2.hospital_id
  10927. AND t1.behospital_code = t2.behospital_code
  10928. AND t2.home_page_id = t3.home_page_id
  10929. AND t2.is_deleted = 'N'
  10930. AND t3.is_deleted = 'N'
  10931. </if>
  10932. ) t
  10933. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10934. AND t.hospitalId = qi.hospital_id
  10935. AND t.behospitalCode = qi.behospital_code
  10936. where 1=1
  10937. <if test="qcResultShortPageVO.checkStatus != null">
  10938. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10939. </if>
  10940. <if test="qcResultShortPageVO.mrStatus != null">
  10941. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10942. </if>
  10943. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10944. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10945. </if>
  10946. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10947. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10948. </if>
  10949. <if test="qcResultShortPageVO.chTimeStart != null ">
  10950. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10951. </if>
  10952. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10953. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10954. </if>
  10955. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10956. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10957. </if>
  10958. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10959. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10960. </if>
  10961. GROUP BY
  10962. t.behDeptId,
  10963. t.behDeptName
  10964. )f2
  10965. WHERE
  10966. f1.behDeptId = f2.behDeptId
  10967. AND f1.behDeptName = f2.behDeptName
  10968. )m
  10969. </select>
  10970. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  10971. <result column="deptName" property="deptName"/>
  10972. <result column="deptId" property="deptId"/>
  10973. <result column="doctorGroup" property="doctorGroup"/>
  10974. <result column="doctorName" property="doctorName"/>
  10975. <result column="entry_2658_num" property="entry_2658_num"/>
  10976. <result column="entry_2686_num" property="entry_2686_num"/>
  10977. <result column="entry_2657_num" property="entry_2657_num"/>
  10978. <result column="entry_3010_num" property="entry_3010_num"/>
  10979. <result column="entry_2655_num" property="entry_2655_num"/>
  10980. <result column="entry_2654_num" property="entry_2654_num"/>
  10981. <result column="entry_2852_num" property="entry_2852_num"/>
  10982. <result column="entry_2287_num" property="entry_2287_num"/>
  10983. <result column="entry_3025_num" property="entry_3025_num"/>
  10984. <result column="entry_2170_num" property="entry_2170_num"/>
  10985. <result column="entry_2930_num" property="entry_2930_num"/>
  10986. <result column="entry_2900_num" property="entry_2900_num"/>
  10987. <result column="entry_2229_num" property="entry_2229_num"/>
  10988. <result column="entry_2217_num" property="entry_2217_num"/>
  10989. <result column="entry_2218_num" property="entry_2218_num"/>
  10990. <result column="entry_2220_num" property="entry_2220_num"/>
  10991. <result column="entry_2486_num" property="entry_2486_num"/>
  10992. <result column="entry_3063_num" property="entry_3063_num"/>
  10993. <result column="entry_3062_num" property="entry_3062_num"/>
  10994. <result column="entry_2495_num" property="entry_2495_num"/>
  10995. </resultMap>
  10996. <!-- 病历稽查表-->
  10997. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  10998. SELECT
  10999. a.beh_dept_id AS deptId,
  11000. a.beh_dept_name AS deptName,
  11001. a.doctor_name as doctorGroup,
  11002. a.doctor_name as doctorName,
  11003. sum(c.cases_entry_id = 2658) as entry_2658_num,
  11004. sum(c.cases_entry_id = 2686) as entry_2686_num,
  11005. sum(c.cases_entry_id = 2657) as entry_2657_num,
  11006. sum(c.cases_entry_id = 3010) as entry_3010_num,
  11007. sum(c.cases_entry_id = 2655) as entry_2655_num,
  11008. sum(c.cases_entry_id = 2654) as entry_2654_num,
  11009. sum(c.cases_entry_id = 2852) as entry_2852_num,
  11010. sum(c.cases_entry_id = 2287) as entry_2287_num,
  11011. sum(c.cases_entry_id = 3025) as entry_3025_num,
  11012. sum(c.cases_entry_id = 2170) as entry_2170_num,
  11013. sum(c.cases_entry_id = 2930) as entry_2930_num,
  11014. sum(c.cases_entry_id = 2900) as entry_2900_num,
  11015. sum(c.cases_entry_id = 2229) as entry_2229_num,
  11016. sum(c.cases_entry_id = 2217) as entry_2217_num,
  11017. sum(c.cases_entry_id = 2218) as entry_2218_num,
  11018. sum(c.cases_entry_id = 2220) as entry_2220_num,
  11019. sum(c.cases_entry_id = 2486) as entry_2486_num,
  11020. sum(c.cases_entry_id = 3063) as entry_3063_num,
  11021. sum(c.cases_entry_id = 3062) as entry_3062_num,
  11022. sum(c.cases_entry_id = 2495) as entry_2495_num
  11023. FROM
  11024. med_behospital_info a,
  11025. med_qcresult_info b,
  11026. med_qcresult_detail c,
  11027. qc_cases_entry d,
  11028. bas_doctor_info e
  11029. WHERE
  11030. a.is_deleted = 'N'
  11031. AND b.is_deleted = 'N'
  11032. AND c.is_deleted = 'N'
  11033. AND d.is_deleted = 'N'
  11034. AND e.is_deleted = 'N'
  11035. AND a.hospital_id = b.hospital_id
  11036. AND a.hospital_id = c.hospital_id
  11037. AND a.hospital_id = e.hospital_id
  11038. AND a.behospital_code = b.behospital_code
  11039. AND a.behospital_code = c.behospital_code
  11040. AND a.beh_dept_id = e.dept_id
  11041. AND c.cases_entry_id = d.id
  11042. and a.doctor_id=e.doctor_id
  11043. and e.group_id is not NULL
  11044. AND LENGTH(e.group_id)>0
  11045. AND a.qc_type_id != 0
  11046. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11047. and a.is_placefile = #{filterVO.isPlacefile}
  11048. </if>
  11049. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11050. AND a.hospital_id = #{filterVO.hospitalId}
  11051. </if>
  11052. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11053. <if test="filterVO.startDate != null ">
  11054. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11055. </if>
  11056. <if test="filterVO.endDate != null ">
  11057. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11058. </if>
  11059. </if>
  11060. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11061. <if test="filterVO.startDate != null ">
  11062. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11063. </if>
  11064. <if test="filterVO.endDate != null ">
  11065. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11066. </if>
  11067. </if>
  11068. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11069. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  11070. </if>
  11071. GROUP BY
  11072. a.beh_dept_id,
  11073. e.group_id,
  11074. a.doctor_id
  11075. </select>
  11076. <!-- 病历稽查表-科室-->
  11077. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  11078. SELECT
  11079. a.beh_dept_id AS deptId,
  11080. a.beh_dept_name AS deptName,
  11081. a.doctor_name as doctorName,
  11082. a.doctor_name as doctorGroup,
  11083. sum(c.cases_entry_id = 2658) as entry_2658_num,
  11084. sum(c.cases_entry_id = 2686) as entry_2686_num,
  11085. sum(c.cases_entry_id = 2657) as entry_2657_num,
  11086. sum(c.cases_entry_id = 3010) as entry_3010_num,
  11087. sum(c.cases_entry_id = 2655) as entry_2655_num,
  11088. sum(c.cases_entry_id = 2654) as entry_2654_num,
  11089. sum(c.cases_entry_id = 2852) as entry_2852_num,
  11090. sum(c.cases_entry_id = 2287) as entry_2287_num,
  11091. sum(c.cases_entry_id = 3025) as entry_3025_num,
  11092. sum(c.cases_entry_id = 2170) as entry_2170_num,
  11093. sum(c.cases_entry_id = 2930) as entry_2930_num,
  11094. sum(c.cases_entry_id = 2900) as entry_2900_num,
  11095. sum(c.cases_entry_id = 2229) as entry_2229_num,
  11096. sum(c.cases_entry_id = 2217) as entry_2217_num,
  11097. sum(c.cases_entry_id = 2218) as entry_2218_num,
  11098. sum(c.cases_entry_id = 2220) as entry_2220_num,
  11099. sum(c.cases_entry_id = 2486) as entry_2486_num,
  11100. sum(c.cases_entry_id = 3063) as entry_3063_num,
  11101. sum(c.cases_entry_id = 3062) as entry_3062_num,
  11102. sum(c.cases_entry_id = 2495) as entry_2495_num
  11103. FROM
  11104. med_behospital_info a,
  11105. med_qcresult_info b,
  11106. med_qcresult_detail c,
  11107. qc_cases_entry d,
  11108. bas_doctor_info e,
  11109. sys_user_dept f
  11110. WHERE
  11111. a.is_deleted = 'N'
  11112. AND b.is_deleted = 'N'
  11113. AND c.is_deleted = 'N'
  11114. AND d.is_deleted = 'N'
  11115. AND e.is_deleted = 'N'
  11116. AND f.is_deleted = 'N'
  11117. AND a.hospital_id = b.hospital_id
  11118. AND a.hospital_id = c.hospital_id
  11119. AND a.hospital_id = e.hospital_id
  11120. AND a.hospital_id = f.hospital_id
  11121. AND a.behospital_code = b.behospital_code
  11122. AND a.behospital_code = c.behospital_code
  11123. AND a.beh_dept_id = f.dept_id
  11124. AND c.cases_entry_id = d.id
  11125. and a.doctor_id=e.doctor_id
  11126. and e.group_id is not NULL
  11127. AND LENGTH(e.group_id)>0
  11128. AND a.qc_type_id != 0
  11129. <if test="filterVO.userId!=null">
  11130. AND f.user_id = #{filterVO.userId}
  11131. </if>
  11132. <if test="filterVO.name != null and filterVO.name != ''">
  11133. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11134. </if>
  11135. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11136. and a.is_placefile = #{filterVO.isPlacefile}
  11137. </if>
  11138. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11139. AND a.hospital_id = #{filterVO.hospitalId}
  11140. </if>
  11141. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11142. <if test="filterVO.startDate != null ">
  11143. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11144. </if>
  11145. <if test="filterVO.endDate != null ">
  11146. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11147. </if>
  11148. </if>
  11149. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11150. <if test="filterVO.startDate != null ">
  11151. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11152. </if>
  11153. <if test="filterVO.endDate != null ">
  11154. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11155. </if>
  11156. </if>
  11157. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11158. AND a.beh_dept_name = #{filterVO.deptName}
  11159. </if>
  11160. GROUP BY
  11161. a.beh_dept_id,
  11162. e.group_id,
  11163. a.doctor_name
  11164. </select>
  11165. <!-- 病历稽查表最新sql、id&&name-->
  11166. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  11167. SELECT
  11168. d.id,
  11169. d.name
  11170. from
  11171. qc_cases_entry d
  11172. where
  11173. 1=1
  11174. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  11175. and d.id in
  11176. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  11177. '${item}'
  11178. </foreach>
  11179. </if>
  11180. </select>
  11181. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  11182. <result column="deptName" property="deptName"/>
  11183. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  11184. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  11185. <result column="doctorName" property="doctorName"/>
  11186. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  11187. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  11188. <result column="RYJLW_24" property="ryjlw_24"/>
  11189. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  11190. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  11191. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  11192. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  11193. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  11194. <result column="QJJLW_6H" property="qjjlw_6h"/>
  11195. <result column="HZJLW_24H" property="hzjlw_24h"/>
  11196. <result column="SQTLXJW" property="sqtlxjw"/>
  11197. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  11198. <result column="XHSCW_30M" property="xhscw_30m"/>
  11199. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  11200. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  11201. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  11202. <result column="ZKJLW_24" property="zkjlw_24"/>
  11203. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  11204. <result column="SXHWJL" property="sxhwjl"/>
  11205. <result column="SXPJW_24" property="sxpjw_24"/>
  11206. <result column="WJZWJL" property="wjzwjl"/>
  11207. <result column="WYWWCXJ" property="wywwcxj"/>
  11208. </collection>
  11209. </collection>
  11210. </resultMap>
  11211. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  11212. <result column="deptName" property="deptName"/>
  11213. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  11214. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  11215. <result column="doctorGroup" property="doctorGroup"/>
  11216. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  11217. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  11218. <result column="doctorName" property="doctorName"/>
  11219. <result column="RYJLW_24" property="ryjlw_24"/>
  11220. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  11221. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  11222. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  11223. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  11224. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  11225. <result column="QJJLW_6H" property="qjjlw_6h"/>
  11226. <result column="HZJLW_24H" property="hzjlw_24h"/>
  11227. <result column="SQTLXJW" property="sqtlxjw"/>
  11228. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  11229. <result column="XHSCW_30M" property="xhscw_30m"/>
  11230. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  11231. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  11232. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  11233. <result column="ZKJLW_24" property="zkjlw_24"/>
  11234. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  11235. <result column="SXHWJL" property="sxhwjl"/>
  11236. <result column="SXPJW_24" property="sxpjw_24"/>
  11237. <result column="WJZWJL" property="wjzwjl"/>
  11238. <result column="WYWWCXJ" property="wywwcxj"/>
  11239. </collection>
  11240. </collection>
  11241. </resultMap>
  11242. <!-- 病历稽查表最新导出-->
  11243. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  11244. SELECT
  11245. a.beh_dept_id AS deptId,
  11246. a.beh_dept_name AS deptName,
  11247. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  11248. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  11249. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  11250. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  11251. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  11252. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  11253. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  11254. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  11255. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  11256. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  11257. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  11258. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  11259. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  11260. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  11261. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  11262. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  11263. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  11264. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  11265. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  11266. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  11267. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  11268. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  11269. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  11270. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  11271. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  11272. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  11273. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  11274. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  11275. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  11276. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  11277. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  11278. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  11279. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  11280. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  11281. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  11282. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  11283. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  11284. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  11285. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  11286. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  11287. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  11288. FROM
  11289. med_behospital_info a,
  11290. med_qcresult_info b,
  11291. med_qcresult_detail c,
  11292. qc_cases_entry d,
  11293. bas_doctor_info e
  11294. WHERE
  11295. a.is_deleted = 'N'
  11296. AND b.is_deleted = 'N'
  11297. AND c.is_deleted = 'N'
  11298. AND d.is_deleted = 'N'
  11299. AND e.is_deleted = 'N'
  11300. AND a.hospital_id = b.hospital_id
  11301. AND a.hospital_id = c.hospital_id
  11302. AND a.hospital_id = e.hospital_id
  11303. AND a.behospital_code = b.behospital_code
  11304. AND a.behospital_code = c.behospital_code
  11305. AND a.beh_dept_id = e.dept_id
  11306. AND c.cases_entry_id = d.id
  11307. and a.doctor_id=e.doctor_id
  11308. and e.group_id is not NULL
  11309. AND LENGTH(e.group_id)>0
  11310. AND a.qc_type_id != 0
  11311. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11312. and a.is_placefile = #{filterVO.isPlacefile}
  11313. </if>
  11314. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11315. AND a.hospital_id = #{filterVO.hospitalId}
  11316. </if>
  11317. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11318. <if test="filterVO.startDate != null ">
  11319. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11320. </if>
  11321. <if test="filterVO.endDate != null ">
  11322. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11323. </if>
  11324. </if>
  11325. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11326. <if test="filterVO.startDate != null ">
  11327. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11328. </if>
  11329. <if test="filterVO.endDate != null ">
  11330. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11331. </if>
  11332. </if>
  11333. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11334. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  11335. </if>
  11336. GROUP BY
  11337. a.beh_dept_id,
  11338. e.group_id
  11339. </select>
  11340. <!-- 病历稽查表最新导出-->
  11341. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  11342. SELECT
  11343. a.beh_dept_id AS deptId,
  11344. a.beh_dept_name AS deptName,
  11345. a.doctor_name as doctorGroup,
  11346. a.doctor_name as doctorName,
  11347. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  11348. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  11349. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  11350. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  11351. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  11352. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  11353. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  11354. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  11355. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  11356. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  11357. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  11358. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  11359. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  11360. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  11361. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  11362. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  11363. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  11364. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  11365. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  11366. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  11367. FROM
  11368. med_behospital_info a,
  11369. med_qcresult_info b,
  11370. med_qcresult_detail c,
  11371. qc_cases_entry d,
  11372. bas_doctor_info e,
  11373. sys_user_dept f
  11374. WHERE
  11375. a.is_deleted = 'N'
  11376. AND b.is_deleted = 'N'
  11377. AND c.is_deleted = 'N'
  11378. AND d.is_deleted = 'N'
  11379. AND e.is_deleted = 'N'
  11380. AND f.is_deleted = 'N'
  11381. AND a.hospital_id = b.hospital_id
  11382. AND a.hospital_id = c.hospital_id
  11383. AND a.hospital_id = e.hospital_id
  11384. AND a.hospital_id = f.hospital_id
  11385. AND a.behospital_code = b.behospital_code
  11386. AND a.behospital_code = c.behospital_code
  11387. AND a.beh_dept_id = f.dept_id
  11388. AND c.cases_entry_id = d.id
  11389. and a.doctor_id=e.doctor_id
  11390. and e.group_id is not NULL
  11391. AND LENGTH(e.group_id)>0
  11392. AND a.qc_type_id != 0
  11393. <if test="filterVO.userId!=null">
  11394. AND f.user_id = #{filterVO.userId}
  11395. </if>
  11396. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  11397. and a.is_placefile = #{filterVO.isPlacefile}
  11398. </if>
  11399. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  11400. AND a.hospital_id = #{filterVO.hospitalId}
  11401. </if>
  11402. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  11403. <if test="filterVO.startDate != null ">
  11404. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  11405. </if>
  11406. <if test="filterVO.endDate != null ">
  11407. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  11408. </if>
  11409. </if>
  11410. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  11411. <if test="filterVO.startDate != null ">
  11412. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  11413. </if>
  11414. <if test="filterVO.endDate != null ">
  11415. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  11416. </if>
  11417. </if>
  11418. <if test="filterVO.name != null and filterVO.name != ''">
  11419. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  11420. </if>
  11421. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  11422. AND a.beh_dept_name = #{filterVO.deptName}
  11423. </if>
  11424. GROUP BY
  11425. a.beh_dept_id,
  11426. e.group_id,
  11427. a.doctor_name
  11428. </select>
  11429. <!-- 未整改病历统计-->
  11430. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11431. SELECT
  11432. a.beh_dept_id AS deptId,
  11433. a.beh_dept_name AS deptName,
  11434. d.id AS casesEntryId,
  11435. d.NAME AS casesEntryName,
  11436. count(*) AS casesEntryNum
  11437. FROM
  11438. med_behospital_info a,
  11439. med_qcresult_info b,
  11440. med_qcresult_detail c,
  11441. qc_cases_entry d
  11442. WHERE
  11443. a.is_deleted = 'N'
  11444. AND b.is_deleted = 'N'
  11445. AND c.is_deleted = 'N'
  11446. AND d.is_deleted = 'N'
  11447. AND a.hospital_id = b.hospital_id
  11448. AND a.hospital_id = c.hospital_id
  11449. AND a.behospital_code = b.behospital_code
  11450. AND a.behospital_code = c.behospital_code
  11451. AND c.cases_entry_id = d.id
  11452. AND a.qc_type_id != 0
  11453. <if test="isPlacefile != null and isPlacefile != ''">
  11454. and a.is_placefile = #{isPlacefile}
  11455. </if>
  11456. <if test="hospitalId != null and hospitalId != ''">
  11457. AND a.hospital_id = #{hospitalId}
  11458. </if>
  11459. <if test="isPlacefile != null and isPlacefile == 0">
  11460. <if test="startDate != null ">
  11461. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11462. </if>
  11463. <if test="endDate != null ">
  11464. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11465. </if>
  11466. </if>
  11467. <if test="isPlacefile != null and isPlacefile == 1">
  11468. <if test="startDate != null ">
  11469. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11470. </if>
  11471. <if test="endDate != null ">
  11472. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11473. </if>
  11474. </if>
  11475. <if test="deptName != null and deptName != ''">
  11476. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  11477. </if>
  11478. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11479. AND c.cases_entry_id IN
  11480. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11481. #{item}
  11482. </foreach>
  11483. </if>
  11484. GROUP BY
  11485. a.beh_dept_id,
  11486. a.beh_dept_name,
  11487. c.cases_entry_id,
  11488. d.NAME
  11489. </select>
  11490. <!-- 未整改病历统计-科室-->
  11491. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  11492. SELECT
  11493. a.beh_dept_id AS deptId,
  11494. a.beh_dept_name AS deptName,
  11495. a.doctor_id as doctorId,
  11496. a.doctor_name as doctorName,
  11497. d.id AS casesEntryId,
  11498. d.NAME AS casesEntryName,
  11499. count(*) AS casesEntryNum
  11500. FROM
  11501. med_behospital_info a,
  11502. med_qcresult_info b,
  11503. med_qcresult_detail c,
  11504. qc_cases_entry d,
  11505. sys_user_dept f
  11506. WHERE
  11507. a.is_deleted = 'N'
  11508. AND b.is_deleted = 'N'
  11509. AND c.is_deleted = 'N'
  11510. AND d.is_deleted = 'N'
  11511. AND f.is_deleted = 'N'
  11512. AND a.hospital_id = b.hospital_id
  11513. AND a.hospital_id = c.hospital_id
  11514. AND a.hospital_id = f.hospital_id
  11515. AND a.behospital_code = b.behospital_code
  11516. AND a.behospital_code = c.behospital_code
  11517. AND a.beh_dept_id = f.dept_id
  11518. AND c.cases_entry_id = d.id
  11519. AND a.qc_type_id != 0
  11520. <if test="userId!=null">
  11521. AND f.user_id = #{userId}
  11522. </if>
  11523. <if test="isPlacefile != null and isPlacefile != ''">
  11524. and a.is_placefile = #{isPlacefile}
  11525. </if>
  11526. <if test="hospitalId != null and hospitalId != ''">
  11527. AND a.hospital_id = #{hospitalId}
  11528. </if>
  11529. <if test="isPlacefile != null and isPlacefile == 0">
  11530. <if test="startDate != null ">
  11531. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11532. </if>
  11533. <if test="endDate != null ">
  11534. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11535. </if>
  11536. </if>
  11537. <if test="isPlacefile != null and isPlacefile == 1">
  11538. <if test="startDate != null ">
  11539. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11540. </if>
  11541. <if test="endDate != null ">
  11542. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11543. </if>
  11544. </if>
  11545. <if test="deptName != null and deptName != ''">
  11546. AND a.beh_dept_name= #{deptName}
  11547. </if>
  11548. <if test="doctorName != null and doctorName != ''">
  11549. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11550. </if>
  11551. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11552. AND c.cases_entry_id IN
  11553. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11554. #{item}
  11555. </foreach>
  11556. </if>
  11557. GROUP BY
  11558. a.doctor_id,
  11559. a.doctor_name,
  11560. c.cases_entry_id,
  11561. d.NAME
  11562. </select>
  11563. <!-- 不合格/合格数病历号(内页)科室-->
  11564. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  11565. SELECT t.*
  11566. FROM
  11567. (SELECT DISTINCT
  11568. t1.hospital_id AS hospitalId,
  11569. t1.behospital_code AS behospitalCode,
  11570. t1.bed_code AS bedCode,
  11571. t1.LEVEL AS LEVEL,
  11572. t1.grade_type AS gradeType,
  11573. t1.score_res AS scoreRes,
  11574. t1.scoreBn,
  11575. t1.NAME AS NAME,
  11576. t1.sex AS sex,
  11577. t1.medoupName,
  11578. t1.beh_dept_id AS behDeptId,
  11579. t1.beh_dept_name AS behDeptName,
  11580. t1.doctor_id AS doctorId,
  11581. t1.doctor_name AS doctorName,
  11582. t1.beh_doctor_id AS behDoctorId,
  11583. t1.beh_doctor_name AS behDoctorName,
  11584. t1.director_doctor_id AS directorDoctorId,
  11585. t1.director_doctor_name AS directorDoctorName,
  11586. t1.birthday AS birthday,
  11587. t1.behospital_date AS behospitalDate,
  11588. t1.leave_hospital_date AS leaveHospitalDate,
  11589. t1.placefile_date AS placefileDate,
  11590. t1.gmt_create AS gradeTime,
  11591. t1.diagnose,
  11592. t1.ward_name AS wardName,
  11593. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11594. t1.file_code AS fileCode,
  11595. t1.checkStatus,
  11596. t1.mrStatus,
  11597. t1.chName,
  11598. t1.mrName,
  11599. t1.chTime,
  11600. t1.mrTime
  11601. FROM
  11602. (SELECT
  11603. be.*,
  11604. t3.name as medoupName,
  11605. b.LEVEL,
  11606. b.grade_type,
  11607. b.score_res,
  11608. b.gmt_create,
  11609. ifnull(mci.status,0) AS checkStatus,
  11610. ifnull(hm_mci.status,0) AS mrStatus,
  11611. mci.check_name as chName,
  11612. hm_mci.check_name as mrName,
  11613. mci.gmt_create as chTime,
  11614. hm_mci.gmt_create as mrTime
  11615. FROM
  11616. (
  11617. SELECT DISTINCT
  11618. a.hospital_id,
  11619. a.behospital_code,
  11620. a.bed_code,
  11621. a.file_code,
  11622. e.score_res as scoreBn,
  11623. a.NAME,
  11624. a.sex,
  11625. a.beh_dept_id,
  11626. a.beh_dept_name,
  11627. a.birthday,
  11628. a.behospital_date,
  11629. a.leave_hospital_date,
  11630. a.doctor_id,
  11631. a.doctor_name,
  11632. a.beh_doctor_id,
  11633. a.beh_doctor_name,
  11634. a.director_doctor_id,
  11635. a.director_doctor_name,
  11636. a.diagnose,
  11637. a.placefile_date,
  11638. a.ward_name
  11639. FROM
  11640. med_behospital_info a,
  11641. sys_user_dept c,
  11642. med_qcresult_cases e
  11643. WHERE
  11644. a.is_deleted = 'N'
  11645. AND c.is_deleted = 'N'
  11646. AND e.is_deleted = 'N'
  11647. AND a.hospital_id = c.hospital_id
  11648. AND a.hospital_id = e.hospital_id
  11649. AND a.beh_dept_id = c.dept_id
  11650. AND a.behospital_code = e.behospital_code
  11651. AND a.qc_type_id != 0
  11652. AND e.cases_id = 243
  11653. <if test="userId!=null">
  11654. AND c.user_id = #{userId}
  11655. </if>
  11656. <if test="deptName != null and deptName != ''">
  11657. and a.beh_dept_name = #{deptName}
  11658. </if>
  11659. <if test="deptClass != null and deptClass != ''">
  11660. and a.beh_dept_id = #{deptClass}
  11661. </if>
  11662. <if test="deptId != null and deptId != ''">
  11663. and a.beh_dept_id = #{deptId}
  11664. </if>
  11665. <if test="titleName != null and titleName != '' ">
  11666. <if test="titleName == '不合格数'">
  11667. AND e.`level`='不合格'
  11668. </if>
  11669. <if test="titleName == '合格数'">
  11670. AND e.`level`='合格'
  11671. </if>
  11672. </if>
  11673. <if test="isPlacefile != null and isPlacefile != ''">
  11674. and a.is_placefile = #{isPlacefile}
  11675. </if>
  11676. <if test="doctorId != null and doctorId != ''">
  11677. AND a.doctor_id = #{doctorId}
  11678. </if>
  11679. <if test="doctorName != null and doctorName != ''">
  11680. AND a.doctor_name = #{doctorName}
  11681. </if>
  11682. <if test="hospitalId != null and hospitalId != ''">
  11683. AND a.hospital_id = #{hospitalId}
  11684. </if>
  11685. <if test="isPlacefile != null and isPlacefile == 0">
  11686. <if test="startDate != null ">
  11687. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11688. </if>
  11689. <if test="endDate != null ">
  11690. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11691. </if>
  11692. </if>
  11693. <if test="isPlacefile != null and isPlacefile == 1">
  11694. <if test="startDate != null ">
  11695. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11696. </if>
  11697. <if test="endDate != null">
  11698. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11699. </if>
  11700. </if>
  11701. <if test="diagnose != null and diagnose != ''">
  11702. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11703. </if>
  11704. <if test="wardName != null and wardName != ''">
  11705. AND a.ward_name LIKE CONCAT( '%', #{wardName}, '%' )
  11706. </if>
  11707. <if test="behospitalCode != null and behospitalCode != ''">
  11708. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11709. </if>
  11710. <if test="patName != null and patName != ''">
  11711. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11712. </if>
  11713. )be
  11714. left join med_check_info mci
  11715. on mci.is_deleted = 'N'
  11716. and mci.check_type = 0
  11717. and be.hospital_id = mci.hospital_id
  11718. and be.behospital_code = mci.behospital_code
  11719. left join med_check_info hm_mci
  11720. on hm_mci.is_deleted = 'N'
  11721. and hm_mci.check_type = 1
  11722. and be.hospital_id = hm_mci.hospital_id
  11723. and be.behospital_code = hm_mci.behospital_code
  11724. left join med_qcresult_info b
  11725. on b.is_deleted = 'N'
  11726. AND be.hospital_id = b.hospital_id
  11727. AND be.behospital_code = b.behospital_code
  11728. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  11729. and be.hospital_id = t2.hospital_id
  11730. AND t2.is_deleted = 'N'
  11731. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  11732. AND t3.is_deleted = 'N'
  11733. where
  11734. 1=1
  11735. <if test="level != null and level != ''">
  11736. AND b.`level` = #{level}
  11737. </if>
  11738. <if test="medoupName != null and medoupName != ''">
  11739. AND t3.name LIKE CONCAT( '%', #{medoupName}, '%' )
  11740. </if>
  11741. ) t1
  11742. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11743. AND t1.behospital_code = t2.behospital_code
  11744. AND t2.is_deleted = 'N'
  11745. ) t,
  11746. (
  11747. SELECT
  11748. a.doctor_id as doctorId,
  11749. a.doctor_name as doctorName
  11750. FROM
  11751. med_behospital_info a,
  11752. sys_user_dept b,
  11753. med_qcresult_cases c,
  11754. med_qcresult_detail d,
  11755. qc_cases_entry e
  11756. WHERE
  11757. a.is_deleted = 'N'
  11758. AND b.is_deleted = 'N'
  11759. AND c.is_deleted = 'N'
  11760. AND d.is_deleted = 'N'
  11761. AND e.is_deleted = 'N'
  11762. AND a.hospital_id = b.hospital_id
  11763. AND a.hospital_id = c.hospital_id
  11764. AND a.hospital_id = d.hospital_id
  11765. AND a.behospital_code = c.behospital_code
  11766. AND a.behospital_code = d.behospital_code
  11767. AND a.beh_dept_id = b.dept_id
  11768. AND c.cases_id = d.cases_id
  11769. AND d.cases_id = e.cases_id
  11770. AND d.cases_entry_id = e.id
  11771. AND d.cases_id = 243
  11772. AND a.qc_type_id != 0
  11773. <if test="userId!=null">
  11774. AND b.user_id = #{userId}
  11775. </if>
  11776. <if test="deptName != null and deptName != ''">
  11777. and a.beh_dept_name = #{deptName}
  11778. </if>
  11779. <if test="doctorName != null and doctorName != ''">
  11780. AND a.doctor_name = #{doctorName}
  11781. </if>
  11782. <if test="doctorId != null and doctorId != ''">
  11783. AND a.doctor_id = #{doctorId}
  11784. </if>
  11785. <if test="deptClass != null and deptClass != ''">
  11786. and a.beh_dept_id = #{deptClass}
  11787. </if>
  11788. <if test="deptId != null and deptId != ''">
  11789. and a.beh_dept_id = #{deptId}
  11790. </if>
  11791. <if test="isPlacefile != null and isPlacefile != ''">
  11792. and a.is_placefile = #{isPlacefile}
  11793. </if>
  11794. <if test="hospitalId != null and hospitalId != ''">
  11795. AND a.hospital_id = #{hospitalId}
  11796. </if>
  11797. <if test="isPlacefile != null and isPlacefile == 0">
  11798. <if test="startDate != null ">
  11799. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11800. </if>
  11801. <if test="endDate != null ">
  11802. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11803. </if>
  11804. </if>
  11805. <if test="isPlacefile != null and isPlacefile == 1">
  11806. <if test="startDate != null ">
  11807. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11808. </if>
  11809. <if test="endDate != null">
  11810. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11811. </if>
  11812. </if>
  11813. <if test="diagnose != null and diagnose != ''">
  11814. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11815. </if>
  11816. <if test="wardName != null and wardName != ''">
  11817. AND a.ward_name LIKE CONCAT( '%', #{wardName}, '%' )
  11818. </if>
  11819. <if test="behospitalCode != null and behospitalCode != ''">
  11820. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11821. </if>
  11822. <if test="patName != null and patName != ''">
  11823. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11824. </if>
  11825. GROUP BY
  11826. a.doctor_id,
  11827. a.doctor_name
  11828. ) t2
  11829. where
  11830. t.doctorId = t2.doctorId
  11831. AND t.doctorName = t2.doctorName
  11832. <if test="checkStatus != null">
  11833. AND t.checkStatus = #{checkStatus}
  11834. </if>
  11835. <if test="mrStatus != null">
  11836. AND t.mrStatus = #{mrStatus}
  11837. </if>
  11838. <if test="chName != null and chName!=''">
  11839. AND t.chName like concat('%', #{chName}, '%')
  11840. </if>
  11841. <if test="mrName != null and mrName!=''">
  11842. AND t.mrName like concat('%', #{mrName}, '%')
  11843. </if>
  11844. <if test="chTimeStart != null ">
  11845. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  11846. </if>
  11847. <if test="chTimeEnd != null ">
  11848. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  11849. </if>
  11850. <if test="mrTimeStart != null ">
  11851. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  11852. </if>
  11853. <if test="mrTimeEnd != null ">
  11854. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  11855. </if>
  11856. </select>
  11857. <!-- 不合格/合格数病历号(内页)全院-->
  11858. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11859. SELECT t.*
  11860. FROM
  11861. (SELECT DISTINCT
  11862. t1.hospital_id AS hospitalId,
  11863. t1.behospital_code AS behospitalCode,
  11864. t1.bed_code AS bedCode,
  11865. t1.LEVEL AS LEVEL,
  11866. t1.grade_type AS gradeType,
  11867. t1.score_res AS scoreRes,
  11868. t1.scoreBn,
  11869. t1.NAME AS NAME,
  11870. t1.sex AS sex,
  11871. t1.beh_dept_id AS behDeptId,
  11872. t1.beh_dept_name AS behDeptName,
  11873. t1.doctor_id AS doctorId,
  11874. t1.doctor_name AS doctorName,
  11875. t1.beh_doctor_id AS behDoctorId,
  11876. t1.beh_doctor_name AS behDoctorName,
  11877. t1.director_doctor_id AS directorDoctorId,
  11878. t1.director_doctor_name AS directorDoctorName,
  11879. t1.birthday AS birthday,
  11880. t1.behospital_date AS behospitalDate,
  11881. t1.leave_hospital_date AS leaveHospitalDate,
  11882. t1.placefile_date AS placefileDate,
  11883. t1.gmt_create AS gradeTime,
  11884. t1.diagnose,
  11885. t1.ward_name AS wardName,
  11886. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11887. t1.file_code AS fileCode,
  11888. t1.checkStatus,
  11889. t1.mrStatus,
  11890. t1.chName,
  11891. t1.mrName,
  11892. t1.chTime,
  11893. t1.mrTime
  11894. FROM
  11895. (SELECT
  11896. be.*,
  11897. b.LEVEL,
  11898. b.grade_type,
  11899. b.score_res,
  11900. b.gmt_create,
  11901. ifnull(mci.status,0) AS checkStatus,
  11902. ifnull(hm_mci.status,0) AS mrStatus,
  11903. mci.check_name as chName,
  11904. hm_mci.check_name as mrName,
  11905. mci.gmt_create as chTime,
  11906. hm_mci.gmt_create as mrTime
  11907. FROM
  11908. (
  11909. SELECT DISTINCT
  11910. a.hospital_id,
  11911. a.behospital_code,
  11912. a.bed_code,
  11913. a.file_code,
  11914. e.score_res as scoreBn,
  11915. a.NAME,
  11916. a.sex,
  11917. a.beh_dept_id,
  11918. a.beh_dept_name,
  11919. a.birthday,
  11920. a.behospital_date,
  11921. a.leave_hospital_date,
  11922. a.doctor_id,
  11923. a.doctor_name,
  11924. a.beh_doctor_id,
  11925. a.beh_doctor_name,
  11926. a.director_doctor_id,
  11927. a.director_doctor_name,
  11928. a.diagnose,
  11929. a.placefile_date,
  11930. a.ward_name
  11931. FROM
  11932. med_behospital_info a,
  11933. med_qcresult_cases e
  11934. WHERE
  11935. a.is_deleted = 'N'
  11936. AND e.is_deleted = 'N'
  11937. AND a.hospital_id = e.hospital_id
  11938. AND a.behospital_code = e.behospital_code
  11939. AND a.qc_type_id != 0
  11940. AND e.cases_id = 243
  11941. <if test="qcResultPageVO.titleName != null ">
  11942. <if test="qcResultPageVO.titleName == '不合格数'">
  11943. AND e.`level`='不合格'
  11944. </if>
  11945. <if test="qcResultPageVO.titleName == '合格数'">
  11946. AND e.`level`='合格'
  11947. </if>
  11948. </if>
  11949. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11950. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11951. </if>
  11952. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11953. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11954. </if>
  11955. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11956. <if test="qcResultPageVO.startDate != null ">
  11957. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11958. </if>
  11959. <if test="qcResultPageVO.endDate != null ">
  11960. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11961. </if>
  11962. </if>
  11963. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11964. <if test="qcResultPageVO.startDate != null ">
  11965. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11966. </if>
  11967. <if test="qcResultPageVO.endDate != null">
  11968. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11969. </if>
  11970. </if>
  11971. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11972. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11973. </if>
  11974. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11975. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  11976. </if>
  11977. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11978. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11979. </if>
  11980. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11981. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11982. </if>
  11983. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11984. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11985. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11986. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11987. </if>
  11988. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11989. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11990. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11991. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11992. </if>
  11993. )be
  11994. left join med_check_info mci
  11995. on mci.is_deleted = 'N'
  11996. and mci.check_type = 0
  11997. and be.hospital_id = mci.hospital_id
  11998. and be.behospital_code = mci.behospital_code
  11999. left join med_check_info hm_mci
  12000. on hm_mci.is_deleted = 'N'
  12001. and hm_mci.check_type = 1
  12002. and be.hospital_id = hm_mci.hospital_id
  12003. and be.behospital_code = hm_mci.behospital_code
  12004. left join med_qcresult_info b
  12005. on b.is_deleted = 'N'
  12006. AND be.hospital_id = b.hospital_id
  12007. AND be.behospital_code = b.behospital_code
  12008. where
  12009. 1=1
  12010. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  12011. AND b.`level` = #{qcResultPageVO.level}
  12012. </if>
  12013. ) t1
  12014. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12015. AND t1.behospital_code = t2.behospital_code
  12016. AND t2.is_deleted = 'N'
  12017. ) t,
  12018. (
  12019. SELECT
  12020. a.beh_dept_id AS deptId,
  12021. a.beh_dept_name AS deptName
  12022. FROM
  12023. med_behospital_info a,
  12024. med_qcresult_cases c,
  12025. med_qcresult_detail d,
  12026. qc_cases_entry e
  12027. WHERE
  12028. a.is_deleted = 'N'
  12029. AND c.is_deleted = 'N'
  12030. AND d.is_deleted = 'N'
  12031. AND e.is_deleted = 'N'
  12032. AND a.hospital_id = c.hospital_id
  12033. AND a.hospital_id = d.hospital_id
  12034. AND a.behospital_code = c.behospital_code
  12035. AND a.behospital_code = d.behospital_code
  12036. AND c.cases_id = d.cases_id
  12037. AND d.cases_id = e.cases_id
  12038. AND d.cases_entry_id = e.id
  12039. AND d.cases_id = 243
  12040. AND a.qc_type_id != 0
  12041. <!-- <if test="qcResultPageVO.titleName != null ">-->
  12042. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  12043. <!-- AND c.`level`='不合格'-->
  12044. <!-- </if>-->
  12045. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  12046. <!-- AND c.`level`='合格'-->
  12047. <!-- </if>-->
  12048. <!-- </if>-->
  12049. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  12050. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  12051. </if>
  12052. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  12053. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  12054. </if>
  12055. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  12056. <if test="qcResultPageVO.startDate != null ">
  12057. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  12058. </if>
  12059. <if test="qcResultPageVO.endDate != null ">
  12060. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  12061. </if>
  12062. </if>
  12063. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  12064. <if test="qcResultPageVO.startDate != null ">
  12065. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  12066. </if>
  12067. <if test="qcResultPageVO.endDate != null">
  12068. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  12069. </if>
  12070. </if>
  12071. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  12072. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  12073. </if>
  12074. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  12075. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  12076. </if>
  12077. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  12078. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  12079. </if>
  12080. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  12081. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  12082. </if>
  12083. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  12084. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12085. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  12086. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  12087. </if>
  12088. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  12089. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12090. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  12091. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  12092. </if>
  12093. GROUP BY
  12094. a.beh_dept_id,
  12095. a.beh_dept_name
  12096. ) t2
  12097. where
  12098. t.behDeptId = t2.deptId
  12099. AND t.behDeptName = t2.deptName
  12100. <if test="qcResultPageVO.checkStatus != null">
  12101. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  12102. </if>
  12103. <if test="qcResultPageVO.mrStatus != null">
  12104. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  12105. </if>
  12106. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  12107. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  12108. </if>
  12109. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  12110. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  12111. </if>
  12112. <if test="qcResultPageVO.chTimeStart != null ">
  12113. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  12114. </if>
  12115. <if test="qcResultPageVO.chTimeEnd != null ">
  12116. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  12117. </if>
  12118. <if test="qcResultPageVO.mrTimeStart != null ">
  12119. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  12120. </if>
  12121. <if test="qcResultPageVO.mrTimeEnd != null ">
  12122. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  12123. </if>
  12124. </select>
  12125. <!-- 未整改病历质控评分页(内页)-->
  12126. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12127. SELECT t.*
  12128. FROM
  12129. (SELECT DISTINCT
  12130. t1.hospital_id AS hospitalId,
  12131. t1.behospital_code AS behospitalCode,
  12132. t1.bed_code AS bedCode,
  12133. t1.LEVEL AS LEVEL,
  12134. t1.grade_type AS gradeType,
  12135. t1.score_res AS scoreRes,
  12136. t1.scoreBn,
  12137. t1.NAME AS NAME,
  12138. t1.sex AS sex,
  12139. t1.beh_dept_id AS behDeptId,
  12140. t1.beh_dept_name AS behDeptName,
  12141. t1.doctor_id AS doctorId,
  12142. t1.doctor_name AS doctorName,
  12143. t1.beh_doctor_id AS behDoctorId,
  12144. t1.beh_doctor_name AS behDoctorName,
  12145. t1.director_doctor_id AS directorDoctorId,
  12146. t1.director_doctor_name AS directorDoctorName,
  12147. t1.birthday AS birthday,
  12148. t1.behospital_date AS behospitalDate,
  12149. t1.leave_hospital_date AS leaveHospitalDate,
  12150. t1.placefile_date AS placefileDate,
  12151. t1.gmt_create AS gradeTime,
  12152. t1.diagnose,
  12153. t1.ward_name AS wardName,
  12154. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12155. t1.file_code AS fileCode,
  12156. t1.checkStatus,
  12157. t1.mrStatus,
  12158. t1.chName,
  12159. t1.mrName,
  12160. t1.chTime,
  12161. t1.mrTime
  12162. FROM
  12163. (SELECT
  12164. be.*,
  12165. ifnull(mci.status,0) AS checkStatus,
  12166. ifnull(hm_mci.status,0) AS mrStatus,
  12167. mci.check_name as chName,
  12168. e.score_res as scoreBn,
  12169. hm_mci.check_name as mrName,
  12170. mci.gmt_create as chTime,
  12171. hm_mci.gmt_create as mrTime
  12172. FROM
  12173. (
  12174. SELECT DISTINCT
  12175. a.hospital_id,
  12176. a.behospital_code,
  12177. a.bed_code,
  12178. a.file_code,
  12179. b.LEVEL,
  12180. b.grade_type,
  12181. b.score_res,
  12182. a.NAME,
  12183. a.sex,
  12184. a.beh_dept_id,
  12185. a.beh_dept_name,
  12186. a.birthday,
  12187. a.behospital_date,
  12188. a.leave_hospital_date,
  12189. a.doctor_id,
  12190. a.doctor_name,
  12191. a.beh_doctor_id,
  12192. a.beh_doctor_name,
  12193. a.director_doctor_id,
  12194. a.director_doctor_name,
  12195. a.diagnose,
  12196. a.placefile_date,
  12197. a.ward_name,
  12198. b.gmt_create
  12199. FROM
  12200. med_behospital_info a,
  12201. med_qcresult_info b,
  12202. med_qcresult_detail c,
  12203. qc_cases_entry d
  12204. WHERE
  12205. a.is_deleted = 'N'
  12206. AND b.is_deleted = 'N'
  12207. AND c.is_deleted = 'N'
  12208. AND d.is_deleted = 'N'
  12209. AND a.hospital_id = b.hospital_id
  12210. AND a.hospital_id = c.hospital_id
  12211. AND a.behospital_code = b.behospital_code
  12212. AND a.behospital_code = c.behospital_code
  12213. AND c.cases_id = d.cases_id
  12214. AND c.cases_entry_id = d.id
  12215. AND a.qc_type_id != 0
  12216. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12217. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12218. </if>
  12219. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12220. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12221. </if>
  12222. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12223. <if test="qcResultShortPageVO.startDate != null ">
  12224. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12225. </if>
  12226. <if test="qcResultShortPageVO.endDate != null ">
  12227. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12228. </if>
  12229. </if>
  12230. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12231. <if test="qcResultShortPageVO.startDate != null ">
  12232. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12233. </if>
  12234. <if test="qcResultShortPageVO.endDate != null">
  12235. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12236. </if>
  12237. </if>
  12238. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12239. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12240. </if>
  12241. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12242. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12243. </if>
  12244. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12245. AND b.`level` = #{qcResultShortPageVO.level}
  12246. </if>
  12247. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12248. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12249. </if>
  12250. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12251. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12252. </if>
  12253. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12254. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12255. </if>
  12256. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12257. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12258. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12259. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12260. </if>
  12261. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12262. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12263. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12264. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12265. </if>
  12266. <if test="qcResultShortPageVO.casesEntryId != null ">
  12267. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12268. </if>
  12269. <if test="qcResultShortPageVO.isReject != null">
  12270. AND c.is_reject = #{qcResultShortPageVO.isReject}
  12271. </if>
  12272. <if test="qcResultShortPageVO.ruleType != null">
  12273. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12274. </if>
  12275. )be
  12276. left join med_check_info mci
  12277. on mci.is_deleted = 'N'
  12278. and mci.check_type = 0
  12279. and be.hospital_id = mci.hospital_id
  12280. and be.behospital_code = mci.behospital_code
  12281. left join med_check_info hm_mci
  12282. on hm_mci.is_deleted = 'N'
  12283. and hm_mci.check_type = 1
  12284. and be.hospital_id = hm_mci.hospital_id
  12285. and be.behospital_code = hm_mci.behospital_code
  12286. LEFT JOIN med_qcresult_cases e
  12287. on be.behospital_code = e.behospital_code
  12288. and be.hospital_id = e.hospital_id
  12289. AND e.is_deleted = 'N'
  12290. and e.cases_id = 243
  12291. ) t1
  12292. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12293. AND t1.behospital_code = t2.behospital_code
  12294. AND t2.is_deleted = 'N'
  12295. ) t
  12296. where 1=1
  12297. <if test="qcResultShortPageVO.checkStatus != null">
  12298. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12299. </if>
  12300. <if test="qcResultShortPageVO.mrStatus != null">
  12301. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12302. </if>
  12303. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12304. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12305. </if>
  12306. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12307. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12308. </if>
  12309. <if test="qcResultShortPageVO.chTimeStart != null ">
  12310. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12311. </if>
  12312. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12313. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12314. </if>
  12315. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12316. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12317. </if>
  12318. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12319. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12320. </if>
  12321. </select>
  12322. <!-- 未整改病历质控评分页-科室(内页)-->
  12323. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  12324. SELECT t.*
  12325. FROM
  12326. (SELECT DISTINCT
  12327. t1.hospital_id AS hospitalId,
  12328. t1.behospital_code AS behospitalCode,
  12329. t1.bed_code AS bedCode,
  12330. t1.LEVEL AS LEVEL,
  12331. t1.grade_type AS gradeType,
  12332. t1.score_res AS scoreRes,
  12333. t1.scoreBn,
  12334. t1.NAME AS NAME,
  12335. t1.sex AS sex,
  12336. t1.beh_dept_id AS behDeptId,
  12337. t1.beh_dept_name AS behDeptName,
  12338. t1.doctor_id AS doctorId,
  12339. t1.doctor_name AS doctorName,
  12340. t1.beh_doctor_id AS behDoctorId,
  12341. t1.beh_doctor_name AS behDoctorName,
  12342. t1.director_doctor_id AS directorDoctorId,
  12343. t1.director_doctor_name AS directorDoctorName,
  12344. t1.birthday AS birthday,
  12345. t1.behospital_date AS behospitalDate,
  12346. t1.leave_hospital_date AS leaveHospitalDate,
  12347. t1.placefile_date AS placefileDate,
  12348. t1.gmt_create AS gradeTime,
  12349. t1.diagnose,
  12350. t1.medoupName,
  12351. t1.ward_name AS wardName,
  12352. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12353. t1.file_code AS fileCode,
  12354. t1.checkStatus,
  12355. t1.mrStatus,
  12356. t1.chName,
  12357. t1.mrName,
  12358. t1.chTime,
  12359. t1.mrTime
  12360. FROM
  12361. (SELECT
  12362. be.*,
  12363. t3.name as medoupName,
  12364. ifnull(mci.status,0) AS checkStatus,
  12365. ifnull(hm_mci.status,0) AS mrStatus,
  12366. mci.check_name as chName,
  12367. e.score_res as scoreBn,
  12368. hm_mci.check_name as mrName,
  12369. mci.gmt_create as chTime,
  12370. hm_mci.gmt_create as mrTime
  12371. FROM
  12372. (
  12373. SELECT DISTINCT
  12374. a.hospital_id,
  12375. a.behospital_code,
  12376. a.bed_code,
  12377. a.file_code,
  12378. b.LEVEL,
  12379. b.grade_type,
  12380. b.score_res,
  12381. a.NAME,
  12382. a.sex,
  12383. a.beh_dept_id,
  12384. a.beh_dept_name,
  12385. a.birthday,
  12386. a.behospital_date,
  12387. a.leave_hospital_date,
  12388. a.doctor_id,
  12389. a.doctor_name,
  12390. a.beh_doctor_id,
  12391. a.beh_doctor_name,
  12392. a.director_doctor_id,
  12393. a.director_doctor_name,
  12394. a.diagnose,
  12395. a.placefile_date,
  12396. a.ward_name,
  12397. b.gmt_create
  12398. FROM
  12399. med_behospital_info a,
  12400. med_qcresult_info b,
  12401. med_qcresult_detail c,
  12402. qc_cases_entry d,
  12403. sys_user_dept f
  12404. WHERE
  12405. a.is_deleted = 'N'
  12406. AND b.is_deleted = 'N'
  12407. AND c.is_deleted = 'N'
  12408. AND d.is_deleted = 'N'
  12409. AND f.is_deleted = 'N'
  12410. AND a.hospital_id = b.hospital_id
  12411. AND a.hospital_id = c.hospital_id
  12412. AND a.hospital_id = f.hospital_id
  12413. AND a.behospital_code = b.behospital_code
  12414. AND a.behospital_code = c.behospital_code
  12415. AND c.cases_id = d.cases_id
  12416. AND a.beh_dept_id = f.dept_id
  12417. AND c.cases_entry_id = d.id
  12418. AND a.qc_type_id != 0
  12419. <if test="qcResultShortPageVO.userId!=null">
  12420. AND f.user_id = #{qcResultShortPageVO.userId}
  12421. </if>
  12422. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12423. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12424. </if>
  12425. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  12426. and a.ward_name LIKE CONCAT( '%',#{qcResultShortPageVO.wardName}, '%' )
  12427. </if>
  12428. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12429. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12430. </if>
  12431. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12432. <if test="qcResultShortPageVO.startDate != null ">
  12433. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12434. </if>
  12435. <if test="qcResultShortPageVO.endDate != null ">
  12436. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12437. </if>
  12438. </if>
  12439. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12440. <if test="qcResultShortPageVO.startDate != null ">
  12441. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12442. </if>
  12443. <if test="qcResultShortPageVO.endDate != null">
  12444. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12445. </if>
  12446. </if>
  12447. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12448. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12449. </if>
  12450. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12451. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12452. </if>
  12453. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  12454. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  12455. </if>
  12456. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12457. AND b.`level` = #{qcResultShortPageVO.level}
  12458. </if>
  12459. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12460. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12461. </if>
  12462. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12463. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12464. </if>
  12465. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12466. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12467. </if>
  12468. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12469. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  12470. </if>
  12471. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12472. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  12473. </if>
  12474. <if test="qcResultShortPageVO.casesEntryId != null ">
  12475. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12476. </if>
  12477. <if test="qcResultShortPageVO.isReject != null">
  12478. AND c.is_reject = #{qcResultShortPageVO.isReject}
  12479. </if>
  12480. <if test="qcResultShortPageVO.ruleType != null">
  12481. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12482. </if>
  12483. )be
  12484. left join med_check_info mci
  12485. on mci.is_deleted = 'N'
  12486. and mci.check_type = 0
  12487. and be.hospital_id = mci.hospital_id
  12488. and be.behospital_code = mci.behospital_code
  12489. left join med_check_info hm_mci
  12490. on hm_mci.is_deleted = 'N'
  12491. and hm_mci.check_type = 1
  12492. and be.hospital_id = hm_mci.hospital_id
  12493. and be.behospital_code = hm_mci.behospital_code
  12494. LEFT JOIN med_qcresult_cases e
  12495. on be.behospital_code = e.behospital_code
  12496. and be.hospital_id = e.hospital_id
  12497. AND e.is_deleted = 'N'
  12498. and e.cases_id = 243
  12499. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  12500. and be.hospital_id = t2.hospital_id
  12501. AND t2.is_deleted = 'N'
  12502. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  12503. AND t3.is_deleted = 'N'
  12504. ) t1
  12505. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12506. AND t1.behospital_code = t2.behospital_code
  12507. AND t2.is_deleted = 'N'
  12508. ) t
  12509. where 1=1
  12510. <if test="qcResultShortPageVO.checkStatus != null">
  12511. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12512. </if>
  12513. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  12514. AND t.medoupName like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  12515. </if>
  12516. <if test="qcResultShortPageVO.mrStatus != null">
  12517. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12518. </if>
  12519. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12520. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12521. </if>
  12522. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12523. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12524. </if>
  12525. <if test="qcResultShortPageVO.chTimeStart != null ">
  12526. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12527. </if>
  12528. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12529. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12530. </if>
  12531. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12532. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12533. </if>
  12534. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12535. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12536. </if>
  12537. </select>
  12538. <!-- 病案首页不合格/合格数病历详情页导出-->
  12539. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  12540. SELECT
  12541. f1.behDeptId,
  12542. f1.behDeptName,
  12543. f1.doctorName,
  12544. f1.patName,
  12545. f1.behospitalCode,
  12546. f1.hospitalId,
  12547. f1.behospitalDate,
  12548. f1.leaveHospitalDate,
  12549. f1.score,
  12550. f1.scoreBn,
  12551. f2.avgScore,
  12552. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12553. f1.msg,
  12554. f1.caseName,
  12555. </if>
  12556. f1.checkStatus,
  12557. f1.mrStatus,
  12558. f1.chName,
  12559. f1.mrName,
  12560. f1.chTime,
  12561. f1.mrTime
  12562. FROM
  12563. (SELECT
  12564. t.doctorName,
  12565. t.`name` AS patName,
  12566. t.behospitalCode AS behospitalCode,
  12567. t.behospitalDate AS behospitalDate,
  12568. t.leaveHospitalDate AS leaveHospitalDate,
  12569. qi.score_res AS score,
  12570. t.scoreBn,
  12571. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12572. qd.msg AS msg,
  12573. qc.NAME AS caseName,
  12574. </if>
  12575. t.behDeptId,
  12576. t.behDeptName,
  12577. t.hospitalId,
  12578. t.checkStatus,
  12579. t.mrStatus,
  12580. t.chName,
  12581. t.mrName,
  12582. t.chTime,
  12583. t.mrTime
  12584. FROM
  12585. (SELECT DISTINCT
  12586. t1.hospital_id AS hospitalId,
  12587. t1.behospital_code AS behospitalCode,
  12588. t1.bed_code AS bedCode,
  12589. t1.LEVEL AS LEVEL,
  12590. t1.grade_type AS gradeType,
  12591. t1.score_res AS scoreRes,
  12592. t1.scoreBn,
  12593. t1.NAME AS NAME,
  12594. t1.sex AS sex,
  12595. t1.beh_dept_id AS behDeptId,
  12596. t1.beh_dept_name AS behDeptName,
  12597. t1.doctor_id AS doctorId,
  12598. t1.doctor_name AS doctorName,
  12599. t1.beh_doctor_id AS behDoctorId,
  12600. t1.beh_doctor_name AS behDoctorName,
  12601. t1.director_doctor_id AS directorDoctorId,
  12602. t1.director_doctor_name AS directorDoctorName,
  12603. t1.birthday AS birthday,
  12604. t1.behospital_date AS behospitalDate,
  12605. t1.leave_hospital_date AS leaveHospitalDate,
  12606. t1.placefile_date AS placefileDate,
  12607. t1.gmt_create AS gradeTime,
  12608. t1.diagnose,
  12609. t1.ward_name AS wardName,
  12610. t2.age,
  12611. t1.file_code AS fileCode,
  12612. t1.checkStatus,
  12613. t1.mrStatus,
  12614. t1.chName,
  12615. t1.mrName,
  12616. t1.chTime,
  12617. t1.mrTime
  12618. FROM
  12619. (SELECT
  12620. be.*,
  12621. b.LEVEL,
  12622. b.grade_type,
  12623. b.score_res,
  12624. b.gmt_create,
  12625. ifnull(mci.status,0) AS checkStatus,
  12626. ifnull(hm_mci.status,0) AS mrStatus,
  12627. mci.check_name as chName,
  12628. hm_mci.check_name as mrName,
  12629. mci.gmt_create as chTime,
  12630. hm_mci.gmt_create as mrTime
  12631. FROM
  12632. (
  12633. SELECT DISTINCT
  12634. a.hospital_id,
  12635. a.behospital_code,
  12636. a.bed_code,
  12637. a.file_code,
  12638. c.score_res as scoreBn,
  12639. c.cases_id,
  12640. a.NAME,
  12641. a.sex,
  12642. a.beh_dept_id,
  12643. a.beh_dept_name,
  12644. a.birthday,
  12645. a.behospital_date,
  12646. a.leave_hospital_date,
  12647. a.doctor_id,
  12648. a.doctor_name,
  12649. a.beh_doctor_id,
  12650. a.beh_doctor_name,
  12651. a.director_doctor_id,
  12652. a.director_doctor_name,
  12653. a.diagnose,
  12654. a.placefile_date,
  12655. a.ward_name
  12656. FROM
  12657. med_behospital_info a,
  12658. med_qcresult_cases c
  12659. WHERE
  12660. a.is_deleted = 'N'
  12661. AND c.is_deleted = 'N'
  12662. AND a.hospital_id = c.hospital_id
  12663. AND a.behospital_code = c.behospital_code
  12664. AND a.qc_type_id != 0
  12665. AND c.cases_id = 243
  12666. <if test="qcResultShortPageVO.titleName != null ">
  12667. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12668. AND c.`level`='不合格'
  12669. </if>
  12670. <if test="qcResultShortPageVO.titleName == '合格数'">
  12671. AND c.`level`='合格'
  12672. </if>
  12673. </if>
  12674. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12675. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12676. </if>
  12677. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12678. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12679. </if>
  12680. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12681. <if test="qcResultShortPageVO.startDate != null ">
  12682. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12683. </if>
  12684. <if test="qcResultShortPageVO.endDate != null ">
  12685. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12686. </if>
  12687. </if>
  12688. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12689. <if test="qcResultShortPageVO.startDate != null ">
  12690. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12691. </if>
  12692. <if test="qcResultShortPageVO.endDate != null">
  12693. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12694. </if>
  12695. </if>
  12696. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12697. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12698. </if>
  12699. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12700. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12701. </if>
  12702. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12703. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12704. </if>
  12705. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12706. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12707. </if>
  12708. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12709. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12710. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12711. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12712. </if>
  12713. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12714. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12715. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12716. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12717. </if>
  12718. )be
  12719. left join med_check_info mci
  12720. on mci.is_deleted = 'N'
  12721. and mci.check_type = 0
  12722. and be.hospital_id = mci.hospital_id
  12723. and be.behospital_code = mci.behospital_code
  12724. left join med_check_info hm_mci
  12725. on hm_mci.is_deleted = 'N'
  12726. and hm_mci.check_type = 1
  12727. and be.hospital_id = hm_mci.hospital_id
  12728. and be.behospital_code = hm_mci.behospital_code
  12729. left join med_qcresult_info b
  12730. on b.is_deleted = 'N'
  12731. AND be.hospital_id = b.hospital_id
  12732. AND be.behospital_code = b.behospital_code
  12733. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12734. AND b.`level` = #{qcResultPageVO.level}
  12735. </if>
  12736. left join qc_cases_entry d
  12737. on d.is_deleted = 'N'
  12738. AND be.cases_id = d.cases_id
  12739. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12740. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12741. </if>
  12742. <if test="qcResultShortPageVO.casesEntryId != null ">
  12743. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12744. </if>
  12745. <if test="qcResultShortPageVO.ruleType != null">
  12746. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12747. </if>
  12748. ) t1
  12749. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12750. AND t1.behospital_code = t2.behospital_code
  12751. AND t2.is_deleted = 'N'
  12752. ) t
  12753. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12754. AND t.hospitalId = qi.hospital_id
  12755. AND t.behospitalCode = qi.behospital_code
  12756. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12757. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12758. AND t.hospitalId = qd.hospital_id
  12759. AND t.behospitalCode = qd.behospital_code
  12760. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12761. AND qd.cases_id = qc.id
  12762. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12763. AND qd.cases_id = qce.cases_id
  12764. AND qd.cases_entry_id = qce.id
  12765. </if>
  12766. where 1=1
  12767. <if test="qcResultShortPageVO.checkStatus != null">
  12768. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12769. </if>
  12770. <if test="qcResultShortPageVO.mrStatus != null">
  12771. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12772. </if>
  12773. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12774. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12775. </if>
  12776. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12777. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12778. </if>
  12779. <if test="qcResultShortPageVO.chTimeStart != null ">
  12780. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12781. </if>
  12782. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12783. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12784. </if>
  12785. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12786. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12787. </if>
  12788. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12789. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12790. </if>
  12791. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12792. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12793. </if>
  12794. <if test="qcResultShortPageVO.casesEntryId != null ">
  12795. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12796. </if>
  12797. )f1,
  12798. (SELECT
  12799. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12800. t.behDeptId,
  12801. t.behDeptName
  12802. FROM
  12803. (SELECT DISTINCT
  12804. t1.hospital_id AS hospitalId,
  12805. t1.behospital_code AS behospitalCode,
  12806. t1.bed_code AS bedCode,
  12807. t1.LEVEL AS LEVEL,
  12808. t1.grade_type AS gradeType,
  12809. t1.score_res AS scoreRes,
  12810. t1.NAME AS NAME,
  12811. t1.sex AS sex,
  12812. t1.beh_dept_id AS behDeptId,
  12813. t1.beh_dept_name AS behDeptName,
  12814. t1.doctor_id AS doctorId,
  12815. t1.doctor_name AS doctorName,
  12816. t1.beh_doctor_id AS behDoctorId,
  12817. t1.beh_doctor_name AS behDoctorName,
  12818. t1.director_doctor_id AS directorDoctorId,
  12819. t1.director_doctor_name AS directorDoctorName,
  12820. t1.birthday AS birthday,
  12821. t1.behospital_date AS behospitalDate,
  12822. t1.leave_hospital_date AS leaveHospitalDate,
  12823. t1.placefile_date AS placefileDate,
  12824. t1.gmt_create AS gradeTime,
  12825. t1.diagnose,
  12826. t1.ward_name AS wardName,
  12827. t2.age,
  12828. t1.file_code AS fileCode,
  12829. t1.checkStatus,
  12830. t1.mrStatus,
  12831. t1.chName,
  12832. t1.mrName,
  12833. t1.chTime,
  12834. t1.mrTime
  12835. FROM
  12836. (SELECT
  12837. be.*,
  12838. b.grade_type,
  12839. b.score_res,
  12840. b.gmt_create,
  12841. b.LEVEL,
  12842. ifnull(mci.status,0) AS checkStatus,
  12843. ifnull(hm_mci.status,0) AS mrStatus,
  12844. mci.check_name as chName,
  12845. hm_mci.check_name as mrName,
  12846. mci.gmt_create as chTime,
  12847. hm_mci.gmt_create as mrTime
  12848. FROM
  12849. (
  12850. SELECT DISTINCT
  12851. a.hospital_id,
  12852. a.behospital_code,
  12853. a.bed_code,
  12854. a.file_code,
  12855. a.NAME,
  12856. a.sex,
  12857. a.beh_dept_id,
  12858. a.beh_dept_name,
  12859. a.birthday,
  12860. a.behospital_date,
  12861. a.leave_hospital_date,
  12862. a.doctor_id,
  12863. a.doctor_name,
  12864. a.beh_doctor_id,
  12865. a.beh_doctor_name,
  12866. a.director_doctor_id,
  12867. a.director_doctor_name,
  12868. a.diagnose,
  12869. a.placefile_date,
  12870. a.ward_name
  12871. FROM
  12872. med_behospital_info a,
  12873. med_qcresult_detail k,
  12874. med_qcresult_cases c,
  12875. qc_cases_entry d
  12876. WHERE
  12877. a.is_deleted = 'N'
  12878. AND c.is_deleted = 'N'
  12879. AND d.is_deleted = 'N'
  12880. AND a.hospital_id = c.hospital_id
  12881. AND a.behospital_code = c.behospital_code
  12882. AND c.cases_id = d.cases_id
  12883. AND a.hospital_id = k.hospital_id
  12884. AND a.behospital_code = k.behospital_code
  12885. AND c.cases_id = k.cases_id
  12886. AND k.cases_id = d.cases_id
  12887. AND k.cases_entry_id = d.id
  12888. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12889. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12890. <!-- AND c.`level`='不合格'-->
  12891. <!-- </if>-->
  12892. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12893. <!-- AND c.`level`='合格'-->
  12894. <!-- </if>-->
  12895. <!-- </if>-->
  12896. AND a.qc_type_id != 0
  12897. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12898. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12899. </if>
  12900. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12901. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12902. </if>
  12903. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12904. <if test="qcResultShortPageVO.startDate != null ">
  12905. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12906. </if>
  12907. <if test="qcResultShortPageVO.endDate != null ">
  12908. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12909. </if>
  12910. </if>
  12911. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12912. <if test="qcResultShortPageVO.startDate != null ">
  12913. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12914. </if>
  12915. <if test="qcResultShortPageVO.endDate != null">
  12916. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12917. </if>
  12918. </if>
  12919. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12920. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12921. </if>
  12922. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12923. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12924. </if>
  12925. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12926. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12927. </if>
  12928. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12929. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12930. </if>
  12931. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12932. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12933. </if>
  12934. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12935. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12936. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12937. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12938. </if>
  12939. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12940. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12941. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12942. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12943. </if>
  12944. <if test="qcResultShortPageVO.casesEntryId != null ">
  12945. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12946. </if>
  12947. <if test="qcResultShortPageVO.ruleType != null">
  12948. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12949. </if>
  12950. )be
  12951. left join med_check_info mci
  12952. on mci.is_deleted = 'N'
  12953. and mci.check_type = 0
  12954. and be.hospital_id = mci.hospital_id
  12955. and be.behospital_code = mci.behospital_code
  12956. left join med_check_info hm_mci
  12957. on hm_mci.is_deleted = 'N'
  12958. and hm_mci.check_type = 1
  12959. and be.hospital_id = hm_mci.hospital_id
  12960. and be.behospital_code = hm_mci.behospital_code
  12961. left join med_qcresult_info b
  12962. on b.is_deleted = 'N'
  12963. AND be.hospital_id = b.hospital_id
  12964. AND be.behospital_code = b.behospital_code
  12965. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12966. AND b.`level` = #{qcResultPageVO.level}
  12967. </if>
  12968. ) t1
  12969. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12970. AND t1.behospital_code = t2.behospital_code
  12971. AND t2.is_deleted = 'N'
  12972. ) t
  12973. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12974. AND t.hospitalId = qi.hospital_id
  12975. AND t.behospitalCode = qi.behospital_code
  12976. where 1=1
  12977. <if test="qcResultShortPageVO.checkStatus != null">
  12978. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12979. </if>
  12980. <if test="qcResultShortPageVO.mrStatus != null">
  12981. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12982. </if>
  12983. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12984. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12985. </if>
  12986. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12987. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12988. </if>
  12989. <if test="qcResultShortPageVO.chTimeStart != null ">
  12990. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12991. </if>
  12992. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12993. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12994. </if>
  12995. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12996. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12997. </if>
  12998. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12999. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13000. </if>
  13001. GROUP BY
  13002. t.behDeptId,
  13003. t.behDeptName
  13004. )f2
  13005. WHERE
  13006. f1.behDeptId = f2.behDeptId
  13007. AND f1.behDeptName = f2.behDeptName
  13008. </select>
  13009. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  13010. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  13011. SELECT
  13012. f1.behDeptId,
  13013. f1.behDeptName,
  13014. f1.doctorName,
  13015. f1.patName,
  13016. f1.behospitalCode,
  13017. f1.hospitalId,
  13018. f1.wardName,
  13019. f1.medoupName,
  13020. f1.behospitalDate,
  13021. f1.leaveHospitalDate,
  13022. f1.score,
  13023. f1.scoreBn,
  13024. f2.avgScore,
  13025. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13026. f1.msg,
  13027. f1.caseName,
  13028. </if>
  13029. f1.checkStatus,
  13030. f1.mrStatus,
  13031. f1.chName,
  13032. f1.mrName,
  13033. f1.chTime,
  13034. f1.mrTime
  13035. FROM
  13036. (SELECT
  13037. t.doctorName AS doctorName,
  13038. t.doctorId,
  13039. t.`name` AS patName,
  13040. t.wardName,
  13041. t.behospitalCode AS behospitalCode,
  13042. t.behospitalDate AS behospitalDate,
  13043. t.leaveHospitalDate AS leaveHospitalDate,
  13044. qi.score_res AS score,
  13045. t.scoreBn,
  13046. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13047. qd.msg AS msg,
  13048. qc.NAME AS caseName,
  13049. </if>
  13050. t.behDeptId,
  13051. t.behDeptName,
  13052. t.hospitalId,
  13053. t.checkStatus,
  13054. t.mrStatus,
  13055. t.chName,
  13056. t.mrName,
  13057. t.chTime,
  13058. t.mrTime,
  13059. t3.name as medoupName
  13060. FROM
  13061. (SELECT DISTINCT
  13062. t1.hospital_id AS hospitalId,
  13063. t1.behospital_code AS behospitalCode,
  13064. t1.bed_code AS bedCode,
  13065. t1.LEVEL AS LEVEL,
  13066. t1.grade_type AS gradeType,
  13067. t1.score_res AS scoreRes,
  13068. t1.scoreBn,
  13069. t1.NAME AS NAME,
  13070. t1.sex AS sex,
  13071. t1.beh_dept_id AS behDeptId,
  13072. t1.beh_dept_name AS behDeptName,
  13073. t1.doctor_id AS doctorId,
  13074. t1.doctor_name AS doctorName,
  13075. t1.beh_doctor_id AS behDoctorId,
  13076. t1.beh_doctor_name AS behDoctorName,
  13077. t1.director_doctor_id AS directorDoctorId,
  13078. t1.director_doctor_name AS directorDoctorName,
  13079. t1.birthday AS birthday,
  13080. t1.behospital_date AS behospitalDate,
  13081. t1.leave_hospital_date AS leaveHospitalDate,
  13082. t1.placefile_date AS placefileDate,
  13083. t1.gmt_create AS gradeTime,
  13084. t1.diagnose,
  13085. t1.ward_name AS wardName,
  13086. t2.age,
  13087. t1.file_code AS fileCode,
  13088. t1.checkStatus,
  13089. t1.mrStatus,
  13090. t1.chName,
  13091. t1.mrName,
  13092. t1.chTime,
  13093. t1.mrTime
  13094. FROM
  13095. (SELECT
  13096. be.*,
  13097. b.LEVEL,
  13098. b.grade_type,
  13099. b.score_res,
  13100. b.gmt_create,
  13101. ifnull(mci.status,0) AS checkStatus,
  13102. ifnull(hm_mci.status,0) AS mrStatus,
  13103. mci.check_name as chName,
  13104. hm_mci.check_name as mrName,
  13105. mci.gmt_create as chTime,
  13106. hm_mci.gmt_create as mrTime
  13107. FROM
  13108. (
  13109. SELECT DISTINCT
  13110. a.hospital_id,
  13111. a.behospital_code,
  13112. a.bed_code,
  13113. a.file_code,
  13114. c.score_res as scoreBn,
  13115. c.cases_id,
  13116. a.NAME,
  13117. a.sex,
  13118. a.beh_dept_id,
  13119. a.beh_dept_name,
  13120. a.birthday,
  13121. a.behospital_date,
  13122. a.leave_hospital_date,
  13123. a.doctor_id,
  13124. a.doctor_name,
  13125. a.beh_doctor_id,
  13126. a.beh_doctor_name,
  13127. a.director_doctor_id,
  13128. a.director_doctor_name,
  13129. a.diagnose,
  13130. a.placefile_date,
  13131. a.ward_name
  13132. FROM
  13133. med_behospital_info a,
  13134. sys_user_dept b,
  13135. med_qcresult_cases c
  13136. WHERE
  13137. a.is_deleted = 'N'
  13138. AND b.is_deleted = 'N'
  13139. AND c.is_deleted = 'N'
  13140. AND a.hospital_id = b.hospital_id
  13141. AND a.beh_dept_id = b.dept_id
  13142. AND a.hospital_id = c.hospital_id
  13143. AND a.behospital_code = c.behospital_code
  13144. AND a.qc_type_id != 0
  13145. AND c.cases_id = 243
  13146. <if test="qcResultShortPageVO.userId!=null">
  13147. AND b.user_id = #{qcResultShortPageVO.userId}
  13148. </if>
  13149. <if test="qcResultShortPageVO.titleName != null ">
  13150. <if test="qcResultShortPageVO.titleName == '不合格数'">
  13151. AND c.`level`='不合格'
  13152. </if>
  13153. <if test="qcResultShortPageVO.titleName == '合格数'">
  13154. AND c.`level`='合格'
  13155. </if>
  13156. </if>
  13157. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13158. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13159. </if>
  13160. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13161. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13162. </if>
  13163. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13164. <if test="qcResultShortPageVO.startDate != null ">
  13165. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13166. </if>
  13167. <if test="qcResultShortPageVO.endDate != null ">
  13168. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13169. </if>
  13170. </if>
  13171. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13172. <if test="qcResultShortPageVO.startDate != null ">
  13173. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13174. </if>
  13175. <if test="qcResultShortPageVO.endDate != null">
  13176. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13177. </if>
  13178. </if>
  13179. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13180. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13181. </if>
  13182. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13183. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13184. </if>
  13185. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13186. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13187. </if>
  13188. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13189. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13190. </if>
  13191. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13192. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13193. </if>
  13194. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13195. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13196. </if>
  13197. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13198. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13199. </if>
  13200. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13201. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  13202. </if>
  13203. )be
  13204. left join med_check_info mci
  13205. on mci.is_deleted = 'N'
  13206. and mci.check_type = 0
  13207. and be.hospital_id = mci.hospital_id
  13208. and be.behospital_code = mci.behospital_code
  13209. left join med_check_info hm_mci
  13210. on hm_mci.is_deleted = 'N'
  13211. and hm_mci.check_type = 1
  13212. and be.hospital_id = hm_mci.hospital_id
  13213. and be.behospital_code = hm_mci.behospital_code
  13214. left join med_qcresult_info b
  13215. on b.is_deleted = 'N'
  13216. AND be.hospital_id = b.hospital_id
  13217. AND be.behospital_code = b.behospital_code
  13218. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13219. AND b.`level` = #{qcResultPageVO.level}
  13220. </if>
  13221. left join qc_cases_entry d
  13222. on d.is_deleted = 'N'
  13223. AND be.cases_id = d.cases_id
  13224. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13225. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13226. </if>
  13227. <if test="qcResultShortPageVO.casesEntryId != null ">
  13228. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13229. </if>
  13230. <if test="qcResultShortPageVO.ruleType != null">
  13231. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13232. </if>
  13233. ) t1
  13234. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13235. AND t1.behospital_code = t2.behospital_code
  13236. AND t2.is_deleted = 'N'
  13237. ) t
  13238. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13239. AND t.hospitalId = qi.hospital_id
  13240. AND t.behospitalCode = qi.behospital_code
  13241. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  13242. AND t.hospitalId = t2.hospital_id
  13243. AND t2.is_deleted = 'N'
  13244. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  13245. AND t3.is_deleted = 'N'
  13246. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13247. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13248. AND t.hospitalId = qd.hospital_id
  13249. AND t.behospitalCode = qd.behospital_code
  13250. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13251. AND qd.cases_id = qc.id
  13252. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13253. AND qd.cases_id = qce.cases_id
  13254. AND qd.cases_entry_id = qce.id
  13255. </if>
  13256. where 1=1
  13257. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  13258. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  13259. </if>
  13260. <if test="qcResultShortPageVO.checkStatus != null">
  13261. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13262. </if>
  13263. <if test="qcResultShortPageVO.mrStatus != null">
  13264. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13265. </if>
  13266. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13267. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13268. </if>
  13269. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13270. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13271. </if>
  13272. <if test="qcResultShortPageVO.chTimeStart != null ">
  13273. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13274. </if>
  13275. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13276. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13277. </if>
  13278. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13279. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13280. </if>
  13281. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13282. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13283. </if>
  13284. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13285. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13286. </if>
  13287. <if test="qcResultShortPageVO.casesEntryId != null ">
  13288. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13289. </if>
  13290. )f1,
  13291. (SELECT
  13292. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13293. t.doctorId,
  13294. t.doctorName
  13295. FROM
  13296. (SELECT DISTINCT
  13297. t1.hospital_id AS hospitalId,
  13298. t1.behospital_code AS behospitalCode,
  13299. t1.bed_code AS bedCode,
  13300. t1.LEVEL AS LEVEL,
  13301. t1.grade_type AS gradeType,
  13302. t1.score_res AS scoreRes,
  13303. t1.NAME AS NAME,
  13304. t1.sex AS sex,
  13305. t1.beh_dept_id AS behDeptId,
  13306. t1.beh_dept_name AS behDeptName,
  13307. t1.doctor_id AS doctorId,
  13308. t1.doctor_name AS doctorName,
  13309. t1.beh_doctor_id AS behDoctorId,
  13310. t1.beh_doctor_name AS behDoctorName,
  13311. t1.director_doctor_id AS directorDoctorId,
  13312. t1.director_doctor_name AS directorDoctorName,
  13313. t1.birthday AS birthday,
  13314. t1.behospital_date AS behospitalDate,
  13315. t1.leave_hospital_date AS leaveHospitalDate,
  13316. t1.placefile_date AS placefileDate,
  13317. t1.gmt_create AS gradeTime,
  13318. t1.diagnose,
  13319. t1.ward_name AS wardName,
  13320. t2.age,
  13321. t1.file_code AS fileCode,
  13322. t1.checkStatus,
  13323. t1.mrStatus,
  13324. t1.chName,
  13325. t1.mrName,
  13326. t1.chTime,
  13327. t1.mrTime
  13328. FROM
  13329. (SELECT
  13330. be.*,
  13331. b.grade_type,
  13332. b.score_res,
  13333. b.gmt_create,
  13334. b.LEVEL,
  13335. ifnull(mci.status,0) AS checkStatus,
  13336. ifnull(hm_mci.status,0) AS mrStatus,
  13337. mci.check_name as chName,
  13338. hm_mci.check_name as mrName,
  13339. mci.gmt_create as chTime,
  13340. hm_mci.gmt_create as mrTime
  13341. FROM
  13342. (
  13343. SELECT DISTINCT
  13344. a.hospital_id,
  13345. a.behospital_code,
  13346. a.bed_code,
  13347. a.file_code,
  13348. a.NAME,
  13349. a.sex,
  13350. a.beh_dept_id,
  13351. a.beh_dept_name,
  13352. a.birthday,
  13353. a.behospital_date,
  13354. a.leave_hospital_date,
  13355. a.doctor_id,
  13356. a.doctor_name,
  13357. a.beh_doctor_id,
  13358. a.beh_doctor_name,
  13359. a.director_doctor_id,
  13360. a.director_doctor_name,
  13361. a.diagnose,
  13362. a.placefile_date,
  13363. a.ward_name
  13364. FROM
  13365. med_behospital_info a,
  13366. med_qcresult_detail k,
  13367. sys_user_dept b,
  13368. med_qcresult_cases c,
  13369. qc_cases_entry d
  13370. WHERE
  13371. a.is_deleted = 'N'
  13372. AND b.is_deleted = 'N'
  13373. AND c.is_deleted = 'N'
  13374. AND d.is_deleted = 'N'
  13375. AND a.hospital_id = b.hospital_id
  13376. AND a.hospital_id = c.hospital_id
  13377. AND a.behospital_code = c.behospital_code
  13378. AND a.beh_dept_id = b.dept_id
  13379. AND c.cases_id = d.cases_id
  13380. AND a.hospital_id = k.hospital_id
  13381. AND a.behospital_code = k.behospital_code
  13382. AND c.cases_id = k.cases_id
  13383. AND k.cases_id = d.cases_id
  13384. AND k.cases_entry_id = d.id
  13385. AND a.qc_type_id != 0
  13386. <if test="qcResultShortPageVO.userId!=null">
  13387. AND b.user_id = #{qcResultShortPageVO.userId}
  13388. </if>
  13389. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13390. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13391. </if>
  13392. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13393. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13394. </if>
  13395. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13396. <if test="qcResultShortPageVO.startDate != null ">
  13397. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13398. </if>
  13399. <if test="qcResultShortPageVO.endDate != null ">
  13400. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13401. </if>
  13402. </if>
  13403. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13404. <if test="qcResultShortPageVO.startDate != null ">
  13405. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13406. </if>
  13407. <if test="qcResultShortPageVO.endDate != null">
  13408. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13409. </if>
  13410. </if>
  13411. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13412. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13413. </if>
  13414. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13415. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13416. </if>
  13417. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13418. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13419. </if>
  13420. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13421. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13422. </if>
  13423. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13424. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13425. </if>
  13426. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13427. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13428. </if>
  13429. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13430. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13431. </if>
  13432. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13433. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13434. </if>
  13435. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13436. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  13437. </if>
  13438. <if test="qcResultShortPageVO.casesEntryId != null ">
  13439. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13440. </if>
  13441. <if test="qcResultShortPageVO.ruleType != null">
  13442. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13443. </if>
  13444. )be
  13445. left join med_check_info mci
  13446. on mci.is_deleted = 'N'
  13447. and mci.check_type = 0
  13448. and be.hospital_id = mci.hospital_id
  13449. and be.behospital_code = mci.behospital_code
  13450. left join med_check_info hm_mci
  13451. on hm_mci.is_deleted = 'N'
  13452. and hm_mci.check_type = 1
  13453. and be.hospital_id = hm_mci.hospital_id
  13454. and be.behospital_code = hm_mci.behospital_code
  13455. left join med_qcresult_info b
  13456. on b.is_deleted = 'N'
  13457. AND be.hospital_id = b.hospital_id
  13458. AND be.behospital_code = b.behospital_code
  13459. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13460. AND b.`level` = #{qcResultPageVO.level}
  13461. </if>
  13462. ) t1
  13463. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13464. AND t1.behospital_code = t2.behospital_code
  13465. AND t2.is_deleted = 'N'
  13466. ) t
  13467. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13468. AND t.hospitalId = qi.hospital_id
  13469. AND t.behospitalCode = qi.behospital_code
  13470. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  13471. AND t.hospitalId = t2.hospital_id
  13472. AND t2.is_deleted = 'N'
  13473. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  13474. AND t3.is_deleted = 'N'
  13475. where 1=1
  13476. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  13477. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  13478. </if>
  13479. <if test="qcResultShortPageVO.checkStatus != null">
  13480. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13481. </if>
  13482. <if test="qcResultShortPageVO.mrStatus != null">
  13483. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13484. </if>
  13485. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13486. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13487. </if>
  13488. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13489. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13490. </if>
  13491. <if test="qcResultShortPageVO.chTimeStart != null ">
  13492. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13493. </if>
  13494. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13495. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13496. </if>
  13497. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13498. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13499. </if>
  13500. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13501. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13502. </if>
  13503. GROUP BY
  13504. t.behDeptId,
  13505. t.behDeptName,
  13506. t.doctorId,
  13507. t.doctorName
  13508. )f2
  13509. WHERE
  13510. f1.doctorId = f2.doctorId
  13511. AND f1.doctorName = f2.doctorName
  13512. </select>
  13513. <!-- 未整改病历缺陷评分详情页导出-->
  13514. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  13515. SELECT
  13516. f1.behDeptId,
  13517. f1.behDeptName,
  13518. f1.doctorName,
  13519. f1.patName,
  13520. f1.behospitalCode,
  13521. f1.hospitalId,
  13522. f1.behospitalDate,
  13523. f1.leaveHospitalDate,
  13524. f1.score,
  13525. f1.scoreBn,
  13526. f2.avgScore,
  13527. f1.msg,
  13528. f1.caseName,
  13529. f1.checkStatus,
  13530. f1.mrStatus,
  13531. f1.chName,
  13532. f1.mrName,
  13533. f1.chTime,
  13534. f1.mrTime
  13535. FROM
  13536. (SELECT
  13537. t.doctorName,
  13538. t.`name` AS patName,
  13539. t.behospitalCode AS behospitalCode,
  13540. t.behospitalDate AS behospitalDate,
  13541. t.leaveHospitalDate AS leaveHospitalDate,
  13542. qi.score_res AS score,
  13543. t.scoreBn,
  13544. qd.msg AS msg,
  13545. qc.NAME AS caseName,
  13546. t.behDeptId,
  13547. t.behDeptName,
  13548. t.hospitalId,
  13549. t.checkStatus,
  13550. t.mrStatus,
  13551. t.chName,
  13552. t.mrName,
  13553. t.chTime,
  13554. t.mrTime
  13555. FROM
  13556. (SELECT DISTINCT
  13557. t1.hospital_id AS hospitalId,
  13558. t1.behospital_code AS behospitalCode,
  13559. t1.bed_code AS bedCode,
  13560. t1.LEVEL AS LEVEL,
  13561. t1.grade_type AS gradeType,
  13562. t1.score_res AS scoreRes,
  13563. t1.scoreBn,
  13564. t1.NAME AS NAME,
  13565. t1.sex AS sex,
  13566. t1.beh_dept_id AS behDeptId,
  13567. t1.beh_dept_name AS behDeptName,
  13568. t1.doctor_id AS doctorId,
  13569. t1.doctor_name AS doctorName,
  13570. t1.beh_doctor_id AS behDoctorId,
  13571. t1.beh_doctor_name AS behDoctorName,
  13572. t1.director_doctor_id AS directorDoctorId,
  13573. t1.director_doctor_name AS directorDoctorName,
  13574. t1.birthday AS birthday,
  13575. t1.behospital_date AS behospitalDate,
  13576. t1.leave_hospital_date AS leaveHospitalDate,
  13577. t1.placefile_date AS placefileDate,
  13578. t1.gmt_create AS gradeTime,
  13579. t1.diagnose,
  13580. t1.ward_name AS wardName,
  13581. t2.age,
  13582. t1.file_code AS fileCode,
  13583. t1.checkStatus,
  13584. t1.mrStatus,
  13585. t1.chName,
  13586. t1.mrName,
  13587. t1.chTime,
  13588. t1.mrTime
  13589. FROM
  13590. (SELECT
  13591. be.*,
  13592. ifnull(mci.status,0) AS checkStatus,
  13593. ifnull(hm_mci.status,0) AS mrStatus,
  13594. mci.check_name as chName,
  13595. e.score_res as scoreBn,
  13596. hm_mci.check_name as mrName,
  13597. mci.gmt_create as chTime,
  13598. hm_mci.gmt_create as mrTime
  13599. FROM
  13600. (
  13601. SELECT DISTINCT
  13602. a.hospital_id,
  13603. a.behospital_code,
  13604. a.bed_code,
  13605. a.file_code,
  13606. b.LEVEL,
  13607. b.grade_type,
  13608. b.score_res,
  13609. a.NAME,
  13610. a.sex,
  13611. a.beh_dept_id,
  13612. a.beh_dept_name,
  13613. a.birthday,
  13614. a.behospital_date,
  13615. a.leave_hospital_date,
  13616. a.doctor_id,
  13617. a.doctor_name,
  13618. a.beh_doctor_id,
  13619. a.beh_doctor_name,
  13620. a.director_doctor_id,
  13621. a.director_doctor_name,
  13622. a.diagnose,
  13623. a.placefile_date,
  13624. a.ward_name,
  13625. b.gmt_create
  13626. FROM
  13627. med_behospital_info a,
  13628. med_qcresult_info b,
  13629. med_qcresult_detail c,
  13630. qc_cases_entry d
  13631. WHERE
  13632. a.is_deleted = 'N'
  13633. AND b.is_deleted = 'N'
  13634. AND c.is_deleted = 'N'
  13635. AND d.is_deleted = 'N'
  13636. AND a.hospital_id = b.hospital_id
  13637. AND a.hospital_id = c.hospital_id
  13638. AND a.behospital_code = b.behospital_code
  13639. AND a.behospital_code = c.behospital_code
  13640. AND c.cases_id = d.cases_id
  13641. AND c.cases_entry_id = d.id
  13642. AND a.qc_type_id != 0
  13643. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13644. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13645. </if>
  13646. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13647. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13648. </if>
  13649. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13650. <if test="qcResultShortPageVO.startDate != null ">
  13651. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13652. </if>
  13653. <if test="qcResultShortPageVO.endDate != null ">
  13654. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13655. </if>
  13656. </if>
  13657. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13658. <if test="qcResultShortPageVO.startDate != null ">
  13659. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13660. </if>
  13661. <if test="qcResultShortPageVO.endDate != null">
  13662. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13663. </if>
  13664. </if>
  13665. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13666. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13667. </if>
  13668. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13669. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13670. </if>
  13671. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13672. AND b.`level` = #{qcResultShortPageVO.level}
  13673. </if>
  13674. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13675. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13676. </if>
  13677. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13678. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13679. </if>
  13680. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13681. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13682. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13683. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13684. </if>
  13685. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13686. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13687. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13688. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13689. </if>
  13690. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13691. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13692. </if>
  13693. <if test="qcResultShortPageVO.casesEntryId != null ">
  13694. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13695. </if>
  13696. <if test="qcResultShortPageVO.isReject != null">
  13697. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13698. </if>
  13699. <if test="qcResultShortPageVO.ruleType != null">
  13700. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13701. </if>
  13702. )be
  13703. left join med_check_info mci
  13704. on mci.is_deleted = 'N'
  13705. and mci.check_type = 0
  13706. and be.hospital_id = mci.hospital_id
  13707. and be.behospital_code = mci.behospital_code
  13708. left join med_check_info hm_mci
  13709. on hm_mci.is_deleted = 'N'
  13710. and hm_mci.check_type = 1
  13711. and be.hospital_id = hm_mci.hospital_id
  13712. and be.behospital_code = hm_mci.behospital_code
  13713. LEFT JOIN med_qcresult_cases e
  13714. on be.behospital_code = e.behospital_code
  13715. and be.hospital_id = e.hospital_id
  13716. AND e.is_deleted = 'N'
  13717. and e.cases_id = 243
  13718. ) t1
  13719. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13720. AND t1.behospital_code = t2.behospital_code
  13721. AND t2.is_deleted = 'N'
  13722. ) t
  13723. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13724. AND t.hospitalId = qi.hospital_id
  13725. AND t.behospitalCode = qi.behospital_code
  13726. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13727. AND t.hospitalId = qd.hospital_id
  13728. AND t.behospitalCode = qd.behospital_code
  13729. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13730. AND qd.cases_id = qc.id
  13731. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13732. AND qd.cases_id = qce.cases_id
  13733. AND qd.cases_entry_id = qce.id
  13734. where 1=1
  13735. <if test="qcResultShortPageVO.checkStatus != null">
  13736. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13737. </if>
  13738. <if test="qcResultShortPageVO.mrStatus != null">
  13739. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13740. </if>
  13741. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13742. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13743. </if>
  13744. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13745. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13746. </if>
  13747. <if test="qcResultShortPageVO.chTimeStart != null ">
  13748. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13749. </if>
  13750. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13751. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13752. </if>
  13753. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13754. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13755. </if>
  13756. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13757. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13758. </if>
  13759. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13760. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13761. </if>
  13762. <if test="qcResultShortPageVO.casesEntryId != null ">
  13763. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13764. </if>
  13765. )f1,
  13766. (SELECT
  13767. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13768. t.behDeptId,
  13769. t.behDeptName
  13770. FROM
  13771. (SELECT DISTINCT
  13772. t1.hospital_id AS hospitalId,
  13773. t1.behospital_code AS behospitalCode,
  13774. t1.bed_code AS bedCode,
  13775. t1.LEVEL AS LEVEL,
  13776. t1.grade_type AS gradeType,
  13777. t1.score_res AS scoreRes,
  13778. t1.NAME AS NAME,
  13779. t1.sex AS sex,
  13780. t1.beh_dept_id AS behDeptId,
  13781. t1.beh_dept_name AS behDeptName,
  13782. t1.doctor_id AS doctorId,
  13783. t1.doctor_name AS doctorName,
  13784. t1.beh_doctor_id AS behDoctorId,
  13785. t1.beh_doctor_name AS behDoctorName,
  13786. t1.director_doctor_id AS directorDoctorId,
  13787. t1.director_doctor_name AS directorDoctorName,
  13788. t1.birthday AS birthday,
  13789. t1.behospital_date AS behospitalDate,
  13790. t1.leave_hospital_date AS leaveHospitalDate,
  13791. t1.placefile_date AS placefileDate,
  13792. t1.gmt_create AS gradeTime,
  13793. t1.diagnose,
  13794. t1.ward_name AS wardName,
  13795. t2.age,
  13796. t1.file_code AS fileCode,
  13797. t1.checkStatus,
  13798. t1.mrStatus,
  13799. t1.chName,
  13800. t1.mrName,
  13801. t1.chTime,
  13802. t1.mrTime
  13803. FROM
  13804. (SELECT
  13805. be.*,
  13806. ifnull(mci.status,0) AS checkStatus,
  13807. ifnull(hm_mci.status,0) AS mrStatus,
  13808. mci.check_name as chName,
  13809. hm_mci.check_name as mrName,
  13810. mci.gmt_create as chTime,
  13811. hm_mci.gmt_create as mrTime
  13812. FROM
  13813. (
  13814. SELECT DISTINCT
  13815. a.hospital_id,
  13816. a.behospital_code,
  13817. a.bed_code,
  13818. a.file_code,
  13819. b.LEVEL,
  13820. b.grade_type,
  13821. b.score_res,
  13822. a.NAME,
  13823. a.sex,
  13824. a.beh_dept_id,
  13825. a.beh_dept_name,
  13826. a.birthday,
  13827. a.behospital_date,
  13828. a.leave_hospital_date,
  13829. a.doctor_id,
  13830. a.doctor_name,
  13831. a.beh_doctor_id,
  13832. a.beh_doctor_name,
  13833. a.director_doctor_id,
  13834. a.director_doctor_name,
  13835. a.diagnose,
  13836. a.placefile_date,
  13837. a.ward_name,
  13838. b.gmt_create
  13839. FROM
  13840. med_behospital_info a,
  13841. med_qcresult_info b,
  13842. med_qcresult_detail c,
  13843. qc_cases_entry d
  13844. WHERE
  13845. a.is_deleted = 'N'
  13846. AND b.is_deleted = 'N'
  13847. AND c.is_deleted = 'N'
  13848. AND d.is_deleted = 'N'
  13849. AND a.hospital_id = b.hospital_id
  13850. AND a.hospital_id = c.hospital_id
  13851. AND a.behospital_code = b.behospital_code
  13852. AND a.behospital_code = c.behospital_code
  13853. AND c.cases_id = d.cases_id
  13854. AND c.cases_entry_id = d.id
  13855. AND a.qc_type_id != 0
  13856. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13857. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13858. </if>
  13859. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13860. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13861. </if>
  13862. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13863. <if test="qcResultShortPageVO.startDate != null ">
  13864. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13865. </if>
  13866. <if test="qcResultShortPageVO.endDate != null ">
  13867. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13868. </if>
  13869. </if>
  13870. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13871. <if test="qcResultShortPageVO.startDate != null ">
  13872. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13873. </if>
  13874. <if test="qcResultShortPageVO.endDate != null">
  13875. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13876. </if>
  13877. </if>
  13878. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13879. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13880. </if>
  13881. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13882. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13883. </if>
  13884. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13885. AND b.`level` = #{qcResultShortPageVO.level}
  13886. </if>
  13887. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13888. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13889. </if>
  13890. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13891. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13892. </if>
  13893. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13894. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13895. </if>
  13896. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13897. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13898. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13899. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13900. </if>
  13901. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13902. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13903. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13904. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13905. </if>
  13906. <if test="qcResultShortPageVO.casesEntryId != null ">
  13907. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13908. </if>
  13909. <if test="qcResultShortPageVO.isReject != null">
  13910. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13911. </if>
  13912. <if test="qcResultShortPageVO.ruleType != null">
  13913. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13914. </if>
  13915. )be
  13916. left join med_check_info mci
  13917. on mci.is_deleted = 'N'
  13918. and mci.check_type = 0
  13919. and be.hospital_id = mci.hospital_id
  13920. and be.behospital_code = mci.behospital_code
  13921. left join med_check_info hm_mci
  13922. on hm_mci.is_deleted = 'N'
  13923. and hm_mci.check_type = 1
  13924. and be.hospital_id = hm_mci.hospital_id
  13925. and be.behospital_code = hm_mci.behospital_code
  13926. ) t1
  13927. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13928. AND t1.behospital_code = t2.behospital_code
  13929. AND t2.is_deleted = 'N'
  13930. ) t
  13931. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13932. AND t.hospitalId = qi.hospital_id
  13933. AND t.behospitalCode = qi.behospital_code
  13934. where 1=1
  13935. <if test="qcResultShortPageVO.checkStatus != null">
  13936. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13937. </if>
  13938. <if test="qcResultShortPageVO.mrStatus != null">
  13939. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13940. </if>
  13941. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13942. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13943. </if>
  13944. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13945. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13946. </if>
  13947. <if test="qcResultShortPageVO.chTimeStart != null ">
  13948. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13949. </if>
  13950. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13951. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13952. </if>
  13953. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13954. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13955. </if>
  13956. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13957. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13958. </if>
  13959. GROUP BY
  13960. t.behDeptId,
  13961. t.behDeptName
  13962. )f2
  13963. WHERE
  13964. f1.behDeptId = f2.behDeptId
  13965. AND f1.behDeptName = f2.behDeptName
  13966. </select>
  13967. <!-- 未整改病历缺陷评分详情页导出-科室-->
  13968. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  13969. SELECT
  13970. f1.behDeptId,
  13971. f1.behDeptName,
  13972. f1.wardName,
  13973. f1.medoupName,
  13974. f1.doctorName,
  13975. f1.patName,
  13976. f1.behospitalCode,
  13977. f1.hospitalId,
  13978. f1.behospitalDate,
  13979. f1.leaveHospitalDate,
  13980. f1.score,
  13981. f1.scoreBn,
  13982. f2.avgScore,
  13983. f1.msg,
  13984. f1.caseName,
  13985. f1.checkStatus,
  13986. f1.mrStatus,
  13987. f1.chName,
  13988. f1.mrName,
  13989. f1.chTime,
  13990. f1.mrTime
  13991. FROM
  13992. (SELECT
  13993. t.doctorName,
  13994. t.doctorId,
  13995. t.wardName,
  13996. t3.name as medoupName,
  13997. t.`name` AS patName,
  13998. t.behospitalCode AS behospitalCode,
  13999. t.behospitalDate AS behospitalDate,
  14000. t.leaveHospitalDate AS leaveHospitalDate,
  14001. qi.score_res AS score,
  14002. t.scoreBn,
  14003. qd.msg AS msg,
  14004. qc.NAME AS caseName,
  14005. t.behDeptId,
  14006. t.behDeptName,
  14007. t.hospitalId,
  14008. t.checkStatus,
  14009. t.mrStatus,
  14010. t.chName,
  14011. t.mrName,
  14012. t.chTime,
  14013. t.mrTime
  14014. FROM
  14015. (SELECT DISTINCT
  14016. t1.hospital_id AS hospitalId,
  14017. t1.behospital_code AS behospitalCode,
  14018. t1.bed_code AS bedCode,
  14019. t1.LEVEL AS LEVEL,
  14020. t1.grade_type AS gradeType,
  14021. t1.score_res AS scoreRes,
  14022. t1.scoreBn,
  14023. t1.NAME AS NAME,
  14024. t1.sex AS sex,
  14025. t1.beh_dept_id AS behDeptId,
  14026. t1.beh_dept_name AS behDeptName,
  14027. t1.doctor_id AS doctorId,
  14028. t1.doctor_name AS doctorName,
  14029. t1.beh_doctor_id AS behDoctorId,
  14030. t1.beh_doctor_name AS behDoctorName,
  14031. t1.director_doctor_id AS directorDoctorId,
  14032. t1.director_doctor_name AS directorDoctorName,
  14033. t1.birthday AS birthday,
  14034. t1.behospital_date AS behospitalDate,
  14035. t1.leave_hospital_date AS leaveHospitalDate,
  14036. t1.placefile_date AS placefileDate,
  14037. t1.gmt_create AS gradeTime,
  14038. t1.diagnose,
  14039. t1.ward_name AS wardName,
  14040. t2.age,
  14041. t1.file_code AS fileCode,
  14042. t1.checkStatus,
  14043. t1.mrStatus,
  14044. t1.chName,
  14045. t1.mrName,
  14046. t1.chTime,
  14047. t1.mrTime
  14048. FROM
  14049. (SELECT
  14050. be.*,
  14051. ifnull(mci.status,0) AS checkStatus,
  14052. ifnull(hm_mci.status,0) AS mrStatus,
  14053. mci.check_name as chName,
  14054. e.score_res as scoreBn,
  14055. hm_mci.check_name as mrName,
  14056. mci.gmt_create as chTime,
  14057. hm_mci.gmt_create as mrTime
  14058. FROM
  14059. (
  14060. SELECT DISTINCT
  14061. a.hospital_id,
  14062. a.behospital_code,
  14063. a.bed_code,
  14064. a.file_code,
  14065. b.LEVEL,
  14066. b.grade_type,
  14067. b.score_res,
  14068. a.NAME,
  14069. a.sex,
  14070. a.beh_dept_id,
  14071. a.beh_dept_name,
  14072. a.birthday,
  14073. a.behospital_date,
  14074. a.leave_hospital_date,
  14075. a.doctor_id,
  14076. a.doctor_name,
  14077. a.beh_doctor_id,
  14078. a.beh_doctor_name,
  14079. a.director_doctor_id,
  14080. a.director_doctor_name,
  14081. a.diagnose,
  14082. a.placefile_date,
  14083. a.ward_name,
  14084. b.gmt_create
  14085. FROM
  14086. med_behospital_info a,
  14087. med_qcresult_info b,
  14088. med_qcresult_detail c,
  14089. qc_cases_entry d,
  14090. sys_user_dept f
  14091. WHERE
  14092. a.is_deleted = 'N'
  14093. AND b.is_deleted = 'N'
  14094. AND c.is_deleted = 'N'
  14095. AND d.is_deleted = 'N'
  14096. AND f.is_deleted = 'N'
  14097. AND a.hospital_id = b.hospital_id
  14098. AND a.hospital_id = c.hospital_id
  14099. AND a.hospital_id = f.hospital_id
  14100. AND a.behospital_code = b.behospital_code
  14101. AND a.behospital_code = c.behospital_code
  14102. AND c.cases_id = d.cases_id
  14103. AND c.cases_entry_id = d.id
  14104. AND a.beh_dept_id = f.dept_id
  14105. AND a.qc_type_id != 0
  14106. <if test="qcResultShortPageVO.userId!=null">
  14107. AND f.user_id = #{qcResultShortPageVO.userId}
  14108. </if>
  14109. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14110. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14111. </if>
  14112. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14113. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14114. </if>
  14115. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14116. <if test="qcResultShortPageVO.startDate != null ">
  14117. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14118. </if>
  14119. <if test="qcResultShortPageVO.endDate != null ">
  14120. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14121. </if>
  14122. </if>
  14123. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14124. <if test="qcResultShortPageVO.startDate != null ">
  14125. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14126. </if>
  14127. <if test="qcResultShortPageVO.endDate != null">
  14128. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14129. </if>
  14130. </if>
  14131. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14132. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14133. </if>
  14134. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  14135. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  14136. </if>
  14137. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14138. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14139. </if>
  14140. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14141. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14142. </if>
  14143. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14144. AND b.`level` = #{qcResultShortPageVO.level}
  14145. </if>
  14146. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14147. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14148. </if>
  14149. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14150. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14151. </if>
  14152. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14153. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14154. </if>
  14155. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14156. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  14157. </if>
  14158. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14159. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14160. </if>
  14161. <if test="qcResultShortPageVO.casesEntryId != null ">
  14162. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14163. </if>
  14164. <if test="qcResultShortPageVO.isReject != null">
  14165. AND c.is_reject = #{qcResultShortPageVO.isReject}
  14166. </if>
  14167. <if test="qcResultShortPageVO.ruleType != null">
  14168. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14169. </if>
  14170. )be
  14171. left join med_check_info mci
  14172. on mci.is_deleted = 'N'
  14173. and mci.check_type = 0
  14174. and be.hospital_id = mci.hospital_id
  14175. and be.behospital_code = mci.behospital_code
  14176. left join med_check_info hm_mci
  14177. on hm_mci.is_deleted = 'N'
  14178. and hm_mci.check_type = 1
  14179. and be.hospital_id = hm_mci.hospital_id
  14180. and be.behospital_code = hm_mci.behospital_code
  14181. LEFT JOIN med_qcresult_cases e
  14182. on be.behospital_code = e.behospital_code
  14183. and be.hospital_id = e.hospital_id
  14184. AND e.is_deleted = 'N'
  14185. and e.cases_id = 243
  14186. ) t1
  14187. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14188. AND t1.behospital_code = t2.behospital_code
  14189. AND t2.is_deleted = 'N'
  14190. ) t
  14191. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14192. AND t.hospitalId = qi.hospital_id
  14193. AND t.behospitalCode = qi.behospital_code
  14194. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14195. AND t.hospitalId = qd.hospital_id
  14196. AND t.behospitalCode = qd.behospital_code
  14197. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14198. AND qd.cases_id = qc.id
  14199. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  14200. AND qd.cases_id = qce.cases_id
  14201. AND qd.cases_entry_id = qce.id
  14202. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  14203. AND t.hospitalId = t2.hospital_id
  14204. AND t2.is_deleted = 'N'
  14205. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  14206. AND t3.is_deleted = 'N'
  14207. where 1=1
  14208. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  14209. AND t3.name like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  14210. </if>
  14211. <if test="qcResultShortPageVO.checkStatus != null">
  14212. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14213. </if>
  14214. <if test="qcResultShortPageVO.mrStatus != null">
  14215. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14216. </if>
  14217. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14218. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14219. </if>
  14220. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14221. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14222. </if>
  14223. <if test="qcResultShortPageVO.chTimeStart != null ">
  14224. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14225. </if>
  14226. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14227. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14228. </if>
  14229. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14230. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14231. </if>
  14232. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14233. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14234. </if>
  14235. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14236. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  14237. </if>
  14238. <if test="qcResultShortPageVO.casesEntryId != null ">
  14239. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  14240. </if>
  14241. )f1,
  14242. (SELECT
  14243. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14244. t.behDeptId,
  14245. t.behDeptName,
  14246. t.doctorId,
  14247. t.doctorName
  14248. FROM
  14249. (SELECT DISTINCT
  14250. t1.hospital_id AS hospitalId,
  14251. t1.behospital_code AS behospitalCode,
  14252. t1.bed_code AS bedCode,
  14253. t1.LEVEL AS LEVEL,
  14254. t1.grade_type AS gradeType,
  14255. t1.score_res AS scoreRes,
  14256. t1.NAME AS NAME,
  14257. t1.sex AS sex,
  14258. t1.beh_dept_id AS behDeptId,
  14259. t1.beh_dept_name AS behDeptName,
  14260. t1.doctor_id AS doctorId,
  14261. t1.doctor_name AS doctorName,
  14262. t1.beh_doctor_id AS behDoctorId,
  14263. t1.beh_doctor_name AS behDoctorName,
  14264. t1.director_doctor_id AS directorDoctorId,
  14265. t1.director_doctor_name AS directorDoctorName,
  14266. t1.birthday AS birthday,
  14267. t1.behospital_date AS behospitalDate,
  14268. t1.leave_hospital_date AS leaveHospitalDate,
  14269. t1.placefile_date AS placefileDate,
  14270. t1.gmt_create AS gradeTime,
  14271. t1.diagnose,
  14272. t1.ward_name AS wardName,
  14273. t2.age,
  14274. t1.file_code AS fileCode,
  14275. t1.checkStatus,
  14276. t1.mrStatus,
  14277. t1.chName,
  14278. t1.mrName,
  14279. t1.chTime,
  14280. t1.mrTime
  14281. FROM
  14282. (SELECT
  14283. be.*,
  14284. ifnull(mci.status,0) AS checkStatus,
  14285. ifnull(hm_mci.status,0) AS mrStatus,
  14286. mci.check_name as chName,
  14287. hm_mci.check_name as mrName,
  14288. mci.gmt_create as chTime,
  14289. hm_mci.gmt_create as mrTime
  14290. FROM
  14291. (
  14292. SELECT DISTINCT
  14293. a.hospital_id,
  14294. a.behospital_code,
  14295. a.bed_code,
  14296. a.file_code,
  14297. b.LEVEL,
  14298. b.grade_type,
  14299. b.score_res,
  14300. a.NAME,
  14301. a.sex,
  14302. a.beh_dept_id,
  14303. a.beh_dept_name,
  14304. a.birthday,
  14305. a.behospital_date,
  14306. a.leave_hospital_date,
  14307. a.doctor_id,
  14308. a.doctor_name,
  14309. a.beh_doctor_id,
  14310. a.beh_doctor_name,
  14311. a.director_doctor_id,
  14312. a.director_doctor_name,
  14313. a.diagnose,
  14314. a.placefile_date,
  14315. a.ward_name,
  14316. b.gmt_create
  14317. FROM
  14318. med_behospital_info a,
  14319. med_qcresult_info b,
  14320. med_qcresult_detail c,
  14321. qc_cases_entry d,
  14322. sys_user_dept f
  14323. WHERE
  14324. a.is_deleted = 'N'
  14325. AND b.is_deleted = 'N'
  14326. AND c.is_deleted = 'N'
  14327. AND d.is_deleted = 'N'
  14328. AND f.is_deleted = 'N'
  14329. AND a.hospital_id = b.hospital_id
  14330. AND a.hospital_id = c.hospital_id
  14331. AND a.hospital_id = f.hospital_id
  14332. AND a.behospital_code = b.behospital_code
  14333. AND a.behospital_code = c.behospital_code
  14334. AND c.cases_id = d.cases_id
  14335. AND c.cases_entry_id = d.id
  14336. AND a.beh_dept_id = f.dept_id
  14337. AND a.qc_type_id != 0
  14338. <if test="qcResultShortPageVO.userId!=null">
  14339. AND f.user_id = #{qcResultShortPageVO.userId}
  14340. </if>
  14341. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14342. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14343. </if>
  14344. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14345. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14346. </if>
  14347. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14348. <if test="qcResultShortPageVO.startDate != null ">
  14349. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14350. </if>
  14351. <if test="qcResultShortPageVO.endDate != null ">
  14352. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14353. </if>
  14354. </if>
  14355. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14356. <if test="qcResultShortPageVO.startDate != null ">
  14357. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14358. </if>
  14359. <if test="qcResultShortPageVO.endDate != null">
  14360. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14361. </if>
  14362. </if>
  14363. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14364. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14365. </if>
  14366. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  14367. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  14368. </if>
  14369. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14370. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14371. </if>
  14372. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14373. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14374. </if>
  14375. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14376. AND b.`level` = #{qcResultShortPageVO.level}
  14377. </if>
  14378. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14379. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14380. </if>
  14381. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14382. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14383. </if>
  14384. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  14385. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  14386. </if>
  14387. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14388. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14389. </if>
  14390. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14391. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  14392. </if>
  14393. <if test="qcResultShortPageVO.casesEntryId != null ">
  14394. AND d.id = #{qcResultShortPageVO.casesEntryId}
  14395. </if>
  14396. <if test="qcResultShortPageVO.isReject != null">
  14397. AND c.is_reject = #{qcResultShortPageVO.isReject}
  14398. </if>
  14399. <if test="qcResultShortPageVO.ruleType != null">
  14400. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  14401. </if>
  14402. )be
  14403. left join med_check_info mci
  14404. on mci.is_deleted = 'N'
  14405. and mci.check_type = 0
  14406. and be.hospital_id = mci.hospital_id
  14407. and be.behospital_code = mci.behospital_code
  14408. left join med_check_info hm_mci
  14409. on hm_mci.is_deleted = 'N'
  14410. and hm_mci.check_type = 1
  14411. and be.hospital_id = hm_mci.hospital_id
  14412. and be.behospital_code = hm_mci.behospital_code
  14413. ) t1
  14414. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14415. AND t1.behospital_code = t2.behospital_code
  14416. AND t2.is_deleted = 'N'
  14417. ) t
  14418. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14419. AND t.hospitalId = qi.hospital_id
  14420. AND t.behospitalCode = qi.behospital_code
  14421. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  14422. AND t.hospitalId = t2.hospital_id
  14423. AND t2.is_deleted = 'N'
  14424. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  14425. AND t3.is_deleted = 'N'
  14426. where 1=1
  14427. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  14428. AND t3.name like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  14429. </if>
  14430. <if test="qcResultShortPageVO.checkStatus != null">
  14431. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14432. </if>
  14433. <if test="qcResultShortPageVO.mrStatus != null">
  14434. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14435. </if>
  14436. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14437. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14438. </if>
  14439. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14440. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14441. </if>
  14442. <if test="qcResultShortPageVO.chTimeStart != null ">
  14443. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14444. </if>
  14445. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14446. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14447. </if>
  14448. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14449. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14450. </if>
  14451. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14452. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14453. </if>
  14454. GROUP BY
  14455. t.doctorId,
  14456. t.doctorName
  14457. )f2
  14458. WHERE
  14459. f1.doctorId = f2.doctorId
  14460. AND f1.doctorName = f2.doctorName
  14461. </select>
  14462. <!-- 31天再入院详情页-->
  14463. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14464. SELECT
  14465. t.fileCode,
  14466. t.diagnose,
  14467. t.diagnoseName,
  14468. t.NAME,
  14469. t.sex,
  14470. t.hospitalId,
  14471. t.behDeptId,
  14472. t.behDeptName,
  14473. t.behospitalCode,
  14474. t.behospitalDate,
  14475. t.lastDiagnose,
  14476. t.lastDiagnoseName,
  14477. t.leaveHospitalDate,
  14478. t.lastBehDeptId,
  14479. t.lastBehDeptName,
  14480. t.lastBehospitalCode,
  14481. t.lastBehospitalDate,
  14482. t.lastLeaveHospitalDate,
  14483. t.diffDays,
  14484. mqi.score_res AS scoreRes,
  14485. mqi.LEVEL AS LEVEL,
  14486. mqi_last.score_res AS lastScoreRes,
  14487. mqi_last.LEVEL AS lastLevel,
  14488. mhp.total_fee AS totleFee,
  14489. mhp.behospital_day_num AS behospitalDayNum,
  14490. mhp.again_behospital_plan AS againBehospitalPlan,
  14491. IF(mhp.age is null, null,CONCAT( ifnull(mhp.age,'') ,ifnull(mhp.age_unit,'') ))as age,
  14492. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  14493. IF(mhp_last.age is null, null,CONCAT( ifnull(mhp_last.age,'') ,ifnull(mhp_last.age_unit,'') ))as lastAge,
  14494. mhp_last.total_fee AS lastTotleFee,
  14495. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14496. FROM
  14497. (
  14498. SELECT
  14499. be.fileCode,
  14500. be.diagnose,
  14501. be.diagnoseName,
  14502. be.NAME,
  14503. be.sex,
  14504. be.hospitalId,
  14505. be.behDeptId,
  14506. be.behDeptName,
  14507. be.behospitalCode,
  14508. be.behospitalDate,
  14509. be.leaveHospitalDate,
  14510. be.lastDiagnose,
  14511. be.lastDiagnoseName,
  14512. be.lastBehDeptId,
  14513. be.lastBehDeptName,
  14514. be.lastBehospitalCode,
  14515. be.lastBehospitalDate,
  14516. be.lastLeaveHospitalDate,
  14517. be.diffDays
  14518. FROM
  14519. (
  14520. SELECT
  14521. r1.file_code AS fileCode,
  14522. r1.diagnose,
  14523. r1.diagnose_name AS diagnoseName,
  14524. r1.NAME,
  14525. r1.sex,
  14526. r1.hospital_id AS hospitalId,
  14527. r1.beh_dept_id AS behDeptId,
  14528. r1.beh_dept_name AS behDeptName,
  14529. r1.behospital_code AS behospitalCode,
  14530. r1.behospital_date AS behospitalDate,
  14531. r1.leave_hospital_date AS leaveHospitalDate,
  14532. r2.diagnose AS lastDiagnose,
  14533. r2.diagnose_name AS lastDiagnoseName,
  14534. r2.beh_dept_id AS lastBehDeptId,
  14535. r2.beh_dept_name AS lastBehDeptName,
  14536. r2.behospital_code AS lastBehospitalCode,
  14537. r2.behospital_date AS lastBehospitalDate,
  14538. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14539. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14540. FROM
  14541. (
  14542. SELECT
  14543. ( @rownum := @rownum + 1 ) AS rownum,
  14544. t1.file_code,
  14545. t1.behospital_code,
  14546. t1.diagnose,
  14547. t1.diagnose_name,
  14548. t1.NAME,
  14549. t1.sex,
  14550. t1.hospital_id,
  14551. t1.beh_dept_id,
  14552. t1.beh_dept_name,
  14553. t1.behospital_date,
  14554. t1.leave_hospital_date
  14555. FROM(
  14556. select
  14557. tt3.file_code,
  14558. tt3.behospital_code,
  14559. tt3.diagnose,
  14560. tt3.NAME,
  14561. tt3.sex,
  14562. tt3.hospital_id,
  14563. tt3.beh_dept_id,
  14564. tt3.beh_dept_name,
  14565. tt3.behospital_date,
  14566. tt3.leave_hospital_date,
  14567. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14568. FROM(
  14569. SELECT
  14570. tt2.file_code,
  14571. tt2.diagnose,
  14572. tt2.NAME,
  14573. tt2.sex,
  14574. tt2.hospital_id,
  14575. tt2.beh_dept_id,
  14576. tt2.beh_dept_name,
  14577. tt2.behospital_code,
  14578. tt2.behospital_date,
  14579. tt2.leave_hospital_date
  14580. FROM
  14581. (
  14582. SELECT
  14583. a.file_code
  14584. FROM
  14585. med_behospital_info a
  14586. WHERE
  14587. a.is_deleted = 'N'
  14588. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14589. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14590. </if>
  14591. AND a.qc_type_id != 0
  14592. AND IFNULL( a.diagnose, '' )!= ''
  14593. AND IFNULL( a.file_code, '' )!= ''
  14594. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14595. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14596. </if>
  14597. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14598. <if test="reBeHosPageVO.startDate != null ">
  14599. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14600. </if>
  14601. <if test="reBeHosPageVO.endDate != null ">
  14602. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14603. </if>
  14604. </if>
  14605. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14606. <if test="reBeHosPageVO.startDate != null ">
  14607. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14608. </if>
  14609. <if test="reBeHosPageVO.endDate != null">
  14610. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14611. </if>
  14612. </if>
  14613. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14614. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14615. </if>
  14616. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14617. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14618. </if>
  14619. GROUP BY
  14620. a.file_code
  14621. HAVING
  14622. count(*)> 1
  14623. ) tt1,
  14624. med_behospital_info tt2
  14625. WHERE
  14626. tt2.is_deleted = 'N'
  14627. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14628. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14629. </if>
  14630. AND tt2.qc_type_id != 0
  14631. AND tt1.file_code = tt2.file_code
  14632. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14633. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14634. </if>
  14635. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14636. <if test="reBeHosPageVO.startDate != null ">
  14637. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14638. </if>
  14639. <if test="reBeHosPageVO.endDate != null ">
  14640. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14641. </if>
  14642. </if>
  14643. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14644. <if test="reBeHosPageVO.startDate != null ">
  14645. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14646. </if>
  14647. <if test="reBeHosPageVO.endDate != null">
  14648. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14649. </if>
  14650. </if>
  14651. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14652. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14653. </if>
  14654. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14655. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14656. </if>
  14657. ORDER BY
  14658. tt1.file_code,
  14659. tt2.behospital_date DESC)tt3
  14660. left join med_home_page tt4 on tt4.is_deleted = 'N'
  14661. AND tt3.hospital_id = tt4.hospital_id
  14662. AND tt3.behospital_code = tt4.behospital_code
  14663. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  14664. AND tt4.hospital_id = tt5.hospital_id
  14665. AND tt4.home_page_id = tt5.home_page_id
  14666. GROUP by tt3.behospital_code
  14667. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  14668. ) t1,
  14669. ( SELECT @rownum := 0 ) r
  14670. ) r1
  14671. LEFT JOIN (
  14672. SELECT
  14673. ( @INDEX := @INDEX + 1 ) AS rownum,
  14674. t1.file_code,
  14675. t1.behospital_code,
  14676. t1.diagnose,
  14677. t1.diagnose_name,
  14678. t1.NAME,
  14679. t1.sex,
  14680. t1.hospital_id,
  14681. t1.beh_dept_id,
  14682. t1.beh_dept_name,
  14683. t1.behospital_date,
  14684. t1.leave_hospital_date
  14685. FROM(
  14686. select
  14687. tt3.file_code,
  14688. tt3.behospital_code,
  14689. tt3.diagnose,
  14690. tt3.NAME,
  14691. tt3.sex,
  14692. tt3.hospital_id,
  14693. tt3.beh_dept_id,
  14694. tt3.beh_dept_name,
  14695. tt3.behospital_date,
  14696. tt3.leave_hospital_date,
  14697. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14698. FROM(
  14699. SELECT
  14700. tt2.file_code,
  14701. tt2.diagnose,
  14702. tt2.NAME,
  14703. tt2.sex,
  14704. tt2.hospital_id,
  14705. tt2.beh_dept_id,
  14706. tt2.beh_dept_name,
  14707. tt2.behospital_code,
  14708. tt2.behospital_date,
  14709. tt2.leave_hospital_date
  14710. FROM
  14711. (
  14712. SELECT
  14713. a.file_code
  14714. FROM
  14715. med_behospital_info a
  14716. WHERE
  14717. a.is_deleted = 'N'
  14718. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14719. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14720. </if>
  14721. AND a.qc_type_id != 0
  14722. AND IFNULL( a.diagnose, '' )!= ''
  14723. AND IFNULL( a.file_code, '' )!= ''
  14724. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14725. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14726. </if>
  14727. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14728. <if test="reBeHosPageVO.startDate != null ">
  14729. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14730. </if>
  14731. <if test="reBeHosPageVO.endDate != null ">
  14732. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14733. </if>
  14734. </if>
  14735. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14736. <if test="reBeHosPageVO.startDate != null ">
  14737. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14738. </if>
  14739. <if test="reBeHosPageVO.endDate != null">
  14740. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14741. </if>
  14742. </if>
  14743. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14744. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14745. </if>
  14746. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14747. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14748. </if>
  14749. GROUP BY
  14750. a.file_code
  14751. HAVING
  14752. count(*)> 1
  14753. ) tt1,
  14754. med_behospital_info tt2
  14755. WHERE
  14756. tt2.is_deleted = 'N'
  14757. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14758. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14759. </if>
  14760. AND tt2.qc_type_id != 0
  14761. AND tt1.file_code = tt2.file_code
  14762. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14763. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14764. </if>
  14765. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14766. <if test="reBeHosPageVO.startDate != null ">
  14767. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14768. </if>
  14769. <if test="reBeHosPageVO.endDate != null ">
  14770. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14771. </if>
  14772. </if>
  14773. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14774. <if test="reBeHosPageVO.startDate != null ">
  14775. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14776. </if>
  14777. <if test="reBeHosPageVO.endDate != null">
  14778. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14779. </if>
  14780. </if>
  14781. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14782. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14783. </if>
  14784. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14785. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14786. </if>
  14787. ORDER BY
  14788. tt1.file_code,
  14789. tt2.behospital_date DESC)tt3
  14790. left join med_home_page tt4 on tt4.is_deleted = 'N'
  14791. AND tt3.hospital_id = tt4.hospital_id
  14792. AND tt3.behospital_code = tt4.behospital_code
  14793. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  14794. AND tt4.hospital_id = tt5.hospital_id
  14795. AND tt4.home_page_id = tt5.home_page_id
  14796. GROUP by tt3.behospital_code
  14797. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  14798. ) t1,
  14799. ( SELECT @INDEX := 0 ) r
  14800. ) r2 ON r1.file_code = r2.file_code
  14801. AND r1.rownum = r2.rownum - 1
  14802. ) be
  14803. WHERE
  14804. be.diffDays IS NOT NULL
  14805. AND be.diffDays BETWEEN 0
  14806. AND 31
  14807. ) t
  14808. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14809. AND t.hospitalId = mqi.hospital_id
  14810. AND t.behospitalCode = mqi.behospital_code
  14811. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14812. AND t.hospitalId = mqi_last.hospital_id
  14813. AND t.lastBehospitalCode = mqi_last.behospital_code
  14814. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14815. AND t.hospitalId = mhp.hospital_id
  14816. AND t.behospitalCode = mhp.behospital_code
  14817. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14818. AND t.hospitalId = mhp_last.hospital_id
  14819. AND t.lastBehospitalCode = mhp_last.behospital_code
  14820. </select>
  14821. <!-- 31天再入院详情页-科室-->
  14822. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14823. SELECT
  14824. t.fileCode,
  14825. t.diagnose,
  14826. t.diagnoseName,
  14827. t.NAME,
  14828. t.sex,
  14829. t.hospitalId,
  14830. t.behDeptId,
  14831. t.behDeptName,
  14832. t.doctorId,
  14833. t.doctorName,
  14834. t.behospitalCode,
  14835. t.behospitalDate,
  14836. t.leaveHospitalDate,
  14837. t.lastDiagnose,
  14838. t.lastDiagnoseName,
  14839. t.lastBehDeptId,
  14840. t.lastBehDeptName,
  14841. t.lastDoctorName,
  14842. t.lastBehospitalCode,
  14843. t.lastBehospitalDate,
  14844. t.lastLeaveHospitalDate,
  14845. t.diffDays,
  14846. mqi.score_res AS scoreRes,
  14847. mqi.LEVEL AS LEVEL,
  14848. mqi_last.score_res AS lastScoreRes,
  14849. mqi_last.LEVEL AS lastLevel,
  14850. mhp.again_behospital_plan AS againBehospitalPlan,
  14851. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  14852. mhp.total_fee AS totleFee,
  14853. mhp.behospital_day_num AS behospitalDayNum,
  14854. mhp_last.total_fee AS lastTotleFee,
  14855. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14856. FROM
  14857. (
  14858. SELECT
  14859. be.fileCode,
  14860. be.diagnose,
  14861. be.diagnoseName,
  14862. be.NAME,
  14863. be.sex,
  14864. be.hospitalId,
  14865. be.behDeptId,
  14866. be.behDeptName,
  14867. be.doctorId,
  14868. be.doctorName,
  14869. be.behospitalCode,
  14870. be.behospitalDate,
  14871. be.leaveHospitalDate,
  14872. be.lastDiagnose,
  14873. be.lastDiagnoseName,
  14874. be.lastBehDeptId,
  14875. be.lastBehDeptName,
  14876. be.lastDoctorId,
  14877. be.lastDoctorName,
  14878. be.lastBehospitalCode,
  14879. be.lastBehospitalDate,
  14880. be.lastLeaveHospitalDate,
  14881. be.diffDays
  14882. FROM
  14883. (
  14884. SELECT
  14885. r1.file_code AS fileCode,
  14886. r1.diagnose,
  14887. r1.diagnose_name AS diagnoseName,
  14888. r1.NAME,
  14889. r1.sex,
  14890. r1.hospital_id AS hospitalId,
  14891. r1.beh_dept_id AS behDeptId,
  14892. r1.beh_dept_name AS behDeptName,
  14893. r1.doctor_id as doctorId,
  14894. r1.doctor_name as doctorName,
  14895. r1.behospital_code AS behospitalCode,
  14896. r1.behospital_date AS behospitalDate,
  14897. r1.leave_hospital_date AS leaveHospitalDate,
  14898. r2.diagnose AS lastDiagnose,
  14899. r2.diagnose_name AS lastDiagnoseName,
  14900. r2.beh_dept_id AS lastBehDeptId,
  14901. r2.beh_dept_name AS lastBehDeptName,
  14902. r2.behospital_code AS lastBehospitalCode,
  14903. r2.behospital_date AS lastBehospitalDate,
  14904. r2.doctor_id as lastDoctorId,
  14905. r2.doctor_name as lastDoctorName,
  14906. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14907. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14908. FROM
  14909. (
  14910. SELECT
  14911. ( @rownum := @rownum + 1 ) AS rownum,
  14912. t1.file_code,
  14913. t1.NAME,
  14914. t1.sex,
  14915. t1.diagnose,
  14916. t1.diagnose_name,
  14917. t1.doctor_id,
  14918. t1.doctor_name,
  14919. t1.hospital_id,
  14920. t1.beh_dept_id,
  14921. t1.beh_dept_name,
  14922. t1.behospital_code,
  14923. t1.behospital_date,
  14924. t1.leave_hospital_date
  14925. FROM
  14926. (
  14927. select
  14928. tt3.file_code,
  14929. tt3.behospital_code,
  14930. tt3.diagnose,
  14931. tt3.NAME,
  14932. tt3.sex,
  14933. tt3.hospital_id,
  14934. tt3.beh_dept_id,
  14935. tt3.beh_dept_name,
  14936. tt3.doctor_id,
  14937. tt3.doctor_name,
  14938. tt3.behospital_date,
  14939. tt3.leave_hospital_date,
  14940. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  14941. FROM(
  14942. SELECT
  14943. tt1.file_code,
  14944. tt2.diagnose,
  14945. tt2.doctor_id,
  14946. tt2.doctor_name,
  14947. tt2.NAME,
  14948. tt2.sex,
  14949. tt2.hospital_id,
  14950. tt2.beh_dept_id,
  14951. tt2.beh_dept_name,
  14952. tt2.behospital_code,
  14953. tt2.behospital_date,
  14954. tt2.leave_hospital_date
  14955. FROM
  14956. (
  14957. SELECT
  14958. a.file_code
  14959. FROM
  14960. med_behospital_info a,
  14961. sys_user_dept c
  14962. WHERE
  14963. a.is_deleted = 'N'
  14964. AND c.is_deleted = 'N'
  14965. AND a.hospital_id = c.hospital_id
  14966. AND a.beh_dept_id = c.dept_id
  14967. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14968. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14969. </if>
  14970. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14971. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14972. </if>
  14973. <if test="reBeHosPageVO.userId!=null">
  14974. AND c.user_id = #{reBeHosPageVO.userId}
  14975. </if>
  14976. AND a.qc_type_id != 0
  14977. AND IFNULL( a.diagnose, '' )!= ''
  14978. AND IFNULL( a.file_code, '' )!= ''
  14979. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14980. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14981. </if>
  14982. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14983. <if test="reBeHosPageVO.startDate != null ">
  14984. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14985. </if>
  14986. <if test="reBeHosPageVO.endDate != null ">
  14987. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14988. </if>
  14989. </if>
  14990. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14991. <if test="reBeHosPageVO.startDate != null ">
  14992. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14993. </if>
  14994. <if test="reBeHosPageVO.endDate != null">
  14995. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14996. </if>
  14997. </if>
  14998. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14999. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15000. </if>
  15001. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15002. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  15003. </if>
  15004. GROUP BY
  15005. a.file_code
  15006. HAVING
  15007. count(*)> 1
  15008. ) tt1,
  15009. med_behospital_info tt2
  15010. WHERE
  15011. tt2.is_deleted = 'N'
  15012. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15013. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  15014. </if>
  15015. AND tt2.qc_type_id != 0
  15016. AND tt1.file_code = tt2.file_code
  15017. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15018. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  15019. </if>
  15020. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15021. <if test="reBeHosPageVO.startDate != null ">
  15022. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15023. </if>
  15024. <if test="reBeHosPageVO.endDate != null ">
  15025. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15026. </if>
  15027. </if>
  15028. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15029. <if test="reBeHosPageVO.startDate != null ">
  15030. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15031. </if>
  15032. <if test="reBeHosPageVO.endDate != null">
  15033. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15034. </if>
  15035. </if>
  15036. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15037. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15038. </if>
  15039. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15040. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  15041. </if>
  15042. ORDER BY
  15043. tt1.file_code,
  15044. tt2.behospital_date DESC)tt3
  15045. left join med_home_page tt4 on tt4.is_deleted = 'N'
  15046. AND tt3.hospital_id = tt4.hospital_id
  15047. AND tt3.behospital_code = tt4.behospital_code
  15048. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  15049. AND tt4.hospital_id = tt5.hospital_id
  15050. AND tt4.home_page_id = tt5.home_page_id
  15051. GROUP by tt3.behospital_code
  15052. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  15053. ) t1,
  15054. ( SELECT @rownum := 0 ) r
  15055. ) r1
  15056. LEFT JOIN (
  15057. SELECT
  15058. ( @INDEX := @INDEX + 1 ) AS rownum,
  15059. t1.file_code,
  15060. t1.NAME,
  15061. t1.sex,
  15062. t1.diagnose,
  15063. t1.diagnose_name,
  15064. t1.doctor_id,
  15065. t1.doctor_name,
  15066. t1.hospital_id,
  15067. t1.beh_dept_id,
  15068. t1.beh_dept_name,
  15069. t1.behospital_code,
  15070. t1.behospital_date,
  15071. t1.leave_hospital_date
  15072. FROM
  15073. (
  15074. select
  15075. tt3.file_code,
  15076. tt3.behospital_code,
  15077. tt3.diagnose,
  15078. tt3.NAME,
  15079. tt3.sex,
  15080. tt3.hospital_id,
  15081. tt3.beh_dept_id,
  15082. tt3.beh_dept_name,
  15083. tt3.doctor_id,
  15084. tt3.doctor_name,
  15085. tt3.behospital_date,
  15086. tt3.leave_hospital_date,
  15087. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  15088. FROM(
  15089. SELECT
  15090. tt1.file_code,
  15091. tt2.diagnose,
  15092. tt2.doctor_id,
  15093. tt2.doctor_name,
  15094. tt2.NAME,
  15095. tt2.sex,
  15096. tt2.hospital_id,
  15097. tt2.beh_dept_id,
  15098. tt2.beh_dept_name,
  15099. tt2.behospital_code,
  15100. tt2.behospital_date,
  15101. tt2.leave_hospital_date
  15102. FROM
  15103. (
  15104. SELECT
  15105. a.file_code
  15106. FROM
  15107. med_behospital_info a,
  15108. sys_user_dept c
  15109. WHERE
  15110. a.is_deleted = 'N'
  15111. AND c.is_deleted = 'N'
  15112. AND a.hospital_id = c.hospital_id
  15113. AND a.beh_dept_id = c.dept_id
  15114. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  15115. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  15116. </if>
  15117. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15118. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  15119. </if>
  15120. <if test="reBeHosPageVO.userId!=null">
  15121. AND c.user_id = #{reBeHosPageVO.userId}
  15122. </if>
  15123. AND a.qc_type_id != 0
  15124. AND IFNULL( a.diagnose, '' )!= ''
  15125. AND IFNULL( a.file_code, '' )!= ''
  15126. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15127. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  15128. </if>
  15129. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15130. <if test="reBeHosPageVO.startDate != null ">
  15131. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15132. </if>
  15133. <if test="reBeHosPageVO.endDate != null ">
  15134. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15135. </if>
  15136. </if>
  15137. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15138. <if test="reBeHosPageVO.startDate != null ">
  15139. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15140. </if>
  15141. <if test="reBeHosPageVO.endDate != null">
  15142. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15143. </if>
  15144. </if>
  15145. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15146. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15147. </if>
  15148. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15149. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  15150. </if>
  15151. GROUP BY
  15152. a.file_code
  15153. HAVING
  15154. count(*)> 1
  15155. ) tt1,
  15156. med_behospital_info tt2
  15157. WHERE
  15158. tt2.is_deleted = 'N'
  15159. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  15160. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  15161. </if>
  15162. AND tt2.qc_type_id != 0
  15163. AND tt1.file_code = tt2.file_code
  15164. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  15165. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  15166. </if>
  15167. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  15168. <if test="reBeHosPageVO.startDate != null ">
  15169. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  15170. </if>
  15171. <if test="reBeHosPageVO.endDate != null ">
  15172. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  15173. </if>
  15174. </if>
  15175. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  15176. <if test="reBeHosPageVO.startDate != null ">
  15177. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  15178. </if>
  15179. <if test="reBeHosPageVO.endDate != null">
  15180. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  15181. </if>
  15182. </if>
  15183. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  15184. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  15185. </if>
  15186. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  15187. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  15188. </if>
  15189. ORDER BY
  15190. tt1.file_code,
  15191. tt2.behospital_date DESC)tt3
  15192. left join med_home_page tt4 on tt4.is_deleted = 'N'
  15193. AND tt3.hospital_id = tt4.hospital_id
  15194. AND tt3.behospital_code = tt4.behospital_code
  15195. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  15196. AND tt4.hospital_id = tt5.hospital_id
  15197. AND tt4.home_page_id = tt5.home_page_id
  15198. GROUP by tt3.behospital_code
  15199. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  15200. ) t1,
  15201. ( SELECT @INDEX := 0 ) r
  15202. ) r2 ON r1.file_code = r2.file_code
  15203. AND r1.rownum = r2.rownum - 1
  15204. ) be
  15205. WHERE
  15206. be.diffDays IS NOT NULL
  15207. AND be.diffDays BETWEEN 0
  15208. AND 31
  15209. ) t
  15210. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  15211. AND t.hospitalId = mqi.hospital_id
  15212. AND t.behospitalCode = mqi.behospital_code
  15213. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  15214. AND t.hospitalId = mqi_last.hospital_id
  15215. AND t.lastBehospitalCode = mqi_last.behospital_code
  15216. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  15217. AND t.hospitalId = mhp.hospital_id
  15218. AND t.behospitalCode = mhp.behospital_code
  15219. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  15220. AND t.hospitalId = mhp_last.hospital_id
  15221. AND t.lastBehospitalCode = mhp_last.behospital_code
  15222. </select>
  15223. <!-- 单条条目缺陷统计-->
  15224. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  15225. SELECT
  15226. a.beh_dept_id AS id,
  15227. a.beh_dept_name AS NAME,
  15228. count(*) AS num
  15229. FROM
  15230. med_behospital_info a,
  15231. med_qcresult_detail b
  15232. WHERE
  15233. a.is_deleted = 'N'
  15234. AND b.is_deleted = 'N'
  15235. AND a.hospital_id = b.hospital_id
  15236. AND a.behospital_code = b.behospital_code
  15237. AND a.qc_type_id != 0
  15238. and b.cases_entry_id=2658
  15239. <if test="isPlacefile != null and isPlacefile != ''">
  15240. and a.is_placefile = #{isPlacefile}
  15241. </if>
  15242. <if test="hospitalId != null and hospitalId != ''">
  15243. AND a.hospital_id = #{hospitalId}
  15244. </if>
  15245. <if test="isPlacefile != null and isPlacefile == 0">
  15246. <if test="startDate != null and startDate != ''">
  15247. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  15248. </if>
  15249. <if test="endDate != null and endDate != ''">
  15250. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  15251. </if>
  15252. </if>
  15253. <if test="isPlacefile != null and isPlacefile == 1">
  15254. <if test="startDate != null and startDate != ''">
  15255. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  15256. </if>
  15257. <if test="endDate != null and endDate != ''">
  15258. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  15259. </if>
  15260. </if>
  15261. GROUP BY
  15262. a.beh_dept_id,
  15263. a.beh_dept_name
  15264. </select>
  15265. <!-- 单条条目缺陷统计-->
  15266. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  15267. SELECT
  15268. a.beh_dept_id AS deptId,
  15269. a.beh_dept_name AS deptName,
  15270. a.doctor_id as doctorId,
  15271. a.doctor_name as doctorName,
  15272. count(*) AS num
  15273. FROM
  15274. med_behospital_info a,
  15275. med_qcresult_detail b,
  15276. sys_user_dept c
  15277. WHERE
  15278. a.is_deleted = 'N'
  15279. AND b.is_deleted = 'N'
  15280. AND c.is_deleted = 'N'
  15281. AND a.hospital_id = b.hospital_id
  15282. AND a.hospital_id = c.hospital_id
  15283. AND a.behospital_code = b.behospital_code
  15284. AND a.beh_dept_id = c.dept_id
  15285. AND a.qc_type_id != 0
  15286. and b.cases_entry_id=2658
  15287. <if test="isPlacefile != null and isPlacefile != ''">
  15288. and a.is_placefile = #{isPlacefile}
  15289. </if>
  15290. <if test="hospitalId != null and hospitalId != ''">
  15291. AND a.hospital_id = #{hospitalId}
  15292. </if>
  15293. <if test="userId!=null">
  15294. AND c.user_id = #{userId}
  15295. </if>
  15296. <if test="isPlacefile != null and isPlacefile == 0">
  15297. <if test="startDate != null and startDate != ''">
  15298. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  15299. </if>
  15300. <if test="endDate != null and endDate != ''">
  15301. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  15302. </if>
  15303. </if>
  15304. <if test="isPlacefile != null and isPlacefile == 1">
  15305. <if test="startDate != null and startDate != ''">
  15306. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  15307. </if>
  15308. <if test="endDate != null and endDate != ''">
  15309. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  15310. </if>
  15311. </if>
  15312. GROUP BY
  15313. a.beh_dept_id,
  15314. a.beh_dept_name,
  15315. a.doctor_id,
  15316. a.doctor_name
  15317. </select>
  15318. <!-- 病案首页改善率质控评分页(内页)-->
  15319. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  15320. SELECT
  15321. t.*
  15322. FROM
  15323. (
  15324. SELECT DISTINCT
  15325. t1.hospital_id AS hospitalId,
  15326. t1.behospital_code AS behospitalCode,
  15327. t1.bed_code AS bedCode,
  15328. t1.LEVEL AS LEVEL,
  15329. t1.grade_type AS gradeType,
  15330. t1.score_res AS scoreRes,
  15331. t1.scoreBn,
  15332. t1.NAME AS NAME,
  15333. t1.sex AS sex,
  15334. t1.beh_dept_id AS behDeptId,
  15335. t1.beh_dept_name AS behDeptName,
  15336. t1.doctor_id AS doctorId,
  15337. t1.doctor_name AS doctorName,
  15338. t1.beh_doctor_id AS behDoctorId,
  15339. t1.beh_doctor_name AS behDoctorName,
  15340. t1.director_doctor_id AS directorDoctorId,
  15341. t1.director_doctor_name AS directorDoctorName,
  15342. t1.birthday AS birthday,
  15343. t1.behospital_date AS behospitalDate,
  15344. t1.leave_hospital_date AS leaveHospitalDate,
  15345. t1.placefile_date AS placefileDate,
  15346. t1.gmt_create AS gradeTime,
  15347. t1.diagnose,
  15348. t1.ward_name AS wardName,
  15349. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15350. t1.file_code AS fileCode,
  15351. t1.checkStatus,
  15352. t1.chName,
  15353. t1.chTime
  15354. FROM
  15355. (
  15356. SELECT
  15357. be.*,
  15358. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15359. mci.check_name AS chName,
  15360. mci.gmt_create AS chTime
  15361. FROM
  15362. (
  15363. SELECT DISTINCT
  15364. a.hospital_id,
  15365. a.behospital_code,
  15366. a.bed_code,
  15367. a.file_code,
  15368. c.LEVEL,
  15369. c.grade_type,
  15370. c.score_res,
  15371. a.NAME,
  15372. a.sex,
  15373. a.beh_dept_id,
  15374. a.beh_dept_name,
  15375. a.birthday,
  15376. a.behospital_date,
  15377. a.leave_hospital_date,
  15378. a.doctor_id,
  15379. a.doctor_name,
  15380. a.beh_doctor_id,
  15381. a.beh_doctor_name,
  15382. a.director_doctor_id,
  15383. a.director_doctor_name,
  15384. a.diagnose,
  15385. a.placefile_date,
  15386. a.ward_name,
  15387. c.gmt_create,
  15388. d.score_res as scoreBn
  15389. FROM
  15390. med_behospital_info a,
  15391. med_home_page b,
  15392. med_qcresult_info c,
  15393. med_qcresult_cases d,
  15394. (
  15395. SELECT
  15396. m4.*
  15397. FROM
  15398. med_behospital_info m1,
  15399. med_home_page m2,
  15400. med_qcresult_info m3,
  15401. med_qcresult_cases m4
  15402. WHERE
  15403. m1.is_deleted = 'N'
  15404. AND m2.is_deleted = 'N'
  15405. AND m3.is_deleted = 'Y'
  15406. AND m4.is_deleted = 'Y'
  15407. AND m1.hospital_id = m2.hospital_id
  15408. AND m1.hospital_id = m3.hospital_id
  15409. AND m1.hospital_id = m4.hospital_id
  15410. AND m1.behospital_code = m2.behospital_code
  15411. AND m1.behospital_code = m3.behospital_code
  15412. AND m1.behospital_code = m4.behospital_code
  15413. AND m3.gmt_create = m4.gmt_create
  15414. AND m3.have_home_page = 1
  15415. AND m4.cases_id = 243
  15416. AND m1.qc_type_id != 0
  15417. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15418. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15419. </if>
  15420. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15421. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15422. </if>
  15423. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15424. <if test="qcResultShortPageVO.startDate != null ">
  15425. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15426. </if>
  15427. <if test="qcResultShortPageVO.endDate != null ">
  15428. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15429. </if>
  15430. </if>
  15431. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15432. <if test="qcResultShortPageVO.startDate != null">
  15433. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15434. </if>
  15435. <if test="qcResultShortPageVO.endDate != null ">
  15436. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15437. </if>
  15438. </if>
  15439. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15440. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15441. </if>
  15442. GROUP BY
  15443. m1.behospital_code
  15444. ORDER BY
  15445. m1.behospital_code,
  15446. m4.gmt_create
  15447. ) e
  15448. WHERE
  15449. a.is_deleted = 'N'
  15450. AND b.is_deleted = 'N'
  15451. AND c.is_deleted = 'N'
  15452. AND d.is_deleted = 'N'
  15453. AND a.hospital_id = b.hospital_id
  15454. AND a.hospital_id = c.hospital_id
  15455. AND a.hospital_id = d.hospital_id
  15456. AND a.hospital_id = e.hospital_id
  15457. AND a.behospital_code = b.behospital_code
  15458. AND a.behospital_code = c.behospital_code
  15459. AND a.behospital_code = d.behospital_code
  15460. AND a.behospital_code = e.behospital_code
  15461. AND d.cases_id = 243
  15462. AND d.score_res > e.score_res
  15463. AND a.qc_type_id != 0
  15464. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15465. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15466. </if>
  15467. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15468. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15469. </if>
  15470. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15471. <if test="qcResultShortPageVO.startDate != null ">
  15472. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15473. </if>
  15474. <if test="qcResultShortPageVO.endDate != null ">
  15475. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15476. </if>
  15477. </if>
  15478. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15479. <if test="qcResultShortPageVO.startDate != null ">
  15480. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15481. </if>
  15482. <if test="qcResultShortPageVO.endDate != null">
  15483. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15484. </if>
  15485. </if>
  15486. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15487. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15488. </if>
  15489. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15490. AND c.`level` = #{qcResultShortPageVO.level}
  15491. </if>
  15492. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15493. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15494. </if>
  15495. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15496. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15497. </if>
  15498. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15499. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15500. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15501. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15502. </if>
  15503. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15504. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15505. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15506. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15507. </if>
  15508. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15509. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15510. </if>
  15511. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15512. AND d.score_res = 20
  15513. </if>
  15514. ) be
  15515. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15516. AND mci.check_type in(0,2)
  15517. AND be.hospital_id = mci.hospital_id
  15518. AND be.behospital_code = mci.behospital_code
  15519. ) t1
  15520. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15521. AND t1.behospital_code = t2.behospital_code
  15522. AND t2.is_deleted = 'N'
  15523. ) t
  15524. WHERE
  15525. 1 = 1
  15526. <if test="qcResultShortPageVO.checkStatus != null">
  15527. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15528. </if>
  15529. <if test="qcResultShortPageVO.mrStatus != null">
  15530. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15531. </if>
  15532. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15533. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15534. </if>
  15535. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15536. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15537. </if>
  15538. <if test="qcResultShortPageVO.chTimeStart != null ">
  15539. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15540. </if>
  15541. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15542. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15543. </if>
  15544. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15545. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15546. </if>
  15547. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15548. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15549. </if>
  15550. </select>
  15551. <!-- 病案首页改善率质控评分页(内页)-科室-->
  15552. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  15553. SELECT
  15554. t.*
  15555. FROM
  15556. (
  15557. SELECT DISTINCT
  15558. t1.hospital_id AS hospitalId,
  15559. t1.behospital_code AS behospitalCode,
  15560. t1.bed_code AS bedCode,
  15561. t1.LEVEL AS LEVEL,
  15562. t1.grade_type AS gradeType,
  15563. t1.score_res AS scoreRes,
  15564. t1.NAME AS NAME,
  15565. t1.scoreBn,
  15566. t1.medoupName,
  15567. t1.sex AS sex,
  15568. t1.beh_dept_id AS behDeptId,
  15569. t1.beh_dept_name AS behDeptName,
  15570. t1.doctor_id AS doctorId,
  15571. t1.doctor_name AS doctorName,
  15572. t1.beh_doctor_id AS behDoctorId,
  15573. t1.beh_doctor_name AS behDoctorName,
  15574. t1.director_doctor_id AS directorDoctorId,
  15575. t1.director_doctor_name AS directorDoctorName,
  15576. t1.birthday AS birthday,
  15577. t1.behospital_date AS behospitalDate,
  15578. t1.leave_hospital_date AS leaveHospitalDate,
  15579. t1.placefile_date AS placefileDate,
  15580. t1.gmt_create AS gradeTime,
  15581. t1.diagnose,
  15582. t1.ward_name AS wardName,
  15583. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15584. t1.file_code AS fileCode,
  15585. t1.checkStatus,
  15586. t1.mrStatus,
  15587. t1.chName,
  15588. t1.mrName,
  15589. t1.chTime,
  15590. t1.mrTime
  15591. FROM
  15592. (
  15593. SELECT
  15594. be.*,
  15595. t3.name as medoupName,
  15596. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15597. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15598. mci.check_name AS chName,
  15599. hm_mci.check_name AS mrName,
  15600. e.score_res as scoreBn,
  15601. mci.gmt_create AS chTime,
  15602. hm_mci.gmt_create AS mrTime
  15603. FROM
  15604. (
  15605. SELECT DISTINCT
  15606. a.hospital_id,
  15607. a.behospital_code,
  15608. a.bed_code,
  15609. a.file_code,
  15610. c.LEVEL,
  15611. c.grade_type,
  15612. c.score_res,
  15613. a.NAME,
  15614. a.sex,
  15615. a.beh_dept_id,
  15616. a.beh_dept_name,
  15617. a.birthday,
  15618. a.behospital_date,
  15619. a.leave_hospital_date,
  15620. a.doctor_id,
  15621. a.doctor_name,
  15622. a.beh_doctor_id,
  15623. a.beh_doctor_name,
  15624. a.director_doctor_id,
  15625. a.director_doctor_name,
  15626. a.diagnose,
  15627. a.placefile_date,
  15628. a.ward_name,
  15629. c.gmt_create
  15630. FROM
  15631. med_behospital_info a,
  15632. med_home_page b,
  15633. med_qcresult_info c,
  15634. med_qcresult_cases d,
  15635. sys_user_dept f,
  15636. (
  15637. SELECT
  15638. m4.*
  15639. FROM
  15640. med_behospital_info m1,
  15641. med_home_page m2,
  15642. med_qcresult_info m3,
  15643. med_qcresult_cases m4
  15644. WHERE
  15645. m1.is_deleted = 'N'
  15646. AND m2.is_deleted = 'N'
  15647. AND m3.is_deleted = 'Y'
  15648. AND m4.is_deleted = 'Y'
  15649. AND m1.hospital_id = m2.hospital_id
  15650. AND m1.hospital_id = m3.hospital_id
  15651. AND m1.hospital_id = m4.hospital_id
  15652. AND m1.behospital_code = m2.behospital_code
  15653. AND m1.behospital_code = m3.behospital_code
  15654. AND m1.behospital_code = m4.behospital_code
  15655. AND m3.gmt_create = m4.gmt_create
  15656. AND m3.have_home_page = 1
  15657. AND m4.cases_id = 243
  15658. AND m1.qc_type_id != 0
  15659. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15660. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15661. </if>
  15662. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  15663. AND m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  15664. </if>
  15665. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15666. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15667. </if>
  15668. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15669. AND m1.doctor_name = #{qcResultShortPageVO.doctorName}
  15670. </if>
  15671. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15672. <if test="qcResultShortPageVO.startDate != null ">
  15673. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15674. </if>
  15675. <if test="qcResultShortPageVO.endDate != null ">
  15676. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15677. </if>
  15678. </if>
  15679. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15680. <if test="qcResultShortPageVO.startDate != null">
  15681. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15682. </if>
  15683. <if test="qcResultShortPageVO.endDate != null ">
  15684. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15685. </if>
  15686. </if>
  15687. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15688. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15689. </if>
  15690. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  15691. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  15692. </if>
  15693. GROUP BY
  15694. m1.behospital_code
  15695. ORDER BY
  15696. m1.behospital_code,
  15697. m4.gmt_create
  15698. ) e
  15699. WHERE
  15700. a.is_deleted = 'N'
  15701. AND b.is_deleted = 'N'
  15702. AND c.is_deleted = 'N'
  15703. AND d.is_deleted = 'N'
  15704. AND f.is_deleted = 'N'
  15705. AND a.hospital_id = b.hospital_id
  15706. AND a.hospital_id = c.hospital_id
  15707. AND a.hospital_id = d.hospital_id
  15708. AND a.hospital_id = f.hospital_id
  15709. AND a.hospital_id = e.hospital_id
  15710. AND a.behospital_code = b.behospital_code
  15711. AND a.behospital_code = c.behospital_code
  15712. AND a.behospital_code = d.behospital_code
  15713. AND a.beh_dept_id = f.dept_id
  15714. AND a.behospital_code = e.behospital_code
  15715. AND d.cases_id = 243
  15716. AND d.score_res > e.score_res
  15717. AND a.qc_type_id != 0
  15718. <if test="qcResultShortPageVO.userId!=null">
  15719. AND f.user_id = #{qcResultShortPageVO.userId}
  15720. </if>
  15721. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15722. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15723. </if>
  15724. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15725. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15726. </if>
  15727. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  15728. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  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.deptName != null and qcResultShortPageVO.deptName != ''">
  15747. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15748. </if>
  15749. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  15750. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  15751. </if>
  15752. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15753. AND c.`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 = #{qcResultShortPageVO.doctorId}
  15763. </if>
  15764. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15765. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  15766. </if>
  15767. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15768. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15769. </if>
  15770. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15771. AND d.score_res = 20
  15772. </if>
  15773. ) be
  15774. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15775. AND mci.check_type = 0
  15776. AND be.hospital_id = mci.hospital_id
  15777. AND be.behospital_code = mci.behospital_code
  15778. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15779. AND hm_mci.check_type = 1
  15780. AND be.hospital_id = hm_mci.hospital_id
  15781. AND be.behospital_code = hm_mci.behospital_code
  15782. LEFT JOIN med_qcresult_cases e
  15783. on be.behospital_code = e.behospital_code
  15784. and be.hospital_id = e.hospital_id
  15785. AND e.is_deleted = 'N'
  15786. and e.cases_id = 243
  15787. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  15788. and be.hospital_id = t2.hospital_id
  15789. AND t2.is_deleted = 'N'
  15790. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  15791. AND t3.is_deleted = 'N'
  15792. ) t1
  15793. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15794. AND t1.behospital_code = t2.behospital_code
  15795. AND t2.is_deleted = 'N'
  15796. ) t
  15797. WHERE
  15798. 1 = 1
  15799. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  15800. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  15801. </if>
  15802. <if test="qcResultShortPageVO.checkStatus != null">
  15803. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15804. </if>
  15805. <if test="qcResultShortPageVO.mrStatus != null">
  15806. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15807. </if>
  15808. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15809. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15810. </if>
  15811. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15812. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15813. </if>
  15814. <if test="qcResultShortPageVO.chTimeStart != null ">
  15815. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15816. </if>
  15817. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15818. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15819. </if>
  15820. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15821. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15822. </if>
  15823. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15824. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15825. </if>
  15826. </select>
  15827. <!-- 质控核查质控评分页(内页)-->
  15828. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  15829. SELECT
  15830. t.*
  15831. FROM
  15832. (
  15833. SELECT DISTINCT
  15834. t1.hospital_id AS hospitalId,
  15835. t1.behospital_code AS behospitalCode,
  15836. t1.bed_code AS bedCode,
  15837. t1.LEVEL AS LEVEL,
  15838. t1.grade_type AS gradeType,
  15839. t1.score_res AS scoreRes,
  15840. t1.scoreBn,
  15841. t1.NAME AS NAME,
  15842. t1.sex AS sex,
  15843. t1.beh_dept_id AS behDeptId,
  15844. t1.beh_dept_name AS behDeptName,
  15845. t1.doctor_id AS doctorId,
  15846. t1.doctor_name AS doctorName,
  15847. t1.beh_doctor_id AS behDoctorId,
  15848. t1.beh_doctor_name AS behDoctorName,
  15849. t1.director_doctor_id AS directorDoctorId,
  15850. t1.director_doctor_name AS directorDoctorName,
  15851. t1.birthday AS birthday,
  15852. t1.behospital_date AS behospitalDate,
  15853. t1.leave_hospital_date AS leaveHospitalDate,
  15854. t1.placefile_date AS placefileDate,
  15855. t1.gmt_create AS gradeTime,
  15856. t1.diagnose,
  15857. t1.ward_name AS wardName,
  15858. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15859. t1.file_code AS fileCode,
  15860. t1.checkStatus,
  15861. t1.chName,
  15862. t1.chTime
  15863. FROM
  15864. (
  15865. SELECT
  15866. be.*,
  15867. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15868. mci.check_name AS chName,
  15869. e.score_res as scoreBn,
  15870. mci.gmt_create AS chTime
  15871. FROM
  15872. (
  15873. SELECT DISTINCT
  15874. a.hospital_id,
  15875. a.behospital_code,
  15876. a.bed_code,
  15877. a.file_code,
  15878. b.LEVEL,
  15879. b.grade_type,
  15880. b.score_res,
  15881. a.NAME,
  15882. a.sex,
  15883. a.beh_dept_id,
  15884. a.beh_dept_name,
  15885. a.birthday,
  15886. a.behospital_date,
  15887. a.leave_hospital_date,
  15888. a.doctor_id,
  15889. a.doctor_name,
  15890. a.beh_doctor_id,
  15891. a.beh_doctor_name,
  15892. a.director_doctor_id,
  15893. a.director_doctor_name,
  15894. a.diagnose,
  15895. a.placefile_date,
  15896. a.ward_name,
  15897. b.gmt_create
  15898. FROM
  15899. med_behospital_info a,
  15900. med_qcresult_info b
  15901. WHERE
  15902. a.is_deleted = 'N'
  15903. AND b.is_deleted = 'N'
  15904. AND a.hospital_id = b.hospital_id
  15905. AND a.behospital_code = b.behospital_code
  15906. AND a.qc_type_id != 0
  15907. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15908. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15909. </if>
  15910. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15911. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15912. </if>
  15913. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15914. <if test="qcResultShortPageVO.startDate != null ">
  15915. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15916. </if>
  15917. <if test="qcResultShortPageVO.endDate != null ">
  15918. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15919. </if>
  15920. </if>
  15921. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15922. <if test="qcResultShortPageVO.startDate != null ">
  15923. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15924. </if>
  15925. <if test="qcResultShortPageVO.endDate != null">
  15926. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15927. </if>
  15928. </if>
  15929. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15930. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15931. </if>
  15932. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15933. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15934. </if>
  15935. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15936. AND b.`level` = #{qcResultShortPageVO.level}
  15937. </if>
  15938. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15939. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15940. </if>
  15941. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15942. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15943. </if>
  15944. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15945. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15946. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15947. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15948. </if>
  15949. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15950. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15951. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15952. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15953. </if>
  15954. ) be
  15955. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15956. AND mci.check_type in(0,2)
  15957. AND be.hospital_id = mci.hospital_id
  15958. AND be.behospital_code = mci.behospital_code
  15959. LEFT JOIN med_qcresult_cases e
  15960. on be.behospital_code = e.behospital_code
  15961. and be.hospital_id = e.hospital_id
  15962. AND e.is_deleted = 'N'
  15963. and e.cases_id = 243
  15964. ) t1
  15965. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15966. AND t1.behospital_code = t2.behospital_code
  15967. AND t2.is_deleted = 'N'
  15968. ) t
  15969. WHERE
  15970. 1 = 1
  15971. <if test="qcResultShortPageVO.checkStatus != null">
  15972. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15973. </if>
  15974. <if test="qcResultShortPageVO.mrStatus != null">
  15975. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15976. </if>
  15977. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15978. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15979. </if>
  15980. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15981. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15982. </if>
  15983. <if test="qcResultShortPageVO.chTimeStart != null ">
  15984. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15985. </if>
  15986. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15987. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15988. </if>
  15989. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15990. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15991. </if>
  15992. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15993. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15994. </if>
  15995. </select>
  15996. <!-- 质控核查质控评分页-科室(内页)-->
  15997. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  15998. SELECT
  15999. t.*
  16000. FROM
  16001. (
  16002. SELECT DISTINCT
  16003. t1.hospital_id AS hospitalId,
  16004. t1.behospital_code AS behospitalCode,
  16005. t1.bed_code AS bedCode,
  16006. t1.LEVEL AS LEVEL,
  16007. t1.grade_type AS gradeType,
  16008. t1.score_res AS scoreRes,
  16009. t1.scoreBn,
  16010. t1.medoupName,
  16011. t1.NAME AS NAME,
  16012. t1.sex AS sex,
  16013. t1.beh_dept_id AS behDeptId,
  16014. t1.beh_dept_name AS behDeptName,
  16015. t1.doctor_id AS doctorId,
  16016. t1.doctor_name AS doctorName,
  16017. t1.beh_doctor_id AS behDoctorId,
  16018. t1.beh_doctor_name AS behDoctorName,
  16019. t1.director_doctor_id AS directorDoctorId,
  16020. t1.director_doctor_name AS directorDoctorName,
  16021. t1.birthday AS birthday,
  16022. t1.behospital_date AS behospitalDate,
  16023. t1.leave_hospital_date AS leaveHospitalDate,
  16024. t1.placefile_date AS placefileDate,
  16025. t1.gmt_create AS gradeTime,
  16026. t1.diagnose,
  16027. t1.ward_name AS wardName,
  16028. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  16029. t1.file_code AS fileCode,
  16030. t1.checkStatus,
  16031. t1.mrStatus,
  16032. t1.chName,
  16033. t1.mrName,
  16034. t1.chTime,
  16035. t1.mrTime
  16036. FROM
  16037. (
  16038. SELECT
  16039. be.*,
  16040. t3.name as medoupName,
  16041. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16042. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16043. mci.check_name AS chName,
  16044. e.score_res as scoreBn,
  16045. hm_mci.check_name AS mrName,
  16046. mci.gmt_create AS chTime,
  16047. hm_mci.gmt_create AS mrTime
  16048. FROM
  16049. (
  16050. SELECT DISTINCT
  16051. a.hospital_id,
  16052. a.behospital_code,
  16053. a.bed_code,
  16054. a.file_code,
  16055. b.LEVEL,
  16056. b.grade_type,
  16057. b.score_res,
  16058. a.NAME,
  16059. a.sex,
  16060. a.beh_dept_id,
  16061. a.beh_dept_name,
  16062. a.birthday,
  16063. a.behospital_date,
  16064. a.leave_hospital_date,
  16065. a.doctor_id,
  16066. a.doctor_name,
  16067. a.beh_doctor_id,
  16068. a.beh_doctor_name,
  16069. a.director_doctor_id,
  16070. a.director_doctor_name,
  16071. a.diagnose,
  16072. a.placefile_date,
  16073. a.ward_name,
  16074. b.gmt_create
  16075. FROM
  16076. med_behospital_info a,
  16077. med_qcresult_info b,
  16078. sys_user_dept c
  16079. WHERE
  16080. a.is_deleted = 'N'
  16081. AND b.is_deleted = 'N'
  16082. AND c.is_deleted = 'N'
  16083. AND a.hospital_id = b.hospital_id
  16084. AND a.hospital_id = c.hospital_id
  16085. AND a.beh_dept_id = c.dept_id
  16086. AND a.behospital_code = b.behospital_code
  16087. AND a.qc_type_id != 0
  16088. <if test="qcResultShortPageVO.userId!=null">
  16089. AND c.user_id = #{qcResultShortPageVO.userId}
  16090. </if>
  16091. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16092. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16093. </if>
  16094. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16095. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16096. </if>
  16097. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16098. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16099. </if>
  16100. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16101. <if test="qcResultShortPageVO.startDate != null ">
  16102. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16103. </if>
  16104. <if test="qcResultShortPageVO.endDate != null ">
  16105. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16106. </if>
  16107. </if>
  16108. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16109. <if test="qcResultShortPageVO.startDate != null ">
  16110. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16111. </if>
  16112. <if test="qcResultShortPageVO.endDate != null">
  16113. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16114. </if>
  16115. </if>
  16116. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  16117. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  16118. </if>
  16119. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16120. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16121. </if>
  16122. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16123. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  16124. </if>
  16125. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16126. AND b.`level` = #{qcResultShortPageVO.level}
  16127. </if>
  16128. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16129. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16130. </if>
  16131. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16132. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16133. </if>
  16134. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16135. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  16136. </if>
  16137. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16138. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  16139. </if>
  16140. ) be
  16141. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16142. AND mci.check_type = 0
  16143. AND be.hospital_id = mci.hospital_id
  16144. AND be.behospital_code = mci.behospital_code
  16145. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16146. AND hm_mci.check_type = 1
  16147. AND be.hospital_id = hm_mci.hospital_id
  16148. AND be.behospital_code = hm_mci.behospital_code
  16149. LEFT JOIN med_qcresult_cases e
  16150. on be.behospital_code = e.behospital_code
  16151. and be.hospital_id = e.hospital_id
  16152. AND e.is_deleted = 'N'
  16153. and e.cases_id = 243
  16154. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  16155. and be.hospital_id = t2.hospital_id
  16156. AND t2.is_deleted = 'N'
  16157. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  16158. AND t3.is_deleted = 'N'
  16159. ) t1
  16160. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16161. AND t1.behospital_code = t2.behospital_code
  16162. AND t2.is_deleted = 'N'
  16163. ) t
  16164. WHERE
  16165. 1 = 1
  16166. <if test="qcResultShortPageVO.checkStatus != null">
  16167. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16168. </if>
  16169. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  16170. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  16171. </if>
  16172. <if test="qcResultShortPageVO.mrStatus != null">
  16173. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16174. </if>
  16175. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16176. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16177. </if>
  16178. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16179. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16180. </if>
  16181. <if test="qcResultShortPageVO.chTimeStart != null ">
  16182. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16183. </if>
  16184. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16185. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16186. </if>
  16187. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16188. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16189. </if>
  16190. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16191. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16192. </if>
  16193. </select>
  16194. <!-- 病案首页改善率质控评分页导出-->
  16195. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  16196. SELECT
  16197. f1.behDeptId,
  16198. f1.behDeptName,
  16199. f1.patName,
  16200. f1.behospitalCode,
  16201. f1.hospitalId,
  16202. f1.behospitalDate,
  16203. f1.leaveHospitalDate,
  16204. f1.score,
  16205. f1.scoreBn,
  16206. f2.avgScore,
  16207. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16208. f1.msg,
  16209. f1.caseName,
  16210. </if>
  16211. f1.checkStatus,
  16212. f1.chName,
  16213. f1.chTime
  16214. FROM
  16215. (SELECT
  16216. t.doctorName AS behDoctorName,
  16217. t.`name` AS patName,
  16218. t.behospitalCode AS behospitalCode,
  16219. t.behospitalDate AS behospitalDate,
  16220. t.leaveHospitalDate AS leaveHospitalDate,
  16221. qi.score_res AS score,
  16222. t.scoreBn,
  16223. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16224. qd.msg AS msg,
  16225. qc.NAME AS caseName,
  16226. </if>
  16227. t.behDeptId,
  16228. t.behDeptName,
  16229. t.hospitalId,
  16230. t.checkStatus,
  16231. t.chName,
  16232. t.chTime
  16233. FROM
  16234. (
  16235. SELECT DISTINCT
  16236. t1.hospital_id AS hospitalId,
  16237. t1.behospital_code AS behospitalCode,
  16238. t1.bed_code AS bedCode,
  16239. t1.LEVEL AS LEVEL,
  16240. t1.grade_type AS gradeType,
  16241. t1.score_res AS scoreRes,
  16242. t1.scoreBn,
  16243. t1.NAME AS NAME,
  16244. t1.sex AS sex,
  16245. t1.beh_dept_id AS behDeptId,
  16246. t1.beh_dept_name AS behDeptName,
  16247. t1.doctor_id AS doctorId,
  16248. t1.doctor_name AS doctorName,
  16249. t1.beh_doctor_id AS behDoctorId,
  16250. t1.beh_doctor_name AS behDoctorName,
  16251. t1.director_doctor_id AS directorDoctorId,
  16252. t1.director_doctor_name AS directorDoctorName,
  16253. t1.birthday AS birthday,
  16254. t1.behospital_date AS behospitalDate,
  16255. t1.leave_hospital_date AS leaveHospitalDate,
  16256. t1.placefile_date AS placefileDate,
  16257. t1.gmt_create AS gradeTime,
  16258. t1.diagnose,
  16259. t1.ward_name AS wardName,
  16260. t2.age,
  16261. t1.file_code AS fileCode,
  16262. t1.checkStatus,
  16263. t1.chName,
  16264. t1.chTime
  16265. FROM
  16266. (
  16267. SELECT
  16268. be.*,
  16269. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16270. mci.check_name AS chName,
  16271. mci.gmt_create AS chTime
  16272. FROM
  16273. (
  16274. SELECT DISTINCT
  16275. a.hospital_id,
  16276. a.behospital_code,
  16277. a.bed_code,
  16278. a.file_code,
  16279. c.LEVEL,
  16280. c.grade_type,
  16281. c.score_res,
  16282. a.NAME,
  16283. a.sex,
  16284. a.beh_dept_id,
  16285. a.beh_dept_name,
  16286. a.birthday,
  16287. a.behospital_date,
  16288. a.leave_hospital_date,
  16289. a.doctor_id,
  16290. a.doctor_name,
  16291. a.beh_doctor_id,
  16292. a.beh_doctor_name,
  16293. a.director_doctor_id,
  16294. a.director_doctor_name,
  16295. a.diagnose,
  16296. a.placefile_date,
  16297. a.ward_name,
  16298. c.gmt_create,
  16299. d.score_res as scoreBn
  16300. FROM
  16301. med_behospital_info a,
  16302. med_home_page b,
  16303. med_qcresult_info c,
  16304. med_qcresult_cases d,
  16305. (
  16306. SELECT
  16307. m4.*
  16308. FROM
  16309. med_behospital_info m1,
  16310. med_home_page m2,
  16311. med_qcresult_info m3,
  16312. med_qcresult_cases m4
  16313. WHERE
  16314. m1.is_deleted = 'N'
  16315. AND m2.is_deleted = 'N'
  16316. AND m3.is_deleted = 'Y'
  16317. AND m4.is_deleted = 'Y'
  16318. AND m1.hospital_id = m2.hospital_id
  16319. AND m1.hospital_id = m3.hospital_id
  16320. AND m1.hospital_id = m4.hospital_id
  16321. AND m1.behospital_code = m2.behospital_code
  16322. AND m1.behospital_code = m3.behospital_code
  16323. AND m1.behospital_code = m4.behospital_code
  16324. AND m3.gmt_create = m4.gmt_create
  16325. AND m3.have_home_page = 1
  16326. AND m4.cases_id = 243
  16327. AND m1.qc_type_id != 0
  16328. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16329. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16330. </if>
  16331. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16332. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16333. </if>
  16334. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16335. <if test="qcResultShortPageVO.startDate != null ">
  16336. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16337. </if>
  16338. <if test="qcResultShortPageVO.endDate != null ">
  16339. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16340. </if>
  16341. </if>
  16342. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16343. <if test="qcResultShortPageVO.startDate != null">
  16344. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16345. </if>
  16346. <if test="qcResultShortPageVO.endDate != null ">
  16347. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16348. </if>
  16349. </if>
  16350. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16351. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16352. </if>
  16353. GROUP BY
  16354. m1.behospital_code
  16355. ORDER BY
  16356. m1.behospital_code,
  16357. m4.gmt_create
  16358. ) e
  16359. WHERE
  16360. a.is_deleted = 'N'
  16361. AND b.is_deleted = 'N'
  16362. AND c.is_deleted = 'N'
  16363. AND d.is_deleted = 'N'
  16364. AND a.hospital_id = b.hospital_id
  16365. AND a.hospital_id = c.hospital_id
  16366. AND a.hospital_id = d.hospital_id
  16367. AND a.hospital_id = e.hospital_id
  16368. AND a.behospital_code = b.behospital_code
  16369. AND a.behospital_code = c.behospital_code
  16370. AND a.behospital_code = d.behospital_code
  16371. AND a.behospital_code = e.behospital_code
  16372. AND d.cases_id = 243
  16373. AND d.score_res > e.score_res
  16374. AND a.qc_type_id != 0
  16375. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16376. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16377. </if>
  16378. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16379. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16380. </if>
  16381. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16382. <if test="qcResultShortPageVO.startDate != null ">
  16383. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16384. </if>
  16385. <if test="qcResultShortPageVO.endDate != null ">
  16386. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16387. </if>
  16388. </if>
  16389. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16390. <if test="qcResultShortPageVO.startDate != null ">
  16391. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16392. </if>
  16393. <if test="qcResultShortPageVO.endDate != null">
  16394. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16395. </if>
  16396. </if>
  16397. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16398. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16399. </if>
  16400. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16401. AND c.`level` = #{qcResultShortPageVO.level}
  16402. </if>
  16403. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16404. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16405. </if>
  16406. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16407. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16408. </if>
  16409. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16410. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16411. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16412. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16413. </if>
  16414. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16415. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16416. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16417. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16418. </if>
  16419. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16420. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16421. </if>
  16422. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16423. AND d.score_res = 20
  16424. </if>
  16425. ) be
  16426. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16427. AND mci.check_type in(0,2)
  16428. AND be.hospital_id = mci.hospital_id
  16429. AND be.behospital_code = mci.behospital_code
  16430. ) t1
  16431. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16432. AND t1.behospital_code = t2.behospital_code
  16433. AND t2.is_deleted = 'N'
  16434. ) t
  16435. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16436. AND t.hospitalId = qi.hospital_id
  16437. AND t.behospitalCode = qi.behospital_code
  16438. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16439. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16440. AND t.hospitalId = qd.hospital_id
  16441. AND t.behospitalCode = qd.behospital_code
  16442. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16443. AND qd.cases_id = qc.id
  16444. </if>
  16445. where 1=1
  16446. <if test="qcResultShortPageVO.checkStatus != null">
  16447. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16448. </if>
  16449. <if test="qcResultShortPageVO.mrStatus != null">
  16450. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16451. </if>
  16452. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16453. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16454. </if>
  16455. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16456. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16457. </if>
  16458. <if test="qcResultShortPageVO.chTimeStart != null ">
  16459. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16460. </if>
  16461. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16462. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16463. </if>
  16464. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16465. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16466. </if>
  16467. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16468. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16469. </if>
  16470. )f1,
  16471. (SELECT
  16472. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16473. t.behDeptId,
  16474. t.behDeptName
  16475. FROM
  16476. (
  16477. SELECT DISTINCT
  16478. t1.hospital_id AS hospitalId,
  16479. t1.behospital_code AS behospitalCode,
  16480. t1.bed_code AS bedCode,
  16481. t1.LEVEL AS LEVEL,
  16482. t1.grade_type AS gradeType,
  16483. t1.score_res AS scoreRes,
  16484. t1.NAME AS NAME,
  16485. t1.sex AS sex,
  16486. t1.beh_dept_id AS behDeptId,
  16487. t1.beh_dept_name AS behDeptName,
  16488. t1.doctor_id AS doctorId,
  16489. t1.doctor_name AS doctorName,
  16490. t1.beh_doctor_id AS behDoctorId,
  16491. t1.beh_doctor_name AS behDoctorName,
  16492. t1.director_doctor_id AS directorDoctorId,
  16493. t1.director_doctor_name AS directorDoctorName,
  16494. t1.birthday AS birthday,
  16495. t1.behospital_date AS behospitalDate,
  16496. t1.leave_hospital_date AS leaveHospitalDate,
  16497. t1.placefile_date AS placefileDate,
  16498. t1.gmt_create AS gradeTime,
  16499. t1.diagnose,
  16500. t1.ward_name AS wardName,
  16501. t2.age,
  16502. t1.file_code AS fileCode,
  16503. t1.checkStatus,
  16504. t1.chName,
  16505. t1.chTime
  16506. FROM
  16507. (
  16508. SELECT
  16509. be.*,
  16510. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16511. mci.check_name AS chName,
  16512. mci.gmt_create AS chTime
  16513. FROM
  16514. (
  16515. SELECT DISTINCT
  16516. a.hospital_id,
  16517. a.behospital_code,
  16518. a.bed_code,
  16519. a.file_code,
  16520. c.LEVEL,
  16521. c.grade_type,
  16522. c.score_res,
  16523. a.NAME,
  16524. a.sex,
  16525. a.beh_dept_id,
  16526. a.beh_dept_name,
  16527. a.birthday,
  16528. a.behospital_date,
  16529. a.leave_hospital_date,
  16530. a.doctor_id,
  16531. a.doctor_name,
  16532. a.beh_doctor_id,
  16533. a.beh_doctor_name,
  16534. a.director_doctor_id,
  16535. a.director_doctor_name,
  16536. a.diagnose,
  16537. a.placefile_date,
  16538. a.ward_name,
  16539. c.gmt_create
  16540. FROM
  16541. med_behospital_info a,
  16542. med_home_page b,
  16543. med_qcresult_info c,
  16544. med_qcresult_cases d,
  16545. (
  16546. SELECT
  16547. m4.*
  16548. FROM
  16549. med_behospital_info m1,
  16550. med_home_page m2,
  16551. med_qcresult_info m3,
  16552. med_qcresult_cases m4
  16553. WHERE
  16554. m1.is_deleted = 'N'
  16555. AND m2.is_deleted = 'N'
  16556. AND m3.is_deleted = 'Y'
  16557. AND m4.is_deleted = 'Y'
  16558. AND m1.hospital_id = m2.hospital_id
  16559. AND m1.hospital_id = m3.hospital_id
  16560. AND m1.hospital_id = m4.hospital_id
  16561. AND m1.behospital_code = m2.behospital_code
  16562. AND m1.behospital_code = m3.behospital_code
  16563. AND m1.behospital_code = m4.behospital_code
  16564. AND m3.gmt_create = m4.gmt_create
  16565. AND m3.have_home_page = 1
  16566. AND m4.cases_id = 243
  16567. AND m1.qc_type_id != 0
  16568. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16569. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16570. </if>
  16571. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16572. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16573. </if>
  16574. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16575. <if test="qcResultShortPageVO.startDate != null ">
  16576. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16577. </if>
  16578. <if test="qcResultShortPageVO.endDate != null ">
  16579. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16580. </if>
  16581. </if>
  16582. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16583. <if test="qcResultShortPageVO.startDate != null">
  16584. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16585. </if>
  16586. <if test="qcResultShortPageVO.endDate != null ">
  16587. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16588. </if>
  16589. </if>
  16590. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16591. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16592. </if>
  16593. GROUP BY
  16594. m1.behospital_code
  16595. ORDER BY
  16596. m1.behospital_code,
  16597. m4.gmt_create
  16598. ) e
  16599. WHERE
  16600. a.is_deleted = 'N'
  16601. AND b.is_deleted = 'N'
  16602. AND c.is_deleted = 'N'
  16603. AND d.is_deleted = 'N'
  16604. AND a.hospital_id = b.hospital_id
  16605. AND a.hospital_id = c.hospital_id
  16606. AND a.hospital_id = d.hospital_id
  16607. AND a.hospital_id = e.hospital_id
  16608. AND a.behospital_code = b.behospital_code
  16609. AND a.behospital_code = c.behospital_code
  16610. AND a.behospital_code = d.behospital_code
  16611. AND a.behospital_code = e.behospital_code
  16612. AND d.cases_id = 243
  16613. AND d.score_res > e.score_res
  16614. AND a.qc_type_id != 0
  16615. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16616. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16617. </if>
  16618. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16619. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16620. </if>
  16621. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16622. <if test="qcResultShortPageVO.startDate != null ">
  16623. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16624. </if>
  16625. <if test="qcResultShortPageVO.endDate != null ">
  16626. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16627. </if>
  16628. </if>
  16629. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16630. <if test="qcResultShortPageVO.startDate != null ">
  16631. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16632. </if>
  16633. <if test="qcResultShortPageVO.endDate != null">
  16634. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16635. </if>
  16636. </if>
  16637. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16638. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16639. </if>
  16640. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16641. AND c.`level` = #{qcResultShortPageVO.level}
  16642. </if>
  16643. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16644. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16645. </if>
  16646. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16647. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16648. </if>
  16649. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16650. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16651. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16652. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16653. </if>
  16654. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16655. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16656. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16657. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16658. </if>
  16659. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16660. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16661. </if>
  16662. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16663. AND d.score_res = 20
  16664. </if>
  16665. ) be
  16666. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16667. AND mci.check_type in(0,2)
  16668. AND be.hospital_id = mci.hospital_id
  16669. AND be.behospital_code = mci.behospital_code
  16670. ) t1
  16671. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16672. AND t1.behospital_code = t2.behospital_code
  16673. AND t2.is_deleted = 'N'
  16674. ) t
  16675. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16676. AND t.hospitalId = qi.hospital_id
  16677. AND t.behospitalCode = qi.behospital_code
  16678. where 1=1
  16679. <if test="qcResultShortPageVO.checkStatus != null">
  16680. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16681. </if>
  16682. <if test="qcResultShortPageVO.mrStatus != null">
  16683. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16684. </if>
  16685. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16686. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16687. </if>
  16688. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16689. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16690. </if>
  16691. <if test="qcResultShortPageVO.chTimeStart != null ">
  16692. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16693. </if>
  16694. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16695. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16696. </if>
  16697. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16698. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16699. </if>
  16700. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16701. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16702. </if>
  16703. GROUP BY
  16704. t.behDeptId,
  16705. t.behDeptName
  16706. )f2
  16707. WHERE
  16708. f1.behDeptId = f2.behDeptId
  16709. AND f1.behDeptName = f2.behDeptName
  16710. </select>
  16711. <!-- 病案首页改善率质控评分页导出-->
  16712. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  16713. SELECT
  16714. f1.behDeptId,
  16715. f1.behDeptName,
  16716. f1.wardName,
  16717. f1.medoupName,
  16718. f1.doctorId,
  16719. f1.doctorName,
  16720. f1.patName,
  16721. f1.behospitalCode,
  16722. f1.hospitalId,
  16723. f1.scoreBn,
  16724. f1.behospitalDate,
  16725. f1.leaveHospitalDate,
  16726. f1.score,
  16727. f2.avgScore,
  16728. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16729. f1.msg,
  16730. f1.caseName,
  16731. </if>
  16732. f1.checkStatus,
  16733. f1.mrStatus,
  16734. f1.chName,
  16735. f1.mrName,
  16736. f1.chTime,
  16737. f1.mrTime
  16738. FROM
  16739. (SELECT
  16740. t.doctorId,
  16741. t.doctorName,
  16742. t.`name` AS patName,
  16743. t.behospitalCode AS behospitalCode,
  16744. t.behospitalDate AS behospitalDate,
  16745. t.leaveHospitalDate AS leaveHospitalDate,
  16746. qi.score_res AS score,
  16747. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16748. qd.msg AS msg,
  16749. qc.NAME AS caseName,
  16750. </if>
  16751. t.behDeptId,
  16752. t.behDeptName,
  16753. t.wardName,
  16754. t.scoreBn,
  16755. t3.name as medoupName,
  16756. t.hospitalId,
  16757. t.checkStatus,
  16758. t.mrStatus,
  16759. t.chName,
  16760. t.mrName,
  16761. t.chTime,
  16762. t.mrTime
  16763. FROM
  16764. (
  16765. SELECT DISTINCT
  16766. t1.hospital_id AS hospitalId,
  16767. t1.behospital_code AS behospitalCode,
  16768. t1.bed_code AS bedCode,
  16769. t1.LEVEL AS LEVEL,
  16770. t1.grade_type AS gradeType,
  16771. t1.score_res AS scoreRes,
  16772. t1.NAME AS NAME,
  16773. t1.sex AS sex,
  16774. t1.beh_dept_id AS behDeptId,
  16775. t1.beh_dept_name AS behDeptName,
  16776. t1.doctor_id AS doctorId,
  16777. t1.doctor_name AS doctorName,
  16778. t1.beh_doctor_id AS behDoctorId,
  16779. t1.beh_doctor_name AS behDoctorName,
  16780. t1.director_doctor_id AS directorDoctorId,
  16781. t1.director_doctor_name AS directorDoctorName,
  16782. t1.birthday AS birthday,
  16783. t1.behospital_date AS behospitalDate,
  16784. t1.leave_hospital_date AS leaveHospitalDate,
  16785. t1.placefile_date AS placefileDate,
  16786. t1.gmt_create AS gradeTime,
  16787. t1.diagnose,
  16788. t1.ward_name AS wardName,
  16789. t1.scoreBn,
  16790. t1.file_code AS fileCode,
  16791. t1.checkStatus,
  16792. t1.mrStatus,
  16793. t1.chName,
  16794. t1.mrName,
  16795. t1.chTime,
  16796. t1.mrTime
  16797. FROM
  16798. (
  16799. SELECT
  16800. be.*,
  16801. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16802. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16803. mci.check_name AS chName,
  16804. e.score_res as scoreBn,
  16805. hm_mci.check_name AS mrName,
  16806. mci.gmt_create AS chTime,
  16807. hm_mci.gmt_create AS mrTime
  16808. FROM
  16809. (
  16810. SELECT DISTINCT
  16811. a.hospital_id,
  16812. a.behospital_code,
  16813. a.bed_code,
  16814. a.file_code,
  16815. c.LEVEL,
  16816. c.grade_type,
  16817. c.score_res,
  16818. a.NAME,
  16819. a.sex,
  16820. a.beh_dept_id,
  16821. a.beh_dept_name,
  16822. a.birthday,
  16823. a.behospital_date,
  16824. a.leave_hospital_date,
  16825. a.doctor_id,
  16826. a.doctor_name,
  16827. a.beh_doctor_id,
  16828. a.beh_doctor_name,
  16829. a.director_doctor_id,
  16830. a.director_doctor_name,
  16831. a.diagnose,
  16832. a.placefile_date,
  16833. a.ward_name,
  16834. c.gmt_create
  16835. FROM
  16836. med_behospital_info a,
  16837. med_home_page b,
  16838. med_qcresult_info c,
  16839. med_qcresult_cases d,
  16840. sys_user_dept f,
  16841. (
  16842. SELECT
  16843. m4.*
  16844. FROM
  16845. med_behospital_info m1,
  16846. med_home_page m2,
  16847. med_qcresult_info m3,
  16848. med_qcresult_cases m4
  16849. WHERE
  16850. m1.is_deleted = 'N'
  16851. AND m2.is_deleted = 'N'
  16852. AND m3.is_deleted = 'Y'
  16853. AND m4.is_deleted = 'Y'
  16854. AND m1.hospital_id = m2.hospital_id
  16855. AND m1.hospital_id = m3.hospital_id
  16856. AND m1.hospital_id = m4.hospital_id
  16857. AND m1.behospital_code = m2.behospital_code
  16858. AND m1.behospital_code = m3.behospital_code
  16859. AND m1.behospital_code = m4.behospital_code
  16860. AND m3.gmt_create = m4.gmt_create
  16861. AND m3.have_home_page = 1
  16862. AND m4.cases_id = 243
  16863. AND m1.qc_type_id != 0
  16864. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16865. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16866. </if>
  16867. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16868. and m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16869. </if>
  16870. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16871. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16872. </if>
  16873. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16874. AND m1.doctor_name = #{qcResultShortPageVO.doctorName}
  16875. </if>
  16876. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16877. <if test="qcResultShortPageVO.startDate != null ">
  16878. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16879. </if>
  16880. <if test="qcResultShortPageVO.endDate != null ">
  16881. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16882. </if>
  16883. </if>
  16884. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16885. <if test="qcResultShortPageVO.startDate != null">
  16886. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16887. </if>
  16888. <if test="qcResultShortPageVO.endDate != null ">
  16889. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16890. </if>
  16891. </if>
  16892. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16893. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16894. </if>
  16895. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16896. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  16897. </if>
  16898. GROUP BY
  16899. m1.behospital_code
  16900. ORDER BY
  16901. m1.behospital_code,
  16902. m4.gmt_create
  16903. ) e
  16904. WHERE
  16905. a.is_deleted = 'N'
  16906. AND b.is_deleted = 'N'
  16907. AND c.is_deleted = 'N'
  16908. AND d.is_deleted = 'N'
  16909. AND f.is_deleted = 'N'
  16910. AND a.hospital_id = b.hospital_id
  16911. AND a.hospital_id = c.hospital_id
  16912. AND a.hospital_id = d.hospital_id
  16913. AND a.hospital_id = e.hospital_id
  16914. AND a.hospital_id = f.hospital_id
  16915. AND a.behospital_code = b.behospital_code
  16916. AND a.behospital_code = c.behospital_code
  16917. AND a.behospital_code = d.behospital_code
  16918. AND a.behospital_code = e.behospital_code
  16919. AND a.beh_dept_id = f.dept_id
  16920. AND d.cases_id = 243
  16921. AND d.score_res > e.score_res
  16922. AND a.qc_type_id != 0
  16923. <if test="qcResultShortPageVO.userId!=null">
  16924. AND f.user_id = #{qcResultShortPageVO.userId}
  16925. </if>
  16926. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16927. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16928. </if>
  16929. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  16930. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  16931. </if>
  16932. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16933. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16934. </if>
  16935. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16936. <if test="qcResultShortPageVO.startDate != null ">
  16937. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16938. </if>
  16939. <if test="qcResultShortPageVO.endDate != null ">
  16940. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16941. </if>
  16942. </if>
  16943. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16944. <if test="qcResultShortPageVO.startDate != null ">
  16945. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16946. </if>
  16947. <if test="qcResultShortPageVO.endDate != null">
  16948. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16949. </if>
  16950. </if>
  16951. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16952. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16953. </if>
  16954. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  16955. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  16956. </if>
  16957. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16958. AND c.`level` = #{qcResultShortPageVO.level}
  16959. </if>
  16960. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16961. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16962. </if>
  16963. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16964. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16965. </if>
  16966. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16967. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  16968. </if>
  16969. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16970. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  16971. </if>
  16972. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16973. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16974. </if>
  16975. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16976. AND d.score_res = 20
  16977. </if>
  16978. ) be
  16979. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16980. AND mci.check_type = 0
  16981. AND be.hospital_id = mci.hospital_id
  16982. AND be.behospital_code = mci.behospital_code
  16983. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16984. AND hm_mci.check_type = 1
  16985. AND be.hospital_id = hm_mci.hospital_id
  16986. AND be.behospital_code = hm_mci.behospital_code
  16987. LEFT JOIN med_qcresult_cases e
  16988. on be.behospital_code = e.behospital_code
  16989. and be.hospital_id = e.hospital_id
  16990. AND e.is_deleted = 'N'
  16991. and e.cases_id = 243
  16992. ) t1
  16993. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16994. AND t1.behospital_code = t2.behospital_code
  16995. AND t2.is_deleted = 'N'
  16996. ) t
  16997. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16998. AND t.hospitalId = qi.hospital_id
  16999. AND t.behospitalCode = qi.behospital_code
  17000. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  17001. AND t.hospitalId = t2.hospital_id
  17002. AND t2.is_deleted = 'N'
  17003. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  17004. AND t3.is_deleted = 'N'
  17005. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17006. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17007. AND t.hospitalId = qd.hospital_id
  17008. AND t.behospitalCode = qd.behospital_code
  17009. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17010. AND qd.cases_id = qc.id
  17011. </if>
  17012. where 1=1
  17013. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  17014. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  17015. </if>
  17016. <if test="qcResultShortPageVO.checkStatus != null">
  17017. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17018. </if>
  17019. <if test="qcResultShortPageVO.mrStatus != null">
  17020. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17021. </if>
  17022. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17023. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17024. </if>
  17025. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17026. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17027. </if>
  17028. <if test="qcResultShortPageVO.chTimeStart != null ">
  17029. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17030. </if>
  17031. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17032. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17033. </if>
  17034. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17035. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17036. </if>
  17037. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17038. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17039. </if>
  17040. )f1,
  17041. (SELECT
  17042. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17043. t.behDeptId,
  17044. t.behDeptName,
  17045. t.doctorId,
  17046. t.doctorName
  17047. FROM
  17048. (
  17049. SELECT DISTINCT
  17050. t1.hospital_id AS hospitalId,
  17051. t1.behospital_code AS behospitalCode,
  17052. t1.bed_code AS bedCode,
  17053. t1.LEVEL AS LEVEL,
  17054. t1.grade_type AS gradeType,
  17055. t1.score_res AS scoreRes,
  17056. t1.NAME AS NAME,
  17057. t1.sex AS sex,
  17058. t1.beh_dept_id AS behDeptId,
  17059. t1.beh_dept_name AS behDeptName,
  17060. t1.doctor_id AS doctorId,
  17061. t1.doctor_name AS doctorName,
  17062. t1.beh_doctor_id AS behDoctorId,
  17063. t1.beh_doctor_name AS behDoctorName,
  17064. t1.director_doctor_id AS directorDoctorId,
  17065. t1.director_doctor_name AS directorDoctorName,
  17066. t1.birthday AS birthday,
  17067. t1.behospital_date AS behospitalDate,
  17068. t1.leave_hospital_date AS leaveHospitalDate,
  17069. t1.placefile_date AS placefileDate,
  17070. t1.gmt_create AS gradeTime,
  17071. t1.diagnose,
  17072. t1.ward_name AS wardName,
  17073. t2.age,
  17074. t1.file_code AS fileCode,
  17075. t1.checkStatus,
  17076. t1.mrStatus,
  17077. t1.chName,
  17078. t1.mrName,
  17079. t1.chTime,
  17080. t1.mrTime
  17081. FROM
  17082. (
  17083. SELECT
  17084. be.*,
  17085. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17086. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17087. mci.check_name AS chName,
  17088. hm_mci.check_name AS mrName,
  17089. mci.gmt_create AS chTime,
  17090. hm_mci.gmt_create AS mrTime
  17091. FROM
  17092. (
  17093. SELECT DISTINCT
  17094. a.hospital_id,
  17095. a.behospital_code,
  17096. a.bed_code,
  17097. a.file_code,
  17098. c.LEVEL,
  17099. c.grade_type,
  17100. c.score_res,
  17101. a.NAME,
  17102. a.sex,
  17103. a.beh_dept_id,
  17104. a.beh_dept_name,
  17105. a.birthday,
  17106. a.behospital_date,
  17107. a.leave_hospital_date,
  17108. a.doctor_id,
  17109. a.doctor_name,
  17110. a.beh_doctor_id,
  17111. a.beh_doctor_name,
  17112. a.director_doctor_id,
  17113. a.director_doctor_name,
  17114. a.diagnose,
  17115. a.placefile_date,
  17116. a.ward_name,
  17117. c.gmt_create
  17118. FROM
  17119. med_behospital_info a,
  17120. med_home_page b,
  17121. med_qcresult_info c,
  17122. med_qcresult_cases d,
  17123. sys_user_dept f,
  17124. (
  17125. SELECT
  17126. m4.*
  17127. FROM
  17128. med_behospital_info m1,
  17129. med_home_page m2,
  17130. med_qcresult_info m3,
  17131. med_qcresult_cases m4
  17132. WHERE
  17133. m1.is_deleted = 'N'
  17134. AND m2.is_deleted = 'N'
  17135. AND m3.is_deleted = 'Y'
  17136. AND m4.is_deleted = 'Y'
  17137. AND m1.hospital_id = m2.hospital_id
  17138. AND m1.hospital_id = m3.hospital_id
  17139. AND m1.hospital_id = m4.hospital_id
  17140. AND m1.behospital_code = m2.behospital_code
  17141. AND m1.behospital_code = m3.behospital_code
  17142. AND m1.behospital_code = m4.behospital_code
  17143. AND m3.gmt_create = m4.gmt_create
  17144. AND m3.have_home_page = 1
  17145. AND m4.cases_id = 243
  17146. AND m1.qc_type_id != 0
  17147. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17148. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17149. </if>
  17150. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  17151. and m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  17152. </if>
  17153. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17154. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  17155. </if>
  17156. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17157. AND m1.doctor_name = #{qcResultShortPageVO.doctorName}
  17158. </if>
  17159. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17160. <if test="qcResultShortPageVO.startDate != null ">
  17161. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17162. </if>
  17163. <if test="qcResultShortPageVO.endDate != null ">
  17164. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17165. </if>
  17166. </if>
  17167. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17168. <if test="qcResultShortPageVO.startDate != null">
  17169. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17170. </if>
  17171. <if test="qcResultShortPageVO.endDate != null ">
  17172. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17173. </if>
  17174. </if>
  17175. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17176. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  17177. </if>
  17178. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  17179. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  17180. </if>
  17181. GROUP BY
  17182. m1.behospital_code
  17183. ORDER BY
  17184. m1.behospital_code,
  17185. m4.gmt_create
  17186. ) e
  17187. WHERE
  17188. a.is_deleted = 'N'
  17189. AND b.is_deleted = 'N'
  17190. AND c.is_deleted = 'N'
  17191. AND d.is_deleted = 'N'
  17192. AND f.is_deleted = 'N'
  17193. AND a.hospital_id = b.hospital_id
  17194. AND a.hospital_id = c.hospital_id
  17195. AND a.hospital_id = d.hospital_id
  17196. AND a.hospital_id = e.hospital_id
  17197. AND a.hospital_id = f.hospital_id
  17198. AND a.behospital_code = b.behospital_code
  17199. AND a.behospital_code = c.behospital_code
  17200. AND a.behospital_code = d.behospital_code
  17201. AND a.behospital_code = e.behospital_code
  17202. AND a.beh_dept_id = f.dept_id
  17203. AND d.cases_id = 243
  17204. AND d.score_res > e.score_res
  17205. AND a.qc_type_id != 0
  17206. <if test="qcResultShortPageVO.userId!=null">
  17207. AND f.user_id = #{qcResultShortPageVO.userId}
  17208. </if>
  17209. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  17210. and a.ward_nameLIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  17211. </if>
  17212. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17213. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17214. </if>
  17215. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17216. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17217. </if>
  17218. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17219. <if test="qcResultShortPageVO.startDate != null ">
  17220. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17221. </if>
  17222. <if test="qcResultShortPageVO.endDate != null ">
  17223. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17224. </if>
  17225. </if>
  17226. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17227. <if test="qcResultShortPageVO.startDate != null ">
  17228. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17229. </if>
  17230. <if test="qcResultShortPageVO.endDate != null">
  17231. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17232. </if>
  17233. </if>
  17234. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17235. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17236. </if>
  17237. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  17238. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  17239. </if>
  17240. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17241. AND c.`level` = #{qcResultShortPageVO.level}
  17242. </if>
  17243. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17244. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17245. </if>
  17246. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17247. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17248. </if>
  17249. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17250. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  17251. </if>
  17252. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17253. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  17254. </if>
  17255. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  17256. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  17257. </if>
  17258. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  17259. AND d.score_res = 20
  17260. </if>
  17261. ) be
  17262. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17263. AND mci.check_type = 0
  17264. AND be.hospital_id = mci.hospital_id
  17265. AND be.behospital_code = mci.behospital_code
  17266. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17267. AND hm_mci.check_type = 1
  17268. AND be.hospital_id = hm_mci.hospital_id
  17269. AND be.behospital_code = hm_mci.behospital_code
  17270. ) t1
  17271. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17272. AND t1.behospital_code = t2.behospital_code
  17273. AND t2.is_deleted = 'N'
  17274. ) t
  17275. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17276. AND t.hospitalId = qi.hospital_id
  17277. AND t.behospitalCode = qi.behospital_code
  17278. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  17279. AND t.hospitalId = t2.hospital_id
  17280. AND t2.is_deleted = 'N'
  17281. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  17282. AND t3.is_deleted = 'N'
  17283. where 1=1
  17284. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  17285. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  17286. </if>
  17287. <if test="qcResultShortPageVO.checkStatus != null">
  17288. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17289. </if>
  17290. <if test="qcResultShortPageVO.mrStatus != null">
  17291. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17292. </if>
  17293. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17294. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17295. </if>
  17296. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17297. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17298. </if>
  17299. <if test="qcResultShortPageVO.chTimeStart != null ">
  17300. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17301. </if>
  17302. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17303. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17304. </if>
  17305. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17306. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17307. </if>
  17308. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17309. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17310. </if>
  17311. GROUP BY
  17312. t.doctorId,
  17313. t.doctorName
  17314. )f2
  17315. WHERE
  17316. f1.doctorId = f2.doctorId
  17317. AND f1.doctorName = f2.doctorName
  17318. </select>
  17319. <!-- 质控核查质控评分页导出-->
  17320. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  17321. SELECT
  17322. f1.behDeptId,
  17323. f1.behDeptName,
  17324. f1.doctorName,
  17325. f1.patName,
  17326. f1.behospitalCode,
  17327. f1.hospitalId,
  17328. f1.behospitalDate,
  17329. f1.leaveHospitalDate,
  17330. f1.score,
  17331. f1.scoreBn,
  17332. f2.avgScore,
  17333. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17334. f1.msg,
  17335. f1.caseName,
  17336. </if>
  17337. f1.checkStatus,
  17338. f1.chName,
  17339. f1.chTime
  17340. FROM
  17341. (SELECT
  17342. t.doctorName,
  17343. t.`name` AS patName,
  17344. t.behospitalCode AS behospitalCode,
  17345. t.behospitalDate AS behospitalDate,
  17346. t.leaveHospitalDate AS leaveHospitalDate,
  17347. qi.score_res AS score,
  17348. t.scoreBn,
  17349. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17350. qd.msg AS msg,
  17351. qc.NAME AS caseName,
  17352. </if>
  17353. t.behDeptId,
  17354. t.behDeptName,
  17355. t.hospitalId,
  17356. t.checkStatus,
  17357. t.chName,
  17358. t.chTime
  17359. FROM
  17360. (
  17361. SELECT DISTINCT
  17362. t1.hospital_id AS hospitalId,
  17363. t1.behospital_code AS behospitalCode,
  17364. t1.bed_code AS bedCode,
  17365. t1.LEVEL AS LEVEL,
  17366. t1.grade_type AS gradeType,
  17367. t1.score_res AS scoreRes,
  17368. t1.scoreBn,
  17369. t1.NAME AS NAME,
  17370. t1.sex AS sex,
  17371. t1.beh_dept_id AS behDeptId,
  17372. t1.beh_dept_name AS behDeptName,
  17373. t1.doctor_id AS doctorId,
  17374. t1.doctor_name AS doctorName,
  17375. t1.beh_doctor_id AS behDoctorId,
  17376. t1.beh_doctor_name AS behDoctorName,
  17377. t1.director_doctor_id AS directorDoctorId,
  17378. t1.director_doctor_name AS directorDoctorName,
  17379. t1.birthday AS birthday,
  17380. t1.behospital_date AS behospitalDate,
  17381. t1.leave_hospital_date AS leaveHospitalDate,
  17382. t1.placefile_date AS placefileDate,
  17383. t1.gmt_create AS gradeTime,
  17384. t1.diagnose,
  17385. t1.ward_name AS wardName,
  17386. t2.age,
  17387. t1.file_code AS fileCode,
  17388. t1.checkStatus,
  17389. t1.chName,
  17390. t1.chTime
  17391. FROM
  17392. (
  17393. SELECT
  17394. be.*,
  17395. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17396. mci.check_name AS chName,
  17397. e.score_res as scoreBn,
  17398. mci.gmt_create AS chTime
  17399. FROM
  17400. (
  17401. SELECT DISTINCT
  17402. a.hospital_id,
  17403. a.behospital_code,
  17404. a.bed_code,
  17405. a.file_code,
  17406. b.LEVEL,
  17407. b.grade_type,
  17408. b.score_res,
  17409. a.NAME,
  17410. a.sex,
  17411. a.beh_dept_id,
  17412. a.beh_dept_name,
  17413. a.birthday,
  17414. a.behospital_date,
  17415. a.leave_hospital_date,
  17416. a.doctor_id,
  17417. a.doctor_name,
  17418. a.beh_doctor_id,
  17419. a.beh_doctor_name,
  17420. a.director_doctor_id,
  17421. a.director_doctor_name,
  17422. a.diagnose,
  17423. a.placefile_date,
  17424. a.ward_name,
  17425. b.gmt_create
  17426. FROM
  17427. med_behospital_info a,
  17428. med_qcresult_info b
  17429. WHERE
  17430. a.is_deleted = 'N'
  17431. AND b.is_deleted = 'N'
  17432. AND a.hospital_id = b.hospital_id
  17433. AND a.behospital_code = b.behospital_code
  17434. AND a.qc_type_id != 0
  17435. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17436. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17437. </if>
  17438. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17439. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17440. </if>
  17441. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17442. <if test="qcResultShortPageVO.startDate != null ">
  17443. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17444. </if>
  17445. <if test="qcResultShortPageVO.endDate != null ">
  17446. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17447. </if>
  17448. </if>
  17449. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17450. <if test="qcResultShortPageVO.startDate != null ">
  17451. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17452. </if>
  17453. <if test="qcResultShortPageVO.endDate != null">
  17454. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17455. </if>
  17456. </if>
  17457. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17458. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17459. </if>
  17460. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17461. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17462. </if>
  17463. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17464. AND c.`level` = #{qcResultShortPageVO.level}
  17465. </if>
  17466. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17467. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17468. </if>
  17469. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17470. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17471. </if>
  17472. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17473. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17474. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17475. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17476. </if>
  17477. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17478. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17479. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17480. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17481. </if>
  17482. ) be
  17483. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17484. AND mci.check_type in(0,2)
  17485. AND be.hospital_id = mci.hospital_id
  17486. AND be.behospital_code = mci.behospital_code
  17487. LEFT JOIN med_qcresult_cases e
  17488. on be.behospital_code = e.behospital_code
  17489. and be.hospital_id = e.hospital_id
  17490. AND e.is_deleted = 'N'
  17491. and e.cases_id = 243
  17492. ) t1
  17493. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17494. AND t1.behospital_code = t2.behospital_code
  17495. AND t2.is_deleted = 'N'
  17496. ) t
  17497. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17498. AND t.hospitalId = qi.hospital_id
  17499. AND t.behospitalCode = qi.behospital_code
  17500. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17501. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17502. AND t.hospitalId = qd.hospital_id
  17503. AND t.behospitalCode = qd.behospital_code
  17504. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17505. AND qd.cases_id = qc.id
  17506. </if>
  17507. where 1=1
  17508. <if test="qcResultShortPageVO.checkStatus != null">
  17509. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17510. </if>
  17511. <if test="qcResultShortPageVO.mrStatus != null">
  17512. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17513. </if>
  17514. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17515. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17516. </if>
  17517. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17518. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17519. </if>
  17520. <if test="qcResultShortPageVO.chTimeStart != null ">
  17521. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17522. </if>
  17523. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17524. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17525. </if>
  17526. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17527. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17528. </if>
  17529. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17530. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17531. </if>
  17532. )f1,
  17533. (SELECT
  17534. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17535. t.behDeptId,
  17536. t.behDeptName
  17537. FROM
  17538. (
  17539. SELECT DISTINCT
  17540. t1.hospital_id AS hospitalId,
  17541. t1.behospital_code AS behospitalCode,
  17542. t1.bed_code AS bedCode,
  17543. t1.LEVEL AS LEVEL,
  17544. t1.grade_type AS gradeType,
  17545. t1.score_res AS scoreRes,
  17546. t1.NAME AS NAME,
  17547. t1.sex AS sex,
  17548. t1.beh_dept_id AS behDeptId,
  17549. t1.beh_dept_name AS behDeptName,
  17550. t1.doctor_id AS doctorId,
  17551. t1.doctor_name AS doctorName,
  17552. t1.beh_doctor_id AS behDoctorId,
  17553. t1.beh_doctor_name AS behDoctorName,
  17554. t1.director_doctor_id AS directorDoctorId,
  17555. t1.director_doctor_name AS directorDoctorName,
  17556. t1.birthday AS birthday,
  17557. t1.behospital_date AS behospitalDate,
  17558. t1.leave_hospital_date AS leaveHospitalDate,
  17559. t1.placefile_date AS placefileDate,
  17560. t1.gmt_create AS gradeTime,
  17561. t1.diagnose,
  17562. t1.ward_name AS wardName,
  17563. t2.age,
  17564. t1.file_code AS fileCode,
  17565. t1.checkStatus,
  17566. t1.chName,
  17567. t1.chTime
  17568. FROM
  17569. (
  17570. SELECT
  17571. be.*,
  17572. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17573. mci.check_name AS chName,
  17574. mci.gmt_create AS chTime
  17575. FROM
  17576. (
  17577. SELECT DISTINCT
  17578. a.hospital_id,
  17579. a.behospital_code,
  17580. a.bed_code,
  17581. a.file_code,
  17582. b.LEVEL,
  17583. b.grade_type,
  17584. b.score_res,
  17585. a.NAME,
  17586. a.sex,
  17587. a.beh_dept_id,
  17588. a.beh_dept_name,
  17589. a.birthday,
  17590. a.behospital_date,
  17591. a.leave_hospital_date,
  17592. a.doctor_id,
  17593. a.doctor_name,
  17594. a.beh_doctor_id,
  17595. a.beh_doctor_name,
  17596. a.director_doctor_id,
  17597. a.director_doctor_name,
  17598. a.diagnose,
  17599. a.placefile_date,
  17600. a.ward_name,
  17601. b.gmt_create
  17602. FROM
  17603. med_behospital_info a,
  17604. med_qcresult_info b
  17605. WHERE
  17606. a.is_deleted = 'N'
  17607. AND b.is_deleted = 'N'
  17608. AND a.hospital_id = b.hospital_id
  17609. AND a.behospital_code = b.behospital_code
  17610. AND a.qc_type_id != 0
  17611. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17612. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17613. </if>
  17614. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17615. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17616. </if>
  17617. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17618. <if test="qcResultShortPageVO.startDate != null ">
  17619. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17620. </if>
  17621. <if test="qcResultShortPageVO.endDate != null ">
  17622. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17623. </if>
  17624. </if>
  17625. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17626. <if test="qcResultShortPageVO.startDate != null ">
  17627. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17628. </if>
  17629. <if test="qcResultShortPageVO.endDate != null">
  17630. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17631. </if>
  17632. </if>
  17633. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17634. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17635. </if>
  17636. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17637. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17638. </if>
  17639. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17640. AND c.`level` = #{qcResultShortPageVO.level}
  17641. </if>
  17642. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17643. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17644. </if>
  17645. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17646. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17647. </if>
  17648. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17649. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17650. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17651. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17652. </if>
  17653. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17654. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17655. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17656. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17657. </if>
  17658. ) be
  17659. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17660. AND mci.check_type in(0,2)
  17661. AND be.hospital_id = mci.hospital_id
  17662. AND be.behospital_code = mci.behospital_code
  17663. ) t1
  17664. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17665. AND t1.behospital_code = t2.behospital_code
  17666. AND t2.is_deleted = 'N'
  17667. ) t
  17668. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17669. AND t.hospitalId = qi.hospital_id
  17670. AND t.behospitalCode = qi.behospital_code
  17671. where 1=1
  17672. <if test="qcResultShortPageVO.checkStatus != null">
  17673. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17674. </if>
  17675. <if test="qcResultShortPageVO.mrStatus != null">
  17676. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17677. </if>
  17678. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17679. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17680. </if>
  17681. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17682. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17683. </if>
  17684. <if test="qcResultShortPageVO.chTimeStart != null ">
  17685. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17686. </if>
  17687. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17688. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17689. </if>
  17690. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17691. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17692. </if>
  17693. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17694. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17695. </if>
  17696. GROUP BY
  17697. t.behDeptId,
  17698. t.behDeptName
  17699. )f2
  17700. WHERE
  17701. f1.behDeptId = f2.behDeptId
  17702. AND f1.behDeptName = f2.behDeptName
  17703. </select>
  17704. <!-- 质控核查质控评分页导出 -科室-->
  17705. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  17706. SELECT
  17707. f1.behDeptId,
  17708. f1.behDeptName,
  17709. f1.doctorName,
  17710. f1.doctorId,
  17711. f1.patName,
  17712. f1.behospitalCode,
  17713. f1.hospitalId,
  17714. f1.behospitalDate,
  17715. f1.leaveHospitalDate,
  17716. f1.score,
  17717. f1.scoreBn,
  17718. f2.avgScore,
  17719. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17720. f1.msg,
  17721. f1.caseName,
  17722. </if>
  17723. f1.medoupName,
  17724. f1.wardName,
  17725. f1.checkStatus,
  17726. f1.mrStatus,
  17727. f1.chName,
  17728. f1.mrName,
  17729. f1.chTime,
  17730. f1.mrTime
  17731. FROM
  17732. (SELECT
  17733. t.doctorName,
  17734. t.doctorId,
  17735. t.`name` AS patName,
  17736. t.behospitalCode AS behospitalCode,
  17737. t.behospitalDate AS behospitalDate,
  17738. t.leaveHospitalDate AS leaveHospitalDate,
  17739. qi.score_res AS score,
  17740. t.scoreBn,
  17741. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17742. qd.msg AS msg,
  17743. qc.NAME AS caseName,
  17744. </if>
  17745. t.behDeptId,
  17746. t.behDeptName,
  17747. t.wardName,
  17748. t.hospitalId,
  17749. t.checkStatus,
  17750. t.mrStatus,
  17751. t.chName,
  17752. t.mrName,
  17753. t.chTime,
  17754. t.mrTime,
  17755. t3.name as medoupName
  17756. FROM
  17757. (
  17758. SELECT DISTINCT
  17759. t1.hospital_id AS hospitalId,
  17760. t1.behospital_code AS behospitalCode,
  17761. t1.bed_code AS bedCode,
  17762. t1.LEVEL AS LEVEL,
  17763. t1.grade_type AS gradeType,
  17764. t1.score_res AS scoreRes,
  17765. t1.scoreBn,
  17766. t1.NAME AS NAME,
  17767. t1.sex AS sex,
  17768. t1.beh_dept_id AS behDeptId,
  17769. t1.beh_dept_name AS behDeptName,
  17770. t1.doctor_id AS doctorId,
  17771. t1.doctor_name AS doctorName,
  17772. t1.beh_doctor_id AS behDoctorId,
  17773. t1.beh_doctor_name AS behDoctorName,
  17774. t1.director_doctor_id AS directorDoctorId,
  17775. t1.director_doctor_name AS directorDoctorName,
  17776. t1.birthday AS birthday,
  17777. t1.behospital_date AS behospitalDate,
  17778. t1.leave_hospital_date AS leaveHospitalDate,
  17779. t1.placefile_date AS placefileDate,
  17780. t1.gmt_create AS gradeTime,
  17781. t1.diagnose,
  17782. t1.ward_name AS wardName,
  17783. t2.age,
  17784. t1.file_code AS fileCode,
  17785. t1.checkStatus,
  17786. t1.mrStatus,
  17787. t1.chName,
  17788. t1.mrName,
  17789. t1.chTime,
  17790. t1.mrTime
  17791. FROM
  17792. (
  17793. SELECT
  17794. be.*,
  17795. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17796. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17797. mci.check_name AS chName,
  17798. e.score_res as scoreBn,
  17799. hm_mci.check_name AS mrName,
  17800. mci.gmt_create AS chTime,
  17801. hm_mci.gmt_create AS mrTime
  17802. FROM
  17803. (
  17804. SELECT DISTINCT
  17805. a.hospital_id,
  17806. a.behospital_code,
  17807. a.bed_code,
  17808. a.file_code,
  17809. b.LEVEL,
  17810. b.grade_type,
  17811. b.score_res,
  17812. a.NAME,
  17813. a.sex,
  17814. a.beh_dept_id,
  17815. a.beh_dept_name,
  17816. a.birthday,
  17817. a.behospital_date,
  17818. a.leave_hospital_date,
  17819. a.doctor_id,
  17820. a.doctor_name,
  17821. a.beh_doctor_id,
  17822. a.beh_doctor_name,
  17823. a.director_doctor_id,
  17824. a.director_doctor_name,
  17825. a.diagnose,
  17826. a.placefile_date,
  17827. a.ward_name,
  17828. b.gmt_create
  17829. FROM
  17830. med_behospital_info a,
  17831. med_qcresult_info b,
  17832. sys_user_dept c
  17833. WHERE
  17834. a.is_deleted = 'N'
  17835. AND b.is_deleted = 'N'
  17836. AND c.is_deleted = 'N'
  17837. AND a.hospital_id = b.hospital_id
  17838. AND a.hospital_id = c.hospital_id
  17839. AND a.behospital_code = b.behospital_code
  17840. AND a.beh_dept_id = c.dept_id
  17841. AND a.qc_type_id != 0
  17842. <if test="qcResultShortPageVO.userId!=null">
  17843. AND c.user_id = #{qcResultShortPageVO.userId}
  17844. </if>
  17845. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17846. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17847. </if>
  17848. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17849. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17850. </if>
  17851. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17852. <if test="qcResultShortPageVO.startDate != null ">
  17853. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17854. </if>
  17855. <if test="qcResultShortPageVO.endDate != null ">
  17856. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17857. </if>
  17858. </if>
  17859. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17860. <if test="qcResultShortPageVO.startDate != null ">
  17861. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17862. </if>
  17863. <if test="qcResultShortPageVO.endDate != null">
  17864. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17865. </if>
  17866. </if>
  17867. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17868. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17869. </if>
  17870. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  17871. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  17872. </if>
  17873. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17874. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17875. </if>
  17876. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  17877. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  17878. </if>
  17879. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17880. AND c.`level` = #{qcResultShortPageVO.level}
  17881. </if>
  17882. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17883. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17884. </if>
  17885. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17886. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17887. </if>
  17888. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17889. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  17890. </if>
  17891. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17892. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  17893. </if>
  17894. ) be
  17895. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17896. AND mci.check_type = 0
  17897. AND be.hospital_id = mci.hospital_id
  17898. AND be.behospital_code = mci.behospital_code
  17899. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17900. AND hm_mci.check_type = 1
  17901. AND be.hospital_id = hm_mci.hospital_id
  17902. AND be.behospital_code = hm_mci.behospital_code
  17903. LEFT JOIN med_qcresult_cases e
  17904. on be.behospital_code = e.behospital_code
  17905. and be.hospital_id = e.hospital_id
  17906. AND e.is_deleted = 'N'
  17907. and e.cases_id = 243
  17908. ) t1
  17909. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17910. AND t1.behospital_code = t2.behospital_code
  17911. AND t2.is_deleted = 'N'
  17912. ) t
  17913. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17914. AND t.hospitalId = qi.hospital_id
  17915. AND t.behospitalCode = qi.behospital_code
  17916. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  17917. AND t.hospitalId = t2.hospital_id
  17918. AND t2.is_deleted = 'N'
  17919. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  17920. AND t3.is_deleted = 'N'
  17921. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17922. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17923. AND t.hospitalId = qd.hospital_id
  17924. AND t.behospitalCode = qd.behospital_code
  17925. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17926. AND qd.cases_id = qc.id
  17927. </if>
  17928. where 1=1
  17929. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  17930. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  17931. </if>
  17932. <if test="qcResultShortPageVO.checkStatus != null">
  17933. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17934. </if>
  17935. <if test="qcResultShortPageVO.mrStatus != null">
  17936. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17937. </if>
  17938. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17939. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17940. </if>
  17941. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17942. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17943. </if>
  17944. <if test="qcResultShortPageVO.chTimeStart != null ">
  17945. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17946. </if>
  17947. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17948. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17949. </if>
  17950. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17951. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17952. </if>
  17953. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17954. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17955. </if>
  17956. )f1,
  17957. (SELECT
  17958. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17959. t.behDeptId,
  17960. t.behDeptName,
  17961. t.doctorId,
  17962. t.doctorName
  17963. FROM
  17964. (
  17965. SELECT DISTINCT
  17966. t1.hospital_id AS hospitalId,
  17967. t1.behospital_code AS behospitalCode,
  17968. t1.bed_code AS bedCode,
  17969. t1.LEVEL AS LEVEL,
  17970. t1.grade_type AS gradeType,
  17971. t1.score_res AS scoreRes,
  17972. t1.NAME AS NAME,
  17973. t1.sex AS sex,
  17974. t1.beh_dept_id AS behDeptId,
  17975. t1.beh_dept_name AS behDeptName,
  17976. t1.doctor_id AS doctorId,
  17977. t1.doctor_name AS doctorName,
  17978. t1.beh_doctor_id AS behDoctorId,
  17979. t1.beh_doctor_name AS behDoctorName,
  17980. t1.director_doctor_id AS directorDoctorId,
  17981. t1.director_doctor_name AS directorDoctorName,
  17982. t1.birthday AS birthday,
  17983. t1.behospital_date AS behospitalDate,
  17984. t1.leave_hospital_date AS leaveHospitalDate,
  17985. t1.placefile_date AS placefileDate,
  17986. t1.gmt_create AS gradeTime,
  17987. t1.diagnose,
  17988. t1.ward_name AS wardName,
  17989. t2.age,
  17990. t1.file_code AS fileCode,
  17991. t1.checkStatus,
  17992. t1.mrStatus,
  17993. t1.chName,
  17994. t1.mrName,
  17995. t1.chTime,
  17996. t1.mrTime
  17997. FROM
  17998. (
  17999. SELECT
  18000. be.*,
  18001. ifnull( mci.STATUS, 0 ) AS checkStatus,
  18002. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  18003. mci.check_name AS chName,
  18004. hm_mci.check_name AS mrName,
  18005. mci.gmt_create AS chTime,
  18006. hm_mci.gmt_create AS mrTime
  18007. FROM
  18008. (
  18009. SELECT DISTINCT
  18010. a.hospital_id,
  18011. a.behospital_code,
  18012. a.bed_code,
  18013. a.file_code,
  18014. b.LEVEL,
  18015. b.grade_type,
  18016. b.score_res,
  18017. a.NAME,
  18018. a.sex,
  18019. a.beh_dept_id,
  18020. a.beh_dept_name,
  18021. a.birthday,
  18022. a.behospital_date,
  18023. a.leave_hospital_date,
  18024. a.doctor_id,
  18025. a.doctor_name,
  18026. a.beh_doctor_id,
  18027. a.beh_doctor_name,
  18028. a.director_doctor_id,
  18029. a.director_doctor_name,
  18030. a.diagnose,
  18031. a.placefile_date,
  18032. a.ward_name,
  18033. b.gmt_create
  18034. FROM
  18035. med_behospital_info a,
  18036. med_qcresult_info b,
  18037. sys_user_dept c
  18038. WHERE
  18039. a.is_deleted = 'N'
  18040. AND b.is_deleted = 'N'
  18041. AND c.is_deleted = 'N'
  18042. AND a.hospital_id = b.hospital_id
  18043. AND a.hospital_id = c.hospital_id
  18044. AND a.behospital_code = b.behospital_code
  18045. AND a.beh_dept_id = c.dept_id
  18046. AND a.qc_type_id != 0
  18047. <if test="qcResultShortPageVO.userId!=null">
  18048. AND c.user_id = #{qcResultShortPageVO.userId}
  18049. </if>
  18050. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  18051. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  18052. </if>
  18053. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  18054. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  18055. </if>
  18056. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  18057. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  18058. </if>
  18059. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  18060. <if test="qcResultShortPageVO.startDate != null ">
  18061. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  18062. </if>
  18063. <if test="qcResultShortPageVO.endDate != null ">
  18064. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  18065. </if>
  18066. </if>
  18067. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  18068. <if test="qcResultShortPageVO.startDate != null ">
  18069. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  18070. </if>
  18071. <if test="qcResultShortPageVO.endDate != null">
  18072. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  18073. </if>
  18074. </if>
  18075. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  18076. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  18077. </if>
  18078. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  18079. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  18080. </if>
  18081. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  18082. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  18083. </if>
  18084. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  18085. AND c.`level` = #{qcResultShortPageVO.level}
  18086. </if>
  18087. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  18088. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  18089. </if>
  18090. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  18091. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  18092. </if>
  18093. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  18094. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  18095. </if>
  18096. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  18097. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  18098. </if>
  18099. ) be
  18100. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  18101. AND mci.check_type = 0
  18102. AND be.hospital_id = mci.hospital_id
  18103. AND be.behospital_code = mci.behospital_code
  18104. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  18105. AND hm_mci.check_type = 1
  18106. AND be.hospital_id = hm_mci.hospital_id
  18107. AND be.behospital_code = hm_mci.behospital_code
  18108. ) t1
  18109. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  18110. AND t1.behospital_code = t2.behospital_code
  18111. AND t2.is_deleted = 'N'
  18112. ) t
  18113. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  18114. AND t.hospitalId = qi.hospital_id
  18115. AND t.behospitalCode = qi.behospital_code
  18116. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  18117. AND t.hospitalId = t2.hospital_id
  18118. AND t2.is_deleted = 'N'
  18119. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  18120. AND t3.is_deleted = 'N'
  18121. where 1=1
  18122. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  18123. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  18124. </if>
  18125. <if test="qcResultShortPageVO.checkStatus != null">
  18126. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  18127. </if>
  18128. <if test="qcResultShortPageVO.mrStatus != null">
  18129. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  18130. </if>
  18131. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  18132. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  18133. </if>
  18134. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  18135. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  18136. </if>
  18137. <if test="qcResultShortPageVO.chTimeStart != null ">
  18138. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  18139. </if>
  18140. <if test="qcResultShortPageVO.chTimeEnd != null ">
  18141. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  18142. </if>
  18143. <if test="qcResultShortPageVO.mrTimeStart != null ">
  18144. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  18145. </if>
  18146. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  18147. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  18148. </if>
  18149. GROUP BY
  18150. t.doctorId,
  18151. t.doctorName
  18152. )f2
  18153. WHERE
  18154. f1.doctorId = f2.doctorId
  18155. AND f1.doctorName = f2.doctorName
  18156. </select>
  18157. <!-- 入院,手术,出院病案情况-->
  18158. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18159. SELECT
  18160. count(
  18161. DISTINCT
  18162. CASE
  18163. WHEN q.type=5 THEN
  18164. a.behospital_code
  18165. ELSE
  18166. NULL
  18167. END
  18168. ) AS 'operationNote',
  18169. count(
  18170. DISTINCT
  18171. CASE
  18172. WHEN q.type = 4 THEN
  18173. a.behospital_code
  18174. ELSE
  18175. NULL
  18176. END
  18177. ) AS 'residentAdmitNote',
  18178. count(
  18179. DISTINCT
  18180. CASE
  18181. WHEN q.type = 6 THEN
  18182. a.behospital_code
  18183. ELSE
  18184. NULL
  18185. END
  18186. ) AS 'dischargeRecord',
  18187. count(
  18188. DISTINCT
  18189. CASE
  18190. WHEN q.type = 7 THEN
  18191. a.behospital_code
  18192. ELSE
  18193. NULL
  18194. END
  18195. ) AS 'medicalRecord'
  18196. FROM
  18197. (
  18198. SELECT
  18199. a.behospital_code,
  18200. a.cases_entry_id,
  18201. a.hospital_id
  18202. FROM
  18203. (
  18204. SELECT
  18205. a.behospital_code,
  18206. c.cases_entry_id,
  18207. a.hospital_id
  18208. FROM
  18209. (
  18210. SELECT
  18211. a.behospital_code,
  18212. a.hospital_id
  18213. FROM
  18214. med_behospital_info a,
  18215. med_qcresult_info c
  18216. WHERE
  18217. a.is_deleted = 'N'
  18218. AND c.is_deleted = 'N'
  18219. AND a.is_placefile = #{filterVO.isPlacefile}
  18220. <if test="filterVO.startDate != null and filterVO.endDate != null">
  18221. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  18222. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18223. </if>
  18224. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18225. AND a.behospital_code = c.behospital_code
  18226. AND a.hospital_id = #{filterVO.hospitalId}
  18227. AND a.hospital_id = c.hospital_id
  18228. ) a
  18229. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  18230. AND a.behospital_code = c.behospital_code
  18231. AND a.hospital_id = c.hospital_id
  18232. ) a
  18233. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  18234. AND d.is_deleted = 'N'
  18235. ) a
  18236. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  18237. AND a.hospital_id = q.hospital_id
  18238. </select>
  18239. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  18240. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18241. select
  18242. d.behospital_code behospitalCode,
  18243. b.operation_fee operationFee,
  18244. b.pathology_fee pathologyFee,
  18245. b.antibiosis_fee antibiosisFee
  18246. FROM
  18247. (
  18248. SELECT
  18249. a.behospital_code,
  18250. a.hospital_id,
  18251. a.behospital_date,
  18252. a.leave_hospital_date
  18253. FROM
  18254. med_behospital_info a,
  18255. med_qcresult_info c
  18256. WHERE
  18257. a.is_deleted = 'N'
  18258. AND c.is_deleted = 'N'
  18259. AND a.is_placefile = #{filterVO.isPlacefile}
  18260. <if test="filterVO.startDate != null and filterVO.endDate != null">
  18261. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  18262. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18263. </if>
  18264. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18265. AND a.hospital_id = c.hospital_id
  18266. AND a.hospital_id = #{filterVO.hospitalId}
  18267. and a.behospital_code = c.behospital_code
  18268. ) d
  18269. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18270. AND d.hospital_id = b.hospital_id
  18271. AND b.is_deleted = 'N'
  18272. </select>
  18273. <!-- 关于触发规则不符合人数-->
  18274. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18275. SELECT
  18276. count(
  18277. DISTINCT
  18278. CASE
  18279. WHEN a.type=5 THEN
  18280. a.behospital_code
  18281. ELSE
  18282. NULL
  18283. END
  18284. ) AS 'operationNote',
  18285. count(
  18286. DISTINCT
  18287. CASE
  18288. WHEN a.type = 4 THEN
  18289. a.behospital_code
  18290. ELSE
  18291. NULL
  18292. END
  18293. ) AS 'residentAdmitNote',
  18294. count(
  18295. DISTINCT
  18296. CASE
  18297. WHEN a.type = 6 THEN
  18298. a.behospital_code
  18299. ELSE
  18300. NULL
  18301. END
  18302. ) AS 'dischargeRecord',
  18303. count(
  18304. DISTINCT
  18305. CASE
  18306. WHEN a.type = 7 THEN
  18307. a.behospital_code
  18308. ELSE
  18309. NULL
  18310. END
  18311. ) AS 'medicalRecord',
  18312. count(
  18313. DISTINCT
  18314. CASE
  18315. WHEN a.type=8 THEN
  18316. a.behospital_code
  18317. ELSE
  18318. NULL
  18319. END
  18320. ) AS 'CT',
  18321. count(
  18322. DISTINCT
  18323. CASE
  18324. WHEN a.type = 9 THEN
  18325. a.behospital_code
  18326. ELSE
  18327. NULL
  18328. END
  18329. ) AS 'MR',
  18330. count(
  18331. DISTINCT
  18332. CASE
  18333. WHEN a.type = 10 THEN
  18334. a.behospital_code
  18335. ELSE
  18336. NULL
  18337. END
  18338. ) AS 'operationPathologyFee',
  18339. count(
  18340. DISTINCT
  18341. CASE
  18342. WHEN a.type = 11 THEN
  18343. a.behospital_code
  18344. ELSE
  18345. NULL
  18346. END
  18347. ) AS 'bacterialCulture',
  18348. count(
  18349. DISTINCT
  18350. CASE
  18351. WHEN a.type = 12 THEN
  18352. a.behospital_code
  18353. ELSE
  18354. NULL
  18355. END
  18356. ) AS 'antibiosis',
  18357. count(
  18358. DISTINCT
  18359. CASE
  18360. WHEN a.type = 13 THEN
  18361. a.behospital_code
  18362. ELSE
  18363. NULL
  18364. END
  18365. ) AS 'chemotherapyMalignantTumors',
  18366. count(
  18367. DISTINCT
  18368. CASE
  18369. WHEN a.type = 15 THEN
  18370. a.behospital_code
  18371. ELSE
  18372. NULL
  18373. END
  18374. ) AS 'operationRecordNum',
  18375. count(
  18376. DISTINCT
  18377. CASE
  18378. WHEN a.type = 17 THEN
  18379. a.behospital_code
  18380. ELSE
  18381. NULL
  18382. END
  18383. ) AS 'bloodNum',
  18384. count(
  18385. DISTINCT
  18386. CASE
  18387. WHEN a.type = 18 THEN
  18388. a.behospital_code
  18389. ELSE
  18390. NULL
  18391. END
  18392. ) AS 'WardRoundNum',
  18393. count(
  18394. DISTINCT
  18395. CASE
  18396. WHEN a.type = 19 THEN
  18397. a.behospital_code
  18398. ELSE
  18399. NULL
  18400. END
  18401. ) AS 'rescueNum',
  18402. count(
  18403. DISTINCT
  18404. CASE
  18405. WHEN a.type = 22 THEN
  18406. a.behospital_code
  18407. ELSE
  18408. NULL
  18409. END
  18410. ) AS 'unreasonedCopyNum',
  18411. count(
  18412. DISTINCT
  18413. CASE
  18414. WHEN a.type = 14 THEN
  18415. a.behospital_code
  18416. ELSE
  18417. NULL
  18418. END
  18419. ) AS 'tumorRadiationNum',
  18420. count(
  18421. DISTINCT
  18422. CASE
  18423. WHEN a.type = 16 THEN
  18424. a.behospital_code
  18425. ELSE
  18426. NULL
  18427. END
  18428. ) AS 'implantsNum',
  18429. count(
  18430. DISTINCT
  18431. CASE
  18432. WHEN a.type = 23 THEN
  18433. a.behospital_code
  18434. ELSE
  18435. NULL
  18436. END
  18437. ) AS 'InformedNum'
  18438. FROM
  18439. (
  18440. SELECT
  18441. a.behospital_code,
  18442. a.hospital_id,
  18443. q.type
  18444. FROM
  18445. (
  18446. SELECT
  18447. a.behospital_code,
  18448. a.cases_entry_id,
  18449. a.hospital_id
  18450. FROM
  18451. (
  18452. SELECT
  18453. a.behospital_code,
  18454. c.cases_entry_id,
  18455. a.hospital_id
  18456. FROM
  18457. (
  18458. SELECT
  18459. a.behospital_code,
  18460. a.hospital_id
  18461. FROM
  18462. med_behospital_info a,
  18463. med_qcresult_info c
  18464. WHERE
  18465. a.is_deleted = 'N'
  18466. AND c.is_deleted = 'N'
  18467. AND a.is_placefile = #{filterVO.isPlacefile}
  18468. <if test="filterVO.startDate != null and filterVO.endDate != null">
  18469. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  18470. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18471. </if>
  18472. AND a.behospital_code = c.behospital_code
  18473. AND a.hospital_id = #{filterVO.hospitalId}
  18474. AND a.hospital_id = c.hospital_id
  18475. ) a
  18476. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  18477. AND a.behospital_code = c.behospital_code
  18478. AND a.hospital_id = c.hospital_id
  18479. ) a
  18480. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  18481. AND d.is_deleted = 'N'
  18482. ) a
  18483. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  18484. AND a.hospital_id = q.hospital_id
  18485. ) a
  18486. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  18487. AND r.relevance_type = a.type
  18488. AND r.is_deleted = 'N'
  18489. AND a.hospital_id = r.hospital_id
  18490. </select>
  18491. <!-- 跟病案首页关联的出院病历-->
  18492. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18493. SELECT
  18494. d.behospital_code,
  18495. d.behospital_date,
  18496. d.leave_hospital_date,
  18497. b.behospital_code AS b_code,
  18498. b.operation_fee,
  18499. b.antibiosis_fee,
  18500. b.pathology_fee
  18501. FROM
  18502. (
  18503. SELECT
  18504. a.behospital_code,
  18505. a.hospital_id,
  18506. a.behospital_date,
  18507. a.leave_hospital_date
  18508. FROM
  18509. med_behospital_info a,
  18510. med_qcresult_info c
  18511. WHERE
  18512. a.behospital_code = c.behospital_code
  18513. AND a.hospital_id = #{filterVO.hospitalId}
  18514. AND a.is_placefile = #{filterVO.isPlacefile}
  18515. AND a.hospital_id = c.hospital_id
  18516. AND a.is_deleted = 'N'
  18517. AND c.is_deleted = 'N'
  18518. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18519. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  18520. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  18521. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18522. </if>
  18523. ) d
  18524. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18525. AND d.hospital_id = b.hospital_id
  18526. AND b.is_deleted = 'N'
  18527. where ISNULL(b.behospital_code)
  18528. </select>
  18529. <!-- 首页恶性肿瘤-->
  18530. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  18531. select
  18532. a.behospital_code,
  18533. a.hospital_id,
  18534. d.diagnose_name,
  18535. d.diagnose_type,
  18536. d.icd_code
  18537. from(
  18538. SELECT
  18539. d.behospital_code,
  18540. d.hospital_id,
  18541. b.home_page_id
  18542. FROM
  18543. (
  18544. SELECT
  18545. a.behospital_code,
  18546. a.hospital_id,
  18547. a.behospital_date,
  18548. a.leave_hospital_date
  18549. FROM
  18550. med_behospital_info a,
  18551. med_qcresult_info c
  18552. WHERE
  18553. a.behospital_code = c.behospital_code
  18554. AND a.hospital_id = #{filterVO.hospitalId}
  18555. AND a.is_placefile = #{filterVO.isPlacefile}
  18556. AND a.hospital_id = c.hospital_id
  18557. AND a.is_deleted = 'N'
  18558. AND c.is_deleted = 'N'
  18559. <![CDATA[ and a.qc_type_id <>'0' ]]>
  18560. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  18561. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  18562. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  18563. </if>
  18564. ) d
  18565. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  18566. AND d.hospital_id = b.hospital_id
  18567. AND b.is_deleted = 'N'
  18568. )a join
  18569. med_home_diagnose_info d on a.hospital_id=d.hospital_id
  18570. where a.home_page_id =d.home_page_id
  18571. and d.is_deleted ='N'
  18572. and d.diagnose_name like '%恶性肿瘤%'
  18573. and d.icd_code like 'C%'
  18574. </select>
  18575. <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
  18576. <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
  18577. SELECT
  18578. mbi.behospital_code behospitalCode,
  18579. mhp.age,
  18580. TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
  18581. TIMESTAMPDIFF(day,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageDay
  18582. FROM
  18583. med_behospital_info mbi
  18584. LEFT JOIN med_home_page mhp
  18585. ON mbi.behospital_code=mhp.behospital_code
  18586. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  18587. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
  18588. <if test="behospitalCodes !=null and behospitalCodes.size > 0">
  18589. and mbi.behospital_code in
  18590. <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
  18591. #{item}
  18592. </foreach>
  18593. </if>
  18594. </select>
  18595. </mapper>